Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../src/helpers
File: robots-txt-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Values\Robots\User_Agent_List;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* A helper object for the robots txt file.
[7] Fix | Delete
*/
[8] Fix | Delete
class Robots_Txt_Helper {
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Holds a list of user agents with directives.
[12] Fix | Delete
*
[13] Fix | Delete
* @var User_Agent_List
[14] Fix | Delete
*/
[15] Fix | Delete
protected $robots_txt_user_agents;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Holds an array with absolute URLs of sitemaps.
[19] Fix | Delete
*
[20] Fix | Delete
* @var array
[21] Fix | Delete
*/
[22] Fix | Delete
protected $robots_txt_sitemaps;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Constructor for Robots_Txt_Helper.
[26] Fix | Delete
*/
[27] Fix | Delete
public function __construct() {
[28] Fix | Delete
$this->robots_txt_user_agents = new User_Agent_List();
[29] Fix | Delete
$this->robots_txt_sitemaps = [];
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Add a disallow rule for a specific user agent if it does not exist yet.
[34] Fix | Delete
*
[35] Fix | Delete
* @param string $user_agent The user agent to add the disallow rule to.
[36] Fix | Delete
* @param string $path The path to add as a disallow rule.
[37] Fix | Delete
*
[38] Fix | Delete
* @return void
[39] Fix | Delete
*/
[40] Fix | Delete
public function add_disallow( $user_agent, $path ) {
[41] Fix | Delete
$user_agent_container = $this->robots_txt_user_agents->get_user_agent( $user_agent );
[42] Fix | Delete
$user_agent_container->add_disallow_directive( $path );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Add an allow rule for a specific user agent if it does not exist yet.
[47] Fix | Delete
*
[48] Fix | Delete
* @param string $user_agent The user agent to add the allow rule to.
[49] Fix | Delete
* @param string $path The path to add as a allow rule.
[50] Fix | Delete
*
[51] Fix | Delete
* @return void
[52] Fix | Delete
*/
[53] Fix | Delete
public function add_allow( $user_agent, $path ) {
[54] Fix | Delete
$user_agent_container = $this->robots_txt_user_agents->get_user_agent( $user_agent );
[55] Fix | Delete
$user_agent_container->add_allow_directive( $path );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Add sitemap to robots.txt if it does not exist yet.
[60] Fix | Delete
*
[61] Fix | Delete
* @param string $absolute_path The absolute path to the sitemap to add.
[62] Fix | Delete
*
[63] Fix | Delete
* @return void
[64] Fix | Delete
*/
[65] Fix | Delete
public function add_sitemap( $absolute_path ) {
[66] Fix | Delete
if ( ! \in_array( $absolute_path, $this->robots_txt_sitemaps, true ) ) {
[67] Fix | Delete
$this->robots_txt_sitemaps[] = $absolute_path;
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Get all registered disallow directives per user agent.
[73] Fix | Delete
*
[74] Fix | Delete
* @return array The registered disallow directives per user agent.
[75] Fix | Delete
*/
[76] Fix | Delete
public function get_disallow_directives() {
[77] Fix | Delete
return $this->robots_txt_user_agents->get_disallow_directives();
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Get all registered allow directives per user agent.
[82] Fix | Delete
*
[83] Fix | Delete
* @return array The registered allow directives per user agent.
[84] Fix | Delete
*/
[85] Fix | Delete
public function get_allow_directives() {
[86] Fix | Delete
return $this->robots_txt_user_agents->get_allow_directives();
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Get all registered sitemap rules.
[91] Fix | Delete
*
[92] Fix | Delete
* @return array The registered sitemap rules.
[93] Fix | Delete
*/
[94] Fix | Delete
public function get_sitemap_rules() {
[95] Fix | Delete
return $this->robots_txt_sitemaps;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Get all registered user agents
[100] Fix | Delete
*
[101] Fix | Delete
* @return array The registered user agents.
[102] Fix | Delete
*/
[103] Fix | Delete
public function get_robots_txt_user_agents() {
[104] Fix | Delete
return $this->robots_txt_user_agents->get_user_agents();
[105] Fix | Delete
}
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function