PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.12.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.12.1
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 +91 -447 6.266.12.1 View file →
@@ -9,19 +9,13 @@
9 9 * @return void
10 10 */
11 11 public static function menu() {
12 12 FrmAppHelper::maybe_add_permissions();
13 -
14 13 if ( ! current_user_can( 'frm_view_forms' ) ) {
15 14 return;
16 15 }
17 16
18 17 $menu_name = FrmAppHelper::get_menu_name();
19 -
20 - if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
21 - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() );
22 - }
23 -
24 18 add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
25 19 }
26 20
27 21 /**
@@ -32,10 +26,8 @@
32 26 }
33 27
34 28 /**
35 29 * @since 3.05
36 - *
37 - * @return string
38 30 */
39 31 private static function menu_icon() {
40 32 $icon = FrmAppHelper::svg_logo(
41 33 array(
@@ -49,12 +41,8 @@
49 41 }
50 42
51 43 /**
52 44 * @since 3.0
53 - *
54 - * @param string $classes
55 - *
56 - * @return string
57 45 */
58 46 public static function add_admin_class( $classes ) {
59 47 if ( self::is_white_page() ) {
60 48 $classes .= ' frm-white-body ';
@@ -60,12 +48,10 @@
60 48 $classes .= ' frm-white-body ';
61 49 $classes .= self::get_os();
62 50
63 51 $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) );
64 -
65 52 if ( empty( $page ) || $page === 'formidable' ) {
66 53 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
67 -
68 54 if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) {
69 55 $page .= $action;
70 56 } else {
71 57 $page = $action;
@@ -70,9 +56,8 @@
70 56 } else {
71 57 $page = $action;
72 58 }
73 59 }
74 -
75 60 if ( ! empty( $page ) ) {
76 61 $classes .= ' frm-admin-page-' . $page;
77 62 }
78 63 }
@@ -83,9 +68,8 @@
83 68
84 69 if ( FrmAppHelper::is_full_screen() ) {
85 70 $full_screen_on = self::get_full_screen_setting();
86 71 $add_class = '';
87 -
88 72 if ( $full_screen_on ) {
89 73 $add_class = ' frm-full-screen is-fullscreen-mode';
90 74
91 75 // Load the CSS for .is-fullscreen-mode.
@@ -90,9 +74,8 @@
90 74
91 75 // Load the CSS for .is-fullscreen-mode.
92 76 wp_enqueue_style( 'wp-edit-post' );
93 77 }
94 -
95 78 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
96 79 }
97 80
98 81 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -117,9 +100,8 @@
117 100 global $wpdb;
118 101 $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';
119 102
120 103 $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
121 -
122 104 if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) {
123 105 return $prefs['core/edit-post']['fullscreenMode'];
124 106 }
125 107
@@ -133,9 +115,8 @@
133 115 */
134 116 private static function get_os() {
135 117 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
136 118 $os = '';
137 -
138 119 if ( strpos( $agent, 'mac' ) !== false ) {
139 120 $os = ' osx';
140 121 } elseif ( strpos( $agent, 'linux' ) !== false ) {
141 122 $os = ' linux';
@@ -146,10 +127,8 @@
146 127 }
147 128
148 129 /**
149 130 * @since 3.0
150 - *
151 - * @return bool
152 131 */
153 132 private static function is_white_page() {
154 133 $white_pages = array(
155 134 'formidable',
@@ -155,8 +134,9 @@
155 134 'formidable',
156 135 'formidable-entries',
157 136 'formidable-views',
158 137 'formidable-views-editor',
138 + 'formidable-pro-upgrade',
159 139 'formidable-addons',
160 140 'formidable-import',
161 141 'formidable-settings',
162 142 'formidable-styles',
@@ -201,9 +181,8 @@
201 181 private static function is_grey_page() {
202 182 $grey_pages = array(
203 183 'formidable-applications',
204 184 'formidable-dashboard',
205 - 'formidable-views',
206 185 );
207 186
208 187 $is_grey_page = self::is_page_in_list( $grey_pages );
209 188
@@ -212,9 +191,8 @@
212 191 *
213 192 * @since 6.8
214 193 *
215 194 * @param bool $is_grey_page
216 - *
217 195 * @return bool
218 196 */
219 197 return apply_filters( 'frm_is_grey_page', $is_grey_page );
220 198 }
@@ -222,9 +200,8 @@
222 200 /**
223 201 * @since 6.8
224 202 *
225 203 * @param array $pages A list of page names to check.
226 - *
227 204 * @return bool
228 205 */
229 206 private static function is_page_in_list( $pages ) {
230 207 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -248,15 +225,13 @@
248 225 * @return void
249 226 */
250 227 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
251 228 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
252 -
253 229 if ( empty( $show_nav ) || ! $form ) {
254 230 return;
255 231 }
256 232
257 233 FrmForm::maybe_get_form( $form );
258 -
259 234 if ( ! is_object( $form ) ) {
260 235 return;
261 236 }
262 237
@@ -283,9 +258,8 @@
283 258 }
284 259
285 260 /**
286 261 * @param object $form
287 - *
288 262 * @return array
289 263 */
290 264 private static function get_form_nav_items( $form ) {
291 265 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
@@ -357,13 +331,10 @@
357 331
358 332 return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
359 333 }
360 334
335 + // Adds a settings link to the plugins page
361 336 /**
362 - * Adds a settings link to the plugins page
363 - *
364 - * @param array $links
365 - *
366 337 * @return array
367 338 */
368 339 public static function settings_link( $links ) {
369 340 $settings = array();
@@ -368,29 +339,12 @@
368 339 public static function settings_link( $links ) {
369 340 $settings = array();
370 341
371 342 if ( ! FrmAppHelper::pro_is_installed() ) {
372 - if ( FrmAddonsController::is_license_expired() ) {
373 - $label = __( 'Renew', 'formidable' );
374 - } else {
375 - $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' );
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>';
345 + }
376 346
377 - if ( ! $label ) {
378 - $label = __( 'Upgrade to Pro', 'formidable' );
379 - }
380 - }
381 -
382 - $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' );
383 -
384 - if ( $upgrade_link ) {
385 - $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) );
386 - } else {
387 - $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' );
388 - }
389 -
390 - $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
391 - }//end if
392 -
393 347 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
394 348
395 349 return array_merge( $settings, $links );
396 350 }
@@ -399,9 +353,9 @@
399 353 * @return void
400 354 */
401 355 public static function pro_get_started_headline() {
402 356 self::review_request();
403 - FrmAppHelper::min_pro_version_notice( '6.20' );
357 + FrmAppHelper::min_pro_version_notice( '6.0' );
404 358 }
405 359
406 360 /**
407 361 * Add admin notices as needed for reviews
@@ -476,9 +430,8 @@
476 430 *
477 431 * @param string $form_key
478 432 * @param string $title
479 433 * @param string $description
480 - *
481 434 * @return void
482 435 */
483 436 public static function api_email_form( $form_key, $title = '', $description = '' ) {
484 437 $user = wp_get_current_user();
@@ -511,9 +464,10 @@
511 464 * @return void
512 465 */
513 466 public static function remove_upsells() {
514 467 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
515 - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
468 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
469 + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
516 470 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
517 471 }
518 472
519 473 /**
@@ -535,9 +489,8 @@
535 489 /**
536 490 * Check if the database is outdated
537 491 *
538 492 * @since 2.0.1
539 - *
540 493 * @return bool
541 494 */
542 495 public static function needs_update() {
543 496 $needs_upgrade = self::compare_for_update(
@@ -560,9 +513,8 @@
560 513 *
561 514 * @since 3.0.04
562 515 *
563 516 * @param array $atts
564 - *
565 517 * @return bool
566 518 */
567 519 public static function compare_for_update( $atts ) {
568 520 $db_version = get_option( $atts['option'] );
@@ -594,34 +546,13 @@
594 546 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
595 547 FrmFormsController::duplicate();
596 548 }
597 549
598 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
599 - self::add_missing_tables();
600 - }
601 -
602 550 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
603 551 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
604 552 FrmStylesController::save_style();
605 553 }
606 554
607 - if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
608 - $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' );
609 - $utm = array(
610 - 'campaign' => 'upgrade',
611 - 'content' => 'submenu-upgrade',
612 - );
613 -
614 - if ( $redirect ) {
615 - $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm );
616 - } else {
617 - $redirect = FrmAppHelper::admin_upgrade_link( $utm );
618 - }
619 -
620 - wp_redirect( $redirect );
621 - die();
622 - }
623 -
624 555 // Register personal data hooks.
625 556 new FrmPersonalData();
626 557
627 558 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
@@ -639,9 +570,8 @@
639 570 // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
640 571 // This provides backward compatibility for old addons that use legacy modal templates.
641 572 $action = FrmAppHelper::get_param( 'frm_action' );
642 573 $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
643 -
644 574 if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
645 575 $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
646 576 $url_param = $application_id ? '&applicationId=' . $application_id : '';
647 577
@@ -650,8 +580,10 @@
650 580 }
651 581
652 582 FrmInbox::maybe_disable_screen_options();
653 583 }
584 +
585 + self::maybe_add_ip_warning();
654 586 }
655 587
656 588 /**
657 589 * Get the current page and check for a possible function to trigger.
@@ -662,9 +594,8 @@
662 594 * @return void
663 595 */
664 596 private static function trigger_page_load_hooks() {
665 597 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
666 -
667 598 if ( strpos( $page, 'formidable-' ) !== 0 ) {
668 599 // Only trigger hooks on Formidable pages.
669 600 return;
670 601 }
@@ -671,9 +602,8 @@
671 602
672 603 $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
673 604 $page = str_replace( ' ', '', ucwords( $page ) );
674 605 $class = 'Frm' . $page . 'Controller';
675 -
676 606 if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
677 607 call_user_func( array( $class, 'load_page' ) );
678 608 }
679 609 }
@@ -678,10 +608,69 @@
678 608 }
679 609 }
680 610
681 611 /**
612 + * Show a warning for the IP address setting if it hasn't been set.
613 + *
614 + * @since 6.1
615 + *
682 616 * @return void
683 617 */
618 + private static function maybe_add_ip_warning() {
619 + $settings = FrmAppHelper::get_settings();
620 + if ( false !== $settings->custom_header_ip ) {
621 + // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
622 + return;
623 + }
624 +
625 + if ( ! self::is_behind_proxy() ) {
626 + // This message is only applicable when using a reverse proxy.
627 + return;
628 + }
629 +
630 + if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
631 + // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
632 + return;
633 + }
634 +
635 + $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
636 + $message = sprintf(
637 + // Translators: 1: Global Settings Link
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' ),
639 + '<a href="' . esc_url( $global_settings_link ) . '">' . __( 'Global Settings', 'formidable' ) . '</a>'
640 + );
641 + $option_name = 'frm_dismiss_ip_address_notice';
642 + FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
643 + }
644 +
645 + /**
646 + * Check if any reverse proxy headers are set.
647 + *
648 + * @since 6.1
649 + *
650 + * @return bool
651 + */
652 + private static function is_behind_proxy() {
653 + $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
654 + foreach ( $custom_headers as $header ) {
655 + if ( 'REMOTE_ADDR' === $header ) {
656 + // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
657 + continue;
658 + }
659 +
660 + $ip = trim( FrmAppHelper::get_server_value( $header ) );
661 + // Return true for anything that isn't empty but ignoring values like ::1.
662 + if ( $ip && 0 !== strpos( $ip, '::' ) ) {
663 + return true;
664 + }
665 + }
666 +
667 + return false;
668 + }
669 +
670 + /**
671 + * @return void
672 + */
684 673 public static function admin_js() {
685 674 $plugin_url = FrmAppHelper::plugin_url();
686 675 $version = FrmAppHelper::plugin_version();
687 676
@@ -703,16 +692,11 @@
703 692 wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version );
704 693
705 694 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
706 695 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
707 - self::register_popper2();
708 - wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '5.0.2', true );
709 -
710 - $settings_js_vars = array(
711 - 'currencies' => FrmCurrencyHelper::get_currencies(),
712 - );
696 + self::register_popper1();
697 + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
713 698 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
714 - wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars );
715 699
716 700 if ( self::should_show_floating_links() ) {
717 701 self::enqueue_floating_links( $plugin_url, $version );
718 702 }
@@ -743,9 +727,9 @@
743 727 // For the existing page dropdown in the Form embed modal.
744 728 wp_enqueue_script( 'jquery-ui-autocomplete' );
745 729 }
746 730
747 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true );
731 + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
748 732
749 733 if ( ! class_exists( 'FrmTransHooksController', false ) ) {
750 734 /**
751 735 * Gateway fields are included for add-on compatibility but we do not want it to be visible.
@@ -760,24 +744,19 @@
760 744 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
761 745 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
762 746
763 747 global $pagenow;
764 -
765 748 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
766 - self::enqueue_global_settings_scripts( $page );
767 749
768 750 wp_enqueue_script( 'admin-widgets' );
769 751 wp_enqueue_style( 'widgets' );
770 - self::maybe_deregister_popper1();
752 + self::maybe_deregister_popper2();
771 753 wp_enqueue_script( 'formidable_admin' );
772 - wp_set_script_translations( 'formidable_admin', 'formidable' );
773 754 wp_enqueue_script( 'formidable_embed' );
774 - wp_set_script_translations( 'formidable_embed', 'formidable' );
775 755 FrmAppHelper::localize_script( 'admin' );
776 756
777 757 wp_enqueue_style( 'formidable-animations' );
778 758 wp_enqueue_style( 'formidable-admin' );
779 -
780 759 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
781 760 wp_enqueue_style( 'formidable-grids' );
782 761 self::maybe_enqueue_dropzone_css( $page );
783 762 } else {
@@ -800,13 +779,11 @@
800 779 if ( isset( $_REQUEST['post_type'] ) ) {
801 780 $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) );
802 781 } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
803 782 $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) );
804 -
805 783 if ( ! $post ) {
806 784 return;
807 785 }
808 -
809 786 $post_type = $post->post_type;
810 787 } else {
811 788 return;
812 789 }
@@ -819,55 +796,16 @@
819 796 if ( 'formidable-addons' === $page ) {
820 797 wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
821 798 wp_enqueue_script( 'formidable_addons' );
822 799 }
823 -
824 - self::enqueue_builder_assets( $plugin_url, $version );
825 800 }
826 801
827 802 /**
828 - * Enqueue the Form Builder assets.
829 - *
830 - * @since 6.24
831 - *
832 - * @param string $plugin_url The plugin URL.
833 - * @param string $version The plugin version.
834 - *
835 - * @return void
836 - */
837 - private static function enqueue_builder_assets( $plugin_url, $version ) {
838 - wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version );
839 - wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true );
840 -
841 - if ( ! FrmAppHelper::is_form_builder_page() ) {
842 - return;
843 - }
844 -
845 - wp_enqueue_style( 'formidable-settings-components' );
846 - wp_enqueue_script( 'formidable-settings-components' );
847 - }
848 -
849 - /**
850 - * Enqueues global settings scripts.
851 - *
852 - * @param string $page The `page` param in URL.
853 - *
854 - * @return void
855 - */
856 - private static function enqueue_global_settings_scripts( $page ) {
857 - if ( 'formidable-settings' === $page ) {
858 - wp_enqueue_style( 'wp-color-picker' );
859 - wp_enqueue_script( 'formidable_settings' );
860 - }
861 - }
862 -
863 - /**
864 803 * Avoid loading dropzone CSS on the form list page. It isn't required there.
865 804 *
866 805 * @since 6.11
867 806 *
868 807 * @param string $page
869 - *
870 808 * @return void
871 809 */
872 810 private static function maybe_enqueue_dropzone_css( $page ) {
873 811 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -874,9 +812,8 @@
874 812 return;
875 813 }
876 814
877 815 $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
878 -
879 816 if ( ! $should_avoid_loading_dropzone ) {
880 817 wp_enqueue_style( 'formidable-dropzone' );
881 818 }
882 819 }
@@ -893,21 +830,12 @@
893 830 if ( ! FrmAppHelper::is_formidable_branding() ) {
894 831 return false;
895 832 }
896 833
897 - $should_show = FrmAppHelper::is_formidable_admin() &&
834 + return FrmAppHelper::is_formidable_admin() &&
898 835 ! FrmAppHelper::is_style_editor_page() &&
899 836 ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
900 837 ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
901 -
902 - /**
903 - * Filters whether the floating links should be displayed.
904 - *
905 - * @since 6.25.1
906 - *
907 - * @param bool $should_show Whether the floating links should be shown.
908 - */
909 - return apply_filters( 'frm_should_show_floating_links', $should_show );
910 838 }
911 839
912 840 /**
913 841 * @since 6.3.2
@@ -916,14 +844,8 @@
916 844 */
917 845 public static function admin_enqueue_scripts() {
918 846 self::load_wp_admin_style();
919 847 self::maybe_force_formidable_block_on_gutenberg_page();
920 -
921 - if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) {
922 - wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() );
923 - }
924 -
925 - FrmUsageController::load_scripts();
926 848 }
927 849
928 850 /**
929 851 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -934,9 +856,9 @@
934 856 */
935 857 private static function enqueue_legacy_views_assets() {
936 858 wp_enqueue_style( 'formidable-grids' );
937 859 wp_enqueue_script( 'jquery-ui-draggable' );
938 - self::maybe_deregister_popper1();
860 + self::maybe_deregister_popper2();
939 861 wp_enqueue_script( 'formidable_admin' );
940 862 wp_add_inline_style(
941 863 'formidable-admin',
942 864 '
@@ -959,21 +881,20 @@
959 881 }
960 882 '
961 883 );
962 884 wp_enqueue_style( 'formidable-admin' );
963 - wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() );
964 885 FrmAppHelper::localize_script( 'admin' );
965 886 self::include_info_overlay();
966 887 }
967 888
968 889 /**
969 - * Unregister Popper if the registered version is outdated.
890 + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
970 891 *
971 - * @since 6.26
892 + * @since 5.2.02.01
972 893 *
973 894 * @return void
974 895 */
975 - private static function maybe_deregister_popper1() {
896 + private static function maybe_deregister_popper2() {
976 897 global $wp_scripts;
977 898
978 899 if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) {
979 900 return;
@@ -979,27 +900,26 @@
979 900 return;
980 901 }
981 902
982 903 $popper = $wp_scripts->registered['popper'];
983 -
984 - if ( version_compare( $popper->ver, '2.0', '<' ) ) {
904 + if ( version_compare( $popper->ver, '2.0', '>=' ) ) {
985 905 wp_deregister_script( 'popper' );
986 - self::register_popper2();
906 + self::register_popper1();
987 907 }
988 908 }
989 909
990 910 /**
991 - * Register Popper required for Bootstrap 5.
911 + * Register Popper required for Bootstrap 4.
992 912 *
993 - * @since 6.26
913 + * @since 5.2.02.01
994 914 *
995 915 * @return void
996 916 */
997 - private static function register_popper2() {
917 + private static function register_popper1() {
998 918 if ( ! self::should_register_popper() ) {
999 919 return;
1000 920 }
1001 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true );
921 + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
1002 922 }
1003 923
1004 924 /**
1005 925 * Only register popper on Formidable pages.
@@ -1012,9 +932,8 @@
1012 932 private static function should_register_popper() {
1013 933 global $pagenow;
1014 934
1015 935 $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
1016 -
1017 936 if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
1018 937 return true;
1019 938 }
1020 939
@@ -1019,15 +938,13 @@
1019 938 }
1020 939
1021 940 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1022 941 $is_views_post_type = 'frm_display' === $post_type;
1023 -
1024 942 if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
1025 943 return true;
1026 944 }
1027 945
1028 946 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
1029 -
1030 947 if ( strpos( $page, 'formidable' ) === 0 ) {
1031 948 return true;
1032 949 }
1033 950
@@ -1042,15 +959,13 @@
1042 959 * @return void
1043 960 */
1044 961 private static function maybe_force_formidable_block_on_gutenberg_page() {
1045 962 global $pagenow;
1046 -
1047 963 if ( 'post.php' !== $pagenow ) {
1048 964 return;
1049 965 }
1050 966
1051 967 $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
1052 -
1053 968 if ( ! $form_id ) {
1054 969 return;
1055 970 }
1056 971
@@ -1098,9 +1013,9 @@
1098 1013 public static function create_rest_routes() {
1099 1014 $args = array(
1100 1015 'methods' => 'GET',
1101 1016 'callback' => 'FrmAppController::api_install',
1102 - 'permission_callback' => self::class . '::can_update_db',
1017 + 'permission_callback' => __CLASS__ . '::can_update_db',
1103 1018 );
1104 1019
1105 1020 register_rest_route( 'frm-admin/v1', '/install', $args );
1106 1021
@@ -1117,10 +1032,8 @@
1117 1032 * Make sure the install is only being run when we tell it to.
1118 1033 * We don't want to run manually by people calling the API.
1119 1034 *
1120 1035 * @since 4.06.02
1121 - *
1122 - * @return bool
1123 1036 */
1124 1037 public static function can_update_db() {
1125 1038 return get_transient( 'frm_updating_api' );
1126 1039 }
@@ -1164,9 +1077,8 @@
1164 1077 */
1165 1078 private static function maybe_add_wp_site_health() {
1166 1079 if ( ! class_exists( 'WP_Site_Health' ) ) {
1167 1080 $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
1168 -
1169 1081 if ( file_exists( $wp_site_health_path ) ) {
1170 1082 require_once $wp_site_health_path;
1171 1083 }
1172 1084 }
@@ -1178,12 +1090,10 @@
1178 1090 * @return true
1179 1091 */
1180 1092 public static function api_install() {
1181 1093 delete_transient( 'frm_updating_api' );
1182 -
1183 1094 if ( self::needs_update() ) {
1184 1095 $running = get_option( 'frm_install_running' );
1185 -
1186 1096 if ( false === $running || $running < strtotime( '-5 minutes' ) ) {
1187 1097 update_option( 'frm_install_running', time(), 'no' );
1188 1098 self::install();
1189 1099 delete_option( 'frm_install_running' );
@@ -1233,13 +1143,8 @@
1233 1143
1234 1144 wp_die();
1235 1145 }
1236 1146
1237 - /**
1238 - * @param array $tables
1239 - *
1240 - * @return array
1241 - */
1242 1147 public static function drop_tables( $tables ) {
1243 1148 global $wpdb;
1244 1149 $tables[] = $wpdb->prefix . 'frm_fields';
1245 1150 $tables[] = $wpdb->prefix . 'frm_forms';
@@ -1287,13 +1192,8 @@
1287 1192
1288 1193 FrmTransLiteAppController::maybe_schedule_cron();
1289 1194 }
1290 1195
1291 - /**
1292 - * @param string $text
1293 - *
1294 - * @return string
1295 - */
1296 1196 public static function set_footer_text( $text ) {
1297 1197 if ( FrmAppHelper::is_formidable_admin() ) {
1298 1198 $text = '';
1299 1199 }
@@ -1308,10 +1208,8 @@
1308 1208 *
1309 1209 * @return void
1310 1210 */
1311 1211 public static function add_admin_footer_links() {
1312 - FrmFormsController::include_device_too_small_message();
1313 -
1314 1212 if ( self::should_show_footer_links() ) {
1315 1213 include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1316 1214 }
1317 1215 }
@@ -1326,9 +1224,8 @@
1326 1224 private static function should_show_footer_links() {
1327 1225 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1328 1226 $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1329 1227 $show_footer_links = $is_formidable_page;
1330 -
1331 1228 if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1332 1229 $show_footer_links = false;
1333 1230 }
1334 1231
@@ -1337,9 +1234,8 @@
1337 1234 *
1338 1235 * @since 6.7
1339 1236 *
1340 1237 * @param bool $show_footer_links
1341 - *
1342 1238 * @return bool
1343 1239 */
1344 1240 return apply_filters( 'frm_show_footer_links', $show_footer_links );
1345 1241 }
@@ -1353,10 +1249,8 @@
1353 1249 *
1354 1250 * @return void
1355 1251 */
1356 1252 public static function show_error_modal( $error_args ) {
1357 - add_filter( 'frm_show_footer_links', '__return_false' );
1358 -
1359 1253 $defaults = array(
1360 1254 'title' => '',
1361 1255 'body' => '',
1362 1256 'cancel_url' => '',
@@ -1366,9 +1260,8 @@
1366 1260 'icon' => 'frm_lock_simple',
1367 1261 );
1368 1262
1369 1263 $error_args = wp_parse_args( $error_args, $defaults );
1370 -
1371 1264 if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1372 1265 $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1373 1266 }
1374 1267
@@ -1385,9 +1278,8 @@
1385 1278 * @since 6.4
1386 1279 *
1387 1280 * @param string $plugin_url URL of the plugin.
1388 1281 * @param string $version Current version of the plugin.
1389 - *
1390 1282 * @return void
1391 1283 */
1392 1284 private static function enqueue_floating_links( $plugin_url, $version ) {
1393 1285 if ( ! $plugin_url || ! $version ) {
@@ -1398,9 +1290,9 @@
1398 1290 // Enqueue the Floating Links styles.
1399 1291 wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1400 1292
1401 1293 // Enqueue the Floating Links script.
1402 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1294 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1403 1295
1404 1296 // Enqueue the config script.
1405 1297 wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1406 1298
@@ -1407,20 +1299,10 @@
1407 1299 if ( function_exists( 'wp_set_script_translations' ) ) {
1408 1300 wp_set_script_translations( 's11-floating-links-config', 's11-' );
1409 1301 }
1410 1302
1411 - $upgrade_utm = array(
1412 - 'campaign' => 'floating-links',
1413 - 'content' => 'floating-links-upgrade',
1414 - );
1415 - $docs_utm = array(
1416 - 'campaign' => 'floating-links',
1417 - 'content' => 'floating-links-docs',
1418 - );
1419 1303 $floating_links_data = array(
1420 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1421 - 'upgradeUrl' => FrmAppHelper::admin_upgrade_link( $upgrade_utm ),
1422 - 'documentationUrl' => FrmAppHelper::admin_upgrade_link( $docs_utm, 'knowledgebase/' ),
1304 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1423 1305 );
1424 1306 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1425 1307
1426 1308 /**
@@ -1432,249 +1314,11 @@
1432 1314 do_action( 'frm_enqueue_floating_links' );
1433 1315 }
1434 1316
1435 1317 /**
1436 - * Check if we are in our admin pages.
1437 - *
1438 - * @return bool
1318 + * @deprecated 3.0 This is still referenced in https://formidableforms.com/knowledgebase/php-examples/ as of May 8, 2024.
1319 + * @codeCoverageIgnore
1439 1320 */
1440 - private static function in_our_pages() {
1441 - global $current_screen, $pagenow;
1442 -
1443 - if ( FrmAppHelper::is_formidable_admin() ) {
1444 - return true;
1445 - }
1446 -
1447 - if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1448 - return true;
1449 - }
1450 -
1451 - if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) {
1452 - return true;
1453 - }
1454 -
1455 - return false;
1456 - }
1457 -
1458 - /**
1459 - * Handles actions related to the current screen.
1460 - *
1461 - * @since 6.19
1462 - *
1463 - * @return void
1464 - */
1465 - public static function handle_current_screen() {
1466 - if ( ! self::in_our_pages() ) {
1467 - return;
1468 - }
1469 -
1470 - self::filter_admin_notices();
1471 - self::remember_custom_sort();
1472 - }
1473 -
1474 - /**
1475 - * Hide all third-parties admin notices only in our admin pages.
1476 - *
1477 - * @return void
1478 - */
1479 - public static function filter_admin_notices() {
1480 - $actions = array(
1481 - 'admin_notices',
1482 - 'network_admin_notices',
1483 - 'user_admin_notices',
1484 - 'all_admin_notices',
1485 - );
1486 -
1487 - global $wp_filter;
1488 -
1489 - foreach ( $actions as $action ) {
1490 - if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1491 - continue;
1492 - }
1493 -
1494 - foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1495 - foreach ( $callbacks as $callback_name => $callback ) {
1496 - if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1497 - continue;
1498 - }
1499 - unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1500 - }
1501 - }
1502 - }
1503 - }
1504 -
1505 - /**
1506 - * Remembers and applies user-specific sorting preferences.
1507 - *
1508 - * @return void
1509 - */
1510 - private static function remember_custom_sort() {
1511 - $meta_key = self::get_sort_pref_user_meta_key();
1512 -
1513 - if ( false === $meta_key ) {
1514 - return;
1515 - }
1516 -
1517 - $is_form_list = FrmAppHelper::is_admin_list_page();
1518 - $is_entry_list = FrmAppHelper::is_admin_list_page( 'formidable-entries' );
1519 -
1520 - if ( ! $is_form_list && ! $is_entry_list ) {
1521 - return;
1522 - }
1523 -
1524 - $orderby = FrmAppHelper::get_param( 'orderby' );
1525 -
1526 - if ( ! $orderby ) {
1527 - return;
1528 - }
1529 -
1530 - $user_id = get_current_user_id();
1531 - $order = FrmAppHelper::get_param( 'order' );
1532 - $new_sort = array(
1533 - 'orderby' => $orderby,
1534 - 'order' => $order,
1535 - );
1536 - $previous_meta = get_user_meta( $user_id, $meta_key, true );
1537 - $current_sort = $previous_meta;
1538 - $form_id = $is_entry_list ? FrmAppHelper::simple_get( 'form', 'absint' ) : 0;
1539 -
1540 - if ( is_array( $current_sort ) && $form_id && is_int( $form_id ) && isset( $current_sort[ $form_id ] ) ) {
1541 - $current_sort = $current_sort[ $form_id ];
1542 - }
1543 -
1544 - if ( $new_sort !== $current_sort ) {
1545 - $new_meta = $new_sort;
1546 -
1547 - if ( $is_entry_list && $form_id && is_int( $form_id ) ) {
1548 - // Index meta by form ID.
1549 - $temp_meta = is_array( $previous_meta ) ? $previous_meta : array();
1550 - $temp_meta[ $form_id ] = $new_meta;
1551 - $new_meta = $temp_meta;
1552 - unset( $temp_meta );
1553 - }
1554 -
1555 - update_user_meta( $user_id, $meta_key, $new_meta );
1556 - }
1557 - }
1558 -
1559 - /**
1560 - * Retrieve and apply any saved sorting preferences for the current screen.
1561 - *
1562 - * @since 6.19
1563 - *
1564 - * @param string &$orderby Reference to the current 'orderby' parameter.
1565 - * @param string &$order Reference to the current 'order' parameter.
1566 - *
1567 - * @return void
1568 - */
1569 - public static function apply_saved_sort_preference( &$orderby, &$order ) {
1570 - $meta_key = self::get_sort_pref_user_meta_key();
1571 -
1572 - if ( false === $meta_key ) {
1573 - return;
1574 - }
1575 -
1576 - $user_id = get_current_user_id();
1577 - $preferred_list_sort = get_user_meta( $user_id, $meta_key, true );
1578 - $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
1579 -
1580 - if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) {
1581 - $preferred_list_sort = $preferred_list_sort[ $form_id ];
1582 - }
1583 -
1584 - if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) {
1585 - $orderby = $preferred_list_sort['orderby'];
1586 -
1587 - if ( ! empty( $preferred_list_sort['order'] ) ) {
1588 - $order = $preferred_list_sort['order'];
1589 - }
1590 - }
1591 - }
1592 -
1593 - /**
1594 - * Get a simple user meta key that only includes the screen ID.
1595 - *
1596 - * @since 6.25.1
1597 - *
1598 - * @return false|string
1599 - */
1600 - private static function get_sort_pref_user_meta_key() {
1601 - if ( ! function_exists( 'get_current_screen' ) ) {
1602 - return false;
1603 - }
1604 -
1605 - $screen = get_current_screen();
1606 - return $screen ? 'frm_preferred_list_sort_' . $screen->id : false;
1607 - }
1608 -
1609 - /**
1610 - * Validate that the callback name is ours not from third-party.
1611 - *
1612 - * @param string $callback_name WordPress callback name.
1613 - *
1614 - * @return bool
1615 - */
1616 - private static function is_our_callback_string( $callback_name ) {
1617 - return 0 === stripos( $callback_name, 'frm' );
1618 - }
1619 -
1620 - /**
1621 - * Validate that the callback array is ours not from third-party.
1622 - *
1623 - * @param array $callback WordPress callback array.
1624 - *
1625 - * @return bool
1626 - */
1627 - private static function is_our_callback_array( $callback ) {
1628 - return ! empty( $callback['function'] ) &&
1629 - is_array( $callback['function'] ) &&
1630 - ! empty( $callback['function'][0] ) &&
1631 - self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1632 - }
1633 -
1634 - /**
1635 - * In some cases, the DB tables may fail to install.
1636 - * This function tries to add them again when the user clicks the link to try again
1637 - * from the given inbox notice.
1638 - *
1639 - * @since 6.19
1640 - */
1641 - private static function add_missing_tables() {
1642 - FrmAppHelper::permission_check( 'frm_view_forms' );
1643 -
1644 - $inbox = new FrmInbox();
1645 - $error = $inbox->check_for_error();
1646 -
1647 - if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) {
1648 - // Confirm the inbox item with this CTA exists.
1649 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1650 - exit;
1651 - }
1652 -
1653 - global $wpdb;
1654 - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) );
1655 -
1656 - if ( $exists ) {
1657 - // Exit early if the table already exists.
1658 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1659 - exit;
1660 - }
1661 -
1662 - delete_option( 'frm_db_version' );
1663 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1664 - exit;
1665 - }
1666 -
1667 - /**
1668 - * Handles the small screen proceed action.
1669 - *
1670 - * @since 6.21
1671 - *
1672 - * @return void
1673 - */
1674 - public static function small_screen_proceed() {
1675 - FrmAppHelper::permission_check( 'frm_view_forms' );
1676 - check_ajax_referer( 'frm_ajax', 'nonce' );
1677 - update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true );
1678 - wp_send_json_success();
1321 + public static function page_route( $content ) {
1322 + return FrmDeprecated::page_route( $content );
1679 1323 }
1680 1324 }