v3.2.0
This commit is contained in:
parent
b66c727a95
commit
7b3c00cacc
8 changed files with 454 additions and 9 deletions
|
|
@ -1,5 +1,38 @@
|
|||
== Changelog ==
|
||||
|
||||
= 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).
|
||||
|
||||
**Added**
|
||||
|
||||
* **Export / Import of settings (JSON).** Two new controls on the settings page: "Export settings" downloads the consolidated settings as a JSON file (`noindex-seo-settings-{date}.json`), and "Import settings" restores the global settings from a previously exported file. Imports are strictly validated and sanitized: plugin marker check, 1 MB size limit, `is_uploaded_file()` verification, the upload is never persisted to the uploads directory, every directive is normalized to 0/1, config values go through the same safelists as the settings form, and contexts that do not exist on the importing site (e.g. custom post types from another install) are dropped. Per-post and per-term granular overrides are content data and are never touched by an import. Both actions require `manage_options` and a nonce; success and error notices survive the redirect.
|
||||
* **Runtime conflict verification (TODO #10).** When no known SEO plugin conflicts, `noindex_seo_detect_conflicts()` now also inspects the callbacks actually registered on the `wp_robots` filter (WordPress 5.7+): anything that is not a core callback or one of ours — a foreign function, a class method, or a closure from a theme or unknown plugin — produces a dismissible admin notice naming the detected callback. The core callback safelist is filterable via `noindex_seo_core_robots_callbacks`. The notice honours the existing "disable compatibility warnings" opt-out.
|
||||
|
||||
**Changed**
|
||||
|
||||
* Nothing.
|
||||
|
||||
**Fixed**
|
||||
|
||||
* Nothing.
|
||||
|
||||
**Security**
|
||||
|
||||
* No security changes; the new endpoints follow the canonical checklist (capability + nonce on both actions, strict input validation, safelisted config values, no persistence of uploads) and PHPCS/PHPStan/composer audit stay clean.
|
||||
|
||||
**Compatibility**
|
||||
|
||||
* WordPress: 4.7 - 7.2
|
||||
* PHP: 5.6 - 8.5
|
||||
|
||||
**Tests**
|
||||
|
||||
* PHPUnit: 9.6.36 (165 tests, all passing): export payload shape and JSON round-trip, import sanitizer (happy path, normalization, unknown-context dropping, malformed-payload rejection), handler guards, foreign-callback detection (functions, class methods, closures, own-prefix skipping, filterable safelist) and the runtime notice.
|
||||
|
||||
= 3.1.6 =
|
||||
|
||||
_Release date: 2026-09-18_
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -715,3 +715,32 @@ msgstr "Evita fragments de text als resultats de cerca"
|
|||
#: assets/js/editor-sidebar.js:237
|
||||
msgid "Active Directives:"
|
||||
msgstr "Directrius actives:"
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Export settings"
|
||||
msgstr "Exporta els ajustaments"
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Download the current settings as a JSON file."
|
||||
msgstr "Baixa els ajustaments actuals en un fitxer JSON."
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Import settings"
|
||||
msgstr "Importa els ajustaments"
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Restore the global settings from a previously exported JSON file. Per-post and per-term overrides are kept."
|
||||
msgstr "Restaura els ajustaments globals des d'un fitxer JSON exportat anteriorment. Les sobreescriptures per entrada i per terme es conserven."
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Settings imported successfully."
|
||||
msgstr "S'han importat els ajustaments correctament."
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "The settings file could not be imported: it is missing, too large, or not a valid noindex SEO export."
|
||||
msgstr "No s'ha pogut importar el fitxer d'ajustaments: no existeix, és massa gran o no és una exportació vàlida de noindex SEO."
|
||||
|
||||
#, php-format
|
||||
#: 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."
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -718,3 +718,32 @@ msgstr "Evitar fragmentos de texto en los resultados de búsqueda"
|
|||
#: assets/js/editor-sidebar.js:237
|
||||
msgid "Active Directives:"
|
||||
msgstr "Directivas activas:"
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Export settings"
|
||||
msgstr "Exportar ajustes"
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Download the current settings as a JSON file."
|
||||
msgstr "Descarga los ajustes actuales en un archivo JSON."
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Import settings"
|
||||
msgstr "Importar ajustes"
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Restore the global settings from a previously exported JSON file. Per-post and per-term overrides are kept."
|
||||
msgstr "Restaura los ajustes globales desde un archivo JSON exportado anteriormente. Las sobrescrituras por entrada y por término se conservan."
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Settings imported successfully."
|
||||
msgstr "Ajustes importados correctamente."
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "The settings file could not be imported: it is missing, too large, or not a valid noindex SEO export."
|
||||
msgstr "No se ha podido importar el archivo de ajustes: falta, es demasiado grande o no es una exportación válida de noindex SEO."
|
||||
|
||||
#, php-format
|
||||
#: 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."
|
||||
|
|
|
|||
|
|
@ -665,3 +665,32 @@ msgstr ""
|
|||
#: assets/js/editor-sidebar.js:237
|
||||
msgid "Active Directives:"
|
||||
msgstr ""
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Export settings"
|
||||
msgstr ""
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Download the current settings as a JSON file."
|
||||
msgstr ""
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Import settings"
|
||||
msgstr ""
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Restore the global settings from a previously exported JSON file. Per-post and per-term overrides are kept."
|
||||
msgstr ""
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "Settings imported successfully."
|
||||
msgstr ""
|
||||
|
||||
#: noindex-seo.php
|
||||
msgid "The settings file could not be imported: it is missing, too large, or not a valid noindex SEO export."
|
||||
msgstr ""
|
||||
|
||||
#, php-format
|
||||
#: 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 ""
|
||||
|
|
|
|||
325
noindex-seo.php
325
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.1.6
|
||||
* Version: 3.2.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.1.6' );
|
||||
define( 'NOINDEX_SEO_VERSION', '3.2.0' );
|
||||
|
||||
/**
|
||||
* Option key holding the consolidated plugin settings array.
|
||||
|
|
@ -1643,6 +1643,7 @@ function noindex_seo_detect_conflicts() {
|
|||
);
|
||||
|
||||
// Iterate through the conflicting plugins to check if any are active.
|
||||
$found_conflict = false;
|
||||
foreach ( $conflicting_plugins as $plugin_path => $plugin_name ) {
|
||||
if ( is_plugin_active( $plugin_path ) ) {
|
||||
// Add an admin notice if a conflicting plugin is active..
|
||||
|
|
@ -1655,13 +1656,113 @@ function noindex_seo_detect_conflicts() {
|
|||
echo '</p></div>';
|
||||
}
|
||||
);
|
||||
$found_conflict = true;
|
||||
break; // Stop checking after finding the first conflict.
|
||||
}
|
||||
}
|
||||
|
||||
// Runtime verification (3.2.0): when no known plugin conflicts, check
|
||||
// whether anything else is actually emitting robots directives through
|
||||
// the wp_robots API — this also catches themes and unknown plugins.
|
||||
// Only possible on WordPress 5.7+ (the filter does not exist earlier).
|
||||
if ( ! $found_conflict && function_exists( 'has_filter' ) && has_filter( 'wp_robots' ) ) {
|
||||
$foreign_callbacks = noindex_seo_get_foreign_robots_callbacks();
|
||||
if ( ! empty( $foreign_callbacks ) ) {
|
||||
add_action(
|
||||
'admin_notices',
|
||||
function () use ( $foreign_callbacks ) {
|
||||
echo '<div class="notice notice-warning is-dismissible"><p>';
|
||||
// translators: %s: comma-separated list of wp_robots callbacks.
|
||||
printf( esc_html__( '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.', 'noindex-seo' ), esc_html( implode( ', ', $foreign_callbacks ) ) );
|
||||
echo '</p></div>';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'admin_init', 'noindex_seo_detect_conflicts' );
|
||||
|
||||
/**
|
||||
* Returns the wp_robots filter callbacks that do not belong to WordPress
|
||||
* core or to this plugin.
|
||||
*
|
||||
* Runtime conflict verification for {@see noindex_seo_detect_conflicts()}:
|
||||
* instead of trusting plugin slugs, this inspects the callbacks actually
|
||||
* registered on the `wp_robots` filter. Core registers plain functions
|
||||
* (wp_robots_noindex, wp_robots_noindex_embeds, wp_robots_noindex_search,
|
||||
* wp_robots_max_image_preview_large and, conditionally, wp_robots_no_robots);
|
||||
* anything else — named functions from other code, class methods, or
|
||||
* closures — is a third-party robots emitter.
|
||||
*
|
||||
* Only meaningful on WordPress 5.7+; on older versions the filter does not
|
||||
* exist and an empty array is returned.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return string[] Unique readable callback identifiers ('function',
|
||||
* 'Class::method' or 'Closure').
|
||||
*/
|
||||
function noindex_seo_get_foreign_robots_callbacks() {
|
||||
$foreign = array();
|
||||
|
||||
$wp_filter = isset( $GLOBALS['wp_filter'] ) && is_array( $GLOBALS['wp_filter'] ) ? $GLOBALS['wp_filter'] : array();
|
||||
$robots_hook = isset( $wp_filter['wp_robots'] ) ? $wp_filter['wp_robots'] : null;
|
||||
if ( ! $robots_hook instanceof WP_Hook ) {
|
||||
return $foreign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the wp_robots callbacks considered native to WordPress core.
|
||||
*
|
||||
* Third-party code can extend this list if it needs to mark its own
|
||||
* callback as expected (e.g. a site-specific mu-plugin).
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param string[] $core_callbacks Function names registered by core on wp_robots.
|
||||
*/
|
||||
$core_callbacks = apply_filters(
|
||||
'noindex_seo_core_robots_callbacks',
|
||||
array(
|
||||
'wp_robots_noindex',
|
||||
'wp_robots_noindex_embeds',
|
||||
'wp_robots_noindex_search',
|
||||
'wp_robots_max_image_preview_large',
|
||||
'wp_robots_no_robots',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $robots_hook->callbacks as $callbacks ) {
|
||||
foreach ( $callbacks as $callback ) {
|
||||
$function = $callback['function'];
|
||||
|
||||
if ( $function instanceof Closure ) {
|
||||
$identifier = 'Closure';
|
||||
} elseif ( is_string( $function ) ) {
|
||||
if ( in_array( $function, $core_callbacks, true ) || 0 === strpos( $function, 'noindex_seo_' ) ) {
|
||||
continue;
|
||||
}
|
||||
$identifier = $function;
|
||||
} elseif ( is_array( $function ) ) {
|
||||
$class = is_object( $function[0] ) ? get_class( $function[0] ) : (string) $function[0];
|
||||
if ( 0 === strpos( $class, 'noindex_seo_' ) || 0 === strpos( $class, 'Noindex_Seo_' ) ) {
|
||||
continue;
|
||||
}
|
||||
$identifier = $class . '::' . (string) $function[1];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! in_array( $identifier, $foreign, true ) ) {
|
||||
$foreign[] = $identifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $foreign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the form submission for the 'noindex SEO' plugin settings.
|
||||
*
|
||||
|
|
@ -1805,6 +1906,169 @@ function noindex_seo_process_apply_suggestions() {
|
|||
}
|
||||
add_action( 'admin_post_noindex_seo_apply_suggestions', 'noindex_seo_process_apply_suggestions' );
|
||||
|
||||
/**
|
||||
* Builds the JSON export payload for the current settings.
|
||||
*
|
||||
* The payload carries a plugin marker, an export timestamp and the full
|
||||
* consolidated settings array, so a backup can be identified and validated
|
||||
* on import.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return array<string, mixed> Export payload.
|
||||
*/
|
||||
function noindex_seo_build_export_payload() {
|
||||
return array(
|
||||
'plugin' => 'noindex-seo',
|
||||
'exported' => gmdate( 'c' ),
|
||||
'settings' => noindex_seo_get_settings(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the "Export settings" form action: streams the current settings
|
||||
* as a downloadable JSON file.
|
||||
*
|
||||
* Hooked to the {@see 'admin_post_noindex_seo_export'} action.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function noindex_seo_handle_export() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_die( esc_html__( 'Permission denied.', 'noindex-seo' ) );
|
||||
}
|
||||
check_admin_referer( 'noindex_seo_export' );
|
||||
|
||||
nocache_headers();
|
||||
header( 'Content-Type: application/json; charset=utf-8' );
|
||||
header( 'Content-Disposition: attachment; filename=noindex-seo-settings-' . gmdate( 'Ymd-His' ) . '.json' );
|
||||
echo wp_json_encode( noindex_seo_build_export_payload() );
|
||||
exit;
|
||||
}
|
||||
add_action( 'admin_post_noindex_seo_export', 'noindex_seo_handle_export' );
|
||||
|
||||
/**
|
||||
* Validates and sanitizes a settings array that came from an imported
|
||||
* JSON file.
|
||||
*
|
||||
* Only contexts and directives currently known to the plugin are imported
|
||||
* (contexts for custom post types that do not exist on this site are
|
||||
* silently dropped); every directive value is normalized to 0/1 and every
|
||||
* config value to its safelisted form. The returned array always has the
|
||||
* full default shape of noindex_seo_get_settings().
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param mixed $raw Decoded JSON 'settings' value.
|
||||
* @return array{
|
||||
* version: int,
|
||||
* contexts: array<string, array<string, int>>,
|
||||
* config: array{
|
||||
* method: string,
|
||||
* granular: int,
|
||||
* taxonomies_granular: int,
|
||||
* seoplugins: int,
|
||||
* delete_on_uninstall: int
|
||||
* }
|
||||
* }|null Sanitized settings array, or null when the payload is not importable.
|
||||
*/
|
||||
function noindex_seo_sanitize_imported_settings( $raw ) {
|
||||
if ( ! is_array( $raw ) || ! isset( $raw['contexts'], $raw['config'] ) || ! is_array( $raw['contexts'] ) || ! is_array( $raw['config'] ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$settings = noindex_seo_get_settings();
|
||||
$directives = array( 'noindex', 'nofollow', 'noarchive', 'nosnippet', 'noimageindex' );
|
||||
|
||||
foreach ( noindex_seo_get_contexts() as $context ) {
|
||||
if ( ! isset( $raw['contexts'][ $context ] ) || ! is_array( $raw['contexts'][ $context ] ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $directives as $directive ) {
|
||||
if ( isset( $raw['contexts'][ $context ][ $directive ] ) && is_numeric( $raw['contexts'][ $context ][ $directive ] ) ) {
|
||||
$settings['contexts'][ $context ][ $directive ] = ( 1 === (int) $raw['contexts'][ $context ][ $directive ] ) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$raw_config = $raw['config'];
|
||||
|
||||
$method = isset( $raw_config['method'] ) && is_string( $raw_config['method'] )
|
||||
? $raw_config['method']
|
||||
: 'meta';
|
||||
$settings['config']['method'] = in_array( $method, array( 'meta', 'header', 'both' ), true ) ? $method : 'meta';
|
||||
|
||||
foreach ( array( 'granular', 'taxonomies_granular', 'seoplugins', 'delete_on_uninstall' ) as $key ) {
|
||||
$value = isset( $raw_config[ $key ] ) && is_numeric( $raw_config[ $key ] ) ? (int) $raw_config[ $key ] : 0;
|
||||
$settings['config'][ $key ] = ( 1 === $value ) ? 1 : 0;
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the "Import settings" form action: reads an uploaded JSON backup
|
||||
* and restores the global settings from it.
|
||||
*
|
||||
* The upload is validated (error code, size limit, is_uploaded_file) and
|
||||
* never persisted to the uploads directory. Per-post and per-term granular
|
||||
* overrides are content data and are never touched by an import.
|
||||
*
|
||||
* Hooked to the {@see 'admin_post_noindex_seo_import'} action.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function noindex_seo_handle_import() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_die( esc_html__( 'Permission denied.', 'noindex-seo' ) );
|
||||
}
|
||||
check_admin_referer( 'noindex_seo_import' );
|
||||
|
||||
$redirect_error = admin_url( 'options-general.php?page=noindex_seo&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.
|
||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$upload = isset( $_FILES['noindex_seo_import_file'] ) && is_array( $_FILES['noindex_seo_import_file'] )
|
||||
? $_FILES['noindex_seo_import_file'] // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
: array();
|
||||
|
||||
$error = isset( $upload['error'] ) && is_numeric( $upload['error'] ) ? (int) $upload['error'] : -1;
|
||||
$size = isset( $upload['size'] ) && is_numeric( $upload['size'] ) ? (int) $upload['size'] : 0;
|
||||
$tmp = isset( $upload['tmp_name'] ) && is_string( $upload['tmp_name'] ) ? $upload['tmp_name'] : '';
|
||||
|
||||
if ( UPLOAD_ERR_OK !== $error || '' === $tmp || $size > 1048576 || ! is_uploaded_file( $tmp ) ) {
|
||||
wp_safe_redirect( $redirect_error );
|
||||
exit;
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- reading the just-validated upload before it is discarded; is_uploaded_file() was checked above.
|
||||
$raw = file_get_contents( $tmp );
|
||||
$data = is_string( $raw ) ? json_decode( $raw, true ) : null;
|
||||
|
||||
if ( ! is_array( $data ) || 'noindex-seo' !== ( isset( $data['plugin'] ) ? $data['plugin'] : '' ) ) {
|
||||
wp_safe_redirect( $redirect_error );
|
||||
exit;
|
||||
}
|
||||
|
||||
$settings = noindex_seo_sanitize_imported_settings( isset( $data['settings'] ) ? $data['settings'] : null );
|
||||
|
||||
if ( null === $settings ) {
|
||||
wp_safe_redirect( $redirect_error );
|
||||
exit;
|
||||
}
|
||||
|
||||
noindex_seo_update_settings( $settings );
|
||||
|
||||
wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&imported=1' ) );
|
||||
exit;
|
||||
}
|
||||
add_action( 'admin_post_noindex_seo_import', 'noindex_seo_handle_import' );
|
||||
|
||||
/**
|
||||
* Returns the list of contexts flagged as suggested defaults on the settings page.
|
||||
*
|
||||
|
|
@ -3347,6 +3611,20 @@ function noindex_seo_admin() {
|
|||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display-only flag set by our own admin-post handler after a nonce check.
|
||||
if ( '1' === ( isset( $_GET['imported'] ) && is_string( $_GET['imported'] ) ? sanitize_key( wp_unslash( $_GET['imported'] ) ) : '' ) ) {
|
||||
echo '<div class="notice notice-success is-dismissible"><p>';
|
||||
esc_html_e( 'Settings imported successfully.', 'noindex-seo' );
|
||||
echo '</p></div>';
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display-only flag set by our own admin-post handler after a nonce check.
|
||||
if ( '1' === ( isset( $_GET['import_error'] ) && is_string( $_GET['import_error'] ) ? sanitize_key( wp_unslash( $_GET['import_error'] ) ) : '' ) ) {
|
||||
echo '<div class="notice notice-error is-dismissible"><p>';
|
||||
esc_html_e( 'The settings file could not be imported: it is missing, too large, or not a valid noindex SEO export.', 'noindex-seo' );
|
||||
echo '</p></div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- "Apply Recommended Defaults" — standalone sibling form, rendered
|
||||
|
|
@ -3373,6 +3651,49 @@ function noindex_seo_admin() {
|
|||
</span>
|
||||
</form>
|
||||
|
||||
<!-- Export / Import — standalone sibling forms, never nested inside
|
||||
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">
|
||||
<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
|
||||
);
|
||||
?>
|
||||
<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. -->
|
||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||
<input type="hidden" name="action" value="update_noindex_seo">
|
||||
|
|
|
|||
18
readme.txt
18
readme.txt
|
|
@ -3,9 +3,9 @@ Contributors: robotstxt, javiercasares
|
|||
Tags: seo, noindex, nofollow, noarchive, robots
|
||||
Requires at least: 4.7
|
||||
Tested up to: 7.2
|
||||
Stable tag: 3.1.6
|
||||
Stable tag: 3.2.0
|
||||
Requires PHP: 5.6
|
||||
Version: 3.1.6
|
||||
Version: 3.2.0
|
||||
License: GPL-3.0-or-later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
|
|
@ -99,6 +99,10 @@ Important note: if you have any doubt about any of the following items it is bes
|
|||
|
||||
== Using the plugin ==
|
||||
|
||||
= Export / Import =
|
||||
|
||||
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.
|
||||
|
||||
= REST API =
|
||||
|
||||
The plugin exposes two read-only endpoints under `/wp-json/noindex-seo/v1/` so headless consumers can read the configuration:
|
||||
|
|
@ -139,6 +143,10 @@ No. By default all plugin data is preserved on uninstall. If you want a complete
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 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).
|
||||
|
||||
= 3.1.6 =
|
||||
|
||||
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.
|
||||
|
|
@ -147,10 +155,6 @@ Admin UI modernization: all inline styles removed in favour of WordPress admin c
|
|||
|
||||
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.
|
||||
|
||||
= 3.1.3 =
|
||||
|
||||
Compatibility release: WordPress 4.0+ and PHP 5.6+ supported again (the classic `<meta name="robots">` output covers WordPress versions without the `wp_robots` API, and every newer-API integration degrades gracefully). Branding moved to robotstxt.software.
|
||||
|
||||
= Previous versions =
|
||||
|
||||
If you want to see the full changelog, visit the [noindex SEO plugin page](https://www.robotstxt.software/plugins/noindex-seo/).
|
||||
|
|
@ -171,6 +175,6 @@ This plugin adheres to the following security measures and review protocols for
|
|||
|
||||
== Vulnerabilities ==
|
||||
|
||||
* No vulnerabilities have been published up to version 3.1.6.
|
||||
* No vulnerabilities have been published up to version 3.2.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).
|
||||
|
|
|
|||
Loading…
Reference in a new issue