HEX
Server: Apache
System: Linux host.fiblib.com 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: agritoday (1002)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/agritoday/public_html/wp-content/plugins-x/wordpress-seo/src/helpers/robots-helper.php
<?php
/**
 * A helper object for the robots meta tag.
 *
 * @package Yoast\WP\SEO\Helpers
 */

namespace Yoast\WP\SEO\Helpers;

use Yoast\WP\SEO\Presentations\Indexable_Presentation;

/**
 * Class Robots_Helper
 */
class Robots_Helper {

	/**
	 * Sets the robots index to no index.
	 *
	 * @param string                 $robots       The current robots value.
	 * @param Indexable_Presentation $presentation Presentation.
	 *
	 * @return string The altered robots string.
	 */
	public function set_robots_no_index( $robots, Indexable_Presentation $presentation ) {
		// When robots is null just return the default but with noindex: `noindex, follow`.
		if ( ! \is_string( $robots ) ) {
			return 'noindex, follow';
		}

		// Already noindex.
		if ( \strpos( $robots, 'noindex' ) !== false ) {
			return $robots;
		}

		// Replace index with noindex.
		if ( \strpos( $robots, 'index' ) !== false ) {
			return \str_replace( 'index', 'noindex', $robots );
		}

		// Add noindex.
		return 'noindex, ' . $robots;
	}
}