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 15b212d..0298838 100644 Binary files a/languages/noindex-seo-ca.mo and b/languages/noindex-seo-ca.mo differ diff --git a/languages/noindex-seo-ca.po b/languages/noindex-seo-ca.po index 674d751..06d137d 100644 --- a/languages/noindex-seo-ca.po +++ b/languages/noindex-seo-ca.po @@ -744,3 +744,31 @@ msgstr "No s'ha pogut importar el fitxer d'ajustaments: no existeix, és massa g #: 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 detectat que un altre complement o tema està afegint directrius de robots a través de l'API wp_robots (%s). Això pot causar conflictes. Configureu les opcions en conseqüència." + +#: noindex-seo.php +msgid "Recommended settings" +msgstr "Ajustaments recomanats" + +#: noindex-seo.php +msgid "Overview" +msgstr "Resum" + +#: 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 "Ajustaments SEO" + +#: noindex-seo.php +msgid "Import / Export" +msgstr "Importació i exportació" + +#: noindex-seo.php +msgid "Settings sections" +msgstr "Seccions dels ajustaments" diff --git a/languages/noindex-seo-es_ES.mo b/languages/noindex-seo-es_ES.mo index 91253a3..19bf96c 100644 Binary files a/languages/noindex-seo-es_ES.mo and b/languages/noindex-seo-es_ES.mo differ 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() { + + + + + + +

+

+ +

+
+ + + +
+ + +

+

+ +

+
+ + + + + +
+ +