v3.3.0
This commit is contained in:
parent
7b3c00cacc
commit
0ec665db60
10 changed files with 415 additions and 337 deletions
|
|
@ -14,61 +14,19 @@
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================
|
/* Tab navigation uses the native WordPress nav-tab classes. */
|
||||||
Tabs Navigation
|
.noindex-seo-admin-wrap .nav-tab-wrapper {
|
||||||
=========================== */
|
margin-bottom: 20px;
|
||||||
.noindex-seo-tabs {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
border-bottom: 2px solid #c3c4c7;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.noindex-seo-tab {
|
/* Section titles inside a tab panel. Vertical separation between
|
||||||
padding: 12px 24px;
|
sections comes from the content blocks' own bottom margins. */
|
||||||
background: transparent;
|
.noindex-seo-section-title {
|
||||||
border: none;
|
margin: 0 0 12px 0;
|
||||||
color: #646970;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
border-bottom: 3px solid transparent;
|
|
||||||
transition: color 0.3s ease;
|
|
||||||
position: relative;
|
|
||||||
top: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.noindex-seo-tab:hover,
|
.noindex-seo-section-title + .description {
|
||||||
.noindex-seo-tab.active {
|
margin: 0 0 12px 0;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================
|
/* ===========================
|
||||||
|
|
@ -365,11 +323,6 @@ input:checked + .noindex-seo-slider:before {
|
||||||
margin: 0 0 20px 0;
|
margin: 0 0 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.noindex-seo-apply-note {
|
|
||||||
margin-inline-start: 8px;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================
|
/* ===========================
|
||||||
General Config Section
|
General Config Section
|
||||||
=========================== */
|
=========================== */
|
||||||
|
|
@ -758,15 +711,6 @@ input:checked + .noindex-seo-slider:before {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.noindex-seo-tabs {
|
|
||||||
overflow-x: auto;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.noindex-seo-tab {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.noindex-seo-stats {
|
.noindex-seo-stats {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,43 +13,10 @@
|
||||||
* Initialize the admin panel
|
* Initialize the admin panel
|
||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
initTabs();
|
|
||||||
initCollapsibleCards();
|
initCollapsibleCards();
|
||||||
initSearch();
|
initSearch();
|
||||||
initStats();
|
initStats();
|
||||||
initTooltips();
|
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.
|
// 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
|
* Expand all cards
|
||||||
*/
|
*/
|
||||||
|
|
@ -325,9 +235,15 @@
|
||||||
if (urlParams.get( 'updated' ) === 'true') {
|
if (urlParams.get( 'updated' ) === 'true') {
|
||||||
showSuccessMessage( noindexSeoAdmin.successMessage || 'Settings saved successfully!' );
|
showSuccessMessage( noindexSeoAdmin.successMessage || 'Settings saved successfully!' );
|
||||||
|
|
||||||
// Remove the parameter from URL without reload.
|
// Remove only the success flag, keeping the page and tab
|
||||||
const newUrl = window.location.pathname + window.location.hash;
|
// parameters intact (tabs are URL-based since 3.3.0).
|
||||||
window.history.replaceState( {}, document.title, newUrl );
|
urlParams.delete( 'updated' );
|
||||||
|
const remaining = urlParams.toString();
|
||||||
|
window.history.replaceState(
|
||||||
|
{},
|
||||||
|
document.title,
|
||||||
|
window.location.pathname + ( remaining ? '?' + remaining : '' )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,45 @@
|
||||||
== Changelog ==
|
== 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 =
|
= 3.2.0 =
|
||||||
|
|
||||||
_Release date: 2026-09-18_
|
_Release date: 2026-09-18_
|
||||||
|
|
||||||
**Highlights**
|
**Highlights**
|
||||||
|
|
||||||
* Two roadmap features: JSON export/import of the settings (#6) and runtime conflict verification against the `wp_robots` API (#10).
|
* Two roadmap features: JSON export/import of the settings (#6) and runtime conflict verification against the `wp_robots` API (#10).
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -744,3 +744,31 @@ msgstr "No s'ha pogut importar el fitxer d'ajustaments: no existeix, és massa g
|
||||||
#: noindex-seo.php
|
#: 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."
|
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."
|
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"
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -747,3 +747,31 @@ msgstr "No se ha podido importar el archivo de ajustes: falta, es demasiado gran
|
||||||
#: noindex-seo.php
|
#: 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."
|
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."
|
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"
|
||||||
|
|
|
||||||
|
|
@ -694,3 +694,31 @@ msgstr ""
|
||||||
#: noindex-seo.php
|
#: 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."
|
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 ""
|
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 ""
|
||||||
|
|
|
||||||
439
noindex-seo.php
439
noindex-seo.php
|
|
@ -3,7 +3,7 @@
|
||||||
* Plugin Name: noindex SEO
|
* Plugin Name: noindex SEO
|
||||||
* Plugin URI: https://www.robotstxt.software/plugins/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.
|
* 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 at least: 4.7
|
||||||
* Requires PHP: 5.6
|
* Requires PHP: 5.6
|
||||||
* Author: ROBOTSTXT
|
* Author: ROBOTSTXT
|
||||||
|
|
@ -69,7 +69,7 @@ defined( 'ABSPATH' ) || die( 'Bye bye!' );
|
||||||
* form-handler wp_die() message corrected (I2); unreachable
|
* form-handler wp_die() message corrected (I2); unreachable
|
||||||
* REST fallbacks removed (I5).
|
* 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.
|
* 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
|
* 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.
|
* registered options to `0`, and selectively updates those submitted as checked in the form.
|
||||||
*
|
*
|
||||||
* Additionally, it updates the general configuration settings,
|
* The settings page is tabbed (General / SEO Settings), and only the active
|
||||||
* clears the plugin's transient cache, and redirects back to the settings page.
|
* 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.
|
* 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:
|
* @since 3.1.5 Nonce verification split out of the capability check:
|
||||||
* check_admin_referer() dies on failure instead of returning
|
* check_admin_referer() dies on failure instead of returning
|
||||||
* false, so `! check_admin_referer()` was dead code.
|
* 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
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -1789,78 +1794,105 @@ function noindex_seo_process_form() {
|
||||||
}
|
}
|
||||||
check_admin_referer( 'update_noindex_seo_nonce' );
|
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();
|
$contexts = noindex_seo_get_contexts();
|
||||||
$directives = array( 'noindex', 'nofollow', 'noarchive', 'nosnippet', 'noimageindex' );
|
$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.
|
// Fields that only work with HTTP headers.
|
||||||
$header_only_contexts = array( 'attachment' );
|
$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
|
// Start from the current consolidated settings so we only overwrite what
|
||||||
// the form actually touches. The shape is preserved by noindex_seo_update_settings().
|
// the form actually touches. The shape is preserved by noindex_seo_update_settings().
|
||||||
$settings = noindex_seo_get_settings();
|
$settings = noindex_seo_get_settings();
|
||||||
|
|
||||||
// Process checkbox grid: one entry per (context, directive).
|
if ( 'settings' === $scope ) {
|
||||||
foreach ( $contexts as $context ) {
|
// The method select lives on the General tab, so the header-only
|
||||||
foreach ( $directives as $directive ) {
|
// restriction follows the SAVED method, not the POST body.
|
||||||
$option_key = $directive . '_seo_' . $context;
|
$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.
|
// Process checkbox grid: one entry per (context, directive).
|
||||||
if ( in_array( $context, $header_only_contexts, true ) && ! $is_header_enabled ) {
|
// phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce verified above.
|
||||||
$settings['contexts'][ $context ][ $directive ] = 0;
|
foreach ( $contexts as $context ) {
|
||||||
continue;
|
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 ] ) )
|
// Validate method.
|
||||||
? sanitize_text_field( wp_unslash( $_POST[ $option_key ] ) )
|
$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.
|
// Save general configuration values.
|
||||||
$settings['contexts'][ $context ][ $directive ] = ( '1' === $option_value ) ? 1 : 0;
|
$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
|
// Persist. This fires update_option_noindex_seo_settings, which clears the
|
||||||
// transient via noindex_seo_invalidate_cache_on_settings_update() — so we
|
// transient via noindex_seo_invalidate_cache_on_settings_update() — so we
|
||||||
// no longer need to delete_transient() by hand here.
|
// no longer need to delete_transient() by hand here.
|
||||||
noindex_seo_update_settings( $settings );
|
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;
|
exit;
|
||||||
}
|
}
|
||||||
add_action( 'admin_post_update_noindex_seo', 'noindex_seo_process_form' );
|
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.0.0
|
||||||
* @since 3.1.5 Same nonce-verification split as noindex_seo_process_form().
|
* @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
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -1901,7 +1934,7 @@ function noindex_seo_process_apply_suggestions() {
|
||||||
|
|
||||||
noindex_seo_update_settings( $settings );
|
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;
|
exit;
|
||||||
}
|
}
|
||||||
add_action( 'admin_post_noindex_seo_apply_suggestions', 'noindex_seo_process_apply_suggestions' );
|
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.
|
* Hooked to the {@see 'admin_post_noindex_seo_import'} action.
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
|
* @since 3.3.0 Redirects back to the Import / Export tab.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -2028,7 +2062,7 @@ function noindex_seo_handle_import() {
|
||||||
}
|
}
|
||||||
check_admin_referer( 'noindex_seo_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
|
// 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.
|
// 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 );
|
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;
|
exit;
|
||||||
}
|
}
|
||||||
add_action( 'admin_post_noindex_seo_import', 'noindex_seo_handle_import' );
|
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:
|
* The page uses the native WordPress tab navigation (`nav-tab-wrapper` /
|
||||||
* - Modern card-based layout
|
* `nav-tab`, the same pattern as the core Updates and Plugins screens):
|
||||||
* - Toggle switches instead of checkboxes
|
* URL-based switching via the `tab` query parameter, with the active
|
||||||
* - Tabbed navigation for better organization
|
* panel rendered server-side. No custom tab CSS or JavaScript.
|
||||||
* - Visual indicators and badges
|
*
|
||||||
* - Collapsible sections
|
* Tabs:
|
||||||
* - Search/filter functionality
|
* - general: implementation method and general configuration options.
|
||||||
* - Statistics dashboard
|
* - 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 1.0.0
|
||||||
* @since 2.0.0 Completely redesigned with modern UI/UX.
|
* @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
|
* @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)..
|
// Define section icons (using Dashicons)..
|
||||||
$section_icons = array(
|
$section_icons = array(
|
||||||
'main_pages' => 'dashicons-admin-home',
|
'main_pages' => 'dashicons-admin-home',
|
||||||
|
|
@ -3627,96 +3678,34 @@ function noindex_seo_admin() {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- "Apply Recommended Defaults" — standalone sibling form, rendered
|
<?php
|
||||||
BEFORE the main settings form. MUST NOT be nested inside it: HTML5
|
// Native WordPress tab navigation (core nav-tab classes, URL-based).
|
||||||
forbids nested <form> elements; a stray </form> inside the parent
|
$page_url = admin_url( 'options-general.php?page=noindex_seo' );
|
||||||
would close the parent early and orphan the Save Changes button and
|
echo '<nav class="nav-tab-wrapper" aria-label="' . esc_attr__( 'Settings sections', 'noindex-seo' ) . '">';
|
||||||
all directive checkboxes. -->
|
foreach ( $tabs as $tab_slug => $tab_label ) {
|
||||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="noindex-seo-apply-form">
|
printf(
|
||||||
<input type="hidden" name="action" value="noindex_seo_apply_suggestions">
|
'<a href="%s" class="nav-tab%s">%s</a>',
|
||||||
<?php wp_nonce_field( 'noindex_seo_apply_suggestions_nonce' ); ?>
|
esc_url( add_query_arg( 'tab', $tab_slug, $page_url ) ),
|
||||||
<?php
|
$tab_slug === $current_tab ? ' nav-tab-active' : '',
|
||||||
submit_button(
|
esc_html( $tab_label )
|
||||||
__( 'Apply Recommended Defaults', 'noindex-seo' ),
|
|
||||||
'secondary',
|
|
||||||
'noindex-seo-apply-suggestions',
|
|
||||||
false,
|
|
||||||
array(
|
|
||||||
'title' => __( 'Enable all directives for the 12 contexts flagged as recommended.', 'noindex-seo' ),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
?>
|
}
|
||||||
<span class="description noindex-seo-apply-note">
|
echo '</nav>';
|
||||||
<?php esc_html_e( 'Enables all 5 directives on the 12 contexts flagged "Recommended" (privacy policy, date archives, pagination, search results, attachment pages, previews, 404). Review and save.', 'noindex-seo' ); ?>
|
?>
|
||||||
</span>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<!-- Export / Import — standalone sibling forms, never nested inside
|
<?php if ( 'general' === $current_tab ) : ?>
|
||||||
the main settings form (HTML5 forbids nested <form> elements). -->
|
|
||||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="noindex-seo-apply-form">
|
|
||||||
<input type="hidden" name="action" value="noindex_seo_export">
|
|
||||||
<?php wp_nonce_field( 'noindex_seo_export' ); ?>
|
|
||||||
<?php
|
|
||||||
submit_button(
|
|
||||||
__( 'Export settings', 'noindex-seo' ),
|
|
||||||
'secondary',
|
|
||||||
'noindex-seo-export',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
<span class="description noindex-seo-apply-note">
|
|
||||||
<?php esc_html_e( 'Download the current settings as a JSON file.', 'noindex-seo' ); ?>
|
|
||||||
</span>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form method="post" enctype="multipart/form-data" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="noindex-seo-apply-form">
|
<!-- General tab: implementation method and configuration options.
|
||||||
<input type="hidden" name="action" value="noindex_seo_import">
|
Own instance of the main form (scoped to this tab) so saving
|
||||||
<?php wp_nonce_field( 'noindex_seo_import' ); ?>
|
from here never touches the directive grid of the SEO Settings
|
||||||
<label for="noindex_seo_import_file" class="noindex-seo-config-label">
|
tab, and vice versa. -->
|
||||||
<?php esc_html_e( 'Import settings', 'noindex-seo' ); ?>
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
</label>
|
<input type="hidden" name="action" value="update_noindex_seo">
|
||||||
<input
|
<input type="hidden" name="noindex_seo_form_scope" value="general">
|
||||||
type="file"
|
<?php wp_nonce_field( 'update_noindex_seo_nonce' ); ?>
|
||||||
id="noindex_seo_import_file"
|
|
||||||
name="noindex_seo_import_file"
|
|
||||||
accept=".json,application/json"
|
|
||||||
>
|
|
||||||
<?php
|
|
||||||
submit_button(
|
|
||||||
__( 'Import settings', 'noindex-seo' ),
|
|
||||||
'secondary',
|
|
||||||
'noindex-seo-import',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
<span class="description noindex-seo-apply-note">
|
|
||||||
<?php esc_html_e( 'Restore the global settings from a previously exported JSON file. Per-post and per-term overrides are kept.', 'noindex-seo' ); ?>
|
|
||||||
</span>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<!-- Main settings form: wraps stats, config, alert, search, sections, submit. -->
|
<!-- General Configuration -->
|
||||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
<div class="noindex-seo-general-config">
|
||||||
<input type="hidden" name="action" value="update_noindex_seo">
|
|
||||||
<?php wp_nonce_field( 'update_noindex_seo_nonce' ); ?>
|
|
||||||
|
|
||||||
<!-- Statistics Dashboard -->
|
|
||||||
<div class="noindex-seo-stats">
|
|
||||||
<div class="noindex-seo-stat-card">
|
|
||||||
<div class="noindex-seo-stat-number" id="noindex-seo-stat-total">0</div>
|
|
||||||
<div class="noindex-seo-stat-label"><?php esc_html_e( 'Total Options', 'noindex-seo' ); ?></div>
|
|
||||||
</div>
|
|
||||||
<div class="noindex-seo-stat-card">
|
|
||||||
<div class="noindex-seo-stat-number" id="noindex-seo-stat-enabled">0</div>
|
|
||||||
<div class="noindex-seo-stat-label"><?php esc_html_e( 'Enabled', 'noindex-seo' ); ?></div>
|
|
||||||
</div>
|
|
||||||
<div class="noindex-seo-stat-card">
|
|
||||||
<div class="noindex-seo-stat-number" id="noindex-seo-stat-recommended">0</div>
|
|
||||||
<div class="noindex-seo-stat-label"><?php esc_html_e( 'Recommended to Enable', 'noindex-seo' ); ?></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- General Configuration -->
|
|
||||||
<div class="noindex-seo-general-config">
|
|
||||||
<h2>
|
<h2>
|
||||||
<span class="dashicons dashicons-admin-settings"></span>
|
<span class="dashicons dashicons-admin-settings"></span>
|
||||||
<?php esc_html_e( 'General Configuration', 'noindex-seo' ); ?>
|
<?php esc_html_e( 'General Configuration', 'noindex-seo' ); ?>
|
||||||
|
|
@ -3827,28 +3816,85 @@ function noindex_seo_admin() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Alert -->
|
<?php submit_button(); ?>
|
||||||
<div class="noindex-seo-alert">
|
</form>
|
||||||
<span class="dashicons dashicons-warning"></span>
|
|
||||||
<p><?php esc_html_e( 'Important: Enabling noindex on the wrong pages can harm your search engine rankings. Only enable options you fully understand.', 'noindex-seo' ); ?></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Search Box -->
|
<?php endif; ?>
|
||||||
<div class="noindex-seo-search">
|
|
||||||
<input
|
<?php if ( 'settings' === $current_tab ) : ?>
|
||||||
type="search"
|
|
||||||
placeholder="<?php esc_attr_e( 'Search options...', 'noindex-seo' ); ?>"
|
<!-- Recommended settings: one-click defaults. Standalone sibling
|
||||||
aria-label="<?php esc_attr_e( 'Search options', 'noindex-seo' ); ?>"
|
form, never nested inside the main settings form (HTML5 forbids
|
||||||
>
|
nested <form> elements). -->
|
||||||
</div>
|
<h2 class="noindex-seo-section-title"><?php esc_html_e( 'Recommended settings', 'noindex-seo' ); ?></h2>
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e( 'Enables all 5 directives on the 12 contexts flagged "Recommended" (privacy policy, date archives, pagination, search results, attachment pages, previews, 404). Review and save.', 'noindex-seo' ); ?>
|
||||||
|
</p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="noindex-seo-apply-form">
|
||||||
|
<input type="hidden" name="action" value="noindex_seo_apply_suggestions">
|
||||||
|
<?php wp_nonce_field( 'noindex_seo_apply_suggestions_nonce' ); ?>
|
||||||
|
<?php
|
||||||
|
submit_button(
|
||||||
|
__( 'Apply Recommended Defaults', 'noindex-seo' ),
|
||||||
|
'secondary',
|
||||||
|
'noindex-seo-apply-suggestions',
|
||||||
|
false,
|
||||||
|
array(
|
||||||
|
'title' => __( 'Enable all directives for the 12 contexts flagged as recommended.', 'noindex-seo' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Directive grid form (scoped to the settings tab): stats, alert,
|
||||||
|
search, section cards, submit. -->
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<input type="hidden" name="action" value="update_noindex_seo">
|
||||||
|
<input type="hidden" name="noindex_seo_form_scope" value="settings">
|
||||||
|
<?php wp_nonce_field( 'update_noindex_seo_nonce' ); ?>
|
||||||
|
|
||||||
|
<!-- Overview: the number cards. -->
|
||||||
|
<h2 class="noindex-seo-section-title"><?php esc_html_e( 'Overview', 'noindex-seo' ); ?></h2>
|
||||||
|
<div class="noindex-seo-stats">
|
||||||
|
<div class="noindex-seo-stat-card">
|
||||||
|
<div class="noindex-seo-stat-number" id="noindex-seo-stat-total">0</div>
|
||||||
|
<div class="noindex-seo-stat-label"><?php esc_html_e( 'Total Options', 'noindex-seo' ); ?></div>
|
||||||
|
</div>
|
||||||
|
<div class="noindex-seo-stat-card">
|
||||||
|
<div class="noindex-seo-stat-number" id="noindex-seo-stat-enabled">0</div>
|
||||||
|
<div class="noindex-seo-stat-label"><?php esc_html_e( 'Enabled', 'noindex-seo' ); ?></div>
|
||||||
|
</div>
|
||||||
|
<div class="noindex-seo-stat-card">
|
||||||
|
<div class="noindex-seo-stat-number" id="noindex-seo-stat-recommended">0</div>
|
||||||
|
<div class="noindex-seo-stat-label"><?php esc_html_e( 'Recommended to Enable', 'noindex-seo' ); ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Page contexts: the directive grid. -->
|
||||||
|
<h2 class="noindex-seo-section-title"><?php esc_html_e( 'Page contexts', 'noindex-seo' ); ?></h2>
|
||||||
|
|
||||||
|
<!-- Alert -->
|
||||||
|
<div class="noindex-seo-alert">
|
||||||
|
<span class="dashicons dashicons-warning"></span>
|
||||||
|
<p><?php esc_html_e( 'Important: Enabling noindex on the wrong pages can harm your search engine rankings. Only enable options you fully understand.', 'noindex-seo' ); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Search Box -->
|
||||||
|
<div class="noindex-seo-search">
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
placeholder="<?php esc_attr_e( 'Search options...', 'noindex-seo' ); ?>"
|
||||||
|
aria-label="<?php esc_attr_e( 'Search options', 'noindex-seo' ); ?>"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Sections as Cards -->
|
<!-- Sections as Cards -->
|
||||||
<?php foreach ( $sections as $section_id => $section ) : ?>
|
<?php foreach ( $sections as $section_id => $section ) : ?>
|
||||||
<?php
|
<?php
|
||||||
// Default icon when a dynamically-added section (e.g. 'custom_post_types'
|
// Default icon when a dynamically-added section (e.g. 'custom_post_types'
|
||||||
// added in 3.1.0) doesn't have an entry in the static $section_icons map.
|
// added in 3.1.0) doesn't have an entry in the static $section_icons map.
|
||||||
$icon = isset( $section_icons[ $section_id ] ) ? $section_icons[ $section_id ] : 'dashicons-admin-generic';
|
$icon = isset( $section_icons[ $section_id ] ) ? $section_icons[ $section_id ] : 'dashicons-admin-generic';
|
||||||
?>
|
?>
|
||||||
<div class="noindex-seo-card" id="noindex-seo-card-<?php echo esc_attr( $section_id ); ?>">
|
<div class="noindex-seo-card" id="noindex-seo-card-<?php echo esc_attr( $section_id ); ?>">
|
||||||
<div class="noindex-seo-card-header">
|
<div class="noindex-seo-card-header">
|
||||||
<h3>
|
<h3>
|
||||||
|
|
@ -3915,6 +3961,57 @@ function noindex_seo_admin() {
|
||||||
|
|
||||||
<?php submit_button(); ?>
|
<?php submit_button(); ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ( 'tools' === $current_tab ) : ?>
|
||||||
|
|
||||||
|
<!-- Export: download the current settings as a JSON file. -->
|
||||||
|
<h2 class="noindex-seo-section-title"><?php esc_html_e( 'Export settings', 'noindex-seo' ); ?></h2>
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e( 'Download the current settings as a JSON file.', 'noindex-seo' ); ?>
|
||||||
|
</p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="noindex-seo-apply-form">
|
||||||
|
<input type="hidden" name="action" value="noindex_seo_export">
|
||||||
|
<?php wp_nonce_field( 'noindex_seo_export' ); ?>
|
||||||
|
<?php
|
||||||
|
submit_button(
|
||||||
|
__( 'Export settings', 'noindex-seo' ),
|
||||||
|
'secondary',
|
||||||
|
'noindex-seo-export',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Import: restore the global settings from a previous export. -->
|
||||||
|
<h2 class="noindex-seo-section-title"><?php esc_html_e( 'Import settings', 'noindex-seo' ); ?></h2>
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e( 'Restore the global settings from a previously exported JSON file. Per-post and per-term overrides are kept.', 'noindex-seo' ); ?>
|
||||||
|
</p>
|
||||||
|
<form method="post" enctype="multipart/form-data" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="noindex-seo-apply-form">
|
||||||
|
<input type="hidden" name="action" value="noindex_seo_import">
|
||||||
|
<?php wp_nonce_field( 'noindex_seo_import' ); ?>
|
||||||
|
<label for="noindex_seo_import_file" class="noindex-seo-config-label">
|
||||||
|
<?php esc_html_e( 'Import settings', 'noindex-seo' ); ?>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="noindex_seo_import_file"
|
||||||
|
name="noindex_seo_import_file"
|
||||||
|
accept=".json,application/json"
|
||||||
|
>
|
||||||
|
<?php
|
||||||
|
submit_button(
|
||||||
|
__( 'Import settings', 'noindex-seo' ),
|
||||||
|
'secondary',
|
||||||
|
'noindex-seo-import',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
||||||
14
readme.txt
14
readme.txt
|
|
@ -3,9 +3,9 @@ Contributors: robotstxt, javiercasares
|
||||||
Tags: seo, noindex, nofollow, noarchive, robots
|
Tags: seo, noindex, nofollow, noarchive, robots
|
||||||
Requires at least: 4.7
|
Requires at least: 4.7
|
||||||
Tested up to: 7.2
|
Tested up to: 7.2
|
||||||
Stable tag: 3.2.0
|
Stable tag: 3.3.0
|
||||||
Requires PHP: 5.6
|
Requires PHP: 5.6
|
||||||
Version: 3.2.0
|
Version: 3.3.0
|
||||||
License: GPL-3.0-or-later
|
License: GPL-3.0-or-later
|
||||||
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
|
||||||
|
|
@ -143,6 +143,10 @@ No. By default all plugin data is preserved on uninstall. If you want a complete
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 3.3.0 =
|
||||||
|
|
||||||
|
Settings page reorganized with the native WordPress tab navigation (General / SEO Settings / Import-Export, no custom tab code) and titled sections; saving is tab-scoped so hidden tabs never reset each other's values.
|
||||||
|
|
||||||
= 3.2.0 =
|
= 3.2.0 =
|
||||||
|
|
||||||
Feature release: JSON export/import of the settings (validated, sanitized, per-post and per-term overrides untouched) and runtime conflict verification against the `wp_robots` API (foreign callbacks named in a dismissible notice).
|
Feature release: JSON export/import of the settings (validated, sanitized, per-post and per-term overrides untouched) and runtime conflict verification against the `wp_robots` API (foreign callbacks named in a dismissible notice).
|
||||||
|
|
@ -151,10 +155,6 @@ Feature release: JSON export/import of the settings (validated, sanitized, per-p
|
||||||
|
|
||||||
Admin UI modernization: all inline styles removed in favour of WordPress admin color-scheme-aware, RTL-ready classes (follows the admin color schemes instead of hardcoded colors); stale form-handler message corrected; unreachable REST fallbacks removed; Catalan and Spanish translations updated.
|
Admin UI modernization: all inline styles removed in favour of WordPress admin color-scheme-aware, RTL-ready classes (follows the admin color schemes instead of hardcoded colors); stale form-handler message corrected; unreachable REST fallbacks removed; Catalan and Spanish translations updated.
|
||||||
|
|
||||||
= 3.1.5 =
|
|
||||||
|
|
||||||
Maintenance review: WordPress floor corrected to 4.7 (oldest tested version, first with the complete REST API) and tested up to 7.2; nonce verification in the form handlers split into a capability check plus a standalone `check_admin_referer()`; dev dependencies updated; test suite expanded to 147 tests with 94.78% coverage.
|
|
||||||
|
|
||||||
= Previous versions =
|
= Previous versions =
|
||||||
|
|
||||||
If you want to see the full changelog, visit the [noindex SEO plugin page](https://www.robotstxt.software/plugins/noindex-seo/).
|
If you want to see the full changelog, visit the [noindex SEO plugin page](https://www.robotstxt.software/plugins/noindex-seo/).
|
||||||
|
|
@ -175,6 +175,6 @@ This plugin adheres to the following security measures and review protocols for
|
||||||
|
|
||||||
== Vulnerabilities ==
|
== Vulnerabilities ==
|
||||||
|
|
||||||
* No vulnerabilities have been published up to version 3.2.0.
|
* No vulnerabilities have been published up to version 3.3.0.
|
||||||
|
|
||||||
Found a security vulnerability? Please report it to us privately at the [noindex SEO GitHub repository](https://github.com/javiercasares/noindex-seo/security/advisories/new).
|
Found a security vulnerability? Please report it to us privately at the [noindex SEO GitHub repository](https://github.com/javiercasares/noindex-seo/security/advisories/new).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue