PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.11
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.11
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
sureforms / admin / admin.php

admin.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.11, at admin/admin.php

581 lines 19.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Class.
4 *
5 * @package sureforms.
6 */
7
8 namespace SRFM\Admin;
9
10 use SRFM\Inc\Traits\Get_Instance;
11 use SRFM\Inc\AI_Form_Builder\AI_Helper;
12 use SRFM\Inc\Helper;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17 /**
18 * Admin handler class.
19 *
20 * @since 0.0.1
21 */
22 class Admin {
23
24 use Get_Instance;
25
26 /**
27 * Class constructor.
28 *
29 * @return void
30 * @since 0.0.1
31 */
32 public function __construct() {
33 add_action( 'admin_menu', [ $this, 'add_menu_page' ], 9 );
34 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
35 add_action( 'admin_menu', [ $this, 'settings_page' ] );
36 add_action( 'admin_menu', [ $this, 'add_new_form' ] );
37 add_filter( 'plugin_action_links', [ $this, 'add_settings_link' ], 10, 2 );
38 add_action( 'enqueue_block_assets', [ $this, 'enqueue_styles' ] );
39 add_action( 'admin_head', [ $this, 'enqueue_header_styles' ] );
40 add_action( 'admin_body_class', [ $this, 'admin_template_picker_body_class' ] );
41
42 // this action is used to restrict Spectra's quick action bar on SureForms CPTS.
43 add_action( 'uag_enable_quick_action_sidebar', [ $this, 'restrict_spectra_quick_action_bar' ] );
44
45 add_action( 'current_screen', [ $this, 'enable_gutenberg_for_sureforms' ], 100 );
46 }
47
48 /**
49 * Enable Gutenberg for SureForms associated post types.
50 *
51 * @since 0.0.10
52 */
53 public function enable_gutenberg_for_sureforms() {
54
55 // Check if the Classic Editor plugin is active and if it is set to replace the block editor.
56 if ( ! class_exists( 'Classic_Editor' ) || 'block' === get_option( 'classic-editor-replace' ) ) {
57 return;
58 }
59
60 $srfm_post_types = apply_filters( 'srfm_enable_gutenberg_post_types', [ SRFM_FORMS_POST_TYPE ] );
61
62 if ( in_array( get_current_screen()->post_type, $srfm_post_types, true ) ) {
63 add_filter( 'use_block_editor_for_post_type', '__return_true', 110 );
64 add_filter( 'gutenberg_can_edit_post_type', '__return_true', 110 );
65 }
66 }
67
68
69 /**
70 * Sureforms editor header styles.
71 *
72 * @since 0.0.1
73 */
74 public function enqueue_header_styles() {
75 $current_screen = get_current_screen();
76 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
77 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
78
79 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
80
81 /* RTL */
82 if ( is_rtl() ) {
83 $file_prefix .= '-rtl';
84 }
85
86 if ( 'sureforms_form' === $current_screen->id ) {
87 wp_enqueue_style( SRFM_SLUG . '-editor-header-styles', $css_uri . 'header-styles' . $file_prefix . '.css', [], SRFM_VER );
88 }
89 }
90
91 /**
92 * Add menu page.
93 *
94 * @return void
95 * @since 0.0.1
96 */
97 public function add_menu_page() {
98 if ( ! current_user_can( 'manage_options' ) ) {
99 return;
100 }
101
102 $capability = 'manage_options';
103 $menu_slug = 'sureforms_menu';
104
105 $logo = file_get_contents( plugin_dir_path( SRFM_FILE ) . 'images/icon.svg' );
106 add_menu_page(
107 __( 'SureForms', 'sureforms' ),
108 __( 'SureForms', 'sureforms' ),
109 'edit_others_posts',
110 $menu_slug,
111 function () {},
112 'data:image/svg+xml;base64,' . base64_encode( $logo ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
113 30
114 );
115
116 // Add the Dashboard Submenu.
117 add_submenu_page(
118 $menu_slug,
119 __( 'Dashboard', 'sureforms' ),
120 __( 'Dashboard', 'sureforms' ),
121 $capability,
122 $menu_slug,
123 [ $this, 'render_dashboard' ]
124 );
125 }
126
127 /**
128 * Add Settings page.
129 *
130 * @return void
131 * @since 0.0.1
132 */
133 public function settings_page() {
134 $callback = [ $this, 'settings_page_callback' ];
135 add_submenu_page(
136 'sureforms_menu',
137 __( 'Settings', 'sureforms' ),
138 __( 'Settings', 'sureforms' ),
139 'edit_others_posts',
140 'sureforms_form_settings',
141 $callback
142 );
143
144 // Get the current submenu page.
145 $submenu_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $_GET['page'] does not provide nonce.
146
147 if ( ! isset( $_GET['tab'] ) && 'sureforms_form_settings' === $submenu_page ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $_GET['page'] does not provide nonce.
148 wp_safe_redirect( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) );
149 exit;
150 }
151 }
152
153 /**
154 * Render Admin Dashboard.
155 *
156 * @return void
157 * @since 0.0.1
158 */
159 public function render_dashboard() {
160 echo '<div id="srfm-dashboard-container"></div>';
161 }
162
163 /**
164 * Settings page callback.
165 *
166 * @return void
167 * @since 0.0.1
168 */
169 public function settings_page_callback() {
170 echo '<div id="srfm-settings-container"></div>';
171 }
172
173 /**
174 * Add new form menu item.
175 *
176 * @return void
177 * @since 0.0.1
178 */
179 public function add_new_form() {
180 add_submenu_page(
181 'sureforms_menu',
182 __( 'New Form', 'sureforms' ),
183 __( 'New Form', 'sureforms' ),
184 'edit_others_posts',
185 'add-new-form',
186 [ $this, 'add_new_form_callback' ],
187 2
188 );
189 }
190
191 /**
192 * Add new form mentu item callback.
193 *
194 * @return void
195 * @since 0.0.1
196 */
197 public function add_new_form_callback() {
198 echo '<div id="srfm-add-new-form-container"></div>';
199 }
200
201 /**
202 * Adds a settings link to the plugin action links on the plugins page.
203 *
204 * @param array $links An array of plugin action links.
205 * @param string $file The plugin file path.
206 * @return array The updated array of plugin action links.
207 * @since 0.0.1
208 */
209 public function add_settings_link( $links, $file ) {
210 if ( 'sureforms/sureforms.php' === $file ) {
211 $plugin_links = apply_filters(
212 'sureforms_plugin_action_links',
213 [
214 'sureforms_settings' => '<a href="' . esc_url( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) ) . '">' . esc_html__( 'Settings', 'sureforms' ) . '</a>',
215 ]
216 );
217 $links = array_merge( $plugin_links, $links );
218 }
219 return $links;
220 }
221
222 /**
223 * Sureforms block editor styles.
224 *
225 * @since 0.0.1
226 */
227 public function enqueue_styles() {
228 $current_screen = get_current_screen();
229
230 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
231 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
232
233 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
234 $vendor_css_uri = SRFM_URL . 'assets/css/minified/deps/';
235
236 /* RTL */
237 if ( is_rtl() ) {
238 $file_prefix .= '-rtl';
239 }
240
241 // Enqueue editor styles for post and page.
242 if ( SRFM_FORMS_POST_TYPE === $current_screen->post_type ) {
243 wp_enqueue_style( SRFM_SLUG . '-editor', $css_uri . 'backend/editor' . $file_prefix . '.css', [], SRFM_VER );
244 wp_enqueue_style( SRFM_SLUG . '-backend-blocks', $css_uri . 'blocks/default/backend' . $file_prefix . '.css', [], SRFM_VER );
245 wp_enqueue_style( SRFM_SLUG . '-intl', $vendor_css_uri . 'intl/intlTelInput-backend.min.css', [], SRFM_VER );
246 wp_enqueue_style( SRFM_SLUG . '-common', $css_uri . 'common' . $file_prefix . '.css', [], SRFM_VER );
247 wp_enqueue_style( SRFM_SLUG . '-reactQuill', $vendor_css_uri . 'quill/quill.snow.css', [], SRFM_VER );
248 wp_enqueue_style( SRFM_SLUG . '-single-form-modal', $css_uri . 'single-form-setting' . $file_prefix . '.css', [], SRFM_VER );
249 }
250
251 wp_enqueue_style( SRFM_SLUG . '-form-selector', $css_uri . 'srfm-form-selector' . $file_prefix . '.css', [], SRFM_VER );
252 wp_enqueue_style( SRFM_SLUG . '-common-editor', SRFM_URL . 'assets/build/common-editor.css', [], SRFM_VER, 'all' );
253 }
254
255 /**
256 * Get Breadcrumbs for current page.
257 *
258 * @since 0.0.1
259 * @return array Breadcrumbs Array.
260 */
261 public function get_breadcrumbs_for_current_page() {
262 global $post, $pagenow;
263 $breadcrumbs = [];
264
265 if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
266 $page_title = get_admin_page_title();
267 $breadcrumbs[] = [
268 'title' => $page_title,
269 'link' => '',
270 ];
271 } elseif ( $post && in_array( $pagenow, [ 'post.php', 'post-new.php', 'edit.php' ], true ) ) {
272 $post_type_obj = get_post_type_object( get_post_type() );
273 if ( $post_type_obj ) {
274 $post_type_plural = $post_type_obj->labels->name;
275 $breadcrumbs[] = [
276 'title' => $post_type_plural,
277 'link' => admin_url( 'edit.php?post_type=' . $post_type_obj->name ),
278 ];
279
280 if ( 'edit.php' === $pagenow && ! isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
281 $breadcrumbs[ count( $breadcrumbs ) - 1 ]['link'] = '';
282 } else {
283 $breadcrumbs[] = [
284 /* Translators: Post Title. */
285 'title' => sprintf( __( 'Edit %1$s', 'sureforms' ), get_the_title() ),
286 'link' => get_edit_post_link( $post->ID ),
287 ];
288 }
289 }
290 } else {
291 $current_screen = get_current_screen();
292 if ( $current_screen && 'sureforms_form' === $current_screen->post_type ) {
293 $breadcrumbs[] = [
294 'title' => 'Forms',
295 'link' => '',
296 ];
297 } elseif ( $current_screen && 'sureforms_entry' === $current_screen->post_type ) {
298 $breadcrumbs[] = [
299 'title' => 'Entries',
300 'link' => '',
301 ];
302 } else {
303 $breadcrumbs[] = [
304 'title' => '',
305 'link' => '',
306 ];
307 }
308 }
309
310 return $breadcrumbs;
311 }
312
313
314 /**
315 * Enqueue Admin Scripts.
316 *
317 * @return void
318 * @since 0.0.1
319 */
320 public function enqueue_scripts() {
321 $current_screen = get_current_screen();
322
323 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
324 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
325 $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/';
326 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
327
328 /* RTL */
329 if ( is_rtl() ) {
330 $file_prefix .= '-rtl';
331 }
332
333 $localization_data = [
334 'site_url' => get_site_url(),
335 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(),
336 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ),
337 'plugin_version' => SRFM_VER,
338 'global_settings_nonce' => current_user_can( 'manage_options' ) ? wp_create_nonce( 'wp_rest' ) : '',
339 'is_pro_active' => defined( 'SRFM_PRO_VER' ),
340 'pro_plugin_version' => defined( 'SRFM_PRO_VER' ) ? SRFM_PRO_VER : '',
341 'sureforms_pricing_page' => $this->get_sureforms_website_url( 'pricing' ),
342 'field_spacing_vars' => Helper::get_css_vars(),
343 ];
344
345 if ( class_exists( 'SRFM_PRO\Admin\Licensing' ) ) {
346 $license_active = \SRFM_PRO\Admin\Licensing::is_license_active();
347 $localization_data['is_license_active'] = $license_active;
348 }
349
350 if ( SRFM_FORMS_POST_TYPE === $current_screen->post_type || 'toplevel_page_sureforms_menu' === $current_screen->base || SRFM_ENTRIES_POST_TYPE === $current_screen->post_type
351 || 'sureforms_page_sureforms_form_settings' === $current_screen->id
352 ) {
353 $asset_handle = '-dashboard';
354
355 wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER );
356
357 $script_asset_path = SRFM_DIR . 'assets/build/dashboard.asset.php';
358 $script_info = file_exists( $script_asset_path )
359 ? include $script_asset_path
360 : [
361 'dependencies' => [],
362 'version' => SRFM_VER,
363 ];
364 wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/dashboard.js', $script_info['dependencies'], SRFM_VER, true );
365
366 wp_localize_script( SRFM_SLUG . $asset_handle, 'scIcons', [ 'path' => SRFM_URL . 'assets/build/icon-assets' ] );
367
368 $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings' );
369 wp_localize_script(
370 SRFM_SLUG . $asset_handle,
371 SRFM_SLUG . '_admin',
372 apply_filters(
373 SRFM_SLUG . '_admin_filter',
374 $localization_data
375 )
376 );
377 wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' );
378
379 }
380
381 if ( 'sureforms_page_sureforms_form_settings' === $current_screen->id ) {
382 wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . '.css', [], SRFM_VER );
383 }
384
385 // Admin Submenu Styles.
386 wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . '.css', [], SRFM_VER );
387
388 if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id || 'edit-' . SRFM_ENTRIES_POST_TYPE === $current_screen->id ) {
389 $asset_handle = 'page_header';
390
391 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
392 $script_info = file_exists( $script_asset_path )
393 ? include $script_asset_path
394 : [
395 'dependencies' => [],
396 'version' => SRFM_VER,
397 ];
398 wp_enqueue_script( SRFM_SLUG . '-form-page-header', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
399 wp_enqueue_style( SRFM_SLUG . '-form-archive-styles', $css_uri . 'form-archive-styles' . $file_prefix . '.css', [], SRFM_VER );
400 }
401 if ( 'sureforms_page_' . SRFM_FORMS_POST_TYPE . '_settings' === $current_screen->base ) {
402 $asset_handle = 'settings';
403
404 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
405 $script_info = file_exists( $script_asset_path )
406 ? include $script_asset_path
407 : [
408 'dependencies' => [],
409 'version' => SRFM_VER,
410 ];
411
412 wp_enqueue_script( SRFM_SLUG . '-settings', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true );
413 wp_enqueue_style( SRFM_SLUG . '-setting-styles', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [ 'wp-components' ], SRFM_VER, 'all' );
414 wp_localize_script(
415 SRFM_SLUG . '-settings',
416 SRFM_SLUG . '_admin',
417 $localization_data
418 );
419 }
420 if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) {
421 wp_enqueue_script( SRFM_SLUG . '-form-archive', $js_uri . 'form-archive' . $file_prefix . '.js', [], SRFM_VER, true );
422 wp_enqueue_script( SRFM_SLUG . '-export', $js_uri . 'export' . $file_prefix . '.js', [ 'wp-i18n' ], SRFM_VER, true );
423 wp_localize_script(
424 SRFM_SLUG . '-export',
425 SRFM_SLUG . '_export',
426 [
427 'ajaxurl' => admin_url( 'admin-ajax.php' ),
428 'srfm_export_nonce' => wp_create_nonce( 'export_form_nonce' ),
429 'site_url' => get_site_url(),
430 'srfm_import_endpoint' => '/wp-json/sureforms/v1/sureforms_import',
431 'import_form_nonce' => ( current_user_can( 'edit_posts' ) ) ? wp_create_nonce( 'wp_rest' ) : '',
432 ]
433 );
434
435 wp_enqueue_script( SRFM_SLUG . '-backend', $js_uri . 'backend' . $file_prefix . '.js', [], SRFM_VER, true );
436 wp_localize_script(
437 SRFM_SLUG . '-backend',
438 SRFM_SLUG . '_backend',
439 [
440 'site_url' => get_site_url(),
441 ]
442 );
443
444 }
445
446 if ( 'sureforms_page_add-new-form' === $current_screen->id ) {
447
448 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
449 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
450
451 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
452
453 /* RTL */
454 if ( is_rtl() ) {
455 $file_prefix .= '-rtl';
456 }
457
458 wp_enqueue_style( SRFM_SLUG . '-template-picker', $css_uri . 'template-picker' . $file_prefix . '.css', [], SRFM_VER );
459
460 $sureforms_admin = 'templatePicker';
461
462 $script_asset_path = SRFM_DIR . 'assets/build/' . $sureforms_admin . '.asset.php';
463 $script_info = file_exists( $script_asset_path )
464 ? include $script_asset_path
465 : [
466 'dependencies' => [],
467 'version' => SRFM_VER,
468 ];
469 wp_enqueue_script( SRFM_SLUG . '-template-picker', SRFM_URL . 'assets/build/' . $sureforms_admin . '.js', $script_info['dependencies'], SRFM_VER, true );
470
471 wp_localize_script(
472 SRFM_SLUG . '-template-picker',
473 SRFM_SLUG . '_admin',
474 [
475 'site_url' => get_site_url(),
476 'plugin_url' => SRFM_URL,
477 'preview_images_url' => SRFM_URL . 'images/template-previews/',
478 'admin_url' => admin_url( 'admin.php' ),
479 'new_template_picker_base_url' => admin_url( 'post-new.php?post_type=sureforms_form' ),
480 'capability' => current_user_can( 'edit_posts' ),
481 'template_picker_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'wp_rest' ) : '',
482 'is_pro_active' => defined( 'SRFM_PRO_VER' ),
483 'srfm_ai_usage_details' => AI_Helper::get_current_usage_details(),
484 'is_pro_license_active' => AI_Helper::is_pro_license_active(),
485 'srfm_ai_auth_user_email' => get_option( 'srfm_ai_auth_user_email' ),
486 'pricing_page_url' => $this->get_sureforms_website_url( 'pricing' ),
487 ]
488 );
489 }
490 // Quick action sidebar.
491 $default_allowed_quick_sidebar_blocks = apply_filters(
492 'srfm_quick_sidebar_allowed_blocks',
493 [
494 'srfm/input',
495 'srfm/email',
496 'srfm/textarea',
497 'srfm/checkbox',
498 'srfm/number',
499 'srfm/inline-button',
500 'srfm/advanced-heading',
501 ]
502 );
503 if ( ! is_array( $default_allowed_quick_sidebar_blocks ) ) {
504 $default_allowed_quick_sidebar_blocks = [];
505 }
506
507 $srfm_enable_quick_action_sidebar = get_option( 'srfm_enable_quick_action_sidebar' );
508 if ( ! $srfm_enable_quick_action_sidebar ) {
509 $srfm_enable_quick_action_sidebar = 'disabled';
510 }
511 $quick_sidebar_allowed_blocks = get_option( 'srfm_quick_sidebar_allowed_blocks' );
512 $quick_sidebar_allowed_blocks = ! empty( $quick_sidebar_allowed_blocks ) && is_array( $quick_sidebar_allowed_blocks ) ? $quick_sidebar_allowed_blocks : $default_allowed_quick_sidebar_blocks;
513 $srfm_ajax_nonce = wp_create_nonce( 'srfm_ajax_nonce' );
514 wp_enqueue_script( SRFM_SLUG . '-quick-action-siderbar', SRFM_URL . 'assets/build/quickActionSidebar.js', [], SRFM_VER, true );
515 wp_localize_script(
516 SRFM_SLUG . '-quick-action-siderbar',
517 SRFM_SLUG . '_quick_sidebar_blocks',
518 [
519 'allowed_blocks' => $quick_sidebar_allowed_blocks,
520 'srfm_enable_quick_action_sidebar' => $srfm_enable_quick_action_sidebar,
521 'srfm_ajax_nonce' => $srfm_ajax_nonce,
522 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ),
523 ]
524 );
525
526 /**
527 * Enqueuing SureTriggers Integration script.
528 * This script loads suretriggers iframe in Intergations tab.
529 */
530 if ( SRFM_FORMS_POST_TYPE === $current_screen->post_type ) {
531 wp_enqueue_script( SRFM_SLUG . '-suretriggers-integration', SRFM_SURETRIGGERS_INTERGATION_BASE_URL . 'js/v2/embed.js', [], SRFM_VER, true );
532 }
533 }
534
535 /**
536 * Form Template Picker Admin Body Classes
537 *
538 * @since 0.0.1
539 * @param string $classes Space separated class string.
540 */
541 public function admin_template_picker_body_class( $classes = '' ) {
542 $theme_builder_class = isset( $_GET['page'] ) && 'add-new-form' === $_GET['page'] ? 'srfm-template-picker' : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Fetching a $_GET value, no nonce available to validate.
543 $classes .= ' ' . $theme_builder_class . ' ';
544
545 return $classes;
546
547 }
548
549 /**
550 * Disable spectra's quick action bar in sureforms CPT.
551 *
552 * @param string $status current status of the quick action bar.
553 * @since 0.0.2
554 * @return string
555 */
556 public function restrict_spectra_quick_action_bar( $status ) {
557 $screen = get_current_screen();
558 if ( 'disabled' !== $status && isset( $screen->id ) && 'sureforms_form' === $screen->id ) {
559 $status = 'disabled';
560 }
561
562 return $status;
563 }
564
565 /**
566 * Get SureForms Website URL.
567 *
568 * @param string $trail The URL trail to append to SureForms website URL. The parameter should not include a leading slash as the base URL already ends with a trailing slash.
569 * @since 0.0.7
570 * @return string
571 */
572 public static function get_sureforms_website_url( $trail ) {
573 $url = SRFM_WEBSITE;
574 if ( ! empty( $trail ) && is_string( $trail ) ) {
575 $url = SRFM_WEBSITE . $trail;
576 }
577
578 return esc_url( $url );
579 }
580 }
581