PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
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 +161 -69 6.4.26.7.2 View file →
@@ -66,9 +66,11 @@
66 66 $full_screen_on = self::get_full_screen_setting();
67 67 $add_class = '';
68 68 if ( $full_screen_on ) {
69 69 $add_class = ' frm-full-screen is-fullscreen-mode';
70 - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
70 +
71 + // Load the CSS for .is-fullscreen-mode.
72 + wp_enqueue_style( 'wp-edit-post' );
71 73 }
72 74 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
73 75 }
74 76
@@ -75,8 +77,12 @@
75 77 if ( ! FrmAppHelper::pro_is_installed() ) {
76 78 $classes .= ' frm-lite ';
77 79 }
78 80
81 + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) {
82 + $classes .= ' frm-unfold ';
83 + }
84 +
79 85 return $classes;
80 86 }
81 87
82 88 /**
@@ -133,10 +139,22 @@
133 139 'formidable-styles2',
134 140 'formidable-inbox',
135 141 'formidable-welcome',
136 142 'formidable-applications',
143 + FrmFormTemplatesController::PAGE_SLUG,
137 144 );
138 145
146 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
147 + // Only consider the payments page as a "white page" when the Payments submodule is off.
148 + // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
149 +
150 + // Add an extra check to avoid white page styling on the PayPal "edit" action.
151 + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view.
152 + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) {
153 + $white_pages[] = 'formidable-payments';
154 + }
155 + }
156 +
139 157 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
140 158 $is_white_page = in_array( $get_page, $white_pages, true );
141 159
142 160 if ( ! $is_white_page ) {
@@ -163,10 +181,11 @@
163 181 FrmAppHelper::load_font_style();
164 182 }
165 183
166 184 /**
167 - * @param bool $show_nav
168 - * @param string $title
185 + * @param int|object $form
186 + * @param bool $show_nav
187 + * @param string $title
169 188 *
170 189 * @psalm-param 'hide'|'show' $title
171 190 *
172 191 * @return void
@@ -286,9 +305,10 @@
286 305 public static function settings_link( $links ) {
287 306 $settings = array();
288 307
289 308 if ( ! FrmAppHelper::pro_is_installed() ) {
290 - $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>';
309 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
310 + $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 311 }
292 312
293 313 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
294 314
@@ -368,63 +388,26 @@
368 388 $shared_path = $plugin_path . '/classes/views/shared/';
369 389
370 390 include $shared_path . 'upgrade_overlay.php';
371 391 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 392 }
377 393
378 394 /**
395 + * Create a basic form with an email field.
396 + *
397 + * @param string $form_key
398 + * @param string $title
399 + * @param string $description
379 400 * @return void
380 401 */
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 - )
402 + public static function api_email_form( $form_key, $title, $description ) {
403 + $user = wp_get_current_user();
404 + $args = array(
405 + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
406 + 'title' => $title,
407 + 'description' => $description,
396 408 );
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';
409 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
427 410 }
428 411
429 412 /**
430 413 * @return void
@@ -521,8 +504,12 @@
521 504 *
522 505 * @return void
523 506 */
524 507 public static function admin_init() {
508 + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) {
509 + FrmFormsController::delete_all();
510 + }
511 +
525 512 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 513 FrmFormsController::duplicate();
527 514 }
528 515
@@ -530,9 +517,10 @@
530 517 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
531 518 FrmStylesController::save_style();
532 519 }
533 520
534 - new FrmPersonalData(); // register personal data hooks
521 + // Register personal data hooks.
522 + new FrmPersonalData();
535 523
536 524 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
537 525 self::network_upgrade_site();
538 526 }
@@ -542,12 +530,17 @@
542 530 self::admin_js();
543 531 }
544 532
545 533 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
534 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
535 + // This provides backward compatibility for old addons that use legacy modal templates.
546 536 $action = FrmAppHelper::get_param( 'frm_action' );
537 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
538 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
539 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
540 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
547 541
548 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
549 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
542 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
550 543 exit;
551 544 }
552 545
553 546 FrmInbox::maybe_disable_screen_options();
@@ -623,8 +616,14 @@
623 616 $version = FrmAppHelper::plugin_version();
624 617
625 618 FrmAppHelper::load_admin_wide_js();
626 619
620 + if ( class_exists( 'FrmOverlayController' ) ) {
621 + // This should always exist.
622 + // But it may not have loaded properly when updating the plugin.
623 + FrmOverlayController::register_assets();
624 + }
625 +
627 626 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
628 627 wp_enqueue_style( 'formidable_admin_global' );
629 628
630 629 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -662,9 +661,10 @@
662 661 'jquery-ui-sortable',
663 662 'bootstrap_tooltip',
664 663 'bootstrap-multiselect',
665 664 'wp-i18n',
666 - 'wp-hooks', // Required in WP versions older than 5.7
665 + // Required in WP versions older than 5.7
666 + 'wp-hooks',
667 667 'formidable_dom',
668 668 'formidable_embed',
669 669 );
670 670
@@ -681,8 +681,19 @@
681 681 }
682 682
683 683 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
684 684
685 + if ( ! class_exists( 'FrmTransHooksController', false ) ) {
686 + /**
687 + * Gateway fields are included for add-on compatibility but we do not want it to be visible.
688 + * They do however need to be visible when the payments submodule is active.
689 + */
690 + wp_add_inline_style(
691 + 'formidable-admin',
692 + '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
693 + );
694 + }
695 +
685 696 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
686 697
687 698 global $pagenow;
688 699 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -704,8 +715,12 @@
704 715
705 716 if ( 'formidable-entries' === $page ) {
706 717 // Load front end js for entries.
707 718 wp_enqueue_script( 'formidable' );
719 +
720 + // Registers and enqueues the entries page scripts.
721 + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
722 + wp_enqueue_script( 'formidable_entries' );
708 723 }
709 724
710 725 do_action( 'frm_enqueue_builder_scripts' );
711 726 self::include_upgrade_overlay();
@@ -725,9 +740,9 @@
725 740
726 741 if ( $post_type === 'frm_display' ) {
727 742 self::enqueue_legacy_views_assets();
728 743 }
729 - }
744 + }//end if
730 745
731 746 }
732 747
733 748 /**
@@ -995,9 +1010,9 @@
995 1010
996 1011 $frmdb = new FrmMigrate();
997 1012 $frmdb->uninstall();
998 1013
999 - //disable the plugin and redirect after uninstall so the tables don't get added right back
1014 + // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1000 1015 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1001 1016 deactivate_plugins( $plugins, false, false );
1002 1017 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1003 1018
@@ -1027,8 +1042,33 @@
1027 1042 delete_site_option( 'frmpro-authorized' );
1028 1043 wp_die();
1029 1044 }
1030 1045
1046 + /**
1047 + * This is triggered when Formidable is activated.
1048 + *
1049 + * @return void
1050 + */
1051 + public static function handle_activation() {
1052 + self::maybe_activate_payment_cron();
1053 + }
1054 +
1055 + /**
1056 + * The payment cron is unscheduled when Formidable is deactivated.
1057 + * We need to add it back again on activation if Stripe is configured.
1058 + *
1059 + * @since 6.5
1060 + *
1061 + * @return void
1062 + */
1063 + private static function maybe_activate_payment_cron() {
1064 + if ( ! FrmStrpLiteConnectHelper::stripe_connect_is_setup() ) {
1065 + return;
1066 + }
1067 +
1068 + FrmTransLiteAppController::maybe_schedule_cron();
1069 + }
1070 +
1031 1071 public static function set_footer_text( $text ) {
1032 1072 if ( FrmAppHelper::is_formidable_admin() ) {
1033 1073 $text = '';
1034 1074 }
@@ -1043,21 +1083,69 @@
1043 1083 *
1044 1084 * @return void
1045 1085 */
1046 1086 public static function add_admin_footer_links() {
1047 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1087 + if ( self::should_show_footer_links() ) {
1088 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1089 + }
1090 + }
1048 1091
1049 - // Check admin privileges, screen mode, and branding
1050 - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs';
1051 - $is_full_screen = FrmAppHelper::is_full_screen();
1052 - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding();
1092 + /**
1093 + * Check if the footer links should be shown.
1094 + *
1095 + * @since 6.7
1096 + *
1097 + * @return bool
1098 + */
1099 + private static function should_show_footer_links() {
1100 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1101 + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1102 + $show_footer_links = $is_formidable_page;
1103 + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1104 + $show_footer_links = false;
1105 + }
1053 1106
1054 - // Exit if any of the above conditions are met
1055 - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) {
1056 - return;
1107 + /**
1108 + * Filter whether to show the Formidable footer links.
1109 + *
1110 + * @since 6.7
1111 + *
1112 + * @param bool $show_footer_links
1113 + * @return bool
1114 + */
1115 + return apply_filters( 'frm_show_footer_links', $show_footer_links );
1116 + }
1117 +
1118 + /**
1119 + * Show an error modal and terminate the script execution.
1120 + *
1121 + * @since 6.7
1122 + *
1123 + * @param array $error_args Arguments that control the behavior of the error modal.
1124 + *
1125 + * @return void
1126 + */
1127 + public static function show_error_modal( $error_args ) {
1128 + $defaults = array(
1129 + 'title' => '',
1130 + 'body' => '',
1131 + 'cancel_url' => '',
1132 + 'cancel_classes' => '',
1133 + 'continue_url' => '',
1134 + 'continue_classes' => '',
1135 + 'icon' => 'frm_lock_simple',
1136 + );
1137 +
1138 + $error_args = wp_parse_args( $error_args, $defaults );
1139 + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1140 + $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1057 1141 }
1058 1142
1059 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1143 + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) {
1144 + $error_args['continue_text'] = __( 'Continue', 'formidable' );
1145 + }
1146 +
1147 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1060 1148 }
1061 1149
1062 1150 /**
1063 1151 * @deprecated 3.0.04
@@ -1123,9 +1211,13 @@
1123 1211 wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1124 1212
1125 1213 // Enqueue the config script.
1126 1214 wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1127 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1215 +
1216 + if ( function_exists( 'wp_set_script_translations' ) ) {
1217 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1218 + }
1219 +
1128 1220 $floating_links_data = array(
1129 1221 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1130 1222 );
1131 1223 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );