PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.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 +124 -375 6.266.16.1 View file →
@@ -9,20 +9,16 @@
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();
18 + add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
19 19
20 - if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
21 - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() );
22 - }
23 -
24 - add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
20 + self::maybe_add_black_friday_submenu_item();
25 21 }
26 22
27 23 /**
28 24 * @return int
@@ -32,10 +28,8 @@
32 28 }
33 29
34 30 /**
35 31 * @since 3.05
36 - *
37 - * @return string
38 32 */
39 33 private static function menu_icon() {
40 34 $icon = FrmAppHelper::svg_logo(
41 35 array(
@@ -48,14 +42,86 @@
48 42 return apply_filters( 'frm_icon', $icon );
49 43 }
50 44
51 45 /**
52 - * @since 3.0
46 + * @since 6.16
53 47 *
54 - * @param string $classes
48 + * @return void
49 + */
50 + private static function maybe_add_black_friday_submenu_item() {
51 + if ( ! current_user_can( 'frm_change_settings' ) ) {
52 + return;
53 + }
54 +
55 + $is_black_friday = self::is_black_friday();
56 + $is_cyber_monday = self::is_cyber_monday();
57 +
58 + if ( ! $is_black_friday && ! $is_cyber_monday ) {
59 + return;
60 + }
61 +
62 + $black_friday_menu_label = $is_black_friday ? __( 'Black Friday!', 'formidable' ) : __( 'Cyber Monday!', 'formidable' );
63 + $black_friday_menu_label = '<span class="frm-orange-text">' . esc_html( $black_friday_menu_label ) . '</span>';
64 +
65 + add_action(
66 + 'admin_menu',
67 + function () use ( $black_friday_menu_label ) {
68 + add_submenu_page(
69 + 'formidable',
70 + 'Formidable',
71 + $black_friday_menu_label,
72 + 'frm_change_settings',
73 + 'formidable-black-friday',
74 + function () {
75 + // This function should do nothing. The redirect is handled earlier to avoid header conflicts.
76 + }
77 + );
78 + },
79 + 1000
80 + );
81 + }
82 +
83 + /**
84 + * Black Friday sale is from November 25 to 29.
55 85 *
56 - * @return string
86 + * @since 6.16
87 + *
88 + * @return bool
57 89 */
90 + private static function is_black_friday() {
91 + return self::within_sale_date_range( '2024-11-25', '2024-11-29' );
92 + }
93 +
94 + /**
95 + * Cyber Monday sale rules from November 30 to December 4.
96 + *
97 + * @since 6.16
98 + *
99 + * @return bool
100 + */
101 + private static function is_cyber_monday() {
102 + return self::within_sale_date_range( '2024-11-30', '2024-12-04' );
103 + }
104 +
105 + /**
106 + * Check if the current time is within a sale date range.
107 + * Our sales are based on Eastern Time, so we use New York's timezone.
108 + *
109 + * @since 6.16
110 + *
111 + * @param string $from The beginning of the date range. Y-m-d format is expected.
112 + * @param string $to The end of the date range. Y-m-d format is expected.
113 + * @return bool
114 + */
115 + private static function within_sale_date_range( $from, $to ) {
116 + $date = new DateTime( 'now', new DateTimeZone( 'America/New_York' ) );
117 + $today = $date->format( 'Y-m-d' );
118 + return $today >= $from && $today <= $to;
119 + }
120 +
121 + /**
122 + * @since 3.0
123 + */
58 124 public static function add_admin_class( $classes ) {
59 125 if ( self::is_white_page() ) {
60 126 $classes .= ' frm-white-body ';
61 127 $classes .= self::get_os();
@@ -60,12 +126,10 @@
60 126 $classes .= ' frm-white-body ';
61 127 $classes .= self::get_os();
62 128
63 129 $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) );
64 -
65 130 if ( empty( $page ) || $page === 'formidable' ) {
66 131 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
67 -
68 132 if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) {
69 133 $page .= $action;
70 134 } else {
71 135 $page = $action;
@@ -70,9 +134,8 @@
70 134 } else {
71 135 $page = $action;
72 136 }
73 137 }
74 -
75 138 if ( ! empty( $page ) ) {
76 139 $classes .= ' frm-admin-page-' . $page;
77 140 }
78 141 }
@@ -83,9 +146,8 @@
83 146
84 147 if ( FrmAppHelper::is_full_screen() ) {
85 148 $full_screen_on = self::get_full_screen_setting();
86 149 $add_class = '';
87 -
88 150 if ( $full_screen_on ) {
89 151 $add_class = ' frm-full-screen is-fullscreen-mode';
90 152
91 153 // Load the CSS for .is-fullscreen-mode.
@@ -90,9 +152,8 @@
90 152
91 153 // Load the CSS for .is-fullscreen-mode.
92 154 wp_enqueue_style( 'wp-edit-post' );
93 155 }
94 -
95 156 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
96 157 }
97 158
98 159 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -117,9 +178,8 @@
117 178 global $wpdb;
118 179 $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';
119 180
120 181 $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
121 -
122 182 if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) {
123 183 return $prefs['core/edit-post']['fullscreenMode'];
124 184 }
125 185
@@ -133,9 +193,8 @@
133 193 */
134 194 private static function get_os() {
135 195 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
136 196 $os = '';
137 -
138 197 if ( strpos( $agent, 'mac' ) !== false ) {
139 198 $os = ' osx';
140 199 } elseif ( strpos( $agent, 'linux' ) !== false ) {
141 200 $os = ' linux';
@@ -146,10 +205,8 @@
146 205 }
147 206
148 207 /**
149 208 * @since 3.0
150 - *
151 - * @return bool
152 209 */
153 210 private static function is_white_page() {
154 211 $white_pages = array(
155 212 'formidable',
@@ -201,9 +258,8 @@
201 258 private static function is_grey_page() {
202 259 $grey_pages = array(
203 260 'formidable-applications',
204 261 'formidable-dashboard',
205 - 'formidable-views',
206 262 );
207 263
208 264 $is_grey_page = self::is_page_in_list( $grey_pages );
209 265
@@ -212,9 +268,8 @@
212 268 *
213 269 * @since 6.8
214 270 *
215 271 * @param bool $is_grey_page
216 - *
217 272 * @return bool
218 273 */
219 274 return apply_filters( 'frm_is_grey_page', $is_grey_page );
220 275 }
@@ -222,9 +277,8 @@
222 277 /**
223 278 * @since 6.8
224 279 *
225 280 * @param array $pages A list of page names to check.
226 - *
227 281 * @return bool
228 282 */
229 283 private static function is_page_in_list( $pages ) {
230 284 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -248,15 +302,13 @@
248 302 * @return void
249 303 */
250 304 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
251 305 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
252 -
253 306 if ( empty( $show_nav ) || ! $form ) {
254 307 return;
255 308 }
256 309
257 310 FrmForm::maybe_get_form( $form );
258 -
259 311 if ( ! is_object( $form ) ) {
260 312 return;
261 313 }
262 314
@@ -283,9 +335,8 @@
283 335 }
284 336
285 337 /**
286 338 * @param object $form
287 - *
288 339 * @return array
289 340 */
290 341 private static function get_form_nav_items( $form ) {
291 342 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
@@ -357,13 +408,10 @@
357 408
358 409 return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
359 410 }
360 411
412 + // Adds a settings link to the plugins page
361 413 /**
362 - * Adds a settings link to the plugins page
363 - *
364 - * @param array $links
365 - *
366 414 * @return array
367 415 */
368 416 public static function settings_link( $links ) {
369 417 $settings = array();
@@ -368,29 +416,12 @@
368 416 public static function settings_link( $links ) {
369 417 $settings = array();
370 418
371 419 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' );
420 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
421 + $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>';
422 + }
376 423
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 424 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
394 425
395 426 return array_merge( $settings, $links );
396 427 }
@@ -399,9 +430,9 @@
399 430 * @return void
400 431 */
401 432 public static function pro_get_started_headline() {
402 433 self::review_request();
403 - FrmAppHelper::min_pro_version_notice( '6.20' );
434 + FrmAppHelper::min_pro_version_notice( '6.0' );
404 435 }
405 436
406 437 /**
407 438 * Add admin notices as needed for reviews
@@ -476,9 +507,8 @@
476 507 *
477 508 * @param string $form_key
478 509 * @param string $title
479 510 * @param string $description
480 - *
481 511 * @return void
482 512 */
483 513 public static function api_email_form( $form_key, $title = '', $description = '' ) {
484 514 $user = wp_get_current_user();
@@ -511,9 +541,10 @@
511 541 * @return void
512 542 */
513 543 public static function remove_upsells() {
514 544 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
515 - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
545 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
546 + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
516 547 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
517 548 }
518 549
519 550 /**
@@ -535,9 +566,8 @@
535 566 /**
536 567 * Check if the database is outdated
537 568 *
538 569 * @since 2.0.1
539 - *
540 570 * @return bool
541 571 */
542 572 public static function needs_update() {
543 573 $needs_upgrade = self::compare_for_update(
@@ -560,9 +590,8 @@
560 590 *
561 591 * @since 3.0.04
562 592 *
563 593 * @param array $atts
564 - *
565 594 * @return bool
566 595 */
567 596 public static function compare_for_update( $atts ) {
568 597 $db_version = get_option( $atts['option'] );
@@ -594,12 +623,8 @@
594 623 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
595 624 FrmFormsController::duplicate();
596 625 }
597 626
598 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
599 - self::add_missing_tables();
600 - }
601 -
602 627 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
603 628 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
604 629 FrmStylesController::save_style();
605 630 }
@@ -604,21 +629,29 @@
604 629 FrmStylesController::save_style();
605 630 }
606 631
607 632 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',
633 + wp_redirect(
634 + FrmAppHelper::admin_upgrade_link(
635 + array(
636 + 'medium' => 'upgrade',
637 + 'content' => 'submenu-upgrade',
638 + )
639 + )
612 640 );
641 + die();
642 + }
613 643
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 );
644 + if ( 'formidable-black-friday' === FrmAppHelper::get_param( 'page' ) && current_user_can( 'frm_change_settings' ) ) {
645 + wp_redirect(
646 + FrmAppHelper::admin_upgrade_link(
647 + array(
648 + 'medium' => 'black-friday-submenu',
649 + 'content' => self::is_cyber_monday() ? 'cyber-monday-submenu' : 'black-friday-submenu',
650 + ),
651 + 'black-friday'
652 + )
653 + );
621 654 die();
622 655 }
623 656
624 657 // Register personal data hooks.
@@ -639,9 +672,8 @@
639 672 // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
640 673 // This provides backward compatibility for old addons that use legacy modal templates.
641 674 $action = FrmAppHelper::get_param( 'frm_action' );
642 675 $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
643 -
644 676 if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
645 677 $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
646 678 $url_param = $application_id ? '&applicationId=' . $application_id : '';
647 679
@@ -662,9 +694,8 @@
662 694 * @return void
663 695 */
664 696 private static function trigger_page_load_hooks() {
665 697 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
666 -
667 698 if ( strpos( $page, 'formidable-' ) !== 0 ) {
668 699 // Only trigger hooks on Formidable pages.
669 700 return;
670 701 }
@@ -671,9 +702,8 @@
671 702
672 703 $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
673 704 $page = str_replace( ' ', '', ucwords( $page ) );
674 705 $class = 'Frm' . $page . 'Controller';
675 -
676 706 if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
677 707 call_user_func( array( $class, 'load_page' ) );
678 708 }
679 709 }
@@ -703,16 +733,11 @@
703 733 wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version );
704 734
705 735 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
706 736 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 - );
737 + self::register_popper1();
738 + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
713 739 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 740
716 741 if ( self::should_show_floating_links() ) {
717 742 self::enqueue_floating_links( $plugin_url, $version );
718 743 }
@@ -743,9 +768,9 @@
743 768 // For the existing page dropdown in the Form embed modal.
744 769 wp_enqueue_script( 'jquery-ui-autocomplete' );
745 770 }
746 771
747 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true );
772 + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
748 773
749 774 if ( ! class_exists( 'FrmTransHooksController', false ) ) {
750 775 /**
751 776 * Gateway fields are included for add-on compatibility but we do not want it to be visible.
@@ -760,15 +785,13 @@
760 785 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
761 786 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
762 787
763 788 global $pagenow;
764 -
765 789 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
766 - self::enqueue_global_settings_scripts( $page );
767 790
768 791 wp_enqueue_script( 'admin-widgets' );
769 792 wp_enqueue_style( 'widgets' );
770 - self::maybe_deregister_popper1();
793 + self::maybe_deregister_popper2();
771 794 wp_enqueue_script( 'formidable_admin' );
772 795 wp_set_script_translations( 'formidable_admin', 'formidable' );
773 796 wp_enqueue_script( 'formidable_embed' );
774 797 wp_set_script_translations( 'formidable_embed', 'formidable' );
@@ -775,9 +798,8 @@
775 798 FrmAppHelper::localize_script( 'admin' );
776 799
777 800 wp_enqueue_style( 'formidable-animations' );
778 801 wp_enqueue_style( 'formidable-admin' );
779 -
780 802 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
781 803 wp_enqueue_style( 'formidable-grids' );
782 804 self::maybe_enqueue_dropzone_css( $page );
783 805 } else {
@@ -800,13 +822,11 @@
800 822 if ( isset( $_REQUEST['post_type'] ) ) {
801 823 $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) );
802 824 } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
803 825 $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) );
804 -
805 826 if ( ! $post ) {
806 827 return;
807 828 }
808 -
809 829 $post_type = $post->post_type;
810 830 } else {
811 831 return;
812 832 }
@@ -819,55 +839,16 @@
819 839 if ( 'formidable-addons' === $page ) {
820 840 wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
821 841 wp_enqueue_script( 'formidable_addons' );
822 842 }
823 -
824 - self::enqueue_builder_assets( $plugin_url, $version );
825 843 }
826 844
827 845 /**
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 846 * Avoid loading dropzone CSS on the form list page. It isn't required there.
865 847 *
866 848 * @since 6.11
867 849 *
868 850 * @param string $page
869 - *
870 851 * @return void
871 852 */
872 853 private static function maybe_enqueue_dropzone_css( $page ) {
873 854 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -874,9 +855,8 @@
874 855 return;
875 856 }
876 857
877 858 $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
878 -
879 859 if ( ! $should_avoid_loading_dropzone ) {
880 860 wp_enqueue_style( 'formidable-dropzone' );
881 861 }
882 862 }
@@ -893,21 +873,12 @@
893 873 if ( ! FrmAppHelper::is_formidable_branding() ) {
894 874 return false;
895 875 }
896 876
897 - $should_show = FrmAppHelper::is_formidable_admin() &&
877 + return FrmAppHelper::is_formidable_admin() &&
898 878 ! FrmAppHelper::is_style_editor_page() &&
899 879 ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
900 880 ! 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 881 }
911 882
912 883 /**
913 884 * @since 6.3.2
@@ -916,13 +887,8 @@
916 887 */
917 888 public static function admin_enqueue_scripts() {
918 889 self::load_wp_admin_style();
919 890 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 891 FrmUsageController::load_scripts();
926 892 }
927 893
928 894 /**
@@ -934,9 +900,9 @@
934 900 */
935 901 private static function enqueue_legacy_views_assets() {
936 902 wp_enqueue_style( 'formidable-grids' );
937 903 wp_enqueue_script( 'jquery-ui-draggable' );
938 - self::maybe_deregister_popper1();
904 + self::maybe_deregister_popper2();
939 905 wp_enqueue_script( 'formidable_admin' );
940 906 wp_add_inline_style(
941 907 'formidable-admin',
942 908 '
@@ -959,21 +925,20 @@
959 925 }
960 926 '
961 927 );
962 928 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 929 FrmAppHelper::localize_script( 'admin' );
965 930 self::include_info_overlay();
966 931 }
967 932
968 933 /**
969 - * Unregister Popper if the registered version is outdated.
934 + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
970 935 *
971 - * @since 6.26
936 + * @since 5.2.02.01
972 937 *
973 938 * @return void
974 939 */
975 - private static function maybe_deregister_popper1() {
940 + private static function maybe_deregister_popper2() {
976 941 global $wp_scripts;
977 942
978 943 if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) {
979 944 return;
@@ -979,27 +944,26 @@
979 944 return;
980 945 }
981 946
982 947 $popper = $wp_scripts->registered['popper'];
983 -
984 - if ( version_compare( $popper->ver, '2.0', '<' ) ) {
948 + if ( version_compare( $popper->ver, '2.0', '>=' ) ) {
985 949 wp_deregister_script( 'popper' );
986 - self::register_popper2();
950 + self::register_popper1();
987 951 }
988 952 }
989 953
990 954 /**
991 - * Register Popper required for Bootstrap 5.
955 + * Register Popper required for Bootstrap 4.
992 956 *
993 - * @since 6.26
957 + * @since 5.2.02.01
994 958 *
995 959 * @return void
996 960 */
997 - private static function register_popper2() {
961 + private static function register_popper1() {
998 962 if ( ! self::should_register_popper() ) {
999 963 return;
1000 964 }
1001 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true );
965 + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
1002 966 }
1003 967
1004 968 /**
1005 969 * Only register popper on Formidable pages.
@@ -1012,9 +976,8 @@
1012 976 private static function should_register_popper() {
1013 977 global $pagenow;
1014 978
1015 979 $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
1016 -
1017 980 if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
1018 981 return true;
1019 982 }
1020 983
@@ -1019,15 +982,13 @@
1019 982 }
1020 983
1021 984 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1022 985 $is_views_post_type = 'frm_display' === $post_type;
1023 -
1024 986 if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
1025 987 return true;
1026 988 }
1027 989
1028 990 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
1029 -
1030 991 if ( strpos( $page, 'formidable' ) === 0 ) {
1031 992 return true;
1032 993 }
1033 994
@@ -1042,15 +1003,13 @@
1042 1003 * @return void
1043 1004 */
1044 1005 private static function maybe_force_formidable_block_on_gutenberg_page() {
1045 1006 global $pagenow;
1046 -
1047 1007 if ( 'post.php' !== $pagenow ) {
1048 1008 return;
1049 1009 }
1050 1010
1051 1011 $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
1052 -
1053 1012 if ( ! $form_id ) {
1054 1013 return;
1055 1014 }
1056 1015
@@ -1098,9 +1057,9 @@
1098 1057 public static function create_rest_routes() {
1099 1058 $args = array(
1100 1059 'methods' => 'GET',
1101 1060 'callback' => 'FrmAppController::api_install',
1102 - 'permission_callback' => self::class . '::can_update_db',
1061 + 'permission_callback' => __CLASS__ . '::can_update_db',
1103 1062 );
1104 1063
1105 1064 register_rest_route( 'frm-admin/v1', '/install', $args );
1106 1065
@@ -1117,10 +1076,8 @@
1117 1076 * Make sure the install is only being run when we tell it to.
1118 1077 * We don't want to run manually by people calling the API.
1119 1078 *
1120 1079 * @since 4.06.02
1121 - *
1122 - * @return bool
1123 1080 */
1124 1081 public static function can_update_db() {
1125 1082 return get_transient( 'frm_updating_api' );
1126 1083 }
@@ -1164,9 +1121,8 @@
1164 1121 */
1165 1122 private static function maybe_add_wp_site_health() {
1166 1123 if ( ! class_exists( 'WP_Site_Health' ) ) {
1167 1124 $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
1168 -
1169 1125 if ( file_exists( $wp_site_health_path ) ) {
1170 1126 require_once $wp_site_health_path;
1171 1127 }
1172 1128 }
@@ -1178,12 +1134,10 @@
1178 1134 * @return true
1179 1135 */
1180 1136 public static function api_install() {
1181 1137 delete_transient( 'frm_updating_api' );
1182 -
1183 1138 if ( self::needs_update() ) {
1184 1139 $running = get_option( 'frm_install_running' );
1185 -
1186 1140 if ( false === $running || $running < strtotime( '-5 minutes' ) ) {
1187 1141 update_option( 'frm_install_running', time(), 'no' );
1188 1142 self::install();
1189 1143 delete_option( 'frm_install_running' );
@@ -1233,13 +1187,8 @@
1233 1187
1234 1188 wp_die();
1235 1189 }
1236 1190
1237 - /**
1238 - * @param array $tables
1239 - *
1240 - * @return array
1241 - */
1242 1191 public static function drop_tables( $tables ) {
1243 1192 global $wpdb;
1244 1193 $tables[] = $wpdb->prefix . 'frm_fields';
1245 1194 $tables[] = $wpdb->prefix . 'frm_forms';
@@ -1287,13 +1236,8 @@
1287 1236
1288 1237 FrmTransLiteAppController::maybe_schedule_cron();
1289 1238 }
1290 1239
1291 - /**
1292 - * @param string $text
1293 - *
1294 - * @return string
1295 - */
1296 1240 public static function set_footer_text( $text ) {
1297 1241 if ( FrmAppHelper::is_formidable_admin() ) {
1298 1242 $text = '';
1299 1243 }
@@ -1308,10 +1252,8 @@
1308 1252 *
1309 1253 * @return void
1310 1254 */
1311 1255 public static function add_admin_footer_links() {
1312 - FrmFormsController::include_device_too_small_message();
1313 -
1314 1256 if ( self::should_show_footer_links() ) {
1315 1257 include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1316 1258 }
1317 1259 }
@@ -1326,9 +1268,8 @@
1326 1268 private static function should_show_footer_links() {
1327 1269 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1328 1270 $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1329 1271 $show_footer_links = $is_formidable_page;
1330 -
1331 1272 if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1332 1273 $show_footer_links = false;
1333 1274 }
1334 1275
@@ -1337,9 +1278,8 @@
1337 1278 *
1338 1279 * @since 6.7
1339 1280 *
1340 1281 * @param bool $show_footer_links
1341 - *
1342 1282 * @return bool
1343 1283 */
1344 1284 return apply_filters( 'frm_show_footer_links', $show_footer_links );
1345 1285 }
@@ -1353,10 +1293,8 @@
1353 1293 *
1354 1294 * @return void
1355 1295 */
1356 1296 public static function show_error_modal( $error_args ) {
1357 - add_filter( 'frm_show_footer_links', '__return_false' );
1358 -
1359 1297 $defaults = array(
1360 1298 'title' => '',
1361 1299 'body' => '',
1362 1300 'cancel_url' => '',
@@ -1366,9 +1304,8 @@
1366 1304 'icon' => 'frm_lock_simple',
1367 1305 );
1368 1306
1369 1307 $error_args = wp_parse_args( $error_args, $defaults );
1370 -
1371 1308 if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1372 1309 $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1373 1310 }
1374 1311
@@ -1385,9 +1322,8 @@
1385 1322 * @since 6.4
1386 1323 *
1387 1324 * @param string $plugin_url URL of the plugin.
1388 1325 * @param string $version Current version of the plugin.
1389 - *
1390 1326 * @return void
1391 1327 */
1392 1328 private static function enqueue_floating_links( $plugin_url, $version ) {
1393 1329 if ( ! $plugin_url || ! $version ) {
@@ -1407,20 +1343,10 @@
1407 1343 if ( function_exists( 'wp_set_script_translations' ) ) {
1408 1344 wp_set_script_translations( 's11-floating-links-config', 's11-' );
1409 1345 }
1410 1346
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 1347 $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/' ),
1348 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1423 1349 );
1424 1350 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1425 1351
1426 1352 /**
@@ -1437,47 +1363,22 @@
1437 1363 *
1438 1364 * @return bool
1439 1365 */
1440 1366 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;
1367 + global $current_screen;
1368 + return FrmAppHelper::is_formidable_admin() || ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type );
1456 1369 }
1457 1370
1458 1371 /**
1459 - * Handles actions related to the current screen.
1372 + * Hide all third-parties admin notices only in our admin pages.
1460 1373 *
1461 - * @since 6.19
1462 - *
1463 1374 * @return void
1464 1375 */
1465 - public static function handle_current_screen() {
1376 + public static function filter_admin_notices() {
1466 1377 if ( ! self::in_our_pages() ) {
1467 1378 return;
1468 1379 }
1469 1380
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 1381 $actions = array(
1481 1382 'admin_notices',
1482 1383 'network_admin_notices',
1483 1384 'user_admin_notices',
@@ -1489,9 +1390,8 @@
1489 1390 foreach ( $actions as $action ) {
1490 1391 if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1491 1392 continue;
1492 1393 }
1493 -
1494 1394 foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1495 1395 foreach ( $callbacks as $callback_name => $callback ) {
1496 1396 if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1497 1397 continue;
@@ -1502,112 +1402,8 @@
1502 1402 }
1503 1403 }
1504 1404
1505 1405 /**
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 1406 * Validate that the callback name is ours not from third-party.
1611 1407 *
1612 1408 * @param string $callback_name WordPress callback name.
1613 1409 *
@@ -1628,53 +1424,6 @@
1628 1424 return ! empty( $callback['function'] ) &&
1629 1425 is_array( $callback['function'] ) &&
1630 1426 ! empty( $callback['function'][0] ) &&
1631 1427 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();
1679 1428 }
1680 1429 }