| @@ -8,15 +8,14 @@ | ||
| 8 | 8 | namespace SRFM\Admin; |
| 9 | 9 | |
| 10 | 10 | use Astra_Notices; |
| 11 | 11 | use SRFM\Inc\AI_Form_Builder\AI_Helper; |
| 12 | +use SRFM\Inc\Analytics_Events; | |
| 12 | 13 | use SRFM\Inc\Database\Tables\Entries; |
| 13 | -use SRFM\Inc\Global_Settings\Global_Settings; | |
| 14 | 14 | use SRFM\Inc\Helper; |
| 15 | 15 | use SRFM\Inc\Onboarding; |
| 16 | 16 | use SRFM\Inc\Payments\Payment_Helper; |
| 17 | 17 | use SRFM\Inc\Payments\Stripe\Stripe_Helper; |
| 18 | -use SRFM\Inc\Smart_Tags; | |
| 19 | 18 | use SRFM\Inc\Traits\Get_Instance; |
| 20 | 19 | |
| 21 | 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | 21 | exit; // Exit if accessed directly. |
| @@ -21,10 +20,10 @@ | ||
| 21 | 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | 21 | exit; // Exit if accessed directly. |
| 23 | 22 | } |
| 24 | 23 | |
| 25 | -if ( ! class_exists( 'BSF_Admin_Notices' ) ) { | |
| 26 | - require_once SRFM_DIR . 'inc/lib/astra-notices/class-bsf-admin-notices.php'; | |
| 24 | +if ( ! class_exists( 'Astra_Notices' ) ) { | |
| 25 | + require_once SRFM_DIR . 'inc/lib/astra-notices/class-astra-notices.php'; | |
| 27 | 26 | } |
| 28 | 27 | /** |
| 29 | 28 | * Admin handler class. |
| 30 | 29 | * |
| @@ -77,11 +76,8 @@ | ||
| 77 | 76 | add_action( 'admin_menu', [ $this, 'add_learn_page' ] ); |
| 78 | 77 | add_action( 'admin_menu', [ $this, 'add_new_form' ] ); |
| 79 | 78 | add_action( 'admin_menu', [ $this, 'add_suremail_page' ] ); |
| 80 | 79 | if ( ! Helper::has_pro() ) { |
| 81 | - add_action( 'admin_menu', [ $this, 'add_quiz_page' ] ); | |
| 82 | - add_action( 'admin_menu', [ $this, 'add_survey_reports_page' ] ); | |
| 83 | - add_action( 'admin_menu', [ $this, 'add_partial_entries_page' ] ); | |
| 84 | 80 | add_action( 'admin_menu', [ $this, 'add_upgrade_to_pro' ] ); |
| 85 | 81 | add_action( 'admin_footer', [ $this, 'add_upgrade_to_pro_target_attr' ] ); |
| 86 | 82 | } |
| 87 | 83 | |
| @@ -111,8 +107,10 @@ | ||
| 111 | 107 | if ( $admin_notification_on ) { |
| 112 | 108 | add_action( 'admin_menu', [ $this, 'maybe_add_entries_badge' ], 99 ); |
| 113 | 109 | } |
| 114 | 110 | |
| 111 | + add_action( 'admin_menu', [ $this, 'add_payments_badge' ], 99 ); | |
| 112 | + | |
| 115 | 113 | add_filter( 'wpforms_current_user_can', [ $this, 'disable_wpforms_capabilities' ], 10, 3 ); |
| 116 | 114 | |
| 117 | 115 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_pointer' ] ); |
| 118 | 116 | // Ajax callbacks for wp-pointer functionality. |
| @@ -232,9 +230,14 @@ | ||
| 232 | 230 | */ |
| 233 | 231 | public function add_action_links( $links ) { |
| 234 | 232 | if ( ! Helper::has_pro() ) { |
| 235 | 233 | // Display upsell link if SureForms Pro is not installed. |
| 236 | - $upsell_link = Helper::get_sureforms_website_url( 'pricing', [ 'utm_medium' => 'plugin-list' ] ); | |
| 234 | + $upsell_link = add_query_arg( | |
| 235 | + [ | |
| 236 | + 'utm_medium' => 'plugin-list', | |
| 237 | + ], | |
| 238 | + Helper::get_sureforms_website_url( 'pricing' ) | |
| 239 | + ); | |
| 237 | 240 | |
| 238 | 241 | ob_start(); |
| 239 | 242 | ?> |
| 240 | 243 | <a href="<?php echo esc_url( $upsell_link ); ?>" target="_blank" rel="noreferrer" class="sureforms-plugins-go-pro"> |
| @@ -394,9 +397,14 @@ | ||
| 394 | 397 | */ |
| 395 | 398 | public function add_upgrade_to_pro() { |
| 396 | 399 | // The url used here is used as a selector for css to style the upgrade to pro submenu. |
| 397 | 400 | // If you are changing this url, please make sure to update the css as well. |
| 398 | - $upgrade_url = Helper::get_sureforms_website_url( 'upgrade', [ 'utm_medium' => 'submenu_link_upgrade' ] ); | |
| 401 | + $upgrade_url = add_query_arg( | |
| 402 | + [ | |
| 403 | + 'utm_medium' => 'submenu_link_upgrade', | |
| 404 | + ], | |
| 405 | + Helper::get_sureforms_website_url( 'upgrade' ) | |
| 406 | + ); | |
| 399 | 407 | |
| 400 | 408 | add_submenu_page( |
| 401 | 409 | 'sureforms_menu', |
| 402 | 410 | __( 'Upgrade', 'sureforms' ), |
| @@ -406,107 +414,8 @@ | ||
| 406 | 414 | ); |
| 407 | 415 | } |
| 408 | 416 | |
| 409 | 417 | /** |
| 410 | - * Add Quiz empty state submenu page for free users. | |
| 411 | - * | |
| 412 | - * @return void | |
| 413 | - * @since 2.7.0 | |
| 414 | - */ | |
| 415 | - public function add_quiz_page() { | |
| 416 | - add_submenu_page( | |
| 417 | - 'sureforms_menu', | |
| 418 | - __( 'Quiz Entries', 'sureforms' ), | |
| 419 | - __( 'Quizzes', 'sureforms' ) . | |
| 420 | - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' . | |
| 421 | - esc_html__( 'New', 'sureforms' ) . | |
| 422 | - '</span>', | |
| 423 | - self::$sureforms_page_default_capability, | |
| 424 | - 'sureforms_quiz_entries', | |
| 425 | - [ $this, 'render_quiz_empty_state' ], | |
| 426 | - 5 | |
| 427 | - ); | |
| 428 | - } | |
| 429 | - | |
| 430 | - /** | |
| 431 | - * Quiz empty state page callback. | |
| 432 | - * | |
| 433 | - * @return void | |
| 434 | - * @since 2.7.0 | |
| 435 | - */ | |
| 436 | - public function render_quiz_empty_state() { | |
| 437 | - ?> | |
| 438 | - <div id="srfm-quiz-entries-root" class="srfm-admin-wrapper"></div> | |
| 439 | - <?php | |
| 440 | - } | |
| 441 | - | |
| 442 | - /** | |
| 443 | - * Add Survey Reports promotional submenu page for free users. | |
| 444 | - * | |
| 445 | - * @return void | |
| 446 | - * @since 2.8.0 | |
| 447 | - */ | |
| 448 | - public function add_survey_reports_page() { | |
| 449 | - add_submenu_page( | |
| 450 | - 'sureforms_menu', | |
| 451 | - __( 'Survey Reports', 'sureforms' ), | |
| 452 | - __( 'Survey Reports', 'sureforms' ) . | |
| 453 | - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' . | |
| 454 | - esc_html__( 'New', 'sureforms' ) . | |
| 455 | - '</span>', | |
| 456 | - self::$sureforms_page_default_capability, | |
| 457 | - 'sureforms_survey_reports', | |
| 458 | - [ $this, 'render_survey_empty_state' ], | |
| 459 | - 6 | |
| 460 | - ); | |
| 461 | - } | |
| 462 | - | |
| 463 | - /** | |
| 464 | - * Survey empty state page callback. | |
| 465 | - * | |
| 466 | - * @return void | |
| 467 | - * @since 2.8.0 | |
| 468 | - */ | |
| 469 | - public function render_survey_empty_state() { | |
| 470 | - ?> | |
| 471 | - <div id="srfm-survey-empty-state-root" class="srfm-admin-wrapper"></div> | |
| 472 | - <?php | |
| 473 | - } | |
| 474 | - | |
| 475 | - /** | |
| 476 | - * Add Partial Entries promotional submenu page for free users. | |
| 477 | - * | |
| 478 | - * @return void | |
| 479 | - * @since 2.9.0 | |
| 480 | - */ | |
| 481 | - public function add_partial_entries_page() { | |
| 482 | - add_submenu_page( | |
| 483 | - 'sureforms_menu', | |
| 484 | - __( 'Partial Entries', 'sureforms' ), | |
| 485 | - __( 'Partial Entries', 'sureforms' ) . | |
| 486 | - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' . | |
| 487 | - esc_html__( 'New', 'sureforms' ) . | |
| 488 | - '</span>', | |
| 489 | - self::$sureforms_page_default_capability, | |
| 490 | - 'sureforms_partial_entries', | |
| 491 | - [ $this, 'render_partial_entries_empty_state' ], | |
| 492 | - 7 | |
| 493 | - ); | |
| 494 | - } | |
| 495 | - | |
| 496 | - /** | |
| 497 | - * Partial Entries empty state page callback. | |
| 498 | - * | |
| 499 | - * @return void | |
| 500 | - * @since 2.9.0 | |
| 501 | - */ | |
| 502 | - public function render_partial_entries_empty_state() { | |
| 503 | - ?> | |
| 504 | - <div id="srfm-partial-entries-empty-state-root" class="srfm-admin-wrapper"></div> | |
| 505 | - <?php | |
| 506 | - } | |
| 507 | - | |
| 508 | - /** | |
| 509 | 418 | * Add SMTP promotional submenu page. |
| 510 | 419 | * |
| 511 | 420 | * @return void |
| 512 | 421 | * @since 1.7.1 |
| @@ -752,8 +661,36 @@ | ||
| 752 | 661 | } |
| 753 | 662 | } |
| 754 | 663 | |
| 755 | 664 | /** |
| 665 | + * Summary of add_payments_badge | |
| 666 | + * | |
| 667 | + * @since 2.0.0 | |
| 668 | + * @return void | |
| 669 | + */ | |
| 670 | + public function add_payments_badge() { | |
| 671 | + if ( ! Helper::current_user_can() ) { | |
| 672 | + return; | |
| 673 | + } | |
| 674 | + | |
| 675 | + global $submenu; | |
| 676 | + if ( isset( $submenu['sureforms_menu'] ) ) { | |
| 677 | + foreach ( $submenu['sureforms_menu'] as $index => $sub_item ) { | |
| 678 | + if ( isset( $sub_item[2] ) && SRFM_PAYMENTS === $sub_item[2] ) { | |
| 679 | + ob_start(); | |
| 680 | + ?> | |
| 681 | + <span style="color: #4ADE80;font-size: 9px;font-weight: 600;"><?php echo esc_html__( 'New', 'sureforms' ); ?></span> | |
| 682 | + <?php | |
| 683 | + $new_badge_html = ob_get_clean(); | |
| 684 | + // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Adding notifications for submenu item. | |
| 685 | + $submenu['sureforms_menu'][ $index ][0] .= $new_badge_html; | |
| 686 | + break; | |
| 687 | + } | |
| 688 | + } | |
| 689 | + } | |
| 690 | + } | |
| 691 | + | |
| 692 | + /** | |
| 756 | 693 | * Mark the user's visit to the entries page. |
| 757 | 694 | * |
| 758 | 695 | * @since 1.7.3 |
| 759 | 696 | * @return void |
| @@ -909,57 +846,40 @@ | ||
| 909 | 846 | * List of the handles in which we need to add translation compatibility. |
| 910 | 847 | */ |
| 911 | 848 | $script_translations_handlers = []; |
| 912 | 849 | $onboarding_instance = Onboarding::get_instance(); |
| 913 | - $current_user = wp_get_current_user(); | |
| 914 | 850 | |
| 915 | 851 | $localization_data = [ |
| 916 | - 'site_url' => get_site_url(), | |
| 917 | - 'current_user_login' => $current_user->user_login ?? '', | |
| 918 | - 'website_lead_details' => [ | |
| 919 | - 'first_name' => $current_user->first_name ?? '', | |
| 920 | - 'last_name' => $current_user->last_name ?? '', | |
| 921 | - 'email' => $current_user->user_email ?? '', | |
| 922 | - ], | |
| 923 | - 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(), | |
| 924 | - 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ), | |
| 925 | - 'plugin_version' => SRFM_VER, | |
| 926 | - 'global_settings_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '', | |
| 927 | - 'is_pro_active' => Helper::has_pro(), | |
| 928 | - 'is_first_form_created' => self::is_first_form_created(), | |
| 929 | - 'check_three_days_threshold' => self::check_first_form_creation_threshold(), | |
| 930 | - 'check_eight_days_threshold' => self::check_first_form_creation_threshold( 8 ), | |
| 931 | - 'pro_plugin_version' => Helper::has_pro() ? SRFM_PRO_VER : '', | |
| 932 | - 'pro_plugin_name' => Helper::has_pro() && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro', | |
| 933 | - 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ), | |
| 934 | - 'field_spacing_vars' => Helper::get_css_vars(), | |
| 935 | - 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ), | |
| 936 | - 'integrations' => Helper::sureforms_get_integration(), | |
| 937 | - 'rotating_plugin_banner' => Helper::get_rotating_plugin_banner(), | |
| 938 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 939 | - 'sf_plugin_manager_nonce' => wp_create_nonce( 'sf_plugin_manager_nonce' ), | |
| 940 | - 'plugin_installer_nonce' => wp_create_nonce( 'updates' ), | |
| 941 | - 'plugin_activating_text' => __( 'Activating...', 'sureforms' ), | |
| 942 | - 'plugin_activated_text' => __( 'Activated', 'sureforms' ), | |
| 943 | - 'plugin_activate_text' => __( 'Activate', 'sureforms' ), | |
| 944 | - 'plugin_installing_text' => __( 'Installing...', 'sureforms' ), | |
| 945 | - 'plugin_installed_text' => __( 'Installed', 'sureforms' ), | |
| 946 | - 'privacy_policy_url' => Helper::get_sureforms_website_url( 'privacy-policy/' ), | |
| 947 | - 'is_rtl' => $is_rtl, | |
| 948 | - 'onboarding_completed' => method_exists( $onboarding_instance, 'get_onboarding_status' ) ? $onboarding_instance->get_onboarding_status() : false, | |
| 949 | - 'onboarding_redirect' => isset( $_GET['srfm-activation-redirect'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not required for the activation redirection. | |
| 950 | - 'pointer_nonce' => wp_create_nonce( 'sureforms_pointer_action' ), | |
| 951 | - 'general_settings_url' => admin_url( '/options-general.php' ), | |
| 952 | - 'additional_header_nav_items' => [], | |
| 953 | - // Smart tags for the Global Defaults email notification fields. | |
| 954 | - // srfm_block_data is only available in the block editor; these keys | |
| 955 | - // make the same data accessible on the settings page via srfm_admin. | |
| 956 | - 'smart_tags_array' => Smart_Tags::smart_tag_list(), | |
| 957 | - 'smart_tags_array_email' => Smart_Tags::email_smart_tag_list(), | |
| 958 | - // Default confirmation message HTML (icon + heading + text) used as | |
| 959 | - // the initial React state before the settings API response arrives. | |
| 960 | - 'default_confirmation_message' => Global_Settings::get_default_confirmation_message(), | |
| 961 | - 'payments' => apply_filters( | |
| 852 | + 'site_url' => get_site_url(), | |
| 853 | + 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(), | |
| 854 | + 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ), | |
| 855 | + 'plugin_version' => SRFM_VER, | |
| 856 | + 'global_settings_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '', | |
| 857 | + 'is_pro_active' => Helper::has_pro(), | |
| 858 | + 'is_first_form_created' => self::is_first_form_created(), | |
| 859 | + 'check_three_days_threshold' => self::check_first_form_creation_threshold(), | |
| 860 | + 'check_eight_days_threshold' => self::check_first_form_creation_threshold( 8 ), | |
| 861 | + 'pro_plugin_version' => Helper::has_pro() ? SRFM_PRO_VER : '', | |
| 862 | + 'pro_plugin_name' => Helper::has_pro() && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro', | |
| 863 | + 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ), | |
| 864 | + 'field_spacing_vars' => Helper::get_css_vars(), | |
| 865 | + 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ), | |
| 866 | + 'integrations' => Helper::sureforms_get_integration(), | |
| 867 | + 'rotating_plugin_banner' => Helper::get_rotating_plugin_banner(), | |
| 868 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 869 | + 'sf_plugin_manager_nonce' => wp_create_nonce( 'sf_plugin_manager_nonce' ), | |
| 870 | + 'plugin_installer_nonce' => wp_create_nonce( 'updates' ), | |
| 871 | + 'plugin_activating_text' => __( 'Activating...', 'sureforms' ), | |
| 872 | + 'plugin_activated_text' => __( 'Activated', 'sureforms' ), | |
| 873 | + 'plugin_activate_text' => __( 'Activate', 'sureforms' ), | |
| 874 | + 'plugin_installing_text' => __( 'Installing...', 'sureforms' ), | |
| 875 | + 'plugin_installed_text' => __( 'Installed', 'sureforms' ), | |
| 876 | + 'is_rtl' => $is_rtl, | |
| 877 | + 'onboarding_completed' => method_exists( $onboarding_instance, 'get_onboarding_status' ) ? $onboarding_instance->get_onboarding_status() : false, | |
| 878 | + 'onboarding_redirect' => isset( $_GET['srfm-activation-redirect'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not required for the activation redirection. | |
| 879 | + 'pointer_nonce' => wp_create_nonce( 'sureforms_pointer_action' ), | |
| 880 | + 'general_settings_url' => admin_url( '/options-general.php' ), | |
| 881 | + 'payments' => apply_filters( | |
| 962 | 882 | 'srfm_admin_localize_payments_data', |
| 963 | 883 | [ |
| 964 | 884 | 'stripe_connected' => Stripe_Helper::is_stripe_connected(), |
| 965 | 885 | 'stripe_mode' => Stripe_Helper::get_stripe_mode(), |
| @@ -973,25 +893,18 @@ | ||
| 973 | 893 | 'payment_currency' => Payment_Helper::get_currency(), |
| 974 | 894 | 'currency_sign_position' => Payment_Helper::get_currency_sign_position(), |
| 975 | 895 | ] |
| 976 | 896 | ), |
| 977 | - 'mcp_adapter_status' => file_exists( WP_PLUGIN_DIR . '/mcp-adapter/mcp-adapter.php' ) | |
| 978 | - ? ( is_plugin_active( 'mcp-adapter/mcp-adapter.php' ) ? 'active' : 'installed' ) | |
| 979 | - : 'not_installed', | |
| 980 | - 'mcp_endpoint_url' => esc_url_raw( rest_url( 'sureforms/v1/mcp' ) ), | |
| 981 | 897 | ]; |
| 982 | 898 | |
| 983 | - $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' ); | |
| 984 | - $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' ); | |
| 985 | - $is_screen_sureforms_forms = Helper::validate_request_context( 'sureforms_forms', 'page' ); | |
| 986 | - $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' ); | |
| 987 | - $is_screen_sureforms_payments = Helper::validate_request_context( 'sureforms_payments', 'page' ); | |
| 988 | - $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' ); | |
| 989 | - $is_screen_sureforms_learn = Helper::validate_request_context( 'sureforms_learn', 'page' ); | |
| 990 | - $is_screen_quiz_empty_state = Helper::validate_request_context( 'sureforms_quiz_entries', 'page' ); | |
| 991 | - $is_screen_survey_empty_state = Helper::validate_request_context( 'sureforms_survey_reports', 'page' ); | |
| 992 | - $is_screen_partial_entries_empty_state = Helper::validate_request_context( 'sureforms_partial_entries', 'page' ); | |
| 993 | - $is_post_type_sureforms_form = SRFM_FORMS_POST_TYPE === $current_screen->post_type; | |
| 899 | + $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' ); | |
| 900 | + $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' ); | |
| 901 | + $is_screen_sureforms_forms = Helper::validate_request_context( 'sureforms_forms', 'page' ); | |
| 902 | + $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' ); | |
| 903 | + $is_screen_sureforms_payments = Helper::validate_request_context( 'sureforms_payments', 'page' ); | |
| 904 | + $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' ); | |
| 905 | + $is_screen_sureforms_learn = Helper::validate_request_context( 'sureforms_learn', 'page' ); | |
| 906 | + $is_post_type_sureforms_form = SRFM_FORMS_POST_TYPE === $current_screen->post_type; | |
| 994 | 907 | |
| 995 | 908 | /** |
| 996 | 909 | * Check if the current screen is the SureForms Menu and AI Auth Email is present then we will add user type as registered. |
| 997 | 910 | * Compatibility with existing UI code that checks for this condition. |
| @@ -1002,39 +915,9 @@ | ||
| 1002 | 915 | 'type' => ! empty( get_option( 'srfm_ai_auth_user_email' ) ) ? 'registered' : 'non-registered', |
| 1003 | 916 | ]; |
| 1004 | 917 | } |
| 1005 | 918 | |
| 1006 | - // Add the Quizzes and Survey Reports nav items when pro is not active. | |
| 1007 | - if ( ! Helper::has_pro() ) { | |
| 1008 | - $localization_data['additional_header_nav_items'][] = [ | |
| 1009 | - 'slug' => 'sureforms_quiz_entries', | |
| 1010 | - 'text' => __( 'Quizzes', 'sureforms' ), | |
| 1011 | - 'link' => admin_url( 'admin.php?page=sureforms_quiz_entries' ), | |
| 1012 | - ]; | |
| 1013 | - $localization_data['additional_header_nav_items'][] = [ | |
| 1014 | - 'slug' => 'sureforms_survey_reports', | |
| 1015 | - 'text' => __( 'Survey Reports', 'sureforms' ), | |
| 1016 | - 'link' => admin_url( 'admin.php?page=sureforms_survey_reports' ), | |
| 1017 | - ]; | |
| 1018 | - $localization_data['additional_header_nav_items'][] = [ | |
| 1019 | - 'slug' => 'sureforms_partial_entries', | |
| 1020 | - 'text' => __( 'Partial Entries', 'sureforms' ), | |
| 1021 | - 'link' => admin_url( 'admin.php?page=sureforms_partial_entries' ), | |
| 1022 | - ]; | |
| 1023 | - } | |
| 1024 | - | |
| 1025 | - $is_sureforms_screen = $is_screen_sureforms_menu || $is_post_type_sureforms_form || $is_screen_add_new_form || $is_screen_sureforms_forms || $is_screen_sureforms_form_settings || $is_screen_sureforms_entries || $is_screen_sureforms_payments || $is_screen_sureforms_learn || $is_screen_quiz_empty_state || $is_screen_survey_empty_state || $is_screen_partial_entries_empty_state; | |
| 1026 | - | |
| 1027 | - /** | |
| 1028 | - * Filter to allow extending the SureForms dashboard screen check. | |
| 1029 | - * | |
| 1030 | - * @since 2.6.0 | |
| 1031 | - * | |
| 1032 | - * @param bool $is_sureforms_screen Whether the current screen is a SureForms dashboard screen. | |
| 1033 | - */ | |
| 1034 | - $is_sureforms_screen = apply_filters( 'srfm_is_dashboard_screen', $is_sureforms_screen ); | |
| 1035 | - | |
| 1036 | - if ( $is_sureforms_screen ) { | |
| 919 | + if ( $is_screen_sureforms_menu || $is_post_type_sureforms_form || $is_screen_add_new_form || $is_screen_sureforms_forms || $is_screen_sureforms_form_settings || $is_screen_sureforms_entries || $is_screen_sureforms_payments || $is_screen_sureforms_learn ) { | |
| 1037 | 920 | $asset_handle = '-dashboard'; |
| 1038 | 921 | |
| 1039 | 922 | wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER ); |
| 1040 | 923 | |
| @@ -1177,62 +1060,8 @@ | ||
| 1177 | 1060 | |
| 1178 | 1061 | $script_translations_handlers[] = SRFM_SLUG . '-suremail'; |
| 1179 | 1062 | } |
| 1180 | 1063 | |
| 1181 | - // Enqueue scripts for the Quiz empty state page (free users only). | |
| 1182 | - if ( $is_screen_quiz_empty_state && ! Helper::has_pro() ) { | |
| 1183 | - $asset_handle = 'quizEmptyState'; | |
| 1184 | - | |
| 1185 | - $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php'; | |
| 1186 | - $script_info = file_exists( $script_asset_path ) | |
| 1187 | - ? include $script_asset_path | |
| 1188 | - : [ | |
| 1189 | - 'dependencies' => [], | |
| 1190 | - 'version' => SRFM_VER, | |
| 1191 | - ]; | |
| 1192 | - | |
| 1193 | - wp_enqueue_script( SRFM_SLUG . '-quiz-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true ); | |
| 1194 | - wp_enqueue_style( SRFM_SLUG . '-quiz-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' ); | |
| 1195 | - | |
| 1196 | - $script_translations_handlers[] = SRFM_SLUG . '-quiz-empty-state'; | |
| 1197 | - } | |
| 1198 | - | |
| 1199 | - // Enqueue scripts for the Survey Reports empty state page (free users only). | |
| 1200 | - if ( $is_screen_survey_empty_state && ! Helper::has_pro() ) { | |
| 1201 | - $asset_handle = 'surveyEmptyState'; | |
| 1202 | - | |
| 1203 | - $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php'; | |
| 1204 | - $script_info = file_exists( $script_asset_path ) | |
| 1205 | - ? include $script_asset_path | |
| 1206 | - : [ | |
| 1207 | - 'dependencies' => [], | |
| 1208 | - 'version' => SRFM_VER, | |
| 1209 | - ]; | |
| 1210 | - | |
| 1211 | - wp_enqueue_script( SRFM_SLUG . '-survey-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true ); | |
| 1212 | - wp_enqueue_style( SRFM_SLUG . '-survey-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' ); | |
| 1213 | - | |
| 1214 | - $script_translations_handlers[] = SRFM_SLUG . '-survey-empty-state'; | |
| 1215 | - } | |
| 1216 | - | |
| 1217 | - // Enqueue scripts for the Partial Entries empty state page (free users only). | |
| 1218 | - if ( $is_screen_partial_entries_empty_state && ! Helper::has_pro() ) { | |
| 1219 | - $asset_handle = 'partialEntriesEmptyState'; | |
| 1220 | - | |
| 1221 | - $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php'; | |
| 1222 | - $script_info = file_exists( $script_asset_path ) | |
| 1223 | - ? include $script_asset_path | |
| 1224 | - : [ | |
| 1225 | - 'dependencies' => [], | |
| 1226 | - 'version' => SRFM_VER, | |
| 1227 | - ]; | |
| 1228 | - | |
| 1229 | - wp_enqueue_script( SRFM_SLUG . '-partial-entries-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true ); | |
| 1230 | - wp_enqueue_style( SRFM_SLUG . '-partial-entries-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' ); | |
| 1231 | - | |
| 1232 | - $script_translations_handlers[] = SRFM_SLUG . '-partial-entries-empty-state'; | |
| 1233 | - } | |
| 1234 | - | |
| 1235 | 1064 | // Admin Submenu Styles. |
| 1236 | 1065 | wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER ); |
| 1237 | 1066 | |
| 1238 | 1067 | if ( $is_screen_sureforms_form_settings ) { |
| @@ -1249,18 +1078,11 @@ | ||
| 1249 | 1078 | wp_enqueue_script( SRFM_SLUG . '-settings', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true ); |
| 1250 | 1079 | wp_localize_script( |
| 1251 | 1080 | SRFM_SLUG . '-settings', |
| 1252 | 1081 | SRFM_SLUG . '_admin', |
| 1253 | - apply_filters( | |
| 1254 | - SRFM_SLUG . '_admin_filter', | |
| 1255 | - $localization_data | |
| 1256 | - ) | |
| 1082 | + $localization_data | |
| 1257 | 1083 | ); |
| 1258 | 1084 | |
| 1259 | - // Enqueue Tailwind and Quill editor styles for the settings page. | |
| 1260 | - wp_enqueue_style( SRFM_SLUG . '-settings-build', SRFM_URL . 'assets/build/settings.css', [], SRFM_VER, 'all' ); | |
| 1261 | - wp_enqueue_style( SRFM_SLUG . '-reactQuill', SRFM_URL . 'assets/css/minified/deps/quill/quill.snow.css', [], SRFM_VER ); | |
| 1262 | - | |
| 1263 | 1085 | $script_translations_handlers[] = SRFM_SLUG . '-settings'; |
| 1264 | 1086 | } |
| 1265 | 1087 | |
| 1266 | 1088 | if ( $is_screen_add_new_form ) { |
| @@ -1694,9 +1516,9 @@ | ||
| 1694 | 1516 | wp_send_json_error( [ 'message' => __( 'Invalid parameters.', 'sureforms' ) ], 400 ); |
| 1695 | 1517 | } |
| 1696 | 1518 | |
| 1697 | 1519 | $event_name = $valid[ $notice_id ][ $button ]; |
| 1698 | - Analytics::events()->track( $event_name, $button ); | |
| 1520 | + Analytics_Events::track( $event_name, $button ); | |
| 1699 | 1521 | |
| 1700 | 1522 | wp_send_json_success(); |
| 1701 | 1523 | } |
| 1702 | 1524 | |
| @@ -2072,9 +1894,14 @@ | ||
| 2072 | 1894 | </svg> |
| 2073 | 1895 | <span><?php echo esc_html( $this->get_random_premium_feature_text() ); ?></span> |
| 2074 | 1896 | </div> |
| 2075 | 1897 | <?php |
| 2076 | - $upgrade_url = Helper::get_sureforms_website_url( 'pricing', [ 'utm_medium' => 'dashboard-widget' ] ); | |
| 1898 | + $upgrade_url = add_query_arg( | |
| 1899 | + [ | |
| 1900 | + 'utm_medium' => 'dashboard-widget', | |
| 1901 | + ], | |
| 1902 | + Helper::get_sureforms_website_url( 'pricing' ) | |
| 1903 | + ); | |
| 2077 | 1904 | ?> |
| 2078 | 1905 | <a href="<?php echo esc_url( $upgrade_url ); ?>" class="srfm-upgrade-link" target="_blank"> |
| 2079 | 1906 | <?php esc_html_e( 'Upgrade', 'sureforms' ); ?> |
| 2080 | 1907 | </a> |