PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.5
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.5
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 +36 -242 6.35.5.5 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(
@@ -219,15 +170,8 @@
219 170 'page' => 'formidable',
220 171 'permission' => 'frm_edit_forms',
221 172 ),
222 173 array(
223 - 'link' => FrmStylesHelper::get_list_url( $id ),
224 - 'label' => __( 'Style', 'formidable' ),
225 - 'current' => array(),
226 - 'page' => 'formidable-styles',
227 - 'permission' => 'frm_edit_forms',
228 - ),
229 - array(
230 174 'link' => admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . absint( $id ) ),
231 175 'label' => __( 'Settings', 'formidable' ),
232 176 'current' => array( 'settings' ),
233 177 'page' => 'formidable',
@@ -275,15 +219,12 @@
275 219 'form_id' => $id,
276 220 'form' => $form,
277 221 );
278 222
279 - return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
223 + return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
280 224 }
281 225
282 226 // Adds a settings link to the plugins page
283 - /**
284 - * @return array
285 - */
286 227 public static function settings_link( $links ) {
287 228 $settings = array();
288 229
289 230 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -294,11 +235,8 @@
294 235
295 236 return array_merge( $settings, $links );
296 237 }
297 238
298 - /**
299 - * @return void
300 - */
301 239 public static function pro_get_started_headline() {
302 240 self::review_request();
303 241 FrmAppHelper::min_pro_version_notice( '4.0' );
304 242 }
@@ -306,10 +244,8 @@
306 244 /**
307 245 * Add admin notices as needed for reviews
308 246 *
309 247 * @since 3.04.03
310 - *
311 - * @return void
312 248 */
313 249 private static function review_request() {
314 250 $reviews = new FrmReviews();
315 251 $reviews->review_request();
@@ -318,10 +254,8 @@
318 254 /**
319 255 * Save the request to hide the review
320 256 *
321 257 * @since 3.04.03
322 - *
323 - * @return void
324 258 */
325 259 public static function dismiss_review() {
326 260 FrmAppHelper::permission_check( 'frm_change_settings' );
327 261 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -331,10 +265,8 @@
331 265 }
332 266
333 267 /**
334 268 * @since 3.04.02
335 - *
336 - * @return void
337 269 */
338 270 public static function include_upgrade_overlay() {
339 271 self::enqueue_dialog_assets();
340 272 add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' );
@@ -353,10 +285,8 @@
353 285 }
354 286
355 287 /**
356 288 * @since 3.06.03
357 - *
358 - * @return void
359 289 */
360 290 public static function upgrade_overlay_html() {
361 291 $is_pro = FrmAppHelper::pro_is_installed();
362 292 $upgrade_link = array(
@@ -374,11 +304,8 @@
374 304 self::new_form_overlay_html();
375 305 }
376 306 }
377 307
378 - /**
379 - * @return void
380 - */
381 308 private static function new_form_overlay_html() {
382 309 FrmFormsController::before_list_templates();
383 310
384 311 $plugin_path = FrmAppHelper::plugin_path();
@@ -425,19 +352,13 @@
425 352
426 353 include $path . 'new-form-overlay.php';
427 354 }
428 355
429 - /**
430 - * @return void
431 - */
432 356 public static function include_info_overlay() {
433 357 self::enqueue_dialog_assets();
434 358 add_action( 'admin_footer', 'FrmAppController::info_overlay_html' );
435 359 }
436 360
437 - /**
438 - * @return void
439 - */
440 361 public static function info_overlay_html() {
441 362 include FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php';
442 363 }
443 364
@@ -442,10 +363,8 @@
442 363 }
443 364
444 365 /**
445 366 * @since 3.04.02
446 - *
447 - * @return void
448 367 */
449 368 public static function remove_upsells() {
450 369 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
451 370 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
@@ -457,10 +376,8 @@
457 376 * If there are CURL problems on this server, wp_remote_post won't work for installing
458 377 * Use a javascript fallback instead.
459 378 *
460 379 * @since 2.0.3
461 - *
462 - * @return void
463 380 */
464 381 public static function install_js_fallback() {
465 382 FrmAppHelper::load_admin_wide_js();
466 383 ?>
@@ -494,11 +411,8 @@
494 411 /**
495 412 * Check both version number and DB number for changes
496 413 *
497 414 * @since 3.0.04
498 - *
499 - * @param array $atts
500 - * @return bool
501 415 */
502 416 public static function compare_for_update( $atts ) {
503 417 $db_version = get_option( $atts['option'] );
504 418
@@ -517,10 +431,8 @@
517 431 /**
518 432 * Check for database update and trigger js loading
519 433 *
520 434 * @since 2.0.1
521 - *
522 - * @return void
523 435 */
524 436 public static function admin_init() {
525 437 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 438 FrmFormsController::duplicate();
@@ -525,13 +437,8 @@
525 437 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 438 FrmFormsController::duplicate();
527 439 }
528 440
529 - if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
530 - // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
531 - FrmStylesController::save_style();
532 - }
533 -
534 441 new FrmPersonalData(); // register personal data hooks
535 442
536 443 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
537 444 self::network_upgrade_site();
@@ -551,74 +458,13 @@
551 458 }
552 459
553 460 FrmInbox::maybe_disable_screen_options();
554 461 }
555 -
556 - self::maybe_add_ip_warning();
557 462 }
558 463
559 464 /**
560 - * Show a warning for the IP address setting if it hasn't been set.
561 - *
562 - * @since 6.1
563 - *
564 465 * @return void
565 466 */
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.
570 - return;
571 - }
572 -
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>'
588 - );
589 - $option_name = 'frm_dismiss_ip_address_notice';
590 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
591 - }
592 -
593 - /**
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 - * @return void
620 - */
621 467 public static function admin_js() {
622 468 $plugin_url = FrmAppHelper::plugin_url();
623 469 $version = FrmAppHelper::plugin_version();
624 470
@@ -633,9 +479,8 @@
633 479 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
634 480 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
635 481 self::register_popper1();
636 482 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
637 - wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
638 483
639 484 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
640 485
641 486 if ( 'formidable-applications' === $page ) {
@@ -656,10 +501,9 @@
656 501 'formidable_dom',
657 502 'formidable_embed',
658 503 );
659 504
660 - if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) {
661 - // We only need to load the color picker when editing styles.
505 + if ( FrmAppHelper::is_style_editor_page() ) {
662 506 $dependencies[] = 'wp-color-picker';
663 507 }
664 508
665 509 wp_register_script( 'formidable_admin', $plugin_url . '/js/formidable_admin.js', $dependencies, $version, true );
@@ -712,9 +556,15 @@
712 556 return;
713 557 }
714 558
715 559 if ( $post_type === 'frm_display' ) {
716 - self::enqueue_legacy_views_assets();
560 + wp_enqueue_style( 'formidable-grids' );
561 + wp_enqueue_script( 'jquery-ui-draggable' );
562 + self::maybe_deregister_popper2();
563 + wp_enqueue_script( 'formidable_admin' );
564 + wp_enqueue_style( 'formidable-admin' );
565 + FrmAppHelper::localize_script( 'admin' );
566 + self::include_info_overlay();
717 567 }
718 568 }
719 569
720 570 self::maybe_force_formidable_block_on_gutenberg_page();
@@ -720,47 +570,8 @@
720 570 self::maybe_force_formidable_block_on_gutenberg_page();
721 571 }
722 572
723 573 /**
724 - * Enqueue required assets for the Legacy Views editor (Views v4.x).
725 - *
726 - * @since 6.1.2
727 - *
728 - * @return void
729 - */
730 - private static function enqueue_legacy_views_assets() {
731 - wp_enqueue_style( 'formidable-grids' );
732 - wp_enqueue_script( 'jquery-ui-draggable' );
733 - self::maybe_deregister_popper2();
734 - wp_enqueue_script( 'formidable_admin' );
735 - wp_add_inline_style(
736 - 'formidable-admin',
737 - '
738 - .frm-white-body.post-type-frm_display .columns-2 {
739 - display: block;
740 - overflow: visible;
741 - }
742 -
743 - .frm-white-body.post-type-frm_display .columns-2 > div {
744 - overflow-y: hidden;
745 - }
746 -
747 - .frm-white-body.post-type-frm_display #titlediv #title-prompt-text {
748 - padding: 3px 0 0 10px;
749 - }
750 -
751 - .post-type-frm_display #field-search-input,
752 - .post-type-frm_display #advanced-search-input {
753 - flex: 1;
754 - }
755 - '
756 - );
757 - wp_enqueue_style( 'formidable-admin' );
758 - FrmAppHelper::localize_script( 'admin' );
759 - self::include_info_overlay();
760 - }
761 -
762 - /**
763 574 * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
764 575 *
765 576 * @since 5.2.02.01
766 577 *
@@ -814,12 +625,8 @@
814 625
815 626 /**
816 627 * @since 5.3
817 628 *
818 - * @param string $block_name
819 - * @param string $object_key
820 - * @param array|string $object_id
821 - *
822 629 * @return void
823 630 */
824 631 public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
825 632 require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
@@ -824,11 +631,8 @@
824 631 public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
825 632 require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
826 633 }
827 634
828 - /**
829 - * @return void
830 - */
831 635 public static function load_lang() {
832 636 load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
833 637 }
834 638
@@ -835,10 +639,8 @@
835 639 /**
836 640 * Check if the styles are updated when a form is loaded on the front-end
837 641 *
838 642 * @since 3.0.1
839 - *
840 - * @return void
841 643 */
842 644 public static function maybe_update_styles() {
843 645 if ( self::needs_update() ) {
844 646 self::network_upgrade_site();
@@ -846,10 +648,8 @@
846 648 }
847 649
848 650 /**
849 651 * @since 3.0
850 - *
851 - * @return void
852 652 */
853 653 public static function create_rest_routes() {
854 654 $args = array(
855 655 'methods' => 'GET',
@@ -884,10 +684,8 @@
884 684 *
885 685 * @since 2.0.1
886 686 *
887 687 * @param int $blog_id Blog ID.
888 - *
889 - * @return void
890 688 */
891 689 public static function network_upgrade_site( $blog_id = 0 ) {
892 690 // Flag to check if install is happening as intended.
893 691 set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS );
@@ -911,10 +709,8 @@
911 709
912 710 /**
913 711 * Make sure WP_Site_Health has been included because it is required when calling rest_do_request.
914 712 * Check first that the file exists because WP_Site_Health was only introduced in WordPress 5.2.
915 - *
916 - * @return void
917 713 */
918 714 private static function maybe_add_wp_site_health() {
919 715 if ( ! class_exists( 'WP_Site_Health' ) ) {
920 716 $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
@@ -925,10 +721,8 @@
925 721 }
926 722
927 723 /**
928 724 * @since 3.0
929 - *
930 - * @return true
931 725 */
932 726 public static function api_install() {
933 727 delete_transient( 'frm_updating_api' );
934 728 if ( self::needs_update() ) {
@@ -947,10 +741,8 @@
947 741 * Silent database upgrade (no redirect).
948 742 * Called via ajax request during network upgrade process.
949 743 *
950 744 * @since 2.0.1
951 - *
952 - * @return void
953 745 */
954 746 public static function ajax_install() {
955 747 FrmAppHelper::permission_check( 'frm_change_settings' );
956 748 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -957,19 +749,13 @@
957 749 self::api_install();
958 750 wp_die();
959 751 }
960 752
961 - /**
962 - * @return void
963 - */
964 753 public static function install() {
965 754 $frmdb = new FrmMigrate();
966 755 $frmdb->upgrade();
967 756 }
968 757
969 - /**
970 - * @return void
971 - */
972 758 public static function uninstall() {
973 759 FrmAppHelper::permission_check( 'administrator' );
974 760 check_ajax_referer( 'frm_ajax', 'nonce' );
975 761
@@ -993,11 +779,8 @@
993 779
994 780 return $tables;
995 781 }
996 782
997 - /**
998 - * @return void
999 - */
1000 783 public static function deauthorize() {
1001 784 FrmAppHelper::permission_check( 'frm_change_settings' );
1002 785 check_ajax_referer( 'frm_ajax', 'nonce' );
1003 786
@@ -1016,13 +799,36 @@
1016 799 return $text;
1017 800 }
1018 801
1019 802 /**
803 + * @deprecated 1.07.05
804 + * @codeCoverageIgnore
805 + */
806 + public static function get_form_shortcode( $atts ) {
807 + return FrmDeprecated::get_form_shortcode( $atts );
808 + }
809 +
810 + /**
811 + * @deprecated 2.5.4
812 + * @codeCoverageIgnore
813 + */
814 + public static function widget_text_filter( $content ) {
815 + return FrmDeprecated::widget_text_filter( $content );
816 + }
817 +
818 + /**
819 + * Deprecated in favor of wpmu_upgrade_site
820 + *
821 + * @deprecated 2.3
822 + * @codeCoverageIgnore
823 + */
824 + public static function front_head() {
825 + FrmDeprecated::front_head();
826 + }
827 +
828 + /**
1020 829 * @deprecated 3.0.04
1021 - *
1022 830 * @codeCoverageIgnore
1023 - *
1024 - * @return void
1025 831 */
1026 832 public static function activation_install() {
1027 833 FrmDeprecated::activation_install();
1028 834 }
@@ -1043,18 +849,6 @@
1043 849 * @return void
1044 850 */
1045 851 public static function include_embed_form_icons() {
1046 852 _deprecated_function( __METHOD__, '5.3' );
1047 - }
1048 -
1049 - /**
1050 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1051 - * @codeCoverageIgnore
1052 - *
1053 - * @param array $atts
1054 - * @return string
1055 - */
1056 - public static function get_form_shortcode( $atts ) {
1057 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1058 - return FrmFormsController::get_form_shortcode( $atts );
1059 853 }
1060 854 }