| @@ -6,8 +6,14 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace SRFM\Admin; |
| 9 | 9 | |
| 10 | +use SRFM\Admin\Views\Entries_List_Table; | |
| 11 | +use SRFM\Admin\Views\Single_Entry; | |
| 12 | +use SRFM\Inc\AI_Form_Builder\AI_Helper; | |
| 13 | +use SRFM\Inc\Database\Tables\Entries; | |
| 14 | +use SRFM\Inc\Helper; | |
| 15 | +use SRFM\Inc\Post_Types; | |
| 10 | 16 | use SRFM\Inc\Traits\Get_Instance; |
| 11 | 17 | |
| 12 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | 19 | exit; // Exit if accessed directly. |
| @@ -17,9 +23,8 @@ | ||
| 17 | 23 | * |
| 18 | 24 | * @since 0.0.1 |
| 19 | 25 | */ |
| 20 | 26 | class Admin { |
| 21 | - | |
| 22 | 27 | use Get_Instance; |
| 23 | 28 | |
| 24 | 29 | /** |
| 25 | 30 | * Class constructor. |
| @@ -34,15 +39,95 @@ | ||
| 34 | 39 | add_action( 'admin_menu', [ $this, 'add_new_form' ] ); |
| 35 | 40 | add_filter( 'plugin_action_links', [ $this, 'add_settings_link' ], 10, 2 ); |
| 36 | 41 | add_action( 'enqueue_block_assets', [ $this, 'enqueue_styles' ] ); |
| 37 | 42 | add_action( 'admin_head', [ $this, 'enqueue_header_styles' ] ); |
| 38 | - add_action( 'admin_body_class', [ $this, 'admin_template_picker_body_class' ] ); | |
| 43 | + add_filter( 'admin_body_class', [ $this, 'admin_template_picker_body_class' ] ); | |
| 39 | 44 | |
| 40 | 45 | // this action is used to restrict Spectra's quick action bar on SureForms CPTS. |
| 41 | 46 | add_action( 'uag_enable_quick_action_sidebar', [ $this, 'restrict_spectra_quick_action_bar' ] ); |
| 47 | + | |
| 48 | + add_action( 'current_screen', [ $this, 'enable_gutenberg_for_sureforms' ], 100 ); | |
| 49 | + add_action( 'admin_notices', [ $this, 'srfm_pro_version_compatibility' ] ); | |
| 50 | + | |
| 51 | + // Handle entry actions. | |
| 52 | + add_action( 'admin_init', [ $this, 'handle_entry_actions' ] ); | |
| 53 | + add_action( 'admin_notices', [ Entries_List_Table::class, 'display_bulk_action_notice' ] ); | |
| 54 | + | |
| 55 | + // This action enqueues translations for NPS Survey library. | |
| 56 | + // A better solution will be required from library to resolve plugin conflict. | |
| 57 | + add_action( | |
| 58 | + 'admin_footer', | |
| 59 | + static function() { | |
| 60 | + Helper::register_script_translations( 'nps-survey-script' ); | |
| 61 | + }, | |
| 62 | + 1000 | |
| 63 | + ); | |
| 64 | + // Enfold theme compatibility to enable block editor for SureForms post type. | |
| 65 | + add_filter( 'avf_use_block_editor_for_post', [ $this, 'enable_block_editor_in_enfold_theme' ] ); | |
| 66 | + | |
| 67 | + // Add action links to the plugin page. | |
| 68 | + add_filter( 'plugin_action_links_' . SRFM_BASENAME, [ $this, 'add_action_links' ] ); | |
| 69 | + add_filter( 'wpforms_current_user_can', [ $this, 'disable_wpforms_capabilities' ], 10, 3 ); | |
| 42 | 70 | } |
| 43 | 71 | |
| 44 | 72 | /** |
| 73 | + * Show action on plugin page. | |
| 74 | + * | |
| 75 | + * @param array $links links. | |
| 76 | + * @return array | |
| 77 | + * @since 1.4.2 | |
| 78 | + */ | |
| 79 | + public function add_action_links( $links ) { | |
| 80 | + if ( ! defined( 'SRFM_PRO_FILE' ) && ! file_exists( WP_PLUGIN_DIR . '/sureforms-pro/sureforms-pro.php' ) ) { | |
| 81 | + // Display upsell link if SureForms Pro is not installed. | |
| 82 | + $upsell_link = add_query_arg( | |
| 83 | + [ | |
| 84 | + 'utm_medium' => 'plugin-list', | |
| 85 | + ], | |
| 86 | + Helper::get_sureforms_website_url( 'pricing' ) | |
| 87 | + ); | |
| 88 | + $links[] = '<a href="' . esc_url( $upsell_link ) . '" target="_blank" rel="noreferrer" class="sureforms-plugins-go-pro">' . esc_html__( 'Get SureForms Pro', 'sureforms' ) . '</a>'; | |
| 89 | + } | |
| 90 | + | |
| 91 | + return $links; | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Enable block editor in Enfold theme for SureForms post type. | |
| 96 | + * | |
| 97 | + * @param bool $use_block_editor Whether to use block editor. | |
| 98 | + * @since 1.3.1 | |
| 99 | + */ | |
| 100 | + public function enable_block_editor_in_enfold_theme( $use_block_editor ) { | |
| 101 | + // if SureForms form post type then return true. | |
| 102 | + if ( SRFM_FORMS_POST_TYPE === get_current_screen()->post_type ) { | |
| 103 | + return true; | |
| 104 | + } | |
| 105 | + return $use_block_editor; | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * Enable Gutenberg for SureForms associated post types. | |
| 110 | + * | |
| 111 | + * @since 0.0.10 | |
| 112 | + */ | |
| 113 | + public function enable_gutenberg_for_sureforms() { | |
| 114 | + /** | |
| 115 | + * Check if the classic editor is enabled from Classic Editor plugin settings or Divi settings. | |
| 116 | + */ | |
| 117 | + if ( 'block' === get_option( 'classic-editor-replace' ) || 'on' === get_option( 'et_enable_classic_editor' ) ) { | |
| 118 | + return; | |
| 119 | + } | |
| 120 | + | |
| 121 | + $srfm_post_types = apply_filters( 'srfm_enable_gutenberg_post_types', [ SRFM_FORMS_POST_TYPE ] ); | |
| 122 | + | |
| 123 | + if ( in_array( get_current_screen()->post_type, $srfm_post_types, true ) ) { | |
| 124 | + add_filter( 'use_block_editor_for_post_type', '__return_true', 110 ); | |
| 125 | + add_filter( 'gutenberg_can_edit_post_type', '__return_true', 110 ); | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | + /** | |
| 45 | 130 | * Sureforms editor header styles. |
| 46 | 131 | * |
| 47 | 132 | * @since 0.0.1 |
| 48 | 133 | */ |
| @@ -82,9 +167,10 @@ | ||
| 82 | 167 | __( 'SureForms', 'sureforms' ), |
| 83 | 168 | __( 'SureForms', 'sureforms' ), |
| 84 | 169 | 'edit_others_posts', |
| 85 | 170 | $menu_slug, |
| 86 | - function () {}, | |
| 171 | + static function () { | |
| 172 | + }, | |
| 87 | 173 | 'data:image/svg+xml;base64,' . base64_encode( $logo ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode |
| 88 | 174 | 30 |
| 89 | 175 | ); |
| 90 | 176 | |
| @@ -160,8 +246,17 @@ | ||
| 160 | 246 | 'add-new-form', |
| 161 | 247 | [ $this, 'add_new_form_callback' ], |
| 162 | 248 | 2 |
| 163 | 249 | ); |
| 250 | + add_submenu_page( | |
| 251 | + 'sureforms_menu', | |
| 252 | + __( 'Entries', 'sureforms' ), | |
| 253 | + __( 'Entries', 'sureforms' ), | |
| 254 | + 'edit_others_posts', | |
| 255 | + SRFM_ENTRIES, | |
| 256 | + [ $this, 'render_entries' ], | |
| 257 | + 3 | |
| 258 | + ); | |
| 164 | 259 | } |
| 165 | 260 | |
| 166 | 261 | /** |
| 167 | 262 | * Add new form mentu item callback. |
| @@ -173,8 +268,40 @@ | ||
| 173 | 268 | echo '<div id="srfm-add-new-form-container"></div>'; |
| 174 | 269 | } |
| 175 | 270 | |
| 176 | 271 | /** |
| 272 | + * Entries page callback. | |
| 273 | + * | |
| 274 | + * @since 0.0.13 | |
| 275 | + * @return void | |
| 276 | + */ | |
| 277 | + public function render_entries() { | |
| 278 | + // Render single entry view. | |
| 279 | + // Adding the phpcs ignore nonce verification as no database operations are performed in this function, it is used to display the single entry view. | |
| 280 | + 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. | |
| 281 | + $single_entry_view = new Single_Entry(); | |
| 282 | + $single_entry_view->render(); | |
| 283 | + return; | |
| 284 | + } | |
| 285 | + | |
| 286 | + // Render all entries view. | |
| 287 | + $entries_table = new Entries_List_Table(); | |
| 288 | + $entries_table->prepare_items(); | |
| 289 | + echo '<div class="wrap"><h1 class="wp-heading-inline">' . esc_html__( 'Entries', 'sureforms' ) . '</h1>'; | |
| 290 | + if ( empty( $entries_table->all_entries_count ) && empty( $entries_table->trash_entries_count ) ) { | |
| 291 | + $instance = Post_Types::get_instance(); | |
| 292 | + $instance->sureforms_render_blank_state( SRFM_ENTRIES ); | |
| 293 | + $instance->get_blank_state_styles(); | |
| 294 | + return; | |
| 295 | + } | |
| 296 | + echo '<form method="get">'; | |
| 297 | + echo '<input type="hidden" name="page" value="sureforms_entries">'; | |
| 298 | + $entries_table->display(); | |
| 299 | + echo '</form>'; | |
| 300 | + echo '</div>'; | |
| 301 | + } | |
| 302 | + | |
| 303 | + /** | |
| 177 | 304 | * Adds a settings link to the plugin action links on the plugins page. |
| 178 | 305 | * |
| 179 | 306 | * @param array $links An array of plugin action links. |
| 180 | 307 | * @param string $file The plugin file path. |
| @@ -182,10 +309,15 @@ | ||
| 182 | 309 | * @since 0.0.1 |
| 183 | 310 | */ |
| 184 | 311 | public function add_settings_link( $links, $file ) { |
| 185 | 312 | if ( 'sureforms/sureforms.php' === $file ) { |
| 186 | - $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) ) . '">' . esc_html__( 'Settings', 'sureforms' ) . '</a>'; | |
| 187 | - array_push( $links, $settings_link ); | |
| 313 | + $plugin_links = apply_filters( | |
| 314 | + 'sureforms_plugin_action_links', | |
| 315 | + [ | |
| 316 | + 'sureforms_settings' => '<a href="' . esc_url( admin_url( 'admin.php?page=sureforms_form_settings&tab=general-settings' ) ) . '">' . esc_html__( 'Settings', 'sureforms' ) . '</a>', | |
| 317 | + ] | |
| 318 | + ); | |
| 319 | + $links = array_merge( $plugin_links, $links ); | |
| 188 | 320 | } |
| 189 | 321 | return $links; |
| 190 | 322 | } |
| 191 | 323 | |
| @@ -195,8 +327,9 @@ | ||
| 195 | 327 | * @since 0.0.1 |
| 196 | 328 | */ |
| 197 | 329 | public function enqueue_styles() { |
| 198 | 330 | $current_screen = get_current_screen(); |
| 331 | + global $wp_version; | |
| 199 | 332 | |
| 200 | 333 | $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min'; |
| 201 | 334 | $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified'; |
| 202 | 335 | |
| @@ -214,8 +347,17 @@ | ||
| 214 | 347 | wp_enqueue_style( SRFM_SLUG . '-backend-blocks', $css_uri . 'blocks/default/backend' . $file_prefix . '.css', [], SRFM_VER ); |
| 215 | 348 | wp_enqueue_style( SRFM_SLUG . '-intl', $vendor_css_uri . 'intl/intlTelInput-backend.min.css', [], SRFM_VER ); |
| 216 | 349 | wp_enqueue_style( SRFM_SLUG . '-common', $css_uri . 'common' . $file_prefix . '.css', [], SRFM_VER ); |
| 217 | 350 | wp_enqueue_style( SRFM_SLUG . '-reactQuill', $vendor_css_uri . 'quill/quill.snow.css', [], SRFM_VER ); |
| 351 | + wp_enqueue_style( SRFM_SLUG . '-single-form-modal', $css_uri . 'single-form-setting' . $file_prefix . '.css', [], SRFM_VER ); | |
| 352 | + | |
| 353 | + // if version is equal to or lower than 6.6.2 then add compatibility css. | |
| 354 | + if ( version_compare( $wp_version, '6.6.2', '<=' ) ) { | |
| 355 | + $srfm_inline_css = '.srfm-settings-modal .srfm-setting-modal-container .components-toggle-control .components-base-control__help{ | |
| 356 | + margin-left: 4em; | |
| 357 | + }'; | |
| 358 | + wp_add_inline_style( SRFM_SLUG . '-single-form-modal', $srfm_inline_css ); | |
| 359 | + } | |
| 218 | 360 | } |
| 219 | 361 | |
| 220 | 362 | wp_enqueue_style( SRFM_SLUG . '-form-selector', $css_uri . 'srfm-form-selector' . $file_prefix . '.css', [], SRFM_VER ); |
| 221 | 363 | wp_enqueue_style( SRFM_SLUG . '-common-editor', SRFM_URL . 'assets/build/common-editor.css', [], SRFM_VER, 'all' ); |
| @@ -230,9 +372,9 @@ | ||
| 230 | 372 | public function get_breadcrumbs_for_current_page() { |
| 231 | 373 | global $post, $pagenow; |
| 232 | 374 | $breadcrumbs = []; |
| 233 | 375 | |
| 234 | - if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 376 | + if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We don't need nonce verification here. | |
| 235 | 377 | $page_title = get_admin_page_title(); |
| 236 | 378 | $breadcrumbs[] = [ |
| 237 | 379 | 'title' => $page_title, |
| 238 | 380 | 'link' => '', |
| @@ -245,9 +387,9 @@ | ||
| 245 | 387 | 'title' => $post_type_plural, |
| 246 | 388 | 'link' => admin_url( 'edit.php?post_type=' . $post_type_obj->name ), |
| 247 | 389 | ]; |
| 248 | 390 | |
| 249 | - if ( 'edit.php' === $pagenow && ! isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 391 | + if ( 'edit.php' === $pagenow && ! isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We don't need nonce verification here. | |
| 250 | 392 | $breadcrumbs[ count( $breadcrumbs ) - 1 ]['link'] = ''; |
| 251 | 393 | } else { |
| 252 | 394 | $breadcrumbs[] = [ |
| 253 | 395 | /* Translators: Post Title. */ |
| @@ -262,13 +404,8 @@ | ||
| 262 | 404 | $breadcrumbs[] = [ |
| 263 | 405 | 'title' => 'Forms', |
| 264 | 406 | 'link' => '', |
| 265 | 407 | ]; |
| 266 | - } elseif ( $current_screen && 'sureforms_entry' === $current_screen->post_type ) { | |
| 267 | - $breadcrumbs[] = [ | |
| 268 | - 'title' => 'Entries', | |
| 269 | - 'link' => '', | |
| 270 | - ]; | |
| 271 | 408 | } else { |
| 272 | 409 | $breadcrumbs[] = [ |
| 273 | 410 | 'title' => '', |
| 274 | 411 | 'link' => '', |
| @@ -278,9 +415,8 @@ | ||
| 278 | 415 | |
| 279 | 416 | return $breadcrumbs; |
| 280 | 417 | } |
| 281 | 418 | |
| 282 | - | |
| 283 | 419 | /** |
| 284 | 420 | * Enqueue Admin Scripts. |
| 285 | 421 | * |
| 286 | 422 | * @return void |
| @@ -287,22 +423,43 @@ | ||
| 287 | 423 | * @since 0.0.1 |
| 288 | 424 | */ |
| 289 | 425 | public function enqueue_scripts() { |
| 290 | 426 | $current_screen = get_current_screen(); |
| 427 | + global $wp_version; | |
| 291 | 428 | |
| 292 | - $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min'; | |
| 293 | - $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified'; | |
| 294 | - $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/'; | |
| 295 | - $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/'; | |
| 429 | + $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min'; | |
| 430 | + $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified'; | |
| 431 | + $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/'; | |
| 432 | + $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/'; | |
| 433 | + $is_rtl = is_rtl(); | |
| 434 | + $rtl = $is_rtl ? '-rtl' : ''; | |
| 296 | 435 | |
| 297 | - /* RTL */ | |
| 298 | - if ( is_rtl() ) { | |
| 299 | - $file_prefix .= '-rtl'; | |
| 300 | - } | |
| 436 | + /** | |
| 437 | + * List of the handles in which we need to add translation compatibility. | |
| 438 | + */ | |
| 439 | + $script_translations_handlers = []; | |
| 301 | 440 | |
| 302 | - if ( SRFM_FORMS_POST_TYPE === $current_screen->post_type || 'toplevel_page_sureforms_menu' === $current_screen->base || SRFM_ENTRIES_POST_TYPE === $current_screen->post_type | |
| 303 | - || 'sureforms_page_sureforms_form_settings' === $current_screen->id | |
| 304 | - ) { | |
| 441 | + $localization_data = [ | |
| 442 | + 'site_url' => get_site_url(), | |
| 443 | + 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(), | |
| 444 | + 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ), | |
| 445 | + 'plugin_version' => SRFM_VER, | |
| 446 | + 'global_settings_nonce' => current_user_can( 'manage_options' ) ? wp_create_nonce( 'wp_rest' ) : '', | |
| 447 | + 'is_pro_active' => defined( 'SRFM_PRO_VER' ), | |
| 448 | + 'pro_plugin_version' => defined( 'SRFM_PRO_VER' ) ? SRFM_PRO_VER : '', | |
| 449 | + 'pro_plugin_name' => defined( 'SRFM_PRO_VER' ) && defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro', | |
| 450 | + 'sureforms_pricing_page' => Helper::get_sureforms_website_url( 'pricing' ), | |
| 451 | + 'field_spacing_vars' => Helper::get_css_vars(), | |
| 452 | + 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ), | |
| 453 | + ]; | |
| 454 | + | |
| 455 | + $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' ); | |
| 456 | + $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' ); | |
| 457 | + $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' ); | |
| 458 | + $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' ); | |
| 459 | + $is_post_type_sureforms_form = SRFM_FORMS_POST_TYPE === $current_screen->post_type; | |
| 460 | + | |
| 461 | + if ( $is_screen_sureforms_menu || $is_post_type_sureforms_form || $is_screen_add_new_form || $is_screen_sureforms_form_settings || $is_screen_sureforms_entries ) { | |
| 305 | 462 | $asset_handle = '-dashboard'; |
| 306 | 463 | |
| 307 | 464 | wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER ); |
| 308 | 465 | |
| @@ -315,21 +472,31 @@ | ||
| 315 | 472 | ]; |
| 316 | 473 | wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/dashboard.js', $script_info['dependencies'], SRFM_VER, true ); |
| 317 | 474 | |
| 318 | 475 | wp_localize_script( SRFM_SLUG . $asset_handle, 'scIcons', [ 'path' => SRFM_URL . 'assets/build/icon-assets' ] ); |
| 476 | + | |
| 477 | + $script_translations_handlers[] = SRFM_SLUG . $asset_handle; | |
| 478 | + | |
| 479 | + if ( class_exists( 'SRFM_PRO\Admin\Licensing' ) ) { | |
| 480 | + $license_active = \SRFM_PRO\Admin\Licensing::is_license_active(); | |
| 481 | + $localization_data['is_license_active'] = $license_active; | |
| 482 | + | |
| 483 | + // Updating current licensing status. | |
| 484 | + $srfm_pro_license_status = get_option( 'srfm_pro_license_status', '' ); | |
| 485 | + $current_license_status = $license_active ? 'licensed' : 'unlicensed'; | |
| 486 | + if ( $current_license_status !== $srfm_pro_license_status ) { | |
| 487 | + update_option( 'srfm_pro_license_status', $current_license_status ); | |
| 488 | + } | |
| 489 | + } | |
| 490 | + | |
| 491 | + $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings' ); | |
| 492 | + $localization_data['integration_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=integration-settings' ); | |
| 319 | 493 | wp_localize_script( |
| 320 | 494 | SRFM_SLUG . $asset_handle, |
| 321 | 495 | SRFM_SLUG . '_admin', |
| 322 | 496 | apply_filters( |
| 323 | 497 | SRFM_SLUG . '_admin_filter', |
| 324 | - [ | |
| 325 | - 'site_url' => get_site_url(), | |
| 326 | - 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(), | |
| 327 | - 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ), | |
| 328 | - 'plugin_version' => SRFM_VER, | |
| 329 | - 'global_settings_nonce' => ( current_user_can( 'manage_options' ) ) ? wp_create_nonce( 'wp_rest' ) : '', | |
| 330 | - 'security_settings_url' => admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings' ), | |
| 331 | - ] | |
| 498 | + $localization_data | |
| 332 | 499 | ) |
| 333 | 500 | ); |
| 334 | 501 | wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' ); |
| 335 | 502 | |
| @@ -334,17 +501,38 @@ | ||
| 334 | 501 | wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' ); |
| 335 | 502 | |
| 336 | 503 | } |
| 337 | 504 | |
| 338 | - if ( 'sureforms_page_sureforms_form_settings' === $current_screen->id ) { | |
| 339 | - wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . '.css', [], SRFM_VER ); | |
| 505 | + if ( $is_screen_sureforms_form_settings ) { | |
| 506 | + wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . $rtl . '.css', [], SRFM_VER ); | |
| 507 | + | |
| 508 | + // if version is equal to or lower than 6.6.2 then add compatibility css. | |
| 509 | + if ( version_compare( $wp_version, '6.6.2', '<=' ) ) { | |
| 510 | + $srfm_inline_css = ' | |
| 511 | + .srfm-settings-page-container | |
| 512 | + .components-toggle-control { | |
| 513 | + .components-base-control__help{ | |
| 514 | + margin-left: 4em; | |
| 515 | + } | |
| 516 | + } | |
| 517 | + } | |
| 518 | + '; | |
| 519 | + wp_add_inline_style( SRFM_SLUG . '-settings', $srfm_inline_css ); | |
| 520 | + } | |
| 340 | 521 | } |
| 341 | 522 | |
| 523 | + // Enqueue styles for the entries page. | |
| 524 | + if ( $is_screen_sureforms_entries ) { | |
| 525 | + $asset_handle = '-entries'; | |
| 526 | + wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/entries.js', $script_info['dependencies'], SRFM_VER, true ); | |
| 527 | + | |
| 528 | + $script_translations_handlers[] = SRFM_SLUG . $asset_handle; | |
| 529 | + } | |
| 530 | + | |
| 342 | 531 | // Admin Submenu Styles. |
| 343 | - wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . '.css', [], SRFM_VER ); | |
| 344 | - wp_enqueue_style( SRFM_SLUG . '-single-form-modal', $css_uri . 'single-form-setting' . $file_prefix . '.css', [], SRFM_VER ); | |
| 532 | + wp_enqueue_style( SRFM_SLUG . '-admin', $css_uri . 'backend/admin' . $file_prefix . $rtl . '.css', [], SRFM_VER ); | |
| 345 | 533 | |
| 346 | - if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id || 'edit-' . SRFM_ENTRIES_POST_TYPE === $current_screen->id ) { | |
| 534 | + if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) { | |
| 347 | 535 | $asset_handle = 'page_header'; |
| 348 | 536 | |
| 349 | 537 | $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php'; |
| 350 | 538 | $script_info = file_exists( $script_asset_path ) |
| @@ -353,11 +541,14 @@ | ||
| 353 | 541 | 'dependencies' => [], |
| 354 | 542 | 'version' => SRFM_VER, |
| 355 | 543 | ]; |
| 356 | 544 | wp_enqueue_script( SRFM_SLUG . '-form-page-header', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true ); |
| 357 | - wp_enqueue_style( SRFM_SLUG . '-form-archive-styles', $css_uri . 'form-archive-styles' . $file_prefix . '.css', [], SRFM_VER ); | |
| 545 | + wp_enqueue_style( SRFM_SLUG . '-form-archive-styles', $css_uri . 'form-archive-styles' . $file_prefix . $rtl . '.css', [], SRFM_VER ); | |
| 546 | + | |
| 547 | + $script_translations_handlers[] = SRFM_SLUG . '-form-page-header'; | |
| 358 | 548 | } |
| 359 | - if ( 'sureforms_page_' . SRFM_FORMS_POST_TYPE . '_settings' === $current_screen->base ) { | |
| 549 | + | |
| 550 | + if ( $is_screen_sureforms_form_settings ) { | |
| 360 | 551 | $asset_handle = 'settings'; |
| 361 | 552 | |
| 362 | 553 | $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php'; |
| 363 | 554 | $script_info = file_exists( $script_asset_path ) |
| @@ -365,25 +556,22 @@ | ||
| 365 | 556 | : [ |
| 366 | 557 | 'dependencies' => [], |
| 367 | 558 | 'version' => SRFM_VER, |
| 368 | 559 | ]; |
| 560 | + | |
| 369 | 561 | wp_enqueue_script( SRFM_SLUG . '-settings', SRFM_URL . 'assets/build/' . $asset_handle . '.js', $script_info['dependencies'], SRFM_VER, true ); |
| 370 | 562 | wp_enqueue_style( SRFM_SLUG . '-setting-styles', SRFM_URL . 'assets/build/' . $asset_handle . '.css', [ 'wp-components' ], SRFM_VER, 'all' ); |
| 371 | 563 | wp_localize_script( |
| 372 | 564 | SRFM_SLUG . '-settings', |
| 373 | 565 | SRFM_SLUG . '_admin', |
| 374 | - [ | |
| 375 | - 'site_url' => get_site_url(), | |
| 376 | - 'breadcrumbs' => $this->get_breadcrumbs_for_current_page(), | |
| 377 | - 'sureforms_dashboard_url' => admin_url( '/admin.php?page=sureforms_menu' ), | |
| 378 | - 'plugin_version' => SRFM_VER, | |
| 379 | - 'global_settings_nonce' => current_user_can( 'manage_options' ) ? wp_create_nonce( 'wp_rest' ) : '', | |
| 380 | - ] | |
| 566 | + $localization_data | |
| 381 | 567 | ); |
| 568 | + | |
| 569 | + $script_translations_handlers[] = SRFM_SLUG . '-settings'; | |
| 382 | 570 | } |
| 383 | 571 | if ( 'edit-' . SRFM_FORMS_POST_TYPE === $current_screen->id ) { |
| 384 | 572 | wp_enqueue_script( SRFM_SLUG . '-form-archive', $js_uri . 'form-archive' . $file_prefix . '.js', [], SRFM_VER, true ); |
| 385 | - wp_enqueue_script( SRFM_SLUG . '-export', $js_uri . 'export' . $file_prefix . '.js', [], SRFM_VER, true ); | |
| 573 | + wp_enqueue_script( SRFM_SLUG . '-export', $js_uri . 'export' . $file_prefix . '.js', [ 'wp-i18n' ], SRFM_VER, true ); | |
| 386 | 574 | wp_localize_script( |
| 387 | 575 | SRFM_SLUG . '-export', |
| 388 | 576 | SRFM_SLUG . '_export', |
| 389 | 577 | [ |
| @@ -390,9 +578,10 @@ | ||
| 390 | 578 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 391 | 579 | 'srfm_export_nonce' => wp_create_nonce( 'export_form_nonce' ), |
| 392 | 580 | 'site_url' => get_site_url(), |
| 393 | 581 | 'srfm_import_endpoint' => '/wp-json/sureforms/v1/sureforms_import', |
| 394 | - 'import_form_nonce' => ( current_user_can( 'edit_posts' ) ) ? wp_create_nonce( 'wp_rest' ) : '', | |
| 582 | + 'import_form_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'wp_rest' ) : '', | |
| 583 | + 'import_btn_string' => __( 'Import Form', 'sureforms' ), | |
| 395 | 584 | ] |
| 396 | 585 | ); |
| 397 | 586 | |
| 398 | 587 | wp_enqueue_script( SRFM_SLUG . '-backend', $js_uri . 'backend' . $file_prefix . '.js', [], SRFM_VER, true ); |
| @@ -403,24 +592,16 @@ | ||
| 403 | 592 | 'site_url' => get_site_url(), |
| 404 | 593 | ] |
| 405 | 594 | ); |
| 406 | 595 | |
| 596 | + $script_translations_handlers[] = SRFM_SLUG . '-form-archive'; | |
| 597 | + $script_translations_handlers[] = SRFM_SLUG . '-export'; | |
| 598 | + $script_translations_handlers[] = SRFM_SLUG . '-backend'; | |
| 407 | 599 | } |
| 408 | 600 | |
| 409 | - if ( 'sureforms_page_add-new-form' === $current_screen->id ) { | |
| 601 | + if ( $is_screen_add_new_form ) { | |
| 602 | + wp_enqueue_style( SRFM_SLUG . '-template-picker', $css_uri . 'template-picker' . $file_prefix . $rtl . '.css', [], SRFM_VER ); | |
| 410 | 603 | |
| 411 | - $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min'; | |
| 412 | - $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified'; | |
| 413 | - | |
| 414 | - $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/'; | |
| 415 | - | |
| 416 | - /* RTL */ | |
| 417 | - if ( is_rtl() ) { | |
| 418 | - $file_prefix .= '-rtl'; | |
| 419 | - } | |
| 420 | - | |
| 421 | - wp_enqueue_style( SRFM_SLUG . '-template-picker', $css_uri . 'template-picker' . $file_prefix . '.css', [], SRFM_VER ); | |
| 422 | - | |
| 423 | 604 | $sureforms_admin = 'templatePicker'; |
| 424 | 605 | |
| 425 | 606 | $script_asset_path = SRFM_DIR . 'assets/build/' . $sureforms_admin . '.asset.php'; |
| 426 | 607 | $script_info = file_exists( $script_asset_path ) |
| @@ -442,10 +623,16 @@ | ||
| 442 | 623 | 'new_template_picker_base_url' => admin_url( 'post-new.php?post_type=sureforms_form' ), |
| 443 | 624 | 'capability' => current_user_can( 'edit_posts' ), |
| 444 | 625 | 'template_picker_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'wp_rest' ) : '', |
| 445 | 626 | 'is_pro_active' => defined( 'SRFM_PRO_VER' ), |
| 627 | + 'srfm_ai_usage_details' => AI_Helper::get_current_usage_details(), | |
| 628 | + 'is_pro_license_active' => AI_Helper::is_pro_license_active(), | |
| 629 | + 'srfm_ai_auth_user_email' => get_option( 'srfm_ai_auth_user_email' ), | |
| 630 | + 'pricing_page_url' => Helper::get_sureforms_website_url( 'pricing' ), | |
| 446 | 631 | ] |
| 447 | 632 | ); |
| 633 | + | |
| 634 | + $script_translations_handlers[] = SRFM_SLUG . '-template-picker'; | |
| 448 | 635 | } |
| 449 | 636 | // Quick action sidebar. |
| 450 | 637 | $default_allowed_quick_sidebar_blocks = apply_filters( |
| 451 | 638 | 'srfm_quick_sidebar_allowed_blocks', |
| @@ -452,10 +639,12 @@ | ||
| 452 | 639 | [ |
| 453 | 640 | 'srfm/input', |
| 454 | 641 | 'srfm/email', |
| 455 | 642 | 'srfm/textarea', |
| 643 | + 'srfm/checkbox', | |
| 456 | 644 | 'srfm/number', |
| 457 | - 'srfm/address', | |
| 645 | + 'srfm/inline-button', | |
| 646 | + 'srfm/advanced-heading', | |
| 458 | 647 | ] |
| 459 | 648 | ); |
| 460 | 649 | if ( ! is_array( $default_allowed_quick_sidebar_blocks ) ) { |
| 461 | 650 | $default_allowed_quick_sidebar_blocks = []; |
| @@ -478,22 +667,66 @@ | ||
| 478 | 667 | 'srfm_ajax_nonce' => $srfm_ajax_nonce, |
| 479 | 668 | 'srfm_ajax_url' => admin_url( 'admin-ajax.php' ), |
| 480 | 669 | ] |
| 481 | 670 | ); |
| 671 | + | |
| 672 | + $script_translations_handlers[] = SRFM_SLUG . '-quick-action-siderbar'; | |
| 673 | + | |
| 674 | + /** | |
| 675 | + * Enqueuing SureTriggers Integration script. | |
| 676 | + * This script loads suretriggers iframe in Intergations tab. | |
| 677 | + */ | |
| 678 | + if ( $is_post_type_sureforms_form ) { | |
| 679 | + wp_enqueue_script( SRFM_SLUG . '-suretriggers-integration', SRFM_SURETRIGGERS_INTEGRATION_BASE_URL . 'js/v2/embed.js', [], SRFM_VER, true ); | |
| 680 | + } | |
| 681 | + | |
| 682 | + // Check $script_translations_handlers is not empty before calling the function. | |
| 683 | + if ( ! empty( $script_translations_handlers ) ) { | |
| 684 | + // Remove duplicates values from the array. | |
| 685 | + $script_translations_handlers = array_unique( $script_translations_handlers ); | |
| 686 | + | |
| 687 | + foreach ( $script_translations_handlers as $script_handle ) { | |
| 688 | + Helper::register_script_translations( $script_handle ); | |
| 689 | + } | |
| 690 | + } | |
| 482 | 691 | } |
| 483 | 692 | |
| 484 | 693 | /** |
| 485 | 694 | * Form Template Picker Admin Body Classes |
| 695 | + * WordPress sometimes translates class names in the admin body tag, which can result in | |
| 696 | + * incorrect or missing class names when rendering the admin pages. This function ensures | |
| 697 | + * that essential class names are manually added to the body tag to maintain proper functionality. | |
| 486 | 698 | * |
| 487 | 699 | * @since 0.0.1 |
| 488 | 700 | * @param string $classes Space separated class string. |
| 489 | 701 | */ |
| 490 | 702 | public function admin_template_picker_body_class( $classes = '' ) { |
| 491 | - $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. | |
| 492 | - $classes .= ' ' . $theme_builder_class . ' '; | |
| 703 | + // Define an associative array of class names and their corresponding conditions. | |
| 704 | + // Each condition checks whether a specific request context matches. | |
| 705 | + $srfm_classes = [ | |
| 706 | + 'sureforms_page_sureforms_entries' => Helper::validate_request_context( SRFM_ENTRIES, 'page' ), | |
| 707 | + 'sureforms_page_sureforms_form_settings' => Helper::validate_request_context( 'sureforms_form_settings', 'page' ), | |
| 708 | + 'srfm-template-picker' => Helper::validate_request_context( 'add-new-form', 'page' ), | |
| 709 | + ]; | |
| 493 | 710 | |
| 711 | + $add_srfm_classes = ''; | |
| 712 | + | |
| 713 | + // Loop through the defined classes and conditions. | |
| 714 | + foreach ( $srfm_classes as $class => $condition ) { | |
| 715 | + // Check if the condition evaluates to true. | |
| 716 | + if ( $condition ) { | |
| 717 | + // Append the class to the existing classes string, followed by a space. | |
| 718 | + $add_srfm_classes .= empty( $add_srfm_classes ) ? $class : ' ' . $class; | |
| 719 | + } | |
| 720 | + } | |
| 721 | + | |
| 722 | + // Append the new classes to the existing classes string. | |
| 723 | + if ( ! empty( $add_srfm_classes ) ) { | |
| 724 | + $classes .= ' ' . $add_srfm_classes; | |
| 725 | + } | |
| 726 | + | |
| 727 | + // Return the updated list of classes. | |
| 494 | 728 | return $classes; |
| 495 | - | |
| 496 | 729 | } |
| 497 | 730 | |
| 498 | 731 | /** |
| 499 | 732 | * Disable spectra's quick action bar in sureforms CPT. |
| @@ -508,6 +741,127 @@ | ||
| 508 | 741 | $status = 'disabled'; |
| 509 | 742 | } |
| 510 | 743 | |
| 511 | 744 | return $status; |
| 745 | + } | |
| 746 | + | |
| 747 | + // Entries methods. | |
| 748 | + | |
| 749 | + /** | |
| 750 | + * Handle entry actions. | |
| 751 | + * | |
| 752 | + * @since 0.0.13 | |
| 753 | + * @return void | |
| 754 | + */ | |
| 755 | + public function handle_entry_actions() { | |
| 756 | + Entries_List_Table::process_bulk_actions(); | |
| 757 | + | |
| 758 | + if ( ! isset( $_GET['page'] ) || SRFM_ENTRIES !== $_GET['page'] ) { | |
| 759 | + return; | |
| 760 | + } | |
| 761 | + if ( ! isset( $_GET['entry_id'] ) || ! isset( $_GET['action'] ) ) { | |
| 762 | + return; | |
| 763 | + } | |
| 764 | + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'srfm_entries_action' ) ) { | |
| 765 | + wp_die( esc_html__( 'Nonce verification failed.', 'sureforms' ) ); | |
| 766 | + } | |
| 767 | + $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; | |
| 768 | + $entry_id = Helper::get_integer_value( sanitize_text_field( wp_unslash( $_GET['entry_id'] ) ) ); | |
| 769 | + $view = isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : ''; | |
| 770 | + if ( $entry_id > 0 ) { | |
| 771 | + if ( 'read' === $action && 'details' === $view ) { | |
| 772 | + $entry_status = Entries::get( $entry_id )['status']; | |
| 773 | + if ( 'trash' === $entry_status ) { | |
| 774 | + wp_die( esc_html__( 'You cannot view this entry because it is in trash.', 'sureforms' ) ); | |
| 775 | + } | |
| 776 | + } | |
| 777 | + Entries_List_Table::handle_entry_status( $entry_id, $action, $view ); | |
| 778 | + } | |
| 779 | + } | |
| 780 | + | |
| 781 | + /** | |
| 782 | + * Admin Notice Callback if sureforms pro is out of date. | |
| 783 | + * | |
| 784 | + * Hooked - admin_notices | |
| 785 | + * | |
| 786 | + * @return void | |
| 787 | + * @since 1.0.4 | |
| 788 | + */ | |
| 789 | + public function srfm_pro_version_compatibility() { | |
| 790 | + $plugin_file = 'sureforms-pro/sureforms-pro.php'; | |
| 791 | + if ( ! is_plugin_active( $plugin_file ) || ! defined( 'SRFM_PRO_VER' ) ) { | |
| 792 | + return; | |
| 793 | + } | |
| 794 | + | |
| 795 | + if ( empty( get_current_screen() ) ) { | |
| 796 | + return; | |
| 797 | + } | |
| 798 | + | |
| 799 | + if ( ! current_user_can( 'update_plugins' ) ) { | |
| 800 | + return; | |
| 801 | + } | |
| 802 | + | |
| 803 | + $srfm_pro_license_status = get_option( 'srfm_pro_license_status', '' ); | |
| 804 | + /** | |
| 805 | + * If the license status is not set then get the license status and update the option accordingly. | |
| 806 | + * This will be executed only once. Subsequently, the option status is updated by the licensing class on license activation or deactivation. | |
| 807 | + */ | |
| 808 | + if ( empty( $srfm_pro_license_status ) && class_exists( 'SRFM_PRO\Admin\Licensing' ) ) { | |
| 809 | + $srfm_pro_license_status = \SRFM_PRO\Admin\Licensing::is_license_active() ? 'licensed' : 'unlicensed'; | |
| 810 | + update_option( 'srfm_pro_license_status', $srfm_pro_license_status ); | |
| 811 | + } | |
| 812 | + | |
| 813 | + $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro'; | |
| 814 | + $message = ''; | |
| 815 | + $url = admin_url( 'admin.php?page=sureforms_form_settings&tab=account-settings' ); | |
| 816 | + if ( 'unlicensed' === $srfm_pro_license_status ) { | |
| 817 | + $message = '<p>' . sprintf( | |
| 818 | + // translators: %1$s: Opening anchor tag with URL, %2$s: Closing anchor tag, %3$s: SureForms Pro Plugin Name. | |
| 819 | + esc_html__( 'Please %1$sactivate%2$s your copy of %3$s to get new features, access support, receive update notifications, and more.', 'sureforms' ), | |
| 820 | + '<a href="' . esc_url( $url ) . '">', | |
| 821 | + '</a>', | |
| 822 | + '<i>' . esc_html( $pro_plugin_name ) . '</i>' | |
| 823 | + ) . '</p>'; | |
| 824 | + } | |
| 825 | + | |
| 826 | + if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) { | |
| 827 | + $message .= '<p>' . sprintf( | |
| 828 | + // 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. | |
| 829 | + 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' ), | |
| 830 | + esc_html( SRFM_VER ), | |
| 831 | + esc_html( $pro_plugin_name ), | |
| 832 | + esc_html( SRFM_PRO_RECOMMENDED_VER ), | |
| 833 | + '<a href=' . esc_url( admin_url( 'update-core.php' ) ) . '>', | |
| 834 | + '</a>' | |
| 835 | + ) . '</p>'; | |
| 836 | + } | |
| 837 | + | |
| 838 | + if ( ! empty( $message ) ) { | |
| 839 | + // Phpcs ignore comment is required as $message variable is already escaped. | |
| 840 | + echo '<div class="notice notice-warning">' . wp_kses_post( $message ) . '</div>'; | |
| 841 | + } | |
| 842 | + } | |
| 843 | + | |
| 844 | + /** | |
| 845 | + * Disables the capabilities for WPForms to avoid conflicts when enqueueing | |
| 846 | + * scripts and styles for WPForms. | |
| 847 | + * | |
| 848 | + * This function is intended to prevent any potential conflicts that may arise | |
| 849 | + * when WPForms scripts and styles are enqueued. By disabling certain capabilities, | |
| 850 | + * it ensures that WPForms does not interfere with other functionalities. | |
| 851 | + * | |
| 852 | + * @param bool $user_can A boolean indicating whether the user has the capability. | |
| 853 | + * @return bool Returns true if the capabilities are successfully disabled, false otherwise. | |
| 854 | + * @since 1.4.2 | |
| 855 | + */ | |
| 856 | + public function disable_wpforms_capabilities( $user_can ) { | |
| 857 | + // Note: Nonce verification is intentionally omitted here as no database operations are performed. | |
| 858 | + // The values of the $_REQUEST variables are strictly validated, ensuring security without the need for nonce verification. | |
| 859 | + | |
| 860 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 861 | + $post_id = ! empty( $_REQUEST['post'] ) && ! empty( $_REQUEST['action'] ) ? absint( $_REQUEST['post'] ) : 0; | |
| 862 | + | |
| 863 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 864 | + $post_type = $post_id ? get_post_type( $post_id ) : sanitize_text_field( wp_unslash( $_REQUEST['post_type'] ?? '' ) ); | |
| 865 | + return SRFM_FORMS_POST_TYPE === $post_type ? false : $user_can; | |
| 512 | 866 | } |
| 513 | 867 | } |