Completed
Push — master ( a570d7...fa7953 )
by Jamie
09:28
created
classes/helpers/FrmFormsHelper.php 1 patch
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -12,38 +12,38 @@  discard block
 block discarded – undo
12 12
 
13 13
 	public static function get_direct_link( $key, $form = false ) {
14 14
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
15
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
-
17
-        return $target_url;
18
-    }
19
-
20
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
21
-        $defaults = array(
22
-            'blank'     => true,
23
-            'field_id'  => false,
24
-            'onchange'  => false,
25
-            'exclude'   => false,
26
-            'class'     => '',
15
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
+
17
+		return $target_url;
18
+	}
19
+
20
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
21
+		$defaults = array(
22
+			'blank'     => true,
23
+			'field_id'  => false,
24
+			'onchange'  => false,
25
+			'exclude'   => false,
26
+			'class'     => '',
27 27
 			'inc_children' => 'exclude',
28
-        );
29
-        $args = wp_parse_args( $args, $defaults );
28
+		);
29
+		$args = wp_parse_args( $args, $defaults );
30 30
 
31
-        if ( ! $args['field_id'] ) {
32
-            $args['field_id'] = $field_name;
33
-        }
31
+		if ( ! $args['field_id'] ) {
32
+			$args['field_id'] = $field_name;
33
+		}
34 34
 
35 35
 		$query = array();
36
-        if ( $args['exclude'] ) {
36
+		if ( $args['exclude'] ) {
37 37
 			$query['id !'] = $args['exclude'];
38
-        }
38
+		}
39 39
 
40
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
40
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
41 41
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
42 42
 		$add_html = array();
43 43
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
44 44
 		self::add_html_attr( $args['class'], 'class', $add_html );
45 45
 
46
-        ?>
46
+		?>
47 47
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
48 48
 		<?php if ( $args['blank'] ) { ?>
49 49
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		<?php } ?>
56 56
         </select>
57 57
         <?php
58
-    }
58
+	}
59 59
 
60 60
 	/**
61 61
 	 * @param string $class
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 	}
72 72
 
73
-    public static function form_switcher() {
73
+	public static function form_switcher() {
74 74
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
75 75
 		$forms = FrmForm::get_published_forms( $where );
76 76
 
@@ -79,32 +79,32 @@  discard block
 block discarded – undo
79 79
 			unset( $args['form'] );
80 80
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
81 81
 			unset( $args['id'] );
82
-        }
82
+		}
83 83
 
84 84
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
85 85
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
86
-            $args['frm_action'] = 'list';
87
-            $args['form'] = 0;
86
+			$args['frm_action'] = 'list';
87
+			$args['form'] = 0;
88 88
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
89
-            $args['frm_action'] = 'edit';
89
+			$args['frm_action'] = 'edit';
90 90
 		} else if ( isset( $_GET['post'] ) ) {
91
-            $args['form'] = 0;
92
-            $base = admin_url('edit.php?post_type=frm_display');
93
-        }
91
+			$args['form'] = 0;
92
+			$base = admin_url('edit.php?post_type=frm_display');
93
+		}
94 94
 
95
-        ?>
95
+		?>
96 96
 		<li class="dropdown last" id="frm_bs_dropdown">
97 97
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
98 98
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
99 99
 			<?php
100 100
 			foreach ( $forms as $form ) {
101 101
 				if ( isset( $args['id'] ) ) {
102
-			        $args['id'] = $form->id;
102
+					$args['id'] = $form->id;
103 103
 				}
104
-			    if ( isset( $args['form'] ) ) {
105
-			        $args['form'] = $form->id;
104
+				if ( isset( $args['form'] ) ) {
105
+					$args['form'] = $form->id;
106 106
 				}
107
-                ?>
107
+				?>
108 108
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
109 109
 			<?php
110 110
 				unset( $form );
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 			</ul>
113 113
 		</li>
114 114
         <?php
115
-    }
115
+	}
116 116
 
117 117
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
118
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
-    }
118
+		echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
+		echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
+	}
121 121
 
122 122
 	/**
123 123
 	 * Get the invalid form error message
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param array $args
127 127
 	 * @return string
128 128
 	 */
129
-    public static function get_invalid_error_message( $args ) {
129
+	public static function get_invalid_error_message( $args ) {
130 130
 		$frm_settings = FrmAppHelper::get_settings();
131 131
 
132 132
 		$invalid_msg = apply_filters( 'frm_invalid_error_message', $frm_settings->invalid_msg, $args );
@@ -141,110 +141,110 @@  discard block
 block discarded – undo
141 141
 		return $message;
142 142
 	}
143 143
 
144
-    /**
145
-     * Used when a form is created
146
-     */
147
-    public static function setup_new_vars( $values = array() ) {
148
-        global $wpdb;
144
+	/**
145
+	 * Used when a form is created
146
+	 */
147
+	public static function setup_new_vars( $values = array() ) {
148
+		global $wpdb;
149 149
 
150
-        if ( ! empty( $values ) ) {
151
-            $post_values = $values;
152
-        } else {
153
-            $values = array();
154
-            $post_values = isset($_POST) ? $_POST : array();
155
-        }
150
+		if ( ! empty( $values ) ) {
151
+			$post_values = $values;
152
+		} else {
153
+			$values = array();
154
+			$post_values = isset($_POST) ? $_POST : array();
155
+		}
156 156
 
157 157
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
158 158
 			if ( ! isset( $values[ $var ] ) ) {
159 159
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
160
-            }
161
-        }
160
+			}
161
+		}
162 162
 
163
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
163
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
164 164
 
165 165
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
166
-            if ( ! isset( $values[ $var ] ) ) {
166
+			if ( ! isset( $values[ $var ] ) ) {
167 167
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
168
-            }
169
-        }
168
+			}
169
+		}
170 170
 
171
-        if ( ! isset( $values['form_key'] ) ) {
171
+		if ( ! isset( $values['form_key'] ) ) {
172 172
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
173
-        }
173
+		}
174 174
 
175
-        $values = self::fill_default_opts($values, false, $post_values);
175
+		$values = self::fill_default_opts($values, false, $post_values);
176 176
 
177
-        if ( $post_values && isset($post_values['options']['custom_style']) ) {
178
-            $values['custom_style'] = $post_values['options']['custom_style'];
179
-        } else {
180
-            $frm_settings = FrmAppHelper::get_settings();
181
-            $values['custom_style'] = ( $frm_settings->load_style != 'none' );
182
-        }
177
+		if ( $post_values && isset($post_values['options']['custom_style']) ) {
178
+			$values['custom_style'] = $post_values['options']['custom_style'];
179
+		} else {
180
+			$frm_settings = FrmAppHelper::get_settings();
181
+			$values['custom_style'] = ( $frm_settings->load_style != 'none' );
182
+		}
183 183
 
184
-        return apply_filters('frm_setup_new_form_vars', $values);
185
-    }
184
+		return apply_filters('frm_setup_new_form_vars', $values);
185
+	}
186 186
 
187
-    /**
188
-     * Used when editing a form
189
-     */
190
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
187
+	/**
188
+	 * Used when editing a form
189
+	 */
190
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
191 191
 		if ( empty( $post_values ) ) {
192 192
 			$post_values = stripslashes_deep( $_POST );
193 193
 		}
194 194
 
195
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
196
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
197
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
198
-        $values['status'] = $record->status;
195
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
196
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
197
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
198
+		$values['status'] = $record->status;
199 199
 
200
-        $values = self::fill_default_opts($values, $record, $post_values);
200
+		$values = self::fill_default_opts($values, $record, $post_values);
201 201
 
202
-        return apply_filters('frm_setup_edit_form_vars', $values);
203
-    }
202
+		return apply_filters('frm_setup_edit_form_vars', $values);
203
+	}
204 204
 
205 205
 	public static function fill_default_opts( $values, $record, $post_values ) {
206 206
 
207
-        $defaults = self::get_default_opts();
207
+		$defaults = self::get_default_opts();
208 208
 		foreach ( $defaults as $var => $default ) {
209
-            if ( is_array($default) ) {
210
-                if ( ! isset( $values[ $var ] ) ) {
209
+			if ( is_array($default) ) {
210
+				if ( ! isset( $values[ $var ] ) ) {
211 211
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
212
-                }
212
+				}
213 213
 
214
-                foreach ( $default as $k => $v ) {
214
+				foreach ( $default as $k => $v ) {
215 215
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
216 216
 
217
-                    if ( is_array( $v ) ) {
218
-                        foreach ( $v as $k1 => $v1 ) {
217
+					if ( is_array( $v ) ) {
218
+						foreach ( $v as $k1 => $v1 ) {
219 219
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
220
-                            unset( $k1, $v1 );
221
-                        }
222
-                    }
220
+							unset( $k1, $v1 );
221
+						}
222
+					}
223 223
 
224
-                    unset($k, $v);
225
-                }
226
-            } else {
224
+					unset($k, $v);
225
+				}
226
+			} else {
227 227
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
228
-            }
228
+			}
229 229
 
230
-            unset($var, $default);
231
-        }
230
+			unset($var, $default);
231
+		}
232 232
 
233
-        return $values;
234
-    }
233
+		return $values;
234
+	}
235 235
 
236
-    public static function get_default_opts() {
237
-        $frm_settings = FrmAppHelper::get_settings();
236
+	public static function get_default_opts() {
237
+		$frm_settings = FrmAppHelper::get_settings();
238 238
 
239
-        return array(
240
-            'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
241
-            'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
242
-            'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
243
-            'before_html' => self::get_default_html('before'),
244
-            'after_html' => '',
245
-            'submit_html' => self::get_default_html('submit'),
246
-        );
247
-    }
239
+		return array(
240
+			'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
241
+			'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
242
+			'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
243
+			'before_html' => self::get_default_html('before'),
244
+			'after_html' => '',
245
+			'submit_html' => self::get_default_html('submit'),
246
+		);
247
+	}
248 248
 
249 249
 	/**
250 250
 	 * @param array $options
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 		}
260 260
 	}
261 261
 
262
-    /**
263
-     * @param string $loc
264
-     */
262
+	/**
263
+	 * @param string $loc
264
+	 */
265 265
 	public static function get_default_html( $loc ) {
266 266
 		if ( $loc == 'submit' ) {
267
-            $sending = __( 'Sending', 'formidable' );
268
-            $draft_link = self::get_draft_link();
269
-            $img = '[frmurl]/images/ajax_loader.gif';
270
-            $default_html = <<<SUBMIT_HTML
267
+			$sending = __( 'Sending', 'formidable' );
268
+			$draft_link = self::get_draft_link();
269
+			$img = '[frmurl]/images/ajax_loader.gif';
270
+			$default_html = <<<SUBMIT_HTML
271 271
 <div class="frm_submit">
272 272
 [if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button]
273 273
 <input type="submit" value="[button_label]" [button_action] />
@@ -276,49 +276,49 @@  discard block
 block discarded – undo
276 276
 </div>
277 277
 SUBMIT_HTML;
278 278
 		} else if ( $loc == 'before' ) {
279
-            $default_html = <<<BEFORE_HTML
279
+			$default_html = <<<BEFORE_HTML
280 280
 <legend class="frm_hidden">[form_name]</legend>
281 281
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
282 282
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
283 283
 BEFORE_HTML;
284 284
 		} else {
285
-            $default_html = '';
286
-        }
285
+			$default_html = '';
286
+		}
287 287
 
288
-        return $default_html;
289
-    }
288
+		return $default_html;
289
+	}
290 290
 
291
-    public static function get_draft_link() {
292
-        $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
293
-        return $link;
294
-    }
291
+	public static function get_draft_link() {
292
+		$link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
293
+		return $link;
294
+	}
295 295
 
296 296
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
297
-        $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
298
-        if ( ! strpos($button, '[button_action]') ) {
299
-            return;
300
-        }
297
+		$button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
298
+		if ( ! strpos($button, '[button_action]') ) {
299
+			return;
300
+		}
301 301
 
302
-        $button_parts = explode('[button_action]', $button);
303
-        echo $button_parts[0];
304
-        //echo ' id="frm_submit_"';
302
+		$button_parts = explode('[button_action]', $button);
303
+		echo $button_parts[0];
304
+		//echo ' id="frm_submit_"';
305 305
 
306
-        $classes = apply_filters('frm_submit_button_class', array(), $form);
307
-        if ( ! empty($classes) ) {
306
+		$classes = apply_filters('frm_submit_button_class', array(), $form);
307
+		if ( ! empty($classes) ) {
308 308
 			echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
309
-        }
310
-
311
-        do_action('frm_submit_button_action', $form, $form_action);
312
-        echo $button_parts[1];
313
-    }
314
-
315
-    /**
316
-     * Automatically add end section fields if they don't exist (2.0 migration)
317
-     * @since 2.0
318
-     *
319
-     * @param boolean $reset_fields
320
-     */
321
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
309
+		}
310
+
311
+		do_action('frm_submit_button_action', $form, $form_action);
312
+		echo $button_parts[1];
313
+	}
314
+
315
+	/**
316
+	 * Automatically add end section fields if they don't exist (2.0 migration)
317
+	 * @since 2.0
318
+	 *
319
+	 * @param boolean $reset_fields
320
+	 */
321
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
322 322
 		if ( empty( $fields ) ) {
323 323
 			return;
324 324
 		}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$open = $prev_order = false;
328 328
 		$add_order = 0;
329 329
 		$last_field = false;
330
-        foreach ( $fields as $field ) {
330
+		foreach ( $fields as $field ) {
331 331
 			if ( $prev_order === $field->field_order ) {
332 332
 				$add_order++;
333 333
 			}
@@ -338,48 +338,48 @@  discard block
 block discarded – undo
338 338
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
339 339
 			}
340 340
 
341
-            switch ( $field->type ) {
342
-                case 'divider':
343
-                    // create an end section if open
341
+			switch ( $field->type ) {
342
+				case 'divider':
343
+					// create an end section if open
344 344
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
345 345
 
346
-                    // mark it open for the next end section
347
-                    $open = true;
348
-                break;
349
-                case 'break';
346
+					// mark it open for the next end section
347
+					$open = true;
348
+				break;
349
+				case 'break';
350 350
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
351
-                break;
352
-                case 'end_divider':
353
-                    if ( ! $open ) {
354
-                        // the section isn't open, so this is an extra field that needs to be removed
355
-                        FrmField::destroy( $field->id );
356
-                        $reset_fields = true;
357
-                    }
358
-
359
-                    // There is already an end section here, so there is no need to create one
360
-                    $open = false;
361
-            }
351
+				break;
352
+				case 'end_divider':
353
+					if ( ! $open ) {
354
+						// the section isn't open, so this is an extra field that needs to be removed
355
+						FrmField::destroy( $field->id );
356
+						$reset_fields = true;
357
+					}
358
+
359
+					// There is already an end section here, so there is no need to create one
360
+					$open = false;
361
+			}
362 362
 			$prev_order = $field->field_order;
363 363
 
364 364
 			$last_field = $field;
365 365
 			unset( $field );
366
-        }
366
+		}
367 367
 
368 368
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
369
-    }
369
+	}
370 370
 
371 371
 	/**
372 372
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
373 373
 	 * Fix any ordering that may be messed up
374 374
 	 */
375 375
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
376
-        if ( ! $open ) {
377
-            return;
378
-        }
376
+		if ( ! $open ) {
377
+			return;
378
+		}
379 379
 
380 380
 		$end_section_values['field_order'] = $field->field_order + 1;
381 381
 
382
-        FrmField::create( $end_section_values );
382
+		FrmField::create( $end_section_values );
383 383
 
384 384
 		if ( $move == 'move' ) {
385 385
 			// bump the order of current field unless we're at the end of the form
@@ -387,39 +387,39 @@  discard block
 block discarded – undo
387 387
 		}
388 388
 
389 389
 		$add_order += 2;
390
-        $open = false;
391
-        $reset_fields = true;
392
-    }
390
+		$open = false;
391
+		$reset_fields = true;
392
+	}
393 393
 
394
-    public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
394
+	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
395 395
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
396
-            if ( $code == 'form_name' ) {
397
-                $replace_with = $form->name;
398
-            } else if ( $code == 'form_description' ) {
399
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
400
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
401
-                $replace_with = FrmAppHelper::simple_get( 'entry' );
402
-            } else {
403
-                $replace_with = '';
404
-            }
396
+			if ( $code == 'form_name' ) {
397
+				$replace_with = $form->name;
398
+			} else if ( $code == 'form_description' ) {
399
+				$replace_with = FrmAppHelper::use_wpautop($form->description);
400
+			} else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
401
+				$replace_with = FrmAppHelper::simple_get( 'entry' );
402
+			} else {
403
+				$replace_with = '';
404
+			}
405 405
 
406
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
407
-        }
406
+			FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
407
+		}
408 408
 
409
-        //replace [form_key]
410
-        $html = str_replace('[form_key]', $form->form_key, $html);
409
+		//replace [form_key]
410
+		$html = str_replace('[form_key]', $form->form_key, $html);
411 411
 
412
-        //replace [frmurl]
413
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
412
+		//replace [frmurl]
413
+		$html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
414 414
 
415 415
 		if ( strpos( $html, '[button_label]' ) ) {
416 416
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
417 417
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
418 418
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
419 419
 			$html = str_replace( '[button_label]', $submit_label, $html );
420
-        }
420
+		}
421 421
 
422
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
422
+		$html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
423 423
 
424 424
 		if ( strpos( $html, '[if back_button]' ) ) {
425 425
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -433,32 +433,32 @@  discard block
 block discarded – undo
433 433
 			$html = do_shortcode( $html );
434 434
 		}
435 435
 
436
-        return $html;
437
-    }
436
+		return $html;
437
+	}
438 438
 
439 439
 	public static function submit_button_label( $submit ) {
440
-        if ( ! $submit || empty($submit) ) {
441
-            $frm_settings = FrmAppHelper::get_settings();
442
-            $submit = $frm_settings->submit_value;
443
-        }
440
+		if ( ! $submit || empty($submit) ) {
441
+			$frm_settings = FrmAppHelper::get_settings();
442
+			$submit = $frm_settings->submit_value;
443
+		}
444 444
 
445
-        return $submit;
446
-    }
445
+		return $submit;
446
+	}
447 447
 
448 448
 	public static function get_form_style_class( $form = false ) {
449
-        $style = self::get_form_style($form);
450
-        $class = ' with_frm_style';
451
-
452
-        if ( empty($style) ) {
453
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
454
-                return $class;
455
-            } else {
456
-                return;
457
-            }
458
-        }
459
-
460
-        //If submit button needs to be inline or centered
461
-        if ( is_object($form) ) {
449
+		$style = self::get_form_style($form);
450
+		$class = ' with_frm_style';
451
+
452
+		if ( empty($style) ) {
453
+			if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
454
+				return $class;
455
+			} else {
456
+				return;
457
+			}
458
+		}
459
+
460
+		//If submit button needs to be inline or centered
461
+		if ( is_object($form) ) {
462 462
 			$form = $form->options;
463 463
 		}
464 464
 
@@ -470,17 +470,17 @@  discard block
 block discarded – undo
470 470
 			$class .= ' frm_center_submit';
471 471
 		}
472 472
 
473
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
473
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
474 474
 
475
-        return $class;
476
-    }
475
+		return $class;
476
+	}
477 477
 
478
-    /**
479
-     * @param string|boolean $form
480
-     *
481
-     * @return string
482
-     */
483
-    public static function get_form_style( $form ) {
478
+	/**
479
+	 * @param string|boolean $form
480
+	 *
481
+	 * @return string
482
+	 */
483
+	public static function get_form_style( $form ) {
484 484
 		$style = 1;
485 485
 		if ( empty( $form ) || 'default' == 'form' ) {
486 486
 			return $style;
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
501 501
 
502 502
 		return $style;
503
-    }
503
+	}
504 504
 
505 505
 	/**
506 506
 	 * Display the validation error messages when an entry is submitted
@@ -555,74 +555,74 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function get_scroll_js( $form_id ) {
558
-        ?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
559
-    }
558
+		?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
559
+	}
560 560
 
561 561
 	public static function edit_form_link( $form_id ) {
562
-        if ( is_object($form_id) ) {
563
-            $form = $form_id;
564
-            $name = $form->name;
565
-            $form_id = $form->id;
566
-        } else {
567
-            $name = FrmForm::getName($form_id);
568
-        }
569
-
570
-        if ( $form_id ) {
562
+		if ( is_object($form_id) ) {
563
+			$form = $form_id;
564
+			$name = $form->name;
565
+			$form_id = $form->id;
566
+		} else {
567
+			$name = FrmForm::getName($form_id);
568
+		}
569
+
570
+		if ( $form_id ) {
571 571
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
572
-	    } else {
573
-	        $val = '';
574
-	    }
572
+		} else {
573
+			$val = '';
574
+		}
575 575
 
576
-	    return $val;
576
+		return $val;
577 577
 	}
578 578
 
579 579
 	public static function delete_trash_link( $id, $status, $length = 'long' ) {
580
-        $link = '';
581
-        $labels = array(
582
-            'restore' => array(
583
-                'long'  => __( 'Restore from Trash', 'formidable' ),
584
-                'short' => __( 'Restore', 'formidable' ),
585
-            ),
586
-            'trash' => array(
587
-                'long'  => __( 'Move to Trash', 'formidable' ),
588
-                'short' => __( 'Trash', 'formidable' ),
589
-            ),
590
-            'delete' => array(
591
-                'long'  => __( 'Delete Permanently', 'formidable' ),
592
-                'short' => __( 'Delete', 'formidable' ),
593
-            ),
594
-        );
595
-
596
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
580
+		$link = '';
581
+		$labels = array(
582
+			'restore' => array(
583
+				'long'  => __( 'Restore from Trash', 'formidable' ),
584
+				'short' => __( 'Restore', 'formidable' ),
585
+			),
586
+			'trash' => array(
587
+				'long'  => __( 'Move to Trash', 'formidable' ),
588
+				'short' => __( 'Trash', 'formidable' ),
589
+			),
590
+			'delete' => array(
591
+				'long'  => __( 'Delete Permanently', 'formidable' ),
592
+				'short' => __( 'Delete', 'formidable' ),
593
+			),
594
+		);
595
+
596
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
597 597
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
598
-        if ( 'trash' == $status ) {
598
+		if ( 'trash' == $status ) {
599 599
 			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
600
-        } else if ( current_user_can('frm_delete_forms') ) {
601
-            if ( EMPTY_TRASH_DAYS ) {
600
+		} else if ( current_user_can('frm_delete_forms') ) {
601
+			if ( EMPTY_TRASH_DAYS ) {
602 602
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
603
-            } else {
603
+			} else {
604 604
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
605
-            }
606
-        }
605
+			}
606
+		}
607 607
 
608
-        return $link;
609
-    }
608
+		return $link;
609
+	}
610 610
 
611 611
 	public static function status_nice_name( $status ) {
612
-        $nice_names = array(
613
-            'draft'     => __( 'Draft', 'formidable' ),
614
-            'trash'     => __( 'Trash', 'formidable' ),
615
-            'publish'   => __( 'Published', 'formidable' ),
616
-        );
617
-
618
-        if ( ! in_array($status, array_keys($nice_names)) ) {
619
-            $status = 'publish';
620
-        }
612
+		$nice_names = array(
613
+			'draft'     => __( 'Draft', 'formidable' ),
614
+			'trash'     => __( 'Trash', 'formidable' ),
615
+			'publish'   => __( 'Published', 'formidable' ),
616
+		);
617
+
618
+		if ( ! in_array($status, array_keys($nice_names)) ) {
619
+			$status = 'publish';
620
+		}
621 621
 
622 622
 		$name = $nice_names[ $status ];
623 623
 
624
-        return $name;
625
-    }
624
+		return $name;
625
+	}
626 626
 
627 627
 	public static function get_params() {
628 628
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
Please login to merge, or discard this patch.