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/actions/indexabl...
File: indexable-head-action.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Actions\Indexables;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Surfaces\Meta_Surface;
[4] Fix | Delete
use Yoast\WP\SEO\Surfaces\Values\Meta;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Get head action for indexables.
[8] Fix | Delete
*/
[9] Fix | Delete
class Indexable_Head_Action {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Caches the output.
[13] Fix | Delete
*
[14] Fix | Delete
* @var mixed
[15] Fix | Delete
*/
[16] Fix | Delete
protected $cache;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The meta surface.
[20] Fix | Delete
*
[21] Fix | Delete
* @var Meta_Surface
[22] Fix | Delete
*/
[23] Fix | Delete
private $meta_surface;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Indexable_Head_Action constructor.
[27] Fix | Delete
*
[28] Fix | Delete
* @param Meta_Surface $meta_surface The meta surface.
[29] Fix | Delete
*/
[30] Fix | Delete
public function __construct( Meta_Surface $meta_surface ) {
[31] Fix | Delete
$this->meta_surface = $meta_surface;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Retrieves the head for a url.
[36] Fix | Delete
*
[37] Fix | Delete
* @param string $url The url to get the head for.
[38] Fix | Delete
*
[39] Fix | Delete
* @return object Object with head and status properties.
[40] Fix | Delete
*/
[41] Fix | Delete
public function for_url( $url ) {
[42] Fix | Delete
if ( $url === \trailingslashit( \get_home_url() ) ) {
[43] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'home_page' ) );
[44] Fix | Delete
}
[45] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'url', $url ) );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Retrieves the head for a post.
[50] Fix | Delete
*
[51] Fix | Delete
* @param int $id The id.
[52] Fix | Delete
*
[53] Fix | Delete
* @return object Object with head and status properties.
[54] Fix | Delete
*/
[55] Fix | Delete
public function for_post( $id ) {
[56] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'post', $id ) );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Retrieves the head for a term.
[61] Fix | Delete
*
[62] Fix | Delete
* @param int $id The id.
[63] Fix | Delete
*
[64] Fix | Delete
* @return object Object with head and status properties.
[65] Fix | Delete
*/
[66] Fix | Delete
public function for_term( $id ) {
[67] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'term', $id ) );
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Retrieves the head for an author.
[72] Fix | Delete
*
[73] Fix | Delete
* @param int $id The id.
[74] Fix | Delete
*
[75] Fix | Delete
* @return object Object with head and status properties.
[76] Fix | Delete
*/
[77] Fix | Delete
public function for_author( $id ) {
[78] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'author', $id ) );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Retrieves the head for a post type archive.
[83] Fix | Delete
*
[84] Fix | Delete
* @param int $type The id.
[85] Fix | Delete
*
[86] Fix | Delete
* @return object Object with head and status properties.
[87] Fix | Delete
*/
[88] Fix | Delete
public function for_post_type_archive( $type ) {
[89] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'post_type_archive', $type ) );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Retrieves the head for the posts page.
[94] Fix | Delete
*
[95] Fix | Delete
* @return object Object with head and status properties.
[96] Fix | Delete
*/
[97] Fix | Delete
public function for_posts_page() {
[98] Fix | Delete
return $this->with_404_fallback( $this->with_cache( 'posts_page' ) );
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Retrieves the head for the 404 page. Always sets the status to 404.
[103] Fix | Delete
*
[104] Fix | Delete
* @return object Object with head and status properties.
[105] Fix | Delete
*/
[106] Fix | Delete
public function for_404() {
[107] Fix | Delete
$meta = $this->with_cache( '404' );
[108] Fix | Delete
[109] Fix | Delete
if ( ! $meta ) {
[110] Fix | Delete
return (object) [
[111] Fix | Delete
'html' => '',
[112] Fix | Delete
'json' => [],
[113] Fix | Delete
'status' => 404,
[114] Fix | Delete
];
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
$head = $meta->get_head();
[118] Fix | Delete
[119] Fix | Delete
return (object) [
[120] Fix | Delete
'html' => $head->html,
[121] Fix | Delete
'json' => $head->json,
[122] Fix | Delete
'status' => 404,
[123] Fix | Delete
];
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Retrieves the head for a successful page load.
[128] Fix | Delete
*
[129] Fix | Delete
* @param object $head The calculated Yoast head.
[130] Fix | Delete
*
[131] Fix | Delete
* @return object The presentations and status code 200.
[132] Fix | Delete
*/
[133] Fix | Delete
protected function for_200( $head ) {
[134] Fix | Delete
return (object) [
[135] Fix | Delete
'html' => $head->html,
[136] Fix | Delete
'json' => $head->json,
[137] Fix | Delete
'status' => 200,
[138] Fix | Delete
];
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* Returns the head with 404 fallback
[143] Fix | Delete
*
[144] Fix | Delete
* @param Meta|false $meta The meta object.
[145] Fix | Delete
*
[146] Fix | Delete
* @return object The head response.
[147] Fix | Delete
*/
[148] Fix | Delete
protected function with_404_fallback( $meta ) {
[149] Fix | Delete
if ( $meta === false ) {
[150] Fix | Delete
return $this->for_404();
[151] Fix | Delete
}
[152] Fix | Delete
else {
[153] Fix | Delete
return $this->for_200( $meta->get_head() );
[154] Fix | Delete
}
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Retrieves a value from the meta surface cached.
[159] Fix | Delete
*
[160] Fix | Delete
* @param string $type The type of value to retrieve.
[161] Fix | Delete
* @param string $argument Optional. The argument for the value.
[162] Fix | Delete
*
[163] Fix | Delete
* @return Meta The meta object.
[164] Fix | Delete
*/
[165] Fix | Delete
protected function with_cache( $type, $argument = '' ) {
[166] Fix | Delete
if ( ! isset( $this->cache[ $type ][ $argument ] ) ) {
[167] Fix | Delete
$this->cache[ $type ][ $argument ] = \call_user_func( [ $this->meta_surface, "for_$type" ], $argument );
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
return $this->cache[ $type ][ $argument ];
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function