| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/wordpress-seo/src/integrations/front-end/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Integrations\Front_End;
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
use Yoast\WP\SEO\Helpers\Robots_Helper;
use Yoast\WP\SEO\Integrations\Integration_Interface;
/**
* Class Indexing_Controls.
*/
class Indexing_Controls implements Integration_Interface {
/**
* The robots helper.
*
* @var Robots_Helper
*/
protected $robots;
/**
* Returns the conditionals based in which this loadable should be active.
*
* @return array
*/
public static function get_conditionals() {
return [ Front_End_Conditional::class ];
}
/**
* The constructor.
*
* @codeCoverageIgnore Sets the dependencies.
*
* @param Robots_Helper $robots The robots helper.
*/
public function __construct( Robots_Helper $robots ) {
$this->robots = $robots;
}
/**
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @codeCoverageIgnore
*
* @return void
*/
public function register_hooks() {
// The option `blog_public` is set in Settings > Reading > Search Engine Visibility.
if ( (string) \get_option( 'blog_public' ) === '0' ) {
\add_filter( 'wpseo_robots_array', [ $this->robots, 'set_robots_no_index' ] );
}
\add_action( 'template_redirect', [ $this, 'noindex_robots' ] );
\add_filter( 'loginout', [ $this, 'nofollow_link' ] );
\add_filter( 'register', [ $this, 'nofollow_link' ] );
// Remove actions that we will handle through our wpseo_head call, and probably change the output of.
\remove_action( 'wp_head', 'rel_canonical' );
\remove_action( 'wp_head', 'index_rel_link' );
\remove_action( 'wp_head', 'start_post_rel_link' );
\remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
\remove_action( 'wp_head', 'noindex', 1 );
}
/**
* Sends a Robots HTTP header preventing URL from being indexed in the search results while allowing search engines
* to follow the links in the object at the URL.
*
* @return bool Boolean indicating whether the noindex header was sent.
*/
public function noindex_robots() {
if ( ! \is_robots() ) {
return false;
}
return $this->set_robots_header();
}
/**
* Adds rel="nofollow" to a link, only used for login / registration links.
*
* @param string $input The link element as a string.
*
* @return string
*/
public function nofollow_link( $input ) {
return \str_replace( '<a ', '<a rel="nofollow" ', $input );
}
/**
* Sets the x-robots-tag to noindex follow.
*
* @codeCoverageIgnore Too difficult to test.
*
* @return bool
*/
protected function set_robots_header() {
if ( \headers_sent() === false ) {
\header( 'X-Robots-Tag: noindex, follow', true );
return true;
}
return false;
}
}