PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.17
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.17
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 +30 -330 6.266.17 View file →
@@ -9,9 +9,8 @@
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
@@ -32,10 +31,8 @@
32 31 }
33 32
34 33 /**
35 34 * @since 3.05
36 - *
37 - * @return string
38 35 */
39 36 private static function menu_icon() {
40 37 $icon = FrmAppHelper::svg_logo(
41 38 array(
@@ -49,12 +46,8 @@
49 46 }
50 47
51 48 /**
52 49 * @since 3.0
53 - *
54 - * @param string $classes
55 - *
56 - * @return string
57 50 */
58 51 public static function add_admin_class( $classes ) {
59 52 if ( self::is_white_page() ) {
60 53 $classes .= ' frm-white-body ';
@@ -60,12 +53,10 @@
60 53 $classes .= ' frm-white-body ';
61 54 $classes .= self::get_os();
62 55
63 56 $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) );
64 -
65 57 if ( empty( $page ) || $page === 'formidable' ) {
66 58 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
67 -
68 59 if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) {
69 60 $page .= $action;
70 61 } else {
71 62 $page = $action;
@@ -70,9 +61,8 @@
70 61 } else {
71 62 $page = $action;
72 63 }
73 64 }
74 -
75 65 if ( ! empty( $page ) ) {
76 66 $classes .= ' frm-admin-page-' . $page;
77 67 }
78 68 }
@@ -83,9 +73,8 @@
83 73
84 74 if ( FrmAppHelper::is_full_screen() ) {
85 75 $full_screen_on = self::get_full_screen_setting();
86 76 $add_class = '';
87 -
88 77 if ( $full_screen_on ) {
89 78 $add_class = ' frm-full-screen is-fullscreen-mode';
90 79
91 80 // Load the CSS for .is-fullscreen-mode.
@@ -90,9 +79,8 @@
90 79
91 80 // Load the CSS for .is-fullscreen-mode.
92 81 wp_enqueue_style( 'wp-edit-post' );
93 82 }
94 -
95 83 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
96 84 }
97 85
98 86 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -117,9 +105,8 @@
117 105 global $wpdb;
118 106 $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';
119 107
120 108 $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
121 -
122 109 if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) {
123 110 return $prefs['core/edit-post']['fullscreenMode'];
124 111 }
125 112
@@ -133,9 +120,8 @@
133 120 */
134 121 private static function get_os() {
135 122 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
136 123 $os = '';
137 -
138 124 if ( strpos( $agent, 'mac' ) !== false ) {
139 125 $os = ' osx';
140 126 } elseif ( strpos( $agent, 'linux' ) !== false ) {
141 127 $os = ' linux';
@@ -146,10 +132,8 @@
146 132 }
147 133
148 134 /**
149 135 * @since 3.0
150 - *
151 - * @return bool
152 136 */
153 137 private static function is_white_page() {
154 138 $white_pages = array(
155 139 'formidable',
@@ -212,9 +196,8 @@
212 196 *
213 197 * @since 6.8
214 198 *
215 199 * @param bool $is_grey_page
216 - *
217 200 * @return bool
218 201 */
219 202 return apply_filters( 'frm_is_grey_page', $is_grey_page );
220 203 }
@@ -222,9 +205,8 @@
222 205 /**
223 206 * @since 6.8
224 207 *
225 208 * @param array $pages A list of page names to check.
226 - *
227 209 * @return bool
228 210 */
229 211 private static function is_page_in_list( $pages ) {
230 212 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -248,15 +230,13 @@
248 230 * @return void
249 231 */
250 232 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
251 233 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
252 -
253 234 if ( empty( $show_nav ) || ! $form ) {
254 235 return;
255 236 }
256 237
257 238 FrmForm::maybe_get_form( $form );
258 -
259 239 if ( ! is_object( $form ) ) {
260 240 return;
261 241 }
262 242
@@ -283,9 +263,8 @@
283 263 }
284 264
285 265 /**
286 266 * @param object $form
287 - *
288 267 * @return array
289 268 */
290 269 private static function get_form_nav_items( $form ) {
291 270 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
@@ -361,9 +340,8 @@
361 340 /**
362 341 * Adds a settings link to the plugins page
363 342 *
364 343 * @param array $links
365 - *
366 344 * @return array
367 345 */
368 346 public static function settings_link( $links ) {
369 347 $settings = array();
@@ -372,9 +350,8 @@
372 350 if ( FrmAddonsController::is_license_expired() ) {
373 351 $label = __( 'Renew', 'formidable' );
374 352 } else {
375 353 $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' );
376 -
377 354 if ( ! $label ) {
378 355 $label = __( 'Upgrade to Pro', 'formidable' );
379 356 }
380 357 }
@@ -379,17 +356,14 @@
379 356 }
380 357 }
381 358
382 359 $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 {
360 + if ( ! $upgrade_link ) {
387 361 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' );
388 362 }
389 363
390 364 $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
365 + }
392 366
393 367 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
394 368
395 369 return array_merge( $settings, $links );
@@ -399,9 +373,9 @@
399 373 * @return void
400 374 */
401 375 public static function pro_get_started_headline() {
402 376 self::review_request();
403 - FrmAppHelper::min_pro_version_notice( '6.20' );
377 + FrmAppHelper::min_pro_version_notice( '6.0' );
404 378 }
405 379
406 380 /**
407 381 * Add admin notices as needed for reviews
@@ -476,9 +450,8 @@
476 450 *
477 451 * @param string $form_key
478 452 * @param string $title
479 453 * @param string $description
480 - *
481 454 * @return void
482 455 */
483 456 public static function api_email_form( $form_key, $title = '', $description = '' ) {
484 457 $user = wp_get_current_user();
@@ -511,9 +484,9 @@
511 484 * @return void
512 485 */
513 486 public static function remove_upsells() {
514 487 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
515 - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
488 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
516 489 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
517 490 }
518 491
519 492 /**
@@ -535,9 +508,8 @@
535 508 /**
536 509 * Check if the database is outdated
537 510 *
538 511 * @since 2.0.1
539 - *
540 512 * @return bool
541 513 */
542 514 public static function needs_update() {
543 515 $needs_upgrade = self::compare_for_update(
@@ -560,9 +532,8 @@
560 532 *
561 533 * @since 3.0.04
562 534 *
563 535 * @param array $atts
564 - *
565 536 * @return bool
566 537 */
567 538 public static function compare_for_update( $atts ) {
568 539 $db_version = get_option( $atts['option'] );
@@ -594,12 +565,8 @@
594 565 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
595 566 FrmFormsController::duplicate();
596 567 }
597 568
598 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
599 - self::add_missing_tables();
600 - }
601 -
602 569 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
603 570 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
604 571 FrmStylesController::save_style();
605 572 }
@@ -605,17 +572,15 @@
605 572 }
606 573
607 574 if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
608 575 $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 );
576 + if ( ! $redirect ) {
577 + $redirct = FrmAppHelper::admin_upgrade_link(
578 + array(
579 + 'medium' => 'upgrade',
580 + 'content' => 'submenu-upgrade',
581 + )
582 + );
618 583 }
619 584
620 585 wp_redirect( $redirect );
621 586 die();
@@ -639,9 +604,8 @@
639 604 // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
640 605 // This provides backward compatibility for old addons that use legacy modal templates.
641 606 $action = FrmAppHelper::get_param( 'frm_action' );
642 607 $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
643 -
644 608 if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
645 609 $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
646 610 $url_param = $application_id ? '&applicationId=' . $application_id : '';
647 611
@@ -662,9 +626,8 @@
662 626 * @return void
663 627 */
664 628 private static function trigger_page_load_hooks() {
665 629 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
666 -
667 630 if ( strpos( $page, 'formidable-' ) !== 0 ) {
668 631 // Only trigger hooks on Formidable pages.
669 632 return;
670 633 }
@@ -671,9 +634,8 @@
671 634
672 635 $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
673 636 $page = str_replace( ' ', '', ucwords( $page ) );
674 637 $class = 'Frm' . $page . 'Controller';
675 -
676 638 if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
677 639 call_user_func( array( $class, 'load_page' ) );
678 640 }
679 641 }
@@ -703,16 +665,11 @@
703 665 wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version );
704 666
705 667 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
706 668 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 - );
669 + self::register_popper1();
670 + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
713 671 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 672
716 673 if ( self::should_show_floating_links() ) {
717 674 self::enqueue_floating_links( $plugin_url, $version );
718 675 }
@@ -743,9 +700,9 @@
743 700 // For the existing page dropdown in the Form embed modal.
744 701 wp_enqueue_script( 'jquery-ui-autocomplete' );
745 702 }
746 703
747 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true );
704 + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
748 705
749 706 if ( ! class_exists( 'FrmTransHooksController', false ) ) {
750 707 /**
751 708 * Gateway fields are included for add-on compatibility but we do not want it to be visible.
@@ -760,15 +717,13 @@
760 717 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
761 718 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
762 719
763 720 global $pagenow;
764 -
765 721 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
766 - self::enqueue_global_settings_scripts( $page );
767 722
768 723 wp_enqueue_script( 'admin-widgets' );
769 724 wp_enqueue_style( 'widgets' );
770 - self::maybe_deregister_popper1();
725 + self::maybe_deregister_popper2();
771 726 wp_enqueue_script( 'formidable_admin' );
772 727 wp_set_script_translations( 'formidable_admin', 'formidable' );
773 728 wp_enqueue_script( 'formidable_embed' );
774 729 wp_set_script_translations( 'formidable_embed', 'formidable' );
@@ -775,9 +730,8 @@
775 730 FrmAppHelper::localize_script( 'admin' );
776 731
777 732 wp_enqueue_style( 'formidable-animations' );
778 733 wp_enqueue_style( 'formidable-admin' );
779 -
780 734 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
781 735 wp_enqueue_style( 'formidable-grids' );
782 736 self::maybe_enqueue_dropzone_css( $page );
783 737 } else {
@@ -800,13 +754,11 @@
800 754 if ( isset( $_REQUEST['post_type'] ) ) {
801 755 $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) );
802 756 } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
803 757 $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) );
804 -
805 758 if ( ! $post ) {
806 759 return;
807 760 }
808 -
809 761 $post_type = $post->post_type;
810 762 } else {
811 763 return;
812 764 }
@@ -819,55 +771,16 @@
819 771 if ( 'formidable-addons' === $page ) {
820 772 wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
821 773 wp_enqueue_script( 'formidable_addons' );
822 774 }
823 -
824 - self::enqueue_builder_assets( $plugin_url, $version );
825 775 }
826 776
827 777 /**
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 778 * Avoid loading dropzone CSS on the form list page. It isn't required there.
865 779 *
866 780 * @since 6.11
867 781 *
868 782 * @param string $page
869 - *
870 783 * @return void
871 784 */
872 785 private static function maybe_enqueue_dropzone_css( $page ) {
873 786 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -874,9 +787,8 @@
874 787 return;
875 788 }
876 789
877 790 $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
878 -
879 791 if ( ! $should_avoid_loading_dropzone ) {
880 792 wp_enqueue_style( 'formidable-dropzone' );
881 793 }
882 794 }
@@ -893,21 +805,12 @@
893 805 if ( ! FrmAppHelper::is_formidable_branding() ) {
894 806 return false;
895 807 }
896 808
897 - $should_show = FrmAppHelper::is_formidable_admin() &&
809 + return FrmAppHelper::is_formidable_admin() &&
898 810 ! FrmAppHelper::is_style_editor_page() &&
899 811 ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
900 812 ! 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 813 }
911 814
912 815 /**
913 816 * @since 6.3.2
@@ -934,9 +837,9 @@
934 837 */
935 838 private static function enqueue_legacy_views_assets() {
936 839 wp_enqueue_style( 'formidable-grids' );
937 840 wp_enqueue_script( 'jquery-ui-draggable' );
938 - self::maybe_deregister_popper1();
841 + self::maybe_deregister_popper2();
939 842 wp_enqueue_script( 'formidable_admin' );
940 843 wp_add_inline_style(
941 844 'formidable-admin',
942 845 '
@@ -959,21 +862,20 @@
959 862 }
960 863 '
961 864 );
962 865 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 866 FrmAppHelper::localize_script( 'admin' );
965 867 self::include_info_overlay();
966 868 }
967 869
968 870 /**
969 - * Unregister Popper if the registered version is outdated.
871 + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
970 872 *
971 - * @since 6.26
873 + * @since 5.2.02.01
972 874 *
973 875 * @return void
974 876 */
975 - private static function maybe_deregister_popper1() {
877 + private static function maybe_deregister_popper2() {
976 878 global $wp_scripts;
977 879
978 880 if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) {
979 881 return;
@@ -979,27 +881,26 @@
979 881 return;
980 882 }
981 883
982 884 $popper = $wp_scripts->registered['popper'];
983 -
984 - if ( version_compare( $popper->ver, '2.0', '<' ) ) {
885 + if ( version_compare( $popper->ver, '2.0', '>=' ) ) {
985 886 wp_deregister_script( 'popper' );
986 - self::register_popper2();
887 + self::register_popper1();
987 888 }
988 889 }
989 890
990 891 /**
991 - * Register Popper required for Bootstrap 5.
892 + * Register Popper required for Bootstrap 4.
992 893 *
993 - * @since 6.26
894 + * @since 5.2.02.01
994 895 *
995 896 * @return void
996 897 */
997 - private static function register_popper2() {
898 + private static function register_popper1() {
998 899 if ( ! self::should_register_popper() ) {
999 900 return;
1000 901 }
1001 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true );
902 + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
1002 903 }
1003 904
1004 905 /**
1005 906 * Only register popper on Formidable pages.
@@ -1012,9 +913,8 @@
1012 913 private static function should_register_popper() {
1013 914 global $pagenow;
1014 915
1015 916 $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
1016 -
1017 917 if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
1018 918 return true;
1019 919 }
1020 920
@@ -1019,15 +919,13 @@
1019 919 }
1020 920
1021 921 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1022 922 $is_views_post_type = 'frm_display' === $post_type;
1023 -
1024 923 if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
1025 924 return true;
1026 925 }
1027 926
1028 927 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
1029 -
1030 928 if ( strpos( $page, 'formidable' ) === 0 ) {
1031 929 return true;
1032 930 }
1033 931
@@ -1042,15 +940,13 @@
1042 940 * @return void
1043 941 */
1044 942 private static function maybe_force_formidable_block_on_gutenberg_page() {
1045 943 global $pagenow;
1046 -
1047 944 if ( 'post.php' !== $pagenow ) {
1048 945 return;
1049 946 }
1050 947
1051 948 $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
1052 -
1053 949 if ( ! $form_id ) {
1054 950 return;
1055 951 }
1056 952
@@ -1098,9 +994,9 @@
1098 994 public static function create_rest_routes() {
1099 995 $args = array(
1100 996 'methods' => 'GET',
1101 997 'callback' => 'FrmAppController::api_install',
1102 - 'permission_callback' => self::class . '::can_update_db',
998 + 'permission_callback' => __CLASS__ . '::can_update_db',
1103 999 );
1104 1000
1105 1001 register_rest_route( 'frm-admin/v1', '/install', $args );
1106 1002
@@ -1117,10 +1013,8 @@
1117 1013 * Make sure the install is only being run when we tell it to.
1118 1014 * We don't want to run manually by people calling the API.
1119 1015 *
1120 1016 * @since 4.06.02
1121 - *
1122 - * @return bool
1123 1017 */
1124 1018 public static function can_update_db() {
1125 1019 return get_transient( 'frm_updating_api' );
1126 1020 }
@@ -1164,9 +1058,8 @@
1164 1058 */
1165 1059 private static function maybe_add_wp_site_health() {
1166 1060 if ( ! class_exists( 'WP_Site_Health' ) ) {
1167 1061 $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
1168 -
1169 1062 if ( file_exists( $wp_site_health_path ) ) {
1170 1063 require_once $wp_site_health_path;
1171 1064 }
1172 1065 }
@@ -1178,12 +1071,10 @@
1178 1071 * @return true
1179 1072 */
1180 1073 public static function api_install() {
1181 1074 delete_transient( 'frm_updating_api' );
1182 -
1183 1075 if ( self::needs_update() ) {
1184 1076 $running = get_option( 'frm_install_running' );
1185 -
1186 1077 if ( false === $running || $running < strtotime( '-5 minutes' ) ) {
1187 1078 update_option( 'frm_install_running', time(), 'no' );
1188 1079 self::install();
1189 1080 delete_option( 'frm_install_running' );
@@ -1233,13 +1124,8 @@
1233 1124
1234 1125 wp_die();
1235 1126 }
1236 1127
1237 - /**
1238 - * @param array $tables
1239 - *
1240 - * @return array
1241 - */
1242 1128 public static function drop_tables( $tables ) {
1243 1129 global $wpdb;
1244 1130 $tables[] = $wpdb->prefix . 'frm_fields';
1245 1131 $tables[] = $wpdb->prefix . 'frm_forms';
@@ -1287,13 +1173,8 @@
1287 1173
1288 1174 FrmTransLiteAppController::maybe_schedule_cron();
1289 1175 }
1290 1176
1291 - /**
1292 - * @param string $text
1293 - *
1294 - * @return string
1295 - */
1296 1177 public static function set_footer_text( $text ) {
1297 1178 if ( FrmAppHelper::is_formidable_admin() ) {
1298 1179 $text = '';
1299 1180 }
@@ -1308,10 +1189,8 @@
1308 1189 *
1309 1190 * @return void
1310 1191 */
1311 1192 public static function add_admin_footer_links() {
1312 - FrmFormsController::include_device_too_small_message();
1313 -
1314 1193 if ( self::should_show_footer_links() ) {
1315 1194 include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1316 1195 }
1317 1196 }
@@ -1326,9 +1205,8 @@
1326 1205 private static function should_show_footer_links() {
1327 1206 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1328 1207 $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1329 1208 $show_footer_links = $is_formidable_page;
1330 -
1331 1209 if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1332 1210 $show_footer_links = false;
1333 1211 }
1334 1212
@@ -1337,9 +1215,8 @@
1337 1215 *
1338 1216 * @since 6.7
1339 1217 *
1340 1218 * @param bool $show_footer_links
1341 - *
1342 1219 * @return bool
1343 1220 */
1344 1221 return apply_filters( 'frm_show_footer_links', $show_footer_links );
1345 1222 }
@@ -1366,9 +1243,8 @@
1366 1243 'icon' => 'frm_lock_simple',
1367 1244 );
1368 1245
1369 1246 $error_args = wp_parse_args( $error_args, $defaults );
1370 -
1371 1247 if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1372 1248 $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1373 1249 }
1374 1250
@@ -1385,9 +1261,8 @@
1385 1261 * @since 6.4
1386 1262 *
1387 1263 * @param string $plugin_url URL of the plugin.
1388 1264 * @param string $version Current version of the plugin.
1389 - *
1390 1265 * @return void
1391 1266 */
1392 1267 private static function enqueue_floating_links( $plugin_url, $version ) {
1393 1268 if ( ! $plugin_url || ! $version ) {
@@ -1407,20 +1282,10 @@
1407 1282 if ( function_exists( 'wp_set_script_translations' ) ) {
1408 1283 wp_set_script_translations( 's11-floating-links-config', 's11-' );
1409 1284 }
1410 1285
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 1286 $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/' ),
1287 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1423 1288 );
1424 1289 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1425 1290
1426 1291 /**
@@ -1438,9 +1303,8 @@
1438 1303 * @return bool
1439 1304 */
1440 1305 private static function in_our_pages() {
1441 1306 global $current_screen, $pagenow;
1442 -
1443 1307 if ( FrmAppHelper::is_formidable_admin() ) {
1444 1308 return true;
1445 1309 }
1446 1310
@@ -1455,29 +1319,17 @@
1455 1319 return false;
1456 1320 }
1457 1321
1458 1322 /**
1459 - * Handles actions related to the current screen.
1323 + * Hide all third-parties admin notices only in our admin pages.
1460 1324 *
1461 - * @since 6.19
1462 - *
1463 1325 * @return void
1464 1326 */
1465 - public static function handle_current_screen() {
1327 + public static function filter_admin_notices() {
1466 1328 if ( ! self::in_our_pages() ) {
1467 1329 return;
1468 1330 }
1469 1331
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 1332 $actions = array(
1481 1333 'admin_notices',
1482 1334 'network_admin_notices',
1483 1335 'user_admin_notices',
@@ -1489,9 +1341,8 @@
1489 1341 foreach ( $actions as $action ) {
1490 1342 if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1491 1343 continue;
1492 1344 }
1493 -
1494 1345 foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1495 1346 foreach ( $callbacks as $callback_name => $callback ) {
1496 1347 if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1497 1348 continue;
@@ -1502,112 +1353,8 @@
1502 1353 }
1503 1354 }
1504 1355
1505 1356 /**
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 1357 * Validate that the callback name is ours not from third-party.
1611 1358 *
1612 1359 * @param string $callback_name WordPress callback name.
1613 1360 *
@@ -1628,53 +1375,6 @@
1628 1375 return ! empty( $callback['function'] ) &&
1629 1376 is_array( $callback['function'] ) &&
1630 1377 ! empty( $callback['function'][0] ) &&
1631 1378 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 1379 }
1680 1380 }