PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.12.2
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.12.2
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 All 96 releases
← All changes | admin/admin.php +169 -584 2.7.11.12.2 View file →
@@ -6,24 +6,20 @@
6 6 */
7 7
8 8 namespace SRFM\Admin;
9 9
10 -use Astra_Notices;
10 +use SRFM\Admin\Views\Entries_List_Table;
11 +use SRFM\Admin\Views\Single_Entry;
11 12 use SRFM\Inc\AI_Form_Builder\AI_Helper;
12 13 use SRFM\Inc\Database\Tables\Entries;
13 14 use SRFM\Inc\Helper;
14 15 use SRFM\Inc\Onboarding;
15 -use SRFM\Inc\Payments\Payment_Helper;
16 -use SRFM\Inc\Payments\Stripe\Stripe_Helper;
16 +use SRFM\Inc\Post_Types;
17 17 use SRFM\Inc\Traits\Get_Instance;
18 18
19 19 if ( ! defined( 'ABSPATH' ) ) {
20 20 exit; // Exit if accessed directly.
21 21 }
22 -
23 -if ( ! class_exists( 'Astra_Notices' ) ) {
24 - require_once SRFM_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
25 -}
26 22 /**
27 23 * Admin handler class.
28 24 *
29 25 * @since 0.0.1
@@ -31,15 +27,8 @@
31 27 class Admin {
32 28 use Get_Instance;
33 29
34 30 /**
35 - * Minimum number of forms or entries required to show the rating notice.
36 - *
37 - * @since 2.5.2
38 - */
39 - public const RATING_NOTICE_THRESHOLD = 3;
40 -
41 - /**
42 31 * Dashboard widget entries data.
43 32 *
44 33 * @var array
45 34 * @since 1.9.1
@@ -46,16 +35,8 @@
46 35 */
47 36 private $dashboard_widget_data = [];
48 37
49 38 /**
50 - * Cached result for whether the rating notice should display.
51 - *
52 - * @var bool|null
53 - * @since 2.5.2
54 - */
55 - private $should_show_rating = null;
56 -
57 - /**
58 39 * SureForms Page Default permission.
59 40 *
60 41 * @var string
61 42 * @since 1.12.2
@@ -71,13 +52,11 @@
71 52 public function __construct() {
72 53 add_action( 'admin_menu', [ $this, 'add_menu_page' ], 9 );
73 54 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
74 55 add_action( 'admin_menu', [ $this, 'settings_page' ] );
75 - add_action( 'admin_menu', [ $this, 'add_learn_page' ] );
76 56 add_action( 'admin_menu', [ $this, 'add_new_form' ] );
77 57 add_action( 'admin_menu', [ $this, 'add_suremail_page' ] );
78 - if ( ! Helper::has_pro() ) {
79 - add_action( 'admin_menu', [ $this, 'add_quiz_page' ] );
58 + if ( ! Helper::has_pro() && self::is_first_form_created() ) {
80 59 add_action( 'admin_menu', [ $this, 'add_upgrade_to_pro' ] );
81 60 add_action( 'admin_footer', [ $this, 'add_upgrade_to_pro_target_attr' ] );
82 61 }
83 62
@@ -89,13 +68,23 @@
89 68 // this action is used to restrict Spectra's quick action bar on SureForms CPTS.
90 69 add_action( 'uag_enable_quick_action_sidebar', [ $this, 'restrict_spectra_quick_action_bar' ] );
91 70
92 71 add_action( 'current_screen', [ $this, 'enable_gutenberg_for_sureforms' ], 100 );
93 - // Register notices early for React pages (before admin_enqueue_scripts).
94 - add_action( 'admin_init', [ $this, 'register_pro_compatibility_notices' ], 5 );
95 - // Display notices on traditional WordPress admin pages.
96 72 add_action( 'admin_notices', [ $this, 'srfm_pro_version_compatibility' ] );
97 73
74 + // Handle entry actions.
75 + add_action( 'admin_init', [ $this, 'handle_entry_actions' ] );
76 + add_action( 'admin_notices', [ Entries_List_Table::class, 'display_bulk_action_notice' ] );
77 +
78 + // This action enqueues translations for NPS Survey library.
79 + // A better solution will be required from library to resolve plugin conflict.
80 + add_action(
81 + 'admin_footer',
82 + static function() {
83 + Helper::register_script_translations( 'nps-survey-script' );
84 + },
85 + 1000
86 + );
98 87 // Enfold theme compatibility to enable block editor for SureForms post type.
99 88 add_filter( 'avf_use_block_editor_for_post', [ $this, 'enable_block_editor_in_enfold_theme' ] );
100 89
101 90 // Add action links to the plugin page.
@@ -106,9 +95,8 @@
106 95
107 96 if ( $admin_notification_on ) {
108 97 add_action( 'admin_menu', [ $this, 'maybe_add_entries_badge' ], 99 );
109 98 }
110 -
111 99 add_filter( 'wpforms_current_user_can', [ $this, 'disable_wpforms_capabilities' ], 10, 3 );
112 100
113 101 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_pointer' ] );
114 102 // Ajax callbacks for wp-pointer functionality.
@@ -114,9 +102,8 @@
114 102 // Ajax callbacks for wp-pointer functionality.
115 103 add_action( 'wp_ajax_should_show_pointer', [ $this, 'pointer_should_show' ] );
116 104 add_action( 'wp_ajax_sureforms_dismiss_pointer', [ $this, 'pointer_dismissed' ] );
117 105 add_action( 'wp_ajax_sureforms_accept_cta', [ $this, 'pointer_accepted_cta' ] );
118 - add_action( 'wp_ajax_srfm_notice_response', [ $this, 'handle_notice_response' ] );
119 106
120 107 // Register dashboard widget only if there are recent entries.
121 108 add_action( 'admin_init', [ $this, 'maybe_register_dashboard_widget' ] );
122 109
@@ -121,10 +108,8 @@
121 108 add_action( 'admin_init', [ $this, 'maybe_register_dashboard_widget' ] );
122 109
123 110 // Save first form creation time stamp.
124 111 add_action( 'admin_init', [ $this, 'save_first_form_creation_time_stamp' ] );
125 - add_action( 'admin_notices', [ $this, 'display_srfm_rating_notice' ] );
126 - add_action( 'admin_notices', [ $this, 'display_srfm_getting_started_notice' ] );
127 112 }
128 113
129 114 /**
130 115 * Get the first form creation time stamp.
@@ -369,8 +354,14 @@
369 354 * @return void
370 355 * @since 1.6.1
371 356 */
372 357 public function add_upgrade_to_pro_target_attr() {
358 +
359 + // only add if first form was created more than 8 days ago.
360 + if ( ! self::check_first_form_creation_threshold( 8 ) ) {
361 + return;
362 + }
363 +
373 364 ?>
374 365 <script type="text/javascript">
375 366 document.addEventListener('DOMContentLoaded', function () {
376 367 // Upgrade link handler.
@@ -393,8 +384,14 @@
393 384 * @return void
394 385 * @since 1.6.1
395 386 */
396 387 public function add_upgrade_to_pro() {
388 +
389 + // only add if first form was created more than 8 days ago.
390 + if ( ! self::check_first_form_creation_threshold( 8 ) ) {
391 + return;
392 + }
393 +
397 394 // The url used here is used as a selector for css to style the upgrade to pro submenu.
398 395 // If you are changing this url, please make sure to update the css as well.
399 396 $upgrade_url = add_query_arg(
400 397 [
@@ -412,41 +409,8 @@
412 409 );
413 410 }
414 411
415 412 /**
416 - * Add Quiz empty state submenu page for free users.
417 - *
418 - * @return void
419 - * @since 2.7.0
420 - */
421 - public function add_quiz_page() {
422 - add_submenu_page(
423 - 'sureforms_menu',
424 - __( 'Quiz Entries', 'sureforms' ),
425 - __( 'Quizzes', 'sureforms' ) .
426 - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' .
427 - esc_html__( 'New', 'sureforms' ) .
428 - '</span>',
429 - self::$sureforms_page_default_capability,
430 - 'sureforms_quiz_entries',
431 - [ $this, 'render_quiz_empty_state' ],
432 - 5
433 - );
434 - }
435 -
436 - /**
437 - * Quiz empty state page callback.
438 - *
439 - * @return void
440 - * @since 2.7.0
441 - */
442 - public function render_quiz_empty_state() {
443 - ?>
444 - <div id="srfm-quiz-entries-root" class="srfm-admin-wrapper"></div>
445 - <?php
446 - }
447 -
448 - /**
449 413 * Add SMTP promotional submenu page.
450 414 *
451 415 * @return void
452 416 * @since 1.7.1
@@ -508,37 +472,8 @@
508 472 <?php
509 473 }
510 474
511 475 /**
512 - * Add Learn submenu page.
513 - *
514 - * @return void
515 - * @since 2.5.2
516 - */
517 - public function add_learn_page() {
518 - add_submenu_page(
519 - 'sureforms_menu',
520 - __( 'Learn', 'sureforms' ),
521 - __( 'Learn', 'sureforms' ),
522 - self::$sureforms_page_default_capability,
523 - 'sureforms_learn',
524 - [ $this, 'render_learn' ]
525 - );
526 - }
527 -
528 - /**
529 - * Learn page callback.
530 - *
531 - * @return void
532 - * @since 2.5.2
533 - */
534 - public function render_learn() {
535 - ?>
536 - <div id="srfm-learn-root" class="srfm-admin-wrapper"></div>
537 - <?php
538 - }
539 -
540 - /**
541 476 * Add new form menu item.
542 477 *
543 478 * @return void
544 479 * @since 0.0.1
@@ -545,17 +480,8 @@
545 480 */
546 481 public function add_new_form() {
547 482 add_submenu_page(
548 483 'sureforms_menu',
549 - __( 'Forms', 'sureforms' ),
550 - __( 'Forms', 'sureforms' ),
551 - self::$sureforms_page_default_capability,
552 - 'sureforms_forms',
553 - [ $this, 'render_forms' ],
554 - 1
555 - );
556 - add_submenu_page(
557 - 'sureforms_menu',
558 484 __( 'New Form', 'sureforms' ),
559 485 __( 'New Form', 'sureforms' ),
560 486 self::$sureforms_page_default_capability,
561 487 'add-new-form',
@@ -571,18 +497,8 @@
571 497 [ $this, 'render_entries' ],
572 498 3
573 499 );
574 500
575 - add_submenu_page(
576 - 'sureforms_menu',
577 - __( 'Payments', 'sureforms' ),
578 - __( 'Payments', 'sureforms' ),
579 - self::$sureforms_page_default_capability,
580 - SRFM_PAYMENTS,
581 - [ $this, 'render_payments' ],
582 - 4
583 - );
584 -
585 501 if ( $entries_hook ) {
586 502 add_action( 'load-' . $entries_hook, [ $this, 'mark_entries_page_visit' ] );
587 503 }
588 504 }
@@ -587,20 +503,8 @@
587 503 }
588 504 }
589 505
590 506 /**
591 - * Payments page callback.
592 - *
593 - * @return void
594 - * @since 2.0.0
595 - */
596 - public function render_payments() {
597 - ?>
598 - <div id="srfm-payments-react-container" class="srfm-admin-wrapper"></div>
599 - <?php
600 - }
601 -
602 - /**
603 507 * Add new form mentu item callback.
604 508 *
605 509 * @return void
606 510 * @since 0.0.1
@@ -611,28 +515,42 @@
611 515 <?php
612 516 }
613 517
614 518 /**
615 - * Forms page callback.
616 - *
617 - * @return void
618 - * @since 2.0.0
619 - */
620 - public function render_forms() {
621 - ?>
622 - <div id="srfm-forms-root" class="srfm-admin-wrapper"></div>
623 - <?php
624 - }
625 -
626 - /**
627 519 * Entries page callback.
628 520 *
629 521 * @since 0.0.13
630 - * @since 2.0.0 - Updated the entries UI and the function definition.
631 522 * @return void
632 523 */
633 524 public function render_entries() {
634 - echo '<div id="srfm-entries-root"></div>';
525 + // Render single entry view.
526 + // Adding the phpcs ignore nonce verification as no database operations are performed in this function, it is used to display the single entry view.
527 + if ( isset( $_GET['entry_id'] ) && is_numeric( $_GET['entry_id'] ) && isset( $_GET['view'] ) && 'details' === $_GET['view'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is not needed here and explained in the comments above as well.
528 + $single_entry_view = new Single_Entry();
529 + $single_entry_view->render();
530 + return;
531 + }
532 +
533 + // Render all entries view.
534 + $entries_table = new Entries_List_Table();
535 + $entries_table->prepare_items();
536 + ?>
537 + <div class="wrap">
538 + <h1 class="wp-heading-inline"><?php echo esc_html__( 'Entries', 'sureforms' ); ?></h1>
539 + <?php
540 + if ( empty( $entries_table->all_entries_count ) && empty( $entries_table->trash_entries_count ) ) {
541 + $instance = Post_Types::get_instance();
542 + $instance->sureforms_render_blank_state( SRFM_ENTRIES );
543 + $instance->get_blank_state_styles();
544 + return;
545 + }
546 + ?>
547 + <form method="get">
548 + <input type="hidden" name="page" value="sureforms_entries">
549 + <?php $entries_table->display(); ?>
550 + </form>
551 + </div>
552 + <?php
635 553 }
636 554
637 555 /**
638 556 * Add notification badge to SureForms menu when there are new entries.
@@ -840,8 +758,9 @@
840 758 global $wp_version;
841 759
842 760 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
843 761 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
762 + $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/';
844 763 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
845 764 $is_rtl = is_rtl();
846 765 $rtl = $is_rtl ? '-rtl' : '';
847 766
@@ -849,77 +768,44 @@
849 768 * List of the handles in which we need to add translation compatibility.
850 769 */
851 770 $script_translations_handlers = [];
852 771 $onboarding_instance = Onboarding::get_instance();
853 - $current_user = wp_get_current_user();
854 772
855 773 $localization_data = [
856 - 'site_url' => get_site_url(),
857 - 'current_user_login' => $current_user->user_login ?? '',
858 - 'website_lead_details' => [
859 - 'first_name' => $current_user->first_name ?? '',
860 - 'last_name' => $current_user->last_name ?? '',
861 - 'email' => $current_user->user_email ?? '',
862 - ],
863 - 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(),
864 - 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ),
865 - 'plugin_version' => SRFM_VER,
866 - 'global_settings_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '',
867 - 'is_pro_active' => Helper::has_pro(),
868 - 'is_first_form_created' => self::is_first_form_created(),
869 - 'check_three_days_threshold' => self::check_first_form_creation_threshold(),
870 - 'check_eight_days_threshold' => self::check_first_form_creation_threshold( 8 ),
871 - 'pro_plugin_version' => Helper::has_pro() ? SRFM_PRO_VER : '',
872 - 'pro_plugin_name' => Helper::has_pro() && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro',
873 - 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ),
874 - 'field_spacing_vars' => Helper::get_css_vars(),
875 - 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ),
876 - 'integrations' => Helper::sureforms_get_integration(),
877 - 'rotating_plugin_banner' => Helper::get_rotating_plugin_banner(),
878 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
879 - 'sf_plugin_manager_nonce' => wp_create_nonce( 'sf_plugin_manager_nonce' ),
880 - 'plugin_installer_nonce' => wp_create_nonce( 'updates' ),
881 - 'plugin_activating_text' => __( 'Activating...', 'sureforms' ),
882 - 'plugin_activated_text' => __( 'Activated', 'sureforms' ),
883 - 'plugin_activate_text' => __( 'Activate', 'sureforms' ),
884 - 'plugin_installing_text' => __( 'Installing...', 'sureforms' ),
885 - 'plugin_installed_text' => __( 'Installed', 'sureforms' ),
886 - 'privacy_policy_url' => Helper::get_sureforms_website_url( 'privacy-policy/' ),
887 - 'is_rtl' => $is_rtl,
888 - 'onboarding_completed' => method_exists( $onboarding_instance, 'get_onboarding_status' ) ? $onboarding_instance->get_onboarding_status() : false,
889 - 'onboarding_redirect' => isset( $_GET['srfm-activation-redirect'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not required for the activation redirection.
890 - 'pointer_nonce' => wp_create_nonce( 'sureforms_pointer_action' ),
891 - 'general_settings_url' => admin_url( '/options-general.php' ),
892 - 'additional_header_nav_items' => [],
893 - 'payments' => apply_filters(
894 - 'srfm_admin_localize_payments_data',
895 - [
896 - 'stripe_connected' => Stripe_Helper::is_stripe_connected(),
897 - 'stripe_mode' => Stripe_Helper::get_stripe_mode(),
898 - 'stripe_connect_url' => Stripe_Helper::get_stripe_settings_url(),
899 - 'currencies_data' => Payment_Helper::get_all_currencies_data(),
900 - 'zero_decimal_currencies' => Payment_Helper::get_zero_decimal_currencies(),
901 - 'webhook_url' => Stripe_Helper::get_webhook_url(),
902 - 'webhook_test_connected' => Stripe_Helper::is_webhook_configured( 'test', true ),
903 - 'webhook_live_connected' => Stripe_Helper::is_webhook_configured( 'live', true ),
904 - 'is_transaction_present' => Stripe_Helper::is_transaction_present(),
905 - 'payment_currency' => Payment_Helper::get_currency(),
906 - 'currency_sign_position' => Payment_Helper::get_currency_sign_position(),
907 - ]
908 - ),
909 - 'mcp_adapter_status' => file_exists( WP_PLUGIN_DIR . '/mcp-adapter/mcp-adapter.php' )
910 - ? ( is_plugin_active( 'mcp-adapter/mcp-adapter.php' ) ? 'active' : 'installed' )
911 - : 'not_installed',
774 + 'site_url' => get_site_url(),
775 + 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(),
776 + 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ),
777 + 'plugin_version' => SRFM_VER,
778 + 'global_settings_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '',
779 + 'is_pro_active' => Helper::has_pro(),
780 + 'is_first_form_created' => self::is_first_form_created(),
781 + 'check_three_days_threshold' => self::check_first_form_creation_threshold(),
782 + 'check_eight_days_threshold' => self::check_first_form_creation_threshold( 8 ),
783 + 'pro_plugin_version' => Helper::has_pro() ? SRFM_PRO_VER : '',
784 + 'pro_plugin_name' => Helper::has_pro() && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro',
785 + 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ),
786 + 'field_spacing_vars' => Helper::get_css_vars(),
787 + 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ),
788 + 'integrations' => Helper::sureforms_get_integration(),
789 + 'ajax_url' => admin_url( 'admin-ajax.php' ),
790 + 'sf_plugin_manager_nonce' => wp_create_nonce( 'sf_plugin_manager_nonce' ),
791 + 'plugin_installer_nonce' => wp_create_nonce( 'updates' ),
792 + 'plugin_activating_text' => __( 'Activating...', 'sureforms' ),
793 + 'plugin_activated_text' => __( 'Activated', 'sureforms' ),
794 + 'plugin_activate_text' => __( 'Activate', 'sureforms' ),
795 + 'plugin_installing_text' => __( 'Installing...', 'sureforms' ),
796 + 'plugin_installed_text' => __( 'Installed', 'sureforms' ),
797 + 'is_rtl' => $is_rtl,
798 + 'onboarding_completed' => method_exists( $onboarding_instance, 'get_onboarding_status' ) ? $onboarding_instance->get_onboarding_status() : false,
799 + 'onboarding_redirect' => isset( $_GET['srfm-activation-redirect'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not required for the activation redirection.
800 + 'pointer_nonce' => wp_create_nonce( 'sureforms_pointer_action' ),
801 + 'general_settings_url' => admin_url( '/options-general.php' ),
912 802 ];
913 803
914 804 $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' );
915 805 $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' );
916 - $is_screen_sureforms_forms = Helper::validate_request_context( 'sureforms_forms', 'page' );
917 806 $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' );
918 - $is_screen_sureforms_payments = Helper::validate_request_context( 'sureforms_payments', 'page' );
919 807 $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' );
920 - $is_screen_sureforms_learn = Helper::validate_request_context( 'sureforms_learn', 'page' );
921 - $is_screen_quiz_empty_state = Helper::validate_request_context( 'sureforms_quiz_entries', 'page' );
922 808 $is_post_type_sureforms_form = SRFM_FORMS_POST_TYPE === $current_screen->post_type;
923 809
924 810 /**
925 811 * Check if the current screen is the SureForms Menu and AI Auth Email is present then we will add user type as registered.
@@ -931,29 +817,9 @@
931 817 'type' => ! empty( get_option( 'srfm_ai_auth_user_email' ) ) ? 'registered' : 'non-registered',
932 818 ];
933 819 }
934 820
935 - // Add the Quizzes nav item to the header when pro is not active.
936 - if ( ! Helper::has_pro() ) {
937 - $localization_data['additional_header_nav_items'][] = [
938 - 'slug' => 'sureforms_quiz_entries',
939 - 'text' => __( 'Quizzes', 'sureforms' ),
940 - 'link' => admin_url( 'admin.php?page=sureforms_quiz_entries' ),
941 - ];
942 - }
943 -
944 - $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;
945 -
946 - /**
947 - * Filter to allow extending the SureForms dashboard screen check.
948 - *
949 - * @since 2.6.0
950 - *
951 - * @param bool $is_sureforms_screen Whether the current screen is a SureForms dashboard screen.
952 - */
953 - $is_sureforms_screen = apply_filters( 'srfm_is_dashboard_screen', $is_sureforms_screen );
954 -
955 - if ( $is_sureforms_screen ) {
821 + if ( $is_screen_sureforms_menu || $is_post_type_sureforms_form || $is_screen_add_new_form || $is_screen_sureforms_form_settings || $is_screen_sureforms_entries ) {
956 822 $asset_handle = '-dashboard';
957 823
958 824 wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER );
959 825
@@ -981,9 +847,9 @@
981 847 update_option( 'srfm_pro_license_status', $current_license_status );
982 848 }
983 849 }
984 850
985 - $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings&subpage=recaptcha' );
851 + $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings' );
986 852 $localization_data['integration_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=integration-settings' );
987 853 wp_localize_script(
988 854 SRFM_SLUG . $asset_handle,
989 855 SRFM_SLUG . '_admin',
@@ -992,11 +858,12 @@
992 858 $localization_data
993 859 )
994 860 );
995 861 wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' );
862 +
996 863 }
997 864
998 - if ( $is_screen_sureforms_form_settings || $is_screen_sureforms_forms ) {
865 + if ( $is_screen_sureforms_form_settings ) {
999 866 wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1000 867 }
1001 868
1002 869 // Enqueue styles for the entries page.
@@ -1003,61 +870,11 @@
1003 870 if ( $is_screen_sureforms_entries ) {
1004 871 $asset_handle = '-entries';
1005 872 wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/entries.js', $script_info['dependencies'], SRFM_VER, true );
1006 873
1007 - wp_localize_script(
1008 - SRFM_SLUG . $asset_handle,
1009 - SRFM_SLUG . '_admin',
1010 - apply_filters(
1011 - SRFM_SLUG . '_admin_filter',
1012 - $localization_data
1013 - )
1014 - );
1015 874 $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1016 875 }
1017 876
1018 - // Enqueue scripts for the learn page.
1019 - if ( $is_screen_sureforms_learn ) {
1020 - $asset_handle = '-learn';
1021 - wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/learn.js', $script_info['dependencies'], SRFM_VER, true );
1022 -
1023 - wp_localize_script(
1024 - SRFM_SLUG . $asset_handle,
1025 - SRFM_SLUG . '_admin',
1026 - apply_filters(
1027 - SRFM_SLUG . '_admin_filter',
1028 - $localization_data
1029 - )
1030 - );
1031 - $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1032 - }
1033 -
1034 - // Enqueue scripts for the forms page.
1035 - if ( $is_screen_sureforms_forms ) {
1036 - $asset_handle = '-forms';
1037 -
1038 - $script_asset_path = SRFM_DIR . 'assets/build/forms.asset.php';
1039 - $script_info = file_exists( $script_asset_path )
1040 - ? include $script_asset_path
1041 - : [
1042 - 'dependencies' => [],
1043 - 'version' => SRFM_VER,
1044 - ];
1045 -
1046 - wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.js', $script_info['dependencies'], SRFM_VER, true );
1047 - wp_localize_script(
1048 - SRFM_SLUG . $asset_handle,
1049 - SRFM_SLUG . '_admin',
1050 - apply_filters(
1051 - SRFM_SLUG . '_admin_filter',
1052 - $localization_data
1053 - )
1054 - );
1055 - wp_enqueue_style( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.css', [], SRFM_VER, 'all' );
1056 -
1057 - $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1058 - }
1059 -
1060 877 // Enqueue scripts for the SureMail promotional page.
1061 878 $is_screen_sureforms_smtp = Helper::validate_request_context( 'sureforms_smtp', 'page' );
1062 879 if ( $is_screen_sureforms_smtp ) {
1063 880 $asset_handle = 'suremail';
@@ -1096,29 +913,27 @@
1096 913
1097 914 $script_translations_handlers[] = SRFM_SLUG . '-suremail';
1098 915 }
1099 916
1100 - // Enqueue scripts for the Quiz empty state page (free users only).
1101 - if ( $is_screen_quiz_empty_state && ! Helper::has_pro() ) {
1102 - $asset_handle = 'quizEmptyState';
917 + // Admin Submenu Styles.
918 + wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1103 919
920 + if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) {
921 + $asset_handle = 'page_header';
922 +
1104 923 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
1105 924 $script_info = file_exists( $script_asset_path )
1106 - ? include $script_asset_path
1107 - : [
1108 - 'dependencies' => [],
1109 - 'version' => SRFM_VER,
1110 - ];
925 + ? include $script_asset_path
926 + : [
927 + 'dependencies' => [],
928 + 'version' => SRFM_VER,
929 + ];
930 + wp_enqueue_script( SRFM_SLUG . '-form-page-header', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
931 + wp_enqueue_style( SRFM_SLUG . '-form-archive-styles', $css_uri . 'form-archive-styles' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1111 932
1112 - wp_enqueue_script( SRFM_SLUG . '-quiz-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1113 - wp_enqueue_style( SRFM_SLUG . '-quiz-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' );
1114 -
1115 - $script_translations_handlers[] = SRFM_SLUG . '-quiz-empty-state';
933 + $script_translations_handlers[] = SRFM_SLUG . '-form-page-header';
1116 934 }
1117 935
1118 - // Admin Submenu Styles.
1119 - wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1120 -
1121 936 if ( $is_screen_sureforms_form_settings ) {
1122 937 $asset_handle = 'settings';
1123 938
1124 939 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
@@ -1132,17 +947,42 @@
1132 947 wp_enqueue_script( SRFM_SLUG . '-settings', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1133 948 wp_localize_script(
1134 949 SRFM_SLUG . '-settings',
1135 950 SRFM_SLUG . '_admin',
1136 - apply_filters(
1137 - SRFM_SLUG . '_admin_filter',
1138 - $localization_data
1139 - )
951 + $localization_data
1140 952 );
1141 953
1142 954 $script_translations_handlers[] = SRFM_SLUG . '-settings';
1143 955 }
956 + if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) {
957 + wp_enqueue_script( SRFM_SLUG . '-form-archive', $js_uri . 'form-archive' . $file_prefix . '.js', [], SRFM_VER, true );
958 + wp_enqueue_script( SRFM_SLUG . '-export', $js_uri . 'export' . $file_prefix . '.js', [ 'wp-i18n' ], SRFM_VER, true );
959 + wp_localize_script(
960 + SRFM_SLUG . '-export',
961 + SRFM_SLUG . '_export',
962 + [
963 + 'ajaxurl' => admin_url( 'admin-ajax.php' ),
964 + 'srfm_export_nonce' => wp_create_nonce( 'export_form_nonce' ),
965 + 'site_url' => get_site_url(),
966 + 'import_form_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '',
967 + 'import_btn_string' => __( 'Import Form', 'sureforms' ),
968 + ]
969 + );
1144 970
971 + wp_enqueue_script( SRFM_SLUG . '-backend', $js_uri . 'backend' . $file_prefix . '.js', [], SRFM_VER, true );
972 + wp_localize_script(
973 + SRFM_SLUG . '-backend',
974 + SRFM_SLUG . '_backend',
975 + [
976 + 'site_url' => get_site_url(),
977 + ]
978 + );
979 +
980 + $script_translations_handlers[] = SRFM_SLUG . '-form-archive';
981 + $script_translations_handlers[] = SRFM_SLUG . '-export';
982 + $script_translations_handlers[] = SRFM_SLUG . '-backend';
983 + }
984 +
1145 985 if ( $is_screen_add_new_form ) {
1146 986 wp_enqueue_style( SRFM_SLUG . '-template-picker', $css_uri . 'template-picker' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1147 987
1148 988 $sureforms_admin = 'templatePicker';
@@ -1187,9 +1027,8 @@
1187 1027 'srfm/checkbox',
1188 1028 'srfm/number',
1189 1029 'srfm/inline-button',
1190 1030 'srfm/advanced-heading',
1191 - 'srfm/payment',
1192 1031 ]
1193 1032 );
1194 1033 if ( ! is_array( $default_allowed_quick_sidebar_blocks ) ) {
1195 1034 $default_allowed_quick_sidebar_blocks = [];
@@ -1201,25 +1040,22 @@
1201 1040 }
1202 1041 $quick_sidebar_allowed_blocks = get_option( 'srfm_quick_sidebar_allowed_blocks' );
1203 1042 $quick_sidebar_allowed_blocks = ! empty( $quick_sidebar_allowed_blocks ) && is_array( $quick_sidebar_allowed_blocks ) ? $quick_sidebar_allowed_blocks : $default_allowed_quick_sidebar_blocks;
1204 1043 $srfm_ajax_nonce = wp_create_nonce( 'srfm_ajax_nonce' );
1044 + wp_enqueue_script( SRFM_SLUG . '-quick-action-siderbar', SRFM_URL . 'assets/build/quickActionSidebar.js', [], SRFM_VER, true );
1045 + wp_localize_script(
1046 + SRFM_SLUG . '-quick-action-siderbar',
1047 + SRFM_SLUG . '_quick_sidebar_blocks',
1048 + [
1049 + 'allowed_blocks' => $quick_sidebar_allowed_blocks,
1050 + 'srfm_enable_quick_action_sidebar' => $srfm_enable_quick_action_sidebar,
1051 + 'srfm_ajax_nonce' => $srfm_ajax_nonce,
1052 + 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ),
1053 + ]
1054 + );
1205 1055
1206 - if ( Helper::is_sureforms_admin_page() ) {
1207 - wp_enqueue_script( SRFM_SLUG . '-quick-action-siderbar', SRFM_URL . 'assets/build/quickActionSidebar.js', [], SRFM_VER, true );
1208 - wp_localize_script(
1209 - SRFM_SLUG . '-quick-action-siderbar',
1210 - SRFM_SLUG . '_quick_sidebar_blocks',
1211 - [
1212 - 'allowed_blocks' => $quick_sidebar_allowed_blocks,
1213 - 'srfm_enable_quick_action_sidebar' => $srfm_enable_quick_action_sidebar,
1214 - 'srfm_ajax_nonce' => $srfm_ajax_nonce,
1215 - 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ),
1216 - ]
1217 - );
1056 + $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar';
1218 1057
1219 - $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar';
1220 - }
1221 -
1222 1058 /**
1223 1059 * Enqueuing SureTriggers Integration script.
1224 1060 * This script loads suretriggers iframe in Intergations tab.
1225 1061 */
@@ -1291,53 +1127,40 @@
1291 1127
1292 1128 return $status;
1293 1129 }
1294 1130
1131 + // Entries methods.
1132 +
1295 1133 /**
1296 - * Register Pro compatibility notices early for React pages.
1134 + * Handle entry actions.
1297 1135 *
1298 - * This method runs on admin_init (priority 5) to ensure notices are
1299 - * registered BEFORE admin_enqueue_scripts, so they're available when
1300 - * wp_localize_script runs.
1301 - *
1302 - * Hooked - admin_init (priority 5)
1303 - *
1136 + * @since 0.0.13
1304 1137 * @return void
1305 - * @since 2.5.0
1306 1138 */
1307 - public function register_pro_compatibility_notices() {
1308 - // Early exit if Pro is not active, user lacks permissions, or Notice_Manager is unavailable.
1309 - if ( ! Helper::has_pro() || ! Helper::current_user_can() || ! class_exists( 'SRFM\Admin\Notice_Manager' ) ) {
1139 + public function handle_entry_actions() {
1140 + Entries_List_Table::process_bulk_actions();
1141 +
1142 + if ( ! isset( $_GET['page'] ) || SRFM_ENTRIES !== $_GET['page'] ) {
1310 1143 return;
1311 1144 }
1312 -
1313 - // Register version outdated notice for React pages.
1314 - if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
1315 - $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
1316 - $react_outdated_message = sprintf(
1317 - // translators: %1$s: SureForms version, %2$s: SureForms Pro Plugin Name, %3$s: SureForms Pro Version.
1318 - esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version.', 'sureforms' ),
1319 - esc_html( SRFM_VER ),
1320 - esc_html( $pro_plugin_name ),
1321 - esc_html( SRFM_PRO_RECOMMENDED_VER )
1322 - );
1323 -
1324 - \SRFM\Admin\Notice_Manager::register_notice(
1325 - [
1326 - 'id' => 'sureforms-pro-version-outdated',
1327 - 'variant' => 'warning',
1328 - 'message' => $react_outdated_message,
1329 - 'actions' => [
1330 - [
1331 - 'label' => esc_html__( 'Update Now', 'sureforms' ),
1332 - 'url' => admin_url( 'update-core.php' ),
1333 - 'variant' => 'primary',
1334 - ],
1335 - ],
1336 - 'pages' => [ 'all' ],
1337 - ]
1338 - );
1145 + if ( ! isset( $_GET['entry_id'] ) || ! isset( $_GET['action'] ) ) {
1146 + return;
1339 1147 }
1148 + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'srfm_entries_action' ) ) {
1149 + wp_die( esc_html__( 'Nonce verification failed.', 'sureforms' ) );
1150 + }
1151 + $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
1152 + $entry_id = Helper::get_integer_value( sanitize_text_field( wp_unslash( $_GET['entry_id'] ) ) );
1153 + $view = isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : '';
1154 + if ( $entry_id > 0 ) {
1155 + if ( 'read' === $action && 'details' === $view ) {
1156 + $entry_status = Entries::get( $entry_id )['status'];
1157 + if ( 'trash' === $entry_status ) {
1158 + wp_die( esc_html__( 'You cannot view this entry because it is in trash.', 'sureforms' ) );
1159 + }
1160 + }
1161 + Entries_List_Table::handle_entry_status( $entry_id, $action, $view );
1162 + }
1340 1163 }
1341 1164
1342 1165 /**
1343 1166 * Admin Notice Callback if sureforms pro is out of date.
@@ -1419,168 +1242,8 @@
1419 1242 }
1420 1243 }
1421 1244
1422 1245 /**
1423 - * Display a notice to the user about providing a review.
1424 - *
1425 - * @since 2.5.2
1426 - * @return void
1427 - */
1428 - public function display_srfm_rating_notice() {
1429 - // Only show to admins.
1430 - if ( ! Helper::current_user_can() ) {
1431 - return;
1432 - }
1433 -
1434 - // Allow the notice to be disabled.
1435 - if ( ! apply_filters( 'srfm_show_rating_notice', true ) ) {
1436 - return;
1437 - }
1438 -
1439 - Astra_Notices::add_notice(
1440 - [
1441 - 'id' => 'srfm-plugin-review-notice',
1442 - 'type' => '',
1443 - 'message' => $this->build_notice_markup(
1444 - esc_html__( 'Amazing! SureForms is powering your forms and submissions - let\'s keep growing together!', 'sureforms' ),
1445 - esc_html__( 'If SureForms has been helpful, would you mind taking a moment to leave a 5-star review on WordPress.org?', 'sureforms' ),
1446 - esc_url( 'https://wordpress.org/support/plugin/sureforms/reviews/?filter=5#new-post' ),
1447 - esc_html__( 'Rate SureForms', 'sureforms' ),
1448 - esc_html__( 'Maybe later', 'sureforms' ),
1449 - esc_html__( 'I already did', 'sureforms' ),
1450 - WEEK_IN_SECONDS,
1451 - true
1452 - ),
1453 - 'repeat-notice-after' => WEEK_IN_SECONDS,
1454 - 'show_if' => $this->maybe_display_rating_notice(),
1455 - 'display-with-other-notices' => true,
1456 - ]
1457 - );
1458 -
1459 - add_action( 'astra_notice_after_markup_srfm-plugin-review-notice', [ $this, 'enqueue_notice_response_script' ] );
1460 - }
1461 -
1462 - /**
1463 - * Display a "Getting Started" admin notice for new users who haven't yet
1464 - * reached the rating-notice milestone (3+ forms or 3+ entries).
1465 - *
1466 - * The Astra Notices library handles the 7-day delay via the
1467 - * `display-notice-after` parameter.
1468 - *
1469 - * @since 2.5.2
1470 - * @return void
1471 - */
1472 - public function display_srfm_getting_started_notice() {
1473 - // Only show to admins.
1474 - if ( ! Helper::current_user_can() ) {
1475 - return;
1476 - }
1477 -
1478 - // Allow the notice to be disabled programmatically.
1479 - if ( ! apply_filters( 'srfm_show_getting_started_notice', true ) ) {
1480 - return;
1481 - }
1482 -
1483 - Astra_Notices::add_notice(
1484 - [
1485 - 'id' => 'srfm-getting-started-notice',
1486 - 'type' => '',
1487 - 'message' => $this->build_notice_markup(
1488 - esc_html__( 'SureForms is ready to power your forms — explore what\'s possible!', 'sureforms' ),
1489 - esc_html__( 'Manage your forms, track submissions, and discover features like AI Form Builder, payment integrations, and more from the SureForms dashboard.', 'sureforms' ),
1490 - esc_url( admin_url( 'admin.php?page=sureforms_menu' ) ),
1491 - esc_html__( 'Go to Dashboard', 'sureforms' ),
1492 - esc_html__( 'Maybe later', 'sureforms' ),
1493 - esc_html__( 'I already know', 'sureforms' ),
1494 - WEEK_IN_SECONDS
1495 - ),
1496 - 'repeat-notice-after' => WEEK_IN_SECONDS,
1497 - 'show_if' => ! $this->maybe_display_rating_notice(),
1498 - 'display-notice-after' => WEEK_IN_SECONDS,
1499 - 'display-with-other-notices' => true,
1500 - ]
1501 - );
1502 -
1503 - add_action( 'astra_notice_after_markup_srfm-getting-started-notice', [ $this, 'enqueue_notice_response_script' ] );
1504 - }
1505 -
1506 - /**
1507 - * Enqueue the notice response analytics script.
1508 - *
1509 - * Called via the astra_notice_after_markup_{id} hook so the script
1510 - * only loads when a SureForms notice is actually rendered.
1511 - *
1512 - * @since 2.5.2
1513 - * @return void
1514 - */
1515 - public function enqueue_notice_response_script() {
1516 - if ( wp_script_is( 'srfm-notice-response', 'enqueued' ) ) {
1517 - return;
1518 - }
1519 -
1520 - wp_enqueue_script(
1521 - 'srfm-notice-response',
1522 - SRFM_URL . 'admin/assets/js/notice-response.js',
1523 - [],
1524 - SRFM_VER,
1525 - true
1526 - );
1527 -
1528 - wp_localize_script(
1529 - 'srfm-notice-response',
1530 - 'srfmNoticeResponse',
1531 - [
1532 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1533 - 'nonce' => wp_create_nonce( 'srfm_notice_response' ),
1534 - ]
1535 - );
1536 - }
1537 -
1538 - /**
1539 - * Handle the notice response AJAX request.
1540 - *
1541 - * Validates the request and records the analytics event
1542 - * for the notice button that was clicked.
1543 - *
1544 - * @since 2.5.2
1545 - * @return void
1546 - */
1547 - public function handle_notice_response() {
1548 - if ( ! check_ajax_referer( 'srfm_notice_response', 'nonce', false ) ) {
1549 - wp_send_json_error( [ 'message' => __( 'Invalid nonce.', 'sureforms' ) ], 403 );
1550 - }
1551 -
1552 - if ( ! Helper::current_user_can() ) {
1553 - wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1554 - }
1555 -
1556 - $notice_id = isset( $_POST['notice_id'] ) ? sanitize_text_field( wp_unslash( $_POST['notice_id'] ) ) : '';
1557 - $button = isset( $_POST['button'] ) ? sanitize_text_field( wp_unslash( $_POST['button'] ) ) : '';
1558 -
1559 - $valid = [
1560 - 'srfm-getting-started-notice' => [
1561 - 'go_to_dashboard' => 'getting_started_notice_cta',
1562 - 'maybe_later' => 'getting_started_notice_snooze',
1563 - 'dismissed' => 'getting_started_notice_dismiss',
1564 - ],
1565 - 'srfm-plugin-review-notice' => [
1566 - 'rate_sureforms' => 'rating_notice_cta',
1567 - 'maybe_later' => 'rating_notice_snooze',
1568 - 'dismissed' => 'rating_notice_dismiss',
1569 - ],
1570 - ];
1571 -
1572 - if ( ! isset( $valid[ $notice_id ][ $button ] ) ) {
1573 - wp_send_json_error( [ 'message' => __( 'Invalid parameters.', 'sureforms' ) ], 400 );
1574 - }
1575 -
1576 - $event_name = $valid[ $notice_id ][ $button ];
1577 - Analytics::events()->track( $event_name, $button );
1578 -
1579 - wp_send_json_success();
1580 - }
1581 -
1582 - /**
1583 1246 * Disables the capabilities for WPForms to avoid conflicts when enqueueing
1584 1247 * scripts and styles for WPForms.
1585 1248 *
1586 1249 * This function is intended to prevent any potential conflicts that may arise
@@ -1807,86 +1470,8 @@
1807 1470 $this->render_dashboard_widget_footer( $entries_data );
1808 1471 ?>
1809 1472 </div>
1810 1473 <?php
1811 - }
1812 -
1813 - /**
1814 - * Build the shared HTML markup for admin notices.
1815 - *
1816 - * @since 2.5.2
1817 - *
1818 - * All text parameters must be pre-escaped by the caller (e.g. via esc_html__()).
1819 - * URL parameters must be pre-escaped via esc_url().
1820 - *
1821 - * @param string $heading The notice heading text (pre-escaped).
1822 - * @param string $message The notice body text (pre-escaped).
1823 - * @param string $cta_url The primary CTA URL (pre-escaped).
1824 - * @param string $cta_text The primary CTA button text (pre-escaped).
1825 - * @param string $snooze_text The snooze button text (pre-escaped).
1826 - * @param string $dismiss_text The dismiss button text (pre-escaped).
1827 - * @param int $snooze_duration Snooze duration in seconds for the data-repeat-notice-after attribute.
1828 - * @param bool $external_cta Whether the CTA opens in a new tab and also dismisses the notice
1829 - * via the astra-notice-close class. Default false.
1830 - * @return string The notice HTML markup.
1831 - */
1832 - private function build_notice_markup( $heading, $message, $cta_url, $cta_text, $snooze_text, $dismiss_text, $snooze_duration, $external_cta = false ) {
1833 - $image_path = esc_url( SRFM_URL . 'admin/assets/sureforms-logo.png' );
1834 - $cta_class = $external_cta ? 'astra-notice-close button-primary' : 'button-primary';
1835 - $cta_attrs = $external_cta ? ' target="_blank" rel="noopener noreferrer"' : '';
1836 -
1837 - return sprintf(
1838 - '<div class="notice-image">
1839 - <img src="%1$s" class="custom-logo" alt="SureForms" itemprop="logo">
1840 - </div>
1841 - <div class="notice-content">
1842 - <div class="notice-heading">
1843 - %2$s
1844 - </div>
1845 - %3$s<br />
1846 - <div class="astra-review-notice-container">
1847 - <a href="%4$s" class="%5$s"%6$s>
1848 - %7$s
1849 - </a>
1850 - <span class="dashicons dashicons-clock" aria-hidden="true"></span>
1851 - <a href="#" data-repeat-notice-after="%8$s" class="astra-notice-close">
1852 - %9$s
1853 - </a>
1854 - <span class="dashicons dashicons-smiley" aria-hidden="true"></span>
1855 - <a href="#" class="astra-notice-close">
1856 - %10$s
1857 - </a>
1858 - </div>
1859 - </div>',
1860 - $image_path,
1861 - $heading,
1862 - $message,
1863 - $cta_url,
1864 - esc_attr( $cta_class ),
1865 - $cta_attrs,
1866 - $cta_text,
1867 - $snooze_duration,
1868 - $snooze_text,
1869 - $dismiss_text
1870 - );
1871 - }
1872 -
1873 - /**
1874 - * Callback for displaying the rating notice conditionally.
1875 - *
1876 - * Returns true if the user has 3 or more published forms or 3 or more form entries.
1877 - *
1878 - * @since 2.5.2
1879 - * @return bool
1880 - */
1881 - private function maybe_display_rating_notice() {
1882 - if ( null === $this->should_show_rating ) {
1883 - $entries_count = Entries::get_total_entries_by_status( 'all' );
1884 - $form_count = wp_count_posts( SRFM_FORMS_POST_TYPE );
1885 - $this->should_show_rating = $entries_count >= self::RATING_NOTICE_THRESHOLD || Helper::get_integer_value( $form_count->publish ?? 0 ) >= self::RATING_NOTICE_THRESHOLD;
1886 - }
1887 -
1888 - return $this->should_show_rating;
1889 1474 }
1890 1475
1891 1476 /**
1892 1477 * Get random premium feature text.