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