Changeset 3268580
- Timestamp:
- 04/08/2025 09:53:01 AM (8 months ago)
- Location:
- noindex-seo
- Files:
-
- 9 added
- 3 edited
-
tags/1.2.0 (added)
-
tags/1.2.0/changelog.txt (added)
-
tags/1.2.0/languages (added)
-
tags/1.2.0/languages/noindex-seo.pot (added)
-
tags/1.2.0/noindex-seo.php (added)
-
tags/1.2.0/readme.txt (added)
-
tags/1.2.0/uninstall.php (added)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/languages (added)
-
trunk/languages/noindex-seo.pot (added)
-
trunk/noindex-seo.php (modified) (15 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
noindex-seo/trunk/changelog.txt
r3181262 r3268580 1 1 == Changelog == 2 3 = 1.2.0 [2025-04-08] = 4 5 **Changes** 6 7 * Improved functions documentation. 8 9 **Fixes** 10 11 * The way the options are saved. 12 13 **Compatibility** 14 15 * WordPress: 4.1 - 6.8 16 * PHP: 5.6 - 8.4 17 18 **Tests** 19 20 * PHP Coding Standards: 3.12.1 21 * WordPress Coding Standards: 3.1.0 22 * Plugin Check (PCP): 1.4.0 2 23 3 24 = 1.1.1 [2024-11-04] = -
noindex-seo/trunk/noindex-seo.php
r3181262 r3268580 6 6 * Requires at least: 4.1 7 7 * Requires PHP: 5.6 8 * Version: 1. 1.18 * Version: 1.2.0 9 9 * Author: Javier Casares 10 10 * Author URI: https://www.javiercasares.com/ … … 20 20 21 21 /** 22 * Outputs a 'noindex' meta robots tag to the page. 23 * 24 * This function ensures the 'noindex' directive is set in the robots meta tag, 25 * instructing search engines not to index the content of the current page. 22 * Outputs a 'noindex' directive in the meta robots tag. 23 * 24 * This function adds a 'noindex' directive to the robots meta tag to instruct search engines 25 * not to index the current page. It uses the `wp_robots` filter if available (WordPress 5.7+), 26 * or falls back to echoing a raw meta tag for older WordPress versions. 27 * 28 * Intended to be called only when certain conditions are met, such as in specific templates 29 * or based on plugin configuration. 26 30 * 27 31 * @since 1.1.0 32 * 33 * @see https://developer.wordpress.org/reference/hooks/wp_robots/ 28 34 * 29 35 * @return void … … 44 50 } 45 51 46 47 /** 48 * Retrieves and sets the SEO 'noindex' values for various WordPress contexts. 49 * 50 * This function optimizes option retrieval by fetching all relevant settings at once 51 * using transient caching, reducing the number of database queries. 52 * 53 * @global WP_Post $post The post global for the current post, if within The Loop. 52 /** 53 * Determines whether to output a 'noindex' meta tag based on page context and plugin settings. 54 * 55 * This function checks the current page context (e.g., single post, category archive, 404 page, etc.) 56 * and evaluates plugin settings to determine if a 'noindex' directive should be added to the meta robots tag. 57 * 58 * It retrieves settings efficiently using a transient cache. If the cache is not set, it pulls values 59 * from the WordPress options API and rebuilds the cache. 60 * 61 * The list of contexts and their associated option keys can be filtered via the {@see 'noindex_seo_contexts'} filter. 62 * Once a matching context with 'noindex' enabled is found, it calls {@see noindex_seo_metarobots()} to apply the directive. 63 * 64 * @since 1.1.0 65 * 66 * @global WP_Post $post The global post object, if available. 54 67 * 55 68 * @return void 56 *57 * @since 1.1.058 69 */ 59 70 function noindex_seo_show() { … … 136 147 // Iterate through the contexts and apply 'noindex' if the condition and setting are true. 137 148 foreach ( $contexts as $context => $option_key ) { 149 138 150 if ( 139 151 isset( $current_conditions[ $context ] ) && … … 143 155 ) { 144 156 noindex_seo_metarobots(); 157 145 158 break; // Prevent multiple meta tags from being added. 146 159 } … … 156 169 157 170 /** 158 * Adds a 'Settings' link to the plugin action links on the plugins page. 171 * Adds a "Settings" link to the plugin row actions on the Plugins admin screen. 172 * 173 * This function appends a direct link to the plugin's settings page within the list of action links 174 * shown for the plugin on the Plugins page (`/wp-admin/plugins.php`). This improves user accessibility 175 * by allowing quick access to the plugin's configuration page. 176 * 177 * Hooked to the {@see 'plugin_action_links_{plugin_basename}'} filter. 159 178 * 160 179 * @since 1.0.0 161 180 * 162 * @param array $links An array of action links already present for the plugin. 163 * 164 * @return array Returns the updated array of action links including the 'Settings' link. 181 * @param string[] $links Array of existing action links for the plugin. 182 * @return string[] Modified array including the "Settings" link. 165 183 */ 166 184 function noindex_seo_settings_link( $links ) { … … 171 189 172 190 /** 173 * Adds a 'noindex SEO' options page to the WordPress admin menu. 191 * Registers the "noindex SEO" settings page in the WordPress admin menu. 192 * 193 * This function adds an entry under the "Settings" menu in the WordPress admin area, 194 * which links to the plugin's main configuration page. The settings page is only accessible 195 * to users with the 'manage_options' capability. 196 * 197 * Internally uses {@see add_options_page()} to register the page. 174 198 * 175 199 * @since 1.0.0 … … 188 212 189 213 /** 190 * Registers settings for the 'noindex SEO' plugin. 191 * 192 * This function registers a variety of settings associated with the 'noindex SEO' functionality in WordPress. 193 * Each setting determines whether specific pages or post types should be excluded from search engine indexing. 194 * The settings values are integers, with a default value of 0 (which typically represents 'false' or 'off' in boolean context). 214 * Registers all settings used by the 'noindex SEO' plugin. 215 * 216 * This function registers individual options for each context in which the plugin 217 * may apply a 'noindex' directive (e.g., single posts, category pages, archives, etc.). 218 * Each setting is stored as an integer (0 or 1), where 1 indicates that 'noindex' is enabled 219 * for that context. 220 * 221 * All settings are grouped under the option group 'noindexseo' and will be handled by the 222 * WordPress Settings API when the options form is submitted. 223 * 224 * Also registers the general configuration option 'noindex_seo_config_seoplugins'. 225 * A transient cache is cleared upon update using the {@see 'update_option_noindexseo'} action. 195 226 * 196 227 * @since 1.0.0 … … 228 259 229 260 foreach ( $settings as $setting ) { 261 230 262 register_setting( 231 263 'noindexseo', … … 252 284 253 285 /** 254 * Clears the transient cache when settings are updated. 286 * Clears the cached plugin settings stored in the transient. 287 * 288 * This function deletes the 'noindex_seo_options' transient to ensure that updated 289 * option values are fetched fresh from the database on the next request. It is typically 290 * triggered after the plugin settings are updated to prevent stale data from being used. 291 * 292 * Hooked to the {@see 'update_option_noindexseo'} action. 293 * 294 * @since 1.0.0 255 295 * 256 296 * @return void … … 261 301 262 302 /** 263 * Detects conflicting SEO plugins and notifies the administrator. 264 * 265 * This function checks if any known conflicting SEO plugins are active. 266 * If a conflict is detected, it displays an admin notice warning the user. 267 * 268 * @since 1.1.0. 269 * 270 * @return void. 303 * Detects potential conflicts with other SEO plugins and displays an admin notice. 304 * 305 * This function checks for the presence of known SEO plugins that may conflict with 306 * the functionality of 'noindex SEO'. If a conflicting plugin is active and the user 307 * has not opted to suppress warnings (via the 'noindex_seo_config_seoplugins' option), 308 * a dismissible admin notice is displayed to alert the site administrator. 309 * 310 * The list of conflicting plugins includes popular SEO tools such as Yoast SEO, Rank Math, 311 * SEOPress, and others. The check is performed using {@see is_plugin_active()}. 312 * 313 * Hooked to the {@see 'admin_init'} action. 314 * 315 * @since 1.1.0 316 * 317 * @return void 271 318 */ 272 319 function noindex_seo_detect_conflicts() { … … 274 321 $option_config_seoplugins = get_option( 'noindex_seo_config_seoplugins', 0 ); 275 322 276 if ( ! absint( $option_config_seoplugins ) ) {323 if ( ! absint( $option_config_seoplugins ) ) { 277 324 278 325 // Include the plugin.php file if the function is not available. … … 311 358 } 312 359 } 313 314 360 add_action( 'admin_init', 'noindex_seo_detect_conflicts' ); 315 361 316 362 /** 317 * Displays the administration settings page for the 'noindex SEO' plugin. 363 * Processes the form submission for the 'noindex SEO' plugin settings. 364 * 365 * This function handles the saving of plugin options submitted from the custom admin form. 366 * It first verifies the current user's capability and nonce for security. Then it resets all 367 * registered context options to `0`, and selectively updates those submitted as checked in the form. 368 * 369 * Additionally, it updates the general configuration setting `noindex_seo_config_seoplugins`, 370 * clears the plugin's transient cache, and redirects back to the settings page. 371 * 372 * Hooked to the {@see 'admin_post_update_noindex_seo'} action. 373 * 374 * @since 1.2.0 375 * 376 * @return void 377 */ 378 function noindex_seo_process_form() { 379 if ( ! current_user_can( 'manage_options' ) || ! check_admin_referer( 'update_noindex_seo_nonce' ) ) { 380 wp_die( esc_html__( 'Permission denied or invalid nonce.', 'noindex-seo' ) ); 381 } 382 383 $settings = array( 384 'error', 385 'archive', 386 'attachment', 387 'author', 388 'category', 389 'comment_feed', 390 'customize_preview', 391 'date', 392 'day', 393 'feed', 394 'front_page', 395 'home', 396 'month', 397 'page', 398 'paged', 399 'post_type_archive', 400 'preview', 401 'privacy_policy', 402 'robots', 403 'search', 404 'single', 405 'singular', 406 'tag', 407 'time', 408 'year', 409 ); 410 411 // Reset all options to 0. 412 foreach ( $settings as $setting ) { 413 update_option( 'noindex_seo_' . $setting, 0 ); 414 } 415 416 // Save only active options (checked checkboxes). 417 foreach ( $settings as $setting ) { 418 if ( isset( $_POST[ 'noindex_seo_' . $setting ] ) ) { 419 update_option( 'noindex_seo_' . $setting, 1 ); 420 } 421 } 422 423 // Save general configuration option. 424 update_option( 425 'noindex_seo_config_seoplugins', 426 isset( $_POST['noindex_seo_config_seoplugins'] ) ? 1 : 0 427 ); 428 429 // Clear cache. 430 delete_transient( 'noindex_seo_options' ); 431 432 wp_safe_redirect( admin_url( 'options-general.php?page=noindex_seo&updated=true' ) ); 433 exit; 434 } 435 add_action( 'admin_post_update_noindex_seo', 'noindex_seo_process_form' ); 436 437 /** 438 * Renders the settings page for the 'noindex SEO' plugin in the WordPress admin. 439 * 440 * This function outputs the full HTML for the plugin's settings interface, including: 441 * - General configuration (e.g., disabling conflict notices) 442 * - A structured list of SEO-related options grouped by context (main pages, archives, taxonomies, etc.) 443 * 444 * Each context is represented as a checkbox that allows the administrator to enable or disable 445 * the `noindex` meta directive for that specific section of the site. 446 * 447 * The form is submitted via `admin-post.php` and processed by {@see noindex_seo_process_form()}. 448 * Security is enforced with a nonce field. Options are retrieved using `get_option()` for each field. 318 449 * 319 450 * @since 1.0.0 … … 515 646 <div class="wrap"> 516 647 <h1><?php echo esc_html( __( 'noindex SEO Settings', 'noindex-seo' ) ); ?></h1> 517 <form method="post" action="options.php"> 648 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> 649 <input type="hidden" name="action" value="update_noindex_seo"> 518 650 <?php 519 settings_fields( 'noindexseo' ); 520 do_settings_sections( 'noindexseo' ); // In case you have sections added later. 651 wp_nonce_field( 'update_noindex_seo_nonce' ); 521 652 522 653 echo '<h2>' . esc_html( __( 'General Configuration', 'noindex-seo' ) ) . '</h2>'; … … 554 685 echo '<input type="checkbox" id="noindex_seo_' . esc_attr( $field_id ) . '" name="noindex_seo_' . esc_attr( $field_id ) . '" value="1" ' . checked( 1, $option, false ) . '> '; 555 686 echo esc_html( $field['recommended'] ) . ': <span class="dashicons ' . ( $field['suggestion'] ? 'dashicons-yes' : 'dashicons-no' ) . '" title="' . ( $field['suggestion'] ? 'Yes' : 'No' ) . '"></span>. '; 687 556 688 echo '<span class="description">' . esc_html( $field['description'] ) . '</span>'; 557 689 -
noindex-seo/trunk/readme.txt
r3181262 r3268580 3 3 Tags: seo, noindex 4 4 Requires at least: 4.1 5 Tested up to: 6. 76 Stable tag: 1. 1.15 Tested up to: 6.8 6 Stable tag: 1.2.0 7 7 Requires PHP: 5.6 8 Version: 1. 1.18 Version: 1.2.0 9 9 License: GPL-2.0-or-later 10 10 License URI: https://spdx.org/licenses/GPL-2.0-or-later.html … … 82 82 == Compatibility == 83 83 84 * WordPress: 4.1 - 6. 784 * WordPress: 4.1 - 6.8 85 85 * PHP: 5.6 - 8.4 86 86 87 87 == Changelog == 88 89 = 1.2.0 [2025-04-08] = 90 91 **Changes** 92 93 * Improved functions documentation. 94 95 **Fixes** 96 97 * The way the options are saved. 98 99 **Compatibility** 100 101 * WordPress: 4.1 - 6.8 102 * PHP: 5.6 - 8.4 103 104 **Tests** 105 106 * PHP Coding Standards: 3.12.1 107 * WordPress Coding Standards: 3.1.0 108 * Plugin Check (PCP): 1.4.0 88 109 89 110 = 1.1.1 [2024-11-04] = … … 138 159 == Vulnerabilities == 139 160 140 * No vulnerabilities have been published up to version 1. 1.0.161 * No vulnerabilities have been published up to version 1.2.0. 141 162 142 Found a security vulnerability? Please report it to us privately at the [ WPVulnerabilityGitHub repository](https://github.com/javiercasares/noindex-seo/security/advisories/new).163 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).
Note: See TracChangeset
for help on using the changeset viewer.