PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.1.1
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.1.1
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 +83 -35 1.1.01.1.1 View file →
@@ -39,9 +39,9 @@
39 39 add_action( 'admin_menu', [ $this, 'add_new_form' ] );
40 40 add_filter( 'plugin_action_links', [ $this, 'add_settings_link' ], 10, 2 );
41 41 add_action( 'enqueue_block_assets', [ $this, 'enqueue_styles' ] );
42 42 add_action( 'admin_head', [ $this, 'enqueue_header_styles' ] );
43 - add_action( 'admin_body_class', [ $this, 'admin_template_picker_body_class' ] );
43 + add_filter( 'admin_body_class', [ $this, 'admin_template_picker_body_class' ] );
44 44
45 45 // this action is used to restrict Spectra's quick action bar on SureForms CPTS.
46 46 add_action( 'uag_enable_quick_action_sidebar', [ $this, 'restrict_spectra_quick_action_bar' ] );
47 47
@@ -401,14 +401,15 @@
401 401 'field_spacing_vars' => Helper::get_css_vars(),
402 402 'is_ver_lower_than_6_7' => version_compare( $wp_version, '6.6.2', '<=' ),
403 403 ];
404 404
405 - if ( class_exists( 'SRFM_PRO\Admin\Licensing' ) ) {
406 - $license_active = \SRFM_PRO\Admin\Licensing::is_license_active();
407 - $localization_data['is_license_active'] = $license_active;
408 - }
405 + $is_screen_sureforms_menu = Helper::validate_request_context( 'sureforms_menu', 'page' );
406 + $is_screen_add_new_form = Helper::validate_request_context( 'add-new-form', 'page' );
407 + $is_screen_sureforms_form_settings = Helper::validate_request_context( 'sureforms_form_settings', 'page' );
408 + $is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' );
409 + $is_post_type_sureforms_form = SRFM_FORMS_POST_TYPE === $current_screen->post_type;
409 410
410 - if ( SRFM_FORMS_POST_TYPE === $current_screen->post_type || 'toplevel_page_sureforms_menu' === $current_screen->base || 'sureforms_page_sureforms_form_settings' === $current_screen->id || 'sureforms_page_' . SRFM_ENTRIES === $current_screen->id ) {
411 + if ( $is_screen_sureforms_menu || $is_post_type_sureforms_form || $is_screen_add_new_form || $is_screen_sureforms_form_settings || $is_screen_sureforms_entries ) {
411 412 $asset_handle = '-dashboard';
412 413
413 414 wp_enqueue_style( SRFM_SLUG . $asset_handle . '-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap', [], SRFM_VER );
414 415
@@ -424,8 +425,20 @@
424 425 wp_localize_script( SRFM_SLUG . $asset_handle, 'scIcons', [ 'path' => SRFM_URL . 'assets/build/icon-assets' ] );
425 426
426 427 $script_translations_handlers[] = SRFM_SLUG . $asset_handle;
427 428
429 + if ( class_exists( 'SRFM_PRO\Admin\Licensing' ) ) {
430 + $license_active = \SRFM_PRO\Admin\Licensing::is_license_active();
431 + $localization_data['is_license_active'] = $license_active;
432 +
433 + // Updating current licensing status.
434 + $srfm_pro_license_status = get_option( 'srfm_pro_license_status', '' );
435 + $current_license_status = $license_active ? 'licensed' : 'unlicensed';
436 + if ( $current_license_status !== $srfm_pro_license_status ) {
437 + update_option( 'srfm_pro_license_status', $current_license_status );
438 + }
439 + }
440 +
428 441 $localization_data['security_settings_url'] = admin_url( '/admin.php?page=sureforms_form_settings&tab=security-settings' );
429 442 wp_localize_script(
430 443 SRFM_SLUG . $asset_handle,
431 444 SRFM_SLUG . '_admin',
@@ -437,9 +450,9 @@
437 450 wp_enqueue_style( SRFM_SLUG . '-dashboard', SRFM_URL . 'assets/build/dashboard.css', [], SRFM_VER, 'all' );
438 451
439 452 }
440 453
441 - if ( 'sureforms_page_sureforms_form_settings' === $current_screen->id ) {
454 + if ( $is_screen_sureforms_form_settings ) {
442 455 wp_enqueue_style( SRFM_SLUG . '-settings', $css_uri . 'backend/settings' . $file_prefix . '.css', [], SRFM_VER );
443 456
444 457 // if version is equal to or lower than 6.6.2 then add compatibility css.
445 458 if ( version_compare( $wp_version, '6.6.2', '<=' ) ) {
@@ -456,9 +469,9 @@
456 469 }
457 470 }
458 471
459 472 // Enqueue styles for the entries page.
460 - if ( 'sureforms_page_' . SRFM_ENTRIES === $current_screen->id ) {
473 + if ( $is_screen_sureforms_entries ) {
461 474 $asset_handle = '-entries';
462 475 wp_enqueue_style( SRFM_SLUG . $asset_handle, $css_uri . 'backend/entries' . $file_prefix . '.css', [], SRFM_VER );
463 476 wp_enqueue_script( SRFM_SLUG . $asset_handle, SRFM_URL . 'assets/build/entries.js', $script_info['dependencies'], SRFM_VER, true );
464 477
@@ -482,9 +495,10 @@
482 495 wp_enqueue_style( SRFM_SLUG . '-form-archive-styles', $css_uri . 'form-archive-styles' . $file_prefix . '.css', [], SRFM_VER );
483 496
484 497 $script_translations_handlers[] = SRFM_SLUG . '-form-page-header';
485 498 }
486 - if ( 'sureforms_page_' . SRFM_FORMS_POST_TYPE . '_settings' === $current_screen->base ) {
499 +
500 + if ( $is_screen_sureforms_form_settings ) {
487 501 $asset_handle = 'settings';
488 502
489 503 $script_asset_path = SRFM_DIR . 'assets/build/' . $asset_handle . '.asset.php';
490 504 $script_info = file_exists( $script_asset_path )
@@ -532,10 +546,9 @@
532 546 $script_translations_handlers[] = SRFM_SLUG . '-export';
533 547 $script_translations_handlers[] = SRFM_SLUG . '-backend';
534 548 }
535 549
536 - if ( 'sureforms_page_add-new-form' === $current_screen->id ) {
537 -
550 + if ( $is_screen_add_new_form ) {
538 551 $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min';
539 552 $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified';
540 553
541 554 $css_uri = SRFM_URL . 'assets/css/' . $dir_name . '/';
@@ -620,9 +633,9 @@
620 633 /**
621 634 * Enqueuing SureTriggers Integration script.
622 635 * This script loads suretriggers iframe in Intergations tab.
623 636 */
624 - if ( SRFM_FORMS_POST_TYPE === $current_screen->post_type ) {
637 + if ( $is_post_type_sureforms_form ) {
625 638 wp_enqueue_script( SRFM_SLUG . '-suretriggers-integration', SRFM_SURETRIGGERS_INTEGRATION_BASE_URL . 'js/v2/embed.js', [], SRFM_VER, true );
626 639 }
627 640
628 641 // Check $script_translations_handlers is not empty before calling the function.
@@ -637,16 +650,34 @@
637 650 }
638 651
639 652 /**
640 653 * Form Template Picker Admin Body Classes
654 + * WordPress sometimes translates class names in the admin body tag, which can result in
655 + * incorrect or missing class names when rendering the admin pages. This function ensures
656 + * that essential class names are manually added to the body tag to maintain proper functionality.
641 657 *
642 658 * @since 0.0.1
643 659 * @param string $classes Space separated class string.
644 660 */
645 661 public function admin_template_picker_body_class( $classes = '' ) {
646 - $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.
647 - $classes .= ' ' . $theme_builder_class . ' ';
662 + // Define an associative array of class names and their corresponding conditions.
663 + // Each condition checks whether a specific request context matches.
664 + $srfm_classes = [
665 + 'sureforms_page_sureforms_entries' => Helper::validate_request_context( SRFM_ENTRIES, 'page' ),
666 + 'sureforms_page_sureforms_form_settings' => Helper::validate_request_context( 'sureforms_form_settings', 'page' ),
667 + 'srfm-template-picker' => Helper::validate_request_context( 'add-new-form', 'page' ),
668 + ];
648 669
670 + // Loop through the defined classes and conditions.
671 + foreach ( $srfm_classes as $class => $condition ) {
672 + // Check if the condition evaluates to true.
673 + if ( $condition ) {
674 + // Append the class to the existing classes string, followed by a space.
675 + $classes .= $class . ' ';
676 + }
677 + }
678 +
679 + // Return the updated list of classes.
649 680 return $classes;
650 681 }
651 682
652 683 /**
@@ -689,12 +720,10 @@
689 720 * @since 0.0.13
690 721 * @return void
691 722 */
692 723 public function handle_entry_actions() {
693 - if ( isset( $_GET['entry'] ) && isset( $_GET['action'] ) ) {
694 - Entries_List_Table::process_bulk_actions();
695 - return;
696 - }
724 + Entries_List_Table::process_bulk_actions();
725 +
697 726 if ( ! isset( $_GET['page'] ) || SRFM_ENTRIES !== $_GET['page'] ) {
698 727 return;
699 728 }
700 729 if ( ! isset( $_GET['entry_id'] ) || ! isset( $_GET['action'] ) ) {
@@ -730,33 +759,52 @@
730 759 if ( ! is_plugin_active( $plugin_file ) || ! defined( 'SRFM_PRO_VER' ) ) {
731 760 return;
732 761 }
733 762
734 - if ( version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
763 + if ( empty( get_current_screen() ) ) {
735 764 return;
736 765 }
737 766
738 - if ( empty( get_current_screen() ) ) {
767 + if ( ! current_user_can( 'update_plugins' ) ) {
739 768 return;
740 769 }
741 770
742 - if ( ! current_user_can( 'update_plugins' ) ) {
743 - return;
771 + $srfm_pro_license_status = get_option( 'srfm_pro_license_status', '' );
772 + /**
773 + * If the license status is not set then get the license status and update the option accordingly.
774 + * This will be executed only once. Subsequently, the option status is updated by the licensing class on license activation or deactivation.
775 + */
776 + if ( empty( $srfm_pro_license_status ) && class_exists( 'SRFM_PRO\Admin\Licensing' ) ) {
777 + $srfm_pro_license_status = \SRFM_PRO\Admin\Licensing::is_license_active() ? 'licensed' : 'unlicensed';
778 + update_option( 'srfm_pro_license_status', $srfm_pro_license_status );
744 779 }
745 780
746 - $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
747 - $srfm_billing_portal = defined( 'SRFM_BILLING_PORTAL' ) ? SRFM_BILLING_PORTAL : 'https://billing.sureforms.com/';
748 - $message = '<p>' . sprintf(
749 - // 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.
750 - esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Download the latest ZIP from %4$s here%5$s.', 'sureforms' ),
751 - esc_html( SRFM_VER ),
752 - esc_html( $pro_plugin_name ),
753 - esc_html( SRFM_PRO_RECOMMENDED_VER ),
754 - '<a href="' . esc_url( $srfm_billing_portal ) . '" target="_blank">',
755 - '</a>'
756 - ) . '</p>';
781 + $pro_plugin_name = defined( 'SRFM_PRO_PRODUCT' ) ? SRFM_PRO_PRODUCT : 'SureForms Pro';
782 + $message = '';
783 + $url = admin_url( 'admin.php?page=sureforms_form_settings&tab=account-settings' );
784 + if ( 'unlicensed' === $srfm_pro_license_status ) {
785 + $message = '<p>' . sprintf(
786 + // translators: %1$s: Opening anchor tag with URL, %2$s: Closing anchor tag, %3$s: SureForms Pro Plugin Name.
787 + esc_html__( 'Please %1$sactivate%2$s your copy of %3$s to get new features, access support, receive update notifications, and more.', 'sureforms' ),
788 + '<a href="' . esc_url( $url ) . '">',
789 + '</a>',
790 + '<i>' . esc_html( $pro_plugin_name ) . '</i>'
791 + ) . '</p>';
792 + }
757 793
758 - // Phpcs ignore comment is required as $message variable is already escaped.
759 - echo '<div class="error">' . $message . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
794 + if ( ! version_compare( SRFM_PRO_VER, SRFM_PRO_RECOMMENDED_VER, '>=' ) ) {
795 + $message .= '<p>' . sprintf(
796 + // 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.
797 + esc_html__( 'SureForms %1$s requires minimum %2$s %3$s to work properly. Please update to the latest version.', 'sureforms' ),
798 + esc_html( SRFM_VER ),
799 + esc_html( $pro_plugin_name ),
800 + esc_html( SRFM_PRO_RECOMMENDED_VER ),
801 + ) . '</p>';
802 + }
803 +
804 + if ( ! empty( $message ) ) {
805 + // Phpcs ignore comment is required as $message variable is already escaped.
806 + echo '<div class="notice notice-warning">' . $message . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
807 + }
760 808 }
761 809
762 810 }