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 +224 -59 6.36.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>' . 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 );
@@ -637,8 +636,19 @@
637 636 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
638 637
639 638 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
640 639
640 + // Enqueue Floating Links.
641 + $is_valid_page =
642 + FrmAppHelper::is_formidable_admin() &&
643 + ! FrmAppHelper::is_style_editor_page() &&
644 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
645 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
646 + if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
647 + self::enqueue_floating_links( $plugin_url, $version );
648 + }
649 + unset( $is_valid_page );
650 +
641 651 if ( 'formidable-applications' === $page ) {
642 652 FrmApplicationsController::load_assets();
643 653 return;
644 654 }
@@ -651,9 +661,10 @@
651 661 'jquery-ui-sortable',
652 662 'bootstrap_tooltip',
653 663 'bootstrap-multiselect',
654 664 'wp-i18n',
655 - 'wp-hooks', // Required in WP versions older than 5.7
665 + // Required in WP versions older than 5.7
666 + 'wp-hooks',
656 667 'formidable_dom',
657 668 'formidable_embed',
658 669 );
659 670
@@ -670,8 +681,19 @@
670 681 }
671 682
672 683 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
673 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 +
674 696 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
675 697
676 698 global $pagenow;
677 699 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -693,8 +715,12 @@
693 715
694 716 if ( 'formidable-entries' === $page ) {
695 717 // Load front end js for entries.
696 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' );
697 723 }
698 724
699 725 do_action( 'frm_enqueue_builder_scripts' );
700 726 self::include_upgrade_overlay();
@@ -714,10 +740,19 @@
714 740
715 741 if ( $post_type === 'frm_display' ) {
716 742 self::enqueue_legacy_views_assets();
717 743 }
718 - }
744 + }//end if
719 745
746 + }
747 +
748 + /**
749 + * @since 6.3.2
750 + *
751 + * @return void
752 + */
753 + public static function admin_enqueue_scripts() {
754 + self::load_wp_admin_style();
720 755 self::maybe_force_formidable_block_on_gutenberg_page();
721 756 }
722 757
723 758 /**
@@ -975,9 +1010,9 @@
975 1010
976 1011 $frmdb = new FrmMigrate();
977 1012 $frmdb->uninstall();
978 1013
979 - //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.
980 1015 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
981 1016 deactivate_plugins( $plugins, false, false );
982 1017 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
983 1018
@@ -1007,8 +1042,33 @@
1007 1042 delete_site_option( 'frmpro-authorized' );
1008 1043 wp_die();
1009 1044 }
1010 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 +
1011 1071 public static function set_footer_text( $text ) {
1012 1072 if ( FrmAppHelper::is_formidable_admin() ) {
1013 1073 $text = '';
1014 1074 }
@@ -1016,8 +1076,79 @@
1016 1076 return $text;
1017 1077 }
1018 1078
1019 1079 /**
1080 + * Add admin footer links.
1081 + *
1082 + * @since 6.4.1
1083 + *
1084 + * @return void
1085 + */
1086 + public static function add_admin_footer_links() {
1087 + if ( self::should_show_footer_links() ) {
1088 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1089 + }
1090 + }
1091 +
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 + }
1106 +
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' );
1141 + }
1142 +
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';
1148 + }
1149 +
1150 + /**
1020 1151 * @deprecated 3.0.04
1021 1152 *
1022 1153 * @codeCoverageIgnore
1023 1154 *
@@ -1055,6 +1186,40 @@
1055 1186 */
1056 1187 public static function get_form_shortcode( $atts ) {
1057 1188 _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1058 1189 return FrmFormsController::get_form_shortcode( $atts );
1190 + }
1191 +
1192 + /**
1193 + * Handles Floating Links' scripts and styles enqueueing.
1194 + *
1195 + * @since 6.4
1196 + *
1197 + * @param string $plugin_url URL of the plugin.
1198 + * @param string $version Current version of the plugin.
1199 + * @return void
1200 + */
1201 + private static function enqueue_floating_links( $plugin_url, $version ) {
1202 + if ( ! $plugin_url || ! $version ) {
1203 + // If any required parameters are missing, exit early.
1204 + return;
1205 + }
1206 +
1207 + // Enqueue the Floating Links styles.
1208 + wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1209 +
1210 + // Enqueue the Floating Links script.
1211 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1212 +
1213 + // Enqueue the config script.
1214 + wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1215 +
1216 + if ( function_exists( 'wp_set_script_translations' ) ) {
1217 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1218 + }
1219 +
1220 + $floating_links_data = array(
1221 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1222 + );
1223 + wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1059 1224 }
1060 1225 }