Completed
Push — master ( facbef...904b92 )
by Stephanie
03:55
created
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 class FrmAddonsController {
4 4
 
5 5
 	public static function menu() {
6
-		add_submenu_page( 'formidable', 'Formidable | '. __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
6
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
7 7
 
8 8
 		$affiliate = FrmAppHelper::get_affiliate();
9 9
 		if ( ! empty( $affiliate ) && ! FrmAppHelper::pro_is_installed() ) {
10
-			add_submenu_page( 'formidable', 'Formidable | '. __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' );
10
+			add_submenu_page( 'formidable', 'Formidable | ' . __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' );
11 11
 		}
12 12
 	}
13 13
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$keyed_addons = array();
41 41
 		foreach ( $addons as $addon ) {
42
-			$keyed_addons[ $addon['info']['slug'] ] = $addon;
42
+			$keyed_addons[$addon['info']['slug']] = $addon;
43 43
 		}
44 44
 
45 45
 		$plugin_order = array(
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		);
49 49
 		$ordered_addons = array();
50 50
 		foreach ( $plugin_order as $plugin ) {
51
-			if ( isset( $keyed_addons[ $plugin ] ) ) {
52
-				$ordered_addons[] = $keyed_addons[ $plugin ];
53
-				unset( $keyed_addons[ $plugin ] );
51
+			if ( isset( $keyed_addons[$plugin] ) ) {
52
+				$ordered_addons[] = $keyed_addons[$plugin];
53
+				unset( $keyed_addons[$plugin] );
54 54
 			}
55 55
 		}
56 56
 		$addons = $ordered_addons + $keyed_addons;
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	public static function get_licenses() {
88
-		FrmAppHelper::permission_check('frm_change_settings');
88
+		FrmAppHelper::permission_check( 'frm_change_settings' );
89 89
 		check_ajax_referer( 'frm_ajax', 'nonce' );
90 90
 
91
-		$license = get_option('frmpro-credentials');
91
+		$license = get_option( 'frmpro-credentials' );
92 92
 		if ( $license && is_array( $license ) && isset( $license['license'] ) ) {
93
-			$url = 'http://formidablepro.com/frm-edd-api/licenses?l='. urlencode( base64_encode( $license['license'] ) );
93
+			$url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) );
94 94
 			$licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) );
95 95
 			echo json_encode( $licenses );
96 96
 		}
Please login to merge, or discard this patch.
classes/controllers/FrmAppController.php 2 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 class FrmAppController {
4 4
 
5 5
 	public static function menu() {
6
-        FrmAppHelper::maybe_add_permissions();
7
-        if ( ! current_user_can( 'frm_view_forms' ) ) {
8
-            return;
9
-        }
6
+		FrmAppHelper::maybe_add_permissions();
7
+		if ( ! current_user_can( 'frm_view_forms' ) ) {
8
+			return;
9
+		}
10 10
 
11
-        $frm_settings = FrmAppHelper::get_settings();
12
-        add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() );
13
-    }
11
+		$frm_settings = FrmAppHelper::get_settings();
12
+		add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() );
13
+	}
14 14
 
15 15
 	private static function get_menu_position() {
16 16
 		$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
@@ -19,39 +19,39 @@  discard block
 block discarded – undo
19 19
 		return $pos;
20 20
 	}
21 21
 
22
-    public static function load_wp_admin_style() {
23
-        FrmAppHelper::load_font_style();
24
-    }
22
+	public static function load_wp_admin_style() {
23
+		FrmAppHelper::load_font_style();
24
+	}
25 25
 
26 26
 	public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
27
-        global $pagenow, $frm_vars;
27
+		global $pagenow, $frm_vars;
28 28
 
29 29
 		$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
30
-        if ( empty( $show_nav ) ) {
31
-            return;
32
-        }
30
+		if ( empty( $show_nav ) ) {
31
+			return;
32
+		}
33 33
 
34 34
 		$current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
35 35
 		if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
36 36
 			$current_page = 'frm_display';
37 37
 		}
38 38
 
39
-        if ( $form ) {
39
+		if ( $form ) {
40 40
 			FrmForm::maybe_get_form( $form );
41 41
 
42
-            if ( is_object( $form ) ) {
43
-                $id = $form->id;
44
-            }
45
-        }
42
+			if ( is_object( $form ) ) {
43
+				$id = $form->id;
44
+			}
45
+		}
46 46
 
47
-        if ( ! isset( $id ) ) {
48
-            $form = $id = false;
49
-        }
47
+		if ( ! isset( $id ) ) {
48
+			$form = $id = false;
49
+		}
50 50
 
51 51
 		$nav_items = self::get_form_nav_items( $id );
52 52
 
53
-        include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
-    }
53
+		include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
+	}
55 55
 
56 56
 	private static function get_form_nav_items( $id ) {
57 57
 		$nav_items = array(
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
 		return $nav_items;
83 83
 	}
84 84
 
85
-    // Adds a settings link to the plugins page
86
-    public static function settings_link( $links ) {
85
+	// Adds a settings link to the plugins page
86
+	public static function settings_link( $links ) {
87 87
 		$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
88
-        array_unshift( $links, $settings );
88
+		array_unshift( $links, $settings );
89 89
 
90
-        return $links;
91
-    }
90
+		return $links;
91
+	}
92 92
 
93
-    public static function pro_get_started_headline() {
93
+	public static function pro_get_started_headline() {
94 94
 		self::maybe_show_upgrade_bar();
95 95
 
96
-        // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
-        if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
-            return;
99
-        }
96
+		// Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
+		if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
+			return;
99
+		}
100 100
 
101 101
 		if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) {
102
-            FrmAppHelper::load_admin_wide_js();
102
+			FrmAppHelper::load_admin_wide_js();
103 103
 
104
-            // user is authorized, but running free version
105
-            $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
-        ?>
104
+			// user is authorized, but running free version
105
+			$inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
+		?>
107 107
 <div class="error" class="frm_previous_install">
108 108
 		<?php
109 109
 		echo wp_kses_post( apply_filters( 'frm_pro_update_msg',
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 		) ); ?>
116 116
 </div>
117 117
 <?php
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121 121
 	private static function maybe_show_upgrade_bar() {
122 122
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 	}
217 217
 
218
-    public static function admin_js() {
218
+	public static function admin_js() {
219 219
 		$version = FrmAppHelper::plugin_version();
220 220
 		FrmAppHelper::load_admin_wide_js( false );
221 221
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 			'bootstrap_tooltip', 'bootstrap-multiselect',
227 227
 		), $version, true );
228 228
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
229
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
229
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
230 230
 
231 231
 		// load multselect js
232 232
 		wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
@@ -237,78 +237,78 @@  discard block
 block discarded – undo
237 237
 		global $pagenow;
238 238
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
239 239
 
240
-            wp_enqueue_script( 'admin-widgets' );
241
-            wp_enqueue_style( 'widgets' );
242
-            wp_enqueue_script( 'formidable' );
243
-            wp_enqueue_script( 'formidable_admin' );
240
+			wp_enqueue_script( 'admin-widgets' );
241
+			wp_enqueue_style( 'widgets' );
242
+			wp_enqueue_script( 'formidable' );
243
+			wp_enqueue_script( 'formidable_admin' );
244 244
 			FrmAppHelper::localize_script( 'admin' );
245 245
 
246
-            wp_enqueue_style( 'formidable-admin' );
247
-            add_thickbox();
246
+			wp_enqueue_style( 'formidable-admin' );
247
+			add_thickbox();
248 248
 
249
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
249
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
250 250
 
251
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
252
-            if ( isset( $_REQUEST['post_type'] ) ) {
253
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
251
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
252
+			if ( isset( $_REQUEST['post_type'] ) ) {
253
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
254 254
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
255 255
 				$post = get_post( absint( $_REQUEST['post'] ) );
256
-                if ( ! $post ) {
257
-                    return;
258
-                }
259
-                $post_type = $post->post_type;
260
-            } else {
261
-                return;
262
-            }
263
-
264
-            if ( $post_type == 'frm_display' ) {
265
-                wp_enqueue_script( 'jquery-ui-draggable' );
266
-                wp_enqueue_script( 'formidable_admin' );
267
-                wp_enqueue_style( 'formidable-admin' );
256
+				if ( ! $post ) {
257
+					return;
258
+				}
259
+				$post_type = $post->post_type;
260
+			} else {
261
+				return;
262
+			}
263
+
264
+			if ( $post_type == 'frm_display' ) {
265
+				wp_enqueue_script( 'jquery-ui-draggable' );
266
+				wp_enqueue_script( 'formidable_admin' );
267
+				wp_enqueue_style( 'formidable-admin' );
268 268
 				FrmAppHelper::localize_script( 'admin' );
269
-            }
270
-        } else if ( $pagenow == 'widgets.php' ) {
271
-            FrmAppHelper::load_admin_wide_js();
272
-        }
273
-    }
274
-
275
-    public static function wp_admin_body_class( $classes ) {
276
-        global $wp_version;
277
-        //we need this class everywhere in the admin for the menu
278
-        if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
279
-            $classes .= ' frm_38_trigger';
280
-        }
281
-
282
-        return $classes;
283
-    }
284
-
285
-    public static function load_lang() {
286
-        load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
287
-    }
288
-
289
-    /**
290
-     * Filter shortcodes in text widgets
291
-     */
292
-    public static function widget_text_filter( $content ) {
293
-    	$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
294
-    	return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
295
-    }
296
-
297
-    public static function widget_text_filter_callback( $matches ) {
298
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
299
-        return FrmAppHelper::widget_text_filter_callback( $matches );
300
-    }
301
-
302
-    public static function front_head() {
303
-        if ( is_multisite() ) {
304
-            $old_db_version = get_option( 'frm_db_version' );
305
-            $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
306
-            if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
307
-                ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
308
-                self::install( $old_db_version );
309
-            }
310
-        }
311
-    }
269
+			}
270
+		} else if ( $pagenow == 'widgets.php' ) {
271
+			FrmAppHelper::load_admin_wide_js();
272
+		}
273
+	}
274
+
275
+	public static function wp_admin_body_class( $classes ) {
276
+		global $wp_version;
277
+		//we need this class everywhere in the admin for the menu
278
+		if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
279
+			$classes .= ' frm_38_trigger';
280
+		}
281
+
282
+		return $classes;
283
+	}
284
+
285
+	public static function load_lang() {
286
+		load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
287
+	}
288
+
289
+	/**
290
+	 * Filter shortcodes in text widgets
291
+	 */
292
+	public static function widget_text_filter( $content ) {
293
+		$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
294
+		return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
295
+	}
296
+
297
+	public static function widget_text_filter_callback( $matches ) {
298
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
299
+		return FrmAppHelper::widget_text_filter_callback( $matches );
300
+	}
301
+
302
+	public static function front_head() {
303
+		if ( is_multisite() ) {
304
+			$old_db_version = get_option( 'frm_db_version' );
305
+			$pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
306
+			if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
307
+				( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
308
+				self::install( $old_db_version );
309
+			}
310
+		}
311
+	}
312 312
 
313 313
 	public static function localize_script( $location ) {
314 314
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
@@ -368,73 +368,73 @@  discard block
 block discarded – undo
368 368
 		wp_die();
369 369
 	}
370 370
 
371
-    public static function activation_install() {
372
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
373
-        FrmFormActionsController::actions_init();
374
-        self::install();
375
-    }
371
+	public static function activation_install() {
372
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
373
+		FrmFormActionsController::actions_init();
374
+		self::install();
375
+	}
376 376
 
377
-    public static function install( $old_db_version = false ) {
378
-        $frmdb = new FrmDb();
379
-        $frmdb->upgrade( $old_db_version );
380
-    }
377
+	public static function install( $old_db_version = false ) {
378
+		$frmdb = new FrmDb();
379
+		$frmdb->upgrade( $old_db_version );
380
+	}
381 381
 
382
-    public static function uninstall() {
383
-        check_ajax_referer( 'frm_ajax', 'nonce' );
382
+	public static function uninstall() {
383
+		check_ajax_referer( 'frm_ajax', 'nonce' );
384 384
 
385
-        if ( current_user_can( 'administrator' ) ) {
386
-            $frmdb = new FrmDb();
387
-            $frmdb->uninstall();
385
+		if ( current_user_can( 'administrator' ) ) {
386
+			$frmdb = new FrmDb();
387
+			$frmdb->uninstall();
388 388
 
389 389
 			//disable the plugin and redirect after uninstall so the tables don't get added right back
390 390
 			deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
391 391
 			echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
392
-        } else {
393
-            $frm_settings = FrmAppHelper::get_settings();
394
-            wp_die( $frm_settings->admin_permission );
395
-        }
396
-        wp_die();
397
-    }
398
-
399
-    public static function drop_tables( $tables ) {
400
-        global $wpdb;
401
-        $tables[] = $wpdb->prefix . 'frm_fields';
402
-        $tables[] = $wpdb->prefix . 'frm_forms';
403
-        $tables[] = $wpdb->prefix . 'frm_items';
404
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
405
-        return $tables;
406
-    }
407
-
408
-    // Routes for wordpress pages -- we're just replacing content here folks.
409
-    public static function page_route( $content ) {
410
-        global $post;
411
-
412
-        $frm_settings = FrmAppHelper::get_settings();
413
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
414
-            $content = FrmFormsController::page_preview();
415
-        }
416
-
417
-        return $content;
418
-    }
419
-
420
-    public static function deauthorize() {
392
+		} else {
393
+			$frm_settings = FrmAppHelper::get_settings();
394
+			wp_die( $frm_settings->admin_permission );
395
+		}
396
+		wp_die();
397
+	}
398
+
399
+	public static function drop_tables( $tables ) {
400
+		global $wpdb;
401
+		$tables[] = $wpdb->prefix . 'frm_fields';
402
+		$tables[] = $wpdb->prefix . 'frm_forms';
403
+		$tables[] = $wpdb->prefix . 'frm_items';
404
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
405
+		return $tables;
406
+	}
407
+
408
+	// Routes for wordpress pages -- we're just replacing content here folks.
409
+	public static function page_route( $content ) {
410
+		global $post;
411
+
412
+		$frm_settings = FrmAppHelper::get_settings();
413
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
414
+			$content = FrmFormsController::page_preview();
415
+		}
416
+
417
+		return $content;
418
+	}
419
+
420
+	public static function deauthorize() {
421 421
 		FrmAppHelper::permission_check('frm_change_settings');
422
-        check_ajax_referer( 'frm_ajax', 'nonce' );
423
-
424
-        delete_option( 'frmpro-credentials' );
425
-        delete_option( 'frmpro-authorized' );
426
-        delete_site_option( 'frmpro-credentials' );
427
-        delete_site_option( 'frmpro-authorized' );
428
-        wp_die();
429
-    }
430
-
431
-    public static function get_form_shortcode( $atts ) {
432
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
433
-        return FrmFormsController::get_form_shortcode( $atts );
434
-    }
435
-
436
-    public static function get_postbox_class() {
437
-        _deprecated_function( __FUNCTION__, '2.0' );
438
-        return 'postbox-container';
439
-    }
422
+		check_ajax_referer( 'frm_ajax', 'nonce' );
423
+
424
+		delete_option( 'frmpro-credentials' );
425
+		delete_option( 'frmpro-authorized' );
426
+		delete_site_option( 'frmpro-credentials' );
427
+		delete_site_option( 'frmpro-authorized' );
428
+		wp_die();
429
+	}
430
+
431
+	public static function get_form_shortcode( $atts ) {
432
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
433
+		return FrmFormsController::get_form_shortcode( $atts );
434
+	}
435
+
436
+	public static function get_postbox_class() {
437
+		_deprecated_function( __FUNCTION__, '2.0' );
438
+		return 'postbox-container';
439
+	}
440 440
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		if ( ! empty( $affiliate ) ) {
133 133
 ?>
134 134
 <div class="update-nag frm-update-to-pro">
135
-	Looking for more options to get professional results? <span>Take your forms to the next level.</span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com') ) ?>" class="button">Upgrade to Pro</a>
135
+	Looking for more options to get professional results? <span>Take your forms to the next level.</span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com' ) ) ?>" class="button">Upgrade to Pro</a>
136 136
 </div>
137 137
 <?php
138 138
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
     }
419 419
 
420 420
     public static function deauthorize() {
421
-		FrmAppHelper::permission_check('frm_change_settings');
421
+		FrmAppHelper::permission_check( 'frm_change_settings' );
422 422
         check_ajax_referer( 'frm_ajax', 'nonce' );
423 423
 
424 424
         delete_option( 'frmpro-credentials' );
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -2,137 +2,137 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+			$field_name = 'item_meta['. $field_id .']';
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
39
+			ob_start();
40
+			include($path .'/classes/views/frm-forms/add_field.php');
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check('frm_edit_forms');
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+		$field = self::include_new_field($field_type, $form_id);
60 60
 
61
-        // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
61
+		// this hook will allow for multiple fields to be added at once
62
+		do_action('frm_after_field_created', $field, $form_id);
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * @param integer $form_id
69
-     */
67
+	/**
68
+	 * @param integer $form_id
69
+	 */
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71
-        $values = array();
72
-        if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
-        }
71
+		$values = array();
72
+		if ( FrmAppHelper::pro_is_installed() ) {
73
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
+		}
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
-        $field_id = FrmField::create( $field_values );
76
+		$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
+		$field_id = FrmField::create( $field_values );
78 78
 
79
-        if ( ! $field_id ) {
80
-            return false;
81
-        }
79
+		if ( ! $field_id ) {
80
+			return false;
81
+		}
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+		$field = self::include_single_field($field_id, $values, $form_id);
84 84
 
85
-        return $field;
86
-    }
85
+		return $field;
86
+	}
87 87
 
88
-    public static function update_form_id() {
88
+	public static function update_form_id() {
89 89
 		FrmAppHelper::permission_check('frm_edit_forms');
90
-        check_ajax_referer( 'frm_ajax', 'nonce' );
90
+		check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
93 93
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
94 94
 
95
-        if ( ! $field_id || ! $form_id ) {
96
-            wp_die();
97
-        }
95
+		if ( ! $field_id || ! $form_id ) {
96
+			wp_die();
97
+		}
98 98
 
99 99
 		$updated = FrmField::update( $field_id, compact( 'form_id' ) );
100 100
 		echo absint( $updated );
101 101
 
102
-        wp_die();
103
-    }
102
+		wp_die();
103
+	}
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106 106
 		FrmAppHelper::permission_check('frm_edit_forms');
107
-        check_ajax_referer( 'frm_ajax', 'nonce' );
107
+		check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
110
-            $field = 'name';
111
-        }
109
+		if ( empty($field) ) {
110
+			$field = 'name';
111
+		}
112 112
 
113
-        if ( empty($id) ) {
113
+		if ( empty($id) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116
-        }
116
+		}
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
121
-            // set blank value if there is no content
122
-            $value = '';
123
-        }
120
+		if ( trim(strip_tags($value)) == '' ) {
121
+			// set blank value if there is no content
122
+			$value = '';
123
+		}
124 124
 
125 125
 		FrmField::update( $id, array( $field => $value ) );
126 126
 
127 127
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
128 128
 
129 129
 		echo stripslashes( wp_kses_post( $value ) );
130
-        wp_die();
131
-    }
130
+		wp_die();
131
+	}
132 132
 
133
-    public static function update_ajax_option() {
133
+	public static function update_ajax_option() {
134 134
 		FrmAppHelper::permission_check('frm_edit_forms');
135
-        check_ajax_referer( 'frm_ajax', 'nonce' );
135
+		check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
138 138
 		if ( ! $field_id ) {
@@ -142,155 +142,155 @@  discard block
 block discarded – undo
142 142
 		$field = FrmField::getOne( $field_id );
143 143
 
144 144
 		foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) {
145
-            if ( isset($_POST[ $val ]) ) {
145
+			if ( isset($_POST[ $val ]) ) {
146 146
 				// all three of these options are boolean
147 147
 				$new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' );
148 148
 
149
-                if ( $val == 'separate_value' ) {
149
+				if ( $val == 'separate_value' ) {
150 150
 					$new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1;
151
-                }
151
+				}
152 152
 
153
-                $field->field_options[ $val ] = $new_val;
154
-                unset($new_val);
155
-            }
156
-            unset($val);
157
-        }
153
+				$field->field_options[ $val ] = $new_val;
154
+				unset($new_val);
155
+			}
156
+			unset($val);
157
+		}
158 158
 
159
-        FrmField::update( $field_id, array(
160
-            'field_options' => $field->field_options,
159
+		FrmField::update( $field_id, array(
160
+			'field_options' => $field->field_options,
161 161
 			'form_id'		=> $field->form_id,
162
-        ) );
163
-        wp_die();
164
-    }
162
+		) );
163
+		wp_die();
164
+	}
165 165
 
166
-    public static function duplicate() {
166
+	public static function duplicate() {
167 167
 		FrmAppHelper::permission_check('frm_edit_forms');
168
-        check_ajax_referer( 'frm_ajax', 'nonce' );
168
+		check_ajax_referer( 'frm_ajax', 'nonce' );
169 169
 
170
-        global $wpdb;
170
+		global $wpdb;
171 171
 
172 172
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
173 173
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
174 174
 
175 175
 		$copy_field = FrmField::getOne( $field_id );
176
-        if ( ! $copy_field ) {
177
-            wp_die();
178
-        }
176
+		if ( ! $copy_field ) {
177
+			wp_die();
178
+		}
179 179
 
180
-        do_action('frm_duplicate_field', $copy_field, $form_id);
181
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
180
+		do_action('frm_duplicate_field', $copy_field, $form_id);
181
+		do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
182 182
 
183
-        $values = array( 'id' => $form_id );
184
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
183
+		$values = array( 'id' => $form_id );
184
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
185 185
 
186 186
 		$field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
187 187
 
188
-        $values['field_order'] = $field_count + 1;
188
+		$values['field_order'] = $field_count + 1;
189 189
 
190
-        if ( ! $field_id = FrmField::create($values) ) {
191
-            wp_die();
192
-        }
190
+		if ( ! $field_id = FrmField::create($values) ) {
191
+			wp_die();
192
+		}
193 193
 
194
-        self::include_single_field($field_id, $values);
194
+		self::include_single_field($field_id, $values);
195 195
 
196
-        wp_die();
197
-    }
196
+		wp_die();
197
+	}
198 198
 
199
-    /**
200
-     * Load a single field in the form builder along with all needed variables
201
-     */
202
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
203
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
204
-        $field_name = 'item_meta['. $field_id .']';
205
-        $html_id = FrmFieldsHelper::get_html_id($field);
206
-        $id = $form_id ? $form_id : $field['form_id'];
207
-        if ( $field['type'] == 'html' ) {
208
-            $field['stop_filter'] = true;
209
-        }
199
+	/**
200
+	 * Load a single field in the form builder along with all needed variables
201
+	 */
202
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
203
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
204
+		$field_name = 'item_meta['. $field_id .']';
205
+		$html_id = FrmFieldsHelper::get_html_id($field);
206
+		$id = $form_id ? $form_id : $field['form_id'];
207
+		if ( $field['type'] == 'html' ) {
208
+			$field['stop_filter'] = true;
209
+		}
210 210
 
211
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
211
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
212 212
 
213
-        return $field;
214
-    }
213
+		return $field;
214
+	}
215 215
 
216
-    public static function destroy() {
216
+	public static function destroy() {
217 217
 		FrmAppHelper::permission_check('frm_edit_forms');
218
-        check_ajax_referer( 'frm_ajax', 'nonce' );
218
+		check_ajax_referer( 'frm_ajax', 'nonce' );
219 219
 
220 220
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
221 221
 		FrmField::destroy( $field_id );
222
-        wp_die();
223
-    }
222
+		wp_die();
223
+	}
224 224
 
225
-    /* Field Options */
225
+	/* Field Options */
226 226
 
227
-    //Add Single Option or Other Option
228
-    public static function add_option() {
227
+	//Add Single Option or Other Option
228
+	public static function add_option() {
229 229
 		FrmAppHelper::permission_check('frm_edit_forms');
230
-        check_ajax_referer( 'frm_ajax', 'nonce' );
230
+		check_ajax_referer( 'frm_ajax', 'nonce' );
231 231
 
232 232
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
233 233
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
234 234
 
235
-        //Get the field
236
-        $field = FrmField::getOne($id);
235
+		//Get the field
236
+		$field = FrmField::getOne($id);
237 237
 
238 238
 		if ( ! empty( $field->options ) ) {
239 239
 			$keys = array_keys( $field->options );
240
-            $last = str_replace( 'other_', '', end( $keys ) );
241
-        } else {
242
-            $last = 0;
243
-        }
244
-        $opt_key = $last + 1;
240
+			$last = str_replace( 'other_', '', end( $keys ) );
241
+		} else {
242
+			$last = 0;
243
+		}
244
+		$opt_key = $last + 1;
245 245
 
246
-        if ( 'other' == $opt_type ) {
246
+		if ( 'other' == $opt_type ) {
247 247
 			$opt = esc_html__( 'Other', 'formidable' );
248
-            $other_val = '';
249
-            $opt_key = 'other_' . $opt_key;
250
-
251
-            //Update value of "other" in DB
252
-            $field_options = maybe_unserialize( $field->field_options );
253
-            $field_options['other'] = 1;
254
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
255
-        } else {
248
+			$other_val = '';
249
+			$opt_key = 'other_' . $opt_key;
250
+
251
+			//Update value of "other" in DB
252
+			$field_options = maybe_unserialize( $field->field_options );
253
+			$field_options['other'] = 1;
254
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
255
+		} else {
256 256
 			$first_opt = reset( $field->options );
257 257
 			$next_opt = count( $field->options );
258
-            if ( $first_opt != '' ) {
259
-                $next_opt++;
260
-            }
261
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
262
-            unset($next_opt);
263
-        }
264
-        $field_val = $opt;
258
+			if ( $first_opt != '' ) {
259
+				$next_opt++;
260
+			}
261
+			$opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
262
+			unset($next_opt);
263
+		}
264
+		$field_val = $opt;
265 265
 		$field->options[ $opt_key ] = $opt;
266 266
 
267
-        //Update options in DB
267
+		//Update options in DB
268 268
 		FrmField::update( $id, array( 'options' => $field->options ) );
269 269
 
270
-        $field_data = $field;
271
-        $field = array(
272
-            'type'  => $field_data->type,
273
-            'id'    => $id,
274
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
275
-            'form_id' => $field_data->form_id,
276
-            'field_key' => $field_data->field_key,
277
-        );
278
-
279
-        $field_name = 'item_meta['. $id .']';
280
-        $html_id = FrmFieldsHelper::get_html_id($field);
281
-        $checked = '';
282
-
283
-        if ( 'other' == $opt_type ) {
284
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
285
-        } else {
286
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
287
-        }
288
-        wp_die();
289
-    }
290
-
291
-    public static function edit_option() {
270
+		$field_data = $field;
271
+		$field = array(
272
+			'type'  => $field_data->type,
273
+			'id'    => $id,
274
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
275
+			'form_id' => $field_data->form_id,
276
+			'field_key' => $field_data->field_key,
277
+		);
278
+
279
+		$field_name = 'item_meta['. $id .']';
280
+		$html_id = FrmFieldsHelper::get_html_id($field);
281
+		$checked = '';
282
+
283
+		if ( 'other' == $opt_type ) {
284
+			require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
285
+		} else {
286
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
287
+		}
288
+		wp_die();
289
+	}
290
+
291
+	public static function edit_option() {
292 292
 		FrmAppHelper::permission_check('frm_edit_forms');
293
-        check_ajax_referer( 'frm_ajax', 'nonce' );
293
+		check_ajax_referer( 'frm_ajax', 'nonce' );
294 294
 
295 295
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
296 296
 		$ids = explode( '-', $element_id );
@@ -298,43 +298,43 @@  discard block
 block discarded – undo
298 298
 
299 299
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) );
300 300
 		if ( strpos( $element_id, 'key_' ) ) {
301
-            $new_value = $update_value;
302
-        } else {
303
-            $new_label = $update_value;
304
-        }
301
+			$new_value = $update_value;
302
+		} else {
303
+			$new_label = $update_value;
304
+		}
305 305
 
306
-        $field = FrmField::getOne($id);
307
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
306
+		$field = FrmField::getOne($id);
307
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
308 308
 
309
-        $this_opt_id = end($ids);
309
+		$this_opt_id = end($ids);
310 310
 		$this_opt = (array) $field->options[ $this_opt_id ];
311 311
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
312 312
 
313
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
314
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
313
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
314
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
315 315
 
316
-        if ( ! isset( $new_label ) ) {
317
-            $new_label = $label;
318
-        }
316
+		if ( ! isset( $new_label ) ) {
317
+			$new_label = $label;
318
+		}
319 319
 
320
-        if ( isset($new_value) || isset($value) ) {
321
-            $update_value = isset($new_value) ? $new_value : $value;
322
-        }
320
+		if ( isset($new_value) || isset($value) ) {
321
+			$update_value = isset($new_value) ? $new_value : $value;
322
+		}
323 323
 
324 324
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
325 325
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
326
-        } else {
326
+		} else {
327 327
 			$field->options[ $this_opt_id ] = $orig_update_value;
328
-        }
328
+		}
329 329
 
330 330
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
331 331
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
332
-        wp_die();
333
-    }
332
+		wp_die();
333
+	}
334 334
 
335
-    public static function delete_option() {
335
+	public static function delete_option() {
336 336
 		FrmAppHelper::permission_check('frm_edit_forms');
337
-        check_ajax_referer( 'frm_ajax', 'nonce' );
337
+		check_ajax_referer( 'frm_ajax', 'nonce' );
338 338
 
339 339
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
340 340
 		$field = FrmField::getOne( $field_id );
@@ -342,340 +342,340 @@  discard block
 block discarded – undo
342 342
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
343 343
 
344 344
 		$options = $field->options;
345
-        unset( $options[ $opt_key ] );
346
-        $response = array( 'other' => true );
345
+		unset( $options[ $opt_key ] );
346
+		$response = array( 'other' => true );
347 347
 
348
-        //If the deleted option is an "other" option
348
+		//If the deleted option is an "other" option
349 349
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
350
-            //Assume all other options are gone, unless proven otherwise
351
-            $other = false;
350
+			//Assume all other options are gone, unless proven otherwise
351
+			$other = false;
352 352
 
353
-            //Check if all other options are really gone
354
-            foreach ( $options as $o_key => $o_val ) {
355
-                //If there is still an other option in the field, set other to true
353
+			//Check if all other options are really gone
354
+			foreach ( $options as $o_key => $o_val ) {
355
+				//If there is still an other option in the field, set other to true
356 356
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
357
-                    $other = true;
358
-                    break;
359
-                }
360
-                unset( $o_key, $o_val );
361
-            }
362
-
363
-            //If all other options are gone
364
-            if ( false === $other ) {
365
-                $field_options = maybe_unserialize( $field->field_options );
366
-                $field_options['other'] = 0;
357
+					$other = true;
358
+					break;
359
+				}
360
+				unset( $o_key, $o_val );
361
+			}
362
+
363
+			//If all other options are gone
364
+			if ( false === $other ) {
365
+				$field_options = maybe_unserialize( $field->field_options );
366
+				$field_options['other'] = 0;
367 367
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
368
-                $response = array( 'other' => false );
369
-            }
370
-        }
371
-        echo json_encode( $response );
368
+				$response = array( 'other' => false );
369
+			}
370
+		}
371
+		echo json_encode( $response );
372 372
 
373 373
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
374 374
 
375
-        wp_die();
376
-    }
375
+		wp_die();
376
+	}
377 377
 
378
-    public static function import_choices() {
379
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
378
+	public static function import_choices() {
379
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
380 380
 
381 381
 		$field_id = absint( $_REQUEST['field_id'] );
382 382
 
383
-        global $current_screen, $hook_suffix;
383
+		global $current_screen, $hook_suffix;
384 384
 
385
-        // Catch plugins that include admin-header.php before admin.php completes.
386
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
387
-            $hook_suffix = '';
388
-        	set_current_screen();
389
-        }
385
+		// Catch plugins that include admin-header.php before admin.php completes.
386
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
387
+			$hook_suffix = '';
388
+			set_current_screen();
389
+		}
390 390
 
391
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
392
-            register_admin_color_schemes();
393
-        }
391
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
392
+			register_admin_color_schemes();
393
+		}
394 394
 
395
-        $hook_suffix = $admin_body_class = '';
395
+		$hook_suffix = $admin_body_class = '';
396 396
 
397
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
398
-        	$admin_body_class .= ' folded';
399
-        }
397
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
398
+			$admin_body_class .= ' folded';
399
+		}
400 400
 
401
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
402
-        	$admin_body_class .= ' admin-bar';
403
-        }
401
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
402
+			$admin_body_class .= ' admin-bar';
403
+		}
404 404
 
405
-        if ( is_rtl() ) {
406
-        	$admin_body_class .= ' rtl';
407
-        }
405
+		if ( is_rtl() ) {
406
+			$admin_body_class .= ' rtl';
407
+		}
408 408
 
409
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
410
-        $prepop = array();
411
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
409
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
410
+		$prepop = array();
411
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
412 412
 
413
-        $field = FrmField::getOne($field_id);
413
+		$field = FrmField::getOne($field_id);
414 414
 
415
-        wp_enqueue_script( 'utils' );
416
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
417
-        FrmAppHelper::load_admin_wide_js();
415
+		wp_enqueue_script( 'utils' );
416
+		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
417
+		FrmAppHelper::load_admin_wide_js();
418 418
 
419
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
420
-        wp_die();
421
-    }
419
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
420
+		wp_die();
421
+	}
422 422
 
423
-    public static function import_options() {
423
+	public static function import_options() {
424 424
 		FrmAppHelper::permission_check('frm_edit_forms');
425
-        check_ajax_referer( 'frm_ajax', 'nonce' );
425
+		check_ajax_referer( 'frm_ajax', 'nonce' );
426 426
 
427
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
428
-            return;
429
-        }
427
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
428
+			return;
429
+		}
430 430
 
431 431
 		$field_id = absint( $_POST['field_id'] );
432
-        $field = FrmField::getOne($field_id);
432
+		$field = FrmField::getOne($field_id);
433 433
 
434 434
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
435
-            return;
436
-        }
437
-
438
-        $field = FrmFieldsHelper::setup_edit_vars($field);
439
-        $opts = stripslashes_deep($_POST['opts']);
440
-        $opts = explode("\n", rtrim($opts, "\n"));
441
-        if ( $field['separate_value'] ) {
442
-            foreach ( $opts as $opt_key => $opt ) {
443
-                if ( strpos($opt, '|') !== false ) {
444
-                    $vals = explode('|', $opt);
445
-                    if ( $vals[0] != $vals[1] ) {
446
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
447
-                    }
448
-                    unset($vals);
449
-                }
450
-                unset($opt_key, $opt);
451
-            }
452
-        }
453
-
454
-        //Keep other options after bulk update
455
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
456
-            $other_array = array();
457
-            foreach ( $field['options'] as $opt_key => $opt ) {
458
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
459
-                    $other_array[ $opt_key ] = $opt;
460
-                }
461
-                unset($opt_key, $opt);
462
-            }
463
-            if ( ! empty($other_array) ) {
464
-                $opts = array_merge( $opts, $other_array);
465
-            }
466
-        }
467
-
468
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
469
-
470
-        $field['options'] = $opts;
471
-        $field_name = $field['name'];
472
-
473
-        // Get html_id which will be used in single-option.php
474
-        $html_id = FrmFieldsHelper::get_html_id( $field );
475
-
476
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
477
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
478
-        } else {
479
-            FrmFieldsHelper::show_single_option($field);
480
-        }
481
-
482
-        wp_die();
483
-    }
484
-
485
-    public static function update_order() {
435
+			return;
436
+		}
437
+
438
+		$field = FrmFieldsHelper::setup_edit_vars($field);
439
+		$opts = stripslashes_deep($_POST['opts']);
440
+		$opts = explode("\n", rtrim($opts, "\n"));
441
+		if ( $field['separate_value'] ) {
442
+			foreach ( $opts as $opt_key => $opt ) {
443
+				if ( strpos($opt, '|') !== false ) {
444
+					$vals = explode('|', $opt);
445
+					if ( $vals[0] != $vals[1] ) {
446
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
447
+					}
448
+					unset($vals);
449
+				}
450
+				unset($opt_key, $opt);
451
+			}
452
+		}
453
+
454
+		//Keep other options after bulk update
455
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
456
+			$other_array = array();
457
+			foreach ( $field['options'] as $opt_key => $opt ) {
458
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
459
+					$other_array[ $opt_key ] = $opt;
460
+				}
461
+				unset($opt_key, $opt);
462
+			}
463
+			if ( ! empty($other_array) ) {
464
+				$opts = array_merge( $opts, $other_array);
465
+			}
466
+		}
467
+
468
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
469
+
470
+		$field['options'] = $opts;
471
+		$field_name = $field['name'];
472
+
473
+		// Get html_id which will be used in single-option.php
474
+		$html_id = FrmFieldsHelper::get_html_id( $field );
475
+
476
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
477
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
478
+		} else {
479
+			FrmFieldsHelper::show_single_option($field);
480
+		}
481
+
482
+		wp_die();
483
+	}
484
+
485
+	public static function update_order() {
486 486
 		FrmAppHelper::permission_check('frm_edit_forms');
487
-        check_ajax_referer( 'frm_ajax', 'nonce' );
487
+		check_ajax_referer( 'frm_ajax', 'nonce' );
488 488
 
489 489
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
490 490
 		foreach ( (array) $fields as $position => $item ) {
491 491
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
492 492
 		}
493
-        wp_die();
494
-    }
493
+		wp_die();
494
+	}
495 495
 
496 496
 	public static function change_type( $type ) {
497
-        $type_switch = array(
498
-            'scale'     => 'radio',
499
-            '10radio'   => 'radio',
500
-            'rte'       => 'textarea',
501
-            'website'   => 'url',
502
-        );
503
-        if ( isset( $type_switch[ $type ] ) ) {
504
-            $type = $type_switch[ $type ];
505
-        }
497
+		$type_switch = array(
498
+			'scale'     => 'radio',
499
+			'10radio'   => 'radio',
500
+			'rte'       => 'textarea',
501
+			'website'   => 'url',
502
+		);
503
+		if ( isset( $type_switch[ $type ] ) ) {
504
+			$type = $type_switch[ $type ];
505
+		}
506 506
 
507 507
 		$frm_field_selection = FrmField::field_selection();
508
-        $types = array_keys($frm_field_selection);
509
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
510
-            $type = 'text';
511
-        }
508
+		$types = array_keys($frm_field_selection);
509
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
510
+			$type = 'text';
511
+		}
512 512
 
513
-        return $type;
514
-    }
513
+		return $type;
514
+	}
515 515
 
516 516
 	public static function display_field_options( $display ) {
517 517
 		switch ( $display['type'] ) {
518
-            case 'captcha':
519
-                $display['required'] = false;
520
-                $display['invalid'] = true;
521
-                $display['default_blank'] = false;
518
+			case 'captcha':
519
+				$display['required'] = false;
520
+				$display['invalid'] = true;
521
+				$display['default_blank'] = false;
522 522
 				$display['captcha_size'] = true;
523
-            break;
524
-            case 'radio':
525
-                $display['default_blank'] = false;
526
-            break;
527
-            case 'text':
528
-            case 'textarea':
529
-                $display['size'] = true;
530
-                $display['clear_on_focus'] = true;
531
-            break;
532
-            case 'select':
533
-                $display['size'] = true;
534
-            break;
535
-            case 'url':
536
-            case 'website':
537
-            case 'email':
538
-                $display['size'] = true;
539
-                $display['clear_on_focus'] = true;
540
-                $display['invalid'] = true;
541
-        }
542
-
543
-        return $display;
544
-    }
545
-
546
-    public static function input_html( $field, $echo = true ) {
547
-        $class = array(); //$field['type'];
548
-        self::add_input_classes($field, $class);
549
-
550
-        $add_html = array();
551
-        self::add_html_size($field, $add_html);
552
-        self::add_html_length($field, $add_html);
553
-        self::add_html_placeholder($field, $add_html, $class);
523
+			break;
524
+			case 'radio':
525
+				$display['default_blank'] = false;
526
+			break;
527
+			case 'text':
528
+			case 'textarea':
529
+				$display['size'] = true;
530
+				$display['clear_on_focus'] = true;
531
+			break;
532
+			case 'select':
533
+				$display['size'] = true;
534
+			break;
535
+			case 'url':
536
+			case 'website':
537
+			case 'email':
538
+				$display['size'] = true;
539
+				$display['clear_on_focus'] = true;
540
+				$display['invalid'] = true;
541
+		}
542
+
543
+		return $display;
544
+	}
545
+
546
+	public static function input_html( $field, $echo = true ) {
547
+		$class = array(); //$field['type'];
548
+		self::add_input_classes($field, $class);
549
+
550
+		$add_html = array();
551
+		self::add_html_size($field, $add_html);
552
+		self::add_html_length($field, $add_html);
553
+		self::add_html_placeholder($field, $add_html, $class);
554 554
 		//self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete
555 555
 
556
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
556
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
557 557
 
558 558
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
559 559
 
560
-        self::add_shortcodes_to_html($field, $add_html);
560
+		self::add_shortcodes_to_html($field, $add_html);
561 561
 
562 562
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
563 563
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
564 564
 
565
-        if ( $echo ) {
566
-            echo $add_html;
567
-        }
565
+		if ( $echo ) {
566
+			echo $add_html;
567
+		}
568 568
 
569
-        return $add_html;
570
-    }
569
+		return $add_html;
570
+	}
571 571
 
572 572
 	private static function add_input_classes( $field, array &$class ) {
573
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
574
-            $class[] = $field['input_class'];
575
-        }
573
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
574
+			$class[] = $field['input_class'];
575
+		}
576 576
 
577
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
578
-            return;
579
-        }
577
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
578
+			return;
579
+		}
580 580
 
581
-        global $frm_vars;
581
+		global $frm_vars;
582 582
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
583
-            $class[] = 'dyn_default_value';
584
-        }
583
+			$class[] = 'dyn_default_value';
584
+		}
585 585
 
586
-        if ( isset($field['size']) && $field['size'] > 0 ) {
587
-            $class[] = 'auto_width';
588
-        }
589
-    }
586
+		if ( isset($field['size']) && $field['size'] > 0 ) {
587
+			$class[] = 'auto_width';
588
+		}
589
+	}
590 590
 
591 591
 	private static function add_html_size( $field, array &$add_html ) {
592 592
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
593
-            return;
594
-        }
593
+			return;
594
+		}
595 595
 
596
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
597
-            return;
598
-        }
596
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
597
+			return;
598
+		}
599 599
 
600
-        if ( is_numeric($field['size']) ) {
601
-            $field['size'] .= 'px';
602
-        }
600
+		if ( is_numeric($field['size']) ) {
601
+			$field['size'] .= 'px';
602
+		}
603 603
 
604
-        $important = apply_filters('frm_use_important_width', 1, $field);
605
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
606
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
604
+		$important = apply_filters('frm_use_important_width', 1, $field);
605
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
606
+		$add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
607 607
 
608
-        self::add_html_cols($field, $add_html);
609
-    }
608
+		self::add_html_cols($field, $add_html);
609
+	}
610 610
 
611 611
 	private static function add_html_cols( $field, array &$add_html ) {
612 612
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
613
-            return;
614
-        }
613
+			return;
614
+		}
615 615
 
616
-        // convert to cols for textareas
617
-        $calc = array(
618
-            ''      => 9,
619
-            'px'    => 9,
620
-            'rem'   => 0.444,
621
-            'em'    => 0.544,
622
-        );
616
+		// convert to cols for textareas
617
+		$calc = array(
618
+			''      => 9,
619
+			'px'    => 9,
620
+			'rem'   => 0.444,
621
+			'em'    => 0.544,
622
+		);
623 623
 
624
-        // include "col" for valid html
625
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
624
+		// include "col" for valid html
625
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
626 626
 
627
-        if ( ! isset( $calc[ $unit ] ) ) {
628
-            return;
629
-        }
627
+		if ( ! isset( $calc[ $unit ] ) ) {
628
+			return;
629
+		}
630 630
 
631
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
631
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
632 632
 
633 633
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
634
-    }
634
+	}
635 635
 
636 636
 	private static function add_html_length( $field, array &$add_html ) {
637
-        // check for max setting and if this field accepts maxlength
637
+		// check for max setting and if this field accepts maxlength
638 638
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
639
-            return;
640
-        }
639
+			return;
640
+		}
641 641
 
642
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
643
-            // don't load on form builder page
644
-            return;
645
-        }
642
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
643
+			// don't load on form builder page
644
+			return;
645
+		}
646 646
 
647 647
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
648
-    }
648
+	}
649 649
 
650 650
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
651 651
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
652 652
 			return;
653 653
 		}
654 654
 
655
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
655
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
656 656
 			if ( is_array( $field['default_value'] ) ) {
657 657
 				$field['default_value'] = json_encode( $field['default_value'] );
658 658
 			}
659 659
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
660
-            return;
661
-        }
660
+			return;
661
+		}
662 662
 
663
-        $frm_settings = FrmAppHelper::get_settings();
663
+		$frm_settings = FrmAppHelper::get_settings();
664 664
 
665 665
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
666
-            // use HMTL5 placeholder with js fallback
667
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
668
-            wp_enqueue_script('jquery-placeholder');
669
-        } else if ( ! $frm_settings->use_html ) {
666
+			// use HMTL5 placeholder with js fallback
667
+			$add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
668
+			wp_enqueue_script('jquery-placeholder');
669
+		} else if ( ! $frm_settings->use_html ) {
670 670
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
671
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
672
-            $class[] = 'frm_toggle_default';
671
+			$add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
672
+			$class[] = 'frm_toggle_default';
673 673
 
674
-            if ( $field['value'] == $field['default_value'] ) {
675
-                $class[] = 'frm_default';
676
-            }
677
-        }
678
-    }
674
+			if ( $field['value'] == $field['default_value'] ) {
675
+				$class[] = 'frm_default';
676
+			}
677
+		}
678
+	}
679 679
 
680 680
 	private static function add_validation_messages( $field, array &$add_html ) {
681 681
 		if ( FrmField::is_required( $field ) ) {
@@ -696,44 +696,44 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 	}
698 698
 
699
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
700
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
701
-            return;
702
-        }
703
-
704
-        foreach ( $field['shortcodes'] as $k => $v ) {
705
-            if ( 'opt' === $k ) {
706
-                continue;
707
-            }
708
-
709
-            if ( is_numeric($k) && strpos($v, '=') ) {
710
-                $add_html[] = $v;
711
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
712
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
713
-            } else {
699
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
700
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
701
+			return;
702
+		}
703
+
704
+		foreach ( $field['shortcodes'] as $k => $v ) {
705
+			if ( 'opt' === $k ) {
706
+				continue;
707
+			}
708
+
709
+			if ( is_numeric($k) && strpos($v, '=') ) {
710
+				$add_html[] = $v;
711
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
712
+				$add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
713
+			} else {
714 714
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
715
-            }
716
-
717
-            unset($k, $v);
718
-        }
719
-    }
720
-
721
-    public static function check_value( $opt, $opt_key, $field ) {
722
-        if ( is_array( $opt ) ) {
723
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
724
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
725
-            } else {
726
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
727
-            }
728
-        }
729
-        return $opt;
730
-    }
715
+			}
716
+
717
+			unset($k, $v);
718
+		}
719
+	}
720
+
721
+	public static function check_value( $opt, $opt_key, $field ) {
722
+		if ( is_array( $opt ) ) {
723
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
724
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
725
+			} else {
726
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
727
+			}
728
+		}
729
+		return $opt;
730
+	}
731 731
 
732 732
 	public static function check_label( $opt ) {
733
-        if ( is_array($opt) ) {
734
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
735
-        }
733
+		if ( is_array($opt) ) {
734
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
735
+		}
736 736
 
737
-        return $opt;
738
-    }
737
+		return $opt;
738
+	}
739 739
 }
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
                 $field['value'] = '';
34 34
             }
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+            $field_name = 'item_meta[' . $field_id . ']';
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
40
+            include( $path . '/classes/views/frm-forms/add_field.php' );
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
51 51
 
52 52
     public static function create() {
53
-		FrmAppHelper::permission_check('frm_edit_forms');
53
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
54 54
         check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+        $field = self::include_new_field( $field_type, $form_id );
60 60
 
61 61
         // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
62
+        do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64 64
         wp_die();
65 65
     }
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71 71
         $values = array();
72 72
         if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
73
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
74 74
         }
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
76
+        $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) );
77 77
         $field_id = FrmField::create( $field_values );
78 78
 
79 79
         if ( ! $field_id ) {
80 80
             return false;
81 81
         }
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+        $field = self::include_single_field( $field_id, $values, $form_id );
84 84
 
85 85
         return $field;
86 86
     }
87 87
 
88 88
     public static function update_form_id() {
89
-		FrmAppHelper::permission_check('frm_edit_forms');
89
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
90 90
         check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106
-		FrmAppHelper::permission_check('frm_edit_forms');
106
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
107 107
         check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
109
+        if ( empty( $field ) ) {
110 110
             $field = 'name';
111 111
         }
112 112
 
113
-        if ( empty($id) ) {
113
+        if ( empty( $id ) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116 116
         }
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
120
+        if ( trim( strip_tags( $value ) ) == '' ) {
121 121
             // set blank value if there is no content
122 122
             $value = '';
123 123
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
     public static function update_ajax_option() {
134
-		FrmAppHelper::permission_check('frm_edit_forms');
134
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
135 135
         check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$field = FrmField::getOne( $field_id );
143 143
 
144 144
 		foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) {
145
-            if ( isset($_POST[ $val ]) ) {
145
+            if ( isset( $_POST[$val] ) ) {
146 146
 				// all three of these options are boolean
147 147
 				$new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' );
148 148
 
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 					$new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1;
151 151
                 }
152 152
 
153
-                $field->field_options[ $val ] = $new_val;
154
-                unset($new_val);
153
+                $field->field_options[$val] = $new_val;
154
+                unset( $new_val );
155 155
             }
156
-            unset($val);
156
+            unset( $val );
157 157
         }
158 158
 
159 159
         FrmField::update( $field_id, array(
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     }
165 165
 
166 166
     public static function duplicate() {
167
-		FrmAppHelper::permission_check('frm_edit_forms');
167
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
168 168
         check_ajax_referer( 'frm_ajax', 'nonce' );
169 169
 
170 170
         global $wpdb;
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
             wp_die();
178 178
         }
179 179
 
180
-        do_action('frm_duplicate_field', $copy_field, $form_id);
181
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
180
+        do_action( 'frm_duplicate_field', $copy_field, $form_id );
181
+        do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
182 182
 
183 183
         $values = array( 'id' => $form_id );
184 184
         FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
185 185
 
186
-		$field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
186
+		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
187 187
 
188 188
         $values['field_order'] = $field_count + 1;
189 189
 
190
-        if ( ! $field_id = FrmField::create($values) ) {
190
+        if ( ! $field_id = FrmField::create( $values ) ) {
191 191
             wp_die();
192 192
         }
193 193
 
194
-        self::include_single_field($field_id, $values);
194
+        self::include_single_field( $field_id, $values );
195 195
 
196 196
         wp_die();
197 197
     }
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
      * Load a single field in the form builder along with all needed variables
201 201
      */
202 202
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
203
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
204
-        $field_name = 'item_meta['. $field_id .']';
205
-        $html_id = FrmFieldsHelper::get_html_id($field);
203
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
204
+        $field_name = 'item_meta[' . $field_id . ']';
205
+        $html_id = FrmFieldsHelper::get_html_id( $field );
206 206
         $id = $form_id ? $form_id : $field['form_id'];
207 207
         if ( $field['type'] == 'html' ) {
208 208
             $field['stop_filter'] = true;
209 209
         }
210 210
 
211
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
211
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
212 212
 
213 213
         return $field;
214 214
     }
215 215
 
216 216
     public static function destroy() {
217
-		FrmAppHelper::permission_check('frm_edit_forms');
217
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
218 218
         check_ajax_referer( 'frm_ajax', 'nonce' );
219 219
 
220 220
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 
227 227
     //Add Single Option or Other Option
228 228
     public static function add_option() {
229
-		FrmAppHelper::permission_check('frm_edit_forms');
229
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
230 230
         check_ajax_referer( 'frm_ajax', 'nonce' );
231 231
 
232 232
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
233 233
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
234 234
 
235 235
         //Get the field
236
-        $field = FrmField::getOne($id);
236
+        $field = FrmField::getOne( $id );
237 237
 
238 238
 		if ( ! empty( $field->options ) ) {
239 239
 			$keys = array_keys( $field->options );
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 			$first_opt = reset( $field->options );
257 257
 			$next_opt = count( $field->options );
258 258
             if ( $first_opt != '' ) {
259
-                $next_opt++;
259
+                $next_opt ++;
260 260
             }
261
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
262
-            unset($next_opt);
261
+            $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
262
+            unset( $next_opt );
263 263
         }
264 264
         $field_val = $opt;
265
-		$field->options[ $opt_key ] = $opt;
265
+		$field->options[$opt_key] = $opt;
266 266
 
267 267
         //Update options in DB
268 268
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
         $field = array(
272 272
             'type'  => $field_data->type,
273 273
             'id'    => $id,
274
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
274
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
275 275
             'form_id' => $field_data->form_id,
276 276
             'field_key' => $field_data->field_key,
277 277
         );
278 278
 
279
-        $field_name = 'item_meta['. $id .']';
280
-        $html_id = FrmFieldsHelper::get_html_id($field);
279
+        $field_name = 'item_meta[' . $id . ']';
280
+        $html_id = FrmFieldsHelper::get_html_id( $field );
281 281
         $checked = '';
282 282
 
283 283
         if ( 'other' == $opt_type ) {
284
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
284
+            require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
285 285
         } else {
286
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
286
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
287 287
         }
288 288
         wp_die();
289 289
     }
290 290
 
291 291
     public static function edit_option() {
292
-		FrmAppHelper::permission_check('frm_edit_forms');
292
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
293 293
         check_ajax_referer( 'frm_ajax', 'nonce' );
294 294
 
295 295
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -303,28 +303,28 @@  discard block
 block discarded – undo
303 303
             $new_label = $update_value;
304 304
         }
305 305
 
306
-        $field = FrmField::getOne($id);
306
+        $field = FrmField::getOne( $id );
307 307
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
308 308
 
309
-        $this_opt_id = end($ids);
310
-		$this_opt = (array) $field->options[ $this_opt_id ];
311
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
309
+        $this_opt_id = end( $ids );
310
+		$this_opt = (array) $field->options[$this_opt_id];
311
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
312 312
 
313
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
314
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
313
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
314
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
315 315
 
316 316
         if ( ! isset( $new_label ) ) {
317 317
             $new_label = $label;
318 318
         }
319 319
 
320
-        if ( isset($new_value) || isset($value) ) {
321
-            $update_value = isset($new_value) ? $new_value : $value;
320
+        if ( isset( $new_value ) || isset( $value ) ) {
321
+            $update_value = isset( $new_value ) ? $new_value : $value;
322 322
         }
323 323
 
324 324
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
325
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
325
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
326 326
         } else {
327
-			$field->options[ $this_opt_id ] = $orig_update_value;
327
+			$field->options[$this_opt_id] = $orig_update_value;
328 328
         }
329 329
 
330 330
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     }
334 334
 
335 335
     public static function delete_option() {
336
-		FrmAppHelper::permission_check('frm_edit_forms');
336
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
337 337
         check_ajax_referer( 'frm_ajax', 'nonce' );
338 338
 
339 339
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
343 343
 
344 344
 		$options = $field->options;
345
-        unset( $options[ $opt_key ] );
345
+        unset( $options[$opt_key] );
346 346
         $response = array( 'other' => true );
347 347
 
348 348
         //If the deleted option is an "other" option
@@ -408,46 +408,46 @@  discard block
 block discarded – undo
408 408
 
409 409
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
410 410
         $prepop = array();
411
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
411
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
412 412
 
413
-        $field = FrmField::getOne($field_id);
413
+        $field = FrmField::getOne( $field_id );
414 414
 
415 415
         wp_enqueue_script( 'utils' );
416
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
416
+        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
417 417
         FrmAppHelper::load_admin_wide_js();
418 418
 
419
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
419
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
420 420
         wp_die();
421 421
     }
422 422
 
423 423
     public static function import_options() {
424
-		FrmAppHelper::permission_check('frm_edit_forms');
424
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
425 425
         check_ajax_referer( 'frm_ajax', 'nonce' );
426 426
 
427
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
427
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
428 428
             return;
429 429
         }
430 430
 
431 431
 		$field_id = absint( $_POST['field_id'] );
432
-        $field = FrmField::getOne($field_id);
432
+        $field = FrmField::getOne( $field_id );
433 433
 
434 434
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
435 435
             return;
436 436
         }
437 437
 
438
-        $field = FrmFieldsHelper::setup_edit_vars($field);
439
-        $opts = stripslashes_deep($_POST['opts']);
440
-        $opts = explode("\n", rtrim($opts, "\n"));
438
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
439
+        $opts = stripslashes_deep( $_POST['opts'] );
440
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
441 441
         if ( $field['separate_value'] ) {
442 442
             foreach ( $opts as $opt_key => $opt ) {
443
-                if ( strpos($opt, '|') !== false ) {
444
-                    $vals = explode('|', $opt);
443
+                if ( strpos( $opt, '|' ) !== false ) {
444
+                    $vals = explode( '|', $opt );
445 445
                     if ( $vals[0] != $vals[1] ) {
446
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
446
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
447 447
                     }
448
-                    unset($vals);
448
+                    unset( $vals );
449 449
                 }
450
-                unset($opt_key, $opt);
450
+                unset( $opt_key, $opt );
451 451
             }
452 452
         }
453 453
 
@@ -456,12 +456,12 @@  discard block
 block discarded – undo
456 456
             $other_array = array();
457 457
             foreach ( $field['options'] as $opt_key => $opt ) {
458 458
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
459
-                    $other_array[ $opt_key ] = $opt;
459
+                    $other_array[$opt_key] = $opt;
460 460
                 }
461
-                unset($opt_key, $opt);
461
+                unset( $opt_key, $opt );
462 462
             }
463
-            if ( ! empty($other_array) ) {
464
-                $opts = array_merge( $opts, $other_array);
463
+            if ( ! empty( $other_array ) ) {
464
+                $opts = array_merge( $opts, $other_array );
465 465
             }
466 466
         }
467 467
 
@@ -474,16 +474,16 @@  discard block
 block discarded – undo
474 474
         $html_id = FrmFieldsHelper::get_html_id( $field );
475 475
 
476 476
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
477
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
477
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
478 478
         } else {
479
-            FrmFieldsHelper::show_single_option($field);
479
+            FrmFieldsHelper::show_single_option( $field );
480 480
         }
481 481
 
482 482
         wp_die();
483 483
     }
484 484
 
485 485
     public static function update_order() {
486
-		FrmAppHelper::permission_check('frm_edit_forms');
486
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
487 487
         check_ajax_referer( 'frm_ajax', 'nonce' );
488 488
 
489 489
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
             'rte'       => 'textarea',
501 501
             'website'   => 'url',
502 502
         );
503
-        if ( isset( $type_switch[ $type ] ) ) {
504
-            $type = $type_switch[ $type ];
503
+        if ( isset( $type_switch[$type] ) ) {
504
+            $type = $type_switch[$type];
505 505
         }
506 506
 
507 507
 		$frm_field_selection = FrmField::field_selection();
508
-        $types = array_keys($frm_field_selection);
509
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
508
+        $types = array_keys( $frm_field_selection );
509
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
510 510
             $type = 'text';
511 511
         }
512 512
 
@@ -545,19 +545,19 @@  discard block
 block discarded – undo
545 545
 
546 546
     public static function input_html( $field, $echo = true ) {
547 547
         $class = array(); //$field['type'];
548
-        self::add_input_classes($field, $class);
548
+        self::add_input_classes( $field, $class );
549 549
 
550 550
         $add_html = array();
551
-        self::add_html_size($field, $add_html);
552
-        self::add_html_length($field, $add_html);
553
-        self::add_html_placeholder($field, $add_html, $class);
551
+        self::add_html_size( $field, $add_html );
552
+        self::add_html_length( $field, $add_html );
553
+        self::add_html_placeholder( $field, $add_html, $class );
554 554
 		//self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete
555 555
 
556
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
556
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
557 557
 
558 558
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
559 559
 
560
-        self::add_shortcodes_to_html($field, $add_html);
560
+        self::add_shortcodes_to_html( $field, $add_html );
561 561
 
562 562
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
563 563
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     }
571 571
 
572 572
 	private static function add_input_classes( $field, array &$class ) {
573
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
573
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
574 574
             $class[] = $field['input_class'];
575 575
         }
576 576
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             $class[] = 'dyn_default_value';
584 584
         }
585 585
 
586
-        if ( isset($field['size']) && $field['size'] > 0 ) {
586
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
587 587
             $class[] = 'auto_width';
588 588
         }
589 589
     }
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
             return;
594 594
         }
595 595
 
596
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
596
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
597 597
             return;
598 598
         }
599 599
 
600
-        if ( is_numeric($field['size']) ) {
600
+        if ( is_numeric( $field['size'] ) ) {
601 601
             $field['size'] .= 'px';
602 602
         }
603 603
 
604
-        $important = apply_filters('frm_use_important_width', 1, $field);
604
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
605 605
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
606
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
606
+        $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
607 607
 
608
-        self::add_html_cols($field, $add_html);
608
+        self::add_html_cols( $field, $add_html );
609 609
     }
610 610
 
611 611
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
         );
623 623
 
624 624
         // include "col" for valid html
625
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
625
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
626 626
 
627
-        if ( ! isset( $calc[ $unit ] ) ) {
627
+        if ( ! isset( $calc[$unit] ) ) {
628 628
             return;
629 629
         }
630 630
 
631
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
631
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
632 632
 
633 633
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
634 634
     }
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
             return;
640 640
         }
641 641
 
642
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
642
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
643 643
             // don't load on form builder page
644 644
             return;
645 645
         }
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
 
665 665
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
666 666
             // use HMTL5 placeholder with js fallback
667
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
668
-            wp_enqueue_script('jquery-placeholder');
667
+            $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
668
+            wp_enqueue_script( 'jquery-placeholder' );
669 669
         } else if ( ! $frm_settings->use_html ) {
670 670
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
671
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
671
+            $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
672 672
             $class[] = 'frm_toggle_default';
673 673
 
674 674
             if ( $field['value'] == $field['default_value'] ) {
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			$format = FrmEntryValidate::phone_format( $field );
693 693
 			$format = substr( $format, 2, -2 );
694 694
 			$key = 'pattern';
695
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
695
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
696 696
 		}
697 697
 	}
698 698
 
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
                 continue;
707 707
             }
708 708
 
709
-            if ( is_numeric($k) && strpos($v, '=') ) {
709
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
710 710
                 $add_html[] = $v;
711
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
712
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
711
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
712
+                $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
713 713
             } else {
714
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
714
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
715 715
             }
716 716
 
717
-            unset($k, $v);
717
+            unset( $k, $v );
718 718
         }
719 719
     }
720 720
 
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
     }
731 731
 
732 732
 	public static function check_label( $opt ) {
733
-        if ( is_array($opt) ) {
734
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
733
+        if ( is_array( $opt ) ) {
734
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
735 735
         }
736 736
 
737 737
         return $opt;
Please login to merge, or discard this patch.
classes/models/FrmAddon.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	}
39 39
 
40 40
 	public function insert_installed_addon( $plugins ) {
41
-		$plugins[ $this->plugin_slug ] = $this;
41
+		$plugins[$this->plugin_slug] = $this;
42 42
 		return $plugins;
43 43
 	}
44 44
 
45 45
 	public static function get_addon( $plugin_slug ) {
46 46
 		$plugins = apply_filters( 'frm_installed_addons', array() );
47 47
 		$plugin = false;
48
-		if ( isset( $plugins[ $plugin_slug ] ) ) {
49
-			$plugin = $plugins[ $plugin_slug ];
48
+		if ( isset( $plugins[$plugin_slug] ) ) {
49
+			$plugin = $plugins[$plugin_slug];
50 50
 		}
51 51
 		return $plugin;
52 52
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	public function show_license_message( $file, $plugin ) {
99 99
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
100 100
 		echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
101
-		echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
101
+		echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
102 102
 		$id = sanitize_title( $plugin['Name'] );
103 103
 		echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>';
104 104
 		echo '</div></td></tr>';
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 
112 112
 		if ( $this->is_current_version( $transient ) ) {
113 113
 			//make sure it doesn't show there is an update if plugin is up-to-date
114
-			if ( isset( $transient->response[ $this->plugin_folder ] ) ) {
115
-				unset( $transient->response[ $this->plugin_folder ] );
114
+			if ( isset( $transient->response[$this->plugin_folder] ) ) {
115
+				unset( $transient->response[$this->plugin_folder] );
116 116
 			}
117
-		} else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) {
117
+		} else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) {
118 118
 			$cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' );
119 119
 			$version_info = get_transient( $cache_key );
120 120
 			if ( $version_info !== false && version_compare( $version_info->new_version, $this->version, '>' ) ) {
121
-				$transient->response[ $this->plugin_folder ] = $version_info;
121
+				$transient->response[$this->plugin_folder] = $version_info;
122 122
 			} else {
123 123
 				delete_transient( $cache_key );
124 124
 				if ( ! $this->has_been_cleared() ) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 					$this->manually_queue_update();
128 128
 				}
129 129
 
130
-				unset( $transient->response[ $this->plugin_folder ] );
130
+				unset( $transient->response[$this->plugin_folder] );
131 131
 			}
132 132
 		}
133 133
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	private function is_current_version( $transient ) {
138
-		if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) {
138
+		if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) {
139 139
 			return false;
140 140
 		}
141 141
 
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
 			return true;
145 145
 		}
146 146
 
147
-		return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version;
147
+		return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version;
148 148
 	}
149 149
 
150 150
 	private function has_been_cleared() {
151 151
 		$last_cleared = get_option( 'frm_last_cleared' );
152
-		return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime('-5 minutes') ) );
152
+		return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) );
153 153
 	}
154 154
 
155 155
 	private function cleared_plugins() {
156
-		update_option( 'frm_last_cleared', date('Y-m-d H:i:s') );
156
+		update_option( 'frm_last_cleared', date( 'Y-m-d H:i:s' ) );
157 157
 	}
158 158
 
159 159
 	public static function activate() {
160
-		FrmAppHelper::permission_check('frm_change_settings');
160
+		FrmAppHelper::permission_check( 'frm_change_settings' );
161 161
 	 	check_ajax_referer( 'frm_ajax', 'nonce' );
162 162
 
163 163
 		if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	}
206 206
 
207 207
 	public static function deactivate() {
208
-		FrmAppHelper::permission_check('frm_change_settings');
208
+		FrmAppHelper::permission_check( 'frm_change_settings' );
209 209
 		check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$plugin_slug = sanitize_text_field( $_POST['plugin'] );
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$message = __( 'Your License Key was invalid', 'formidable' );
257 257
 		if ( is_wp_error( $resp ) ) {
258
-			$message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>');
258
+			$message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' );
259 259
 			if ( is_wp_error( $resp ) ) {
260
-				$message .= ' '. $resp->get_error_message();
260
+				$message .= ' ' . $resp->get_error_message();
261 261
 			}
262 262
 		} else if ( $body == 'error' || is_wp_error( $body ) ) {
263 263
 			$message = __( 'You had an HTTP error connecting to Formidable Pro\'s API', 'formidable' );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 					$message = $json_res;
271 271
 				}
272 272
 			} else if ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) {
273
-				$message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] .' '. $resp['body'] );
273
+				$message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] );
274 274
 			}
275 275
 		}
276 276
 
Please login to merge, or discard this patch.