PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.15
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.15
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 +376 -147 6.56.15 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 - $add_class = '';
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,25 @@
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,
146 + FrmOnboardingWizardController::PAGE_SLUG,
137 147 );
138 148
139 - if ( ! class_exists( 'FrmTransHooksController', false ) ) {
149 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
140 150 // Only consider the payments page as a "white page" when the Payments submodule is off.
141 151 // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
142 - $white_pages[] = 'formidable-payments';
152 +
153 + // Add an extra check to avoid white page styling on the PayPal "edit" action.
154 + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view.
155 + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) {
156 + $white_pages[] = 'formidable-payments';
157 + }
143 158 }
144 159
145 - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
146 - $is_white_page = in_array( $get_page, $white_pages, true );
160 + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
147 161
148 - if ( ! $is_white_page ) {
149 - $screen = get_current_screen();
150 - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
151 - }
152 -
153 162 /**
154 163 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
155 164 *
156 165 * @since 5.3
@@ -162,8 +171,45 @@
162 171 return $is_white_page;
163 172 }
164 173
165 174 /**
175 + * Add a grey bg instead of white.
176 + *
177 + * @since 6.8
178 + *
179 + * @return bool
180 + */
181 + private static function is_grey_page() {
182 + $grey_pages = array(
183 + 'formidable-applications',
184 + 'formidable-dashboard',
185 + );
186 +
187 + $is_grey_page = self::is_page_in_list( $grey_pages );
188 +
189 + /**
190 + * Filter to change FF wrapper background to grey.
191 + *
192 + * @since 6.8
193 + *
194 + * @param bool $is_grey_page
195 + * @return bool
196 + */
197 + return apply_filters( 'frm_is_grey_page', $is_grey_page );
198 + }
199 +
200 + /**
201 + * @since 6.8
202 + *
203 + * @param array $pages A list of page names to check.
204 + * @return bool
205 + */
206 + private static function is_page_in_list( $pages ) {
207 + $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
208 + return in_array( $get_page, $pages, true );
209 + }
210 +
211 + /**
166 212 * @return void
167 213 */
168 214 public static function load_wp_admin_style() {
169 215 FrmAppHelper::load_font_style();
@@ -169,10 +215,11 @@
169 215 FrmAppHelper::load_font_style();
170 216 }
171 217
172 218 /**
173 - * @param bool $show_nav
174 - * @param string $title
219 + * @param int|object $form
220 + * @param bool $show_nav
221 + * @param string $title
175 222 *
176 223 * @psalm-param 'hide'|'show' $title
177 224 *
178 225 * @return void
@@ -191,9 +238,9 @@
191 238 $id = $form->id;
192 239 $current_page = self::get_current_page();
193 240 $nav_items = self::get_form_nav_items( $form );
194 241
195 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
242 + include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
196 243 }
197 244
198 245 /**
199 246 * @return string
@@ -247,18 +294,18 @@
247 294 'permission' => 'frm_view_entries',
248 295 ),
249 296 );
250 297
251 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
298 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
252 299
253 300 if ( ! $views_installed ) {
254 301 $nav_items[] = array(
255 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
256 - 'label' => __( 'Views', 'formidable' ),
257 - 'current' => array(),
258 - 'page' => 'formidable-views',
302 + 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
303 + 'label' => __( 'Views', 'formidable' ),
304 + 'current' => array(),
305 + 'page' => 'formidable-views',
259 306 'permission' => 'frm_view_entries',
260 - 'atts' => array(
307 + 'atts' => array(
261 308 'class' => 'frm_noallow',
262 309 ),
263 310 );
264 311 }
@@ -265,14 +312,14 @@
265 312
266 313 // Let people know reports and views exist.
267 314 if ( ! FrmAppHelper::pro_is_installed() ) {
268 315 $nav_items[] = array(
269 - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
270 - 'label' => __( 'Reports', 'formidable' ),
271 - 'current' => array( 'reports' ),
272 - 'page' => 'formidable',
316 + 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
317 + 'label' => __( 'Reports', 'formidable' ),
318 + 'current' => array( 'reports' ),
319 + 'page' => 'formidable',
273 320 'permission' => 'frm_view_entries',
274 - 'atts' => array(
321 + 'atts' => array(
275 322 'class' => 'frm_noallow',
276 323 ),
277 324 );
278 325 }
@@ -292,9 +339,10 @@
292 339 public static function settings_link( $links ) {
293 340 $settings = array();
294 341
295 342 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>';
343 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
344 + $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>';
297 345 }
298 346
299 347 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
300 348
@@ -305,9 +353,9 @@
305 353 * @return void
306 354 */
307 355 public static function pro_get_started_headline() {
308 356 self::review_request();
309 - FrmAppHelper::min_pro_version_notice( '4.0' );
357 + FrmAppHelper::min_pro_version_notice( '6.0' );
310 358 }
311 359
312 360 /**
313 361 * Add admin notices as needed for reviews
@@ -374,63 +422,26 @@
374 422 $shared_path = $plugin_path . '/classes/views/shared/';
375 423
376 424 include $shared_path . 'upgrade_overlay.php';
377 425 include $shared_path . 'confirm-overlay.php';
378 -
379 - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) {
380 - self::new_form_overlay_html();
381 - }
382 426 }
383 427
384 428 /**
429 + * Create a basic form with an email field.
430 + *
431 + * @param string $form_key
432 + * @param string $title
433 + * @param string $description
385 434 * @return void
386 435 */
387 - private static function new_form_overlay_html() {
388 - FrmFormsController::before_list_templates();
389 -
390 - $plugin_path = FrmAppHelper::plugin_path();
391 - $path = $plugin_path . '/classes/views/frm-forms/';
392 - $expired = FrmFormsController::expired();
393 - $expiring = FrmAddonsController::is_license_expiring();
394 - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field
395 - $view_path = $path . 'new-form-overlay/';
396 - $modal_class = '';
397 - $upgrade_link = FrmAppHelper::admin_upgrade_link(
398 - array(
399 - 'medium' => 'new-template',
400 - 'content' => 'upgrade',
401 - )
436 + public static function api_email_form( $form_key, $title = '', $description = '' ) {
437 + $user = wp_get_current_user();
438 + $args = array(
439 + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
440 + 'title' => $title,
441 + 'description' => $description,
402 442 );
403 - $renew_link = FrmAppHelper::admin_upgrade_link(
404 - array(
405 - 'medium' => 'new-template',
406 - 'content' => 'renew',
407 - )
408 - );
409 - $blocks_to_render = array();
410 -
411 - if ( ! FrmAppHelper::pro_is_installed() ) {
412 - // avoid rendering the email and code blocks for users who have upgraded or have a free license already
413 - $api = new FrmFormTemplateApi();
414 - if ( ! $api->has_free_access() ) {
415 - array_push( $blocks_to_render, 'email', 'code' );
416 - }
417 - }
418 -
419 - // avoid rendering the upgrade block for users with elite
420 - if ( 'elite' !== FrmAddonsController::license_type() ) {
421 - $blocks_to_render[] = 'upgrade';
422 - }
423 -
424 - // avoid rendering the renew block for users who are not currently expired
425 - if ( $expired ) {
426 - $blocks_to_render[] = 'renew';
427 - $modal_class = 'frm-expired';
428 - } elseif ( $expiring ) {
429 - $modal_class = 'frm-expiring';
430 - }
431 -
432 - include $path . 'new-form-overlay.php';
443 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
433 444 }
434 445
435 446 /**
436 447 * @return void
@@ -478,9 +489,9 @@
478 489 /**
479 490 * Check if the database is outdated
480 491 *
481 492 * @since 2.0.1
482 - * @return boolean
493 + * @return bool
483 494 */
484 495 public static function needs_update() {
485 496 $needs_upgrade = self::compare_for_update(
486 497 array(
@@ -527,8 +538,12 @@
527 538 *
528 539 * @return void
529 540 */
530 541 public static function admin_init() {
542 + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) {
543 + FrmFormsController::delete_all();
544 + }
545 +
531 546 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
532 547 FrmFormsController::duplicate();
533 548 }
534 549
@@ -536,9 +551,10 @@
536 551 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
537 552 FrmStylesController::save_style();
538 553 }
539 554
540 - new FrmPersonalData(); // register personal data hooks
555 + // Register personal data hooks.
556 + new FrmPersonalData();
541 557
542 558 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
543 559 self::network_upgrade_site();
544 560 }
@@ -547,13 +563,20 @@
547 563 // don't continue during ajax calls
548 564 self::admin_js();
549 565 }
550 566
567 + self::trigger_page_load_hooks();
568 +
551 569 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
552 - $action = FrmAppHelper::get_param( 'frm_action' );
570 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
571 + // This provides backward compatibility for old addons that use legacy modal templates.
572 + $action = FrmAppHelper::get_param( 'frm_action' );
573 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
574 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
575 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
576 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
553 577
554 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
555 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
578 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
556 579 exit;
557 580 }
558 581
559 582 FrmInbox::maybe_disable_screen_options();
@@ -562,8 +585,31 @@
562 585 self::maybe_add_ip_warning();
563 586 }
564 587
565 588 /**
589 + * Get the current page and check for a possible function to trigger.
590 + * If a class name matches the page name, and the class has a load_page() method, trigger it.
591 + *
592 + * @since 6.8
593 + *
594 + * @return void
595 + */
596 + private static function trigger_page_load_hooks() {
597 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
598 + if ( strpos( $page, 'formidable-' ) !== 0 ) {
599 + // Only trigger hooks on Formidable pages.
600 + return;
601 + }
602 +
603 + $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
604 + $page = str_replace( ' ', '', ucwords( $page ) );
605 + $class = 'Frm' . $page . 'Controller';
606 + if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
607 + call_user_func( array( $class, 'load_page' ) );
608 + }
609 + }
610 +
611 + /**
566 612 * Show a warning for the IP address setting if it hasn't been set.
567 613 *
568 614 * @since 6.1
569 615 *
@@ -586,12 +632,12 @@
586 632 return;
587 633 }
588 634
589 635 $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
590 - $message = sprintf(
636 + $message = sprintf(
591 637 // Translators: 1: Global Settings Link
592 638 __( '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>'
639 + '<a href="' . esc_url( $global_settings_link ) . '">' . __( 'Global Settings', 'formidable' ) . '</a>'
594 640 );
595 641 $option_name = 'frm_dismiss_ip_address_notice';
596 642 FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
597 643 }
@@ -629,8 +675,17 @@
629 675 $version = FrmAppHelper::plugin_version();
630 676
631 677 FrmAppHelper::load_admin_wide_js();
632 678
679 + // Register component assets early to ensure they can be enqueued later in controllers.
680 + wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version );
681 +
682 + if ( class_exists( 'FrmOverlayController' ) ) {
683 + // This should always exist.
684 + // But it may not have loaded properly when updating the plugin.
685 + FrmOverlayController::register_assets();
686 + }
687 +
633 688 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
634 689 wp_enqueue_style( 'formidable_admin_global' );
635 690
636 691 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -641,26 +696,12 @@
641 696 self::register_popper1();
642 697 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
643 698 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
644 699
645 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
646 -
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() ) {
700 + if ( self::should_show_floating_links() ) {
654 701 self::enqueue_floating_links( $plugin_url, $version );
655 702 }
656 - unset( $is_valid_page );
657 703
658 - if ( 'formidable-applications' === $page ) {
659 - FrmApplicationsController::load_assets();
660 - return;
661 - }
662 -
663 704 $dependencies = array(
664 705 'formidable_admin_global',
665 706 'jquery',
666 707 'jquery-ui-core',
@@ -668,9 +709,10 @@
668 709 'jquery-ui-sortable',
669 710 'bootstrap_tooltip',
670 711 'bootstrap-multiselect',
671 712 'wp-i18n',
672 - 'wp-hooks', // Required in WP versions older than 5.7
713 + // Required in WP versions older than 5.7
714 + 'wp-hooks',
673 715 'formidable_dom',
674 716 'formidable_embed',
675 717 );
676 718
@@ -687,8 +729,20 @@
687 729 }
688 730
689 731 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
690 732
733 + if ( ! class_exists( 'FrmTransHooksController', false ) ) {
734 + /**
735 + * Gateway fields are included for add-on compatibility but we do not want it to be visible.
736 + * They do however need to be visible when the payments submodule is active.
737 + */
738 + wp_add_inline_style(
739 + 'formidable-admin',
740 + '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
741 + );
742 + }
743 +
744 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
691 745 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
692 746
693 747 global $pagenow;
694 748 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -699,12 +753,13 @@
699 753 wp_enqueue_script( 'formidable_admin' );
700 754 wp_enqueue_script( 'formidable_embed' );
701 755 FrmAppHelper::localize_script( 'admin' );
702 756
757 + wp_enqueue_style( 'formidable-animations' );
703 758 wp_enqueue_style( 'formidable-admin' );
704 759 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
705 760 wp_enqueue_style( 'formidable-grids' );
706 - wp_enqueue_style( 'formidable-dropzone' );
761 + self::maybe_enqueue_dropzone_css( $page );
707 762 } else {
708 763 wp_enqueue_style( 'formidable-grids' );
709 764 }
710 765
@@ -710,8 +765,12 @@
710 765
711 766 if ( 'formidable-entries' === $page ) {
712 767 // Load front end js for entries.
713 768 wp_enqueue_script( 'formidable' );
769 +
770 + // Registers and enqueues the entries page scripts.
771 + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
772 + wp_enqueue_script( 'formidable_entries' );
714 773 }
715 774
716 775 do_action( 'frm_enqueue_builder_scripts' );
717 776 self::include_upgrade_overlay();
@@ -731,13 +790,55 @@
731 790
732 791 if ( $post_type === 'frm_display' ) {
733 792 self::enqueue_legacy_views_assets();
734 793 }
794 + }//end if
795 +
796 + if ( 'formidable-addons' === $page ) {
797 + wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
798 + wp_enqueue_script( 'formidable_addons' );
735 799 }
800 + }
736 801
802 + /**
803 + * Avoid loading dropzone CSS on the form list page. It isn't required there.
804 + *
805 + * @since 6.11
806 + *
807 + * @param string $page
808 + * @return void
809 + */
810 + private static function maybe_enqueue_dropzone_css( $page ) {
811 + if ( ! FrmAppHelper::pro_is_installed() ) {
812 + return;
813 + }
814 +
815 + $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
816 + if ( ! $should_avoid_loading_dropzone ) {
817 + wp_enqueue_style( 'formidable-dropzone' );
818 + }
737 819 }
738 820
739 821 /**
822 + * The floating links are not shown on every page.
823 + * They are also not shown if white labeling is being used.
824 + *
825 + * @since 6.8.4
826 + *
827 + * @return bool
828 + */
829 + private static function should_show_floating_links() {
830 + if ( ! FrmAppHelper::is_formidable_branding() ) {
831 + return false;
832 + }
833 +
834 + return FrmAppHelper::is_formidable_admin() &&
835 + ! FrmAppHelper::is_style_editor_page() &&
836 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
837 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
838 + }
839 +
840 + /**
740 841 * @since 6.3.2
741 842 *
742 843 * @return void
743 844 */
@@ -813,12 +914,45 @@
813 914 *
814 915 * @return void
815 916 */
816 917 private static function register_popper1() {
918 + if ( ! self::should_register_popper() ) {
919 + return;
920 + }
817 921 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
818 922 }
819 923
820 924 /**
925 + * Only register popper on Formidable pages.
926 + * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor.
927 + *
928 + * @since 6.11.1
929 + *
930 + * @return bool
931 + */
932 + private static function should_register_popper() {
933 + global $pagenow;
934 +
935 + $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
936 + if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
937 + return true;
938 + }
939 +
940 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
941 + $is_views_post_type = 'frm_display' === $post_type;
942 + if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
943 + return true;
944 + }
945 +
946 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
947 + if ( strpos( $page, 'formidable' ) === 0 ) {
948 + return true;
949 + }
950 +
951 + return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
952 + }
953 +
954 + /**
821 955 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
822 956 *
823 957 * @since 5.2
824 958 *
@@ -877,10 +1011,10 @@
877 1011 * @return void
878 1012 */
879 1013 public static function create_rest_routes() {
880 1014 $args = array(
881 - 'methods' => 'GET',
882 - 'callback' => 'FrmAppController::api_install',
1015 + 'methods' => 'GET',
1016 + 'callback' => 'FrmAppController::api_install',
883 1017 'permission_callback' => __CLASS__ . '::can_update_db',
884 1018 );
885 1019
886 1020 register_rest_route( 'frm-admin/v1', '/install', $args );
@@ -885,10 +1019,10 @@
885 1019
886 1020 register_rest_route( 'frm-admin/v1', '/install', $args );
887 1021
888 1022 $args = array(
889 - 'methods' => 'GET',
890 - 'callback' => 'FrmAddonsController::install_addon_api',
1023 + 'methods' => 'GET',
1024 + 'callback' => 'FrmAddonsController::install_addon_api',
891 1025 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
892 1026 );
893 1027
894 1028 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -1001,9 +1135,9 @@
1001 1135
1002 1136 $frmdb = new FrmMigrate();
1003 1137 $frmdb->uninstall();
1004 1138
1005 - //disable the plugin and redirect after uninstall so the tables don't get added right back
1139 + // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1006 1140 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1007 1141 deactivate_plugins( $plugins, false, false );
1008 1142 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1009 1143
@@ -1074,63 +1208,69 @@
1074 1208 *
1075 1209 * @return void
1076 1210 */
1077 1211 public static function add_admin_footer_links() {
1078 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1079 -
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();
1084 -
1085 - // Exit if any of the above conditions are met
1086 - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) {
1087 - return;
1212 + if ( self::should_show_footer_links() ) {
1213 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1088 1214 }
1089 -
1090 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1091 1215 }
1092 1216
1093 1217 /**
1094 - * @deprecated 3.0.04
1218 + * Check if the footer links should be shown.
1095 1219 *
1096 - * @codeCoverageIgnore
1220 + * @since 6.7
1097 1221 *
1098 - * @return void
1222 + * @return bool
1099 1223 */
1100 - public static function activation_install() {
1101 - FrmDeprecated::activation_install();
1102 - }
1224 + private static function should_show_footer_links() {
1225 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1226 + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1227 + $show_footer_links = $is_formidable_page;
1228 + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1229 + $show_footer_links = false;
1230 + }
1103 1231
1104 - /**
1105 - * @deprecated 3.0
1106 - * @codeCoverageIgnore
1107 - */
1108 - public static function page_route( $content ) {
1109 - return FrmDeprecated::page_route( $content );
1232 + /**
1233 + * Filter whether to show the Formidable footer links.
1234 + *
1235 + * @since 6.7
1236 + *
1237 + * @param bool $show_footer_links
1238 + * @return bool
1239 + */
1240 + return apply_filters( 'frm_show_footer_links', $show_footer_links );
1110 1241 }
1111 1242
1112 1243 /**
1113 - * Include icons on page for Embed Form modal.
1244 + * Show an error modal and terminate the script execution.
1114 1245 *
1115 - * @since 5.2
1246 + * @since 6.7
1116 1247 *
1248 + * @param array $error_args Arguments that control the behavior of the error modal.
1249 + *
1117 1250 * @return void
1118 1251 */
1119 - public static function include_embed_form_icons() {
1120 - _deprecated_function( __METHOD__, '5.3' );
1121 - }
1252 + public static function show_error_modal( $error_args ) {
1253 + $defaults = array(
1254 + 'title' => '',
1255 + 'body' => '',
1256 + 'cancel_url' => '',
1257 + 'cancel_classes' => '',
1258 + 'continue_url' => '',
1259 + 'continue_classes' => '',
1260 + 'icon' => 'frm_lock_simple',
1261 + );
1122 1262
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 );
1263 + $error_args = wp_parse_args( $error_args, $defaults );
1264 + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1265 + $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1266 + }
1267 +
1268 + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) {
1269 + $error_args['continue_text'] = __( 'Continue', 'formidable' );
1270 + }
1271 +
1272 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1133 1273 }
1134 1274
1135 1275 /**
1136 1276 * Handles Floating Links' scripts and styles enqueueing.
@@ -1154,11 +1294,100 @@
1154 1294 wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1155 1295
1156 1296 // Enqueue the config script.
1157 1297 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-' );
1298 +
1299 + if ( function_exists( 'wp_set_script_translations' ) ) {
1300 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1301 + }
1302 +
1159 1303 $floating_links_data = array(
1160 1304 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1161 1305 );
1162 1306 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1307 +
1308 + /**
1309 + * Prompt Pro to load additional floating links scripts.
1310 + * This is used to include images in the Inbox SlideIn when Pro is active.
1311 + *
1312 + * @since 6.8.4
1313 + */
1314 + do_action( 'frm_enqueue_floating_links' );
1315 + }
1316 +
1317 + /**
1318 + * @deprecated 3.0 This is still referenced in https://formidableforms.com/knowledgebase/php-examples/ as of May 8, 2024.
1319 + * @codeCoverageIgnore
1320 + */
1321 + public static function page_route( $content ) {
1322 + return FrmDeprecated::page_route( $content );
1323 + }
1324 +
1325 + /**
1326 + * Check if we are in our admin pages.
1327 + *
1328 + * @return bool
1329 + */
1330 + private static function in_our_pages() {
1331 + global $current_screen;
1332 + return FrmAppHelper::is_formidable_admin() || ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type );
1333 + }
1334 +
1335 + /**
1336 + * Hide all third-parties admin notices only in our admin pages.
1337 + *
1338 + * @return void
1339 + */
1340 + public static function filter_admin_notices() {
1341 + if ( ! self::in_our_pages() ) {
1342 + return;
1343 + }
1344 +
1345 + $actions = array(
1346 + 'admin_notices',
1347 + 'network_admin_notices',
1348 + 'user_admin_notices',
1349 + 'all_admin_notices',
1350 + );
1351 +
1352 + global $wp_filter;
1353 +
1354 + foreach ( $actions as $action ) {
1355 + if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1356 + continue;
1357 + }
1358 + foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1359 + foreach ( $callbacks as $callback_name => $callback ) {
1360 + if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1361 + continue;
1362 + }
1363 + unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1364 + }
1365 + }
1366 + }
1367 + }
1368 +
1369 + /**
1370 + * Validate that the callback name is ours not from third-party.
1371 + *
1372 + * @param string $callback_name WordPress callback name.
1373 + *
1374 + * @return bool
1375 + */
1376 + private static function is_our_callback_string( $callback_name ) {
1377 + return 0 === stripos( $callback_name, 'frm' );
1378 + }
1379 +
1380 + /**
1381 + * Validate that the callback array is ours not from third-party.
1382 + *
1383 + * @param array $callback WordPress callback array.
1384 + *
1385 + * @return bool
1386 + */
1387 + private static function is_our_callback_array( $callback ) {
1388 + return ! empty( $callback['function'] ) &&
1389 + is_array( $callback['function'] ) &&
1390 + ! empty( $callback['function'][0] ) &&
1391 + self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1163 1392 }
1164 1393 }