PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +179 -93 6.5.16.8 View file →
@@ -61,14 +61,20 @@
61 61 $classes .= ' frm-admin-page-' . $page;
62 62 }
63 63 }
64 64
65 + if ( self::is_grey_page() ) {
66 + $classes .= ' frm-grey-body ';
67 + }
68 +
65 69 if ( FrmAppHelper::is_full_screen() ) {
66 70 $full_screen_on = self::get_full_screen_setting();
67 71 $add_class = '';
68 72 if ( $full_screen_on ) {
69 73 $add_class = ' frm-full-screen is-fullscreen-mode';
70 - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
74 +
75 + // Load the CSS for .is-fullscreen-mode.
76 + wp_enqueue_style( 'wp-edit-post' );
71 77 }
72 78 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
73 79 }
74 80
@@ -75,8 +81,12 @@
75 81 if ( ! FrmAppHelper::pro_is_installed() ) {
76 82 $classes .= ' frm-lite ';
77 83 }
78 84
85 + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) {
86 + $classes .= ' frm-unfold ';
87 + }
88 +
79 89 return $classes;
80 90 }
81 91
82 92 /**
@@ -131,26 +141,24 @@
131 141 'formidable-settings',
132 142 'formidable-styles',
133 143 'formidable-styles2',
134 144 'formidable-inbox',
135 - 'formidable-welcome',
136 - 'formidable-applications',
145 + FrmFormTemplatesController::PAGE_SLUG,
137 146 );
138 147
139 - if ( ! class_exists( 'FrmTransHooksController', false ) ) {
148 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
140 149 // Only consider the payments page as a "white page" when the Payments submodule is off.
141 150 // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
142 - $white_pages[] = 'formidable-payments';
151 +
152 + // Add an extra check to avoid white page styling on the PayPal "edit" action.
153 + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view.
154 + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) {
155 + $white_pages[] = 'formidable-payments';
156 + }
143 157 }
144 158
145 - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
146 - $is_white_page = in_array( $get_page, $white_pages, true );
159 + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
147 160
148 - if ( ! $is_white_page ) {
149 - $screen = get_current_screen();
150 - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
151 - }
152 -
153 161 /**
154 162 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
155 163 *
156 164 * @since 5.3
@@ -162,8 +170,45 @@
162 170 return $is_white_page;
163 171 }
164 172
165 173 /**
174 + * Add a grey bg instead of white.
175 + *
176 + * @since 6.8
177 + *
178 + * @return bool
179 + */
180 + private static function is_grey_page() {
181 + $grey_pages = array(
182 + 'formidable-applications',
183 + 'formidable-dashboard',
184 + );
185 +
186 + $is_grey_page = self::is_page_in_list( $grey_pages );
187 +
188 + /**
189 + * Filter to change FF wrapper background to grey.
190 + *
191 + * @since 6.8
192 + *
193 + * @param bool $is_grey_page
194 + * @return bool
195 + */
196 + return apply_filters( 'frm_is_grey_page', $is_grey_page );
197 + }
198 +
199 + /**
200 + * @since 6.8
201 + *
202 + * @param array $pages A list of page names to check.
203 + * @return bool
204 + */
205 + private static function is_page_in_list( $pages ) {
206 + $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
207 + return in_array( $get_page, $pages, true );
208 + }
209 +
210 + /**
166 211 * @return void
167 212 */
168 213 public static function load_wp_admin_style() {
169 214 FrmAppHelper::load_font_style();
@@ -169,10 +214,11 @@
169 214 FrmAppHelper::load_font_style();
170 215 }
171 216
172 217 /**
173 - * @param bool $show_nav
174 - * @param string $title
218 + * @param int|object $form
219 + * @param bool $show_nav
220 + * @param string $title
175 221 *
176 222 * @psalm-param 'hide'|'show' $title
177 223 *
178 224 * @return void
@@ -375,66 +421,11 @@
375 421 $shared_path = $plugin_path . '/classes/views/shared/';
376 422
377 423 include $shared_path . 'upgrade_overlay.php';
378 424 include $shared_path . 'confirm-overlay.php';
379 -
380 - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) {
381 - self::new_form_overlay_html();
382 - }
383 425 }
384 426
385 427 /**
386 - * @return void
387 - */
388 - private static function new_form_overlay_html() {
389 - FrmFormsController::before_list_templates();
390 -
391 - $plugin_path = FrmAppHelper::plugin_path();
392 - $path = $plugin_path . '/classes/views/frm-forms/';
393 - $expired = FrmFormsController::expired();
394 - $expiring = FrmAddonsController::is_license_expiring();
395 - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field
396 - $view_path = $path . 'new-form-overlay/';
397 - $modal_class = '';
398 - $upgrade_link = FrmAppHelper::admin_upgrade_link(
399 - array(
400 - 'medium' => 'new-template',
401 - 'content' => 'upgrade',
402 - )
403 - );
404 - $renew_link = FrmAppHelper::admin_upgrade_link(
405 - array(
406 - 'medium' => 'new-template',
407 - 'content' => 'renew',
408 - )
409 - );
410 - $blocks_to_render = array();
411 -
412 - if ( ! FrmAppHelper::pro_is_installed() ) {
413 - // avoid rendering the email and code blocks for users who have upgraded or have a free license already
414 - $api = new FrmFormTemplateApi();
415 - if ( ! $api->has_free_access() ) {
416 - array_push( $blocks_to_render, 'email', 'code' );
417 - }
418 - }
419 -
420 - // avoid rendering the upgrade block for users with elite
421 - if ( 'elite' !== FrmAddonsController::license_type() ) {
422 - $blocks_to_render[] = 'upgrade';
423 - }
424 -
425 - // avoid rendering the renew block for users who are not currently expired
426 - if ( $expired ) {
427 - $blocks_to_render[] = 'renew';
428 - $modal_class = 'frm-expired';
429 - } elseif ( $expiring ) {
430 - $modal_class = 'frm-expiring';
431 - }
432 -
433 - include $path . 'new-form-overlay.php';
434 - }
435 -
436 - /**
437 428 * Create a basic form with an email field.
438 429 *
439 430 * @param string $form_key
440 431 * @param string $title
@@ -441,12 +432,15 @@
441 432 * @param string $description
442 433 * @return void
443 434 */
444 435 public static function api_email_form( $form_key, $title, $description ) {
445 - $url = 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css';
446 - $view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new-form-overlay/';
447 436 $user = wp_get_current_user();
448 - require $view_path . 'leave-email.php';
437 + $args = array(
438 + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
439 + 'title' => $title,
440 + 'description' => $description,
441 + );
442 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
449 443 }
450 444
451 445 /**
452 446 * @return void
@@ -543,8 +537,12 @@
543 537 *
544 538 * @return void
545 539 */
546 540 public static function admin_init() {
541 + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) {
542 + FrmFormsController::delete_all();
543 + }
544 +
547 545 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
548 546 FrmFormsController::duplicate();
549 547 }
550 548
@@ -552,9 +550,10 @@
552 550 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
553 551 FrmStylesController::save_style();
554 552 }
555 553
556 - new FrmPersonalData(); // register personal data hooks
554 + // Register personal data hooks.
555 + new FrmPersonalData();
557 556
558 557 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
559 558 self::network_upgrade_site();
560 559 }
@@ -563,13 +562,20 @@
563 562 // don't continue during ajax calls
564 563 self::admin_js();
565 564 }
566 565
566 + self::trigger_page_load_hooks();
567 +
567 568 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
569 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
570 + // This provides backward compatibility for old addons that use legacy modal templates.
568 571 $action = FrmAppHelper::get_param( 'frm_action' );
572 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
573 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
574 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
575 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
569 576
570 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
571 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
577 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
572 578 exit;
573 579 }
574 580
575 581 FrmInbox::maybe_disable_screen_options();
@@ -578,8 +584,31 @@
578 584 self::maybe_add_ip_warning();
579 585 }
580 586
581 587 /**
588 + * Get the current page and check for a possible function to trigger.
589 + * If a class name matches the page name, and the class has a load_page() method, trigger it.
590 + *
591 + * @since 6.8
592 + *
593 + * @return void
594 + */
595 + private static function trigger_page_load_hooks() {
596 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
597 + if ( strpos( $page, 'formidable-' ) !== 0 ) {
598 + // Only trigger hooks on Formidable pages.
599 + return;
600 + }
601 +
602 + $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
603 + $page = str_replace( ' ', '', ucwords( $page ) );
604 + $class = 'Frm' . $page . 'Controller';
605 + if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
606 + call_user_func( array( $class, 'load_page' ) );
607 + }
608 + }
609 +
610 + /**
582 611 * Show a warning for the IP address setting if it hasn't been set.
583 612 *
584 613 * @since 6.1
585 614 *
@@ -644,10 +673,15 @@
644 673 $plugin_url = FrmAppHelper::plugin_url();
645 674 $version = FrmAppHelper::plugin_version();
646 675
647 676 FrmAppHelper::load_admin_wide_js();
648 - FrmOverlayController::register_assets();
649 677
678 + if ( class_exists( 'FrmOverlayController' ) ) {
679 + // This should always exist.
680 + // But it may not have loaded properly when updating the plugin.
681 + FrmOverlayController::register_assets();
682 + }
683 +
650 684 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
651 685 wp_enqueue_style( 'formidable_admin_global' );
652 686
653 687 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -671,13 +705,8 @@
671 705 self::enqueue_floating_links( $plugin_url, $version );
672 706 }
673 707 unset( $is_valid_page );
674 708
675 - if ( 'formidable-applications' === $page ) {
676 - FrmApplicationsController::load_assets();
677 - return;
678 - }
679 -
680 709 $dependencies = array(
681 710 'formidable_admin_global',
682 711 'jquery',
683 712 'jquery-ui-core',
@@ -685,9 +714,10 @@
685 714 'jquery-ui-sortable',
686 715 'bootstrap_tooltip',
687 716 'bootstrap-multiselect',
688 717 'wp-i18n',
689 - 'wp-hooks', // Required in WP versions older than 5.7
718 + // Required in WP versions older than 5.7
719 + 'wp-hooks',
690 720 'formidable_dom',
691 721 'formidable_embed',
692 722 );
693 723
@@ -738,8 +768,12 @@
738 768
739 769 if ( 'formidable-entries' === $page ) {
740 770 // Load front end js for entries.
741 771 wp_enqueue_script( 'formidable' );
772 +
773 + // Registers and enqueues the entries page scripts.
774 + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
775 + wp_enqueue_script( 'formidable_entries' );
742 776 }
743 777
744 778 do_action( 'frm_enqueue_builder_scripts' );
745 779 self::include_upgrade_overlay();
@@ -759,10 +793,14 @@
759 793
760 794 if ( $post_type === 'frm_display' ) {
761 795 self::enqueue_legacy_views_assets();
762 796 }
797 + }//end if
798 +
799 + if ( 'formidable-addons' === $page ) {
800 + wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
801 + wp_enqueue_script( 'formidable_addons' );
763 802 }
764 -
765 803 }
766 804
767 805 /**
768 806 * @since 6.3.2
@@ -1029,9 +1067,9 @@
1029 1067
1030 1068 $frmdb = new FrmMigrate();
1031 1069 $frmdb->uninstall();
1032 1070
1033 - //disable the plugin and redirect after uninstall so the tables don't get added right back
1071 + // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1034 1072 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1035 1073 deactivate_plugins( $plugins, false, false );
1036 1074 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1037 1075
@@ -1102,21 +1140,69 @@
1102 1140 *
1103 1141 * @return void
1104 1142 */
1105 1143 public static function add_admin_footer_links() {
1106 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1144 + if ( self::should_show_footer_links() ) {
1145 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1146 + }
1147 + }
1107 1148
1108 - // Check admin privileges, screen mode, and branding
1109 - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs';
1110 - $is_full_screen = FrmAppHelper::is_full_screen();
1111 - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding();
1149 + /**
1150 + * Check if the footer links should be shown.
1151 + *
1152 + * @since 6.7
1153 + *
1154 + * @return bool
1155 + */
1156 + private static function should_show_footer_links() {
1157 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1158 + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1159 + $show_footer_links = $is_formidable_page;
1160 + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1161 + $show_footer_links = false;
1162 + }
1112 1163
1113 - // Exit if any of the above conditions are met
1114 - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) {
1115 - return;
1164 + /**
1165 + * Filter whether to show the Formidable footer links.
1166 + *
1167 + * @since 6.7
1168 + *
1169 + * @param bool $show_footer_links
1170 + * @return bool
1171 + */
1172 + return apply_filters( 'frm_show_footer_links', $show_footer_links );
1173 + }
1174 +
1175 + /**
1176 + * Show an error modal and terminate the script execution.
1177 + *
1178 + * @since 6.7
1179 + *
1180 + * @param array $error_args Arguments that control the behavior of the error modal.
1181 + *
1182 + * @return void
1183 + */
1184 + public static function show_error_modal( $error_args ) {
1185 + $defaults = array(
1186 + 'title' => '',
1187 + 'body' => '',
1188 + 'cancel_url' => '',
1189 + 'cancel_classes' => '',
1190 + 'continue_url' => '',
1191 + 'continue_classes' => '',
1192 + 'icon' => 'frm_lock_simple',
1193 + );
1194 +
1195 + $error_args = wp_parse_args( $error_args, $defaults );
1196 + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1197 + $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1116 1198 }
1117 1199
1118 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1200 + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) {
1201 + $error_args['continue_text'] = __( 'Continue', 'formidable' );
1202 + }
1203 +
1204 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1119 1205 }
1120 1206
1121 1207 /**
1122 1208 * @deprecated 3.0.04