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 +246 -74 6.46.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,20 +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 - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
140 - $is_white_page = in_array( $get_page, $white_pages, true );
148 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
149 + // Only consider the payments page as a "white page" when the Payments submodule is off.
150 + // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
141 151
142 - if ( ! $is_white_page ) {
143 - $screen = get_current_screen();
144 - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
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 + }
145 157 }
146 158
159 + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
160 +
147 161 /**
148 162 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
149 163 *
150 164 * @since 5.3
@@ -156,8 +170,45 @@
156 170 return $is_white_page;
157 171 }
158 172
159 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 + /**
160 211 * @return void
161 212 */
162 213 public static function load_wp_admin_style() {
163 214 FrmAppHelper::load_font_style();
@@ -163,10 +214,11 @@
163 214 FrmAppHelper::load_font_style();
164 215 }
165 216
166 217 /**
167 - * @param bool $show_nav
168 - * @param string $title
218 + * @param int|object $form
219 + * @param bool $show_nav
220 + * @param string $title
169 221 *
170 222 * @psalm-param 'hide'|'show' $title
171 223 *
172 224 * @return void
@@ -286,9 +338,10 @@
286 338 public static function settings_link( $links ) {
287 339 $settings = array();
288 340
289 341 if ( ! FrmAppHelper::pro_is_installed() ) {
290 - $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b>' . esc_html__( 'Upgrade to Pro', 'formidable' ) . '</b></a>';
342 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
343 + $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
291 344 }
292 345
293 346 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
294 347
@@ -368,63 +421,26 @@
368 421 $shared_path = $plugin_path . '/classes/views/shared/';
369 422
370 423 include $shared_path . 'upgrade_overlay.php';
371 424 include $shared_path . 'confirm-overlay.php';
372 -
373 - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) {
374 - self::new_form_overlay_html();
375 - }
376 425 }
377 426
378 427 /**
428 + * Create a basic form with an email field.
429 + *
430 + * @param string $form_key
431 + * @param string $title
432 + * @param string $description
379 433 * @return void
380 434 */
381 - private static function new_form_overlay_html() {
382 - FrmFormsController::before_list_templates();
383 -
384 - $plugin_path = FrmAppHelper::plugin_path();
385 - $path = $plugin_path . '/classes/views/frm-forms/';
386 - $expired = FrmFormsController::expired();
387 - $expiring = FrmAddonsController::is_license_expiring();
388 - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field
389 - $view_path = $path . 'new-form-overlay/';
390 - $modal_class = '';
391 - $upgrade_link = FrmAppHelper::admin_upgrade_link(
392 - array(
393 - 'medium' => 'new-template',
394 - 'content' => 'upgrade',
395 - )
435 + public static function api_email_form( $form_key, $title, $description ) {
436 + $user = wp_get_current_user();
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,
396 441 );
397 - $renew_link = FrmAppHelper::admin_upgrade_link(
398 - array(
399 - 'medium' => 'new-template',
400 - 'content' => 'renew',
401 - )
402 - );
403 - $blocks_to_render = array();
404 -
405 - if ( ! FrmAppHelper::pro_is_installed() ) {
406 - // avoid rendering the email and code blocks for users who have upgraded or have a free license already
407 - $api = new FrmFormTemplateApi();
408 - if ( ! $api->has_free_access() ) {
409 - array_push( $blocks_to_render, 'email', 'code' );
410 - }
411 - }
412 -
413 - // avoid rendering the upgrade block for users with elite
414 - if ( 'elite' !== FrmAddonsController::license_type() ) {
415 - $blocks_to_render[] = 'upgrade';
416 - }
417 -
418 - // avoid rendering the renew block for users who are not currently expired
419 - if ( $expired ) {
420 - $blocks_to_render[] = 'renew';
421 - $modal_class = 'frm-expired';
422 - } elseif ( $expiring ) {
423 - $modal_class = 'frm-expiring';
424 - }
425 -
426 - include $path . 'new-form-overlay.php';
442 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
427 443 }
428 444
429 445 /**
430 446 * @return void
@@ -521,8 +537,12 @@
521 537 *
522 538 * @return void
523 539 */
524 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 +
525 545 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 546 FrmFormsController::duplicate();
527 547 }
528 548
@@ -530,9 +550,10 @@
530 550 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
531 551 FrmStylesController::save_style();
532 552 }
533 553
534 - new FrmPersonalData(); // register personal data hooks
554 + // Register personal data hooks.
555 + new FrmPersonalData();
535 556
536 557 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
537 558 self::network_upgrade_site();
538 559 }
@@ -541,13 +562,20 @@
541 562 // don't continue during ajax calls
542 563 self::admin_js();
543 564 }
544 565
566 + self::trigger_page_load_hooks();
567 +
545 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.
546 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 : '';
547 576
548 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
549 - 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 ) );
550 578 exit;
551 579 }
552 580
553 581 FrmInbox::maybe_disable_screen_options();
@@ -556,8 +584,31 @@
556 584 self::maybe_add_ip_warning();
557 585 }
558 586
559 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 + /**
560 611 * Show a warning for the IP address setting if it hasn't been set.
561 612 *
562 613 * @since 6.1
563 614 *
@@ -623,8 +674,14 @@
623 674 $version = FrmAppHelper::plugin_version();
624 675
625 676 FrmAppHelper::load_admin_wide_js();
626 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 +
627 684 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
628 685 wp_enqueue_style( 'formidable_admin_global' );
629 686
630 687 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -643,18 +700,13 @@
643 700 FrmAppHelper::is_formidable_admin() &&
644 701 ! FrmAppHelper::is_style_editor_page() &&
645 702 ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
646 703 ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
647 - if ( $is_valid_page ) {
704 + if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
648 705 self::enqueue_floating_links( $plugin_url, $version );
649 706 }
650 707 unset( $is_valid_page );
651 708
652 - if ( 'formidable-applications' === $page ) {
653 - FrmApplicationsController::load_assets();
654 - return;
655 - }
656 -
657 709 $dependencies = array(
658 710 'formidable_admin_global',
659 711 'jquery',
660 712 'jquery-ui-core',
@@ -662,9 +714,10 @@
662 714 'jquery-ui-sortable',
663 715 'bootstrap_tooltip',
664 716 'bootstrap-multiselect',
665 717 'wp-i18n',
666 - 'wp-hooks', // Required in WP versions older than 5.7
718 + // Required in WP versions older than 5.7
719 + 'wp-hooks',
667 720 'formidable_dom',
668 721 'formidable_embed',
669 722 );
670 723
@@ -681,8 +734,19 @@
681 734 }
682 735
683 736 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
684 737
738 + if ( ! class_exists( 'FrmTransHooksController', false ) ) {
739 + /**
740 + * Gateway fields are included for add-on compatibility but we do not want it to be visible.
741 + * They do however need to be visible when the payments submodule is active.
742 + */
743 + wp_add_inline_style(
744 + 'formidable-admin',
745 + '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
746 + );
747 + }
748 +
685 749 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
686 750
687 751 global $pagenow;
688 752 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -704,8 +768,12 @@
704 768
705 769 if ( 'formidable-entries' === $page ) {
706 770 // Load front end js for entries.
707 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' );
708 776 }
709 777
710 778 do_action( 'frm_enqueue_builder_scripts' );
711 779 self::include_upgrade_overlay();
@@ -725,10 +793,14 @@
725 793
726 794 if ( $post_type === 'frm_display' ) {
727 795 self::enqueue_legacy_views_assets();
728 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' );
729 802 }
730 -
731 803 }
732 804
733 805 /**
734 806 * @since 6.3.2
@@ -995,9 +1067,9 @@
995 1067
996 1068 $frmdb = new FrmMigrate();
997 1069 $frmdb->uninstall();
998 1070
999 - //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.
1000 1072 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1001 1073 deactivate_plugins( $plugins, false, false );
1002 1074 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1003 1075
@@ -1027,8 +1099,33 @@
1027 1099 delete_site_option( 'frmpro-authorized' );
1028 1100 wp_die();
1029 1101 }
1030 1102
1103 + /**
1104 + * This is triggered when Formidable is activated.
1105 + *
1106 + * @return void
1107 + */
1108 + public static function handle_activation() {
1109 + self::maybe_activate_payment_cron();
1110 + }
1111 +
1112 + /**
1113 + * The payment cron is unscheduled when Formidable is deactivated.
1114 + * We need to add it back again on activation if Stripe is configured.
1115 + *
1116 + * @since 6.5
1117 + *
1118 + * @return void
1119 + */
1120 + private static function maybe_activate_payment_cron() {
1121 + if ( ! FrmStrpLiteConnectHelper::stripe_connect_is_setup() ) {
1122 + return;
1123 + }
1124 +
1125 + FrmTransLiteAppController::maybe_schedule_cron();
1126 + }
1127 +
1031 1128 public static function set_footer_text( $text ) {
1032 1129 if ( FrmAppHelper::is_formidable_admin() ) {
1033 1130 $text = '';
1034 1131 }
@@ -1036,8 +1133,79 @@
1036 1133 return $text;
1037 1134 }
1038 1135
1039 1136 /**
1137 + * Add admin footer links.
1138 + *
1139 + * @since 6.4.1
1140 + *
1141 + * @return void
1142 + */
1143 + public static function add_admin_footer_links() {
1144 + if ( self::should_show_footer_links() ) {
1145 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1146 + }
1147 + }
1148 +
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 + }
1163 +
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' );
1198 + }
1199 +
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';
1205 + }
1206 +
1207 + /**
1040 1208 * @deprecated 3.0.04
1041 1209 *
1042 1210 * @codeCoverageIgnore
1043 1211 *
@@ -1080,9 +1248,9 @@
1080 1248
1081 1249 /**
1082 1250 * Handles Floating Links' scripts and styles enqueueing.
1083 1251 *
1084 - * @since x.x
1252 + * @since 6.4
1085 1253 *
1086 1254 * @param string $plugin_url URL of the plugin.
1087 1255 * @param string $version Current version of the plugin.
1088 1256 * @return void
@@ -1100,9 +1268,13 @@
1100 1268 wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1101 1269
1102 1270 // Enqueue the config script.
1103 1271 wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1104 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1272 +
1273 + if ( function_exists( 'wp_set_script_translations' ) ) {
1274 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1275 + }
1276 +
1105 1277 $floating_links_data = array(
1106 1278 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1107 1279 );
1108 1280 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );