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 -1262 2.12.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,26 +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 - * Inline CSS for Quill 1.x (react-quill) list markers.
45 - *
46 - * Quill 1.x renders bullet/numbered list markers via CSS ::before pseudo-elements,
47 - * whereas the vendor quill.snow.css targets .ql-ui child elements (Quill 2.x approach).
48 - * This constant is shared by enqueue_styles() and enqueue_scripts() to prevent drift.
49 - *
50 - * @since 2.5.2
51 - */
52 - public const QUILL_1X_INLINE_CSS = '.ql-editor ul,.ql-editor ol{padding-left:1.5em}.ql-editor ul>li,.ql-editor ol>li{list-style-type:none}.ql-editor ol li:not(.ql-direction-rtl),.ql-editor ul li:not(.ql-direction-rtl){padding-left:1.5em}.ql-editor ol li.ql-direction-rtl,.ql-editor ul li.ql-direction-rtl{padding-right:1.5em}.ql-editor ul>li::before{content:"\2022"}.ql-editor li::before{display:inline-block;white-space:nowrap;width:1.2em}.ql-editor li:not(.ql-direction-rtl)::before{margin-left:-1.5em;margin-right:.3em;text-align:right}.ql-editor li.ql-direction-rtl::before{margin-left:.3em;margin-right:-1.5em}.ql-editor ol li{counter-reset:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;counter-increment:list-0}.ql-editor ol li::before{content:counter(list-0,decimal) ". "}.ql-editor ol li.ql-indent-1{counter-increment:list-1;counter-reset:list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-1::before{content:counter(list-1,lower-alpha) ". "}.ql-editor ol li.ql-indent-2{counter-increment:list-2;counter-reset:list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-2::before{content:counter(list-2,lower-roman) ". "}.ql-editor ol li.ql-indent-3{counter-increment:list-3;counter-reset:list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-3::before{content:counter(list-3,decimal) ". "}.ql-editor ol li.ql-indent-4{counter-increment:list-4;counter-reset:list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-4::before{content:counter(list-4,lower-alpha) ". "}.ql-editor ol li.ql-indent-5{counter-increment:list-5;counter-reset:list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-5::before{content:counter(list-5,lower-roman) ". "}.ql-editor ol li.ql-indent-6{counter-increment:list-6;counter-reset:list-7 list-8 list-9}.ql-editor ol li.ql-indent-6::before{content:counter(list-6,decimal) ". "}.ql-editor ol li.ql-indent-7{counter-increment:list-7;counter-reset:list-8 list-9}.ql-editor ol li.ql-indent-7::before{content:counter(list-7,lower-alpha) ". "}.ql-editor ol li.ql-indent-8{counter-increment:list-8;counter-reset:list-9}.ql-editor ol li.ql-indent-8::before{content:counter(list-8,lower-roman) ". "}.ql-editor ol li.ql-indent-9{counter-increment:list-9}.ql-editor ol li.ql-indent-9::before{content:counter(list-9,decimal) ". "}';
53 -
54 - /**
55 31 * Dashboard widget entries data.
56 32 *
57 33 * @var array
58 34 * @since 1.9.1
@@ -59,24 +35,8 @@
59 35 */
60 36 private $dashboard_widget_data = [];
61 37
62 38 /**
63 - * Cached result for whether the rating notice should display.
64 - *
65 - * @var bool|null
66 - * @since 2.5.2
67 - */
68 - private $should_show_rating = null;
69 -
70 - /**
71 - * SureForms Page Default permission.
72 - *
73 - * @var string
74 - * @since 1.12.2
75 - */
76 - private static $sureforms_page_default_capability = 'manage_options';
77 -
78 - /**
79 39 * Class constructor.
80 40 *
81 41 * @return void
82 42 * @since 0.0.1
@@ -84,15 +44,11 @@
84 44 public function __construct() {
85 45 add_action( 'admin_menu', [ $this, 'add_menu_page' ], 9 );
86 46 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
87 47 add_action( 'admin_menu', [ $this, 'settings_page' ] );
88 - add_action( 'admin_menu', [ $this, 'add_learn_page' ] );
89 48 add_action( 'admin_menu', [ $this, 'add_new_form' ] );
90 49 add_action( 'admin_menu', [ $this, 'add_suremail_page' ] );
91 50 if ( ! Helper::has_pro() ) {
92 - add_action( 'admin_menu', [ $this, 'add_quiz_page' ] );
93 - add_action( 'admin_menu', [ $this, 'add_survey_reports_page' ] );
94 - add_action( 'admin_menu', [ $this, 'add_partial_entries_page' ] );
95 51 add_action( 'admin_menu', [ $this, 'add_upgrade_to_pro' ] );
96 52 add_action( 'admin_footer', [ $this, 'add_upgrade_to_pro_target_attr' ] );
97 53 }
98 54
@@ -104,13 +60,23 @@
104 60 // this action is used to restrict Spectra's quick action bar on SureForms CPTS.
105 61 add_action( 'uag_enable_quick_action_sidebar', [ $this, 'restrict_spectra_quick_action_bar' ] );
106 62
107 63 add_action( 'current_screen', [ $this, 'enable_gutenberg_for_sureforms' ], 100 );
108 - // Register notices early for React pages (before admin_enqueue_scripts).
109 - add_action( 'admin_init', [ $this, 'register_pro_compatibility_notices' ], 5 );
110 - // Display notices on traditional WordPress admin pages.
111 64 add_action( 'admin_notices', [ $this, 'srfm_pro_version_compatibility' ] );
112 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 + );
113 79 // Enfold theme compatibility to enable block editor for SureForms post type.
114 80 add_filter( 'avf_use_block_editor_for_post', [ $this, 'enable_block_editor_in_enfold_theme' ] );
115 81
116 82 // Add action links to the plugin page.
@@ -121,9 +87,8 @@
121 87
122 88 if ( $admin_notification_on ) {
123 89 add_action( 'admin_menu', [ $this, 'maybe_add_entries_badge' ], 99 );
124 90 }
125 -
126 91 add_filter( 'wpforms_current_user_can', [ $this, 'disable_wpforms_capabilities' ], 10, 3 );
127 92
128 93 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_pointer' ] );
129 94 // Ajax callbacks for wp-pointer functionality.
@@ -129,190 +94,14 @@
129 94 // Ajax callbacks for wp-pointer functionality.
130 95 add_action( 'wp_ajax_should_show_pointer', [ $this, 'pointer_should_show' ] );
131 96 add_action( 'wp_ajax_sureforms_dismiss_pointer', [ $this, 'pointer_dismissed' ] );
132 97 add_action( 'wp_ajax_sureforms_accept_cta', [ $this, 'pointer_accepted_cta' ] );
133 - add_action( 'wp_ajax_srfm_notice_response', [ $this, 'handle_notice_response' ] );
134 - add_action( 'wp_ajax_srfm_ai_widget_usage', [ $this, 'track_ai_widget_usage' ] );
135 98
136 99 // Register dashboard widget only if there are recent entries.
137 100 add_action( 'admin_init', [ $this, 'maybe_register_dashboard_widget' ] );
138 -
139 - // Enqueue the AI quick draft widget script on the dashboard screen.
140 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_ai_dashboard_widget_assets' ] );
141 -
142 - // Save first form creation time stamp.
143 - add_action( 'admin_init', [ $this, 'save_first_form_creation_time_stamp' ] );
144 - add_action( 'admin_notices', [ $this, 'display_srfm_rating_notice' ] );
145 - add_action( 'admin_notices', [ $this, 'display_srfm_getting_started_notice' ] );
146 -
147 - /**
148 - * Suppress foreign (third-party) admin notices on SureForms admin screens.
149 - *
150 - * Some plugins (e.g. Ninja Forms) print large promotional banners on every
151 - * admin page via the admin_notices / all_admin_notices / network_admin_notices
152 - * hooks. These bleed onto SureForms' own React admin screens and break the UI.
153 - * We run at the EARLIEST priority on each notice hook (all third-party
154 - * callbacks are registered before these hooks fire, during admin_init /
155 - * plugin load) and strip the foreign ones before they are echoed, while
156 - * preserving SureForms' own notices. Scoped strictly to SureForms screens.
157 - */
158 - add_action( 'admin_notices', [ $this, 'suppress_foreign_admin_notices' ], PHP_INT_MIN );
159 - add_action( 'all_admin_notices', [ $this, 'suppress_foreign_admin_notices' ], PHP_INT_MIN );
160 - add_action( 'network_admin_notices', [ $this, 'suppress_foreign_admin_notices' ], PHP_INT_MIN );
161 101 }
162 102
163 103 /**
164 - * Remove third-party admin notices on SureForms admin screens.
165 - *
166 - * Iterates over the callbacks registered on the admin notice hooks and
167 - * removes any that are not owned by SureForms. A callback is considered
168 - * owned by SureForms when it belongs to a class in the `SRFM` / `SRFM_PRO`
169 - * namespaces or to the bundled `BSF_Admin_Notices` / `Astra_Notices`
170 - * notices library. SureForms' own notices are therefore preserved while
171 - * foreign promotional banners are suppressed.
172 - *
173 - * This callback is hooked at `PHP_INT_MIN` so that it runs first on each
174 - * notice hook and removes the foreign callbacks before WordPress echoes
175 - * them (WP_Hook honours removals made during iteration). It is strictly
176 - * scoped to SureForms admin screens via {@see Helper::is_sureforms_admin_page()}
177 - * so no other admin page is affected.
178 - *
179 - * @since 2.10.0
180 - * @return void
181 - */
182 - public function suppress_foreign_admin_notices() {
183 - // Bail early if we are not on a SureForms admin screen. This keeps the
184 - // suppression strictly scoped and avoids touching any other admin page.
185 - // is_sureforms_admin_page() covers the core screens (dashboard, add-new,
186 - // settings, entries, the form CPT); we additionally match any admin page
187 - // whose `page` slug is SureForms-owned (sureforms_* / srfm_*) so the
188 - // suppression also applies to the payments/quiz/survey/learn/SMTP screens.
189 - if ( ! Helper::is_sureforms_admin_page() && ! $this->is_sureforms_owned_admin_page() ) {
190 - return;
191 - }
192 -
193 - global $wp_filter;
194 -
195 - // The hook currently being fired (admin_notices, all_admin_notices or network_admin_notices).
196 - $current_hook = current_action();
197 -
198 - if ( empty( $current_hook ) || empty( $wp_filter[ $current_hook ] ) || ! ( $wp_filter[ $current_hook ] instanceof \WP_Hook ) ) {
199 - return;
200 - }
201 -
202 - foreach ( $wp_filter[ $current_hook ]->callbacks as $priority => $callbacks ) {
203 - foreach ( $callbacks as $callback ) {
204 - $function = $callback['function'] ?? null;
205 -
206 - // Never remove our own suppression callback.
207 - if ( is_array( $function ) && isset( $function[0] ) && $function[0] === $this && 'suppress_foreign_admin_notices' === $function[1] ) {
208 - continue;
209 - }
210 -
211 - // Preserve SureForms-owned notices, remove everything else.
212 - if ( $this->is_sureforms_owned_notice_callback( $function ) ) {
213 - continue;
214 - }
215 -
216 - remove_action( $current_hook, $function, $priority );
217 - }
218 - }
219 - }
220 -
221 - /**
222 - * Get the first form creation time stamp.
223 - *
224 - * @since 1.10.1
225 - * @return int|false
226 - */
227 - public static function get_first_form_creation_time_stamp() {
228 - return Helper::get_srfm_option( 'first_form_created_at', false );
229 - }
230 -
231 - /**
232 - * Check if the first form has been created.
233 - *
234 - * @since 1.10.1
235 - * @return bool
236 - */
237 - public static function is_first_form_created() {
238 - // Convert the first form creation time stamp to a boolean. If it exists, it will return true, otherwise false.
239 - $first_form_creation_time_stamp = self::get_first_form_creation_time_stamp();
240 -
241 - // If the first form creation time stamp is not set, return false.
242 - if ( ! $first_form_creation_time_stamp ) {
243 - return false; // No forms created yet.
244 - }
245 -
246 - // Check if the first form creation time stamp is a valid integer and greater than zero.
247 - return is_int( $first_form_creation_time_stamp ) && $first_form_creation_time_stamp > 0;
248 - }
249 -
250 - /**
251 - * Check and save the first form creation time stamp.
252 - * If not already saved.
253 - *
254 - * @since 1.10.1
255 - * @return void
256 - */
257 - public static function save_first_form_creation_time_stamp() {
258 - if ( ! Helper::current_user_can() || self::is_first_form_created() || ! defined( 'SRFM_FORMS_POST_TYPE' ) || ! post_type_exists( SRFM_FORMS_POST_TYPE ) ) {
259 - return;
260 - }
261 -
262 - // Get the first form creation time from the database that is published.
263 - $query = new \WP_Query(
264 - [
265 - 'post_type' => SRFM_FORMS_POST_TYPE,
266 - 'posts_per_page' => 1,
267 - 'orderby' => 'date',
268 - 'order' => 'ASC',
269 - 'fields' => 'ids',
270 - 'post_status' => 'publish',
271 - ]
272 - );
273 -
274 - if ( ! empty( $query->posts ) && isset( $query->posts[0] ) ) {
275 - // Get the first post from the query result.
276 - $post_id = $query->posts[0];
277 - // Get the post creation time in GMT.
278 - $creation_time = get_post_field( 'post_date_gmt', $post_id );
279 - // Convert the creation time to a timestamp.
280 - $timestamp = strtotime( $creation_time );
281 -
282 - if ( ! $timestamp ) {
283 - return;
284 - }
285 -
286 - Helper::update_srfm_option( 'first_form_created_at', $timestamp );
287 - }
288 - }
289 -
290 - /**
291 - * Check if n days have passed since the first form creation.
292 - * This is used to determine if the dynamic nudges should be shown.
293 - *
294 - * @param int $days Number of days to check.
295 - * @since 1.10.1
296 - * @return bool
297 - */
298 - public static function check_first_form_creation_threshold( $days = 3 ) {
299 - $first_form_creation_time_stamp = self::get_first_form_creation_time_stamp();
300 -
301 - if ( ! $first_form_creation_time_stamp ) {
302 - return false; // No forms created yet.
303 - }
304 -
305 - /**
306 - * Calculate the number of days since the first form was created.
307 - */
308 - $days_from_creation = ( strtotime( current_time( 'mysql' ) ) - $first_form_creation_time_stamp ) / DAY_IN_SECONDS;
309 -
310 - // Return a boolean indicating if the number of days since creation is greater than the specified days.
311 - return $days_from_creation > $days;
312 - }
313 -
314 - /**
315 104 * Show action on plugin page.
316 105 *
317 106 * @param array $links links.
318 107 * @return array
@@ -320,17 +109,15 @@
320 109 */
321 110 public function add_action_links( $links ) {
322 111 if ( ! Helper::has_pro() ) {
323 112 // Display upsell link if SureForms Pro is not installed.
324 - $upsell_link = Helper::get_sureforms_website_url( 'pricing', [ 'utm_medium' => 'plugin-list' ] );
325 -
326 - ob_start();
327 - ?>
328 - <a href="<?php echo esc_url( $upsell_link ); ?>" target="_blank" rel="noreferrer" class="sureforms-plugins-go-pro">
329 - <?php echo esc_html__( 'Get SureForms Pro', 'sureforms' ); ?>
330 - </a>
331 - <?php
332 - $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>';
333 120 }
334 121
335 122 return $links;
336 123 }
@@ -398,15 +185,20 @@
398 185 * @return void
399 186 * @since 0.0.1
400 187 */
401 188 public function add_menu_page() {
402 - $menu_slug = 'sureforms_menu';
189 + if ( ! current_user_can( 'manage_options' ) ) {
190 + return;
191 + }
403 192
193 + $capability = 'manage_options';
194 + $menu_slug = 'sureforms_menu';
195 +
404 196 $logo = file_get_contents( plugin_dir_path( SRFM_FILE ) . 'images/icon.svg' );
405 197 add_menu_page(
406 198 __( 'SureForms', 'sureforms' ),
407 199 __( 'SureForms', 'sureforms' ),
408 - self::$sureforms_page_default_capability,
200 + 'edit_others_posts',
409 201 $menu_slug,
410 202 static function () {
411 203 },
412 204 'data:image/svg+xml;base64,' . base64_encode( $logo ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
@@ -417,9 +209,9 @@
417 209 add_submenu_page(
418 210 $menu_slug,
419 211 __( 'Dashboard', 'sureforms' ),
420 212 __( 'Dashboard', 'sureforms' ),
421 - self::$sureforms_page_default_capability,
213 + $capability,
422 214 $menu_slug,
423 215 [ $this, 'render_dashboard' ]
424 216 );
425 217 }
@@ -435,9 +227,9 @@
435 227 add_submenu_page(
436 228 'sureforms_menu',
437 229 __( 'Settings', 'sureforms' ),
438 230 __( 'Settings', 'sureforms' ),
439 - self::$sureforms_page_default_capability,
231 + 'edit_others_posts',
440 232 'sureforms_form_settings',
441 233 $callback
442 234 );
443 235
@@ -482,119 +274,25 @@
482 274 */
483 275 public function add_upgrade_to_pro() {
484 276 // The url used here is used as a selector for css to style the upgrade to pro submenu.
485 277 // If you are changing this url, please make sure to update the css as well.
486 - $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 + );
487 284
488 285 add_submenu_page(
489 286 'sureforms_menu',
490 287 __( 'Upgrade', 'sureforms' ),
491 288 __( 'Upgrade', 'sureforms' ),
492 - self::$sureforms_page_default_capability,
289 + 'edit_others_posts',
493 290 $upgrade_url
494 291 );
495 292 }
496 293
497 294 /**
498 - * Add Quiz empty state submenu page for free users.
499 - *
500 - * @return void
501 - * @since 2.7.0
502 - */
503 - public function add_quiz_page() {
504 - add_submenu_page(
505 - 'sureforms_menu',
506 - __( 'Quiz Entries', 'sureforms' ),
507 - __( 'Quizzes', 'sureforms' ) .
508 - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' .
509 - esc_html__( 'New', 'sureforms' ) .
510 - '</span>',
511 - self::$sureforms_page_default_capability,
512 - 'sureforms_quiz_entries',
513 - [ $this, 'render_quiz_empty_state' ],
514 - 5
515 - );
516 - }
517 -
518 - /**
519 - * Quiz empty state page callback.
520 - *
521 - * @return void
522 - * @since 2.7.0
523 - */
524 - public function render_quiz_empty_state() {
525 - ?>
526 - <div id="srfm-quiz-entries-root" class="srfm-admin-wrapper"></div>
527 - <?php
528 - }
529 -
530 - /**
531 - * Add Survey Reports promotional submenu page for free users.
532 - *
533 - * @return void
534 - * @since 2.8.0
535 - */
536 - public function add_survey_reports_page() {
537 - add_submenu_page(
538 - 'sureforms_menu',
539 - __( 'Survey Reports', 'sureforms' ),
540 - __( 'Survey Reports', 'sureforms' ) .
541 - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' .
542 - esc_html__( 'New', 'sureforms' ) .
543 - '</span>',
544 - self::$sureforms_page_default_capability,
545 - 'sureforms_survey_reports',
546 - [ $this, 'render_survey_empty_state' ],
547 - 6
548 - );
549 - }
550 -
551 - /**
552 - * Survey empty state page callback.
553 - *
554 - * @return void
555 - * @since 2.8.0
556 - */
557 - public function render_survey_empty_state() {
558 - ?>
559 - <div id="srfm-survey-empty-state-root" class="srfm-admin-wrapper"></div>
560 - <?php
561 - }
562 -
563 - /**
564 - * Add Partial Entries promotional submenu page for free users.
565 - *
566 - * @return void
567 - * @since 2.9.0
568 - */
569 - public function add_partial_entries_page() {
570 - add_submenu_page(
571 - 'sureforms_menu',
572 - __( 'Partial Entries', 'sureforms' ),
573 - __( 'Partial Entries', 'sureforms' ) .
574 - ' <span style="color:#4ADE80;font-size:9px;font-weight:600;">' .
575 - esc_html__( 'New', 'sureforms' ) .
576 - '</span>',
577 - self::$sureforms_page_default_capability,
578 - 'sureforms_partial_entries',
579 - [ $this, 'render_partial_entries_empty_state' ],
580 - 7
581 - );
582 - }
583 -
584 - /**
585 - * Partial Entries empty state page callback.
586 - *
587 - * @return void
588 - * @since 2.9.0
589 - */
590 - public function render_partial_entries_empty_state() {
591 - ?>
592 - <div id="srfm-partial-entries-empty-state-root" class="srfm-admin-wrapper"></div>
593 - <?php
594 - }
595 -
596 - /**
597 295 * Add SMTP promotional submenu page.
598 296 *
599 297 * @return void
600 298 * @since 1.7.1
@@ -603,9 +301,9 @@
603 301 add_submenu_page(
604 302 'sureforms_menu',
605 303 __( 'SMTP', 'sureforms' ),
606 304 __( 'SMTP', 'sureforms' ),
607 - self::$sureforms_page_default_capability,
305 + 'edit_others_posts',
608 306 'sureforms_smtp',
609 307 [ $this, 'suremail_page_callback' ]
610 308 );
611 309
@@ -626,11 +324,9 @@
626 324 * @return void
627 325 * @since 1.7.1
628 326 */
629 327 public function suremail_page_callback() {
630 - ?>
631 - <div id="srfm-suremail-container" class="srfm-admin-wrapper"></div>
632 - <?php
328 + echo '<div id="srfm-suremail-container" class="srfm-admin-wrapper"></div>';
633 329 }
634 330
635 331 /**
636 332 * Render Admin Dashboard.
@@ -638,11 +334,9 @@
638 334 * @return void
639 335 * @since 0.0.1
640 336 */
641 337 public function render_dashboard() {
642 - ?>
643 - <div id="srfm-dashboard-container" class="srfm-admin-wrapper"></div>
644 - <?php
338 + echo '<div id="srfm-dashboard-container" class="srfm-admin-wrapper"></div>';
645 339 }
646 340
647 341 /**
648 342 * Settings page callback.
@@ -650,43 +344,12 @@
650 344 * @return void
651 345 * @since 0.0.1
652 346 */
653 347 public function settings_page_callback() {
654 - ?>
655 - <div id="srfm-settings-container" class="srfm-admin-wrapper"></div>
656 - <?php
348 + echo '<div id="srfm-settings-container" class="srfm-admin-wrapper"></div>';
657 349 }
658 350
659 351 /**
660 - * Add Learn submenu page.
661 - *
662 - * @return void
663 - * @since 2.5.2
664 - */
665 - public function add_learn_page() {
666 - add_submenu_page(
667 - 'sureforms_menu',
668 - __( 'Learn', 'sureforms' ),
669 - __( 'Learn', 'sureforms' ),
670 - self::$sureforms_page_default_capability,
671 - 'sureforms_learn',
672 - [ $this, 'render_learn' ]
673 - );
674 - }
675 -
676 - /**
677 - * Learn page callback.
678 - *
679 - * @return void
680 - * @since 2.5.2
681 - */
682 - public function render_learn() {
683 - ?>
684 - <div id="srfm-learn-root" class="srfm-admin-wrapper"></div>
685 - <?php
686 - }
687 -
688 - /**
689 352 * Add new form menu item.
690 353 *
691 354 * @return void
692 355 * @since 0.0.1
@@ -693,20 +356,11 @@
693 356 */
694 357 public function add_new_form() {
695 358 add_submenu_page(
696 359 'sureforms_menu',
697 - __( 'Forms', 'sureforms' ),
698 - __( 'Forms', 'sureforms' ),
699 - self::$sureforms_page_default_capability,
700 - 'sureforms_forms',
701 - [ $this, 'render_forms' ],
702 - 1
703 - );
704 - add_submenu_page(
705 - 'sureforms_menu',
706 360 __( 'New Form', 'sureforms' ),
707 361 __( 'New Form', 'sureforms' ),
708 - self::$sureforms_page_default_capability,
362 + 'edit_others_posts',
709 363 'add-new-form',
710 364 [ $this, 'add_new_form_callback' ],
711 365 2
712 366 );
@@ -713,24 +367,14 @@
713 367 $entries_hook = add_submenu_page(
714 368 'sureforms_menu',
715 369 __( 'Entries', 'sureforms' ),
716 370 __( 'Entries', 'sureforms' ),
717 - self::$sureforms_page_default_capability,
371 + 'edit_others_posts',
718 372 SRFM_ENTRIES,
719 373 [ $this, 'render_entries' ],
720 374 3
721 375 );
722 376
723 - add_submenu_page(
724 - 'sureforms_menu',
725 - __( 'Payments', 'sureforms' ),
726 - __( 'Payments', 'sureforms' ),
727 - self::$sureforms_page_default_capability,
728 - SRFM_PAYMENTS,
729 - [ $this, 'render_payments' ],
730 - 4
731 - );
732 -
733 377 if ( $entries_hook ) {
734 378 add_action( 'load-' . $entries_hook, [ $this, 'mark_entries_page_visit' ] );
735 379 }
736 380 }
@@ -735,20 +379,8 @@
735 379 }
736 380 }
737 381
738 382 /**
739 - * Payments page callback.
740 - *
741 - * @return void
742 - * @since 2.0.0
743 - */
744 - public function render_payments() {
745 - ?>
746 - <div id="srfm-payments-react-container" class="srfm-admin-wrapper"></div>
747 - <?php
748 - }
749 -
750 - /**
751 383 * Add new form mentu item callback.
752 384 *
753 385 * @return void
754 386 * @since 0.0.1
@@ -753,34 +385,41 @@
753 385 * @return void
754 386 * @since 0.0.1
755 387 */
756 388 public function add_new_form_callback() {
757 - ?>
758 - <div id="srfm-add-new-form-container" class="srfm-admin-wrapper"></div>
759 - <?php
389 + echo '<div id="srfm-add-new-form-container" class="srfm-admin-wrapper"></div>';
760 390 }
761 391
762 392 /**
763 - * Forms page callback.
764 - *
765 - * @return void
766 - * @since 2.0.0
767 - */
768 - public function render_forms() {
769 - ?>
770 - <div id="srfm-forms-root" class="srfm-admin-wrapper"></div>
771 - <?php
772 - }
773 -
774 - /**
775 393 * Entries page callback.
776 394 *
777 395 * @since 0.0.13
778 - * @since 2.0.0 - Updated the entries UI and the function definition.
779 396 * @return void
780 397 */
781 398 public function render_entries() {
782 - 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>';
783 422 }
784 423
785 424 /**
786 425 * Add notification badge to SureForms menu when there are new entries.
@@ -788,9 +427,9 @@
788 427 * @since 1.7.3
789 428 * @return void
790 429 */
791 430 public function maybe_add_entries_badge() {
792 - if ( ! Helper::current_user_can() ) {
431 + if ( ! current_user_can( 'edit_others_posts' ) ) {
793 432 return;
794 433 }
795 434
796 435 // If currently viewing the entries listing page, mark it as visited and skip the badge.
@@ -809,15 +448,10 @@
809 448
810 449 global $menu;
811 450 foreach ( $menu as $index => $item ) {
812 451 if ( isset( $item[2] ) && 'sureforms_menu' === $item[2] ) {
813 - ob_start();
814 - ?>
815 - <span class="srfm-update-dot"></span>
816 - <?php
817 - $dot_html = ob_get_clean();
818 452 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Adding notifications for menu item.
819 - $menu[ $index ][0] .= $dot_html;
453 + $menu[ $index ][0] .= ' <span class="srfm-update-dot"></span>';
820 454 break;
821 455 }
822 456 }
823 457
@@ -824,17 +458,12 @@
824 458 global $submenu;
825 459 if ( isset( $submenu['sureforms_menu'] ) ) {
826 460 foreach ( $submenu['sureforms_menu'] as $index => $sub_item ) {
827 461 if ( isset( $sub_item[2] ) && SRFM_ENTRIES === $sub_item[2] ) {
828 - ob_start();
829 - ?>
830 - <span class="update-plugins count-<?php echo absint( $new_entries ); ?>">
831 - <span class="plugin-count"><?php echo absint( $new_entries ); ?></span>
832 - </span>
833 - <?php
834 - $badge_html = ob_get_clean();
835 - // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Adding notifications for submenu item.
836 - $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 + );
837 466 break;
838 467 }
839 468 }
840 469 }
@@ -846,9 +475,9 @@
846 475 * @since 1.7.3
847 476 * @return void
848 477 */
849 478 public function mark_entries_page_visit() {
850 - if ( Helper::current_user_can() ) {
479 + if ( current_user_can( 'edit_others_posts' ) ) {
851 480 $srfm_options = get_option( 'srfm_options', [] );
852 481 $srfm_options['entries_last_visited'] = time();
853 482 \SRFM\Inc\Helper::update_admin_settings_option( 'srfm_options', $srfm_options );
854 483 }
@@ -863,22 +492,15 @@
863 492 * @since 0.0.1
864 493 */
865 494 public function add_settings_link( $links, $file ) {
866 495 if ( 'sureforms/sureforms.php' === $file ) {
867 - ob_start();
868 - ?>
869 - <a href="<?php echo esc_url( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) ); ?>">
870 - <?php echo esc_html__( 'Settings', 'sureforms' ); ?>
871 - </a>
872 - <?php
873 - $settings_link_html = ob_get_clean();
874 - $plugin_links = apply_filters(
496 + $plugin_links = apply_filters(
875 497 'sureforms_plugin_action_links',
876 498 [
877 - '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>',
878 500 ]
879 501 );
880 - $links = array_merge( $plugin_links, $links );
502 + $links = array_merge( $plugin_links, $links );
881 503 }
882 504 return $links;
883 505 }
884 506
@@ -908,9 +530,8 @@
908 530 wp_enqueue_style( SRFM_SLUG . '-backend-blocks', $css_uri . 'blocks/default/backend' . $file_prefix . '.css', [], SRFM_VER );
909 531 wp_enqueue_style( SRFM_SLUG . '-intl', $vendor_css_uri . 'intl/intlTelInput-backend.min.css', [], SRFM_VER );
910 532 wp_enqueue_style( SRFM_SLUG . '-common', $css_uri . 'common' . $file_prefix . '.css', [], SRFM_VER );
911 533 wp_enqueue_style( SRFM_SLUG . '-reactQuill', $vendor_css_uri . 'quill/quill.snow.css', [], SRFM_VER );
912 - wp_add_inline_style( SRFM_SLUG . '-reactQuill', self::QUILL_1X_INLINE_CSS );
913 534 wp_enqueue_style( SRFM_SLUG . '-single-form-modal', $css_uri . 'single-form-setting' . $file_prefix . '.css', [], SRFM_VER );
914 535
915 536 // if version is equal to or lower than 6.6.2 then add compatibility css.
916 537 if ( version_compare( $wp_version, '6.6.2', '<=' ) ) {
@@ -989,8 +610,9 @@
989 610 global $wp_version;
990 611
991 612 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
992 613 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
614 + $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/';
993 615 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
994 616 $is_rtl = is_rtl();
995 617 $rtl = $is_rtl ? '-rtl' : '';
996 618
@@ -998,134 +620,44 @@
998 620 * List of the handles in which we need to add translation compatibility.
999 621 */
1000 622 $script_translations_handlers = [];
1001 623 $onboarding_instance = Onboarding::get_instance();
1002 - $current_user = wp_get_current_user();
1003 624
1004 625 $localization_data = [
1005 - 'site_url' => get_site_url(),
1006 - 'current_user_login' => $current_user->user_login ?? '',
1007 - 'website_lead_details' => [
1008 - 'first_name' => $current_user->first_name ?? '',
1009 - 'last_name' => $current_user->last_name ?? '',
1010 - 'email' => $current_user->user_email ?? '',
1011 - ],
1012 - 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(),
1013 - 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ),
1014 - 'plugin_version' => SRFM_VER,
1015 - 'global_settings_nonce' => Helper::current_user_can() ? wp_create_nonce( 'wp_rest' ) : '',
1016 - 'is_pro_active' => Helper::has_pro(),
1017 - 'is_first_form_created' => self::is_first_form_created(),
1018 - 'check_three_days_threshold' => self::check_first_form_creation_threshold(),
1019 - 'check_eight_days_threshold' => self::check_first_form_creation_threshold( 8 ),
1020 - 'pro_plugin_version' => Helper::has_pro() ? SRFM_PRO_VER : '',
1021 - 'pro_plugin_name' => Helper::has_pro() && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro',
1022 - 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ),
1023 - 'field_spacing_vars' => Helper::get_css_vars(),
1024 - 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ),
1025 - 'integrations' => Helper::sureforms_get_integration(),
1026 - 'rotating_plugin_banner' => Helper::get_rotating_plugin_banner(),
1027 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
1028 - 'sf_plugin_manager_nonce' => wp_create_nonce( 'sf_plugin_manager_nonce' ),
1029 - 'plugin_installer_nonce' => wp_create_nonce( 'updates' ),
1030 - 'plugin_activating_text' => __( 'Activating...', 'sureforms' ),
1031 - 'plugin_activated_text' => __( 'Activated', 'sureforms' ),
1032 - 'plugin_activate_text' => __( 'Activate', 'sureforms' ),
1033 - 'plugin_installing_text' => __( 'Installing...', 'sureforms' ),
1034 - 'plugin_installed_text' => __( 'Installed', 'sureforms' ),
1035 - 'privacy_policy_url' => Helper::get_sureforms_website_url( 'privacy-policy/' ),
1036 - 'is_rtl' => $is_rtl,
1037 - 'onboarding_completed' => method_exists( $onboarding_instance, 'get_onboarding_status' ) ? $onboarding_instance->get_onboarding_status() : false,
1038 - 'migration_banner_dismissed' => method_exists( $onboarding_instance, 'is_migration_banner_dismissed' ) ? $onboarding_instance->is_migration_banner_dismissed() : false,
1039 - 'migration_settings_url' => admin_url( 'admin.php?page=sureforms_form_settings&tab=migration-settings' ),
1040 - 'onboarding_redirect' => isset( $_GET['srfm-activation-redirect'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not required for the activation redirection.
1041 - 'pointer_nonce' => wp_create_nonce( 'sureforms_pointer_action' ),
1042 - 'general_settings_url' => admin_url( '/options-general.php' ),
1043 - 'additional_header_nav_items' => [],
1044 - // Smart tags for the Global Defaults email notification fields.
1045 - // srfm_block_data is only available in the block editor; these keys
1046 - // make the same data accessible on the settings page via srfm_admin.
1047 - 'smart_tags_array' => Smart_Tags::smart_tag_list(),
1048 - 'smart_tags_array_email' => Smart_Tags::email_smart_tag_list(),
1049 - // Default confirmation message HTML (icon + heading + text) used as
1050 - // the initial React state before the settings API response arrives.
1051 - 'default_confirmation_message' => Global_Settings::get_default_confirmation_message(),
1052 - 'payments' => apply_filters(
1053 - 'srfm_admin_localize_payments_data',
1054 - [
1055 - 'stripe_connected' => Stripe_Helper::is_stripe_connected(),
1056 - 'stripe_mode' => Stripe_Helper::get_stripe_mode(),
1057 - 'stripe_connect_url' => Stripe_Helper::get_stripe_settings_url(),
1058 - 'currencies_data' => Payment_Helper::get_all_currencies_data(),
1059 - 'zero_decimal_currencies' => Payment_Helper::get_zero_decimal_currencies(),
1060 - 'webhook_url' => Stripe_Helper::get_webhook_url(),
1061 - 'webhook_test_connected' => Stripe_Helper::is_webhook_configured( 'test', true ),
1062 - 'webhook_live_connected' => Stripe_Helper::is_webhook_configured( 'live', true ),
1063 - 'is_transaction_present' => Stripe_Helper::is_transaction_present(),
1064 - 'payment_currency' => Payment_Helper::get_currency(),
1065 - 'currency_sign_position' => Payment_Helper::get_currency_sign_position(),
1066 - ]
1067 - ),
1068 - 'mcp_adapter_status' => file_exists( WP_PLUGIN_DIR . '/mcp-adapter/mcp-adapter.php' )
1069 - ? ( is_plugin_active( 'mcp-adapter/mcp-adapter.php' ) ? 'active' : 'installed' )
1070 - : 'not_installed',
1071 - '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(),
1072 651 ];
1073 652
1074 - $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' );
1075 - $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' );
1076 - $is_screen_sureforms_forms = Helper::validate_request_context( 'sureforms_forms', 'page' );
1077 - $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' );
1078 - $is_screen_sureforms_payments = Helper::validate_request_context( 'sureforms_payments', 'page' );
1079 - $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' );
1080 - $is_screen_sureforms_learn = Helper::validate_request_context( 'sureforms_learn', 'page' );
1081 - $is_screen_quiz_empty_state = Helper::validate_request_context( 'sureforms_quiz_entries', 'page' );
1082 - $is_screen_survey_empty_state = Helper::validate_request_context( 'sureforms_survey_reports', 'page' );
1083 - $is_screen_partial_entries_empty_state = Helper::validate_request_context( 'sureforms_partial_entries', 'page' );
1084 - $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;
1085 658
1086 - /**
1087 - * Check if the current screen is the SureForms Menu and AI Auth Email is present then we will add user type as registered.
1088 - * Compatibility with existing UI code that checks for this condition.
1089 - */
1090 - if ( $is_screen_sureforms_menu ) {
1091 - // If email is stored send the user type as registered else non-registered.
1092 - $localization_data['srfm_ai_details'] = [
1093 - 'type' => ! empty( get_option( 'srfm_ai_auth_user_email' ) ) ? 'registered' : 'non-registered',
1094 - ];
1095 - }
1096 -
1097 - // Add the Quizzes and Survey Reports nav items when pro is not active.
1098 - if ( ! Helper::has_pro() ) {
1099 - $localization_data['additional_header_nav_items'][] = [
1100 - 'slug' => 'sureforms_quiz_entries',
1101 - 'text' => __( 'Quizzes', 'sureforms' ),
1102 - 'link' => admin_url( 'admin.php?page=sureforms_quiz_entries' ),
1103 - ];
1104 - $localization_data['additional_header_nav_items'][] = [
1105 - 'slug' => 'sureforms_survey_reports',
1106 - 'text' => __( 'Survey Reports', 'sureforms' ),
1107 - 'link' => admin_url( 'admin.php?page=sureforms_survey_reports' ),
1108 - ];
1109 - $localization_data['additional_header_nav_items'][] = [
1110 - 'slug' => 'sureforms_partial_entries',
1111 - 'text' => __( 'Partial Entries', 'sureforms' ),
1112 - 'link' => admin_url( 'admin.php?page=sureforms_partial_entries' ),
1113 - ];
1114 - }
1115 -
1116 - $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;
1117 -
1118 - /**
1119 - * Filter to allow extending the SureForms dashboard screen check.
1120 - *
1121 - * @since 2.6.0
1122 - *
1123 - * @param bool $is_sureforms_screen Whether the current screen is a SureForms dashboard screen.
1124 - */
1125 - $is_sureforms_screen = apply_filters( 'srfm_is_dashboard_screen', $is_sureforms_screen );
1126 -
1127 - 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 ) {
1128 660 $asset_handle = '-dashboard';
1129 661
1130 662 wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER );
1131 663
@@ -1153,9 +685,9 @@
1153 685 update_option( 'srfm_pro_license_status', $current_license_status );
1154 686 }
1155 687 }
1156 688
1157 - $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' );
1158 690 $localization_data['integration_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=integration-settings' );
1159 691 wp_localize_script(
1160 692 SRFM_SLUG . $asset_handle,
1161 693 SRFM_SLUG . '_admin',
@@ -1164,11 +696,12 @@
1164 696 $localization_data
1165 697 )
1166 698 );
1167 699 wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' );
700 +
1168 701 }
1169 702
1170 - if ( $is_screen_sureforms_form_settings || $is_screen_sureforms_forms ) {
703 + if ( $is_screen_sureforms_form_settings ) {
1171 704 wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1172 705 }
1173 706
1174 707 // Enqueue styles for the entries page.
@@ -1175,61 +708,11 @@
1175 708 if ( $is_screen_sureforms_entries ) {
1176 709 $asset_handle = '-entries';
1177 710 wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/entries.js', $script_info['dependencies'], SRFM_VER, true );
1178 711
1179 - wp_localize_script(
1180 - SRFM_SLUG . $asset_handle,
1181 - SRFM_SLUG . '_admin',
1182 - apply_filters(
1183 - SRFM_SLUG . '_admin_filter',
1184 - $localization_data
1185 - )
1186 - );
1187 712 $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1188 713 }
1189 714
1190 - // Enqueue scripts for the learn page.
1191 - if ( $is_screen_sureforms_learn ) {
1192 - $asset_handle = '-learn';
1193 - wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/learn.js', $script_info['dependencies'], SRFM_VER, true );
1194 -
1195 - wp_localize_script(
1196 - SRFM_SLUG . $asset_handle,
1197 - SRFM_SLUG . '_admin',
1198 - apply_filters(
1199 - SRFM_SLUG . '_admin_filter',
1200 - $localization_data
1201 - )
1202 - );
1203 - $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1204 - }
1205 -
1206 - // Enqueue scripts for the forms page.
1207 - if ( $is_screen_sureforms_forms ) {
1208 - $asset_handle = '-forms';
1209 -
1210 - $script_asset_path = SRFM_DIR . 'assets/build/forms.asset.php';
1211 - $script_info = file_exists( $script_asset_path )
1212 - ? include $script_asset_path
1213 - : [
1214 - 'dependencies' => [],
1215 - 'version' => SRFM_VER,
1216 - ];
1217 -
1218 - wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.js', $script_info['dependencies'], SRFM_VER, true );
1219 - wp_localize_script(
1220 - SRFM_SLUG . $asset_handle,
1221 - SRFM_SLUG . '_admin',
1222 - apply_filters(
1223 - SRFM_SLUG . '_admin_filter',
1224 - $localization_data
1225 - )
1226 - );
1227 - wp_enqueue_style( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/forms.css', [], SRFM_VER, 'all' );
1228 -
1229 - $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
1230 - }
1231 -
1232 715 // Enqueue scripts for the SureMail promotional page.
1233 716 $is_screen_sureforms_smtp = Helper::validate_request_context( 'sureforms_smtp', 'page' );
1234 717 if ( $is_screen_sureforms_smtp ) {
1235 718 $asset_handle = 'suremail';
@@ -1268,65 +751,27 @@
1268 751
1269 752 $script_translations_handlers[] = SRFM_SLUG . '-suremail';
1270 753 }
1271 754
1272 - // Enqueue scripts for the Quiz empty state page (free users only).
1273 - if ( $is_screen_quiz_empty_state && ! Helper::has_pro() ) {
1274 - $asset_handle = 'quizEmptyState';
755 + // Admin Submenu Styles.
756 + wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1275 757
1276 - $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
1277 - $script_info = file_exists( $script_asset_path )
1278 - ? include $script_asset_path
1279 - : [
1280 - 'dependencies' => [],
1281 - 'version' => SRFM_VER,
1282 - ];
758 + if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) {
759 + $asset_handle = 'page_header';
1283 760
1284 - wp_enqueue_script( SRFM_SLUG . '-quiz-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1285 - wp_enqueue_style( SRFM_SLUG . '-quiz-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' );
1286 -
1287 - $script_translations_handlers[] = SRFM_SLUG . '-quiz-empty-state';
1288 - }
1289 -
1290 - // Enqueue scripts for the Survey Reports empty state page (free users only).
1291 - if ( $is_screen_survey_empty_state && ! Helper::has_pro() ) {
1292 - $asset_handle = 'surveyEmptyState';
1293 -
1294 761 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
1295 762 $script_info = file_exists( $script_asset_path )
1296 - ? include $script_asset_path
1297 - : [
1298 - 'dependencies' => [],
1299 - 'version' => SRFM_VER,
1300 - ];
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 );
1301 770
1302 - wp_enqueue_script( SRFM_SLUG . '-survey-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1303 - wp_enqueue_style( SRFM_SLUG . '-survey-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' );
1304 -
1305 - $script_translations_handlers[] = SRFM_SLUG . '-survey-empty-state';
771 + $script_translations_handlers[] = SRFM_SLUG . '-form-page-header';
1306 772 }
1307 773
1308 - // Enqueue scripts for the Partial Entries empty state page (free users only).
1309 - if ( $is_screen_partial_entries_empty_state && ! Helper::has_pro() ) {
1310 - $asset_handle = 'partialEntriesEmptyState';
1311 -
1312 - $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
1313 - $script_info = file_exists( $script_asset_path )
1314 - ? include $script_asset_path
1315 - : [
1316 - 'dependencies' => [],
1317 - 'version' => SRFM_VER,
1318 - ];
1319 -
1320 - wp_enqueue_script( SRFM_SLUG . '-partial-entries-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1321 - wp_enqueue_style( SRFM_SLUG . '-partial-entries-empty-state', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [], SRFM_VER, 'all' );
1322 -
1323 - $script_translations_handlers[] = SRFM_SLUG . '-partial-entries-empty-state';
1324 - }
1325 -
1326 - // Admin Submenu Styles.
1327 - wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER );
1328 -
1329 774 if ( $is_screen_sureforms_form_settings ) {
1330 775 $asset_handle = 'settings';
1331 776
1332 777 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
@@ -1340,20 +785,40 @@
1340 785 wp_enqueue_script( SRFM_SLUG . '-settings', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
1341 786 wp_localize_script(
1342 787 SRFM_SLUG . '-settings',
1343 788 SRFM_SLUG . '_admin',
1344 - apply_filters(
1345 - SRFM_SLUG . '_admin_filter',
1346 - $localization_data
1347 - )
789 + $localization_data
1348 790 );
1349 791
1350 - // Enqueue Tailwind and Quill editor styles for the settings page.
1351 - wp_enqueue_style( SRFM_SLUG . '-settings-build', SRFM_URL . 'assets/build/settings.css', [], SRFM_VER, 'all' );
1352 - wp_enqueue_style( SRFM_SLUG . '-reactQuill', SRFM_URL . 'assets/css/minified/deps/quill/quill.snow.css', [], SRFM_VER );
1353 - wp_add_inline_style( SRFM_SLUG . '-reactQuill', self::QUILL_1X_INLINE_CSS );
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 + );
1354 808
1355 - $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';
1356 821 }
1357 822
1358 823 if ( $is_screen_add_new_form ) {
1359 824 wp_enqueue_style( SRFM_SLUG . '-template-picker', $css_uri . 'template-picker' . $file_prefix . $rtl . '.css', [], SRFM_VER );
@@ -1374,12 +839,13 @@
1374 839 SRFM_SLUG . '_admin',
1375 840 [
1376 841 'site_url' => get_site_url(),
1377 842 'plugin_url' => SRFM_URL,
843 + 'preview_images_url' => SRFM_URL . 'images/template-previews/',
1378 844 'admin_url' => admin_url( 'admin.php' ),
1379 845 'new_template_picker_base_url' => admin_url( 'post-new.php?post_type=sureforms_form' ),
1380 - 'capability' => Helper::current_user_can(),
1381 - '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' ) : '',
1382 848 'is_pro_active' => Helper::has_pro(),
1383 849 'srfm_ai_usage_details' => AI_Helper::get_current_usage_details(),
1384 850 'is_pro_license_active' => AI_Helper::is_pro_license_active(),
1385 851 'srfm_ai_auth_user_email' => get_option( 'srfm_ai_auth_user_email' ),
@@ -1400,9 +866,8 @@
1400 866 'srfm/checkbox',
1401 867 'srfm/number',
1402 868 'srfm/inline-button',
1403 869 'srfm/advanced-heading',
1404 - 'srfm/payment',
1405 870 ]
1406 871 );
1407 872 if ( ! is_array( $default_allowed_quick_sidebar_blocks ) ) {
1408 873 $default_allowed_quick_sidebar_blocks = [];
@@ -1414,25 +879,22 @@
1414 879 }
1415 880 $quick_sidebar_allowed_blocks = get_option( 'srfm_quick_sidebar_allowed_blocks' );
1416 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;
1417 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 + );
1418 894
1419 - if ( Helper::is_sureforms_admin_page() ) {
1420 - wp_enqueue_script( SRFM_SLUG . '-quick-action-siderbar', SRFM_URL . 'assets/build/quickActionSidebar.js', [], SRFM_VER, true );
1421 - wp_localize_script(
1422 - SRFM_SLUG . '-quick-action-siderbar',
1423 - SRFM_SLUG . '_quick_sidebar_blocks',
1424 - [
1425 - 'allowed_blocks' => $quick_sidebar_allowed_blocks,
1426 - 'srfm_enable_quick_action_sidebar' => $srfm_enable_quick_action_sidebar,
1427 - 'srfm_ajax_nonce' => $srfm_ajax_nonce,
1428 - 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ),
1429 - ]
1430 - );
895 + $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar';
1431 896
1432 - $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar';
1433 - }
1434 -
1435 897 /**
1436 898 * Enqueuing SureTriggers Integration script.
1437 899 * This script loads suretriggers iframe in Intergations tab.
1438 900 */
@@ -1504,53 +966,40 @@
1504 966
1505 967 return $status;
1506 968 }
1507 969
970 + // Entries methods.
971 +
1508 972 /**
1509 - * Register Pro compatibility notices early for React pages.
973 + * Handle entry actions.
1510 974 *
1511 - * This method runs on admin_init (priority 5) to ensure notices are
1512 - * registered BEFORE admin_enqueue_scripts, so they're available when
1513 - * wp_localize_script runs.
1514 - *
1515 - * Hooked - admin_init (priority 5)
1516 - *
975 + * @since 0.0.13
1517 976 * @return void
1518 - * @since 2.5.0
1519 977 */
1520 - public function register_pro_compatibility_notices() {
1521 - // Early exit if Pro is not active, user lacks permissions, or Notice_Manager is unavailable.
1522 - 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'] ) {
1523 982 return;
1524 983 }
1525 -
1526 - // Register version outdated notice for React pages.
1527 - if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
1528 - $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
1529 - $react_outdated_message = sprintf(
1530 - // translators: %1$s: SureForms version, %2$s: SureForms Pro Plugin Name, %3$s: SureForms Pro Version.
1531 - esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version.', 'sureforms' ),
1532 - esc_html( SRFM_VER ),
1533 - esc_html( $pro_plugin_name ),
1534 - esc_html( SRFM_PRO_RECOMMENDED_VER )
1535 - );
1536 -
1537 - \SRFM\Admin\Notice_Manager::register_notice(
1538 - [
1539 - 'id' => 'sureforms-pro-version-outdated',
1540 - 'variant' => 'warning',
1541 - 'message' => $react_outdated_message,
1542 - 'actions' => [
1543 - [
1544 - 'label' => esc_html__( 'Update Now', 'sureforms' ),
1545 - 'url' => admin_url( 'update-core.php' ),
1546 - 'variant' => 'primary',
1547 - ],
1548 - ],
1549 - 'pages' => [ 'all' ],
1550 - ]
1551 - );
984 + if ( ! isset( $_GET['entry_id'] ) || ! isset( $_GET['action'] ) ) {
985 + return;
1552 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 + }
1553 1002 }
1554 1003
1555 1004 /**
1556 1005 * Admin Notice Callback if sureforms pro is out of date.
@@ -1568,9 +1017,9 @@
1568 1017 if ( empty( get_current_screen() ) ) {
1569 1018 return;
1570 1019 }
1571 1020
1572 - if ( ! Helper::current_user_can() ) {
1021 + if ( ! current_user_can( 'update_plugins' ) ) {
1573 1022 return;
1574 1023 }
1575 1024
1576 1025 $srfm_pro_license_status = get_option( 'srfm_pro_license_status', '' );
@@ -1586,214 +1035,36 @@
1586 1035 $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
1587 1036 $message = '';
1588 1037 $url = admin_url( 'admin.php?page=sureforms_form_settings&tab=account-settings' );
1589 1038 if ( 'unlicensed' === $srfm_pro_license_status ) {
1590 - ob_start();
1591 - ?>
1592 - <p>
1593 - <?php
1594 - printf(
1595 - // translators: %1$s: Opening anchor tag with URL, %2$s: Closing anchor tag, %3$s: SureForms Pro Plugin Name.
1596 - esc_html__( 'Please %1$sactivate%2$s your copy of %3$s to get new features, access support, receive update notifications, and more.', 'sureforms' ),
1597 - '<a href="' . esc_url( $url ) . '">',
1598 - '</a>',
1599 - '<i>' . esc_html( $pro_plugin_name ) . '</i>'
1600 - );
1601 - ?>
1602 - </p>
1603 - <?php
1604 - $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>';
1605 1046 }
1606 1047
1607 1048 if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
1608 - ob_start();
1609 - ?>
1610 - <p>
1611 - <?php
1612 - printf(
1613 - // 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.
1614 - 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' ),
1615 - esc_html( SRFM_VER ),
1616 - esc_html( $pro_plugin_name ),
1617 - esc_html( SRFM_PRO_RECOMMENDED_VER ),
1618 - '<a href="' . esc_url( admin_url( 'update-core.php' ) ) . '">',
1619 - '</a>'
1620 - );
1621 - ?>
1622 - </p>
1623 - <?php
1624 - $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>';
1625 1058 }
1626 1059
1627 1060 if ( ! empty( $message ) ) {
1628 1061 // Phpcs ignore comment is required as $message variable is already escaped.
1629 - ?>
1630 - <div class="notice notice-warning"><?php echo wp_kses_post( $message ); ?></div>
1631 - <?php
1062 + echo '<div class="notice notice-warning">' . wp_kses_post( $message ) . '</div>';
1632 1063 }
1633 1064 }
1634 1065
1635 1066 /**
1636 - * Display a notice to the user about providing a review.
1637 - *
1638 - * @since 2.5.2
1639 - * @return void
1640 - */
1641 - public function display_srfm_rating_notice() {
1642 - // Only show to admins.
1643 - if ( ! Helper::current_user_can() ) {
1644 - return;
1645 - }
1646 -
1647 - // Allow the notice to be disabled.
1648 - if ( ! apply_filters( 'srfm_show_rating_notice', true ) ) {
1649 - return;
1650 - }
1651 -
1652 - Astra_Notices::add_notice(
1653 - [
1654 - 'id' => 'srfm-plugin-review-notice',
1655 - 'type' => '',
1656 - 'message' => $this->build_notice_markup(
1657 - esc_html__( 'Amazing! SureForms is powering your forms and submissions - let\'s keep growing together!', 'sureforms' ),
1658 - esc_html__( 'If SureForms has been helpful, would you mind taking a moment to leave a 5-star review on WordPress.org?', 'sureforms' ),
1659 - esc_url( 'https://wordpress.org/support/plugin/sureforms/reviews/' ),
1660 - esc_html__( 'Rate SureForms', 'sureforms' ),
1661 - esc_html__( 'Maybe later', 'sureforms' ),
1662 - esc_html__( 'I already did', 'sureforms' ),
1663 - WEEK_IN_SECONDS,
1664 - true
1665 - ),
1666 - 'repeat-notice-after' => WEEK_IN_SECONDS,
1667 - 'show_if' => $this->maybe_display_rating_notice(),
1668 - 'display-with-other-notices' => true,
1669 - ]
1670 - );
1671 -
1672 - add_action( 'astra_notice_after_markup_srfm-plugin-review-notice', [ $this, 'enqueue_notice_response_script' ] );
1673 - }
1674 -
1675 - /**
1676 - * Display a "Getting Started" admin notice for new users who haven't yet
1677 - * reached the rating-notice milestone (3+ forms or 3+ entries).
1678 - *
1679 - * The Astra Notices library handles the 7-day delay via the
1680 - * `display-notice-after` parameter.
1681 - *
1682 - * @since 2.5.2
1683 - * @return void
1684 - */
1685 - public function display_srfm_getting_started_notice() {
1686 - // Only show to admins.
1687 - if ( ! Helper::current_user_can() ) {
1688 - return;
1689 - }
1690 -
1691 - // Allow the notice to be disabled programmatically.
1692 - if ( ! apply_filters( 'srfm_show_getting_started_notice', true ) ) {
1693 - return;
1694 - }
1695 -
1696 - Astra_Notices::add_notice(
1697 - [
1698 - 'id' => 'srfm-getting-started-notice',
1699 - 'type' => '',
1700 - 'message' => $this->build_notice_markup(
1701 - esc_html__( 'SureForms is ready to power your forms — explore what\'s possible!', 'sureforms' ),
1702 - esc_html__( 'Manage your forms, track submissions, and discover features like AI Form Builder, payment integrations, and more from the SureForms dashboard.', 'sureforms' ),
1703 - esc_url( admin_url( 'admin.php?page=sureforms_menu' ) ),
1704 - esc_html__( 'Go to Dashboard', 'sureforms' ),
1705 - esc_html__( 'Maybe later', 'sureforms' ),
1706 - esc_html__( 'I already know', 'sureforms' ),
1707 - WEEK_IN_SECONDS
1708 - ),
1709 - 'repeat-notice-after' => WEEK_IN_SECONDS,
1710 - 'show_if' => ! $this->maybe_display_rating_notice(),
1711 - 'display-notice-after' => WEEK_IN_SECONDS,
1712 - 'display-with-other-notices' => true,
1713 - ]
1714 - );
1715 -
1716 - add_action( 'astra_notice_after_markup_srfm-getting-started-notice', [ $this, 'enqueue_notice_response_script' ] );
1717 - }
1718 -
1719 - /**
1720 - * Enqueue the notice response analytics script.
1721 - *
1722 - * Called via the astra_notice_after_markup_{id} hook so the script
1723 - * only loads when a SureForms notice is actually rendered.
1724 - *
1725 - * @since 2.5.2
1726 - * @return void
1727 - */
1728 - public function enqueue_notice_response_script() {
1729 - if ( wp_script_is( 'srfm-notice-response', 'enqueued' ) ) {
1730 - return;
1731 - }
1732 -
1733 - wp_enqueue_script(
1734 - 'srfm-notice-response',
1735 - SRFM_URL . 'admin/assets/js/notice-response.js',
1736 - [],
1737 - SRFM_VER,
1738 - true
1739 - );
1740 -
1741 - wp_localize_script(
1742 - 'srfm-notice-response',
1743 - 'srfmNoticeResponse',
1744 - [
1745 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1746 - 'nonce' => wp_create_nonce( 'srfm_notice_response' ),
1747 - ]
1748 - );
1749 - }
1750 -
1751 - /**
1752 - * Handle the notice response AJAX request.
1753 - *
1754 - * Validates the request and records the analytics event
1755 - * for the notice button that was clicked.
1756 - *
1757 - * @since 2.5.2
1758 - * @return void
1759 - */
1760 - public function handle_notice_response() {
1761 - if ( ! check_ajax_referer( 'srfm_notice_response', 'nonce', false ) ) {
1762 - wp_send_json_error( [ 'message' => __( 'Invalid nonce.', 'sureforms' ) ], 403 );
1763 - }
1764 -
1765 - if ( ! Helper::current_user_can() ) {
1766 - wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1767 - }
1768 -
1769 - $notice_id = isset( $_POST['notice_id'] ) ? sanitize_text_field( wp_unslash( $_POST['notice_id'] ) ) : '';
1770 - $button = isset( $_POST['button'] ) ? sanitize_text_field( wp_unslash( $_POST['button'] ) ) : '';
1771 -
1772 - $valid = [
1773 - 'srfm-getting-started-notice' => [
1774 - 'go_to_dashboard' => 'getting_started_notice_cta',
1775 - 'maybe_later' => 'getting_started_notice_snooze',
1776 - 'dismissed' => 'getting_started_notice_dismiss',
1777 - ],
1778 - 'srfm-plugin-review-notice' => [
1779 - 'rate_sureforms' => 'rating_notice_cta',
1780 - 'maybe_later' => 'rating_notice_snooze',
1781 - 'dismissed' => 'rating_notice_dismiss',
1782 - ],
1783 - ];
1784 -
1785 - if ( ! isset( $valid[ $notice_id ][ $button ] ) ) {
1786 - wp_send_json_error( [ 'message' => __( 'Invalid parameters.', 'sureforms' ) ], 400 );
1787 - }
1788 -
1789 - $event_name = $valid[ $notice_id ][ $button ];
1790 - Analytics::events()->track( $event_name, $button );
1791 -
1792 - wp_send_json_success();
1793 - }
1794 -
1795 - /**
1796 1067 * Disables the capabilities for WPForms to avoid conflicts when enqueueing
1797 1068 * scripts and styles for WPForms.
1798 1069 *
1799 1070 * This function is intended to prevent any potential conflicts that may arise
@@ -1852,9 +1123,9 @@
1852 1123 * @since 1.8.0
1853 1124 */
1854 1125 public function pointer_should_show() {
1855 1126 // Security: Check user capability.
1856 - if ( ! Helper::current_user_can() ) {
1127 + if ( ! current_user_can( 'manage_options' ) ) {
1857 1128 wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1858 1129 }
1859 1130 // Security: Nonce check.
1860 1131 if ( empty( $_POST['pointer_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pointer_nonce'] ) ), 'sureforms_pointer_action' ) ) {
@@ -1890,9 +1161,9 @@
1890 1161 * @since 1.8.0
1891 1162 */
1892 1163 public function pointer_dismissed() {
1893 1164 // Security: Check user capability.
1894 - if ( ! Helper::current_user_can() ) {
1165 + if ( ! current_user_can( 'manage_options' ) ) {
1895 1166 wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1896 1167 }
1897 1168 // Security: Nonce check.
1898 1169 if ( empty( $_POST['pointer_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pointer_nonce'] ) ), 'sureforms_pointer_action' ) ) {
@@ -1911,9 +1182,9 @@
1911 1182 * @since 1.8.0
1912 1183 */
1913 1184 public function pointer_accepted_cta() {
1914 1185 // Security: Check user capability.
1915 - if ( ! Helper::current_user_can() ) {
1186 + if ( ! current_user_can( 'manage_options' ) ) {
1916 1187 wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
1917 1188 }
1918 1189 // Security: Nonce check.
1919 1190 if ( empty( $_POST['pointer_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pointer_nonce'] ) ), 'sureforms_pointer_action' ) ) {
@@ -1931,17 +1202,8 @@
1931 1202 * @return void
1932 1203 * @since 1.9.1
1933 1204 */
1934 1205 public function maybe_register_dashboard_widget() {
1935 -
1936 - // Only for users with manage_options capability.
1937 - if ( ! Helper::current_user_can() ) {
1938 - return;
1939 - }
1940 -
1941 - // Register the AI quick draft widget for capable users (the capability gate above applies); unlike the recent-entries widget below, it is not conditional on having entries.
1942 - add_action( 'wp_dashboard_setup', [ $this, 'register_ai_dashboard_widget' ] );
1943 -
1944 1206 // Quick check if there are any entries in the last 7 days.
1945 1207 $seven_days_ago = strtotime( '-7 days' );
1946 1208 $total_entries = Entries::get_entries_count_after( $seven_days_ago );
1947 1209
@@ -1976,180 +1238,8 @@
1976 1238 );
1977 1239 }
1978 1240
1979 1241 /**
1980 - * Register the AI quick draft dashboard widget.
1981 - *
1982 - * @return void
1983 - * @since 2.12.1
1984 - */
1985 - public function register_ai_dashboard_widget() {
1986 - wp_add_dashboard_widget(
1987 - 'sureforms_ai_quick_draft',
1988 - __( 'SureForms AI Quick Draft', 'sureforms' ),
1989 - [ $this, 'render_ai_dashboard_widget' ],
1990 - null,
1991 - null,
1992 - 'normal',
1993 - 'high'
1994 - );
1995 - }
1996 -
1997 - /**
1998 - * Render AI quick draft dashboard widget content.
1999 - *
2000 - * @return void
2001 - * @since 2.12.1
2002 - */
2003 - public function render_ai_dashboard_widget() {
2004 - ?>
2005 - <div class="srfm-ai-dashboard-widget">
2006 - <p>
2007 - <?php esc_html_e( 'Describe the form and let SureForms AI generate it for you.', 'sureforms' ); ?>
2008 - </p>
2009 - <label for="srfm-ai-dashboard-prompt" class="screen-reader-text">
2010 - <?php esc_html_e( 'Describe your form', 'sureforms' ); ?>
2011 - </label>
2012 - <textarea
2013 - id="srfm-ai-dashboard-prompt"
2014 - class="widefat"
2015 - rows="5"
2016 - maxlength="2000"
2017 - placeholder="<?php esc_attr_e( 'Example: Create a contact form with name, email, phone, and message fields.', 'sureforms' ); ?>"
2018 - ></textarea>
2019 - <p style="margin-top:10px;margin-bottom:0;display:flex;align-items:center;gap:10px;">
2020 - <button type="button" class="button button-primary" id="srfm-ai-dashboard-generate" disabled>
2021 - <?php esc_html_e( 'Create New Form', 'sureforms' ); ?>
2022 - </button>
2023 - <span id="srfm-ai-dashboard-char-count" style="color:#646970;">0/2000</span>
2024 - </p>
2025 - </div>
2026 - <?php
2027 - }
2028 -
2029 - /**
2030 - * Enqueue the AI quick draft dashboard widget script on the dashboard screen.
2031 - *
2032 - * The widget's behavior lives here (attached via wp_add_inline_script) rather than as an
2033 - * inline <script> in the render callback, so it passes Plugin Check and keeps server values
2034 - * out of the markup. Server values are passed through wp_localize_script.
2035 - *
2036 - * @param string $hook_suffix The current admin page hook suffix.
2037 - * @return void
2038 - * @since 2.12.1
2039 - */
2040 - public function enqueue_ai_dashboard_widget_assets( $hook_suffix ) {
2041 - // Only on the main dashboard, and only for capable users (matches the widget gate).
2042 - if ( 'index.php' !== $hook_suffix || ! Helper::current_user_can() ) {
2043 - return;
2044 - }
2045 -
2046 - // Register an inline-only handle (empty src) — the WordPress-core pattern for attaching
2047 - // localized data plus an inline script without shipping a separate asset file.
2048 - wp_register_script( 'srfm-ai-dashboard-widget', '', [], SRFM_VER, true );
2049 - wp_enqueue_script( 'srfm-ai-dashboard-widget' );
2050 -
2051 - wp_localize_script(
2052 - 'srfm-ai-dashboard-widget',
2053 - 'srfmAiDashboardWidget',
2054 - [
2055 - 'redirectUrl' => admin_url( 'admin.php?page=add-new-form' ),
2056 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
2057 - 'nonce' => wp_create_nonce( 'srfm_ai_widget_usage' ),
2058 - 'redirectingTxt' => __( 'Redirecting...', 'sureforms' ),
2059 - ]
2060 - );
2061 -
2062 - $inline_script = <<<'JS'
2063 -( function () {
2064 - const config = window.srfmAiDashboardWidget || {};
2065 - const generateButton = document.getElementById( 'srfm-ai-dashboard-generate' );
2066 - const promptField = document.getElementById( 'srfm-ai-dashboard-prompt' );
2067 - const charCount = document.getElementById( 'srfm-ai-dashboard-char-count' );
2068 - if ( ! generateButton || ! promptField ) {
2069 - return;
2070 - }
2071 -
2072 - const updateWidgetState = function () {
2073 - const promptValue = promptField.value.trim();
2074 - generateButton.disabled = ! promptValue;
2075 - if ( charCount ) {
2076 - charCount.textContent = `${ promptField.value.length }/2000`;
2077 - }
2078 - };
2079 -
2080 - const triggerGeneration = function () {
2081 - const prompt = promptField.value.trim();
2082 - if ( ! prompt ) {
2083 - promptField.focus();
2084 - return;
2085 - }
2086 -
2087 - generateButton.disabled = true;
2088 - generateButton.textContent = config.redirectingTxt;
2089 -
2090 - const redirectUrl = new URL( config.redirectUrl, window.location.origin );
2091 - redirectUrl.searchParams.set( 'srfm_ai_dashboard_prompt', prompt );
2092 -
2093 - const requestBody = new URLSearchParams();
2094 - requestBody.append( 'action', 'srfm_ai_widget_usage' );
2095 - requestBody.append( 'nonce', config.nonce );
2096 -
2097 - fetch( config.ajaxUrl, {
2098 - method: 'POST',
2099 - credentials: 'same-origin',
2100 - headers: {
2101 - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
2102 - },
2103 - body: requestBody.toString(),
2104 - } ).finally( function () {
2105 - window.location.href = redirectUrl.toString();
2106 - } );
2107 - };
2108 -
2109 - promptField.addEventListener( 'input', updateWidgetState );
2110 - generateButton.addEventListener( 'click', triggerGeneration );
2111 - promptField.addEventListener( 'keydown', function ( event ) {
2112 - if ( event.key === 'Enter' && ( event.metaKey || event.ctrlKey ) ) {
2113 - event.preventDefault();
2114 - triggerGeneration();
2115 - }
2116 - } );
2117 -
2118 - updateWidgetState();
2119 -}() );
2120 -JS;
2121 -
2122 - wp_add_inline_script( 'srfm-ai-dashboard-widget', $inline_script );
2123 - }
2124 -
2125 - /**
2126 - * Track AI dashboard widget usage.
2127 - *
2128 - * @return void
2129 - * @since 2.12.1
2130 - */
2131 - public function track_ai_widget_usage() {
2132 - if ( ! check_ajax_referer( 'srfm_ai_widget_usage', 'nonce', false ) ) {
2133 - wp_send_json_error( [ 'message' => __( 'Invalid nonce.', 'sureforms' ) ], 403 );
2134 - }
2135 -
2136 - if ( ! Helper::current_user_can() ) {
2137 - wp_send_json_error( [ 'message' => __( 'Unauthorized user.', 'sureforms' ) ], 403 );
2138 - }
2139 -
2140 - $current_count = (int) Helper::get_srfm_option( 'ai_dashboard_widget_uses', 0 ) + 1;
2141 - Helper::update_srfm_option( 'ai_dashboard_widget_uses', $current_count );
2142 -
2143 - // Emit an analytics event so usage lands in the warehouse via events_record.
2144 - // $force = true because this is a cumulative counter, not a one-time event —
2145 - // it must re-send the latest count each cycle (bypasses one-time dedup).
2146 - Analytics::events()->track( 'ai_dashboard_widget_used', (string) $current_count, [], true );
2147 -
2148 - wp_send_json_success();
2149 - }
2150 -
2151 - /**
2152 1242 * Render the dashboard widget content.
2153 1243 *
2154 1244 * @return void
2155 1245 * @since 1.9.1
@@ -2198,143 +1288,8 @@
2198 1288 <?php
2199 1289 }
2200 1290
2201 1291 /**
2202 - * Determine whether a notice callback is owned by SureForms.
2203 - *
2204 - * Recognises object methods on classes in the `SRFM` / `SRFM_PRO` namespaces
2205 - * as well as the bundled notices libraries (`BSF_Admin_Notices` and the
2206 - * legacy `Astra_Notices` alias). Everything else is treated as foreign.
2207 - *
2208 - * @param callable|array|string|null $function The registered callback function.
2209 - * @since 2.10.0
2210 - * @return bool True when the callback belongs to SureForms, false otherwise.
2211 - */
2212 - private function is_sureforms_owned_notice_callback( $function ) {
2213 - $class_name = '';
2214 -
2215 - if ( is_array( $function ) && isset( $function[0] ) ) {
2216 - // Object or static method callback represented as an array. The first
2217 - // element is either the object instance or the fully qualified class name.
2218 - $class_name = is_object( $function[0] ) ? get_class( $function[0] ) : (string) $function[0];
2219 - } elseif ( is_string( $function ) && false !== strpos( $function, '::' ) ) {
2220 - // Static method passed as "Class::method".
2221 - $class_name = strstr( $function, '::', true );
2222 - }
2223 -
2224 - if ( '' === $class_name ) {
2225 - // Plain function callbacks are never owned by SureForms.
2226 - return false;
2227 - }
2228 -
2229 - // SureForms (free and pro) namespaced classes. Pro's real namespace is
2230 - // `SRFM_Pro\` (case-sensitive) — not the all-caps `SRFM_PRO_` constant
2231 - // prefix — so match it case-insensitively to be safe.
2232 - if ( 0 === strpos( $class_name, 'SRFM\\' ) || 0 === stripos( $class_name, 'SRFM_Pro\\' ) ) {
2233 - return true;
2234 - }
2235 -
2236 - // Bundled notices library shipped with SureForms.
2237 - return in_array( $class_name, [ 'BSF_Admin_Notices', 'Astra_Notices' ], true );
2238 - }
2239 -
2240 - /**
2241 - * Whether the current admin page is a SureForms-owned screen identified by a
2242 - * `sureforms_*` / `srfm_*` `page` query slug. Complements
2243 - * {@see Helper::is_sureforms_admin_page()} so foreign-notice suppression also
2244 - * covers the payments / quiz / survey / learn / SMTP / partial-entries screens
2245 - * that the core helper does not enumerate. Read-only screen check.
2246 - *
2247 - * @since 2.10.0
2248 - * @return bool
2249 - */
2250 - private function is_sureforms_owned_admin_page() {
2251 - if ( ! is_admin() || empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection, no state change.
2252 - return false;
2253 - }
2254 - $page = sanitize_key( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection, no state change.
2255 - return 0 === strpos( $page, 'sureforms' ) || 0 === strpos( $page, 'srfm' );
2256 - }
2257 -
2258 - /**
2259 - * Build the shared HTML markup for admin notices.
2260 - *
2261 - * @since 2.5.2
2262 - *
2263 - * All text parameters must be pre-escaped by the caller (e.g. via esc_html__()).
2264 - * URL parameters must be pre-escaped via esc_url().
2265 - *
2266 - * @param string $heading The notice heading text (pre-escaped).
2267 - * @param string $message The notice body text (pre-escaped).
2268 - * @param string $cta_url The primary CTA URL (pre-escaped).
2269 - * @param string $cta_text The primary CTA button text (pre-escaped).
2270 - * @param string $snooze_text The snooze button text (pre-escaped).
2271 - * @param string $dismiss_text The dismiss button text (pre-escaped).
2272 - * @param int $snooze_duration Snooze duration in seconds for the data-repeat-notice-after attribute.
2273 - * @param bool $external_cta Whether the CTA opens in a new tab and also dismisses the notice
2274 - * via the astra-notice-close class. Default false.
2275 - * @return string The notice HTML markup.
2276 - */
2277 - private function build_notice_markup( $heading, $message, $cta_url, $cta_text, $snooze_text, $dismiss_text, $snooze_duration, $external_cta = false ) {
2278 - $image_path = esc_url( SRFM_URL . 'admin/assets/sureforms-logo.png' );
2279 - $cta_class = $external_cta ? 'astra-notice-close button-primary' : 'button-primary';
2280 - $cta_attrs = $external_cta ? ' target="_blank" rel="noopener noreferrer"' : '';
2281 -
2282 - return sprintf(
2283 - '<div class="notice-image">
2284 - <img src="%1$s" class="custom-logo" alt="SureForms" itemprop="logo">
2285 - </div>
2286 - <div class="notice-content">
2287 - <div class="notice-heading">
2288 - %2$s
2289 - </div>
2290 - %3$s<br />
2291 - <div class="astra-review-notice-container">
2292 - <a href="%4$s" class="%5$s"%6$s>
2293 - %7$s
2294 - </a>
2295 - <span class="dashicons dashicons-clock" aria-hidden="true"></span>
2296 - <a href="#" data-repeat-notice-after="%8$s" class="astra-notice-close">
2297 - %9$s
2298 - </a>
2299 - <span class="dashicons dashicons-smiley" aria-hidden="true"></span>
2300 - <a href="#" class="astra-notice-close">
2301 - %10$s
2302 - </a>
2303 - </div>
2304 - </div>',
2305 - $image_path,
2306 - $heading,
2307 - $message,
2308 - $cta_url,
2309 - esc_attr( $cta_class ),
2310 - $cta_attrs,
2311 - $cta_text,
2312 - $snooze_duration,
2313 - $snooze_text,
2314 - $dismiss_text
2315 - );
2316 - }
2317 -
2318 - /**
2319 - * Callback for displaying the rating notice conditionally.
2320 - *
2321 - * Returns true if the user has 3 or more published forms or 3 or more form entries.
2322 - *
2323 - * @since 2.5.2
2324 - * @return bool
2325 - */
2326 - private function maybe_display_rating_notice() {
2327 - if ( null === $this->should_show_rating ) {
2328 - $entries_count = Entries::get_total_entries_by_status( 'all' );
2329 - $form_count = wp_count_posts( SRFM_FORMS_POST_TYPE );
2330 - $this->should_show_rating = $entries_count >= self::RATING_NOTICE_THRESHOLD || Helper::get_integer_value( $form_count->publish ?? 0 ) >= self::RATING_NOTICE_THRESHOLD;
2331 - }
2332 -
2333 - return $this->should_show_rating;
2334 - }
2335 -
2336 - /**
2337 1292 * Get random premium feature text.
2338 1293 *
2339 1294 * @return string Random feature text.
2340 1295 * @since 1.9.1
@@ -2396,9 +1351,14 @@
2396 1351 </svg>
2397 1352 <span><?php echo esc_html( $this->get_random_premium_feature_text() ); ?></span>
2398 1353 </div>
2399 1354 <?php
2400 - $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 + );
2401 1361 ?>
2402 1362 <a href="<?php echo esc_url( $upgrade_url ); ?>" class="srfm-upgrade-link" target="_blank">
2403 1363 <?php esc_html_e( 'Upgrade', 'sureforms' ); ?>
2404 1364 </a>