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/integrat.../front-en...
File: crawl-cleanup-rss.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Front_End;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[5] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Adds actions that cleanup unwanted rss feed links.
[9] Fix | Delete
*/
[10] Fix | Delete
class Crawl_Cleanup_Rss implements Integration_Interface {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* The options helper.
[14] Fix | Delete
*
[15] Fix | Delete
* @var Options_Helper
[16] Fix | Delete
*/
[17] Fix | Delete
private $options_helper;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Crawl Cleanup RSS integration constructor.
[21] Fix | Delete
*
[22] Fix | Delete
* @param Options_Helper $options_helper The option helper.
[23] Fix | Delete
*/
[24] Fix | Delete
public function __construct( Options_Helper $options_helper ) {
[25] Fix | Delete
$this->options_helper = $options_helper;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Returns the conditionals based on which this loadable should be active.
[30] Fix | Delete
*
[31] Fix | Delete
* @return array The conditionals.
[32] Fix | Delete
*/
[33] Fix | Delete
public static function get_conditionals() {
[34] Fix | Delete
return [ Front_End_Conditional::class ];
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Register our RSS related hooks.
[39] Fix | Delete
*
[40] Fix | Delete
* @return void
[41] Fix | Delete
*/
[42] Fix | Delete
public function register_hooks() {
[43] Fix | Delete
if ( $this->is_true( 'remove_feed_global' ) ) {
[44] Fix | Delete
\add_action( 'feed_links_show_posts_feed', '__return_false' );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
if ( $this->is_true( 'remove_feed_global_comments' ) ) {
[48] Fix | Delete
\add_action( 'feed_links_show_comments_feed', '__return_false' );
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
\add_action( 'wp', [ $this, 'maybe_disable_feeds' ] );
[52] Fix | Delete
\add_action( 'wp', [ $this, 'maybe_redirect_feeds' ], -10000 );
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Disable feeds on selected cases.
[57] Fix | Delete
*
[58] Fix | Delete
* @return void
[59] Fix | Delete
*/
[60] Fix | Delete
public function maybe_disable_feeds() {
[61] Fix | Delete
if ( ( \is_singular() && $this->is_true( 'remove_feed_post_comments' ) )
[62] Fix | Delete
|| ( \is_author() && $this->is_true( 'remove_feed_authors' ) )
[63] Fix | Delete
|| ( \is_category() && $this->is_true( 'remove_feed_categories' ) )
[64] Fix | Delete
|| ( \is_tag() && $this->is_true( 'remove_feed_tags' ) )
[65] Fix | Delete
|| ( \is_tax() && $this->is_true( 'remove_feed_custom_taxonomies' ) )
[66] Fix | Delete
|| ( \is_post_type_archive() && $this->is_true( 'remove_feed_post_types' ) )
[67] Fix | Delete
|| ( \is_search() && $this->is_true( 'remove_feed_search' ) )
[68] Fix | Delete
) {
[69] Fix | Delete
\remove_action( 'wp_head', 'feed_links_extra', 3 );
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Redirect feeds we don't want away.
[75] Fix | Delete
*
[76] Fix | Delete
* @return void
[77] Fix | Delete
*/
[78] Fix | Delete
public function maybe_redirect_feeds() {
[79] Fix | Delete
global $wp_query;
[80] Fix | Delete
[81] Fix | Delete
if ( ! \is_feed() ) {
[82] Fix | Delete
return;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if ( \in_array( \get_query_var( 'feed' ), [ 'atom', 'rdf' ], true ) && $this->is_true( 'remove_atom_rdf_feeds' ) ) {
[86] Fix | Delete
$this->redirect_feed( \home_url(), 'We disable Atom/RDF feeds for performance reasons.' );
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
// Only if we're on the global feed, the query is _just_ `'feed' => 'feed'`, hence this check.
[90] Fix | Delete
if ( ( $wp_query->query === [ 'feed' => 'feed' ]
[91] Fix | Delete
|| $wp_query->query === [ 'feed' => 'atom' ]
[92] Fix | Delete
|| $wp_query->query === [ 'feed' => 'rdf' ] )
[93] Fix | Delete
&& $this->is_true( 'remove_feed_global' ) ) {
[94] Fix | Delete
$this->redirect_feed( \home_url(), 'We disable the RSS feed for performance reasons.' );
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
if ( \is_comment_feed() && ! ( \is_singular() || \is_attachment() ) && $this->is_true( 'remove_feed_global_comments' ) ) {
[98] Fix | Delete
$this->redirect_feed( \home_url(), 'We disable comment feeds for performance reasons.' );
[99] Fix | Delete
}
[100] Fix | Delete
elseif ( \is_comment_feed()
[101] Fix | Delete
&& \is_singular()
[102] Fix | Delete
&& ( $this->is_true( 'remove_feed_post_comments' ) || $this->is_true( 'remove_feed_global_comments' ) ) ) {
[103] Fix | Delete
$url = \get_permalink( \get_queried_object() );
[104] Fix | Delete
$this->redirect_feed( $url, 'We disable post comment feeds for performance reasons.' );
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
if ( \is_author() && $this->is_true( 'remove_feed_authors' ) ) {
[108] Fix | Delete
$author_id = (int) \get_query_var( 'author' );
[109] Fix | Delete
$url = \get_author_posts_url( $author_id );
[110] Fix | Delete
$this->redirect_feed( $url, 'We disable author feeds for performance reasons.' );
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
if ( ( \is_category() && $this->is_true( 'remove_feed_categories' ) )
[114] Fix | Delete
|| ( \is_tag() && $this->is_true( 'remove_feed_tags' ) )
[115] Fix | Delete
|| ( \is_tax() && $this->is_true( 'remove_feed_custom_taxonomies' ) ) ) {
[116] Fix | Delete
$term = \get_queried_object();
[117] Fix | Delete
$url = \get_term_link( $term, $term->taxonomy );
[118] Fix | Delete
if ( \is_wp_error( $url ) ) {
[119] Fix | Delete
$url = \home_url();
[120] Fix | Delete
}
[121] Fix | Delete
$this->redirect_feed( $url, 'We disable taxonomy feeds for performance reasons.' );
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
if ( ( \is_post_type_archive() ) && $this->is_true( 'remove_feed_post_types' ) ) {
[125] Fix | Delete
$url = \get_post_type_archive_link( $this->get_queried_post_type() );
[126] Fix | Delete
$this->redirect_feed( $url, 'We disable post type feeds for performance reasons.' );
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
if ( \is_search() && $this->is_true( 'remove_feed_search' ) ) {
[130] Fix | Delete
$url = \trailingslashit( \home_url() ) . '?s=' . \get_search_query();
[131] Fix | Delete
$this->redirect_feed( $url, 'We disable search RSS feeds for performance reasons.' );
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* Sends a cache control header.
[137] Fix | Delete
*
[138] Fix | Delete
* @param int $expiration The expiration time.
[139] Fix | Delete
*
[140] Fix | Delete
* @return void
[141] Fix | Delete
*/
[142] Fix | Delete
public function cache_control_header( $expiration ) {
[143] Fix | Delete
\header_remove( 'Expires' );
[144] Fix | Delete
[145] Fix | Delete
// The cacheability of the current request. 'public' allows caching, 'private' would not allow caching by proxies like CloudFlare.
[146] Fix | Delete
$cacheability = 'public';
[147] Fix | Delete
$format = '%1$s, max-age=%2$d, s-maxage=%2$d, stale-while-revalidate=120, stale-if-error=14400';
[148] Fix | Delete
[149] Fix | Delete
if ( \is_user_logged_in() ) {
[150] Fix | Delete
$expiration = 0;
[151] Fix | Delete
$cacheability = 'private';
[152] Fix | Delete
$format = '%1$s, max-age=%2$d';
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
\header( \sprintf( 'Cache-Control: ' . $format, $cacheability, $expiration ), true );
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Redirect a feed result to somewhere else.
[160] Fix | Delete
*
[161] Fix | Delete
* @param string $url The location we're redirecting to.
[162] Fix | Delete
* @param string $reason The reason we're redirecting.
[163] Fix | Delete
*
[164] Fix | Delete
* @return void
[165] Fix | Delete
*/
[166] Fix | Delete
private function redirect_feed( $url, $reason ) {
[167] Fix | Delete
\header_remove( 'Content-Type' );
[168] Fix | Delete
\header_remove( 'Last-Modified' );
[169] Fix | Delete
[170] Fix | Delete
$this->cache_control_header( 7 * \DAY_IN_SECONDS );
[171] Fix | Delete
[172] Fix | Delete
\wp_safe_redirect( $url, 301, 'Yoast SEO: ' . $reason );
[173] Fix | Delete
exit;
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Retrieves the queried post type.
[178] Fix | Delete
*
[179] Fix | Delete
* @return string The queried post type.
[180] Fix | Delete
*/
[181] Fix | Delete
private function get_queried_post_type() {
[182] Fix | Delete
$post_type = \get_query_var( 'post_type' );
[183] Fix | Delete
if ( \is_array( $post_type ) ) {
[184] Fix | Delete
$post_type = \reset( $post_type );
[185] Fix | Delete
}
[186] Fix | Delete
return $post_type;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
/**
[190] Fix | Delete
* Checks if the value of an option is set to true.
[191] Fix | Delete
*
[192] Fix | Delete
* @param string $option_name The option name.
[193] Fix | Delete
*
[194] Fix | Delete
* @return bool
[195] Fix | Delete
*/
[196] Fix | Delete
private function is_true( $option_name ) {
[197] Fix | Delete
return $this->options_helper->get( $option_name ) === true;
[198] Fix | Delete
}
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function