From 0ec665db60ed8d5f79eb12ca15cecab250147cbf Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Tue, 3 Nov 2026 17:04:31 +0000 Subject: [PATCH] v3.3.0 --- assets/css/admin.css | 74 +----- assets/js/admin.js | 102 +------- changelog.txt | 37 +++ languages/noindex-seo-ca.mo | Bin 17317 -> 17702 bytes languages/noindex-seo-ca.po | 28 +++ languages/noindex-seo-es_ES.mo | Bin 17264 -> 17646 bytes languages/noindex-seo-es_ES.po | 28 +++ languages/noindex-seo.pot | 28 +++ noindex-seo.php | 439 ++++++++++++++++++++------------- readme.txt | 14 +- 10 files changed, 414 insertions(+), 336 deletions(-) diff --git a/assets/css/admin.css b/assets/css/admin.css index 39b51b9..4d01325 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -14,61 +14,19 @@ margin: 20px 0; } -/* =========================== - Tabs Navigation - =========================== */ -.noindex-seo-tabs { - display: flex; - gap: 10px; - margin-bottom: 30px; - border-bottom: 2px solid #c3c4c7; - flex-wrap: wrap; +/* Tab navigation uses the native WordPress nav-tab classes. */ +.noindex-seo-admin-wrap .nav-tab-wrapper { + margin-bottom: 20px; } -.noindex-seo-tab { - padding: 12px 24px; - background: transparent; - border: none; - color: #646970; - font-size: 15px; - font-weight: 500; - cursor: pointer; - border-bottom: 3px solid transparent; - transition: color 0.3s ease; - position: relative; - top: 2px; +/* Section titles inside a tab panel. Vertical separation between + sections comes from the content blocks' own bottom margins. */ +.noindex-seo-section-title { + margin: 0 0 12px 0; } -.noindex-seo-tab:hover, -.noindex-seo-tab.active { - color: var(--wp-admin-theme-color, #2271b1); -} - -.noindex-seo-tab.active { - border-bottom-color: var(--wp-admin-theme-color, #2271b1); -} - -/* =========================== - Tab Content - =========================== */ -.noindex-seo-tab-content { - display: none; -} - -.noindex-seo-tab-content.active { - display: block; - animation: noindexSeoFadeIn 0.3s ease; -} - -@keyframes noindexSeoFadeIn { - from { - opacity: 0; - transform: translateY(10px); - } - to { - opacity: 1; - transform: translateY(0); - } +.noindex-seo-section-title + .description { + margin: 0 0 12px 0; } /* =========================== @@ -365,11 +323,6 @@ input:checked + .noindex-seo-slider:before { margin: 0 0 20px 0; } -.noindex-seo-apply-note { - margin-inline-start: 8px; - vertical-align: middle; -} - /* =========================== General Config Section =========================== */ @@ -758,15 +711,6 @@ input:checked + .noindex-seo-slider:before { grid-template-columns: 1fr; } - .noindex-seo-tabs { - overflow-x: auto; - -webkit-overflow-scrolling: touch; - } - - .noindex-seo-tab { - white-space: nowrap; - } - .noindex-seo-stats { grid-template-columns: 1fr; } diff --git a/assets/js/admin.js b/assets/js/admin.js index 72d7c9a..e4a56c9 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -13,43 +13,10 @@ * Initialize the admin panel */ function init() { - initTabs(); initCollapsibleCards(); initSearch(); initStats(); initTooltips(); - initMethodDependentFields(); - } - - /** - * Initialize tabs functionality - */ - function initTabs() { - $( '.noindex-seo-tab' ).on( - 'click', - function (e) { - e.preventDefault(); - - const tabId = $( this ).data( 'tab' ); - - // Update active tab. - $( '.noindex-seo-tab' ).removeClass( 'active' ); - $( this ).addClass( 'active' ); - - // Update active content. - $( '.noindex-seo-tab-content' ).removeClass( 'active' ); - $( '#' + tabId ).addClass( 'active' ); - - // Save last active tab to localStorage. - localStorage.setItem( 'noindexSeoActiveTab', tabId ); - } - ); - - // Restore last active tab. - const lastTab = localStorage.getItem( 'noindexSeoActiveTab' ); - if (lastTab && $( '#' + lastTab ).length) { - $( '.noindex-seo-tab[data-tab="' + lastTab + '"]' ).click(); - } } /** @@ -163,63 +130,6 @@ // Can be enhanced with a tooltip library if needed. } - /** - * Initialize method-dependent field states - * Some fields only work with HTTP headers, not HTML meta tags - */ - function initMethodDependentFields() { - const methodSelect = $( '#noindex_seo_config_method' ); - - if (methodSelect.length === 0) { - return; - } - - /** - * Update field states based on selected implementation method - */ - function updateFieldStates() { - const method = methodSelect.val(); - const isHeaderEnabled = (method === 'header' || method === 'both'); - - // Contexts that ONLY work with HTTP headers (non-HTML content). - const headerOnlyContexts = [ - 'attachment', // Attachment pages (may contain PDFs, images, etc.). - 'feed', // RSS/Atom feeds (XML, not HTML). - 'comment_feed' // Comment feeds (XML, not HTML). - ]; - - headerOnlyContexts.forEach( - function (context) { - // Find all directive checkboxes for this context. - const directiveCheckboxes = $( 'input[name$="_seo_' + context + '"]' ); - const option = directiveCheckboxes.first().closest( '.noindex-seo-option' ); - - if ( ! isHeaderEnabled) { - // Disable all directives for this context. - directiveCheckboxes.prop( 'disabled', true ); - directiveCheckboxes.prop( 'checked', false ); - option.addClass( 'disabled' ); - option.attr( 'title', 'This option only works with HTTP Headers implementation method' ); - } else { - // Enable all directives for this context. - directiveCheckboxes.prop( 'disabled', false ); - option.removeClass( 'disabled' ); - option.removeAttr( 'title' ); - } - } - ); - - // Update stats after changing field states. - updateStats(); - } - - // Listen for method changes. - methodSelect.on( 'change', updateFieldStates ); - - // Execute on page load. - updateFieldStates(); - } - /** * Expand all cards */ @@ -325,9 +235,15 @@ if (urlParams.get( 'updated' ) === 'true') { showSuccessMessage( noindexSeoAdmin.successMessage || 'Settings saved successfully!' ); - // Remove the parameter from URL without reload. - const newUrl = window.location.pathname + window.location.hash; - window.history.replaceState( {}, document.title, newUrl ); + // Remove only the success flag, keeping the page and tab + // parameters intact (tabs are URL-based since 3.3.0). + urlParams.delete( 'updated' ); + const remaining = urlParams.toString(); + window.history.replaceState( + {}, + document.title, + window.location.pathname + ( remaining ? '?' + remaining : '' ) + ); } } ); diff --git a/changelog.txt b/changelog.txt index 8757699..c0f0266 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,8 +1,45 @@ == Changelog == += 3.3.0 = + +_Release date: 2026-09-19_ +**Highlights** + +* The settings page is reorganized with the native WordPress tab navigation (General / SEO Settings / Import-Export) and titled sections, built exclusively on core `nav-tab` classes with URL-based switching — no proprietary tab CSS or JavaScript. + +**Added** + +* Native WordPress tab navigation on the settings page (`nav-tab-wrapper` / `nav-tab`, the same pattern as the core Updates and Plugins screens): General (implementation method and configuration options), SEO Settings (the directive grid), and Import / Export (the JSON tools). Tabs switch through the `tab` query parameter and the active panel renders server-side, so they work without JavaScript and are bookmarkable. +* Titled sections inside the tabs: "Recommended settings" (one-click defaults), "Overview" (the number cards) and "Page contexts" (the directive grid) on SEO Settings; "Export settings" and "Import settings" headers on the Import / Export tab. Spacing added between the tab bar and the content below. + +**Changed** + +* `noindex_seo_process_form()` is now tab-scoped: saving from the General tab updates only the configuration and preserves the directive grid, saving from SEO Settings updates only the directives and preserves the configuration — hidden tabs can no longer reset each other's values. The form carries a `noindex_seo_form_scope` marker and the redirect returns to the tab the user saved from. +* The header-only restriction for the attachment context now follows the saved implementation method (the method select lives on the General tab), and switching the method to meta/HTML-only from General zeroes the attachment directives to keep the invariant consistent. +* The apply-suggestions redirect and the import success/error redirects return to their source tabs (`tab=settings`, `tab=tools`). +* Removed the dead custom tab machinery: the `.noindex-seo-tab*` CSS rules, the `initTabs()` JavaScript with its localStorage persistence, and the unused `.noindex-seo-apply-note` class (previously flagged as dead code by the 3.1.6 deploy audit). + +**Fixed** + +* Nothing. + +**Security** + +* No security changes; the tab parameter is strictly safelisted server-side (`sanitize_key` + allow list) and PHPCS/PHPStan/composer audit stay clean. + +**Compatibility** + +* WordPress: 4.7 - 7.2 +* PHP: 5.6 - 8.5 + +**Tests** + +* PHPUnit: 9.6.36 (172 tests, all passing): tab markup (three tabs, active class, unknown-tab fallback), per-tab rendering isolation, scope-aware saving (config-only / grid-only / preserve-other-side / attachment invariant / tab-aware redirect), and section ordering. + = 3.2.0 = _Release date: 2026-09-18_ + **Highlights** * Two roadmap features: JSON export/import of the settings (#6) and runtime conflict verification against the `wp_robots` API (#10). diff --git a/languages/noindex-seo-ca.mo b/languages/noindex-seo-ca.mo index 15b212d62a5fa26461623a29765ba7a8c58175d5..0298838b051201e7cacce6e510aed229b7ff3f2d 100644 GIT binary patch delta 3841 zcmZYBdr*{B7{~F0K%fHN5J5s-6Uhsrq6DF+h@=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3RAssbTbm2o}TTKs6AwNvRn>Y!zmywKO0mk7`Y(Tcx zBn`2)E)TT=6{uvaL~pFep|}IJ#TQXI@KEQkX4sQo^;t|qWos#BV+}GUa|2l<^TO`$ z$4$PpSK}SrV7K#GhAy;=Q3GCuozZFcZ%3U2N9^|5B-Vcn9arhl3iy$E`phOEpSHwsOx@5{xd;NGR23=cnrZD z4926Y#pjOa}>1ZPU7>k2Zzvp5{oNv1f zHNdr4rSHF*%2YaDpt3cG)YOtsLtQuzCpwH-j`wMwO1HAVk;Kt}Q^zuRJcQb!l^K?s zP|w?iJlgC-7SFWU?Z9zt5$`vdRLCo{7`22=s1YB-06dAB;peCUUB+(s4X(jo@Ep$J z5YheN917Z+SldL@b23n0#S{$1+30joQPJ5ymk1}yh_{ITgkGFTyiI6OrG&~-LWfof z(Lku^?3hDD5sb;KC1w*US_ze{7M_!_K>NRp4keiOSViA^IZ;K7CfbVjasrXp)`6PM zMk0yOR?H+066=Y!GL%XMv7cB+Oe1;{y@(?1zxJA(Gckn9PNI%b5@}mp#OuU9LM7M2 z^Eqv!o=>bM-XIneD~Tn;see*?N;ZEv63i~E={Ym(swYWT&{#w`+w&)c*hI`CGKjWPOl3aNn@F%b zhv5K12{_*F+m4NPy^U%rO2Ql>)9##vZ4=%@eY%?UR5lRH36*y|e>tga`{4nimf(vs zy9xczsjbYQLLz$(n>f3(9rm&7V{LtH!%#=|R3g;8X7%oc0AjP%^!$@+F!lF{HADxy zU+9+9|Fl*0B7%rWcS~TluWLZqVfUS|3Ws-YN$Em&X+(jS``f6|4p&rkqx(|ygHYEe h$=BSwhuv~Ga@}>quY0-6Q(X>MKw7i=>$I4T{{r?LSdah! diff --git a/languages/noindex-seo-es_ES.po b/languages/noindex-seo-es_ES.po index 1ea15ce..d907cd2 100644 --- a/languages/noindex-seo-es_ES.po +++ b/languages/noindex-seo-es_ES.po @@ -747,3 +747,31 @@ msgstr "No se ha podido importar el archivo de ajustes: falta, es demasiado gran #: noindex-seo.php msgid "noindex SEO has detected that another plugin or theme is adding robots directives through the wp_robots API (%s). This may cause conflicts. Please configure the options accordingly." msgstr "noindex SEO ha detectado que otro plugin o tema está añadiendo directivas de robots mediante la API wp_robots (%s). Esto puede causar conflictos. Configura las opciones en consecuencia." + +#: noindex-seo.php +msgid "Recommended settings" +msgstr "Ajustes recomendados" + +#: noindex-seo.php +msgid "Overview" +msgstr "Resumen" + +#: noindex-seo.php +msgid "Page contexts" +msgstr "Contextos de página" + +#: noindex-seo.php +msgid "General" +msgstr "General" + +#: noindex-seo.php +msgid "SEO Settings" +msgstr "Ajustes SEO" + +#: noindex-seo.php +msgid "Import / Export" +msgstr "Importación y exportación" + +#: noindex-seo.php +msgid "Settings sections" +msgstr "Secciones de los ajustes" diff --git a/languages/noindex-seo.pot b/languages/noindex-seo.pot index 900de93..7c1cd96 100644 --- a/languages/noindex-seo.pot +++ b/languages/noindex-seo.pot @@ -694,3 +694,31 @@ msgstr "" #: noindex-seo.php msgid "noindex SEO has detected that another plugin or theme is adding robots directives through the wp_robots API (%s). This may cause conflicts. Please configure the options accordingly." msgstr "" + +#: noindex-seo.php +msgid "Recommended settings" +msgstr "" + +#: noindex-seo.php +msgid "Overview" +msgstr "" + +#: noindex-seo.php +msgid "Page contexts" +msgstr "" + +#: noindex-seo.php +msgid "General" +msgstr "" + +#: noindex-seo.php +msgid "SEO Settings" +msgstr "" + +#: noindex-seo.php +msgid "Import / Export" +msgstr "" + +#: noindex-seo.php +msgid "Settings sections" +msgstr "" diff --git a/noindex-seo.php b/noindex-seo.php index 68bbd20..7f9ccb4 100644 --- a/noindex-seo.php +++ b/noindex-seo.php @@ -3,7 +3,7 @@ * Plugin Name: noindex SEO * Plugin URI: https://www.robotstxt.software/plugins/noindex-seo/ * Description: Control search engine indexing with robots directives (noindex, nofollow, noarchive, nosnippet, noimageindex) for specific parts of your WordPress site. - * Version: 3.2.0 + * Version: 3.3.0 * Requires at least: 4.7 * Requires PHP: 5.6 * Author: ROBOTSTXT @@ -69,7 +69,7 @@ defined( 'ABSPATH' ) || die( 'Bye bye!' ); * form-handler wp_die() message corrected (I2); unreachable * REST fallbacks removed (I5). */ -define( 'NOINDEX_SEO_VERSION', '3.2.0' ); +define( 'NOINDEX_SEO_VERSION', '3.3.0' ); /** * Option key holding the consolidated plugin settings array. @@ -1770,8 +1770,10 @@ function noindex_seo_get_foreign_robots_callbacks() { * It first verifies the current user's capability and nonce for security. Then it resets all * registered options to `0`, and selectively updates those submitted as checked in the form. * - * Additionally, it updates the general configuration settings, - * clears the plugin's transient cache, and redirects back to the settings page. + * The settings page is tabbed (General / SEO Settings), and only the active + * tab's fields are present in the POST body. The form carries a + * `noindex_seo_form_scope` marker so the handler knows which group to + * process and preserves the values of the other group untouched. * * Hooked to the {@see 'admin_post_update_noindex_seo'} action. * @@ -1780,6 +1782,9 @@ function noindex_seo_get_foreign_robots_callbacks() { * @since 3.1.5 Nonce verification split out of the capability check: * check_admin_referer() dies on failure instead of returning * false, so `! check_admin_referer()` was dead code. + * @since 3.3.0 Tab-scoped processing: 'settings' saves only the directive + * grid, 'general' only the configuration options; the other + * group is preserved. The redirect returns to the saved tab. * * @return void */ @@ -1789,78 +1794,105 @@ function noindex_seo_process_form() { } check_admin_referer( 'update_noindex_seo_nonce' ); + // Which tab the form was submitted from. Unknown or missing scope + // defaults to the directive grid (the plugin's main surface). + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified above. + $scope = ( isset( $_POST['noindex_seo_form_scope'] ) && is_string( $_POST['noindex_seo_form_scope'] ) ) + ? sanitize_key( wp_unslash( $_POST['noindex_seo_form_scope'] ) ) + : 'settings'; + if ( ! in_array( $scope, array( 'general', 'settings' ), true ) ) { + $scope = 'settings'; + } + $contexts = noindex_seo_get_contexts(); $directives = array( 'noindex', 'nofollow', 'noarchive', 'nosnippet', 'noimageindex' ); - // Get the implementation method to validate field compatibility. - $method_value = ( isset( $_POST['noindex_seo_config_method'] ) && is_string( $_POST['noindex_seo_config_method'] ) ) - ? sanitize_text_field( wp_unslash( $_POST['noindex_seo_config_method'] ) ) - : 'meta'; - - // Validate method. - $method_value = in_array( $method_value, array( 'meta', 'header', 'both' ), true ) ? $method_value : 'meta'; - // Fields that only work with HTTP headers. $header_only_contexts = array( 'attachment' ); - $is_header_enabled = in_array( $method_value, array( 'header', 'both' ), true ); // Start from the current consolidated settings so we only overwrite what // the form actually touches. The shape is preserved by noindex_seo_update_settings(). $settings = noindex_seo_get_settings(); - // Process checkbox grid: one entry per (context, directive). - foreach ( $contexts as $context ) { - foreach ( $directives as $directive ) { - $option_key = $directive . '_seo_' . $context; + if ( 'settings' === $scope ) { + // The method select lives on the General tab, so the header-only + // restriction follows the SAVED method, not the POST body. + $saved_method = noindex_seo_get_config( 'method', 'meta' ); + $is_header_enabled = in_array( $saved_method, array( 'header', 'both' ), true ); - // Header-only contexts are forced to 0 when headers aren't enabled. - if ( in_array( $context, $header_only_contexts, true ) && ! $is_header_enabled ) { - $settings['contexts'][ $context ][ $directive ] = 0; - continue; + // Process checkbox grid: one entry per (context, directive). + // phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce verified above. + foreach ( $contexts as $context ) { + foreach ( $directives as $directive ) { + $option_key = $directive . '_seo_' . $context; + + // Header-only contexts are forced to 0 when headers aren't enabled. + if ( in_array( $context, $header_only_contexts, true ) && ! $is_header_enabled ) { + $settings['contexts'][ $context ][ $directive ] = 0; + continue; + } + + $option_value = ( isset( $_POST[ $option_key ] ) && is_string( $_POST[ $option_key ] ) ) + ? sanitize_text_field( wp_unslash( $_POST[ $option_key ] ) ) + : ''; + + // Only '1' counts as checked; everything else (including invalid input) is 0. + $settings['contexts'][ $context ][ $directive ] = ( '1' === $option_value ) ? 1 : 0; } + } + // phpcs:enable WordPress.Security.NonceVerification.Missing + } else { + // phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce verified above. + // Get the implementation method to validate field compatibility. + $method_value = ( isset( $_POST['noindex_seo_config_method'] ) && is_string( $_POST['noindex_seo_config_method'] ) ) + ? sanitize_text_field( wp_unslash( $_POST['noindex_seo_config_method'] ) ) + : 'meta'; - $option_value = ( isset( $_POST[ $option_key ] ) && is_string( $_POST[ $option_key ] ) ) - ? sanitize_text_field( wp_unslash( $_POST[ $option_key ] ) ) - : ''; + // Validate method. + $settings['config']['method'] = in_array( $method_value, array( 'meta', 'header', 'both' ), true ) ? $method_value : 'meta'; - // Only '1' counts as checked; everything else (including invalid input) is 0. - $settings['contexts'][ $context ][ $directive ] = ( '1' === $option_value ) ? 1 : 0; + // Save general configuration values. + $config_value = ( isset( $_POST['noindex_seo_config_seoplugins'] ) && is_string( $_POST['noindex_seo_config_seoplugins'] ) ) + ? absint( $_POST['noindex_seo_config_seoplugins'] ) + : 0; + $settings['config']['seoplugins'] = ( 1 === $config_value ) ? 1 : 0; + + // Granular control. + $granular_value = ( isset( $_POST['noindex_seo_config_granular'] ) && is_string( $_POST['noindex_seo_config_granular'] ) ) + ? absint( $_POST['noindex_seo_config_granular'] ) + : 0; + $settings['config']['granular'] = ( 1 === $granular_value ) ? 1 : 0; + + // Per-term granular control on taxonomies. + $tax_granular_value = ( isset( $_POST['noindex_seo_config_taxonomies_granular'] ) && is_string( $_POST['noindex_seo_config_taxonomies_granular'] ) ) + ? absint( $_POST['noindex_seo_config_taxonomies_granular'] ) + : 0; + $settings['config']['taxonomies_granular'] = ( 1 === $tax_granular_value ) ? 1 : 0; + + // Delete-on-uninstall opt-in. + $delete_value = ( isset( $_POST['noindex_seo_config_delete_on_uninstall'] ) && is_string( $_POST['noindex_seo_config_delete_on_uninstall'] ) ) + ? absint( $_POST['noindex_seo_config_delete_on_uninstall'] ) + : 0; + $settings['config']['delete_on_uninstall'] = ( 1 === $delete_value ) ? 1 : 0; + // phpcs:enable WordPress.Security.NonceVerification.Missing + + // Keep the header-only invariant consistent with the (possibly just + // changed) method: attachment directives cannot survive a method + // that does not send HTTP headers. + $is_header_enabled = in_array( $settings['config']['method'], array( 'header', 'both' ), true ); + if ( ! $is_header_enabled ) { + foreach ( $directives as $directive ) { + $settings['contexts']['attachment'][ $directive ] = 0; + } } } - // Save general configuration values. - $config_value = ( isset( $_POST['noindex_seo_config_seoplugins'] ) && is_string( $_POST['noindex_seo_config_seoplugins'] ) ) - ? absint( $_POST['noindex_seo_config_seoplugins'] ) - : 0; - $settings['config']['seoplugins'] = ( 1 === $config_value ) ? 1 : 0; - - // Implementation method (validated above). - $settings['config']['method'] = $method_value; - - // Granular control. - $granular_value = ( isset( $_POST['noindex_seo_config_granular'] ) && is_string( $_POST['noindex_seo_config_granular'] ) ) - ? absint( $_POST['noindex_seo_config_granular'] ) - : 0; - $settings['config']['granular'] = ( 1 === $granular_value ) ? 1 : 0; - - // Per-term granular control on taxonomies. - $tax_granular_value = ( isset( $_POST['noindex_seo_config_taxonomies_granular'] ) && is_string( $_POST['noindex_seo_config_taxonomies_granular'] ) ) - ? absint( $_POST['noindex_seo_config_taxonomies_granular'] ) - : 0; - $settings['config']['taxonomies_granular'] = ( 1 === $tax_granular_value ) ? 1 : 0; - - // Delete-on-uninstall opt-in. - $delete_value = ( isset( $_POST['noindex_seo_config_delete_on_uninstall'] ) && is_string( $_POST['noindex_seo_config_delete_on_uninstall'] ) ) - ? absint( $_POST['noindex_seo_config_delete_on_uninstall'] ) - : 0; - $settings['config']['delete_on_uninstall'] = ( 1 === $delete_value ) ? 1 : 0; - // Persist. This fires update_option_noindex_seo_settings, which clears the // transient via noindex_seo_invalidate_cache_on_settings_update() — so we // no longer need to delete_transient() by hand here. noindex_seo_update_settings( $settings ); - wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&updated=true' ) ); + wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&tab=' . $scope . '&updated=true' ) ); exit; } add_action( 'admin_post_update_noindex_seo', 'noindex_seo_process_form' ); @@ -1881,6 +1913,7 @@ add_action( 'admin_post_update_noindex_seo', 'noindex_seo_process_form' ); * * @since 3.0.0 * @since 3.1.5 Same nonce-verification split as noindex_seo_process_form(). + * @since 3.3.0 Redirects back to the SEO Settings tab. * * @return void */ @@ -1901,7 +1934,7 @@ function noindex_seo_process_apply_suggestions() { noindex_seo_update_settings( $settings ); - wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&suggestions_applied=1' ) ); + wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&tab=settings&suggestions_applied=1' ) ); exit; } add_action( 'admin_post_noindex_seo_apply_suggestions', 'noindex_seo_process_apply_suggestions' ); @@ -2019,6 +2052,7 @@ function noindex_seo_sanitize_imported_settings( $raw ) { * Hooked to the {@see 'admin_post_noindex_seo_import'} action. * * @since 3.2.0 + * @since 3.3.0 Redirects back to the Import / Export tab. * * @return void */ @@ -2028,7 +2062,7 @@ function noindex_seo_handle_import() { } check_admin_referer( 'noindex_seo_import' ); - $redirect_error = admin_url( 'options-general.php?page=noindex_seo&import_error=1' ); + $redirect_error = admin_url( 'options-general.php?page=noindex_seo&tab=tools&import_error=1' ); // The upload is validated immediately below (error code, size, is_uploaded_file) and its // contents go through strict JSON shape validation before anything is persisted. @@ -2064,7 +2098,7 @@ function noindex_seo_handle_import() { noindex_seo_update_settings( $settings ); - wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&imported=1' ) ); + wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&tab=tools&imported=1' ) ); exit; } add_action( 'admin_post_noindex_seo_import', 'noindex_seo_handle_import' ); @@ -3290,19 +3324,24 @@ add_action( ); /** - * Renders the modern, visual settings page for the 'noindex SEO' plugin. + * Renders the settings page for the 'noindex SEO' plugin. * - * This function outputs a completely redesigned admin interface with: - * - Modern card-based layout - * - Toggle switches instead of checkboxes - * - Tabbed navigation for better organization - * - Visual indicators and badges - * - Collapsible sections - * - Search/filter functionality - * - Statistics dashboard + * The page uses the native WordPress tab navigation (`nav-tab-wrapper` / + * `nav-tab`, the same pattern as the core Updates and Plugins screens): + * URL-based switching via the `tab` query parameter, with the active + * panel rendered server-side. No custom tab CSS or JavaScript. + * + * Tabs: + * - general: implementation method and general configuration options. + * - settings: the directive grid (contexts x directives) with stats, + * search and the "Apply Recommended Defaults" action. + * - tools: the JSON export / import forms. * * @since 1.0.0 * @since 2.0.0 Completely redesigned with modern UI/UX. + * @since 3.3.0 Reorganized into native WordPress nav tabs; the form + * handler became tab-scoped so saving one tab never + * resets the values of the other. * * @return void */ @@ -3316,6 +3355,18 @@ function noindex_seo_admin() { ); } + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only navigation state, not form data. + $current_tab = isset( $_GET['tab'] ) && is_string( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'general'; + if ( ! in_array( $current_tab, array( 'general', 'settings', 'tools' ), true ) ) { + $current_tab = 'general'; + } + + $tabs = array( + 'general' => __( 'General', 'noindex-seo' ), + 'settings' => __( 'SEO Settings', 'noindex-seo' ), + 'tools' => __( 'Import / Export', 'noindex-seo' ), + ); + // Define section icons (using Dashicons).. $section_icons = array( 'main_pages' => 'dashicons-admin-home', @@ -3627,96 +3678,34 @@ function noindex_seo_admin() { } ?> - -
- - - __( 'Enable all directives for the 12 contexts flagged as recommended.', 'noindex-seo' ), - ) + '; + foreach ( $tabs as $tab_slug => $tab_label ) { + printf( + '%s', + esc_url( add_query_arg( 'tab', $tab_slug, $page_url ) ), + $tab_slug === $current_tab ? ' nav-tab-active' : '', + esc_html( $tab_label ) ); - ?> - - - -
+ } + echo ''; + ?> - -
- - - - - - -
+ -
- - - - - - - - -
+ +
+ + + - - - - - - -
-
-
0
-
-
-
-
0
-
-
-
- -
-
-
- - -
+ +

@@ -3827,28 +3816,85 @@ function noindex_seo_admin() {

- -
- -

-
+ +
- - + + + + + +

+

+ +

+
+ + + __( 'Enable all directives for the 12 contexts flagged as recommended.', 'noindex-seo' ), + ) + ); + ?> +
+ + +
+ + + + + +

+
+
+
0
+
+
+
+
0
+
+
+
+ +
+
+
+ + +

+ + +
+ +

+
+ + + - $section ) : ?> - + $section ) : ?> +

@@ -3915,6 +3961,57 @@ function noindex_seo_admin() { + + + + + + +

+

+ +

+
+ + + +
+ + +

+

+ +

+
+ + + + + +
+ +