Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 54122d3d95 | |||
| 3cf187303e |
12 changed files with 3672 additions and 1009 deletions
|
|
@ -761,3 +761,122 @@ input:checked + .noindex-seo-slider:before {
|
|||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Value directives & rules (3.6.0)
|
||||
=========================== */
|
||||
|
||||
/* Settings-grid value cells: number, select and datetime inputs. */
|
||||
.noindex-seo-directive-value input[type="number"],
|
||||
.noindex-seo-directive-value input[type="datetime-local"] {
|
||||
width: 130px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.noindex-seo-directive-value select {
|
||||
width: 130px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.noindex-seo-directive-value .directive-label {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Meta-box and term-panel value rows. */
|
||||
.noindex-seo-value-list {
|
||||
margin-top: 10px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.noindex-seo-values-title {
|
||||
margin: 0 0 6px;
|
||||
}
|
||||
|
||||
.noindex-seo-value-row input[type="number"],
|
||||
.noindex-seo-value-row input[type="datetime-local"] {
|
||||
width: 150px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.noindex-seo-value-row select {
|
||||
width: 110px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.noindex-seo-term-directive-value {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.noindex-seo-term-directive-value input[type="number"],
|
||||
.noindex-seo-term-directive-value input[type="datetime-local"] {
|
||||
width: 150px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Quick Edit value rows. */
|
||||
.noindex-seo-quick-edit-value input[type="number"],
|
||||
.noindex-seo-quick-edit-value input[type="datetime-local"] {
|
||||
width: 130px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.noindex-seo-quick-edit-value select {
|
||||
width: 110px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Conditional-rules table. */
|
||||
.noindex-seo-rules-table {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.noindex-seo-rule-head,
|
||||
.noindex-seo-rule-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 44px;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.noindex-seo-rule-head {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.noindex-seo-rule-remove .dashicons {
|
||||
margin-top: 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Robots.txt management (3.7.0)
|
||||
=========================== */
|
||||
|
||||
.noindex-seo-robotstxt-table {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.noindex-seo-robotstxt-table input[type="text"] {
|
||||
width: 100%;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.noindex-seo-robotstxt-preview {
|
||||
max-width: 480px;
|
||||
padding: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-radius: 3px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.noindex-seo-robotstxt-preview code {
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
font-size: 12px;
|
||||
white-space: pre;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,82 @@
|
|||
initSearch();
|
||||
initStats();
|
||||
initTooltips();
|
||||
initRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the rule tables (conditional rules + robots.txt):
|
||||
* add / remove rows, and the robots.txt preset buttons.
|
||||
*/
|
||||
function initRules() {
|
||||
// Add rule: clone the last row of the target container and clear it.
|
||||
$( '.noindex-seo-rule-add' ).on(
|
||||
'click',
|
||||
function () {
|
||||
const target = $( this ).data( 'target' ) || '.noindex-seo-rule-rows';
|
||||
const $rows = $( target ).first();
|
||||
const max = parseInt( $rows.data( 'max-rules' ) || 20, 10 );
|
||||
|
||||
if ( $rows.find( '.noindex-seo-rule-row' ).length >= max ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $clone = $rows.find( '.noindex-seo-rule-row' ).last().clone();
|
||||
$clone.find( 'input[type="text"], input[type="number"], input[type="datetime-local"]' ).val( '' );
|
||||
$rows.append( $clone );
|
||||
}
|
||||
);
|
||||
|
||||
// Remove rule: drop the row, or clear it when it is the last one left.
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.noindex-seo-rule-remove',
|
||||
function () {
|
||||
const $row = $( this ).closest( '.noindex-seo-rule-row' );
|
||||
const $rows = $( this ).closest( '.noindex-seo-rule-rows' );
|
||||
|
||||
if ( $rows.find( '.noindex-seo-rule-row' ).length > 1 ) {
|
||||
$row.remove();
|
||||
} else {
|
||||
$row.find( 'input[type="text"]' ).val( '' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Robots.txt presets: append one blocked row per bot of the preset
|
||||
// (skipping agents that already have a rule).
|
||||
$( '.noindex-seo-robotstxt-preset' ).on(
|
||||
'click',
|
||||
function () {
|
||||
const preset = $( this ).data( 'preset' );
|
||||
const bots = ( 'search' === preset ) ? ( window.noindexSeoAdmin.searchBots || [] ) : ( window.noindexSeoAdmin.aiBots || [] );
|
||||
const $rows = $( '.noindex-seo-robotstxt-rows' ).first();
|
||||
const max = parseInt( $rows.data( 'max-rules' ) || 30, 10 );
|
||||
|
||||
const existing = {};
|
||||
$rows.find( 'input[name="noindex_seo_robotstxt_agent[]"]' ).each(
|
||||
function () {
|
||||
existing[ $( this ).val().toLowerCase() ] = true;
|
||||
}
|
||||
);
|
||||
|
||||
bots.forEach(
|
||||
function ( bot ) {
|
||||
if ( existing[ bot.toLowerCase() ] ) {
|
||||
return;
|
||||
}
|
||||
if ( $rows.find( '.noindex-seo-rule-row' ).length >= max ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $clone = $rows.find( '.noindex-seo-rule-row' ).last().clone();
|
||||
$clone.find( 'input[name="noindex_seo_robotstxt_agent[]"]' ).val( bot );
|
||||
$clone.find( 'select' ).val( 'block' );
|
||||
$rows.append( $clone );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
/**
|
||||
* Noindex SEO - Gutenberg Sidebar Panel
|
||||
* Version: 2.0.0
|
||||
* Version: 3.0.0
|
||||
*
|
||||
* Provides a native Gutenberg sidebar panel for controlling robots directives
|
||||
* on individual posts and pages.
|
||||
* on individual posts and pages: boolean flags plus the value directives
|
||||
* introduced in 3.6.0 (max-snippet, max-image-preview, max-video-preview,
|
||||
* unavailable_after).
|
||||
*
|
||||
* @package noindex-seo
|
||||
*/
|
||||
|
|
@ -11,11 +13,21 @@
|
|||
(function (wp) {
|
||||
const { registerPlugin } = wp.plugins;
|
||||
const { PluginDocumentSettingPanel } = wp.editPost;
|
||||
const { CheckboxControl, PanelRow } = wp.components;
|
||||
const { CheckboxControl, PanelRow, SelectControl, TextControl } = wp.components;
|
||||
const { useSelect, useDispatch } = wp.data;
|
||||
const { createElement: el } = wp.element;
|
||||
const { __ } = wp.i18n;
|
||||
|
||||
/**
|
||||
* Boolean directives: checkbox controls backed by integer meta (0/1).
|
||||
*/
|
||||
const booleanDirectives = ['noindex', 'nofollow', 'noarchive', 'nosnippet', 'noimageindex', 'notranslate'];
|
||||
|
||||
/**
|
||||
* Value directives: inputs backed by string meta ('' = off).
|
||||
*/
|
||||
const valueDirectives = ['max-snippet', 'max-image-preview', 'max-video-preview', 'unavailable_after'];
|
||||
|
||||
/**
|
||||
* Robots Directives Sidebar Panel Component
|
||||
*/
|
||||
|
|
@ -29,34 +41,42 @@
|
|||
|
||||
const { editPost } = useDispatch( 'core/editor' );
|
||||
|
||||
// Current values.
|
||||
const override = Boolean( postMeta._noindex_seo_override );
|
||||
const noindex = Boolean( postMeta._noindex_seo_noindex );
|
||||
const nofollow = Boolean( postMeta._noindex_seo_nofollow );
|
||||
const noarchive = Boolean( postMeta._noindex_seo_noarchive );
|
||||
const nosnippet = Boolean( postMeta._noindex_seo_nosnippet );
|
||||
const noimageindex = Boolean( postMeta._noindex_seo_noimageindex );
|
||||
// Current override state.
|
||||
const override = Boolean( postMeta._noindex_seo_override );
|
||||
|
||||
// Update meta function.
|
||||
const updateMeta = function (key, value) {
|
||||
// Update a boolean meta value (0/1).
|
||||
const updateBoolean = function (key, value) {
|
||||
const newMeta = {};
|
||||
newMeta[key] = value ? 1 : 0;
|
||||
editPost( { meta: newMeta } );
|
||||
};
|
||||
|
||||
// Update a value-directive meta value (string, '' = off).
|
||||
const updateValue = function (key, value) {
|
||||
const newMeta = {};
|
||||
newMeta[key] = value || '';
|
||||
editPost( { meta: newMeta } );
|
||||
};
|
||||
|
||||
// Clear all directive meta values.
|
||||
const clearAllDirectives = function () {
|
||||
const directives = ['noindex', 'nofollow', 'noarchive', 'nosnippet', 'noimageindex'];
|
||||
directives.forEach(
|
||||
const newMeta = {};
|
||||
booleanDirectives.forEach(
|
||||
function (directive) {
|
||||
updateMeta( '_noindex_seo_' + directive, false );
|
||||
newMeta['_noindex_seo_' + directive] = 0;
|
||||
}
|
||||
);
|
||||
valueDirectives.forEach(
|
||||
function (directive) {
|
||||
newMeta['_noindex_seo_' + directive] = '';
|
||||
}
|
||||
);
|
||||
editPost( { meta: newMeta } );
|
||||
};
|
||||
|
||||
// Handle override toggle.
|
||||
const handleOverrideChange = function (value) {
|
||||
updateMeta( '_noindex_seo_override', value );
|
||||
updateBoolean( '_noindex_seo_override', value );
|
||||
|
||||
// If disabling override, clear all directives.
|
||||
if ( ! value) {
|
||||
|
|
@ -64,26 +84,91 @@
|
|||
}
|
||||
};
|
||||
|
||||
// Get active directives for preview.
|
||||
// Build the preview list: names for booleans, name:value for values.
|
||||
const activeDirectives = [];
|
||||
if (override) {
|
||||
if (noindex) {
|
||||
activeDirectives.push( 'noindex' );
|
||||
}
|
||||
if (nofollow) {
|
||||
activeDirectives.push( 'nofollow' );
|
||||
}
|
||||
if (noarchive) {
|
||||
activeDirectives.push( 'noarchive' );
|
||||
}
|
||||
if (nosnippet) {
|
||||
activeDirectives.push( 'nosnippet' );
|
||||
}
|
||||
if (noimageindex) {
|
||||
activeDirectives.push( 'noimageindex' );
|
||||
}
|
||||
booleanDirectives.forEach(
|
||||
function (directive) {
|
||||
if ( Boolean( postMeta['_noindex_seo_' + directive] ) ) {
|
||||
activeDirectives.push( directive );
|
||||
}
|
||||
}
|
||||
);
|
||||
valueDirectives.forEach(
|
||||
function (directive) {
|
||||
const value = postMeta['_noindex_seo_' + directive];
|
||||
if ( value ) {
|
||||
activeDirectives.push( directive + ':' + value );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Boolean directive rows.
|
||||
const booleanRows = booleanDirectives.map(
|
||||
function (directive) {
|
||||
return el(
|
||||
PanelRow,
|
||||
{ key: directive + '-row' },
|
||||
el(
|
||||
CheckboxControl,
|
||||
{
|
||||
label: __( directive, 'noindex-seo' ),
|
||||
checked: Boolean( postMeta['_noindex_seo_' + directive] ),
|
||||
onChange: function (value) {
|
||||
updateBoolean( '_noindex_seo_' + directive, value ); },
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Value directive rows.
|
||||
const valueRows = valueDirectives.map(
|
||||
function (directive) {
|
||||
const metaKey = '_noindex_seo_' + directive;
|
||||
|
||||
if ( 'max-image-preview' === directive) {
|
||||
return el(
|
||||
PanelRow,
|
||||
{ key: directive + '-row' },
|
||||
el(
|
||||
SelectControl,
|
||||
{
|
||||
label: __( directive, 'noindex-seo' ),
|
||||
value: postMeta[metaKey] || '',
|
||||
options: [
|
||||
{ value: '', label: __( 'Off', 'noindex-seo' ) },
|
||||
{ value: 'none', label: __( 'none', 'noindex-seo' ) },
|
||||
{ value: 'standard', label: __( 'standard', 'noindex-seo' ) },
|
||||
{ value: 'large', label: __( 'large', 'noindex-seo' ) },
|
||||
],
|
||||
onChange: function (value) {
|
||||
updateValue( metaKey, value ); },
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const inputType = ( 'unavailable_after' === directive) ? 'datetime-local' : 'number';
|
||||
|
||||
return el(
|
||||
PanelRow,
|
||||
{ key: directive + '-row' },
|
||||
el(
|
||||
TextControl,
|
||||
{
|
||||
type: inputType,
|
||||
label: __( directive, 'noindex-seo' ),
|
||||
value: ( postMeta[metaKey] || '' ).toString().replace( ' ', 'T' ),
|
||||
onChange: function (value) {
|
||||
updateValue( metaKey, value ); },
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
return el(
|
||||
PluginDocumentSettingPanel,
|
||||
{
|
||||
|
|
@ -119,141 +204,68 @@
|
|||
}
|
||||
},
|
||||
[
|
||||
el(
|
||||
'p',
|
||||
{
|
||||
key: 'directives-label',
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
fontWeight: '600',
|
||||
marginBottom: '12px',
|
||||
color: '#1e1e1e',
|
||||
}
|
||||
},
|
||||
__( 'Robots Directives:', 'noindex-seo' )
|
||||
),
|
||||
|
||||
el(
|
||||
PanelRow,
|
||||
{ key: 'noindex-row' },
|
||||
el(
|
||||
CheckboxControl,
|
||||
{
|
||||
label: '🔍 ' + __( 'noindex', 'noindex-seo' ),
|
||||
help: __( 'Prevent search engines from indexing', 'noindex-seo' ),
|
||||
checked: noindex,
|
||||
onChange: function (value) {
|
||||
updateMeta( '_noindex_seo_noindex', value ); },
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
el(
|
||||
PanelRow,
|
||||
{ key: 'nofollow-row' },
|
||||
el(
|
||||
CheckboxControl,
|
||||
{
|
||||
label: '🔗 ' + __( 'nofollow', 'noindex-seo' ),
|
||||
help: __( 'Prevent search engines from following links', 'noindex-seo' ),
|
||||
checked: nofollow,
|
||||
onChange: function (value) {
|
||||
updateMeta( '_noindex_seo_nofollow', value ); },
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
el(
|
||||
PanelRow,
|
||||
{ key: 'noarchive-row' },
|
||||
el(
|
||||
CheckboxControl,
|
||||
{
|
||||
label: '💾 ' + __( 'noarchive', 'noindex-seo' ),
|
||||
help: __( 'Prevent cached versions in search results', 'noindex-seo' ),
|
||||
checked: noarchive,
|
||||
onChange: function (value) {
|
||||
updateMeta( '_noindex_seo_noarchive', value ); },
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
el(
|
||||
PanelRow,
|
||||
{ key: 'nosnippet-row' },
|
||||
el(
|
||||
CheckboxControl,
|
||||
{
|
||||
label: '📄 ' + __( 'nosnippet', 'noindex-seo' ),
|
||||
help: __( 'Prevent text snippets in search results', 'noindex-seo' ),
|
||||
checked: nosnippet,
|
||||
onChange: function (value) {
|
||||
updateMeta( '_noindex_seo_nosnippet', value ); },
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
el(
|
||||
PanelRow,
|
||||
{ key: 'noimageindex-row' },
|
||||
el(
|
||||
CheckboxControl,
|
||||
{
|
||||
label: '🖼️ ' + __( 'noimageindex', 'noindex-seo' ),
|
||||
help: __( 'Prevent image indexing', 'noindex-seo' ),
|
||||
checked: noimageindex,
|
||||
onChange: function (value) {
|
||||
updateMeta( '_noindex_seo_noimageindex', value ); },
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
// Preview section.
|
||||
activeDirectives.length > 0 && el(
|
||||
'div',
|
||||
{
|
||||
key: 'preview-section',
|
||||
style: {
|
||||
marginTop: '16px',
|
||||
padding: '12px',
|
||||
background: '#f0f6fc',
|
||||
border: '1px solid #0969da',
|
||||
borderRadius: '4px',
|
||||
}
|
||||
},
|
||||
[
|
||||
el(
|
||||
'p',
|
||||
{
|
||||
key: 'preview-label',
|
||||
style: {
|
||||
fontSize: '11px',
|
||||
fontWeight: '600',
|
||||
marginBottom: '8px',
|
||||
color: '#0969da',
|
||||
textTransform: 'uppercase',
|
||||
}
|
||||
},
|
||||
__( 'Active Directives:', 'noindex-seo' )
|
||||
),
|
||||
el(
|
||||
'code',
|
||||
{
|
||||
key: 'preview-code',
|
||||
key: 'directives-label',
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
display: 'block',
|
||||
padding: '8px',
|
||||
background: '#fff',
|
||||
border: '1px solid #d0d7de',
|
||||
borderRadius: '3px',
|
||||
wordBreak: 'break-word',
|
||||
fontWeight: '600',
|
||||
marginBottom: '12px',
|
||||
color: '#1e1e1e',
|
||||
}
|
||||
},
|
||||
activeDirectives.join( ', ' )
|
||||
__( 'Robots Directives:', 'noindex-seo' )
|
||||
),
|
||||
booleanRows,
|
||||
valueRows,
|
||||
|
||||
// Preview section.
|
||||
activeDirectives.length > 0 && el(
|
||||
'div',
|
||||
{
|
||||
key: 'preview-section',
|
||||
style: {
|
||||
marginTop: '16px',
|
||||
padding: '12px',
|
||||
background: '#f0f6fc',
|
||||
border: '1px solid #0969da',
|
||||
borderRadius: '4px',
|
||||
}
|
||||
},
|
||||
[
|
||||
el(
|
||||
'p',
|
||||
{
|
||||
key: 'preview-label',
|
||||
style: {
|
||||
fontSize: '11px',
|
||||
fontWeight: '600',
|
||||
marginBottom: '8px',
|
||||
color: '#0969da',
|
||||
textTransform: 'uppercase',
|
||||
}
|
||||
},
|
||||
__( 'Active Directives:', 'noindex-seo' )
|
||||
),
|
||||
el(
|
||||
'code',
|
||||
{
|
||||
key: 'preview-code',
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
display: 'block',
|
||||
padding: '8px',
|
||||
background: '#fff',
|
||||
border: '1px solid #d0d7de',
|
||||
borderRadius: '3px',
|
||||
wordBreak: 'break-word',
|
||||
}
|
||||
},
|
||||
activeDirectives.join( ', ' )
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,88 @@
|
|||
== Changelog ==
|
||||
|
||||
= 3.7.0 =
|
||||
|
||||
_Release date: 2026-11-03_
|
||||
|
||||
**Highlights**
|
||||
|
||||
* Import from other SEO plugins (spec section 5): on-demand migration of the noindex / nofollow flags stored by Yoast SEO, Rank Math, SEOPress and All in One SEO into noindex SEO per-post and per-term overrides — detected from data presence (the source plugin does not need to be installed), user-confirmed, and never overwriting content that already has its own override.
|
||||
* Virtual robots.txt management (spec section 7): block (`Disallow: /`) or allow (`Allow: /`) individual crawlers, appended to the robots.txt WordPress generates virtually — never replacing it — with one-click presets for the well-known AI and search-engine crawlers. Inactive by default.
|
||||
|
||||
**Added**
|
||||
|
||||
* **Import from other plugins.** A new section on the Import / Export tab lists every supported source plugin together with how many posts and terms carry its robots flags, and imports the checked ones on explicit confirmation. The runner converts source flags into granular overrides (`_noindex_seo_override=1` plus noindex / nofollow), skips and reports content that already carries a noindex SEO override row (an explicit "off" counts as data), re-verifies LIKE-based matches (Rank Math's serialized arrays) per post so false positives are dropped, and whitelists source slugs server-side. Sources are data-driven and filterable (`noindex_seo_import_sources`) so third parties can register or correct one.
|
||||
* **Robots.txt tab.** A fourth settings tab manages up to 30 bot rules (User-agent token + block/allow policy; `*` wildcard supported, duplicates collapse, agents stripped to the robots.txt-legal charset). The rules are appended through core's `robots_txt` filter only while the feature is enabled, a live preview shows the exact block appended, and preset buttons add the well-known AI crawlers (GPTBot, ClaudeBot, Google-Extended, CCBot, Bytespider… — filterable via `noindex_seo_ai_bots`) or the main search engine crawlers (`noindex_seo_search_bots`) as blocked rules. The core output — and a physical robots.txt or "Discourage search engines" — always takes precedence.
|
||||
* The robots.txt settings ride the consolidated option and the JSON export/import.
|
||||
|
||||
**Changed**
|
||||
|
||||
* The settings page gained a fourth tab (General / SEO Settings / Import-Export / Robots.txt); the rule-table JavaScript is now shared between the conditional rules and the robots.txt tables, scoped per container.
|
||||
|
||||
**Fixed**
|
||||
|
||||
* Block editor granular overrides now save on custom post types registered without `custom-fields` support (a very common CPT registration). Without that support the REST API exposes no `meta` field for the post type, so the editor sidebar's saves were silently dropped with an HTTP 200 — the override checkbox appeared to do nothing. The plugin now adds `custom-fields` support for exactly the post types it registers meta on (while per-post granular control is enabled).
|
||||
|
||||
**Security**
|
||||
|
||||
* No new attack surface: the import handler is `manage_options` + nonce gated with whitelisted sources, writes only through the meta API after re-reading each source flag, and skips content with existing override data; robots.txt agents are charset-stripped (no newline or comment injection into the file) and policies are whitelisted; the tab form rides the existing nonce + capability path. PHPCS/PHPStan/composer audit clean.
|
||||
|
||||
**Compatibility**
|
||||
|
||||
* WordPress: 7.0 - 7.2
|
||||
* PHP: 8.3 - 8.6
|
||||
|
||||
**Tests**
|
||||
|
||||
* PHPUnit: 9.6.38 (230 tests, 1152 assertions, all passing) on the WordPress 7.2-beta3 test library, run under PHP 8.3, 8.4, 8.5 and 8.6.0RC3 — including the new robots.txt sanitization/output/filter/form suites and the import detection/conversion/never-overwrite/false-positive/handler suites.
|
||||
* PHPCompatibility: 0 errors on the declared range 8.3-8.6 and on the full review range 5.6-8.6.
|
||||
* PHPCS (WordPress-Core, -Docs, -Extra) and PHPStan level 9: 0 errors.
|
||||
* Translations: Catalan and Spanish catalogs regenerated and 100% complete (209 strings each).
|
||||
|
||||
= 3.6.0 =
|
||||
|
||||
_Release date: 2026-11-03_
|
||||
|
||||
**Highlights**
|
||||
|
||||
* Modern robots directives (TODO #5): `notranslate`, `max-snippet`, `max-image-preview`, `max-video-preview` and `unavailable_after` join the five existing booleans — on every surface: the global context grid, per-post and per-term granular overrides, Quick Edit, the block editor sidebar, the REST `/effective` endpoint and WP-CLI (`name=value` tokens).
|
||||
* Conditional auto-noindex rules (TODO #11): apply `noindex` automatically to any post whose custom field (for example an ACF field) exactly matches a value; matched posts also drop out of the core XML sitemap.
|
||||
* Multisite behavior documented (TODO #9, docs variant): per-site by design, with an export/import-based rollout recipe.
|
||||
|
||||
**Added**
|
||||
|
||||
* **Value directives everywhere.** Boolean directives are flags; value directives carry a value and render as `name:value` (`max-snippet:-1`, `max-image-preview:large`, `unavailable_after: Tue, 01 Jan 2030 09:00:00 +0000` in site time with a numeric UTC offset). They are configured with typed inputs (number, size select, `datetime-local`) on the settings grid, the post meta box, Quick Edit, the term panel and the Gutenberg sidebar; stored in the consolidated option (contexts) and in `_noindex_seo_{directive}` post/term meta; registered with the REST API (`register_post_meta`/`register_term_meta` with per-type sanitization); exported/imported with normalization; and supported by WP-CLI — `wp noindex-seo set archive max-snippet=-1 max-image-preview=large`, `wp noindex-seo unset archive max-snippet` (plain name clears the value), and `list` reports the configured value (`max-snippet:-1`) or `off`.
|
||||
* **`notranslate`** as the sixth boolean directive, including a matching SVG icon in the plugin's icon registry and membership in the "Apply Recommended Defaults" set (which enables the six booleans; value directives stay untouched — "enabling" them without a value is meaningless).
|
||||
* **Conditional rules (TODO #11).** A "Conditional rules" card on the SEO Settings tab manages up to 20 exact-match rules (custom field name + value; rows with empty field/value are ignored, and the plugin's own `_noindex_seo_` meta keys are rejected). Rules run on the front-end below an explicit per-post override and above per-CPT/global defaults; matched posts surface as `source: auto_rule` in `/effective` and are excluded from the pages sitemap. The rules read plain post meta, so no ACF installation is required.
|
||||
* A `notranslate` SVG directive icon, plus badge support for value directives in the Robots columns (`max-snippet:-1` tokens).
|
||||
|
||||
**Changed**
|
||||
|
||||
* `noindex_seo_metarobots()` now takes a directive **map** (`name => true|value`); a flat list of boolean names (the pre-3.6.0 third-party calling convention) is still accepted and normalized. The `wp_robots` integration passes directive values through to core (`$robots['max-snippet'] = '-1'`).
|
||||
* `noindex_seo_get_setting()` returns the normalized string value for value directives ('' = off) instead of coercing everything to 0/1; the hourly transient cache stores values the same way.
|
||||
* The WP-CLI `set`/`unset` default (no directive arguments) now enables/disables the six boolean directives; value directives always require explicit `name=value` tokens (a value on a boolean, or an invalid/missing value, is rejected with a descriptive error). Datetime values need quoting or a `T` separator because of the space: `unavailable_after=2030-01-01T09:00`.
|
||||
* Block editor sidebar labels dropped their emoji prefixes (matching the 3.5.0 admin UI icon direction), and the sidebar gained controls for all five new directives.
|
||||
|
||||
**Fixed**
|
||||
|
||||
* Nothing.
|
||||
|
||||
**Security**
|
||||
|
||||
* No new attack surface: rules and value directives ride the existing nonce + capability paths (settings form: `manage_options` + `check_admin_referer`; meta box/Quick Edit: `edit_post`; term panel: `manage_categories`); every value normalizes through a single whitelist-driven normalizer (integers ≥ -1, a none/standard/large enum, a parse-validated datetime); rule fields strip everything but `[A-Za-z0-9_-]` and values go through `sanitize_text_field()`; sitemap rule clauses use WP_Query's `meta_query` (prepared by core). PHPCS/PHPStan/composer audit clean.
|
||||
|
||||
**Compatibility**
|
||||
|
||||
* WordPress: 7.0 - 7.2
|
||||
* PHP: 8.3 - 8.6
|
||||
|
||||
**Tests**
|
||||
|
||||
* PHPUnit: 9.6.38 (216 tests, 1107 assertions, all passing) on the WordPress 7.2-beta3 test library, run under PHP 8.3, 8.4, 8.5 and 8.6.0RC3 — including the new registry/normalization, settings-merge, form-roundtrip, front-end value output, granular value overrides, REST formatted tokens, CLI name=value, rules sanitization/matching/precedence/sitemap/auto_rule suites.
|
||||
* PHPCompatibility: 0 errors on the declared range 8.3-8.6 and on the full review range 5.6-8.6.
|
||||
* PHPCS (WordPress-Core, -Docs, -Extra) and PHPStan level 9: 0 errors.
|
||||
* Translations: Catalan and Spanish catalogs regenerated and 100% complete (188/187 strings), including the previously untranslated strings found during the merge.
|
||||
|
||||
= 3.5.0 =
|
||||
|
||||
_Release date: 2026-11-03_
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2100
noindex-seo.php
2100
noindex-seo.php
File diff suppressed because it is too large
Load diff
60
readme.txt
60
readme.txt
|
|
@ -3,9 +3,9 @@ Contributors: robotstxt, javiercasares
|
|||
Tags: seo, noindex, nofollow, noarchive, robots
|
||||
Requires at least: 7.0
|
||||
Tested up to: 7.2
|
||||
Stable tag: 3.5.0
|
||||
Stable tag: 3.7.0
|
||||
Requires PHP: 8.3
|
||||
Version: 3.5.0
|
||||
Version: 3.7.0
|
||||
License: GPL-3.0-or-later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
|
|
@ -13,9 +13,9 @@ Control search engine indexing with robots directives using HTML meta tags or HT
|
|||
|
||||
== Description ==
|
||||
|
||||
Fine-grained control over how search engines index and display your WordPress content. Apply 5 independent robots directives to 25 different page contexts with flexible implementation methods.
|
||||
Fine-grained control over how search engines index and display your WordPress content. Apply 10 robots directives to 25 different page contexts with flexible implementation methods.
|
||||
|
||||
**5 Robots Directives:**
|
||||
**5 Boolean Robots Directives:**
|
||||
|
||||
* **noindex**: Prevent search engines from indexing the page
|
||||
* **nofollow**: Prevent search engines from following links on the page
|
||||
|
|
@ -23,6 +23,16 @@ Fine-grained control over how search engines index and display your WordPress co
|
|||
* **nosnippet**: Prevent search engines from showing text snippets in results
|
||||
* **noimageindex**: Prevent search engines from indexing images on the page
|
||||
|
||||
**5 Value Robots Directives (3.6.0):**
|
||||
|
||||
* **notranslate**: Ask search engines not to translate the page
|
||||
* **max-snippet**: Limit the text snippet length in characters (-1 = no limit)
|
||||
* **max-image-preview**: Limit the image preview size (none / standard / large)
|
||||
* **max-video-preview**: Limit the video preview length in seconds (-1 = no limit)
|
||||
* **unavailable_after**: Stop indexing the page after a date and time
|
||||
|
||||
**Conditional rules (3.6.0):** automatically apply noindex to any post whose custom field (for example an ACF field) exactly matches a value you define.
|
||||
|
||||
**Implementation Methods:**
|
||||
|
||||
* HTML Meta Tags: Traditional method, easy to verify in page source (default)
|
||||
|
|
@ -110,7 +120,7 @@ Important note: if you have any doubt about any of the following items it is bes
|
|||
The plugin ships a `wp noindex-seo` command namespace (WP-CLI 2.x required):
|
||||
|
||||
* `wp noindex-seo list [--only=<context>] [--format=<format>]` — lists every context × directive pair and its on/off status (table, csv, json or yaml).
|
||||
* `wp noindex-seo set <context> [<directive>...]` — enables directives on a context (default: all five). Example: `wp noindex-seo set search noindex noarchive`.
|
||||
* `wp noindex-seo set <context> [<directive>...]` — enables directives on a context (default: all six boolean directives). Boolean directives go by name; value directives as `name=value`: `wp noindex-seo set search noindex noarchive`, `wp noindex-seo set archive max-snippet=-1 max-image-preview=large`.
|
||||
* `wp noindex-seo unset <context> [<directive>...]` — disables directives on a context.
|
||||
* `wp noindex-seo export [<file>]` — prints the settings payload as JSON to STDOUT, or writes it to a file.
|
||||
* `wp noindex-seo import <file> [--dry-run]` — restores settings from an export; `--dry-run` reports how many values would change without saving.
|
||||
|
|
@ -122,15 +132,35 @@ The commands enforce the same rules as the settings page (unknown contexts and d
|
|||
|
||||
The settings page includes an "Export settings" button that downloads the current global settings as a JSON file, and an "Import settings" form that restores them on the same or another site (useful for migrations and staging-to-production copies). Imports are strictly validated, and per-post / per-term overrides are never touched.
|
||||
|
||||
= Robots.txt =
|
||||
|
||||
A dedicated "Robots.txt" tab extends the robots.txt that WordPress generates virtually with bot rules — it never replaces the core output and is inactive until you enable it:
|
||||
|
||||
* Block (`Disallow: /`) or allow (`Allow: /`) individual crawlers, with `*` wildcard rules supported.
|
||||
* One-click presets add the well-known AI crawlers (GPTBot, ClaudeBot, Google-Extended, CCBot, Bytespider…) or the main search engine crawlers (Googlebot, Bingbot, DuckDuckBot…) as blocked rules — edit them freely afterwards. Both lists are filterable.
|
||||
* Rules only apply when WordPress serves robots.txt itself: a physical robots.txt file in the site root, or "Discourage search engines" in Reading settings, takes precedence.
|
||||
|
||||
= Import from other plugins =
|
||||
|
||||
The "Import / Export" tab detects robots data left by other SEO plugins — Yoast SEO, Rank Math, SEOPress and All in One SEO (installed or not) — and imports their noindex / nofollow flags as per-post and per-term overrides. Nothing imports automatically: you pick the detected plugins and confirm. Content that already has its own override — even a disabled one — is never touched and is reported as skipped.
|
||||
|
||||
= REST API =
|
||||
|
||||
The plugin exposes two read-only endpoints under `/wp-json/noindex-seo/v1/` so headless consumers can read the configuration:
|
||||
|
||||
* `GET /settings`: returns the consolidated settings array (contexts and directives plus config). Requires an authenticated user with the `manage_options` capability.
|
||||
* `GET /effective?post_id=123`: returns the list of active directives for a specific post, computed with the same precedence used on the front-end (per-post override, then per-post-type default, then the built-in context). Public only for published, non-password-protected posts; everything else requires `edit_post` capabilities.
|
||||
* `GET /effective?post_id=123`: returns the list of active directives for a specific post, computed with the same precedence used on the front-end (per-post override, then conditional rules, then per-post-type default, then the built-in context). Value directives return as `name:value` tokens (e.g. `max-snippet:-1`); `source` is `post_meta`, `auto_rule` (a conditional rule matched) or `global_setting`. Public only for published, non-password-protected posts; everything else requires `edit_post` capabilities.
|
||||
|
||||
On WordPress versions with XML sitemaps (5.5+), URLs that are noindexed are automatically excluded from the core sitemaps.
|
||||
|
||||
== Multisite ==
|
||||
|
||||
The plugin is designed **per site** and works on WordPress Multisite when activated on each site individually (or via the Network Admin's "Add Plugin" per-site flow):
|
||||
|
||||
* Directives are site-content concerns, so every site keeps its own independent settings, per-post overrides, per-term overrides and conditional rules (stored per site, no network-wide storage).
|
||||
* There is no network-admin settings page and no `Network: true` header by design: activating the plugin network-wide would apply each site's own settings anyway (each site reads its own options), so per-site activation is the intended and documented mode.
|
||||
* To roll out the same configuration across sites, use the built-in export/import (Tools tab, JSON) or `wp noindex-seo export` / `wp noindex-seo import` per site — for example with WP-CLI's `--url` switch.
|
||||
|
||||
== Installation ==
|
||||
|
||||
= Automatic download =
|
||||
|
|
@ -162,18 +192,18 @@ No. By default all plugin data is preserved on uninstall. If you want a complete
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 3.7.0 =
|
||||
|
||||
Feature release: on-demand import of robots overrides from other SEO plugins (Yoast SEO, Rank Math, SEOPress, All in One SEO — detected with or without them installed, never overwriting existing data) and virtual robots.txt management: block or allow individual crawlers (AI and search-engine presets included) appended to the robots.txt WordPress generates, inactive by default.
|
||||
|
||||
= 3.6.0 =
|
||||
|
||||
Feature release: 5 modern robots directives (notranslate, max-snippet, max-image-preview, max-video-preview, unavailable_after) available on every surface — global contexts, per-post and per-term overrides, Quick Edit, the block editor sidebar, REST and WP-CLI (name=value tokens); conditional auto-noindex rules that apply noindex when a custom field (e.g. an ACF field) exactly matches a value (matched posts also drop out of the XML sitemap); Multisite behavior documented (per-site by design, with export/import-based rollout).
|
||||
|
||||
= 3.5.0 =
|
||||
|
||||
WooCommerce special-page contexts: dedicated robots directives for the Cart, Checkout and My Account pages (detected through the page-ID options, no WooCommerce code needed), recommended by default and mirrored across the front-end, the REST /effective endpoint and the core XML sitemaps. Compatibility window updated to WordPress 7.0 - 7.2 and PHP 8.3 - 8.6 (tested on WordPress 7.2-beta3 and PHP 8.6.0RC3). The five directive icons now render as SVG through the WordPress Icons API on WP 7.2+ (legacy emoji fallback on WP 7.0 - 7.1), matching the SVG direction of the WordPress 7.2 admin. Fixed the `wp noindex-seo list` command, which fatalled on real WP-CLI installs (its `--context` filter collided with WP-CLI 2.11+'s reserved global flag, now `--only`, and the output call used a nonexistent API).
|
||||
|
||||
= 3.4.0 =
|
||||
|
||||
WP-CLI support: a `wp noindex-seo` command namespace with `list`, `set`, `unset`, `export`, `import` and bulk per-post `override` — automation-friendly and scaling past the ~200-post ceiling of the bulk UI.
|
||||
|
||||
= 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.
|
||||
|
||||
= Previous versions =
|
||||
|
||||
If you want to see the full changelog, visit the [noindex SEO plugin page](https://www.robotstxt.software/plugins/noindex-seo/).
|
||||
|
|
@ -194,6 +224,6 @@ This plugin adheres to the following security measures and review protocols for
|
|||
|
||||
== Vulnerabilities ==
|
||||
|
||||
* No vulnerabilities have been published up to version 3.5.0.
|
||||
* No vulnerabilities have been published up to version 3.7.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).
|
||||
|
|
|
|||
|
|
@ -137,7 +137,8 @@ $wpdb->query(
|
|||
)
|
||||
);
|
||||
|
||||
// Clean up post meta (granular control).
|
||||
// Clean up post meta (granular control). The 3.6.0 value directives store
|
||||
// their per-post values under the same prefix.
|
||||
$noindex_seo_meta_keys = array(
|
||||
'_noindex_seo_override',
|
||||
'_noindex_seo_noindex',
|
||||
|
|
@ -145,6 +146,11 @@ $noindex_seo_meta_keys = array(
|
|||
'_noindex_seo_noarchive',
|
||||
'_noindex_seo_nosnippet',
|
||||
'_noindex_seo_noimageindex',
|
||||
'_noindex_seo_notranslate',
|
||||
'_noindex_seo_max-snippet',
|
||||
'_noindex_seo_max-image-preview',
|
||||
'_noindex_seo_max-video-preview',
|
||||
'_noindex_seo_unavailable_after',
|
||||
);
|
||||
|
||||
foreach ( $noindex_seo_meta_keys as $noindex_seo_meta_key ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue