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/presenta...
File: indexable-term-archive-presentation.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Presentations;
[2] Fix | Delete
[3] Fix | Delete
use WP_Term;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\Taxonomy_Helper;
[5] Fix | Delete
use Yoast\WP\SEO\Wrappers\WP_Query_Wrapper;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Class Indexable_Term_Archive_Presentation.
[9] Fix | Delete
*
[10] Fix | Delete
* Presentation object for indexables.
[11] Fix | Delete
*
[12] Fix | Delete
* @property WP_Term $source
[13] Fix | Delete
*/
[14] Fix | Delete
class Indexable_Term_Archive_Presentation extends Indexable_Presentation {
[15] Fix | Delete
[16] Fix | Delete
use Archive_Adjacent;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Holds the WP query wrapper instance.
[20] Fix | Delete
*
[21] Fix | Delete
* @var WP_Query_Wrapper
[22] Fix | Delete
*/
[23] Fix | Delete
private $wp_query_wrapper;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Holds the taxonomy helper instance.
[27] Fix | Delete
*
[28] Fix | Delete
* @var Taxonomy_Helper
[29] Fix | Delete
*/
[30] Fix | Delete
private $taxonomy;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Indexable_Post_Type_Presentation constructor.
[34] Fix | Delete
*
[35] Fix | Delete
* @codeCoverageIgnore
[36] Fix | Delete
*
[37] Fix | Delete
* @param WP_Query_Wrapper $wp_query_wrapper The wp query wrapper.
[38] Fix | Delete
* @param Taxonomy_Helper $taxonomy The Taxonomy helper.
[39] Fix | Delete
*/
[40] Fix | Delete
public function __construct(
[41] Fix | Delete
WP_Query_Wrapper $wp_query_wrapper,
[42] Fix | Delete
Taxonomy_Helper $taxonomy
[43] Fix | Delete
) {
[44] Fix | Delete
$this->wp_query_wrapper = $wp_query_wrapper;
[45] Fix | Delete
$this->taxonomy = $taxonomy;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Generates the canonical.
[50] Fix | Delete
*
[51] Fix | Delete
* @return string The canonical.
[52] Fix | Delete
*/
[53] Fix | Delete
public function generate_canonical() {
[54] Fix | Delete
if ( $this->is_multiple_terms_query() ) {
[55] Fix | Delete
return '';
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
if ( $this->model->canonical ) {
[59] Fix | Delete
return $this->model->canonical;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
if ( ! $this->permalink ) {
[63] Fix | Delete
return '';
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$current_page = $this->pagination->get_current_archive_page_number();
[67] Fix | Delete
if ( $current_page > 1 ) {
[68] Fix | Delete
return $this->pagination->get_paginated_url( $this->permalink, $current_page );
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
return $this->permalink;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Generates the meta description.
[76] Fix | Delete
*
[77] Fix | Delete
* @return string The meta description.
[78] Fix | Delete
*/
[79] Fix | Delete
public function generate_meta_description() {
[80] Fix | Delete
if ( $this->model->description ) {
[81] Fix | Delete
return $this->model->description;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
return $this->options->get( 'metadesc-tax-' . $this->model->object_sub_type );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Generates the source.
[89] Fix | Delete
*
[90] Fix | Delete
* @return array The source.
[91] Fix | Delete
*/
[92] Fix | Delete
public function generate_source() {
[93] Fix | Delete
if ( ! empty( $this->model->object_id ) || \is_null( \get_queried_object() ) ) {
[94] Fix | Delete
return \get_term( $this->model->object_id, $this->model->object_sub_type );
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
return \get_term( \get_queried_object()->term_id, \get_queried_object()->taxonomy );
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Generates the Open Graph description.
[102] Fix | Delete
*
[103] Fix | Delete
* @return string The Open Graph description.
[104] Fix | Delete
*/
[105] Fix | Delete
public function generate_open_graph_description() {
[106] Fix | Delete
$open_graph_description = parent::generate_open_graph_description();
[107] Fix | Delete
if ( $open_graph_description ) {
[108] Fix | Delete
return $open_graph_description;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
return $this->taxonomy->get_term_description( $this->model->object_id );
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Generates the Twitter description.
[116] Fix | Delete
*
[117] Fix | Delete
* @return string The Twitter description.
[118] Fix | Delete
*/
[119] Fix | Delete
public function generate_twitter_description() {
[120] Fix | Delete
$twitter_description = parent::generate_twitter_description();
[121] Fix | Delete
if ( $twitter_description ) {
[122] Fix | Delete
return $twitter_description;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
if ( $this->open_graph_description && $this->context->open_graph_enabled === true ) {
[126] Fix | Delete
return '';
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
return $this->taxonomy->get_term_description( $this->model->object_id );
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Generates the robots value.
[134] Fix | Delete
*
[135] Fix | Delete
* @return array The robots value.
[136] Fix | Delete
*/
[137] Fix | Delete
public function generate_robots() {
[138] Fix | Delete
$robots = $this->get_base_robots();
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* If its a multiple terms archive page return a noindex.
[142] Fix | Delete
*/
[143] Fix | Delete
if ( $this->current_page->is_multiple_terms_page() ) {
[144] Fix | Delete
$robots['index'] = 'noindex';
[145] Fix | Delete
[146] Fix | Delete
return $this->filter_robots( $robots );
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* First we get the no index option for this taxonomy, because it can be overwritten the indexable value for
[151] Fix | Delete
* this specific term.
[152] Fix | Delete
*/
[153] Fix | Delete
if ( \is_wp_error( $this->source ) || ! $this->taxonomy->is_indexable( $this->source->taxonomy ) ) {
[154] Fix | Delete
$robots['index'] = 'noindex';
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Overwrite the index directive when there is a term specific directive set.
[159] Fix | Delete
*/
[160] Fix | Delete
if ( $this->model->is_robots_noindex !== null ) {
[161] Fix | Delete
$robots['index'] = ( $this->model->is_robots_noindex ) ? 'noindex' : 'index';
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
return $this->filter_robots( $robots );
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
/**
[168] Fix | Delete
* Generates the title.
[169] Fix | Delete
*
[170] Fix | Delete
* @return string The title.
[171] Fix | Delete
*/
[172] Fix | Delete
public function generate_title() {
[173] Fix | Delete
if ( $this->model->title ) {
[174] Fix | Delete
return $this->model->title;
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
if ( \is_wp_error( $this->source ) ) {
[178] Fix | Delete
return $this->model->title;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
// Get the SEO title as entered in Search Appearance.
[182] Fix | Delete
$title = $this->options->get( 'title-tax-' . $this->source->taxonomy );
[183] Fix | Delete
if ( $title ) {
[184] Fix | Delete
return $title;
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
// Get the installation default title.
[188] Fix | Delete
$title = $this->options->get_title_default( 'title-tax-' . $this->source->taxonomy );
[189] Fix | Delete
[190] Fix | Delete
return $title;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
/**
[194] Fix | Delete
* Generates the Open Graph type.
[195] Fix | Delete
*
[196] Fix | Delete
* @return string The Open Graph type.
[197] Fix | Delete
*/
[198] Fix | Delete
public function generate_open_graph_type() {
[199] Fix | Delete
return 'article';
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* Checks if term archive query is for multiple terms (/term-1,term-2/ or /term-1+term-2/).
[204] Fix | Delete
*
[205] Fix | Delete
* @return bool Whether the query contains multiple terms.
[206] Fix | Delete
*/
[207] Fix | Delete
protected function is_multiple_terms_query() {
[208] Fix | Delete
$query = $this->wp_query_wrapper->get_query();
[209] Fix | Delete
[210] Fix | Delete
if ( ! isset( $query->tax_query ) ) {
[211] Fix | Delete
return false;
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
if ( \is_wp_error( $this->source ) ) {
[215] Fix | Delete
return false;
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
$queried_terms = $query->tax_query->queried_terms;
[219] Fix | Delete
[220] Fix | Delete
if ( empty( $queried_terms[ $this->source->taxonomy ]['terms'] ) ) {
[221] Fix | Delete
return false;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
return \count( $queried_terms[ $this->source->taxonomy ]['terms'] ) > 1;
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function