PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.0
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmAppController.php +43 -279 6.4.16.0 View file →
@@ -4,11 +4,8 @@
4 4 }
5 5
6 6 class FrmAppController {
7 7
8 - /**
9 - * @return void
10 - */
11 8 public static function menu() {
12 9 FrmAppHelper::maybe_add_permissions();
13 10 if ( ! current_user_can( 'frm_view_forms' ) ) {
14 11 return;
@@ -62,15 +59,9 @@
62 59 }
63 60 }
64 61
65 62 if ( FrmAppHelper::is_full_screen() ) {
66 - $full_screen_on = self::get_full_screen_setting();
67 - $add_class = '';
68 - if ( $full_screen_on ) {
69 - $add_class = ' frm-full-screen is-fullscreen-mode';
70 - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
71 - }
72 - $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
63 + $classes .= apply_filters( 'frm_admin_full_screen_class', ' frm-full-screen folded' );
73 64 }
74 65
75 66 if ( ! FrmAppHelper::pro_is_installed() ) {
76 67 $classes .= ' frm-lite ';
@@ -79,30 +70,9 @@
79 70 return $classes;
80 71 }
81 72
82 73 /**
83 - * Get the full screen mode setting from the block editor.
84 - *
85 - * @since 6.1
86 - *
87 - * @return bool
88 - */
89 - private static function get_full_screen_setting() {
90 - global $wpdb;
91 - $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';
92 -
93 - $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
94 - if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) {
95 - return $prefs['core/edit-post']['fullscreenMode'];
96 - }
97 -
98 - return true;
99 - }
100 -
101 - /**
102 74 * @since 4.0
103 - *
104 - * @return string
105 75 */
106 76 private static function get_os() {
107 77 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
108 78 $os = '';
@@ -123,9 +93,8 @@
123 93 $white_pages = array(
124 94 'formidable',
125 95 'formidable-entries',
126 96 'formidable-views',
127 - 'formidable-views-editor',
128 97 'formidable-pro-upgrade',
129 98 'formidable-addons',
130 99 'formidable-import',
131 100 'formidable-settings',
@@ -155,23 +124,12 @@
155 124
156 125 return $is_white_page;
157 126 }
158 127
159 - /**
160 - * @return void
161 - */
162 128 public static function load_wp_admin_style() {
163 129 FrmAppHelper::load_font_style();
164 130 }
165 131
166 - /**
167 - * @param bool $show_nav
168 - * @param string $title
169 - *
170 - * @psalm-param 'hide'|'show' $title
171 - *
172 - * @return void
173 - */
174 132 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
175 133 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
176 134 if ( empty( $show_nav ) || ! $form ) {
177 135 return;
@@ -188,11 +146,8 @@
188 146
189 147 include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
190 148 }
191 149
192 - /**
193 - * @return string
194 - */
195 150 private static function get_current_page() {
196 151 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
197 152 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
198 153 $current_page = isset( $_GET['page'] ) ? $page : $post_type;
@@ -203,12 +158,8 @@
203 158
204 159 return $current_page;
205 160 }
206 161
207 - /**
208 - * @param object $form
209 - * @return array
210 - */
211 162 private static function get_form_nav_items( $form ) {
212 163 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
213 164
214 165 $nav_items = array(
@@ -275,15 +226,12 @@
275 226 'form_id' => $id,
276 227 'form' => $form,
277 228 );
278 229
279 - return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
230 + return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
280 231 }
281 232
282 233 // Adds a settings link to the plugins page
283 - /**
284 - * @return array
285 - */
286 234 public static function settings_link( $links ) {
287 235 $settings = array();
288 236
289 237 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -294,11 +242,8 @@
294 242
295 243 return array_merge( $settings, $links );
296 244 }
297 245
298 - /**
299 - * @return void
300 - */
301 246 public static function pro_get_started_headline() {
302 247 self::review_request();
303 248 FrmAppHelper::min_pro_version_notice( '4.0' );
304 249 }
@@ -306,10 +251,8 @@
306 251 /**
307 252 * Add admin notices as needed for reviews
308 253 *
309 254 * @since 3.04.03
310 - *
311 - * @return void
312 255 */
313 256 private static function review_request() {
314 257 $reviews = new FrmReviews();
315 258 $reviews->review_request();
@@ -318,10 +261,8 @@
318 261 /**
319 262 * Save the request to hide the review
320 263 *
321 264 * @since 3.04.03
322 - *
323 - * @return void
324 265 */
325 266 public static function dismiss_review() {
326 267 FrmAppHelper::permission_check( 'frm_change_settings' );
327 268 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -331,10 +272,8 @@
331 272 }
332 273
333 274 /**
334 275 * @since 3.04.02
335 - *
336 - * @return void
337 276 */
338 277 public static function include_upgrade_overlay() {
339 278 self::enqueue_dialog_assets();
340 279 add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' );
@@ -353,10 +292,8 @@
353 292 }
354 293
355 294 /**
356 295 * @since 3.06.03
357 - *
358 - * @return void
359 296 */
360 297 public static function upgrade_overlay_html() {
361 298 $is_pro = FrmAppHelper::pro_is_installed();
362 299 $upgrade_link = array(
@@ -374,11 +311,8 @@
374 311 self::new_form_overlay_html();
375 312 }
376 313 }
377 314
378 - /**
379 - * @return void
380 - */
381 315 private static function new_form_overlay_html() {
382 316 FrmFormsController::before_list_templates();
383 317
384 318 $plugin_path = FrmAppHelper::plugin_path();
@@ -425,19 +359,13 @@
425 359
426 360 include $path . 'new-form-overlay.php';
427 361 }
428 362
429 - /**
430 - * @return void
431 - */
432 363 public static function include_info_overlay() {
433 364 self::enqueue_dialog_assets();
434 365 add_action( 'admin_footer', 'FrmAppController::info_overlay_html' );
435 366 }
436 367
437 - /**
438 - * @return void
439 - */
440 368 public static function info_overlay_html() {
441 369 include FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php';
442 370 }
443 371
@@ -442,10 +370,8 @@
442 370 }
443 371
444 372 /**
445 373 * @since 3.04.02
446 - *
447 - * @return void
448 374 */
449 375 public static function remove_upsells() {
450 376 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
451 377 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
@@ -457,10 +383,8 @@
457 383 * If there are CURL problems on this server, wp_remote_post won't work for installing
458 384 * Use a javascript fallback instead.
459 385 *
460 386 * @since 2.0.3
461 - *
462 - * @return void
463 387 */
464 388 public static function install_js_fallback() {
465 389 FrmAppHelper::load_admin_wide_js();
466 390 ?>
@@ -494,11 +418,8 @@
494 418 /**
495 419 * Check both version number and DB number for changes
496 420 *
497 421 * @since 3.0.04
498 - *
499 - * @param array $atts
500 - * @return bool
501 422 */
502 423 public static function compare_for_update( $atts ) {
503 424 $db_version = get_option( $atts['option'] );
504 425
@@ -517,10 +438,8 @@
517 438 /**
518 439 * Check for database update and trigger js loading
519 440 *
520 441 * @since 2.0.1
521 - *
522 - * @return void
523 442 */
524 443 public static function admin_init() {
525 444 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 445 FrmFormsController::duplicate();
@@ -541,8 +460,10 @@
541 460 // don't continue during ajax calls
542 461 self::admin_js();
543 462 }
544 463
464 + self::disable_admin_menus();
465 +
545 466 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
546 467 $action = FrmAppHelper::get_param( 'frm_action' );
547 468
548 469 if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
@@ -551,72 +472,32 @@
551 472 }
552 473
553 474 FrmInbox::maybe_disable_screen_options();
554 475 }
555 -
556 - self::maybe_add_ip_warning();
557 476 }
558 477
559 478 /**
560 - * Show a warning for the IP address setting if it hasn't been set.
479 + * Remove the admin menus and hide the gaps on full screen pages.
561 480 *
562 - * @since 6.1
563 - *
564 - * @return void
481 + * @since 6.0
565 482 */
566 - private static function maybe_add_ip_warning() {
567 - $settings = FrmAppHelper::get_settings();
568 - if ( false !== $settings->custom_header_ip ) {
569 - // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
483 + private static function disable_admin_menus() {
484 + if ( ! FrmAppHelper::is_full_screen() ) {
570 485 return;
571 486 }
572 487
573 - if ( ! self::is_behind_proxy() ) {
574 - // This message is only applicable when using a reverse proxy.
575 - return;
576 - }
577 -
578 - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
579 - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
580 - return;
581 - }
582 -
583 - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
584 - $message = sprintf(
585 - // Translators: 1: Global Settings Link
586 - __( 'IP addresses in form submissions may no longer be accurate! If you are experiencing issues, we recommend going to %1$s and enabling the "Use custom headers when retrieving IPs with form submissions." setting.', 'formidable' ),
587 - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
488 + wp_deregister_script( 'admin-bar' );
489 + wp_deregister_style( 'admin-bar' );
490 + remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
491 + add_action(
492 + 'admin_head',
493 + function() {
494 + echo '<style>html.wp-toolbar{padding-top:0}</style>';
495 + }
588 496 );
589 - $option_name = 'frm_dismiss_ip_address_notice';
590 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
591 497 }
592 498
593 499 /**
594 - * Check if any reverse proxy headers are set.
595 - *
596 - * @since 6.1
597 - *
598 - * @return bool
599 - */
600 - private static function is_behind_proxy() {
601 - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
602 - foreach ( $custom_headers as $header ) {
603 - if ( 'REMOTE_ADDR' === $header ) {
604 - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
605 - continue;
606 - }
607 -
608 - $ip = trim( FrmAppHelper::get_server_value( $header ) );
609 - // Return true for anything that isn't empty but ignoring values like ::1.
610 - if ( $ip && 0 !== strpos( $ip, '::' ) ) {
611 - return true;
612 - }
613 - }
614 -
615 - return false;
616 - }
617 -
618 - /**
619 500 * @return void
620 501 */
621 502 public static function admin_js() {
622 503 $plugin_url = FrmAppHelper::plugin_url();
@@ -637,19 +518,8 @@
637 518 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
638 519
639 520 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
640 521
641 - // Enqueue Floating Links.
642 - $is_valid_page =
643 - FrmAppHelper::is_formidable_admin() &&
644 - ! FrmAppHelper::is_style_editor_page() &&
645 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
646 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
647 - if ( $is_valid_page ) {
648 - self::enqueue_floating_links( $plugin_url, $version );
649 - }
650 - unset( $is_valid_page );
651 -
652 522 if ( 'formidable-applications' === $page ) {
653 523 FrmApplicationsController::load_assets();
654 524 return;
655 525 }
@@ -723,64 +593,22 @@
723 593 return;
724 594 }
725 595
726 596 if ( $post_type === 'frm_display' ) {
727 - self::enqueue_legacy_views_assets();
597 + wp_enqueue_style( 'formidable-grids' );
598 + wp_enqueue_script( 'jquery-ui-draggable' );
599 + self::maybe_deregister_popper2();
600 + wp_enqueue_script( 'formidable_admin' );
601 + wp_enqueue_style( 'formidable-admin' );
602 + FrmAppHelper::localize_script( 'admin' );
603 + self::include_info_overlay();
728 604 }
729 605 }
730 606
731 - }
732 -
733 - /**
734 - * @since 6.3.2
735 - *
736 - * @return void
737 - */
738 - public static function admin_enqueue_scripts() {
739 - self::load_wp_admin_style();
740 607 self::maybe_force_formidable_block_on_gutenberg_page();
741 608 }
742 609
743 610 /**
744 - * Enqueue required assets for the Legacy Views editor (Views v4.x).
745 - *
746 - * @since 6.1.2
747 - *
748 - * @return void
749 - */
750 - private static function enqueue_legacy_views_assets() {
751 - wp_enqueue_style( 'formidable-grids' );
752 - wp_enqueue_script( 'jquery-ui-draggable' );
753 - self::maybe_deregister_popper2();
754 - wp_enqueue_script( 'formidable_admin' );
755 - wp_add_inline_style(
756 - 'formidable-admin',
757 - '
758 - .frm-white-body.post-type-frm_display .columns-2 {
759 - display: block;
760 - overflow: visible;
761 - }
762 -
763 - .frm-white-body.post-type-frm_display .columns-2 > div {
764 - overflow-y: hidden;
765 - }
766 -
767 - .frm-white-body.post-type-frm_display #titlediv #title-prompt-text {
768 - padding: 3px 0 0 10px;
769 - }
770 -
771 - .post-type-frm_display #field-search-input,
772 - .post-type-frm_display #advanced-search-input {
773 - flex: 1;
774 - }
775 - '
776 - );
777 - wp_enqueue_style( 'formidable-admin' );
778 - FrmAppHelper::localize_script( 'admin' );
779 - self::include_info_overlay();
780 - }
781 -
782 - /**
783 611 * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
784 612 *
785 613 * @since 5.2.02.01
786 614 *
@@ -834,12 +662,8 @@
834 662
835 663 /**
836 664 * @since 5.3
837 665 *
838 - * @param string $block_name
839 - * @param string $object_key
840 - * @param array|string $object_id
841 - *
842 666 * @return void
843 667 */
844 668 public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
845 669 require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
@@ -844,11 +668,8 @@
844 668 public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
845 669 require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
846 670 }
847 671
848 - /**
849 - * @return void
850 - */
851 672 public static function load_lang() {
852 673 load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
853 674 }
854 675
@@ -855,10 +676,8 @@
855 676 /**
856 677 * Check if the styles are updated when a form is loaded on the front-end
857 678 *
858 679 * @since 3.0.1
859 - *
860 - * @return void
861 680 */
862 681 public static function maybe_update_styles() {
863 682 if ( self::needs_update() ) {
864 683 self::network_upgrade_site();
@@ -866,10 +685,8 @@
866 685 }
867 686
868 687 /**
869 688 * @since 3.0
870 - *
871 - * @return void
872 689 */
873 690 public static function create_rest_routes() {
874 691 $args = array(
875 692 'methods' => 'GET',
@@ -904,10 +721,8 @@
904 721 *
905 722 * @since 2.0.1
906 723 *
907 724 * @param int $blog_id Blog ID.
908 - *
909 - * @return void
910 725 */
911 726 public static function network_upgrade_site( $blog_id = 0 ) {
912 727 // Flag to check if install is happening as intended.
913 728 set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS );
@@ -931,10 +746,8 @@
931 746
932 747 /**
933 748 * Make sure WP_Site_Health has been included because it is required when calling rest_do_request.
934 749 * Check first that the file exists because WP_Site_Health was only introduced in WordPress 5.2.
935 - *
936 - * @return void
937 750 */
938 751 private static function maybe_add_wp_site_health() {
939 752 if ( ! class_exists( 'WP_Site_Health' ) ) {
940 753 $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
@@ -945,10 +758,8 @@
945 758 }
946 759
947 760 /**
948 761 * @since 3.0
949 - *
950 - * @return true
951 762 */
952 763 public static function api_install() {
953 764 delete_transient( 'frm_updating_api' );
954 765 if ( self::needs_update() ) {
@@ -967,10 +778,8 @@
967 778 * Silent database upgrade (no redirect).
968 779 * Called via ajax request during network upgrade process.
969 780 *
970 781 * @since 2.0.1
971 - *
972 - * @return void
973 782 */
974 783 public static function ajax_install() {
975 784 FrmAppHelper::permission_check( 'frm_change_settings' );
976 785 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -977,19 +786,13 @@
977 786 self::api_install();
978 787 wp_die();
979 788 }
980 789
981 - /**
982 - * @return void
983 - */
984 790 public static function install() {
985 791 $frmdb = new FrmMigrate();
986 792 $frmdb->upgrade();
987 793 }
988 794
989 - /**
990 - * @return void
991 - */
992 795 public static function uninstall() {
993 796 FrmAppHelper::permission_check( 'administrator' );
994 797 check_ajax_referer( 'frm_ajax', 'nonce' );
995 798
@@ -1013,11 +816,8 @@
1013 816
1014 817 return $tables;
1015 818 }
1016 819
1017 - /**
1018 - * @return void
1019 - */
1020 820 public static function deauthorize() {
1021 821 FrmAppHelper::permission_check( 'frm_change_settings' );
1022 822 check_ajax_referer( 'frm_ajax', 'nonce' );
1023 823
@@ -1036,30 +836,36 @@
1036 836 return $text;
1037 837 }
1038 838
1039 839 /**
1040 - * Add admin footer links.
1041 - *
1042 - * @since 6.4.1
1043 - *
1044 - * @return void
840 + * @deprecated 1.07.05
841 + * @codeCoverageIgnore
1045 842 */
1046 - public static function add_admin_footer_links() {
1047 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
843 + public static function get_form_shortcode( $atts ) {
844 + return FrmDeprecated::get_form_shortcode( $atts );
845 + }
1048 846
1049 - if ( ( ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs' ) || FrmAppHelper::is_full_screen() ) {
1050 - return;
1051 - }
847 + /**
848 + * @deprecated 2.5.4
849 + * @codeCoverageIgnore
850 + */
851 + public static function widget_text_filter( $content ) {
852 + return FrmDeprecated::widget_text_filter( $content );
853 + }
1052 854
1053 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
855 + /**
856 + * Deprecated in favor of wpmu_upgrade_site
857 + *
858 + * @deprecated 2.3
859 + * @codeCoverageIgnore
860 + */
861 + public static function front_head() {
862 + FrmDeprecated::front_head();
1054 863 }
1055 864
1056 865 /**
1057 866 * @deprecated 3.0.04
1058 - *
1059 867 * @codeCoverageIgnore
1060 - *
1061 - * @return void
1062 868 */
1063 869 public static function activation_install() {
1064 870 FrmDeprecated::activation_install();
1065 871 }
@@ -1080,48 +886,6 @@
1080 886 * @return void
1081 887 */
1082 888 public static function include_embed_form_icons() {
1083 889 _deprecated_function( __METHOD__, '5.3' );
1084 - }
1085 -
1086 - /**
1087 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1088 - * @codeCoverageIgnore
1089 - *
1090 - * @param array $atts
1091 - * @return string
1092 - */
1093 - public static function get_form_shortcode( $atts ) {
1094 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1095 - return FrmFormsController::get_form_shortcode( $atts );
1096 - }
1097 -
1098 - /**
1099 - * Handles Floating Links' scripts and styles enqueueing.
1100 - *
1101 - * @since 6.4
1102 - *
1103 - * @param string $plugin_url URL of the plugin.
1104 - * @param string $version Current version of the plugin.
1105 - * @return void
1106 - */
1107 - private static function enqueue_floating_links( $plugin_url, $version ) {
1108 - if ( ! $plugin_url || ! $version ) {
1109 - // If any required parameters are missing, exit early.
1110 - return;
1111 - }
1112 -
1113 - // Enqueue the Floating Links styles.
1114 - wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1115 -
1116 - // Enqueue the Floating Links script.
1117 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1118 -
1119 - // Enqueue the config script.
1120 - wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1121 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1122 - $floating_links_data = array(
1123 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1124 - );
1125 - wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1126 890 }
1127 891 }