Completed
Push — master ( a59cae...706dd9 )
by Stephanie
03:48
created
classes/controllers/FrmAppController.php 1 patch
Indentation   +123 added lines, -123 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,15 +19,15 @@  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 27
 		$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
28
-        if ( empty( $show_nav ) || ! $form ) {
29
-            return;
30
-        }
28
+		if ( empty( $show_nav ) || ! $form ) {
29
+			return;
30
+		}
31 31
 
32 32
 		FrmForm::maybe_get_form( $form );
33 33
 		if ( ! is_object( $form ) ) {
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
 		return $nav_items;
86 86
 	}
87 87
 
88
-    // Adds a settings link to the plugins page
89
-    public static function settings_link( $links ) {
88
+	// Adds a settings link to the plugins page
89
+	public static function settings_link( $links ) {
90 90
 		$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
91
-        array_unshift( $links, $settings );
91
+		array_unshift( $links, $settings );
92 92
 
93
-        return $links;
94
-    }
93
+		return $links;
94
+	}
95 95
 
96
-    public static function pro_get_started_headline() {
96
+	public static function pro_get_started_headline() {
97 97
 		self::maybe_show_upgrade_bar();
98 98
 
99
-        // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
100
-        if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
101
-            return;
102
-        }
99
+		// Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
100
+		if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
101
+			return;
102
+		}
103 103
 
104 104
 		if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) {
105
-            FrmAppHelper::load_admin_wide_js();
105
+			FrmAppHelper::load_admin_wide_js();
106 106
 
107
-            // user is authorized, but running free version
108
-            $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
109
-        ?>
107
+			// user is authorized, but running free version
108
+			$inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
109
+		?>
110 110
 <div class="error" class="frm_previous_install">
111 111
 		<?php
112 112
 		echo wp_kses_post( apply_filters( 'frm_pro_update_msg',
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 		) ); ?>
119 119
 </div>
120 120
 <?php
121
-        }
122
-    }
121
+		}
122
+	}
123 123
 
124 124
 	private static function maybe_show_upgrade_bar() {
125 125
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 	}
223 223
 
224
-    public static function admin_js() {
224
+	public static function admin_js() {
225 225
 		$version = FrmAppHelper::plugin_version();
226 226
 		FrmAppHelper::load_admin_wide_js( false );
227 227
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			'bootstrap_tooltip', 'bootstrap-multiselect',
233 233
 		), $version, true );
234 234
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
235
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
235
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
236 236
 		wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
237 237
 		wp_register_style( 'formidable-dropzone', FrmAppHelper::plugin_url() . '/css/dropzone.css', array(), $version );
238 238
 
@@ -245,65 +245,65 @@  discard block
 block discarded – undo
245 245
 		global $pagenow;
246 246
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
247 247
 
248
-            wp_enqueue_script( 'admin-widgets' );
249
-            wp_enqueue_style( 'widgets' );
250
-            wp_enqueue_script( 'formidable' );
251
-            wp_enqueue_script( 'formidable_admin' );
248
+			wp_enqueue_script( 'admin-widgets' );
249
+			wp_enqueue_style( 'widgets' );
250
+			wp_enqueue_script( 'formidable' );
251
+			wp_enqueue_script( 'formidable_admin' );
252 252
 			FrmAppHelper::localize_script( 'admin' );
253 253
 
254
-            wp_enqueue_style( 'formidable-admin' );
254
+			wp_enqueue_style( 'formidable-admin' );
255 255
 			wp_enqueue_style( 'formidable-grids' );
256 256
 			wp_enqueue_style( 'formidable-dropzone' );
257
-            add_thickbox();
257
+			add_thickbox();
258 258
 
259
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
259
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
260 260
 
261
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
262
-            if ( isset( $_REQUEST['post_type'] ) ) {
263
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
261
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
262
+			if ( isset( $_REQUEST['post_type'] ) ) {
263
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
264 264
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
265 265
 				$post = get_post( absint( $_REQUEST['post'] ) );
266
-                if ( ! $post ) {
267
-                    return;
268
-                }
269
-                $post_type = $post->post_type;
270
-            } else {
271
-                return;
272
-            }
273
-
274
-            if ( $post_type == 'frm_display' ) {
275
-                wp_enqueue_script( 'jquery-ui-draggable' );
276
-                wp_enqueue_script( 'formidable_admin' );
277
-                wp_enqueue_style( 'formidable-admin' );
266
+				if ( ! $post ) {
267
+					return;
268
+				}
269
+				$post_type = $post->post_type;
270
+			} else {
271
+				return;
272
+			}
273
+
274
+			if ( $post_type == 'frm_display' ) {
275
+				wp_enqueue_script( 'jquery-ui-draggable' );
276
+				wp_enqueue_script( 'formidable_admin' );
277
+				wp_enqueue_style( 'formidable-admin' );
278 278
 				FrmAppHelper::localize_script( 'admin' );
279
-            }
280
-        } else if ( $pagenow == 'widgets.php' ) {
281
-            FrmAppHelper::load_admin_wide_js();
282
-        }
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 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
-    }
279
+			}
280
+		} else if ( $pagenow == 'widgets.php' ) {
281
+			FrmAppHelper::load_admin_wide_js();
282
+		}
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 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' );
@@ -358,20 +358,20 @@  discard block
 block discarded – undo
358 358
 		wp_die();
359 359
 	}
360 360
 
361
-    public static function activation_install() {
362
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
363
-        FrmFormActionsController::actions_init();
364
-        self::install();
365
-    }
361
+	public static function activation_install() {
362
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
363
+		FrmFormActionsController::actions_init();
364
+		self::install();
365
+	}
366 366
 
367
-    public static function install( $old_db_version = false ) {
368
-        $frmdb = new FrmDb();
369
-        $frmdb->upgrade( $old_db_version );
370
-    }
367
+	public static function install( $old_db_version = false ) {
368
+		$frmdb = new FrmDb();
369
+		$frmdb->upgrade( $old_db_version );
370
+	}
371 371
 
372
-    public static function uninstall() {
372
+	public static function uninstall() {
373 373
 		FrmAppHelper::permission_check('administrator');
374
-        check_ajax_referer( 'frm_ajax', 'nonce' );
374
+		check_ajax_referer( 'frm_ajax', 'nonce' );
375 375
 
376 376
 		$frmdb = new FrmDb();
377 377
 		$frmdb->uninstall();
@@ -380,43 +380,43 @@  discard block
 block discarded – undo
380 380
 		deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
381 381
 		echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
382 382
 
383
-        wp_die();
384
-    }
383
+		wp_die();
384
+	}
385 385
 
386
-    public static function drop_tables( $tables ) {
387
-        global $wpdb;
388
-        $tables[] = $wpdb->prefix . 'frm_fields';
389
-        $tables[] = $wpdb->prefix . 'frm_forms';
390
-        $tables[] = $wpdb->prefix . 'frm_items';
391
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
392
-        return $tables;
393
-    }
386
+	public static function drop_tables( $tables ) {
387
+		global $wpdb;
388
+		$tables[] = $wpdb->prefix . 'frm_fields';
389
+		$tables[] = $wpdb->prefix . 'frm_forms';
390
+		$tables[] = $wpdb->prefix . 'frm_items';
391
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
392
+		return $tables;
393
+	}
394 394
 
395
-    // Routes for wordpress pages -- we're just replacing content here folks.
396
-    public static function page_route( $content ) {
397
-        global $post;
395
+	// Routes for wordpress pages -- we're just replacing content here folks.
396
+	public static function page_route( $content ) {
397
+		global $post;
398 398
 
399
-        $frm_settings = FrmAppHelper::get_settings();
400
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
401
-            $content = FrmFormsController::page_preview();
402
-        }
399
+		$frm_settings = FrmAppHelper::get_settings();
400
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
401
+			$content = FrmFormsController::page_preview();
402
+		}
403 403
 
404
-        return $content;
405
-    }
404
+		return $content;
405
+	}
406 406
 
407
-    public static function deauthorize() {
407
+	public static function deauthorize() {
408 408
 		FrmAppHelper::permission_check('frm_change_settings');
409
-        check_ajax_referer( 'frm_ajax', 'nonce' );
410
-
411
-        delete_option( 'frmpro-credentials' );
412
-        delete_option( 'frmpro-authorized' );
413
-        delete_site_option( 'frmpro-credentials' );
414
-        delete_site_option( 'frmpro-authorized' );
415
-        wp_die();
416
-    }
417
-
418
-    public static function get_form_shortcode( $atts ) {
419
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
420
-        return FrmFormsController::get_form_shortcode( $atts );
421
-    }
409
+		check_ajax_referer( 'frm_ajax', 'nonce' );
410
+
411
+		delete_option( 'frmpro-credentials' );
412
+		delete_option( 'frmpro-authorized' );
413
+		delete_site_option( 'frmpro-credentials' );
414
+		delete_site_option( 'frmpro-authorized' );
415
+		wp_die();
416
+	}
417
+
418
+	public static function get_form_shortcode( $atts ) {
419
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
420
+		return FrmFormsController::get_form_shortcode( $atts );
421
+	}
422 422
 }
Please login to merge, or discard this patch.