| @@ -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,9 +356,8 @@ | ||
| 379 | 356 | } |
| 380 | 357 | } |
| 381 | 358 | |
| 382 | 359 | $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' ); |
| 383 | - | |
| 384 | 360 | if ( $upgrade_link ) { |
| 385 | 361 | $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) ); |
| 386 | 362 | } else { |
| 387 | 363 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' ); |
| @@ -387,9 +363,9 @@ | ||
| 387 | 363 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' ); |
| 388 | 364 | } |
| 389 | 365 | |
| 390 | 366 | $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 | |
| 367 | + } | |
| 392 | 368 | |
| 393 | 369 | $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 394 | 370 | |
| 395 | 371 | return array_merge( $settings, $links ); |
| @@ -399,9 +375,9 @@ | ||
| 399 | 375 | * @return void |
| 400 | 376 | */ |
| 401 | 377 | public static function pro_get_started_headline() { |
| 402 | 378 | self::review_request(); |
| 403 | - FrmAppHelper::min_pro_version_notice( '6.20' ); | |
| 379 | + FrmAppHelper::min_pro_version_notice( '6.0' ); | |
| 404 | 380 | } |
| 405 | 381 | |
| 406 | 382 | /** |
| 407 | 383 | * Add admin notices as needed for reviews |
| @@ -476,9 +452,8 @@ | ||
| 476 | 452 | * |
| 477 | 453 | * @param string $form_key |
| 478 | 454 | * @param string $title |
| 479 | 455 | * @param string $description |
| 480 | - * | |
| 481 | 456 | * @return void |
| 482 | 457 | */ |
| 483 | 458 | public static function api_email_form( $form_key, $title = '', $description = '' ) { |
| 484 | 459 | $user = wp_get_current_user(); |
| @@ -535,9 +510,8 @@ | ||
| 535 | 510 | /** |
| 536 | 511 | * Check if the database is outdated |
| 537 | 512 | * |
| 538 | 513 | * @since 2.0.1 |
| 539 | - * | |
| 540 | 514 | * @return bool |
| 541 | 515 | */ |
| 542 | 516 | public static function needs_update() { |
| 543 | 517 | $needs_upgrade = self::compare_for_update( |
| @@ -560,9 +534,8 @@ | ||
| 560 | 534 | * |
| 561 | 535 | * @since 3.0.04 |
| 562 | 536 | * |
| 563 | 537 | * @param array $atts |
| 564 | - * | |
| 565 | 538 | * @return bool |
| 566 | 539 | */ |
| 567 | 540 | public static function compare_for_update( $atts ) { |
| 568 | 541 | $db_version = get_option( $atts['option'] ); |
| @@ -606,10 +579,10 @@ | ||
| 606 | 579 | |
| 607 | 580 | if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) { |
| 608 | 581 | $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' ); |
| 609 | 582 | $utm = array( |
| 610 | - 'campaign' => 'upgrade', | |
| 611 | - 'content' => 'submenu-upgrade', | |
| 583 | + 'medium' => 'upgrade', | |
| 584 | + 'content' => 'submenu-upgrade', | |
| 612 | 585 | ); |
| 613 | 586 | |
| 614 | 587 | if ( $redirect ) { |
| 615 | 588 | $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm ); |
| @@ -639,9 +612,8 @@ | ||
| 639 | 612 | // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. |
| 640 | 613 | // This provides backward compatibility for old addons that use legacy modal templates. |
| 641 | 614 | $action = FrmAppHelper::get_param( 'frm_action' ); |
| 642 | 615 | $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); |
| 643 | - | |
| 644 | 616 | if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { |
| 645 | 617 | $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); |
| 646 | 618 | $url_param = $application_id ? '&applicationId=' . $application_id : ''; |
| 647 | 619 | |
| @@ -662,9 +634,8 @@ | ||
| 662 | 634 | * @return void |
| 663 | 635 | */ |
| 664 | 636 | private static function trigger_page_load_hooks() { |
| 665 | 637 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 666 | - | |
| 667 | 638 | if ( strpos( $page, 'formidable-' ) !== 0 ) { |
| 668 | 639 | // Only trigger hooks on Formidable pages. |
| 669 | 640 | return; |
| 670 | 641 | } |
| @@ -671,9 +642,8 @@ | ||
| 671 | 642 | |
| 672 | 643 | $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page ); |
| 673 | 644 | $page = str_replace( ' ', '', ucwords( $page ) ); |
| 674 | 645 | $class = 'Frm' . $page . 'Controller'; |
| 675 | - | |
| 676 | 646 | if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) { |
| 677 | 647 | call_user_func( array( $class, 'load_page' ) ); |
| 678 | 648 | } |
| 679 | 649 | } |
| @@ -703,10 +673,10 @@ | ||
| 703 | 673 | wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version ); |
| 704 | 674 | |
| 705 | 675 | wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true ); |
| 706 | 676 | 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 ); | |
| 677 | + self::register_popper1(); | |
| 678 | + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true ); | |
| 709 | 679 | |
| 710 | 680 | $settings_js_vars = array( |
| 711 | 681 | 'currencies' => FrmCurrencyHelper::get_currencies(), |
| 712 | 682 | ); |
| @@ -743,9 +713,9 @@ | ||
| 743 | 713 | // For the existing page dropdown in the Form embed modal. |
| 744 | 714 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 745 | 715 | } |
| 746 | 716 | |
| 747 | - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true ); | |
| 717 | + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true ); | |
| 748 | 718 | |
| 749 | 719 | if ( ! class_exists( 'FrmTransHooksController', false ) ) { |
| 750 | 720 | /** |
| 751 | 721 | * Gateway fields are included for add-on compatibility but we do not want it to be visible. |
| @@ -760,15 +730,12 @@ | ||
| 760 | 730 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 761 | 731 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 762 | 732 | |
| 763 | 733 | global $pagenow; |
| 764 | - | |
| 765 | 734 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| 766 | - self::enqueue_global_settings_scripts( $page ); | |
| 767 | - | |
| 768 | 735 | wp_enqueue_script( 'admin-widgets' ); |
| 769 | 736 | wp_enqueue_style( 'widgets' ); |
| 770 | - self::maybe_deregister_popper1(); | |
| 737 | + self::maybe_deregister_popper2(); | |
| 771 | 738 | wp_enqueue_script( 'formidable_admin' ); |
| 772 | 739 | wp_set_script_translations( 'formidable_admin', 'formidable' ); |
| 773 | 740 | wp_enqueue_script( 'formidable_embed' ); |
| 774 | 741 | wp_set_script_translations( 'formidable_embed', 'formidable' ); |
| @@ -775,9 +742,8 @@ | ||
| 775 | 742 | FrmAppHelper::localize_script( 'admin' ); |
| 776 | 743 | |
| 777 | 744 | wp_enqueue_style( 'formidable-animations' ); |
| 778 | 745 | wp_enqueue_style( 'formidable-admin' ); |
| 779 | - | |
| 780 | 746 | if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) { |
| 781 | 747 | wp_enqueue_style( 'formidable-grids' ); |
| 782 | 748 | self::maybe_enqueue_dropzone_css( $page ); |
| 783 | 749 | } else { |
| @@ -800,13 +766,11 @@ | ||
| 800 | 766 | if ( isset( $_REQUEST['post_type'] ) ) { |
| 801 | 767 | $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) ); |
| 802 | 768 | } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 803 | 769 | $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) ); |
| 804 | - | |
| 805 | 770 | if ( ! $post ) { |
| 806 | 771 | return; |
| 807 | 772 | } |
| 808 | - | |
| 809 | 773 | $post_type = $post->post_type; |
| 810 | 774 | } else { |
| 811 | 775 | return; |
| 812 | 776 | } |
| @@ -830,9 +794,8 @@ | ||
| 830 | 794 | * @since 6.24 |
| 831 | 795 | * |
| 832 | 796 | * @param string $plugin_url The plugin URL. |
| 833 | 797 | * @param string $version The plugin version. |
| 834 | - * | |
| 835 | 798 | * @return void |
| 836 | 799 | */ |
| 837 | 800 | private static function enqueue_builder_assets( $plugin_url, $version ) { |
| 838 | 801 | wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version ); |
| @@ -846,28 +809,13 @@ | ||
| 846 | 809 | wp_enqueue_script( 'formidable-settings-components' ); |
| 847 | 810 | } |
| 848 | 811 | |
| 849 | 812 | /** |
| 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 | 813 | * Avoid loading dropzone CSS on the form list page. It isn't required there. |
| 865 | 814 | * |
| 866 | 815 | * @since 6.11 |
| 867 | 816 | * |
| 868 | 817 | * @param string $page |
| 869 | - * | |
| 870 | 818 | * @return void |
| 871 | 819 | */ |
| 872 | 820 | private static function maybe_enqueue_dropzone_css( $page ) { |
| 873 | 821 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| @@ -874,9 +822,8 @@ | ||
| 874 | 822 | return; |
| 875 | 823 | } |
| 876 | 824 | |
| 877 | 825 | $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 878 | - | |
| 879 | 826 | if ( ! $should_avoid_loading_dropzone ) { |
| 880 | 827 | wp_enqueue_style( 'formidable-dropzone' ); |
| 881 | 828 | } |
| 882 | 829 | } |
| @@ -893,21 +840,12 @@ | ||
| 893 | 840 | if ( ! FrmAppHelper::is_formidable_branding() ) { |
| 894 | 841 | return false; |
| 895 | 842 | } |
| 896 | 843 | |
| 897 | - $should_show = FrmAppHelper::is_formidable_admin() && | |
| 844 | + return FrmAppHelper::is_formidable_admin() && | |
| 898 | 845 | ! FrmAppHelper::is_style_editor_page() && |
| 899 | 846 | ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && |
| 900 | 847 | ! 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 | 848 | } |
| 911 | 849 | |
| 912 | 850 | /** |
| 913 | 851 | * @since 6.3.2 |
| @@ -934,9 +872,9 @@ | ||
| 934 | 872 | */ |
| 935 | 873 | private static function enqueue_legacy_views_assets() { |
| 936 | 874 | wp_enqueue_style( 'formidable-grids' ); |
| 937 | 875 | wp_enqueue_script( 'jquery-ui-draggable' ); |
| 938 | - self::maybe_deregister_popper1(); | |
| 876 | + self::maybe_deregister_popper2(); | |
| 939 | 877 | wp_enqueue_script( 'formidable_admin' ); |
| 940 | 878 | wp_add_inline_style( |
| 941 | 879 | 'formidable-admin', |
| 942 | 880 | ' |
| @@ -965,15 +903,15 @@ | ||
| 965 | 903 | self::include_info_overlay(); |
| 966 | 904 | } |
| 967 | 905 | |
| 968 | 906 | /** |
| 969 | - * Unregister Popper if the registered version is outdated. | |
| 907 | + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459. | |
| 970 | 908 | * |
| 971 | - * @since 6.26 | |
| 909 | + * @since 5.2.02.01 | |
| 972 | 910 | * |
| 973 | 911 | * @return void |
| 974 | 912 | */ |
| 975 | - private static function maybe_deregister_popper1() { | |
| 913 | + private static function maybe_deregister_popper2() { | |
| 976 | 914 | global $wp_scripts; |
| 977 | 915 | |
| 978 | 916 | if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) { |
| 979 | 917 | return; |
| @@ -979,27 +917,26 @@ | ||
| 979 | 917 | return; |
| 980 | 918 | } |
| 981 | 919 | |
| 982 | 920 | $popper = $wp_scripts->registered['popper']; |
| 983 | - | |
| 984 | - if ( version_compare( $popper->ver, '2.0', '<' ) ) { | |
| 921 | + if ( version_compare( $popper->ver, '2.0', '>=' ) ) { | |
| 985 | 922 | wp_deregister_script( 'popper' ); |
| 986 | - self::register_popper2(); | |
| 923 | + self::register_popper1(); | |
| 987 | 924 | } |
| 988 | 925 | } |
| 989 | 926 | |
| 990 | 927 | /** |
| 991 | - * Register Popper required for Bootstrap 5. | |
| 928 | + * Register Popper required for Bootstrap 4. | |
| 992 | 929 | * |
| 993 | - * @since 6.26 | |
| 930 | + * @since 5.2.02.01 | |
| 994 | 931 | * |
| 995 | 932 | * @return void |
| 996 | 933 | */ |
| 997 | - private static function register_popper2() { | |
| 934 | + private static function register_popper1() { | |
| 998 | 935 | if ( ! self::should_register_popper() ) { |
| 999 | 936 | return; |
| 1000 | 937 | } |
| 1001 | - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true ); | |
| 938 | + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true ); | |
| 1002 | 939 | } |
| 1003 | 940 | |
| 1004 | 941 | /** |
| 1005 | 942 | * Only register popper on Formidable pages. |
| @@ -1012,9 +949,8 @@ | ||
| 1012 | 949 | private static function should_register_popper() { |
| 1013 | 950 | global $pagenow; |
| 1014 | 951 | |
| 1015 | 952 | $post_id = FrmAppHelper::simple_get( 'post', 'absint' ); |
| 1016 | - | |
| 1017 | 953 | if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) { |
| 1018 | 954 | return true; |
| 1019 | 955 | } |
| 1020 | 956 | |
| @@ -1019,15 +955,13 @@ | ||
| 1019 | 955 | } |
| 1020 | 956 | |
| 1021 | 957 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 1022 | 958 | $is_views_post_type = 'frm_display' === $post_type; |
| 1023 | - | |
| 1024 | 959 | if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) { |
| 1025 | 960 | return true; |
| 1026 | 961 | } |
| 1027 | 962 | |
| 1028 | 963 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 1029 | - | |
| 1030 | 964 | if ( strpos( $page, 'formidable' ) === 0 ) { |
| 1031 | 965 | return true; |
| 1032 | 966 | } |
| 1033 | 967 | |
| @@ -1042,15 +976,13 @@ | ||
| 1042 | 976 | * @return void |
| 1043 | 977 | */ |
| 1044 | 978 | private static function maybe_force_formidable_block_on_gutenberg_page() { |
| 1045 | 979 | global $pagenow; |
| 1046 | - | |
| 1047 | 980 | if ( 'post.php' !== $pagenow ) { |
| 1048 | 981 | return; |
| 1049 | 982 | } |
| 1050 | 983 | |
| 1051 | 984 | $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' ); |
| 1052 | - | |
| 1053 | 985 | if ( ! $form_id ) { |
| 1054 | 986 | return; |
| 1055 | 987 | } |
| 1056 | 988 | |
| @@ -1098,9 +1030,9 @@ | ||
| 1098 | 1030 | public static function create_rest_routes() { |
| 1099 | 1031 | $args = array( |
| 1100 | 1032 | 'methods' => 'GET', |
| 1101 | 1033 | 'callback' => 'FrmAppController::api_install', |
| 1102 | - 'permission_callback' => self::class . '::can_update_db', | |
| 1034 | + 'permission_callback' => __CLASS__ . '::can_update_db', | |
| 1103 | 1035 | ); |
| 1104 | 1036 | |
| 1105 | 1037 | register_rest_route( 'frm-admin/v1', '/install', $args ); |
| 1106 | 1038 | |
| @@ -1117,10 +1049,8 @@ | ||
| 1117 | 1049 | * Make sure the install is only being run when we tell it to. |
| 1118 | 1050 | * We don't want to run manually by people calling the API. |
| 1119 | 1051 | * |
| 1120 | 1052 | * @since 4.06.02 |
| 1121 | - * | |
| 1122 | - * @return bool | |
| 1123 | 1053 | */ |
| 1124 | 1054 | public static function can_update_db() { |
| 1125 | 1055 | return get_transient( 'frm_updating_api' ); |
| 1126 | 1056 | } |
| @@ -1164,9 +1094,8 @@ | ||
| 1164 | 1094 | */ |
| 1165 | 1095 | private static function maybe_add_wp_site_health() { |
| 1166 | 1096 | if ( ! class_exists( 'WP_Site_Health' ) ) { |
| 1167 | 1097 | $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; |
| 1168 | - | |
| 1169 | 1098 | if ( file_exists( $wp_site_health_path ) ) { |
| 1170 | 1099 | require_once $wp_site_health_path; |
| 1171 | 1100 | } |
| 1172 | 1101 | } |
| @@ -1178,12 +1107,10 @@ | ||
| 1178 | 1107 | * @return true |
| 1179 | 1108 | */ |
| 1180 | 1109 | public static function api_install() { |
| 1181 | 1110 | delete_transient( 'frm_updating_api' ); |
| 1182 | - | |
| 1183 | 1111 | if ( self::needs_update() ) { |
| 1184 | 1112 | $running = get_option( 'frm_install_running' ); |
| 1185 | - | |
| 1186 | 1113 | if ( false === $running || $running < strtotime( '-5 minutes' ) ) { |
| 1187 | 1114 | update_option( 'frm_install_running', time(), 'no' ); |
| 1188 | 1115 | self::install(); |
| 1189 | 1116 | delete_option( 'frm_install_running' ); |
| @@ -1233,13 +1160,8 @@ | ||
| 1233 | 1160 | |
| 1234 | 1161 | wp_die(); |
| 1235 | 1162 | } |
| 1236 | 1163 | |
| 1237 | - /** | |
| 1238 | - * @param array $tables | |
| 1239 | - * | |
| 1240 | - * @return array | |
| 1241 | - */ | |
| 1242 | 1164 | public static function drop_tables( $tables ) { |
| 1243 | 1165 | global $wpdb; |
| 1244 | 1166 | $tables[] = $wpdb->prefix . 'frm_fields'; |
| 1245 | 1167 | $tables[] = $wpdb->prefix . 'frm_forms'; |
| @@ -1287,13 +1209,8 @@ | ||
| 1287 | 1209 | |
| 1288 | 1210 | FrmTransLiteAppController::maybe_schedule_cron(); |
| 1289 | 1211 | } |
| 1290 | 1212 | |
| 1291 | - /** | |
| 1292 | - * @param string $text | |
| 1293 | - * | |
| 1294 | - * @return string | |
| 1295 | - */ | |
| 1296 | 1213 | public static function set_footer_text( $text ) { |
| 1297 | 1214 | if ( FrmAppHelper::is_formidable_admin() ) { |
| 1298 | 1215 | $text = ''; |
| 1299 | 1216 | } |
| @@ -1309,9 +1226,8 @@ | ||
| 1309 | 1226 | * @return void |
| 1310 | 1227 | */ |
| 1311 | 1228 | public static function add_admin_footer_links() { |
| 1312 | 1229 | FrmFormsController::include_device_too_small_message(); |
| 1313 | - | |
| 1314 | 1230 | if ( self::should_show_footer_links() ) { |
| 1315 | 1231 | include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; |
| 1316 | 1232 | } |
| 1317 | 1233 | } |
| @@ -1326,9 +1242,8 @@ | ||
| 1326 | 1242 | private static function should_show_footer_links() { |
| 1327 | 1243 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 1328 | 1244 | $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type; |
| 1329 | 1245 | $show_footer_links = $is_formidable_page; |
| 1330 | - | |
| 1331 | 1246 | if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) { |
| 1332 | 1247 | $show_footer_links = false; |
| 1333 | 1248 | } |
| 1334 | 1249 | |
| @@ -1337,9 +1252,8 @@ | ||
| 1337 | 1252 | * |
| 1338 | 1253 | * @since 6.7 |
| 1339 | 1254 | * |
| 1340 | 1255 | * @param bool $show_footer_links |
| 1341 | - * | |
| 1342 | 1256 | * @return bool |
| 1343 | 1257 | */ |
| 1344 | 1258 | return apply_filters( 'frm_show_footer_links', $show_footer_links ); |
| 1345 | 1259 | } |
| @@ -1366,9 +1280,8 @@ | ||
| 1366 | 1280 | 'icon' => 'frm_lock_simple', |
| 1367 | 1281 | ); |
| 1368 | 1282 | |
| 1369 | 1283 | $error_args = wp_parse_args( $error_args, $defaults ); |
| 1370 | - | |
| 1371 | 1284 | if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) { |
| 1372 | 1285 | $error_args['cancel_text'] = __( 'Cancel', 'formidable' ); |
| 1373 | 1286 | } |
| 1374 | 1287 | |
| @@ -1385,9 +1298,8 @@ | ||
| 1385 | 1298 | * @since 6.4 |
| 1386 | 1299 | * |
| 1387 | 1300 | * @param string $plugin_url URL of the plugin. |
| 1388 | 1301 | * @param string $version Current version of the plugin. |
| 1389 | - * | |
| 1390 | 1302 | * @return void |
| 1391 | 1303 | */ |
| 1392 | 1304 | private static function enqueue_floating_links( $plugin_url, $version ) { |
| 1393 | 1305 | if ( ! $plugin_url || ! $version ) { |
| @@ -1407,20 +1319,10 @@ | ||
| 1407 | 1319 | if ( function_exists( 'wp_set_script_translations' ) ) { |
| 1408 | 1320 | wp_set_script_translations( 's11-floating-links-config', 's11-' ); |
| 1409 | 1321 | } |
| 1410 | 1322 | |
| 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 | 1323 | $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/' ), | |
| 1324 | + 'proIsInstalled' => FrmAppHelper::pro_is_installed(), | |
| 1423 | 1325 | ); |
| 1424 | 1326 | wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); |
| 1425 | 1327 | |
| 1426 | 1328 | /** |
| @@ -1438,9 +1340,8 @@ | ||
| 1438 | 1340 | * @return bool |
| 1439 | 1341 | */ |
| 1440 | 1342 | private static function in_our_pages() { |
| 1441 | 1343 | global $current_screen, $pagenow; |
| 1442 | - | |
| 1443 | 1344 | if ( FrmAppHelper::is_formidable_admin() ) { |
| 1444 | 1345 | return true; |
| 1445 | 1346 | } |
| 1446 | 1347 | |
| @@ -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; |
| @@ -1507,18 +1407,14 @@ | ||
| 1507 | 1407 | * |
| 1508 | 1408 | * @return void |
| 1509 | 1409 | */ |
| 1510 | 1410 | private static function remember_custom_sort() { |
| 1511 | - $meta_key = self::get_sort_pref_user_meta_key(); | |
| 1512 | - | |
| 1513 | - if ( false === $meta_key ) { | |
| 1411 | + $screen = get_current_screen(); | |
| 1412 | + if ( ! $screen ) { | |
| 1514 | 1413 | return; |
| 1515 | 1414 | } |
| 1516 | 1415 | |
| 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 ) { | |
| 1416 | + if ( ! FrmAppHelper::is_admin_list_page() && ! FrmAppHelper::is_admin_list_page( 'formidable-entries' ) ) { | |
| 1521 | 1417 | return; |
| 1522 | 1418 | } |
| 1523 | 1419 | |
| 1524 | 1420 | $orderby = FrmAppHelper::get_param( 'orderby' ); |
| @@ -1526,34 +1422,28 @@ | ||
| 1526 | 1422 | if ( ! $orderby ) { |
| 1527 | 1423 | return; |
| 1528 | 1424 | } |
| 1529 | 1425 | |
| 1530 | - $user_id = get_current_user_id(); | |
| 1531 | - $order = FrmAppHelper::get_param( 'order' ); | |
| 1532 | - $new_sort = array( | |
| 1426 | + $user_id = get_current_user_id(); | |
| 1427 | + $meta_key = 'frm_preferred_list_sort_' . $screen->id; | |
| 1428 | + $order = FrmAppHelper::get_param( 'order' ); | |
| 1429 | + | |
| 1430 | + $new_sort = array( | |
| 1533 | 1431 | 'orderby' => $orderby, |
| 1534 | 1432 | 'order' => $order, |
| 1535 | 1433 | ); |
| 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 | 1434 | |
| 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 | - } | |
| 1435 | + $current_sort = get_user_meta( $user_id, $meta_key, true ); | |
| 1543 | 1436 | |
| 1544 | 1437 | 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 ); | |
| 1438 | + update_user_meta( | |
| 1439 | + $user_id, | |
| 1440 | + $meta_key, | |
| 1441 | + array( | |
| 1442 | + 'orderby' => $orderby, | |
| 1443 | + 'order' => $order, | |
| 1444 | + ) | |
| 1445 | + ); | |
| 1556 | 1446 | } |
| 1557 | 1447 | } |
| 1558 | 1448 | |
| 1559 | 1449 | /** |
| @@ -1562,26 +1452,23 @@ | ||
| 1562 | 1452 | * @since 6.19 |
| 1563 | 1453 | * |
| 1564 | 1454 | * @param string &$orderby Reference to the current 'orderby' parameter. |
| 1565 | 1455 | * @param string &$order Reference to the current 'order' parameter. |
| 1566 | - * | |
| 1567 | 1456 | * @return void |
| 1568 | 1457 | */ |
| 1569 | 1458 | public static function apply_saved_sort_preference( &$orderby, &$order ) { |
| 1570 | - $meta_key = self::get_sort_pref_user_meta_key(); | |
| 1459 | + if ( ! function_exists( 'get_current_screen' ) ) { | |
| 1460 | + return; | |
| 1461 | + } | |
| 1571 | 1462 | |
| 1572 | - if ( false === $meta_key ) { | |
| 1463 | + $screen = get_current_screen(); | |
| 1464 | + if ( ! $screen ) { | |
| 1573 | 1465 | return; |
| 1574 | 1466 | } |
| 1575 | 1467 | |
| 1576 | 1468 | $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' ); | |
| 1469 | + $preferred_list_sort = get_user_meta( $user_id, 'frm_preferred_list_sort_' . $screen->id, true ); | |
| 1579 | 1470 | |
| 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 | 1471 | if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) { |
| 1585 | 1472 | $orderby = $preferred_list_sort['orderby']; |
| 1586 | 1473 | |
| 1587 | 1474 | if ( ! empty( $preferred_list_sort['order'] ) ) { |
| @@ -1587,24 +1474,8 @@ | ||
| 1587 | 1474 | if ( ! empty( $preferred_list_sort['order'] ) ) { |
| 1588 | 1475 | $order = $preferred_list_sort['order']; |
| 1589 | 1476 | } |
| 1590 | 1477 | } |
| 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 | 1478 | } |
| 1608 | 1479 | |
| 1609 | 1480 | /** |
| 1610 | 1481 | * Validate that the callback name is ours not from third-party. |