PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.1
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 +40 -249 6.56.1 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;
@@ -81,9 +78,9 @@
81 78
82 79 /**
83 80 * Get the full screen mode setting from the block editor.
84 81 *
85 - * @since 6.1
82 + * @since x.x
86 83 *
87 84 * @return bool
88 85 */
89 86 private static function get_full_screen_setting() {
@@ -99,10 +96,8 @@
99 96 }
100 97
101 98 /**
102 99 * @since 4.0
103 - *
104 - * @return string
105 100 */
106 101 private static function get_os() {
107 102 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
108 103 $os = '';
@@ -135,14 +130,8 @@
135 130 'formidable-welcome',
136 131 'formidable-applications',
137 132 );
138 133
139 - if ( ! class_exists( 'FrmTransHooksController', false ) ) {
140 - // Only consider the payments page as a "white page" when the Payments submodule is off.
141 - // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
142 - $white_pages[] = 'formidable-payments';
143 - }
144 -
145 134 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
146 135 $is_white_page = in_array( $get_page, $white_pages, true );
147 136
148 137 if ( ! $is_white_page ) {
@@ -161,23 +150,12 @@
161 150
162 151 return $is_white_page;
163 152 }
164 153
165 - /**
166 - * @return void
167 - */
168 154 public static function load_wp_admin_style() {
169 155 FrmAppHelper::load_font_style();
170 156 }
171 157
172 - /**
173 - * @param bool $show_nav
174 - * @param string $title
175 - *
176 - * @psalm-param 'hide'|'show' $title
177 - *
178 - * @return void
179 - */
180 158 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
181 159 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
182 160 if ( empty( $show_nav ) || ! $form ) {
183 161 return;
@@ -194,11 +172,8 @@
194 172
195 173 include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
196 174 }
197 175
198 - /**
199 - * @return string
200 - */
201 176 private static function get_current_page() {
202 177 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
203 178 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
204 179 $current_page = isset( $_GET['page'] ) ? $page : $post_type;
@@ -209,12 +184,8 @@
209 184
210 185 return $current_page;
211 186 }
212 187
213 - /**
214 - * @param object $form
215 - * @return array
216 - */
217 188 private static function get_form_nav_items( $form ) {
218 189 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
219 190
220 191 $nav_items = array(
@@ -281,20 +252,17 @@
281 252 'form_id' => $id,
282 253 'form' => $form,
283 254 );
284 255
285 - return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
256 + return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
286 257 }
287 258
288 259 // Adds a settings link to the plugins page
289 - /**
290 - * @return array
291 - */
292 260 public static function settings_link( $links ) {
293 261 $settings = array();
294 262
295 263 if ( ! FrmAppHelper::pro_is_installed() ) {
296 - $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html__( 'Upgrade to Pro', 'formidable' ) . '</b></a>';
264 + $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b>' . esc_html__( 'Upgrade to Pro', 'formidable' ) . '</b></a>';
297 265 }
298 266
299 267 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
300 268
@@ -300,11 +268,8 @@
300 268
301 269 return array_merge( $settings, $links );
302 270 }
303 271
304 - /**
305 - * @return void
306 - */
307 272 public static function pro_get_started_headline() {
308 273 self::review_request();
309 274 FrmAppHelper::min_pro_version_notice( '4.0' );
310 275 }
@@ -312,10 +277,8 @@
312 277 /**
313 278 * Add admin notices as needed for reviews
314 279 *
315 280 * @since 3.04.03
316 - *
317 - * @return void
318 281 */
319 282 private static function review_request() {
320 283 $reviews = new FrmReviews();
321 284 $reviews->review_request();
@@ -324,10 +287,8 @@
324 287 /**
325 288 * Save the request to hide the review
326 289 *
327 290 * @since 3.04.03
328 - *
329 - * @return void
330 291 */
331 292 public static function dismiss_review() {
332 293 FrmAppHelper::permission_check( 'frm_change_settings' );
333 294 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -337,10 +298,8 @@
337 298 }
338 299
339 300 /**
340 301 * @since 3.04.02
341 - *
342 - * @return void
343 302 */
344 303 public static function include_upgrade_overlay() {
345 304 self::enqueue_dialog_assets();
346 305 add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' );
@@ -359,10 +318,8 @@
359 318 }
360 319
361 320 /**
362 321 * @since 3.06.03
363 - *
364 - * @return void
365 322 */
366 323 public static function upgrade_overlay_html() {
367 324 $is_pro = FrmAppHelper::pro_is_installed();
368 325 $upgrade_link = array(
@@ -380,11 +337,8 @@
380 337 self::new_form_overlay_html();
381 338 }
382 339 }
383 340
384 - /**
385 - * @return void
386 - */
387 341 private static function new_form_overlay_html() {
388 342 FrmFormsController::before_list_templates();
389 343
390 344 $plugin_path = FrmAppHelper::plugin_path();
@@ -431,19 +385,13 @@
431 385
432 386 include $path . 'new-form-overlay.php';
433 387 }
434 388
435 - /**
436 - * @return void
437 - */
438 389 public static function include_info_overlay() {
439 390 self::enqueue_dialog_assets();
440 391 add_action( 'admin_footer', 'FrmAppController::info_overlay_html' );
441 392 }
442 393
443 - /**
444 - * @return void
445 - */
446 394 public static function info_overlay_html() {
447 395 include FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php';
448 396 }
449 397
@@ -448,10 +396,8 @@
448 396 }
449 397
450 398 /**
451 399 * @since 3.04.02
452 - *
453 - * @return void
454 400 */
455 401 public static function remove_upsells() {
456 402 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
457 403 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
@@ -463,10 +409,8 @@
463 409 * If there are CURL problems on this server, wp_remote_post won't work for installing
464 410 * Use a javascript fallback instead.
465 411 *
466 412 * @since 2.0.3
467 - *
468 - * @return void
469 413 */
470 414 public static function install_js_fallback() {
471 415 FrmAppHelper::load_admin_wide_js();
472 416 ?>
@@ -500,11 +444,8 @@
500 444 /**
501 445 * Check both version number and DB number for changes
502 446 *
503 447 * @since 3.0.04
504 - *
505 - * @param array $atts
506 - * @return bool
507 448 */
508 449 public static function compare_for_update( $atts ) {
509 450 $db_version = get_option( $atts['option'] );
510 451
@@ -523,10 +464,8 @@
523 464 /**
524 465 * Check for database update and trigger js loading
525 466 *
526 467 * @since 2.0.1
527 - *
528 - * @return void
529 468 */
530 469 public static function admin_init() {
531 470 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
532 471 FrmFormsController::duplicate();
@@ -564,9 +503,9 @@
564 503
565 504 /**
566 505 * Show a warning for the IP address setting if it hasn't been set.
567 506 *
568 - * @since 6.1
507 + * @since x.x
569 508 *
570 509 * @return void
571 510 */
572 511 private static function maybe_add_ip_warning() {
@@ -576,9 +515,9 @@
576 515 return;
577 516 }
578 517
579 518 if ( ! self::is_behind_proxy() ) {
580 - // This message is only applicable when using a reverse proxy.
519 + // This message is only applicable when where is a reverse proxy.
581 520 return;
582 521 }
583 522
584 523 if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
@@ -585,22 +524,22 @@
585 524 // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
586 525 return;
587 526 }
588 527
589 - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
590 - $message = sprintf(
591 - // Translators: 1: Global Settings Link
592 - __( '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' ),
593 - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
528 + add_filter(
529 + 'frm_message_list',
530 + function( $show_messages ) {
531 + $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
532 + $show_messages['ip_msg'] = 'IP addresses in form submissions may no longer be accurate! If you are experiencing issues, we recommend going to <a href="' . esc_url( $global_settings_link ) . '">Global Settings</a> and enabling the "Use custom headers when retrieving IPs with form submissions." setting.';
533 + return $show_messages;
534 + }
594 535 );
595 - $option_name = 'frm_dismiss_ip_address_notice';
596 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
597 536 }
598 537
599 538 /**
600 539 * Check if any reverse proxy headers are set.
601 540 *
602 - * @since 6.1
541 + * @since x.x
603 542 *
604 543 * @return bool
605 544 */
606 545 private static function is_behind_proxy() {
@@ -643,19 +582,8 @@
643 582 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
644 583
645 584 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
646 585
647 - // Enqueue Floating Links.
648 - $is_valid_page =
649 - FrmAppHelper::is_formidable_admin() &&
650 - ! FrmAppHelper::is_style_editor_page() &&
651 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
652 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
653 - if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
654 - self::enqueue_floating_links( $plugin_url, $version );
655 - }
656 - unset( $is_valid_page );
657 -
658 586 if ( 'formidable-applications' === $page ) {
659 587 FrmApplicationsController::load_assets();
660 588 return;
661 589 }
@@ -729,64 +657,22 @@
729 657 return;
730 658 }
731 659
732 660 if ( $post_type === 'frm_display' ) {
733 - self::enqueue_legacy_views_assets();
661 + wp_enqueue_style( 'formidable-grids' );
662 + wp_enqueue_script( 'jquery-ui-draggable' );
663 + self::maybe_deregister_popper2();
664 + wp_enqueue_script( 'formidable_admin' );
665 + wp_enqueue_style( 'formidable-admin' );
666 + FrmAppHelper::localize_script( 'admin' );
667 + self::include_info_overlay();
734 668 }
735 669 }
736 670
737 - }
738 -
739 - /**
740 - * @since 6.3.2
741 - *
742 - * @return void
743 - */
744 - public static function admin_enqueue_scripts() {
745 - self::load_wp_admin_style();
746 671 self::maybe_force_formidable_block_on_gutenberg_page();
747 672 }
748 673
749 674 /**
750 - * Enqueue required assets for the Legacy Views editor (Views v4.x).
751 - *
752 - * @since 6.1.2
753 - *
754 - * @return void
755 - */
756 - private static function enqueue_legacy_views_assets() {
757 - wp_enqueue_style( 'formidable-grids' );
758 - wp_enqueue_script( 'jquery-ui-draggable' );
759 - self::maybe_deregister_popper2();
760 - wp_enqueue_script( 'formidable_admin' );
761 - wp_add_inline_style(
762 - 'formidable-admin',
763 - '
764 - .frm-white-body.post-type-frm_display .columns-2 {
765 - display: block;
766 - overflow: visible;
767 - }
768 -
769 - .frm-white-body.post-type-frm_display .columns-2 > div {
770 - overflow-y: hidden;
771 - }
772 -
773 - .frm-white-body.post-type-frm_display #titlediv #title-prompt-text {
774 - padding: 3px 0 0 10px;
775 - }
776 -
777 - .post-type-frm_display #field-search-input,
778 - .post-type-frm_display #advanced-search-input {
779 - flex: 1;
780 - }
781 - '
782 - );
783 - wp_enqueue_style( 'formidable-admin' );
784 - FrmAppHelper::localize_script( 'admin' );
785 - self::include_info_overlay();
786 - }
787 -
788 - /**
789 675 * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
790 676 *
791 677 * @since 5.2.02.01
792 678 *
@@ -840,12 +726,8 @@
840 726
841 727 /**
842 728 * @since 5.3
843 729 *
844 - * @param string $block_name
845 - * @param string $object_key
846 - * @param array|string $object_id
847 - *
848 730 * @return void
849 731 */
850 732 public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
851 733 require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
@@ -850,11 +732,8 @@
850 732 public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
851 733 require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
852 734 }
853 735
854 - /**
855 - * @return void
856 - */
857 736 public static function load_lang() {
858 737 load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
859 738 }
860 739
@@ -861,10 +740,8 @@
861 740 /**
862 741 * Check if the styles are updated when a form is loaded on the front-end
863 742 *
864 743 * @since 3.0.1
865 - *
866 - * @return void
867 744 */
868 745 public static function maybe_update_styles() {
869 746 if ( self::needs_update() ) {
870 747 self::network_upgrade_site();
@@ -872,10 +749,8 @@
872 749 }
873 750
874 751 /**
875 752 * @since 3.0
876 - *
877 - * @return void
878 753 */
879 754 public static function create_rest_routes() {
880 755 $args = array(
881 756 'methods' => 'GET',
@@ -910,10 +785,8 @@
910 785 *
911 786 * @since 2.0.1
912 787 *
913 788 * @param int $blog_id Blog ID.
914 - *
915 - * @return void
916 789 */
917 790 public static function network_upgrade_site( $blog_id = 0 ) {
918 791 // Flag to check if install is happening as intended.
919 792 set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS );
@@ -937,10 +810,8 @@
937 810
938 811 /**
939 812 * Make sure WP_Site_Health has been included because it is required when calling rest_do_request.
940 813 * Check first that the file exists because WP_Site_Health was only introduced in WordPress 5.2.
941 - *
942 - * @return void
943 814 */
944 815 private static function maybe_add_wp_site_health() {
945 816 if ( ! class_exists( 'WP_Site_Health' ) ) {
946 817 $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
@@ -951,10 +822,8 @@
951 822 }
952 823
953 824 /**
954 825 * @since 3.0
955 - *
956 - * @return true
957 826 */
958 827 public static function api_install() {
959 828 delete_transient( 'frm_updating_api' );
960 829 if ( self::needs_update() ) {
@@ -973,10 +842,8 @@
973 842 * Silent database upgrade (no redirect).
974 843 * Called via ajax request during network upgrade process.
975 844 *
976 845 * @since 2.0.1
977 - *
978 - * @return void
979 846 */
980 847 public static function ajax_install() {
981 848 FrmAppHelper::permission_check( 'frm_change_settings' );
982 849 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -983,19 +850,13 @@
983 850 self::api_install();
984 851 wp_die();
985 852 }
986 853
987 - /**
988 - * @return void
989 - */
990 854 public static function install() {
991 855 $frmdb = new FrmMigrate();
992 856 $frmdb->upgrade();
993 857 }
994 858
995 - /**
996 - * @return void
997 - */
998 859 public static function uninstall() {
999 860 FrmAppHelper::permission_check( 'administrator' );
1000 861 check_ajax_referer( 'frm_ajax', 'nonce' );
1001 862
@@ -1019,11 +880,8 @@
1019 880
1020 881 return $tables;
1021 882 }
1022 883
1023 - /**
1024 - * @return void
1025 - */
1026 884 public static function deauthorize() {
1027 885 FrmAppHelper::permission_check( 'frm_change_settings' );
1028 886 check_ajax_referer( 'frm_ajax', 'nonce' );
1029 887
@@ -1033,33 +891,8 @@
1033 891 delete_site_option( 'frmpro-authorized' );
1034 892 wp_die();
1035 893 }
1036 894
1037 - /**
1038 - * This is triggered when Formidable is activated.
1039 - *
1040 - * @return void
1041 - */
1042 - public static function handle_activation() {
1043 - self::maybe_activate_payment_cron();
1044 - }
1045 -
1046 - /**
1047 - * The payment cron is unscheduled when Formidable is deactivated.
1048 - * We need to add it back again on activation if Stripe is configured.
1049 - *
1050 - * @since 6.5
1051 - *
1052 - * @return void
1053 - */
1054 - private static function maybe_activate_payment_cron() {
1055 - if ( ! FrmStrpLiteConnectHelper::stripe_connect_is_setup() ) {
1056 - return;
1057 - }
1058 -
1059 - FrmTransLiteAppController::maybe_schedule_cron();
1060 - }
1061 -
1062 895 public static function set_footer_text( $text ) {
1063 896 if ( FrmAppHelper::is_formidable_admin() ) {
1064 897 $text = '';
1065 898 }
@@ -1067,36 +900,36 @@
1067 900 return $text;
1068 901 }
1069 902
1070 903 /**
1071 - * Add admin footer links.
1072 - *
1073 - * @since 6.4.1
1074 - *
1075 - * @return void
904 + * @deprecated 1.07.05
905 + * @codeCoverageIgnore
1076 906 */
1077 - public static function add_admin_footer_links() {
1078 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
907 + public static function get_form_shortcode( $atts ) {
908 + return FrmDeprecated::get_form_shortcode( $atts );
909 + }
1079 910
1080 - // Check admin privileges, screen mode, and branding
1081 - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs';
1082 - $is_full_screen = FrmAppHelper::is_full_screen();
1083 - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding();
911 + /**
912 + * @deprecated 2.5.4
913 + * @codeCoverageIgnore
914 + */
915 + public static function widget_text_filter( $content ) {
916 + return FrmDeprecated::widget_text_filter( $content );
917 + }
1084 918
1085 - // Exit if any of the above conditions are met
1086 - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) {
1087 - return;
1088 - }
1089 -
1090 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
919 + /**
920 + * Deprecated in favor of wpmu_upgrade_site
921 + *
922 + * @deprecated 2.3
923 + * @codeCoverageIgnore
924 + */
925 + public static function front_head() {
926 + FrmDeprecated::front_head();
1091 927 }
1092 928
1093 929 /**
1094 930 * @deprecated 3.0.04
1095 - *
1096 931 * @codeCoverageIgnore
1097 - *
1098 - * @return void
1099 932 */
1100 933 public static function activation_install() {
1101 934 FrmDeprecated::activation_install();
1102 935 }
@@ -1117,48 +950,6 @@
1117 950 * @return void
1118 951 */
1119 952 public static function include_embed_form_icons() {
1120 953 _deprecated_function( __METHOD__, '5.3' );
1121 - }
1122 -
1123 - /**
1124 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1125 - * @codeCoverageIgnore
1126 - *
1127 - * @param array $atts
1128 - * @return string
1129 - */
1130 - public static function get_form_shortcode( $atts ) {
1131 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1132 - return FrmFormsController::get_form_shortcode( $atts );
1133 - }
1134 -
1135 - /**
1136 - * Handles Floating Links' scripts and styles enqueueing.
1137 - *
1138 - * @since 6.4
1139 - *
1140 - * @param string $plugin_url URL of the plugin.
1141 - * @param string $version Current version of the plugin.
1142 - * @return void
1143 - */
1144 - private static function enqueue_floating_links( $plugin_url, $version ) {
1145 - if ( ! $plugin_url || ! $version ) {
1146 - // If any required parameters are missing, exit early.
1147 - return;
1148 - }
1149 -
1150 - // Enqueue the Floating Links styles.
1151 - wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1152 -
1153 - // Enqueue the Floating Links script.
1154 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1155 -
1156 - // Enqueue the config script.
1157 - wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1158 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1159 - $floating_links_data = array(
1160 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1161 - );
1162 - wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1163 954 }
1164 955 }