PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.10.0
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.10.0
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 +222 -938 2.10.11.10.0 View file →
@@ -6,26 +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 -use SRFM\Inc\Global_Settings\Global_Settings;
14 14 use SRFM\Inc\Helper;
15 15 use SRFM\Inc\Onboarding;
16 -use SRFM\Inc\Payments\Payment_Helper;
17 -use SRFM\Inc\Payments\Stripe\Stripe_Helper;
18 -use SRFM\Inc\Smart_Tags;
16 +use SRFM\Inc\Post_Types;
19 17 use SRFM\Inc\Traits\Get_Instance;
20 18
21 19 if ( ! defined( 'ABSPATH' ) ) {
22 20 exit; // Exit if accessed directly.
23 21 }
24 -
25 -if ( ! class_exists( 'BSF_Admin_Notices' ) ) {
26 - require_once SRFM_DIR . 'inc/lib/astra-notices/class-bsf-admin-notices.php';
27 -}
28 22 /**
29 23 * Admin handler class.
30 24 *
31 25 * @since 0.0.1
@@ -33,15 +27,8 @@
33 27 class Admin {
34 28 use Get_Instance;
35 29
36 30 /**
37 - * Minimum number of forms or entries required to show the rating notice.
38 - *
39 - * @since 2.5.2
40 - */
41 - public const RATING_NOTICE_THRESHOLD = 3;
42 -
43 - /**
44 31 * Dashboard widget entries data.
45 32 *
46 33 * @var array
47 34 * @since 1.9.1
@@ -48,24 +35,8 @@
48 35 */
49 36 private $dashboard_widget_data = [];
50 37
51 38 /**
52 - * Cached result for whether the rating notice should display.
53 - *
54 - * @var bool|null
55 - * @since 2.5.2
56 - */
57 - private $should_show_rating = null;
58 -
59 - /**
60 - * SureForms Page Default permission.
61 - *
62 - * @var string
63 - * @since 1.12.2
64 - */
65 - private static $sureforms_page_default_capability = 'manage_options';
66 -
67 - /**
68 39 * Class constructor.
69 40 *
70 41 * @return void
71 42 * @since 0.0.1
@@ -73,15 +44,11 @@
73 44 public function __construct() {
74 45 add_action( 'admin_menu', [ $this, 'add_menu_page' ], 9 );
75 46 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
76 47 add_action( 'admin_menu', [ $this, 'settings_page' ] );
77 - add_action( 'admin_menu', [ $this, 'add_learn_page' ] );
78 48 add_action( 'admin_menu', [ $this, 'add_new_form' ] );
79 49 add_action( 'admin_menu', [ $this, 'add_suremail_page' ] );
80 50 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 51 add_action( 'admin_menu', [ $this, 'add_upgrade_to_pro' ] );
85 52 add_action( 'admin_footer', [ $this, 'add_upgrade_to_pro_target_attr' ] );
86 53 }
87 54
@@ -93,13 +60,23 @@
93 60 // this action is used to restrict Spectra's quick action bar on SureForms CPTS.
94 61 add_action( 'uag_enable_quick_action_sidebar', [ $this, 'restrict_spectra_quick_action_bar' ] );
95 62
96 63 add_action( 'current_screen', [ $this, 'enable_gutenberg_for_sureforms' ], 100 );
97 - // Register notices early for React pages (before admin_enqueue_scripts).
98 - add_action( 'admin_init', [ $this, 'register_pro_compatibility_notices' ], 5 );
99 - // Display notices on traditional WordPress admin pages.
100 64 add_action( 'admin_notices', [ $this, 'srfm_pro_version_compatibility' ] );
101 65
66 + // Handle entry actions.
67 + add_action( 'admin_init', [ $this, 'handle_entry_actions' ] );
68 + add_action( 'admin_notices', [ Entries_List_Table::class, 'display_bulk_action_notice' ] );
69 +
70 + // This action enqueues translations for NPS Survey library.
71 + // A better solution will be required from library to resolve plugin conflict.
72 + add_action(
73 + 'admin_footer',
74 + static function() {
75 + Helper::register_script_translations( 'nps-survey-script' );
76 + },
77 + 1000
78 + );
102 79 // Enfold theme compatibility to enable block editor for SureForms post type.
103 80 add_filter( 'avf_use_block_editor_for_post', [ $this, 'enable_block_editor_in_enfold_theme' ] );
104 81
105 82 // Add action links to the plugin page.
@@ -110,9 +87,8 @@
110 87
111 88 if ( $admin_notification_on ) {
112 89 add_action( 'admin_menu', [ $this, 'maybe_add_entries_badge' ], 99 );
113 90 }
114 -
115 91 add_filter( 'wpforms_current_user_can', [ $this, 'disable_wpforms_capabilities' ], 10, 3 );
116 92
117 93 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_pointer' ] );
118 94 // Ajax callbacks for wp-pointer functionality.
@@ -118,113 +94,14 @@
118 94 // Ajax callbacks for wp-pointer functionality.
119 95 add_action( 'wp_ajax_should_show_pointer', [ $this, 'pointer_should_show' ] );
120 96 add_action( 'wp_ajax_sureforms_dismiss_pointer', [ $this, 'pointer_dismissed' ] );
121 97 add_action( 'wp_ajax_sureforms_accept_cta', [ $this, 'pointer_accepted_cta' ] );
122 - add_action( 'wp_ajax_srfm_notice_response', [ $this, 'handle_notice_response' ] );
123 98
124 99 // Register dashboard widget only if there are recent entries.
125 100 add_action( 'admin_init', [ $this, 'maybe_register_dashboard_widget' ] );
126 -
127 - // Save first form creation time stamp.
128 - add_action( 'admin_init', [ $this, 'save_first_form_creation_time_stamp' ] );
129 - add_action( 'admin_notices', [ $this, 'display_srfm_rating_notice' ] );
130 - add_action( 'admin_notices', [ $this, 'display_srfm_getting_started_notice' ] );
131 101 }
132 102
133 103 /**
134 - * Get the first form creation time stamp.
135 - *
136 - * @since 1.10.1
137 - * @return int|false
138 - */
139 - public static function get_first_form_creation_time_stamp() {
140 - return Helper::get_srfm_option( 'first_form_created_at', false );
141 - }
142 -
143 - /**
144 - * Check if the first form has been created.
145 - *
146 - * @since 1.10.1
147 - * @return bool
148 - */
149 - public static function is_first_form_created() {
150 - // Convert the first form creation time stamp to a boolean. If it exists, it will return true, otherwise false.
151 - $first_form_creation_time_stamp = self::get_first_form_creation_time_stamp();
152 -
153 - // If the first form creation time stamp is not set, return false.
154 - if ( ! $first_form_creation_time_stamp ) {
155 - return false; // No forms created yet.
156 - }
157 -
158 - // Check if the first form creation time stamp is a valid integer and greater than zero.
159 - return is_int( $first_form_creation_time_stamp ) && $first_form_creation_time_stamp > 0;
160 - }
161 -
162 - /**
163 - * Check and save the first form creation time stamp.
164 - * If not already saved.
165 - *
166 - * @since 1.10.1
167 - * @return void
168 - */
169 - public static function save_first_form_creation_time_stamp() {
170 - if ( ! Helper::current_user_can() || self::is_first_form_created() || ! defined( 'SRFM_FORMS_POST_TYPE' ) || ! post_type_exists( SRFM_FORMS_POST_TYPE ) ) {
171 - return;
172 - }
173 -
174 - // Get the first form creation time from the database that is published.
175 - $query = new \WP_Query(
176 - [
177 - 'post_type' => SRFM_FORMS_POST_TYPE,
178 - 'posts_per_page' => 1,
179 - 'orderby' => 'date',
180 - 'order' => 'ASC',
181 - 'fields' => 'ids',
182 - 'post_status' => 'publish',
183 - ]
184 - );
185 -
186 - if ( ! empty( $query->posts ) && isset( $query->posts[0] ) ) {
187 - // Get the first post from the query result.
188 - $post_id = $query->posts[0];
189 - // Get the post creation time in GMT.
190 - $creation_time = get_post_field( 'post_date_gmt', $post_id );
191 - // Convert the creation time to a timestamp.
192 - $timestamp = strtotime( $creation_time );
193 -
194 - if ( ! $timestamp ) {
195 - return;
196 - }
197 -
198 - Helper::update_srfm_option( 'first_form_created_at', $timestamp );
199 - }
200 - }
201 -
202 - /**
203 - * Check if n days have passed since the first form creation.
204 - * This is used to determine if the dynamic nudges should be shown.
205 - *
206 - * @param int $days Number of days to check.
207 - * @since 1.10.1
208 - * @return bool
209 - */
210 - public static function check_first_form_creation_threshold( $days = 3 ) {
211 - $first_form_creation_time_stamp = self::get_first_form_creation_time_stamp();
212 -
213 - if ( ! $first_form_creation_time_stamp ) {
214 - return false; // No forms created yet.
215 - }
216 -
217 - /**
218 - * Calculate the number of days since the first form was created.
219 - */
220 - $days_from_creation = ( strtotime( current_time( 'mysql' ) ) - $first_form_creation_time_stamp ) / DAY_IN_SECONDS;
221 -
222 - // Return a boolean indicating if the number of days since creation is greater than the specified days.
223 - return $days_from_creation > $days;
224 - }
225 -
226 - /**
227 104 * Show action on plugin page.
228 105 *
229 106 * @param array $links links.
230 107 * @return array
@@ -232,17 +109,15 @@
232 109 */
233 110 public function add_action_links( $links ) {
234 111 if ( ! Helper::has_pro() ) {
235 112 // Display upsell link if SureForms Pro is not installed.
236 - $upsell_link = Helper::get_sureforms_website_url( 'pricing', [ 'utm_medium' => 'plugin-list' ] );
237 -
238 - ob_start();
239 - ?>
240 - <a href="<?php echo esc_url( $upsell_link ); ?>" target="_blank" rel="noreferrer" class="sureforms-plugins-go-pro">
241 - <?php echo esc_html__( 'Get SureForms Pro', 'sureforms' ); ?>
242 - </a>
243 - <?php
244 - $links[] = trim( ob_get_clean() );
113 + $upsell_link = add_query_arg(
114 + [
115 + 'utm_medium' => 'plugin-list',
116 + ],
117 + Helper::get_sureforms_website_url( 'pricing' )
118 + );
119 + $links[] = '<a href="' . esc_url( $upsell_link ) . '" target="_blank" rel="noreferrer" class="sureforms-plugins-go-pro">' . esc_html__( 'Get SureForms Pro', 'sureforms' ) . '</a>';
245 120 }
246 121
247 122 return $links;
248 123 }
@@ -310,15 +185,20 @@
310 185 * @return void
311 186 * @since 0.0.1
312 187 */
313 188 public function add_menu_page() {
314 - $menu_slug = 'sureforms_menu';
189 + if ( ! current_user_can( 'manage_options' ) ) {
190 + return;
191 + }
315 192
193 + $capability = 'manage_options';
194 + $menu_slug = 'sureforms_menu';
195 +
316 196 $logo = file_get_contents( plugin_dir_path( SRFM_FILE ) . 'images/icon.svg' );
317 197 add_menu_page(
318 198 __( 'SureForms', 'sureforms' ),
319 199 __( 'SureForms', 'sureforms' ),
320 - self::$sureforms_page_default_capability,
200 + 'edit_others_posts',
321 201 $menu_slug,
322 202 static function () {
323 203 },
324 204 'data:image/svg+xml;base64,' . base64_encode( $logo ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
@@ -329,9 +209,9 @@
329 209 add_submenu_page(
330 210 $menu_slug,
331 211 __( 'Dashboard', 'sureforms' ),
332 212 __( 'Dashboard', 'sureforms' ),
333 - self::$sureforms_page_default_capability,
213 + $capability,
334 214 $menu_slug,
335 215 [ $this, 'render_dashboard' ]
336 216 );
337 217 }
@@ -347,9 +227,9 @@
347 227 add_submenu_page(
348 228 'sureforms_menu',
349 229 __( 'Settings', 'sureforms' ),
350 230 __( 'Settings', 'sureforms' ),
351 - self::$sureforms_page_default_capability,
231 + 'edit_others_posts',
352 232 'sureforms_form_settings',
353 233 $callback
354 234 );
355 235
@@ -394,119 +274,25 @@
394 274 */
395 275 public function add_upgrade_to_pro() {
396 276 // The url used here is used as a selector for css to style the upgrade to pro submenu.
397 277 // 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' ] );
278 + $upgrade_url = add_query_arg(
279 + [
280 + 'utm_medium' => 'submenu_link_upgrade',
281 + ],
282 + Helper::get_sureforms_website_url( 'upgrade' )
283 + );
399 284
400 285 add_submenu_page(
401 286 'sureforms_menu',
402 287 __( 'Upgrade', 'sureforms' ),
403 288 __( 'Upgrade', 'sureforms' ),
404 - self::$sureforms_page_default_capability,
289 + 'edit_others_posts',
405 290 $upgrade_url
406 291 );
407 292 }
408 293
409 294 /**
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 295 * Add SMTP promotional submenu page.
510 296 *
511 297 * @return void
512 298 * @since 1.7.1
@@ -515,9 +301,9 @@
515 301 add_submenu_page(
516 302 'sureforms_menu',
517 303 __( 'SMTP', 'sureforms' ),
518 304 __( 'SMTP', 'sureforms' ),
519 - self::$sureforms_page_default_capability,
305 + 'edit_others_posts',
520 306 'sureforms_smtp',
521 307 [ $this, 'suremail_page_callback' ]
522 308 );
523 309
@@ -538,11 +324,9 @@
538 324 * @return void
539 325 * @since 1.7.1
540 326 */
541 327 public function suremail_page_callback() {
542 - ?>
543 - <div id="srfm-suremail-container" class="srfm-admin-wrapper"></div>
544 - <?php
328 + echo '<div id="srfm-suremail-container" class="srfm-admin-wrapper"></div>';
545 329 }
546 330
547 331 /**
548 332 * Render Admin Dashboard.
@@ -550,11 +334,9 @@
550 334 * @return void
551 335 * @since 0.0.1
552 336 */
553 337 public function render_dashboard() {
554 - ?>
555 - <div id="srfm-dashboard-container" class="srfm-admin-wrapper"></div>
556 - <?php
338 + echo '<div id="srfm-dashboard-container" class="srfm-admin-wrapper"></div>';
557 339 }
558 340
559 341 /**
560 342 * Settings page callback.
@@ -562,43 +344,12 @@
562 344 * @return void
563 345 * @since 0.0.1
564 346 */
565 347 public function settings_page_callback() {
566 - ?>
567 - <div id="srfm-settings-container" class="srfm-admin-wrapper"></div>
568 - <?php
348 + echo '<div id="srfm-settings-container" class="srfm-admin-wrapper"></div>';
569 349 }
570 350
571 351 /**
572 - * Add Learn submenu page.
573 - *
574 - * @return void
575 - * @since 2.5.2
576 - */
577 - public function add_learn_page() {
578 - add_submenu_page(
579 - 'sureforms_menu',
580 - __( 'Learn', 'sureforms' ),
581 - __( 'Learn', 'sureforms' ),
582 - self::$sureforms_page_default_capability,
583 - 'sureforms_learn',
584 - [ $this, 'render_learn' ]
585 - );
586 - }
587 -
588 - /**
589 - * Learn page callback.
590 - *
591 - * @return void
592 - * @since 2.5.2
593 - */
594 - public function render_learn() {
595 - ?>
596 - <div id="srfm-learn-root" class="srfm-admin-wrapper"></div>
597 - <?php
598 - }
599 -
600 - /**
601 352 * Add new form menu item.
602 353 *
603 354 * @return void
604 355 * @since 0.0.1
@@ -605,20 +356,11 @@
605 356 */
606 357 public function add_new_form() {
607 358 add_submenu_page(
608 359 'sureforms_menu',
609 - __( 'Forms', 'sureforms' ),
610 - __( 'Forms', 'sureforms' ),
611 - self::$sureforms_page_default_capability,
612 - 'sureforms_forms',
613 - [ $this, 'render_forms' ],
614 - 1
615 - );
616 - add_submenu_page(
617 - 'sureforms_menu',
618 360 __( 'New Form', 'sureforms' ),
619 361 __( 'New Form', 'sureforms' ),
620 - self::$sureforms_page_default_capability,
362 + 'edit_others_posts',
621 363 'add-new-form',
622 364 [ $this, 'add_new_form_callback' ],
623 365 2
624 366 );
@@ -625,24 +367,14 @@
625 367 $entries_hook = add_submenu_page(
626 368 'sureforms_menu',
627 369 __( 'Entries', 'sureforms' ),
628 370 __( 'Entries', 'sureforms' ),
629 - self::$sureforms_page_default_capability,
371 + 'edit_others_posts',
630 372 SRFM_ENTRIES,
631 373 [ $this, 'render_entries' ],
632 374 3
633 375 );
634 376
635 - add_submenu_page(
636 - 'sureforms_menu',
637 - __( 'Payments', 'sureforms' ),
638 - __( 'Payments', 'sureforms' ),
639 - self::$sureforms_page_default_capability,
640 - SRFM_PAYMENTS,
641 - [ $this, 'render_payments' ],
642 - 4
643 - );
644 -
645 377 if ( $entries_hook ) {
646 378 add_action( 'load-' . $entries_hook, [ $this, 'mark_entries_page_visit' ] );
647 379 }
648 380 }
@@ -647,20 +379,8 @@
647 379 }
648 380 }
649 381
650 382 /**
651 - * Payments page callback.
652 - *
653 - * @return void
654 - * @since 2.0.0
655 - */
656 - public function render_payments() {
657 - ?>
658 - <div id="srfm-payments-react-container" class="srfm-admin-wrapper"></div>
659 - <?php
660 - }
661 -
662 - /**
663 383 * Add new form mentu item callback.
664 384 *
665 385 * @return void
666 386 * @since 0.0.1
@@ -665,34 +385,41 @@
665 385 * @return void
666 386 * @since 0.0.1
667 387 */
668 388 public function add_new_form_callback() {
669 - ?>
670 - <div id="srfm-add-new-form-container" class="srfm-admin-wrapper"></div>
671 - <?php
389 + echo '<div id="srfm-add-new-form-container" class="srfm-admin-wrapper"></div>';
672 390 }
673 391
674 392 /**
675 - * Forms page callback.
676 - *
677 - * @return void
678 - * @since 2.0.0
679 - */
680 - public function render_forms() {
681 - ?>
682 - <div id="srfm-forms-root" class="srfm-admin-wrapper"></div>
683 - <?php
684 - }
685 -
686 - /**
687 393 * Entries page callback.
688 394 *
689 395 * @since 0.0.13
690 - * @since 2.0.0 - Updated the entries UI and the function definition.
691 396 * @return void
692 397 */
693 398 public function render_entries() {
694 - echo '<div id="srfm-entries-root"></div>';
399 + // Render single entry view.
400 + // Adding the phpcs ignore nonce verification as no database operations are performed in this function, it is used to display the single entry view.
401 + 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.
402 + $single_entry_view = new Single_Entry();
403 + $single_entry_view->render();
404 + return;
405 + }
406 +
407 + // Render all entries view.
408 + $entries_table = new Entries_List_Table();
409 + $entries_table->prepare_items();
410 + echo '<div class="wrap"><h1 class="wp-heading-inline">' . esc_html__( 'Entries', 'sureforms' ) . '</h1>';
411 + if ( empty( $entries_table->all_entries_count ) && empty( $entries_table->trash_entries_count ) ) {
412 + $instance = Post_Types::get_instance();
413 + $instance->sureforms_render_blank_state( SRFM_ENTRIES );
414 + $instance->get_blank_state_styles();
415 + return;
416 + }
417 + echo '<form method="get">';
418 + echo '<input type="hidden" name="page" value="sureforms_entries">';
419 + $entries_table->display();
420 + echo '</form>';
421 + echo '</div>';
695 422 }
696 423
697 424 /**
698 425 * Add notification badge to SureForms menu when there are new entries.
@@ -700,9 +427,9 @@
700 427 * @since 1.7.3
701 428 * @return void
702 429 */
703 430 public function maybe_add_entries_badge() {
704 - if ( ! Helper::current_user_can() ) {
431 + if ( ! current_user_can( 'edit_others_posts' ) ) {
705 432 return;
706 433 }
707 434
708 435 // If currently viewing the entries listing page, mark it as visited and skip the badge.
@@ -721,15 +448,10 @@
721 448
722 449 global $menu;
723 450 foreach ( $menu as $index => $item ) {
724 451 if ( isset( $item[2] ) && 'sureforms_menu' === $item[2] ) {
725 - ob_start();
726 - ?>
727 - <span class="srfm-update-dot"></span>
728 - <?php
729 - $dot_html = ob_get_clean();
730 452 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Adding notifications for menu item.
731 - $menu[ $index ][0] .= $dot_html;
453 + $menu[ $index ][0] .= ' <span class="srfm-update-dot"></span>';
732 454 break;
733 455 }
734 456 }
735 457
@@ -736,17 +458,12 @@
736 458 global $submenu;
737 459 if ( isset( $submenu['sureforms_menu'] ) ) {
738 460 foreach ( $submenu['sureforms_menu'] as $index => $sub_item ) {
739 461 if ( isset( $sub_item[2] ) && SRFM_ENTRIES === $sub_item[2] ) {
740 - ob_start();
741 - ?>
742 - <span class="update-plugins count-<?php echo absint( $new_entries ); ?>">
743 - <span class="plugin-count"><?php echo absint( $new_entries ); ?></span>
744 - </span>
745 - <?php
746 - $badge_html = ob_get_clean();
747 - // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Adding notifications for submenu item.
748 - $submenu['sureforms_menu'][ $index ][0] .= $badge_html;
462 + $submenu['sureforms_menu'][ $index ][0] .= sprintf( // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Adding notifications for submenu item.
463 + ' <span class="update-plugins count-%1$d"><span class="plugin-count">%1$d</span></span>',
464 + absint( $new_entries )
465 + );
749 466 break;
750 467 }
751 468 }
752 469 }
@@ -758,9 +475,9 @@
758 475 * @since 1.7.3
759 476 * @return void
760 477 */
761 478 public function mark_entries_page_visit() {
762 - if ( Helper::current_user_can() ) {
479 + if ( current_user_can( 'edit_others_posts' ) ) {
763 480 $srfm_options = get_option( 'srfm_options', [] );
764 481 $srfm_options['entries_last_visited'] = time();
765 482 \SRFM\Inc\Helper::update_admin_settings_option( 'srfm_options', $srfm_options );
766 483 }
@@ -775,22 +492,15 @@
775 492 * @since 0.0.1
776 493 */
777 494 public function add_settings_link( $links, $file ) {
778 495 if ( 'sureforms/sureforms.php' === $file ) {
779 - ob_start();
780 - ?>
781 - <a href="<?php echo esc_url( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) ); ?>">
782 - <?php echo esc_html__( 'Settings', 'sureforms' ); ?>
783 - </a>
784 - <?php
785 - $settings_link_html = ob_get_clean();
786 - $plugin_links = apply_filters(
496 + $plugin_links = apply_filters(
787 497 'sureforms_plugin_action_links',
788 498 [
789 - 'sureforms_settings' => $settings_link_html,
499 + 'sureforms_settings' => '<a href="' . esc_url( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) ) . '">' . esc_html__( 'Settings', 'sureforms' ) . '</a>',
790 500 ]
791 501 );
792 - $links = array_merge( $plugin_links, $links );
502 + $links = array_merge( $plugin_links, $links );
793 503 }
794 504 return $links;
795 505 }
796 506
@@ -900,8 +610,9 @@
900 610 global $wp_version;
901 611
902 612 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
903 613 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
614 + $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/';
904 615 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
905 616 $is_rtl = is_rtl();
906 617 $rtl = $is_rtl ? '-rtl' : '';
907 618
@@ -909,132 +620,44 @@
909 620 * List of the handles in which we need to add translation compatibility.
910 621 */
911 622 $script_translations_handlers = [];
912 623 $onboarding_instance = Onboarding::get_instance();
913 - $current_user = wp_get_current_user();
914 624
915 625 $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(
962 - 'srfm_admin_localize_payments_data',
963 - [
964 - 'stripe_connected' => Stripe_Helper::is_stripe_connected(),
965 - 'stripe_mode' => Stripe_Helper::get_stripe_mode(),
966 - 'stripe_connect_url' => Stripe_Helper::get_stripe_settings_url(),
967 - 'currencies_data' => Payment_Helper::get_all_currencies_data(),
968 - 'zero_decimal_currencies' => Payment_Helper::get_zero_decimal_currencies(),
969 - 'webhook_url' => Stripe_Helper::get_webhook_url(),
970 - 'webhook_test_connected' => Stripe_Helper::is_webhook_configured( 'test', true ),
971 - 'webhook_live_connected' => Stripe_Helper::is_webhook_configured( 'live', true ),
972 - 'is_transaction_present' => Stripe_Helper::is_transaction_present(),
973 - 'payment_currency' => Payment_Helper::get_currency(),
974 - 'currency_sign_position' => Payment_Helper::get_currency_sign_position(),
975 - ]
976 - ),
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' ) ),
626 + 'site_url' => get_site_url(),
627 + 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(),
628 + 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ),
629 + 'plugin_version' => SRFM_VER,
630 + 'global_settings_nonce' => current_user_can( 'manage_options' ) ? wp_create_nonce( 'wp_rest' ) : '',
631 + 'is_pro_active' => Helper::has_pro(),
632 + 'pro_plugin_version' => Helper::has_pro() ? SRFM_PRO_VER : '',
633 + 'pro_plugin_name' => Helper::has_pro() && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro',
634 + 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ),
635 + 'field_spacing_vars' => Helper::get_css_vars(),
636 + 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ),
637 + 'integrations' => Helper::sureforms_get_integration(),
638 + 'ajax_url' => admin_url( 'admin-ajax.php' ),
639 + 'sf_plugin_manager_nonce' => wp_create_nonce( 'sf_plugin_manager_nonce' ),
640 + 'plugin_installer_nonce' => wp_create_nonce( 'updates' ),
641 + 'plugin_activating_text' => __( 'Activating...', 'sureforms' ),
642 + 'plugin_activated_text' => __( 'Activated', 'sureforms' ),
643 + 'plugin_activate_text' => __( 'Activate', 'sureforms' ),
644 + 'plugin_installing_text' => __( 'Installing...', 'sureforms' ),
645 + 'plugin_installed_text' => __( 'Installed', 'sureforms' ),
646 + 'is_rtl' => $is_rtl,
647 + 'onboarding_completed' => method_exists( $onboarding_instance, 'get_onboarding_status' ) ? $onboarding_instance->get_onboarding_status() : false,
648 + 'onboarding_redirect' => isset( $_GET['srfm-activation-redirect'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not required for the activation redirection.
649 + 'pointer_nonce' => wp_create_nonce( 'sureforms_pointer_action' ),
650 + 'srfm_ai_details' => AI_Helper::get_current_usage_details(),
981 651 ];
982 652
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;
653 + $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' );
654 + $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' );
655 + $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' );
656 + $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' );
657 + $is_post_type_sureforms_form = SRFM_FORMS_POST_TYPE === $current_screen->post_type;
994 658
995 - /**
996 - * Check if the current screen is the SureForms Menu and AI Auth Email is present then we will add user type as registered.
997 - * Compatibility with existing UI code that checks for this condition.
998 - */
999 - if ( $is_screen_sureforms_menu ) {
1000 - // If email is stored send the user type as registered else non-registered.
1001 - $localization_data['srfm_ai_details'] = [
1002 - 'type' => ! empty( get_option( 'srfm_ai_auth_user_email' ) ) ? 'registered' : 'non-registered',
1003 - ];
1004 - }
1005 -
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 ) {
659 + if ( $is_screen_sureforms_menu || $is_post_type_sureforms_form || $is_screen_add_new_form || $is_screen_sureforms_form_settings || $is_screen_sureforms_entries ) {
1037 660 $asset_handle = '-dashboard';
1038 661
1039 662 wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER );
1040 663
@@ -1062,9 +685,9 @@
1062 685 update_option( 'srfm_pro_license_status', $current_license_status );
1063 686 }
1064 687 }
1065 688
1066 - $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings&subpage=recaptcha' );
689 + $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings' );
1067 690 $localization_data['integration_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=integration-settings' );
1068 691 wp_localize_script(
1069 692 SRFM_SLUG . $asset_handle,
1070 693 SRFM_SLUG . '_admin',
@@ -1073,11 +696,12 @@
1073 696 $localization_data
1074 697 )
1075 698 );
1076 699 wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' );
700 +
1077 701 }
1078 702
1079 - if ( $is_screen_sureforms_form_settings || $is_screen_sureforms_forms ) {
703 + if ( $is_screen_sureforms_form_settings ) {
1080 704 wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1081 705 }
1082 706
1083 707 // Enqueue styles for the entries page.
@@ -1084,61 +708,11 @@
1084 708 if ( $is_screen_sureforms_entries ) {
1085 709 $asset_handle = '-entries';
1086 710 wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/entries.js', $script_info['dependencies'], SRFM_VER, true );
1087 711
1088 - wp_localize_script(
1089 - SRFM_SLUG . $asset_handle,
1090 - SRFM_SLUG . '_admin',
1091 - apply_filters(
1092 - SRFM_SLUG . '_admin_filter',
1093 - $localization_data
1094 - )
1095 - );
1096 712 $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1097 713 }
1098 714
1099 - // Enqueue scripts for the learn page.
1100 - if ( $is_screen_sureforms_learn ) {
1101 - $asset_handle = '-learn';
1102 - wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/learn.js', $script_info['dependencies'], SRFM_VER, true );
1103 -
1104 - wp_localize_script(
1105 - SRFM_SLUG . $asset_handle,
1106 - SRFM_SLUG . '_admin',
1107 - apply_filters(
1108 - SRFM_SLUG . '_admin_filter',
1109 - $localization_data
1110 - )
1111 - );
1112 - $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1113 - }
1114 -
1115 - // Enqueue scripts for the forms page.
1116 - if ( $is_screen_sureforms_forms ) {
1117 - $asset_handle = '-forms';
1118 -
1119 - $script_asset_path = SRFM_DIR . 'assets/build/forms.asset.php';
1120 - $script_info = file_exists( $script_asset_path )
1121 - ? include $script_asset_path
1122 - : [
1123 - 'dependencies' => [],
1124 - 'version' => SRFM_VER,
1125 - ];
1126 -
1127 - wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.js', $script_info['dependencies'], SRFM_VER, true );
1128 - wp_localize_script(
1129 - SRFM_SLUG . $asset_handle,
1130 - SRFM_SLUG . '_admin',
1131 - apply_filters(
1132 - SRFM_SLUG . '_admin_filter',
1133 - $localization_data
1134 - )
1135 - );
1136 - wp_enqueue_style( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.css', [], SRFM_VER, 'all' );
1137 -
1138 - $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1139 - }
1140 -
1141 715 // Enqueue scripts for the SureMail promotional page.
1142 716 $is_screen_sureforms_smtp = Helper::validate_request_context( 'sureforms_smtp', 'page' );
1143 717 if ( $is_screen_sureforms_smtp ) {
1144 718 $asset_handle = 'suremail';
@@ -1177,65 +751,27 @@
1177 751
1178 752 $script_translations_handlers[] = SRFM_SLUG . '-suremail';
1179 753 }
1180 754
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';
755 + // Admin Submenu Styles.
756 + wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1184 757
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 - ];
758 + if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) {
759 + $asset_handle = 'page_header';
1192 760
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 761 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
1204 762 $script_info = file_exists( $script_asset_path )
1205 - ? include $script_asset_path
1206 - : [
1207 - 'dependencies' => [],
1208 - 'version' => SRFM_VER,
1209 - ];
763 + ? include $script_asset_path
764 + : [
765 + 'dependencies' => [],
766 + 'version' => SRFM_VER,
767 + ];
768 + wp_enqueue_script( SRFM_SLUG . '-form-page-header', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
769 + wp_enqueue_style( SRFM_SLUG . '-form-archive-styles', $css_uri . 'form-archive-styles' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1210 770
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';
771 + $script_translations_handlers[] = SRFM_SLUG . '-form-page-header';
1215 772 }
1216 773
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 - // Admin Submenu Styles.
1236 - wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1237 -
1238 774 if ( $is_screen_sureforms_form_settings ) {
1239 775 $asset_handle = 'settings';
1240 776
1241 777 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
@@ -1249,19 +785,40 @@
1249 785 wp_enqueue_script( SRFM_SLUG . '-settings', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1250 786 wp_localize_script(
1251 787 SRFM_SLUG . '-settings',
1252 788 SRFM_SLUG . '_admin',
1253 - apply_filters(
1254 - SRFM_SLUG . '_admin_filter',
1255 - $localization_data
1256 - )
789 + $localization_data
1257 790 );
1258 791
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 );
792 + $script_translations_handlers[] = SRFM_SLUG . '-settings';
793 + }
794 + if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) {
795 + wp_enqueue_script( SRFM_SLUG . '-form-archive', $js_uri . 'form-archive' . $file_prefix . '.js', [], SRFM_VER, true );
796 + wp_enqueue_script( SRFM_SLUG . '-export', $js_uri . 'export' . $file_prefix . '.js', [ 'wp-i18n' ], SRFM_VER, true );
797 + wp_localize_script(
798 + SRFM_SLUG . '-export',
799 + SRFM_SLUG . '_export',
800 + [
801 + 'ajaxurl' => admin_url( 'admin-ajax.php' ),
802 + 'srfm_export_nonce' => wp_create_nonce( 'export_form_nonce' ),
803 + 'site_url' => get_site_url(),
804 + 'import_form_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'wp_rest' ) : '',
805 + 'import_btn_string' => __( 'Import Form', 'sureforms' ),
806 + ]
807 + );
1262 808
1263 - $script_translations_handlers[] = SRFM_SLUG . '-settings';
809 + wp_enqueue_script( SRFM_SLUG . '-backend', $js_uri . 'backend' . $file_prefix . '.js', [], SRFM_VER, true );
810 + wp_localize_script(
811 + SRFM_SLUG . '-backend',
812 + SRFM_SLUG . '_backend',
813 + [
814 + 'site_url' => get_site_url(),
815 + ]
816 + );
817 +
818 + $script_translations_handlers[] = SRFM_SLUG . '-form-archive';
819 + $script_translations_handlers[] = SRFM_SLUG . '-export';
820 + $script_translations_handlers[] = SRFM_SLUG . '-backend';
1264 821 }
1265 822
1266 823 if ( $is_screen_add_new_form ) {
1267 824 wp_enqueue_style( SRFM_SLUG . '-template-picker', $css_uri . 'template-picker' . $file_prefix . $rtl . '.css', [], SRFM_VER );
@@ -1282,12 +839,13 @@
1282 839 SRFM_SLUG . '_admin',
1283 840 [
1284 841 'site_url' => get_site_url(),
1285 842 'plugin_url' => SRFM_URL,
843 + 'preview_images_url' => SRFM_URL . 'images/template-previews/',
1286 844 'admin_url' => admin_url( 'admin.php' ),
1287 845 'new_template_picker_base_url' => admin_url( 'post-new.php?post_type=sureforms_form' ),
1288 - 'capability' => Helper::current_user_can(),
1289 - 'template_picker_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '',
846 + 'capability' => current_user_can( 'edit_posts' ),
847 + 'template_picker_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'wp_rest' ) : '',
1290 848 'is_pro_active' => Helper::has_pro(),
1291 849 'srfm_ai_usage_details' => AI_Helper::get_current_usage_details(),
1292 850 'is_pro_license_active' => AI_Helper::is_pro_license_active(),
1293 851 'srfm_ai_auth_user_email' => get_option( 'srfm_ai_auth_user_email' ),
@@ -1308,9 +866,8 @@
1308 866 'srfm/checkbox',
1309 867 'srfm/number',
1310 868 'srfm/inline-button',
1311 869 'srfm/advanced-heading',
1312 - 'srfm/payment',
1313 870 ]
1314 871 );
1315 872 if ( ! is_array( $default_allowed_quick_sidebar_blocks ) ) {
1316 873 $default_allowed_quick_sidebar_blocks = [];
@@ -1322,25 +879,22 @@
1322 879 }
1323 880 $quick_sidebar_allowed_blocks = get_option( 'srfm_quick_sidebar_allowed_blocks' );
1324 881 $quick_sidebar_allowed_blocks = ! empty( $quick_sidebar_allowed_blocks ) && is_array( $quick_sidebar_allowed_blocks ) ? $quick_sidebar_allowed_blocks : $default_allowed_quick_sidebar_blocks;
1325 882 $srfm_ajax_nonce = wp_create_nonce( 'srfm_ajax_nonce' );
883 + wp_enqueue_script( SRFM_SLUG . '-quick-action-siderbar', SRFM_URL . 'assets/build/quickActionSidebar.js', [], SRFM_VER, true );
884 + wp_localize_script(
885 + SRFM_SLUG . '-quick-action-siderbar',
886 + SRFM_SLUG . '_quick_sidebar_blocks',
887 + [
888 + 'allowed_blocks' => $quick_sidebar_allowed_blocks,
889 + 'srfm_enable_quick_action_sidebar' => $srfm_enable_quick_action_sidebar,
890 + 'srfm_ajax_nonce' => $srfm_ajax_nonce,
891 + 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ),
892 + ]
893 + );
1326 894
1327 - if ( Helper::is_sureforms_admin_page() ) {
1328 - wp_enqueue_script( SRFM_SLUG . '-quick-action-siderbar', SRFM_URL . 'assets/build/quickActionSidebar.js', [], SRFM_VER, true );
1329 - wp_localize_script(
1330 - SRFM_SLUG . '-quick-action-siderbar',
1331 - SRFM_SLUG . '_quick_sidebar_blocks',
1332 - [
1333 - 'allowed_blocks' => $quick_sidebar_allowed_blocks,
1334 - 'srfm_enable_quick_action_sidebar' => $srfm_enable_quick_action_sidebar,
1335 - 'srfm_ajax_nonce' => $srfm_ajax_nonce,
1336 - 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ),
1337 - ]
1338 - );
895 + $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar';
1339 896
1340 - $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar';
1341 - }
1342 -
1343 897 /**
1344 898 * Enqueuing SureTriggers Integration script.
1345 899 * This script loads suretriggers iframe in Intergations tab.
1346 900 */
@@ -1412,53 +966,40 @@
1412 966
1413 967 return $status;
1414 968 }
1415 969
970 + // Entries methods.
971 +
1416 972 /**
1417 - * Register Pro compatibility notices early for React pages.
973 + * Handle entry actions.
1418 974 *
1419 - * This method runs on admin_init (priority 5) to ensure notices are
1420 - * registered BEFORE admin_enqueue_scripts, so they're available when
1421 - * wp_localize_script runs.
1422 - *
1423 - * Hooked - admin_init (priority 5)
1424 - *
975 + * @since 0.0.13
1425 976 * @return void
1426 - * @since 2.5.0
1427 977 */
1428 - public function register_pro_compatibility_notices() {
1429 - // Early exit if Pro is not active, user lacks permissions, or Notice_Manager is unavailable.
1430 - if ( ! Helper::has_pro() || ! Helper::current_user_can() || ! class_exists( 'SRFM\Admin\Notice_Manager' ) ) {
978 + public function handle_entry_actions() {
979 + Entries_List_Table::process_bulk_actions();
980 +
981 + if ( ! isset( $_GET['page'] ) || SRFM_ENTRIES !== $_GET['page'] ) {
1431 982 return;
1432 983 }
1433 -
1434 - // Register version outdated notice for React pages.
1435 - if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
1436 - $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
1437 - $react_outdated_message = sprintf(
1438 - // translators: %1$s: SureForms version, %2$s: SureForms Pro Plugin Name, %3$s: SureForms Pro Version.
1439 - esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version.', 'sureforms' ),
1440 - esc_html( SRFM_VER ),
1441 - esc_html( $pro_plugin_name ),
1442 - esc_html( SRFM_PRO_RECOMMENDED_VER )
1443 - );
1444 -
1445 - \SRFM\Admin\Notice_Manager::register_notice(
1446 - [
1447 - 'id' => 'sureforms-pro-version-outdated',
1448 - 'variant' => 'warning',
1449 - 'message' => $react_outdated_message,
1450 - 'actions' => [
1451 - [
1452 - 'label' => esc_html__( 'Update Now', 'sureforms' ),
1453 - 'url' => admin_url( 'update-core.php' ),
1454 - 'variant' => 'primary',
1455 - ],
1456 - ],
1457 - 'pages' => [ 'all' ],
1458 - ]
1459 - );
984 + if ( ! isset( $_GET['entry_id'] ) || ! isset( $_GET['action'] ) ) {
985 + return;
1460 986 }
987 + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'srfm_entries_action' ) ) {
988 + wp_die( esc_html__( 'Nonce verification failed.', 'sureforms' ) );
989 + }
990 + $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
991 + $entry_id = Helper::get_integer_value( sanitize_text_field( wp_unslash( $_GET['entry_id'] ) ) );
992 + $view = isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : '';
993 + if ( $entry_id > 0 ) {
994 + if ( 'read' === $action && 'details' === $view ) {
995 + $entry_status = Entries::get( $entry_id )['status'];
996 + if ( 'trash' === $entry_status ) {
997 + wp_die( esc_html__( 'You cannot view this entry because it is in trash.', 'sureforms' ) );
998 + }
999 + }
1000 + Entries_List_Table::handle_entry_status( $entry_id, $action, $view );
1001 + }
1461 1002 }
1462 1003
1463 1004 /**
1464 1005 * Admin Notice Callback if sureforms pro is out of date.
@@ -1476,9 +1017,9 @@
1476 1017 if ( empty( get_current_screen() ) ) {
1477 1018 return;
1478 1019 }
1479 1020
1480 - if ( ! Helper::current_user_can() ) {
1021 + if ( ! current_user_can( 'update_plugins' ) ) {
1481 1022 return;
1482 1023 }
1483 1024
1484 1025 $srfm_pro_license_status = get_option( 'srfm_pro_license_status', '' );
@@ -1494,214 +1035,36 @@
1494 1035 $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
1495 1036 $message = '';
1496 1037 $url = admin_url( 'admin.php?page=sureforms_form_settings&tab=account-settings' );
1497 1038 if ( 'unlicensed' === $srfm_pro_license_status ) {
1498 - ob_start();
1499 - ?>
1500 - <p>
1501 - <?php
1502 - printf(
1503 - // translators: %1$s: Opening anchor tag with URL, %2$s: Closing anchor tag, %3$s: SureForms Pro Plugin Name.
1504 - esc_html__( 'Please %1$sactivate%2$s your copy of %3$s to get new features, access support, receive update notifications, and more.', 'sureforms' ),
1505 - '<a href="' . esc_url( $url ) . '">',
1506 - '</a>',
1507 - '<i>' . esc_html( $pro_plugin_name ) . '</i>'
1508 - );
1509 - ?>
1510 - </p>
1511 - <?php
1512 - $message = ob_get_clean();
1039 + $message = '<p>' . sprintf(
1040 + // translators: %1$s: Opening anchor tag with URL, %2$s: Closing anchor tag, %3$s: SureForms Pro Plugin Name.
1041 + esc_html__( 'Please %1$sactivate%2$s your copy of %3$s to get new features, access support, receive update notifications, and more.', 'sureforms' ),
1042 + '<a href="' . esc_url( $url ) . '">',
1043 + '</a>',
1044 + '<i>' . esc_html( $pro_plugin_name ) . '</i>'
1045 + ) . '</p>';
1513 1046 }
1514 1047
1515 1048 if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
1516 - ob_start();
1517 - ?>
1518 - <p>
1519 - <?php
1520 - printf(
1521 - // translators: %1$s: SureForms version, %2$s: SureForms Pro Plugin Name, %3$s: SureForms Pro Version, %4$s: Anchor tag open, %5$s: Closing anchor tag.
1522 - esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version from %4$shere%5$s.', 'sureforms' ),
1523 - esc_html( SRFM_VER ),
1524 - esc_html( $pro_plugin_name ),
1525 - esc_html( SRFM_PRO_RECOMMENDED_VER ),
1526 - '<a href="' . esc_url( admin_url( 'update-core.php' ) ) . '">',
1527 - '</a>'
1528 - );
1529 - ?>
1530 - </p>
1531 - <?php
1532 - $message .= ob_get_clean();
1049 + $message .= '<p>' . sprintf(
1050 + // translators: %1$s: SureForms version, %2$s: SureForms Pro Plugin Name, %3$s: SureForms Pro Version, %4$s: Anchor tag open, %5$s: Closing anchor tag.
1051 + esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version from %4$shere%5$s.', 'sureforms' ),
1052 + esc_html( SRFM_VER ),
1053 + esc_html( $pro_plugin_name ),
1054 + esc_html( SRFM_PRO_RECOMMENDED_VER ),
1055 + '<a href=' . esc_url( admin_url( 'update-core.php' ) ) . '>',
1056 + '</a>'
1057 + ) . '</p>';
1533 1058 }
1534 1059
1535 1060 if ( ! empty( $message ) ) {
1536 1061 // Phpcs ignore comment is required as $message variable is already escaped.
1537 - ?>
1538 - <div class="notice notice-warning"><?php echo wp_kses_post( $message ); ?></div>
1539 - <?php
1062 + echo '<div class="notice notice-warning">' . wp_kses_post( $message ) . '</div>';
1540 1063 }
1541 1064 }
1542 1065
1543 1066 /**
1544 - * Display a notice to the user about providing a review.
1545 - *
1546 - * @since 2.5.2
1547 - * @return void
1548 - */
1549 - public function display_srfm_rating_notice() {
1550 - // Only show to admins.
1551 - if ( ! Helper::current_user_can() ) {
1552 - return;
1553 - }
1554 -
1555 - // Allow the notice to be disabled.
1556 - if ( ! apply_filters( 'srfm_show_rating_notice', true ) ) {
1557 - return;
1558 - }
1559 -
1560 - Astra_Notices::add_notice(
1561 - [
1562 - 'id' => 'srfm-plugin-review-notice',
1563 - 'type' => '',
1564 - 'message' => $this->build_notice_markup(
1565 - esc_html__( 'Amazing! SureForms is powering your forms and submissions - let\'s keep growing together!', 'sureforms' ),
1566 - esc_html__( 'If SureForms has been helpful, would you mind taking a moment to leave a 5-star review on WordPress.org?', 'sureforms' ),
1567 - esc_url( 'https://wordpress.org/support/plugin/sureforms/reviews/?filter=5#new-post' ),
1568 - esc_html__( 'Rate SureForms', 'sureforms' ),
1569 - esc_html__( 'Maybe later', 'sureforms' ),
1570 - esc_html__( 'I already did', 'sureforms' ),
1571 - WEEK_IN_SECONDS,
1572 - true
1573 - ),
1574 - 'repeat-notice-after' => WEEK_IN_SECONDS,
1575 - 'show_if' => $this->maybe_display_rating_notice(),
1576 - 'display-with-other-notices' => true,
1577 - ]
1578 - );
1579 -
1580 - add_action( 'astra_notice_after_markup_srfm-plugin-review-notice', [ $this, 'enqueue_notice_response_script' ] );
1581 - }
1582 -
1583 - /**
1584 - * Display a "Getting Started" admin notice for new users who haven't yet
1585 - * reached the rating-notice milestone (3+ forms or 3+ entries).
1586 - *
1587 - * The Astra Notices library handles the 7-day delay via the
1588 - * `display-notice-after` parameter.
1589 - *
1590 - * @since 2.5.2
1591 - * @return void
1592 - */
1593 - public function display_srfm_getting_started_notice() {
1594 - // Only show to admins.
1595 - if ( ! Helper::current_user_can() ) {
1596 - return;
1597 - }
1598 -
1599 - // Allow the notice to be disabled programmatically.
1600 - if ( ! apply_filters( 'srfm_show_getting_started_notice', true ) ) {
1601 - return;
1602 - }
1603 -
1604 - Astra_Notices::add_notice(
1605 - [
1606 - 'id' => 'srfm-getting-started-notice',
1607 - 'type' => '',
1608 - 'message' => $this->build_notice_markup(
1609 - esc_html__( 'SureForms is ready to power your forms — explore what\'s possible!', 'sureforms' ),
1610 - esc_html__( 'Manage your forms, track submissions, and discover features like AI Form Builder, payment integrations, and more from the SureForms dashboard.', 'sureforms' ),
1611 - esc_url( admin_url( 'admin.php?page=sureforms_menu' ) ),
1612 - esc_html__( 'Go to Dashboard', 'sureforms' ),
1613 - esc_html__( 'Maybe later', 'sureforms' ),
1614 - esc_html__( 'I already know', 'sureforms' ),
1615 - WEEK_IN_SECONDS
1616 - ),
1617 - 'repeat-notice-after' => WEEK_IN_SECONDS,
1618 - 'show_if' => ! $this->maybe_display_rating_notice(),
1619 - 'display-notice-after' => WEEK_IN_SECONDS,
1620 - 'display-with-other-notices' => true,
1621 - ]
1622 - );
1623 -
1624 - add_action( 'astra_notice_after_markup_srfm-getting-started-notice', [ $this, 'enqueue_notice_response_script' ] );
1625 - }
1626 -
1627 - /**
1628 - * Enqueue the notice response analytics script.
1629 - *
1630 - * Called via the astra_notice_after_markup_{id} hook so the script
1631 - * only loads when a SureForms notice is actually rendered.
1632 - *
1633 - * @since 2.5.2
1634 - * @return void
1635 - */
1636 - public function enqueue_notice_response_script() {
1637 - if ( wp_script_is( 'srfm-notice-response', 'enqueued' ) ) {
1638 - return;
1639 - }
1640 -
1641 - wp_enqueue_script(
1642 - 'srfm-notice-response',
1643 - SRFM_URL . 'admin/assets/js/notice-response.js',
1644 - [],
1645 - SRFM_VER,
1646 - true
1647 - );
1648 -
1649 - wp_localize_script(
1650 - 'srfm-notice-response',
1651 - 'srfmNoticeResponse',
1652 - [
1653 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1654 - 'nonce' => wp_create_nonce( 'srfm_notice_response' ),
1655 - ]
1656 - );
1657 - }
1658 -
1659 - /**
1660 - * Handle the notice response AJAX request.
1661 - *
1662 - * Validates the request and records the analytics event
1663 - * for the notice button that was clicked.
1664 - *
1665 - * @since 2.5.2
1666 - * @return void
1667 - */
1668 - public function handle_notice_response() {
1669 - if ( ! check_ajax_referer( 'srfm_notice_response', 'nonce', false ) ) {
1670 - wp_send_json_error( [ 'message' => __( 'Invalid nonce.', 'sureforms' ) ], 403 );
1671 - }
1672 -
1673 - if ( ! Helper::current_user_can() ) {
1674 - wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1675 - }
1676 -
1677 - $notice_id = isset( $_POST['notice_id'] ) ? sanitize_text_field( wp_unslash( $_POST['notice_id'] ) ) : '';
1678 - $button = isset( $_POST['button'] ) ? sanitize_text_field( wp_unslash( $_POST['button'] ) ) : '';
1679 -
1680 - $valid = [
1681 - 'srfm-getting-started-notice' => [
1682 - 'go_to_dashboard' => 'getting_started_notice_cta',
1683 - 'maybe_later' => 'getting_started_notice_snooze',
1684 - 'dismissed' => 'getting_started_notice_dismiss',
1685 - ],
1686 - 'srfm-plugin-review-notice' => [
1687 - 'rate_sureforms' => 'rating_notice_cta',
1688 - 'maybe_later' => 'rating_notice_snooze',
1689 - 'dismissed' => 'rating_notice_dismiss',
1690 - ],
1691 - ];
1692 -
1693 - if ( ! isset( $valid[ $notice_id ][ $button ] ) ) {
1694 - wp_send_json_error( [ 'message' => __( 'Invalid parameters.', 'sureforms' ) ], 400 );
1695 - }
1696 -
1697 - $event_name = $valid[ $notice_id ][ $button ];
1698 - Analytics::events()->track( $event_name, $button );
1699 -
1700 - wp_send_json_success();
1701 - }
1702 -
1703 - /**
1704 1067 * Disables the capabilities for WPForms to avoid conflicts when enqueueing
1705 1068 * scripts and styles for WPForms.
1706 1069 *
1707 1070 * This function is intended to prevent any potential conflicts that may arise
@@ -1760,9 +1123,9 @@
1760 1123 * @since 1.8.0
1761 1124 */
1762 1125 public function pointer_should_show() {
1763 1126 // Security: Check user capability.
1764 - if ( ! Helper::current_user_can() ) {
1127 + if ( ! current_user_can( 'manage_options' ) ) {
1765 1128 wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1766 1129 }
1767 1130 // Security: Nonce check.
1768 1131 if ( empty( $_POST['pointer_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pointer_nonce'] ) ), 'sureforms_pointer_action' ) ) {
@@ -1798,9 +1161,9 @@
1798 1161 * @since 1.8.0
1799 1162 */
1800 1163 public function pointer_dismissed() {
1801 1164 // Security: Check user capability.
1802 - if ( ! Helper::current_user_can() ) {
1165 + if ( ! current_user_can( 'manage_options' ) ) {
1803 1166 wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1804 1167 }
1805 1168 // Security: Nonce check.
1806 1169 if ( empty( $_POST['pointer_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pointer_nonce'] ) ), 'sureforms_pointer_action' ) ) {
@@ -1819,9 +1182,9 @@
1819 1182 * @since 1.8.0
1820 1183 */
1821 1184 public function pointer_accepted_cta() {
1822 1185 // Security: Check user capability.
1823 - if ( ! Helper::current_user_can() ) {
1186 + if ( ! current_user_can( 'manage_options' ) ) {
1824 1187 wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1825 1188 }
1826 1189 // Security: Nonce check.
1827 1190 if ( empty( $_POST['pointer_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pointer_nonce'] ) ), 'sureforms_pointer_action' ) ) {
@@ -1839,14 +1202,8 @@
1839 1202 * @return void
1840 1203 * @since 1.9.1
1841 1204 */
1842 1205 public function maybe_register_dashboard_widget() {
1843 -
1844 - // Only for users with manage_options capability.
1845 - if ( ! Helper::current_user_can() ) {
1846 - return;
1847 - }
1848 -
1849 1206 // Quick check if there are any entries in the last 7 days.
1850 1207 $seven_days_ago = strtotime( '-7 days' );
1851 1208 $total_entries = Entries::get_entries_count_after( $seven_days_ago );
1852 1209
@@ -1931,86 +1288,8 @@
1931 1288 <?php
1932 1289 }
1933 1290
1934 1291 /**
1935 - * Build the shared HTML markup for admin notices.
1936 - *
1937 - * @since 2.5.2
1938 - *
1939 - * All text parameters must be pre-escaped by the caller (e.g. via esc_html__()).
1940 - * URL parameters must be pre-escaped via esc_url().
1941 - *
1942 - * @param string $heading The notice heading text (pre-escaped).
1943 - * @param string $message The notice body text (pre-escaped).
1944 - * @param string $cta_url The primary CTA URL (pre-escaped).
1945 - * @param string $cta_text The primary CTA button text (pre-escaped).
1946 - * @param string $snooze_text The snooze button text (pre-escaped).
1947 - * @param string $dismiss_text The dismiss button text (pre-escaped).
1948 - * @param int $snooze_duration Snooze duration in seconds for the data-repeat-notice-after attribute.
1949 - * @param bool $external_cta Whether the CTA opens in a new tab and also dismisses the notice
1950 - * via the astra-notice-close class. Default false.
1951 - * @return string The notice HTML markup.
1952 - */
1953 - private function build_notice_markup( $heading, $message, $cta_url, $cta_text, $snooze_text, $dismiss_text, $snooze_duration, $external_cta = false ) {
1954 - $image_path = esc_url( SRFM_URL . 'admin/assets/sureforms-logo.png' );
1955 - $cta_class = $external_cta ? 'astra-notice-close button-primary' : 'button-primary';
1956 - $cta_attrs = $external_cta ? ' target="_blank" rel="noopener noreferrer"' : '';
1957 -
1958 - return sprintf(
1959 - '<div class="notice-image">
1960 - <img src="%1$s" class="custom-logo" alt="SureForms" itemprop="logo">
1961 - </div>
1962 - <div class="notice-content">
1963 - <div class="notice-heading">
1964 - %2$s
1965 - </div>
1966 - %3$s<br />
1967 - <div class="astra-review-notice-container">
1968 - <a href="%4$s" class="%5$s"%6$s>
1969 - %7$s
1970 - </a>
1971 - <span class="dashicons dashicons-clock" aria-hidden="true"></span>
1972 - <a href="#" data-repeat-notice-after="%8$s" class="astra-notice-close">
1973 - %9$s
1974 - </a>
1975 - <span class="dashicons dashicons-smiley" aria-hidden="true"></span>
1976 - <a href="#" class="astra-notice-close">
1977 - %10$s
1978 - </a>
1979 - </div>
1980 - </div>',
1981 - $image_path,
1982 - $heading,
1983 - $message,
1984 - $cta_url,
1985 - esc_attr( $cta_class ),
1986 - $cta_attrs,
1987 - $cta_text,
1988 - $snooze_duration,
1989 - $snooze_text,
1990 - $dismiss_text
1991 - );
1992 - }
1993 -
1994 - /**
1995 - * Callback for displaying the rating notice conditionally.
1996 - *
1997 - * Returns true if the user has 3 or more published forms or 3 or more form entries.
1998 - *
1999 - * @since 2.5.2
2000 - * @return bool
2001 - */
2002 - private function maybe_display_rating_notice() {
2003 - if ( null === $this->should_show_rating ) {
2004 - $entries_count = Entries::get_total_entries_by_status( 'all' );
2005 - $form_count = wp_count_posts( SRFM_FORMS_POST_TYPE );
2006 - $this->should_show_rating = $entries_count >= self::RATING_NOTICE_THRESHOLD || Helper::get_integer_value( $form_count->publish ?? 0 ) >= self::RATING_NOTICE_THRESHOLD;
2007 - }
2008 -
2009 - return $this->should_show_rating;
2010 - }
2011 -
2012 - /**
2013 1292 * Get random premium feature text.
2014 1293 *
2015 1294 * @return string Random feature text.
2016 1295 * @since 1.9.1
@@ -2072,9 +1351,14 @@
2072 1351 </svg>
2073 1352 <span><?php echo esc_html( $this->get_random_premium_feature_text() ); ?></span>
2074 1353 </div>
2075 1354 <?php
2076 - $upgrade_url = Helper::get_sureforms_website_url( 'pricing', [ 'utm_medium' => 'dashboard-widget' ] );
1355 + $upgrade_url = add_query_arg(
1356 + [
1357 + 'utm_medium' => 'dashboard-widget',
1358 + ],
1359 + Helper::get_sureforms_website_url( 'pricing' )
1360 + );
2077 1361 ?>
2078 1362 <a href="<?php echo esc_url( $upgrade_url ); ?>" class="srfm-upgrade-link" target="_blank">
2079 1363 <?php esc_html_e( 'Upgrade', 'sureforms' ); ?>
2080 1364 </a>