Completed
Push — master ( cfd0f4...9c0b37 )
by Stephanie
04:58
created
classes/controllers/FrmAppController.php 1 patch
Indentation   +144 added lines, -144 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 11
 		$menu_name = FrmAppHelper::get_menu_name();
12 12
 		add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() );
13
-    }
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' );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		}
219 219
 	}
220 220
 
221
-    public static function admin_js() {
221
+	public static function admin_js() {
222 222
 		$version = FrmAppHelper::plugin_version();
223 223
 		FrmAppHelper::load_admin_wide_js( false );
224 224
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			'bootstrap_tooltip', 'bootstrap-multiselect',
230 230
 		), $version, true );
231 231
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
232
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
232
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
233 233
 		wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
234 234
 
235 235
 		// load multselect js
@@ -241,69 +241,69 @@  discard block
 block discarded – undo
241 241
 		global $pagenow;
242 242
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
243 243
 
244
-            wp_enqueue_script( 'admin-widgets' );
245
-            wp_enqueue_style( 'widgets' );
246
-            wp_enqueue_script( 'formidable' );
247
-            wp_enqueue_script( 'formidable_admin' );
244
+			wp_enqueue_script( 'admin-widgets' );
245
+			wp_enqueue_style( 'widgets' );
246
+			wp_enqueue_script( 'formidable' );
247
+			wp_enqueue_script( 'formidable_admin' );
248 248
 			FrmAppHelper::localize_script( 'admin' );
249 249
 
250
-            wp_enqueue_style( 'formidable-admin' );
250
+			wp_enqueue_style( 'formidable-admin' );
251 251
 			wp_enqueue_style( 'formidable-grids' );
252
-            add_thickbox();
252
+			add_thickbox();
253 253
 
254
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
254
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
255 255
 
256
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
257
-            if ( isset( $_REQUEST['post_type'] ) ) {
258
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
256
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
257
+			if ( isset( $_REQUEST['post_type'] ) ) {
258
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
259 259
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
260 260
 				$post = get_post( absint( $_REQUEST['post'] ) );
261
-                if ( ! $post ) {
262
-                    return;
263
-                }
264
-                $post_type = $post->post_type;
265
-            } else {
266
-                return;
267
-            }
268
-
269
-            if ( $post_type == 'frm_display' ) {
270
-                wp_enqueue_script( 'jquery-ui-draggable' );
271
-                wp_enqueue_script( 'formidable_admin' );
272
-                wp_enqueue_style( 'formidable-admin' );
261
+				if ( ! $post ) {
262
+					return;
263
+				}
264
+				$post_type = $post->post_type;
265
+			} else {
266
+				return;
267
+			}
268
+
269
+			if ( $post_type == 'frm_display' ) {
270
+				wp_enqueue_script( 'jquery-ui-draggable' );
271
+				wp_enqueue_script( 'formidable_admin' );
272
+				wp_enqueue_style( 'formidable-admin' );
273 273
 				FrmAppHelper::localize_script( 'admin' );
274
-            }
275
-        } else if ( $pagenow == 'widgets.php' ) {
276
-            FrmAppHelper::load_admin_wide_js();
277
-        }
278
-    }
279
-
280
-    public static function load_lang() {
281
-        load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
282
-    }
283
-
284
-    /**
285
-     * Filter shortcodes in text widgets
286
-     */
287
-    public static function widget_text_filter( $content ) {
288
-    	$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
289
-    	return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
290
-    }
291
-
292
-    public static function widget_text_filter_callback( $matches ) {
293
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
294
-        return FrmAppHelper::widget_text_filter_callback( $matches );
295
-    }
296
-
297
-    public static function front_head() {
298
-        if ( is_multisite() ) {
299
-            $old_db_version = get_option( 'frm_db_version' );
300
-            $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
301
-            if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
302
-                ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
303
-                self::install( $old_db_version );
304
-            }
305
-        }
306
-    }
274
+			}
275
+		} else if ( $pagenow == 'widgets.php' ) {
276
+			FrmAppHelper::load_admin_wide_js();
277
+		}
278
+	}
279
+
280
+	public static function load_lang() {
281
+		load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
282
+	}
283
+
284
+	/**
285
+	 * Filter shortcodes in text widgets
286
+	 */
287
+	public static function widget_text_filter( $content ) {
288
+		$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
289
+		return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
290
+	}
291
+
292
+	public static function widget_text_filter_callback( $matches ) {
293
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
294
+		return FrmAppHelper::widget_text_filter_callback( $matches );
295
+	}
296
+
297
+	public static function front_head() {
298
+		if ( is_multisite() ) {
299
+			$old_db_version = get_option( 'frm_db_version' );
300
+			$pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
301
+			if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
302
+				( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
303
+				self::install( $old_db_version );
304
+			}
305
+		}
306
+	}
307 307
 
308 308
 	public static function localize_script( $location ) {
309 309
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
@@ -363,20 +363,20 @@  discard block
 block discarded – undo
363 363
 		wp_die();
364 364
 	}
365 365
 
366
-    public static function activation_install() {
367
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
368
-        FrmFormActionsController::actions_init();
369
-        self::install();
370
-    }
366
+	public static function activation_install() {
367
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
368
+		FrmFormActionsController::actions_init();
369
+		self::install();
370
+	}
371 371
 
372
-    public static function install( $old_db_version = false ) {
373
-        $frmdb = new FrmDb();
374
-        $frmdb->upgrade( $old_db_version );
375
-    }
372
+	public static function install( $old_db_version = false ) {
373
+		$frmdb = new FrmDb();
374
+		$frmdb->upgrade( $old_db_version );
375
+	}
376 376
 
377
-    public static function uninstall() {
377
+	public static function uninstall() {
378 378
 		FrmAppHelper::permission_check('administrator');
379
-        check_ajax_referer( 'frm_ajax', 'nonce' );
379
+		check_ajax_referer( 'frm_ajax', 'nonce' );
380 380
 
381 381
 		$frmdb = new FrmDb();
382 382
 		$frmdb->uninstall();
@@ -385,48 +385,48 @@  discard block
 block discarded – undo
385 385
 		deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
386 386
 		echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
387 387
 
388
-        wp_die();
389
-    }
388
+		wp_die();
389
+	}
390 390
 
391
-    public static function drop_tables( $tables ) {
392
-        global $wpdb;
393
-        $tables[] = $wpdb->prefix . 'frm_fields';
394
-        $tables[] = $wpdb->prefix . 'frm_forms';
395
-        $tables[] = $wpdb->prefix . 'frm_items';
396
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
397
-        return $tables;
398
-    }
391
+	public static function drop_tables( $tables ) {
392
+		global $wpdb;
393
+		$tables[] = $wpdb->prefix . 'frm_fields';
394
+		$tables[] = $wpdb->prefix . 'frm_forms';
395
+		$tables[] = $wpdb->prefix . 'frm_items';
396
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
397
+		return $tables;
398
+	}
399 399
 
400
-    // Routes for wordpress pages -- we're just replacing content here folks.
401
-    public static function page_route( $content ) {
402
-        global $post;
400
+	// Routes for wordpress pages -- we're just replacing content here folks.
401
+	public static function page_route( $content ) {
402
+		global $post;
403 403
 
404
-        $frm_settings = FrmAppHelper::get_settings();
405
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
406
-            $content = FrmFormsController::page_preview();
407
-        }
404
+		$frm_settings = FrmAppHelper::get_settings();
405
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
406
+			$content = FrmFormsController::page_preview();
407
+		}
408 408
 
409
-        return $content;
410
-    }
409
+		return $content;
410
+	}
411 411
 
412
-    public static function deauthorize() {
412
+	public static function deauthorize() {
413 413
 		FrmAppHelper::permission_check('frm_change_settings');
414
-        check_ajax_referer( 'frm_ajax', 'nonce' );
415
-
416
-        delete_option( 'frmpro-credentials' );
417
-        delete_option( 'frmpro-authorized' );
418
-        delete_site_option( 'frmpro-credentials' );
419
-        delete_site_option( 'frmpro-authorized' );
420
-        wp_die();
421
-    }
422
-
423
-    public static function get_form_shortcode( $atts ) {
424
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
425
-        return FrmFormsController::get_form_shortcode( $atts );
426
-    }
427
-
428
-    public static function get_postbox_class() {
429
-        _deprecated_function( __FUNCTION__, '2.0' );
430
-        return 'postbox-container';
431
-    }
414
+		check_ajax_referer( 'frm_ajax', 'nonce' );
415
+
416
+		delete_option( 'frmpro-credentials' );
417
+		delete_option( 'frmpro-authorized' );
418
+		delete_site_option( 'frmpro-credentials' );
419
+		delete_site_option( 'frmpro-authorized' );
420
+		wp_die();
421
+	}
422
+
423
+	public static function get_form_shortcode( $atts ) {
424
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
425
+		return FrmFormsController::get_form_shortcode( $atts );
426
+	}
427
+
428
+	public static function get_postbox_class() {
429
+		_deprecated_function( __FUNCTION__, '2.0' );
430
+		return 'postbox-container';
431
+	}
432 432
 }
Please login to merge, or discard this patch.