| @@ -81,12 +81,11 @@ | ||
| 81 | 81 | $classes .= ' frm-grey-body '; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if ( FrmAppHelper::is_full_screen() ) { |
| 85 | - $full_screen_on = self::get_full_screen_setting(); | |
| 86 | - $add_class = ''; | |
| 85 | + $add_class = ''; | |
| 87 | 86 | |
| 88 | - if ( $full_screen_on ) { | |
| 87 | + if ( self::get_full_screen_setting() ) { | |
| 89 | 88 | $add_class = ' frm-full-screen is-fullscreen-mode'; |
| 90 | 89 | |
| 91 | 90 | // Load the CSS for .is-fullscreen-mode. |
| 92 | 91 | wp_enqueue_style( 'wp-edit-post' ); |
| @@ -277,15 +276,15 @@ | ||
| 277 | 276 | /** |
| 278 | 277 | * @return string |
| 279 | 278 | */ |
| 280 | 279 | private static function get_current_page() { |
| 281 | - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 282 | - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); | |
| 283 | - | |
| 284 | 280 | if ( FrmAppHelper::is_view_builder_page() ) { |
| 285 | 281 | return 'frm_display'; |
| 286 | 282 | } |
| 287 | 283 | |
| 284 | + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 285 | + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); | |
| 286 | + | |
| 288 | 287 | return isset( $_GET['page'] ) ? $page : $post_type; |
| 289 | 288 | } |
| 290 | 289 | |
| 291 | 290 | /** |
| @@ -374,9 +373,11 @@ | ||
| 374 | 373 | public static function settings_link( $links ) { |
| 375 | 374 | $settings = array(); |
| 376 | 375 | |
| 377 | 376 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 378 | - if ( FrmAddonsController::is_license_expired() ) { | |
| 377 | + $is_expired = FrmAddonsController::is_license_expired(); | |
| 378 | + | |
| 379 | + if ( $is_expired ) { | |
| 379 | 380 | $label = __( 'Renew', 'formidable' ); |
| 380 | 381 | } else { |
| 381 | 382 | $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' ); |
| 382 | 383 | |
| @@ -384,20 +385,26 @@ | ||
| 384 | 385 | $label = __( 'Upgrade to Pro', 'formidable' ); |
| 385 | 386 | } |
| 386 | 387 | } |
| 387 | 388 | |
| 388 | - $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' ); | |
| 389 | + $upgrade_content = $is_expired ? 'renew' : 'upgrade'; | |
| 390 | + $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' ); | |
| 389 | 391 | |
| 392 | + $utm = array( | |
| 393 | + 'campaign' => 'plugin-row', | |
| 394 | + 'content' => $upgrade_content, | |
| 395 | + ); | |
| 396 | + | |
| 390 | 397 | if ( $upgrade_link ) { |
| 391 | - $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) ); | |
| 398 | + $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, $utm ); | |
| 392 | 399 | } else { |
| 393 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' ); | |
| 400 | + $upgrade_link = FrmAppHelper::admin_upgrade_link( $utm ); | |
| 394 | 401 | } |
| 395 | 402 | |
| 396 | 403 | $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>'; |
| 397 | 404 | }//end if |
| 398 | 405 | |
| 399 | - $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; | |
| 406 | + $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . esc_html__( 'Build a Form', 'formidable' ) . '</a>'; | |
| 400 | 407 | |
| 401 | 408 | return array_merge( $settings, $links ); |
| 402 | 409 | } |
| 403 | 410 | |
| @@ -531,12 +538,14 @@ | ||
| 531 | 538 | * @return void |
| 532 | 539 | */ |
| 533 | 540 | public static function install_js_fallback() { |
| 534 | 541 | FrmAppHelper::load_admin_wide_js(); |
| 542 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 535 | 543 | ?> |
| 536 | 544 | <div id="frm_install_message"></div> |
| 537 | 545 | <script>jQuery(document).ready( frm_install_now );</script> |
| 538 | 546 | <?php |
| 547 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 539 | 548 | } |
| 540 | 549 | |
| 541 | 550 | /** |
| 542 | 551 | * Check if the database is outdated |
| @@ -554,9 +563,9 @@ | ||
| 554 | 563 | ) |
| 555 | 564 | ); |
| 556 | 565 | |
| 557 | 566 | if ( ! $needs_upgrade ) { |
| 558 | - $needs_upgrade = apply_filters( 'frm_db_needs_upgrade', $needs_upgrade ); | |
| 567 | + return apply_filters( 'frm_db_needs_upgrade', $needs_upgrade ); | |
| 559 | 568 | } |
| 560 | 569 | |
| 561 | 570 | return $needs_upgrade; |
| 562 | 571 | } |
| @@ -578,11 +587,15 @@ | ||
| 578 | 587 | } |
| 579 | 588 | |
| 580 | 589 | $last_upgrade = explode( '-', $db_version ); |
| 581 | 590 | $needs_db_upgrade = (int) $last_upgrade[1] < (int) $atts['new_db_version']; |
| 582 | - $new_version = version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' ); | |
| 583 | 591 | |
| 584 | - return $needs_db_upgrade || $new_version; | |
| 592 | + if ( $needs_db_upgrade ) { | |
| 593 | + return true; | |
| 594 | + } | |
| 595 | + | |
| 596 | + // New plugin version. | |
| 597 | + return version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' ); | |
| 585 | 598 | } |
| 586 | 599 | |
| 587 | 600 | /** |
| 588 | 601 | * Check for database update and trigger js loading |
| @@ -629,30 +642,32 @@ | ||
| 629 | 642 | self::network_upgrade_site(); |
| 630 | 643 | } |
| 631 | 644 | |
| 632 | 645 | if ( ! FrmAppHelper::doing_ajax() ) { |
| 633 | - // don't continue during ajax calls | |
| 646 | + // Don't continue during ajax calls | |
| 634 | 647 | self::admin_js(); |
| 635 | 648 | } |
| 636 | 649 | |
| 637 | 650 | self::trigger_page_load_hooks(); |
| 638 | 651 | |
| 639 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { | |
| 640 | - // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. | |
| 641 | - // This provides backward compatibility for old addons that use legacy modal templates. | |
| 642 | - $action = FrmAppHelper::get_param( 'frm_action' ); | |
| 643 | - $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); | |
| 652 | + if ( ! FrmAppHelper::is_admin_page( 'formidable' ) ) { | |
| 653 | + return; | |
| 654 | + } | |
| 644 | 655 | |
| 645 | - if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 646 | - $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); | |
| 647 | - $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 656 | + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. | |
| 657 | + // This provides backward compatibility for old addons that use legacy modal templates. | |
| 658 | + $action = FrmAppHelper::get_param( 'frm_action' ); | |
| 659 | + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); | |
| 648 | 660 | |
| 649 | - wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) ); | |
| 650 | - exit; | |
| 651 | - } | |
| 661 | + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 662 | + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); | |
| 663 | + $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 652 | 664 | |
| 653 | - FrmInbox::maybe_disable_screen_options(); | |
| 665 | + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) ); | |
| 666 | + exit; | |
| 654 | 667 | } |
| 668 | + | |
| 669 | + FrmInbox::maybe_disable_screen_options(); | |
| 655 | 670 | } |
| 656 | 671 | |
| 657 | 672 | /** |
| 658 | 673 | * Get the current page and check for a possible function to trigger. |
| @@ -682,13 +697,14 @@ | ||
| 682 | 697 | /** |
| 683 | 698 | * @return void |
| 684 | 699 | */ |
| 685 | 700 | public static function admin_js() { |
| 686 | - $plugin_url = FrmAppHelper::plugin_url(); | |
| 687 | - $version = FrmAppHelper::plugin_version(); | |
| 701 | + $plugin_url = FrmAppHelper::plugin_url(); | |
| 702 | + $version = FrmAppHelper::plugin_version(); | |
| 703 | + $is_pro_min_v6_28 = FrmAppHelper::pro_is_installed() && FrmAppHelper::meets_min_pro_version( '6.28' ); | |
| 704 | + $frm_components_dependencies = $is_pro_min_v6_28 ? array( 'formidable_admin', 'formidable-pro-web-components' ) : array( 'formidable_admin' ); | |
| 688 | 705 | |
| 689 | 706 | FrmAppHelper::load_admin_wide_js(); |
| 690 | - | |
| 691 | 707 | // Register component assets early to ensure they can be enqueued later in controllers. |
| 692 | 708 | wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version ); |
| 693 | 709 | |
| 694 | 710 | if ( class_exists( 'FrmOverlayController' ) ) { |
| @@ -712,11 +728,10 @@ | ||
| 712 | 728 | 'currencies' => FrmCurrencyHelper::get_currencies(), |
| 713 | 729 | ); |
| 714 | 730 | wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true ); |
| 715 | 731 | wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars ); |
| 732 | + wp_register_script( 'formidable-web-components', $plugin_url . '/js/formidable-web-components.js', $frm_components_dependencies, $version, true ); | |
| 716 | 733 | |
| 717 | - wp_register_script( 'formidable-web-components', $plugin_url . '/js/formidable-web-components.js', array( 'formidable_admin' ), $version, true ); | |
| 718 | - | |
| 719 | 734 | if ( self::should_show_floating_links() ) { |
| 720 | 735 | self::enqueue_floating_links( $plugin_url, $version ); |
| 721 | 736 | } |
| 722 | 737 | |
| @@ -721,24 +736,28 @@ | ||
| 721 | 736 | } |
| 722 | 737 | |
| 723 | 738 | wp_register_script( 'formidable_admin', $plugin_url . '/js/formidable_admin.js', self::get_admin_js_dependencies(), $version, true ); |
| 724 | 739 | |
| 740 | + wp_register_script( | |
| 741 | + 'formidable_forms_list', | |
| 742 | + $plugin_url . '/js/admin/forms-list.js', | |
| 743 | + array( | |
| 744 | + 'formidable_dom', | |
| 745 | + ), | |
| 746 | + $version, | |
| 747 | + true | |
| 748 | + ); | |
| 749 | + | |
| 725 | 750 | if ( FrmAppHelper::on_form_listing_page() ) { |
| 726 | 751 | // For the existing page dropdown in the Form embed modal. |
| 727 | 752 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 753 | + wp_enqueue_script( 'formidable_forms_list' ); | |
| 728 | 754 | } |
| 729 | 755 | |
| 730 | 756 | wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true ); |
| 731 | 757 | |
| 732 | 758 | if ( ! class_exists( 'FrmTransHooksController', false ) ) { |
| 733 | - /** | |
| 734 | - * Gateway fields are included for add-on compatibility but we do not want it to be visible. | |
| 735 | - * They do however need to be visible when the payments submodule is active. | |
| 736 | - */ | |
| 737 | - wp_add_inline_style( | |
| 738 | - 'formidable-admin', | |
| 739 | - '#frm_builder_page li[data-ftype="gateway"] { display: none; }' | |
| 740 | - ); | |
| 759 | + FrmTransLiteAppController::hide_gateway_fields_in_builder(); | |
| 741 | 760 | } |
| 742 | 761 | |
| 743 | 762 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 744 | 763 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| @@ -776,8 +795,9 @@ | ||
| 776 | 795 | wp_enqueue_script( 'formidable_entries' ); |
| 777 | 796 | } |
| 778 | 797 | |
| 779 | 798 | do_action( 'frm_enqueue_builder_scripts' ); |
| 799 | + self::maybe_enqueue_legacy_paypal_assets(); | |
| 780 | 800 | self::include_upgrade_overlay(); |
| 781 | 801 | self::include_info_overlay(); |
| 782 | 802 | } elseif ( FrmAppHelper::is_view_builder_page() ) { |
| 783 | 803 | if ( isset( $_REQUEST['post_type'] ) ) { |
| @@ -865,12 +885,14 @@ | ||
| 865 | 885 | * |
| 866 | 886 | * @return void |
| 867 | 887 | */ |
| 868 | 888 | private static function enqueue_global_settings_scripts( $page ) { |
| 869 | - if ( 'formidable-settings' === $page ) { | |
| 870 | - wp_enqueue_style( 'wp-color-picker' ); | |
| 871 | - wp_enqueue_script( 'formidable_settings' ); | |
| 889 | + if ( 'formidable-settings' !== $page ) { | |
| 890 | + return; | |
| 872 | 891 | } |
| 892 | + | |
| 893 | + wp_enqueue_style( 'wp-color-picker' ); | |
| 894 | + wp_enqueue_script( 'formidable_settings' ); | |
| 873 | 895 | } |
| 874 | 896 | |
| 875 | 897 | /** |
| 876 | 898 | * Avoid loading dropzone CSS on the form list page. It isn't required there. |
| @@ -905,12 +927,9 @@ | ||
| 905 | 927 | if ( ! FrmAppHelper::is_formidable_branding() ) { |
| 906 | 928 | return false; |
| 907 | 929 | } |
| 908 | 930 | |
| 909 | - $should_show = FrmAppHelper::is_formidable_admin() && | |
| 910 | - ! FrmAppHelper::is_style_editor_page() && | |
| 911 | - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && | |
| 912 | - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); | |
| 931 | + $should_show = FrmAppHelper::is_formidable_admin() && ! FrmAppHelper::is_style_editor_page() && ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 913 | 932 | |
| 914 | 933 | /** |
| 915 | 934 | * Filters whether the floating links should be displayed. |
| 916 | 935 | * |
| @@ -937,8 +956,29 @@ | ||
| 937 | 956 | FrmUsageController::load_scripts(); |
| 938 | 957 | } |
| 939 | 958 | |
| 940 | 959 | /** |
| 960 | + * Enqueue legacy PayPal action settings styles when the PayPal add-on is active. | |
| 961 | + * | |
| 962 | + * @since 6.31 | |
| 963 | + * | |
| 964 | + * @return void | |
| 965 | + */ | |
| 966 | + private static function maybe_enqueue_legacy_paypal_assets() { | |
| 967 | + if ( ! FrmAppHelper::is_form_builder_page() || ! class_exists( 'FrmPaymentsController' ) ) { | |
| 968 | + return; | |
| 969 | + } | |
| 970 | + | |
| 971 | + wp_register_style( | |
| 972 | + 'formidable-legacy-paypal', | |
| 973 | + FrmAppHelper::plugin_url() . '/css/admin/frm-legacy-paypal.css', | |
| 974 | + array( 'formidable-admin' ), | |
| 975 | + FrmAppHelper::plugin_version() | |
| 976 | + ); | |
| 977 | + wp_enqueue_style( 'formidable-legacy-paypal' ); | |
| 978 | + } | |
| 979 | + | |
| 980 | + /** | |
| 941 | 981 | * Enqueue required assets for the Legacy Views editor (Views v4.x). |
| 942 | 982 | * |
| 943 | 983 | * @since 6.1.2 |
| 944 | 984 | * |
| @@ -992,12 +1032,14 @@ | ||
| 992 | 1032 | } |
| 993 | 1033 | |
| 994 | 1034 | $popper = $wp_scripts->registered['popper']; |
| 995 | 1035 | |
| 996 | - if ( version_compare( $popper->ver, '2.0', '<' ) ) { | |
| 997 | - wp_deregister_script( 'popper' ); | |
| 998 | - self::register_popper2(); | |
| 1036 | + if ( ! version_compare( $popper->ver, '2.0', '<' ) ) { | |
| 1037 | + return; | |
| 999 | 1038 | } |
| 1039 | + | |
| 1040 | + wp_deregister_script( 'popper' ); | |
| 1041 | + self::register_popper2(); | |
| 1000 | 1042 | } |
| 1001 | 1043 | |
| 1002 | 1044 | /** |
| 1003 | 1045 | * Register Popper required for Bootstrap 5. |
| @@ -1162,9 +1204,9 @@ | ||
| 1162 | 1204 | $response = rest_do_request( $request ); |
| 1163 | 1205 | } |
| 1164 | 1206 | |
| 1165 | 1207 | if ( $response->is_error() ) { |
| 1166 | - // if the remove post fails, use javascript instead | |
| 1208 | + // If the remove post fails, use javascript instead | |
| 1167 | 1209 | add_action( 'admin_notices', 'FrmAppController::install_js_fallback' ); |
| 1168 | 1210 | } |
| 1169 | 1211 | } |
| 1170 | 1212 | |
| @@ -1174,14 +1216,16 @@ | ||
| 1174 | 1216 | * |
| 1175 | 1217 | * @return void |
| 1176 | 1218 | */ |
| 1177 | 1219 | private static function maybe_add_wp_site_health() { |
| 1178 | - if ( ! class_exists( 'WP_Site_Health' ) ) { | |
| 1179 | - $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; | |
| 1220 | + if ( class_exists( 'WP_Site_Health' ) ) { | |
| 1221 | + return; | |
| 1222 | + } | |
| 1180 | 1223 | |
| 1181 | - if ( file_exists( $wp_site_health_path ) ) { | |
| 1182 | - require_once $wp_site_health_path; | |
| 1183 | - } | |
| 1224 | + $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; | |
| 1225 | + | |
| 1226 | + if ( file_exists( $wp_site_health_path ) ) { | |
| 1227 | + require_once $wp_site_health_path; | |
| 1184 | 1228 | } |
| 1185 | 1229 | } |
| 1186 | 1230 | |
| 1187 | 1231 | /** |
| @@ -1195,9 +1239,9 @@ | ||
| 1195 | 1239 | if ( self::needs_update() ) { |
| 1196 | 1240 | $running = get_option( 'frm_install_running' ); |
| 1197 | 1241 | |
| 1198 | 1242 | if ( false === $running || $running < strtotime( '-5 minutes' ) ) { |
| 1199 | - update_option( 'frm_install_running', time(), 'no' ); | |
| 1243 | + update_option( 'frm_install_running', time(), false ); | |
| 1200 | 1244 | self::install(); |
| 1201 | 1245 | delete_option( 'frm_install_running' ); |
| 1202 | 1246 | } |
| 1203 | 1247 | } |
| @@ -1285,9 +1329,9 @@ | ||
| 1285 | 1329 | } |
| 1286 | 1330 | |
| 1287 | 1331 | /** |
| 1288 | 1332 | * The payment cron is unscheduled when Formidable is deactivated. |
| 1289 | - * We need to add it back again on activation if Stripe is configured. | |
| 1333 | + * We need to add it back again on activation if any payment gateway is configured. | |
| 1290 | 1334 | * |
| 1291 | 1335 | * @since 6.5 |
| 1292 | 1336 | * |
| 1293 | 1337 | * @return void |
| @@ -1292,9 +1336,13 @@ | ||
| 1292 | 1336 | * |
| 1293 | 1337 | * @return void |
| 1294 | 1338 | */ |
| 1295 | 1339 | private static function maybe_activate_payment_cron() { |
| 1296 | - if ( ! FrmStrpLiteConnectHelper::stripe_connect_is_setup() ) { | |
| 1340 | + $stripe_connected = FrmStrpLiteConnectHelper::at_least_one_mode_is_setup(); | |
| 1341 | + $square_connected = FrmSquareLiteConnectHelper::at_least_one_mode_is_setup(); | |
| 1342 | + $paypal_connected = FrmPayPalLiteConnectHelper::at_least_one_mode_is_setup(); | |
| 1343 | + | |
| 1344 | + if ( ! $stripe_connected && ! $square_connected && ! $paypal_connected ) { | |
| 1297 | 1345 | return; |
| 1298 | 1346 | } |
| 1299 | 1347 | |
| 1300 | 1348 | FrmTransLiteAppController::maybe_schedule_cron(); |
| @@ -1305,13 +1353,9 @@ | ||
| 1305 | 1353 | * |
| 1306 | 1354 | * @return string |
| 1307 | 1355 | */ |
| 1308 | 1356 | public static function set_footer_text( $text ) { |
| 1309 | - if ( FrmAppHelper::is_formidable_admin() ) { | |
| 1310 | - $text = ''; | |
| 1311 | - } | |
| 1312 | - | |
| 1313 | - return $text; | |
| 1357 | + return FrmAppHelper::is_formidable_admin() ? '' : $text; | |
| 1314 | 1358 | } |
| 1315 | 1359 | |
| 1316 | 1360 | /** |
| 1317 | 1361 | * Add admin footer links. |
| @@ -1374,8 +1418,9 @@ | ||
| 1374 | 1418 | 'cancel_url' => '', |
| 1375 | 1419 | 'cancel_classes' => '', |
| 1376 | 1420 | 'continue_url' => '', |
| 1377 | 1421 | 'continue_classes' => '', |
| 1422 | + 'continue_target' => '', | |
| 1378 | 1423 | 'icon' => 'frm_lock_simple', |
| 1379 | 1424 | ); |
| 1380 | 1425 | |
| 1381 | 1426 | $error_args = wp_parse_args( $error_args, $defaults ); |
| @@ -1548,21 +1593,23 @@ | ||
| 1548 | 1593 | if ( is_array( $current_sort ) && $form_id && is_int( $form_id ) && isset( $current_sort[ $form_id ] ) ) { |
| 1549 | 1594 | $current_sort = $current_sort[ $form_id ]; |
| 1550 | 1595 | } |
| 1551 | 1596 | |
| 1552 | - if ( $new_sort !== $current_sort ) { | |
| 1553 | - $new_meta = $new_sort; | |
| 1597 | + if ( $new_sort === $current_sort ) { | |
| 1598 | + return; | |
| 1599 | + } | |
| 1554 | 1600 | |
| 1555 | - if ( $is_entry_list && $form_id && is_int( $form_id ) ) { | |
| 1556 | - // Index meta by form ID. | |
| 1557 | - $temp_meta = is_array( $previous_meta ) ? $previous_meta : array(); | |
| 1558 | - $temp_meta[ $form_id ] = $new_meta; | |
| 1559 | - $new_meta = $temp_meta; | |
| 1560 | - unset( $temp_meta ); | |
| 1561 | - } | |
| 1601 | + $new_meta = $new_sort; | |
| 1562 | 1602 | |
| 1563 | - update_user_meta( $user_id, $meta_key, $new_meta ); | |
| 1603 | + if ( $is_entry_list && $form_id && is_int( $form_id ) ) { | |
| 1604 | + // Index meta by form ID. | |
| 1605 | + $temp_meta = is_array( $previous_meta ) ? $previous_meta : array(); | |
| 1606 | + $temp_meta[ $form_id ] = $new_meta; | |
| 1607 | + $new_meta = $temp_meta; | |
| 1608 | + unset( $temp_meta ); | |
| 1564 | 1609 | } |
| 1610 | + | |
| 1611 | + update_user_meta( $user_id, $meta_key, $new_meta ); | |
| 1565 | 1612 | } |
| 1566 | 1613 | |
| 1567 | 1614 | /** |
| 1568 | 1615 | * Retrieve and apply any saved sorting preferences for the current screen. |
| @@ -1568,10 +1615,10 @@ | ||
| 1568 | 1615 | * Retrieve and apply any saved sorting preferences for the current screen. |
| 1569 | 1616 | * |
| 1570 | 1617 | * @since 6.19 |
| 1571 | 1618 | * |
| 1572 | - * @param string &$orderby Reference to the current 'orderby' parameter. | |
| 1573 | - * @param string &$order Reference to the current 'order' parameter. | |
| 1619 | + * @param string $orderby Reference to the current 'orderby' parameter. | |
| 1620 | + * @param string $order Reference to the current 'order' parameter. | |
| 1574 | 1621 | * |
| 1575 | 1622 | * @return void |
| 1576 | 1623 | */ |
| 1577 | 1624 | public static function apply_saved_sort_preference( &$orderby, &$order ) { |
| @@ -1580,10 +1627,9 @@ | ||
| 1580 | 1627 | if ( false === $meta_key ) { |
| 1581 | 1628 | return; |
| 1582 | 1629 | } |
| 1583 | 1630 | |
| 1584 | - $user_id = get_current_user_id(); | |
| 1585 | - $preferred_list_sort = get_user_meta( $user_id, $meta_key, true ); | |
| 1631 | + $preferred_list_sort = get_user_meta( get_current_user_id(), $meta_key, true ); | |
| 1586 | 1632 | $form_id = FrmAppHelper::simple_get( 'form', 'absint' ); |
| 1587 | 1633 | |
| 1588 | 1634 | if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) { |
| 1589 | 1635 | $preferred_list_sort = $preferred_list_sort[ $form_id ]; |
| @@ -1588,14 +1634,16 @@ | ||
| 1588 | 1634 | if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) { |
| 1589 | 1635 | $preferred_list_sort = $preferred_list_sort[ $form_id ]; |
| 1590 | 1636 | } |
| 1591 | 1637 | |
| 1592 | - if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) { | |
| 1593 | - $orderby = $preferred_list_sort['orderby']; | |
| 1638 | + if ( ! is_array( $preferred_list_sort ) || empty( $preferred_list_sort['orderby'] ) ) { | |
| 1639 | + return; | |
| 1640 | + } | |
| 1594 | 1641 | |
| 1595 | - if ( ! empty( $preferred_list_sort['order'] ) ) { | |
| 1596 | - $order = $preferred_list_sort['order']; | |
| 1597 | - } | |
| 1642 | + $orderby = $preferred_list_sort['orderby']; | |
| 1643 | + | |
| 1644 | + if ( ! empty( $preferred_list_sort['order'] ) ) { | |
| 1645 | + $order = $preferred_list_sort['order']; | |
| 1598 | 1646 | } |
| 1599 | 1647 | } |
| 1600 | 1648 | |
| 1601 | 1649 | /** |
| @@ -1632,12 +1680,9 @@ | ||
| 1632 | 1680 | * |
| 1633 | 1681 | * @return bool |
| 1634 | 1682 | */ |
| 1635 | 1683 | private static function is_our_callback_array( $callback ) { |
| 1636 | - return ! empty( $callback['function'] ) && | |
| 1637 | - is_array( $callback['function'] ) && | |
| 1638 | - ! empty( $callback['function'][0] ) && | |
| 1639 | - self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] ); | |
| 1684 | + return ! empty( $callback['function'] ) && is_array( $callback['function'] ) && ! empty( $callback['function'][0] ) && self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 1640 | 1685 | } |
| 1641 | 1686 | |
| 1642 | 1687 | /** |
| 1643 | 1688 | * In some cases, the DB tables may fail to install. |
| @@ -1682,6 +1727,21 @@ | ||
| 1682 | 1727 | FrmAppHelper::permission_check( 'frm_view_forms' ); |
| 1683 | 1728 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 1684 | 1729 | update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true ); |
| 1685 | 1730 | wp_send_json_success(); |
| 1731 | + } | |
| 1732 | + | |
| 1733 | + /** | |
| 1734 | + * Enqueue the components scripts. | |
| 1735 | + * | |
| 1736 | + * @since 6.28 | |
| 1737 | + * | |
| 1738 | + * @return void | |
| 1739 | + */ | |
| 1740 | + public static function enqueue_components_scripts() { | |
| 1741 | + if ( is_callable( array( 'FrmProFormsController', 'enqueue_pro_web_components_script' ) ) ) { | |
| 1742 | + FrmProFormsController::enqueue_pro_web_components_script(); | |
| 1743 | + } | |
| 1744 | + | |
| 1745 | + wp_enqueue_script( 'formidable-web-components' ); | |
| 1686 | 1746 | } |
| 1687 | 1747 | } |