| @@ -14,14 +14,11 @@ | ||
| 14 | 14 | return; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 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() ); | |
| 18 | 19 | |
| 19 | - if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) { | |
| 20 | - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() ); | |
| 21 | - } | |
| 22 | - | |
| 23 | - 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(); | |
| 24 | 21 | } |
| 25 | 22 | |
| 26 | 23 | /** |
| 27 | 24 | * @return int |
| @@ -45,8 +42,84 @@ | ||
| 45 | 42 | return apply_filters( 'frm_icon', $icon ); |
| 46 | 43 | } |
| 47 | 44 | |
| 48 | 45 | /** |
| 46 | + * @since 6.16 | |
| 47 | + * | |
| 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. | |
| 85 | + * | |
| 86 | + * @since 6.16 | |
| 87 | + * | |
| 88 | + * @return bool | |
| 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 | + /** | |
| 49 | 122 | * @since 3.0 |
| 50 | 123 | */ |
| 51 | 124 | public static function add_admin_class( $classes ) { |
| 52 | 125 | if ( self::is_white_page() ) { |
| @@ -185,9 +258,8 @@ | ||
| 185 | 258 | private static function is_grey_page() { |
| 186 | 259 | $grey_pages = array( |
| 187 | 260 | 'formidable-applications', |
| 188 | 261 | 'formidable-dashboard', |
| 189 | - 'formidable-views', | |
| 190 | 262 | ); |
| 191 | 263 | |
| 192 | 264 | $is_grey_page = self::is_page_in_list( $grey_pages ); |
| 193 | 265 | |
| @@ -336,12 +408,10 @@ | ||
| 336 | 408 | |
| 337 | 409 | return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args ); |
| 338 | 410 | } |
| 339 | 411 | |
| 412 | + // Adds a settings link to the plugins page | |
| 340 | 413 | /** |
| 341 | - * Adds a settings link to the plugins page | |
| 342 | - * | |
| 343 | - * @param array $links | |
| 344 | 414 | * @return array |
| 345 | 415 | */ |
| 346 | 416 | public static function settings_link( $links ) { |
| 347 | 417 | $settings = array(); |
| @@ -346,25 +416,10 @@ | ||
| 346 | 416 | public static function settings_link( $links ) { |
| 347 | 417 | $settings = array(); |
| 348 | 418 | |
| 349 | 419 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 350 | - if ( FrmAddonsController::is_license_expired() ) { | |
| 351 | - $label = __( 'Renew', 'formidable' ); | |
| 352 | - } else { | |
| 353 | - $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' ); | |
| 354 | - if ( ! $label ) { | |
| 355 | - $label = __( 'Upgrade to Pro', 'formidable' ); | |
| 356 | - } | |
| 357 | - } | |
| 358 | - | |
| 359 | - $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' ); | |
| 360 | - if ( $upgrade_link ) { | |
| 361 | - $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) ); | |
| 362 | - } else { | |
| 363 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' ); | |
| 364 | - } | |
| 365 | - | |
| 366 | - $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>'; | |
| 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>'; | |
| 367 | 422 | } |
| 368 | 423 | |
| 369 | 424 | $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 370 | 425 | |
| @@ -486,9 +541,10 @@ | ||
| 486 | 541 | * @return void |
| 487 | 542 | */ |
| 488 | 543 | public static function remove_upsells() { |
| 489 | 544 | remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
| 490 | - 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' ); | |
| 491 | 547 | remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' ); |
| 492 | 548 | } |
| 493 | 549 | |
| 494 | 550 | /** |
| @@ -567,12 +623,8 @@ | ||
| 567 | 623 | if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 568 | 624 | FrmFormsController::duplicate(); |
| 569 | 625 | } |
| 570 | 626 | |
| 571 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) { | |
| 572 | - self::add_missing_tables(); | |
| 573 | - } | |
| 574 | - | |
| 575 | 627 | if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 576 | 628 | // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent. |
| 577 | 629 | FrmStylesController::save_style(); |
| 578 | 630 | } |
| @@ -577,21 +629,29 @@ | ||
| 577 | 629 | FrmStylesController::save_style(); |
| 578 | 630 | } |
| 579 | 631 | |
| 580 | 632 | if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) { |
| 581 | - $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' ); | |
| 582 | - $utm = array( | |
| 583 | - 'medium' => 'upgrade', | |
| 584 | - 'content' => 'submenu-upgrade', | |
| 633 | + wp_redirect( | |
| 634 | + FrmAppHelper::admin_upgrade_link( | |
| 635 | + array( | |
| 636 | + 'medium' => 'upgrade', | |
| 637 | + 'content' => 'submenu-upgrade', | |
| 638 | + ) | |
| 639 | + ) | |
| 585 | 640 | ); |
| 641 | + die(); | |
| 642 | + } | |
| 586 | 643 | |
| 587 | - if ( $redirect ) { | |
| 588 | - $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm ); | |
| 589 | - } else { | |
| 590 | - $redirect = FrmAppHelper::admin_upgrade_link( $utm ); | |
| 591 | - } | |
| 592 | - | |
| 593 | - 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 | + ); | |
| 594 | 654 | die(); |
| 595 | 655 | } |
| 596 | 656 | |
| 597 | 657 | // Register personal data hooks. |
| @@ -675,14 +735,9 @@ | ||
| 675 | 735 | wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true ); |
| 676 | 736 | wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true ); |
| 677 | 737 | self::register_popper1(); |
| 678 | 738 | wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true ); |
| 679 | - | |
| 680 | - $settings_js_vars = array( | |
| 681 | - 'currencies' => FrmCurrencyHelper::get_currencies(), | |
| 682 | - ); | |
| 683 | 739 | wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true ); |
| 684 | - wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars ); | |
| 685 | 740 | |
| 686 | 741 | if ( self::should_show_floating_links() ) { |
| 687 | 742 | self::enqueue_floating_links( $plugin_url, $version ); |
| 688 | 743 | } |
| @@ -731,9 +786,8 @@ | ||
| 731 | 786 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 732 | 787 | |
| 733 | 788 | global $pagenow; |
| 734 | 789 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| 735 | - self::enqueue_global_settings_scripts( $page ); | |
| 736 | 790 | |
| 737 | 791 | wp_enqueue_script( 'admin-widgets' ); |
| 738 | 792 | wp_enqueue_style( 'widgets' ); |
| 739 | 793 | self::maybe_deregister_popper2(); |
| @@ -785,46 +839,11 @@ | ||
| 785 | 839 | if ( 'formidable-addons' === $page ) { |
| 786 | 840 | wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); |
| 787 | 841 | wp_enqueue_script( 'formidable_addons' ); |
| 788 | 842 | } |
| 789 | - | |
| 790 | - self::enqueue_builder_assets( $plugin_url, $version ); | |
| 791 | 843 | } |
| 792 | 844 | |
| 793 | 845 | /** |
| 794 | - * Enqueue the Form Builder assets. | |
| 795 | - * | |
| 796 | - * @since 6.24 | |
| 797 | - * | |
| 798 | - * @param string $plugin_url The plugin URL. | |
| 799 | - * @param string $version The plugin version. | |
| 800 | - * @return void | |
| 801 | - */ | |
| 802 | - private static function enqueue_builder_assets( $plugin_url, $version ) { | |
| 803 | - wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version ); | |
| 804 | - wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true ); | |
| 805 | - | |
| 806 | - if ( ! FrmAppHelper::is_form_builder_page() ) { | |
| 807 | - return; | |
| 808 | - } | |
| 809 | - | |
| 810 | - wp_enqueue_style( 'formidable-settings-components' ); | |
| 811 | - wp_enqueue_script( 'formidable-settings-components' ); | |
| 812 | - } | |
| 813 | - | |
| 814 | - /** | |
| 815 | - * Enqueues global settings scripts. | |
| 816 | - * | |
| 817 | - * @param string $page The `page` param in URL. | |
| 818 | - */ | |
| 819 | - private static function enqueue_global_settings_scripts( $page ) { | |
| 820 | - if ( 'formidable-settings' === $page ) { | |
| 821 | - wp_enqueue_style( 'wp-color-picker' ); | |
| 822 | - wp_enqueue_script( 'formidable_settings' ); | |
| 823 | - } | |
| 824 | - } | |
| 825 | - | |
| 826 | - /** | |
| 827 | 846 | * Avoid loading dropzone CSS on the form list page. It isn't required there. |
| 828 | 847 | * |
| 829 | 848 | * @since 6.11 |
| 830 | 849 | * |
| @@ -868,14 +887,8 @@ | ||
| 868 | 887 | */ |
| 869 | 888 | public static function admin_enqueue_scripts() { |
| 870 | 889 | self::load_wp_admin_style(); |
| 871 | 890 | self::maybe_force_formidable_block_on_gutenberg_page(); |
| 872 | - | |
| 873 | - if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) { | |
| 874 | - wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() ); | |
| 875 | - } | |
| 876 | - | |
| 877 | - FrmUsageController::load_scripts(); | |
| 878 | 891 | } |
| 879 | 892 | |
| 880 | 893 | /** |
| 881 | 894 | * Enqueue required assets for the Legacy Views editor (Views v4.x). |
| @@ -911,9 +924,8 @@ | ||
| 911 | 924 | } |
| 912 | 925 | ' |
| 913 | 926 | ); |
| 914 | 927 | wp_enqueue_style( 'formidable-admin' ); |
| 915 | - wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() ); | |
| 916 | 928 | FrmAppHelper::localize_script( 'admin' ); |
| 917 | 929 | self::include_info_overlay(); |
| 918 | 930 | } |
| 919 | 931 | |
| @@ -1044,9 +1056,9 @@ | ||
| 1044 | 1056 | public static function create_rest_routes() { |
| 1045 | 1057 | $args = array( |
| 1046 | 1058 | 'methods' => 'GET', |
| 1047 | 1059 | 'callback' => 'FrmAppController::api_install', |
| 1048 | - 'permission_callback' => self::class . '::can_update_db', | |
| 1060 | + 'permission_callback' => __CLASS__ . '::can_update_db', | |
| 1049 | 1061 | ); |
| 1050 | 1062 | |
| 1051 | 1063 | register_rest_route( 'frm-admin/v1', '/install', $args ); |
| 1052 | 1064 | |
| @@ -1239,9 +1251,8 @@ | ||
| 1239 | 1251 | * |
| 1240 | 1252 | * @return void |
| 1241 | 1253 | */ |
| 1242 | 1254 | public static function add_admin_footer_links() { |
| 1243 | - FrmFormsController::include_device_too_small_message(); | |
| 1244 | 1255 | if ( self::should_show_footer_links() ) { |
| 1245 | 1256 | include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; |
| 1246 | 1257 | } |
| 1247 | 1258 | } |
| @@ -1281,10 +1292,8 @@ | ||
| 1281 | 1292 | * |
| 1282 | 1293 | * @return void |
| 1283 | 1294 | */ |
| 1284 | 1295 | public static function show_error_modal( $error_args ) { |
| 1285 | - add_filter( 'frm_show_footer_links', '__return_false' ); | |
| 1286 | - | |
| 1287 | 1296 | $defaults = array( |
| 1288 | 1297 | 'title' => '', |
| 1289 | 1298 | 'body' => '', |
| 1290 | 1299 | 'cancel_url' => '', |
| @@ -1348,51 +1357,35 @@ | ||
| 1348 | 1357 | do_action( 'frm_enqueue_floating_links' ); |
| 1349 | 1358 | } |
| 1350 | 1359 | |
| 1351 | 1360 | /** |
| 1361 | + * @deprecated 3.0 This is still referenced in https://formidableforms.com/knowledgebase/php-examples/ as of May 8, 2024. | |
| 1362 | + * @codeCoverageIgnore | |
| 1363 | + */ | |
| 1364 | + public static function page_route( $content ) { | |
| 1365 | + return FrmDeprecated::page_route( $content ); | |
| 1366 | + } | |
| 1367 | + | |
| 1368 | + /** | |
| 1352 | 1369 | * Check if we are in our admin pages. |
| 1353 | 1370 | * |
| 1354 | 1371 | * @return bool |
| 1355 | 1372 | */ |
| 1356 | 1373 | private static function in_our_pages() { |
| 1357 | - global $current_screen, $pagenow; | |
| 1358 | - if ( FrmAppHelper::is_formidable_admin() ) { | |
| 1359 | - return true; | |
| 1360 | - } | |
| 1361 | - | |
| 1362 | - if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) { | |
| 1363 | - return true; | |
| 1364 | - } | |
| 1365 | - | |
| 1366 | - if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) { | |
| 1367 | - return true; | |
| 1368 | - } | |
| 1369 | - | |
| 1370 | - return false; | |
| 1374 | + global $current_screen; | |
| 1375 | + return FrmAppHelper::is_formidable_admin() || ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ); | |
| 1371 | 1376 | } |
| 1372 | 1377 | |
| 1373 | 1378 | /** |
| 1374 | - * Handles actions related to the current screen. | |
| 1379 | + * Hide all third-parties admin notices only in our admin pages. | |
| 1375 | 1380 | * |
| 1376 | - * @since 6.19 | |
| 1377 | - * | |
| 1378 | 1381 | * @return void |
| 1379 | 1382 | */ |
| 1380 | - public static function handle_current_screen() { | |
| 1383 | + public static function filter_admin_notices() { | |
| 1381 | 1384 | if ( ! self::in_our_pages() ) { |
| 1382 | 1385 | return; |
| 1383 | 1386 | } |
| 1384 | 1387 | |
| 1385 | - self::filter_admin_notices(); | |
| 1386 | - self::remember_custom_sort(); | |
| 1387 | - } | |
| 1388 | - | |
| 1389 | - /** | |
| 1390 | - * Hide all third-parties admin notices only in our admin pages. | |
| 1391 | - * | |
| 1392 | - * @return void | |
| 1393 | - */ | |
| 1394 | - public static function filter_admin_notices() { | |
| 1395 | 1388 | $actions = array( |
| 1396 | 1389 | 'admin_notices', |
| 1397 | 1390 | 'network_admin_notices', |
| 1398 | 1391 | 'user_admin_notices', |
| @@ -1416,83 +1409,8 @@ | ||
| 1416 | 1409 | } |
| 1417 | 1410 | } |
| 1418 | 1411 | |
| 1419 | 1412 | /** |
| 1420 | - * Remembers and applies user-specific sorting preferences. | |
| 1421 | - * | |
| 1422 | - * @return void | |
| 1423 | - */ | |
| 1424 | - private static function remember_custom_sort() { | |
| 1425 | - $screen = get_current_screen(); | |
| 1426 | - if ( ! $screen ) { | |
| 1427 | - return; | |
| 1428 | - } | |
| 1429 | - | |
| 1430 | - if ( ! FrmAppHelper::is_admin_list_page() && ! FrmAppHelper::is_admin_list_page( 'formidable-entries' ) ) { | |
| 1431 | - return; | |
| 1432 | - } | |
| 1433 | - | |
| 1434 | - $orderby = FrmAppHelper::get_param( 'orderby' ); | |
| 1435 | - | |
| 1436 | - if ( ! $orderby ) { | |
| 1437 | - return; | |
| 1438 | - } | |
| 1439 | - | |
| 1440 | - $user_id = get_current_user_id(); | |
| 1441 | - $meta_key = 'frm_preferred_list_sort_' . $screen->id; | |
| 1442 | - $order = FrmAppHelper::get_param( 'order' ); | |
| 1443 | - | |
| 1444 | - $new_sort = array( | |
| 1445 | - 'orderby' => $orderby, | |
| 1446 | - 'order' => $order, | |
| 1447 | - ); | |
| 1448 | - | |
| 1449 | - $current_sort = get_user_meta( $user_id, $meta_key, true ); | |
| 1450 | - | |
| 1451 | - if ( $new_sort !== $current_sort ) { | |
| 1452 | - update_user_meta( | |
| 1453 | - $user_id, | |
| 1454 | - $meta_key, | |
| 1455 | - array( | |
| 1456 | - 'orderby' => $orderby, | |
| 1457 | - 'order' => $order, | |
| 1458 | - ) | |
| 1459 | - ); | |
| 1460 | - } | |
| 1461 | - } | |
| 1462 | - | |
| 1463 | - /** | |
| 1464 | - * Retrieve and apply any saved sorting preferences for the current screen. | |
| 1465 | - * | |
| 1466 | - * @since 6.19 | |
| 1467 | - * | |
| 1468 | - * @param string &$orderby Reference to the current 'orderby' parameter. | |
| 1469 | - * @param string &$order Reference to the current 'order' parameter. | |
| 1470 | - * @return void | |
| 1471 | - */ | |
| 1472 | - public static function apply_saved_sort_preference( &$orderby, &$order ) { | |
| 1473 | - if ( ! function_exists( 'get_current_screen' ) ) { | |
| 1474 | - return; | |
| 1475 | - } | |
| 1476 | - | |
| 1477 | - $screen = get_current_screen(); | |
| 1478 | - if ( ! $screen ) { | |
| 1479 | - return; | |
| 1480 | - } | |
| 1481 | - | |
| 1482 | - $user_id = get_current_user_id(); | |
| 1483 | - $preferred_list_sort = get_user_meta( $user_id, 'frm_preferred_list_sort_' . $screen->id, true ); | |
| 1484 | - | |
| 1485 | - if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) { | |
| 1486 | - $orderby = $preferred_list_sort['orderby']; | |
| 1487 | - | |
| 1488 | - if ( ! empty( $preferred_list_sort['order'] ) ) { | |
| 1489 | - $order = $preferred_list_sort['order']; | |
| 1490 | - } | |
| 1491 | - } | |
| 1492 | - } | |
| 1493 | - | |
| 1494 | - /** | |
| 1495 | 1413 | * Validate that the callback name is ours not from third-party. |
| 1496 | 1414 | * |
| 1497 | 1415 | * @param string $callback_name WordPress callback name. |
| 1498 | 1416 | * |
| @@ -1513,53 +1431,6 @@ | ||
| 1513 | 1431 | return ! empty( $callback['function'] ) && |
| 1514 | 1432 | is_array( $callback['function'] ) && |
| 1515 | 1433 | ! empty( $callback['function'][0] ) && |
| 1516 | 1434 | self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] ); |
| 1517 | - } | |
| 1518 | - | |
| 1519 | - /** | |
| 1520 | - * In some cases, the DB tables may fail to install. | |
| 1521 | - * This function tries to add them again when the user clicks the link to try again | |
| 1522 | - * from the given inbox notice. | |
| 1523 | - * | |
| 1524 | - * @since 6.19 | |
| 1525 | - */ | |
| 1526 | - private static function add_missing_tables() { | |
| 1527 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 1528 | - | |
| 1529 | - $inbox = new FrmInbox(); | |
| 1530 | - $error = $inbox->check_for_error(); | |
| 1531 | - | |
| 1532 | - if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) { | |
| 1533 | - // Confirm the inbox item with this CTA exists. | |
| 1534 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); | |
| 1535 | - exit; | |
| 1536 | - } | |
| 1537 | - | |
| 1538 | - global $wpdb; | |
| 1539 | - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) ); | |
| 1540 | - | |
| 1541 | - if ( $exists ) { | |
| 1542 | - // Exit early if the table already exists. | |
| 1543 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); | |
| 1544 | - exit; | |
| 1545 | - } | |
| 1546 | - | |
| 1547 | - delete_option( 'frm_db_version' ); | |
| 1548 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); | |
| 1549 | - exit; | |
| 1550 | - } | |
| 1551 | - | |
| 1552 | - /** | |
| 1553 | - * Handles the small screen proceed action. | |
| 1554 | - * | |
| 1555 | - * @since 6.21 | |
| 1556 | - * | |
| 1557 | - * @return void | |
| 1558 | - */ | |
| 1559 | - public static function small_screen_proceed() { | |
| 1560 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 1561 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 1562 | - update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true ); | |
| 1563 | - wp_send_json_success(); | |
| 1564 | 1435 | } |
| 1565 | 1436 | } |