@@ -3,14 +3,14 @@ discard block |
||
| 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,17 +19,17 @@ discard block |
||
| 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 $frm_vars; |
|
| 27 | + global $frm_vars; |
|
| 28 | 28 | |
| 29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 30 | - if ( empty( $show_nav || ! $form ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 30 | + if ( empty( $show_nav || ! $form ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | FrmForm::maybe_get_form( $form ); |
| 35 | 35 | if ( ! is_object( $form ) ) { |
@@ -87,28 +87,28 @@ discard block |
||
| 87 | 87 | return $nav_items; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - // Adds a settings link to the plugins page |
|
| 91 | - public static function settings_link( $links ) { |
|
| 90 | + // Adds a settings link to the plugins page |
|
| 91 | + public static function settings_link( $links ) { |
|
| 92 | 92 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 93 | - array_unshift( $links, $settings ); |
|
| 93 | + array_unshift( $links, $settings ); |
|
| 94 | 94 | |
| 95 | - return $links; |
|
| 96 | - } |
|
| 95 | + return $links; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - public static function pro_get_started_headline() { |
|
| 98 | + public static function pro_get_started_headline() { |
|
| 99 | 99 | self::maybe_show_upgrade_bar(); |
| 100 | 100 | |
| 101 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 102 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 103 | - return; |
|
| 104 | - } |
|
| 101 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 102 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 103 | + return; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | 106 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 107 | - FrmAppHelper::load_admin_wide_js(); |
|
| 107 | + FrmAppHelper::load_admin_wide_js(); |
|
| 108 | 108 | |
| 109 | - // user is authorized, but running free version |
|
| 110 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 111 | - ?> |
|
| 109 | + // user is authorized, but running free version |
|
| 110 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 111 | + ?> |
|
| 112 | 112 | <div class="error" class="frm_previous_install"> |
| 113 | 113 | <?php |
| 114 | 114 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | ) ); ?> |
| 121 | 121 | </div> |
| 122 | 122 | <?php |
| 123 | - } |
|
| 124 | - } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | private static function maybe_show_upgrade_bar() { |
| 127 | 127 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public static function admin_js() { |
|
| 226 | + public static function admin_js() { |
|
| 227 | 227 | $version = FrmAppHelper::plugin_version(); |
| 228 | 228 | FrmAppHelper::load_admin_wide_js( false ); |
| 229 | 229 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 235 | 235 | ), $version, true ); |
| 236 | 236 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 237 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 237 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 238 | 238 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 239 | 239 | wp_register_style( 'formidable-dropzone', FrmAppHelper::plugin_url() . '/css/dropzone.css', array(), $version ); |
| 240 | 240 | |
@@ -247,65 +247,65 @@ discard block |
||
| 247 | 247 | global $pagenow; |
| 248 | 248 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 249 | 249 | |
| 250 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | - wp_enqueue_style( 'widgets' ); |
|
| 252 | - wp_enqueue_script( 'formidable' ); |
|
| 253 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 250 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | + wp_enqueue_style( 'widgets' ); |
|
| 252 | + wp_enqueue_script( 'formidable' ); |
|
| 253 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 254 | 254 | FrmAppHelper::localize_script( 'admin' ); |
| 255 | 255 | |
| 256 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 256 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 257 | 257 | wp_enqueue_style( 'formidable-grids' ); |
| 258 | 258 | wp_enqueue_style( 'formidable-dropzone' ); |
| 259 | - add_thickbox(); |
|
| 259 | + add_thickbox(); |
|
| 260 | 260 | |
| 261 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 261 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 262 | 262 | |
| 263 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 263 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 266 | 266 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 267 | 267 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 268 | - if ( ! $post ) { |
|
| 269 | - return; |
|
| 270 | - } |
|
| 271 | - $post_type = $post->post_type; |
|
| 272 | - } else { |
|
| 273 | - return; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - if ( $post_type == 'frm_display' ) { |
|
| 277 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 268 | + if ( ! $post ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | + $post_type = $post->post_type; |
|
| 272 | + } else { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + if ( $post_type == 'frm_display' ) { |
|
| 277 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 280 | 280 | FrmAppHelper::localize_script( 'admin' ); |
| 281 | - } |
|
| 282 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | - FrmAppHelper::load_admin_wide_js(); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - public static function load_lang() { |
|
| 288 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Filter shortcodes in text widgets |
|
| 293 | - */ |
|
| 294 | - public static function widget_text_filter( $content ) { |
|
| 295 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 296 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - public static function front_head() { |
|
| 300 | - if ( is_multisite() ) { |
|
| 301 | - $old_db_version = get_option( 'frm_db_version' ); |
|
| 302 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 303 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 304 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 305 | - self::install( $old_db_version ); |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - } |
|
| 281 | + } |
|
| 282 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | + FrmAppHelper::load_admin_wide_js(); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + public static function load_lang() { |
|
| 288 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Filter shortcodes in text widgets |
|
| 293 | + */ |
|
| 294 | + public static function widget_text_filter( $content ) { |
|
| 295 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 296 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + public static function front_head() { |
|
| 300 | + if ( is_multisite() ) { |
|
| 301 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 302 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 303 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 304 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 305 | + self::install( $old_db_version ); |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | 310 | public static function localize_script( $location ) { |
| 311 | 311 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -360,20 +360,20 @@ discard block |
||
| 360 | 360 | wp_die(); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - public static function activation_install() { |
|
| 364 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 365 | - FrmFormActionsController::actions_init(); |
|
| 366 | - self::install(); |
|
| 367 | - } |
|
| 363 | + public static function activation_install() { |
|
| 364 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 365 | + FrmFormActionsController::actions_init(); |
|
| 366 | + self::install(); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - public static function install( $old_db_version = false ) { |
|
| 370 | - $frmdb = new FrmDb(); |
|
| 371 | - $frmdb->upgrade( $old_db_version ); |
|
| 372 | - } |
|
| 369 | + public static function install( $old_db_version = false ) { |
|
| 370 | + $frmdb = new FrmDb(); |
|
| 371 | + $frmdb->upgrade( $old_db_version ); |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - public static function uninstall() { |
|
| 374 | + public static function uninstall() { |
|
| 375 | 375 | FrmAppHelper::permission_check('administrator'); |
| 376 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 376 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 377 | 377 | |
| 378 | 378 | $frmdb = new FrmDb(); |
| 379 | 379 | $frmdb->uninstall(); |
@@ -382,43 +382,43 @@ discard block |
||
| 382 | 382 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 383 | 383 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 384 | 384 | |
| 385 | - wp_die(); |
|
| 386 | - } |
|
| 385 | + wp_die(); |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - public static function drop_tables( $tables ) { |
|
| 389 | - global $wpdb; |
|
| 390 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 391 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 392 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 393 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 394 | - return $tables; |
|
| 395 | - } |
|
| 388 | + public static function drop_tables( $tables ) { |
|
| 389 | + global $wpdb; |
|
| 390 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 391 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 392 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 393 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 394 | + return $tables; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 398 | - public static function page_route( $content ) { |
|
| 399 | - global $post; |
|
| 397 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 398 | + public static function page_route( $content ) { |
|
| 399 | + global $post; |
|
| 400 | 400 | |
| 401 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 402 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 403 | - $content = FrmFormsController::page_preview(); |
|
| 404 | - } |
|
| 401 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 402 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 403 | + $content = FrmFormsController::page_preview(); |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - return $content; |
|
| 407 | - } |
|
| 406 | + return $content; |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - public static function deauthorize() { |
|
| 409 | + public static function deauthorize() { |
|
| 410 | 410 | FrmAppHelper::permission_check('frm_change_settings'); |
| 411 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 412 | - |
|
| 413 | - delete_option( 'frmpro-credentials' ); |
|
| 414 | - delete_option( 'frmpro-authorized' ); |
|
| 415 | - delete_site_option( 'frmpro-credentials' ); |
|
| 416 | - delete_site_option( 'frmpro-authorized' ); |
|
| 417 | - wp_die(); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - public static function get_form_shortcode( $atts ) { |
|
| 421 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 422 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 423 | - } |
|
| 411 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 412 | + |
|
| 413 | + delete_option( 'frmpro-credentials' ); |
|
| 414 | + delete_option( 'frmpro-authorized' ); |
|
| 415 | + delete_site_option( 'frmpro-credentials' ); |
|
| 416 | + delete_site_option( 'frmpro-authorized' ); |
|
| 417 | + wp_die(); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + public static function get_form_shortcode( $atts ) { |
|
| 421 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 422 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 423 | + } |
|
| 424 | 424 | } |