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.../public_h.../wp-conte.../plugins/wordpres.../src/surfaces/values
File: meta.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Surfaces\Values;
[2] Fix | Delete
[3] Fix | Delete
use WPSEO_Replace_Vars;
[4] Fix | Delete
use Yoast\WP\SEO\Context\Meta_Tags_Context;
[5] Fix | Delete
use Yoast\WP\SEO\Exceptions\Forbidden_Property_Mutation_Exception;
[6] Fix | Delete
use Yoast\WP\SEO\Integrations\Front_End_Integration;
[7] Fix | Delete
use Yoast\WP\SEO\Models\Indexable;
[8] Fix | Delete
use Yoast\WP\SEO\Presenters\Abstract_Indexable_Presenter;
[9] Fix | Delete
use Yoast\WP\SEO\Presenters\Rel_Next_Presenter;
[10] Fix | Delete
use Yoast\WP\SEO\Presenters\Rel_Prev_Presenter;
[11] Fix | Delete
use Yoast\WP\SEO\Surfaces\Helpers_Surface;
[12] Fix | Delete
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ContainerInterface;
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Meta value object.
[16] Fix | Delete
*
[17] Fix | Delete
* @property array $breadcrumbs The breadcrumbs array for the current page.
[18] Fix | Delete
* @property string $canonical The canonical URL for the current page.
[19] Fix | Delete
* @property string $company_name The company name from the Knowledge graph settings.
[20] Fix | Delete
* @property int $company_logo_id The attachment ID for the company logo.
[21] Fix | Delete
* @property string $description The meta description for the current page, if set.
[22] Fix | Delete
* @property int $estimated_reading_time_minutes The estimated reading time in minutes for posts.
[23] Fix | Delete
* @property Indexable $indexable The indexable object.
[24] Fix | Delete
* @property string $main_schema_id Schema ID that points to the main Schema thing on the page, usually the webpage or article Schema piece.
[25] Fix | Delete
* @property string $meta_description The meta description for the current page, if set.
[26] Fix | Delete
* @property string $open_graph_article_author The article:author value.
[27] Fix | Delete
* @property string $open_graph_article_modified_time The article:modified_time value.
[28] Fix | Delete
* @property string $open_graph_article_published_time The article:published_time value.
[29] Fix | Delete
* @property string $open_graph_article_publisher The article:publisher value.
[30] Fix | Delete
* @property string $open_graph_description The og:description.
[31] Fix | Delete
* @property bool $open_graph_enabled Whether OpenGraph is enabled on this site.
[32] Fix | Delete
* @property string $open_graph_fb_app_id The Facebook App ID.
[33] Fix | Delete
* @property array $open_graph_images The array of images we have for this page.
[34] Fix | Delete
* @property string $open_graph_locale The og:locale for the current page.
[35] Fix | Delete
* @property string $open_graph_publisher The OpenGraph publisher reference.
[36] Fix | Delete
* @property string $open_graph_site_name The og:site_name.
[37] Fix | Delete
* @property string $open_graph_title The og:title.
[38] Fix | Delete
* @property string $open_graph_type The og:type.
[39] Fix | Delete
* @property string $open_graph_url The og:url.
[40] Fix | Delete
* @property string $page_type The Schema page type.
[41] Fix | Delete
* @property array $robots An array of the robots values set for the current page.
[42] Fix | Delete
* @property string $rel_next The next page in the series, if any.
[43] Fix | Delete
* @property string $rel_prev The previous page in the series, if any.
[44] Fix | Delete
* @property array $schema The entire Schema array for the current page.
[45] Fix | Delete
* @property string $schema_page_type The Schema page type.
[46] Fix | Delete
* @property string $site_name The site name from the Yoast SEO settings.
[47] Fix | Delete
* @property string $site_represents Whether the site represents a 'person' or a 'company'.
[48] Fix | Delete
* @property array|false $site_represents_reference The schema reference ID for what this site represents.
[49] Fix | Delete
* @property string $site_url The site's main URL.
[50] Fix | Delete
* @property int $site_user_id If the site represents a 'person', this is the ID of the accompanying user profile.
[51] Fix | Delete
* @property string $title The SEO title for the current page.
[52] Fix | Delete
* @property string $twitter_card The Twitter card type for the current page.
[53] Fix | Delete
* @property string $twitter_creator The Twitter card author for the current page.
[54] Fix | Delete
* @property string $twitter_description The Twitter card description for the current page.
[55] Fix | Delete
* @property string $twitter_image The Twitter card image for the current page.
[56] Fix | Delete
* @property string $twitter_site The Twitter card site reference for the current page.
[57] Fix | Delete
* @property string $twitter_title The Twitter card title for the current page.
[58] Fix | Delete
* @property string $wordpress_site_name The site name from the WordPress settings.
[59] Fix | Delete
*/
[60] Fix | Delete
class Meta {
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* The container.
[64] Fix | Delete
*
[65] Fix | Delete
* @var ContainerInterface
[66] Fix | Delete
*/
[67] Fix | Delete
protected $container;
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* The meta tags context.
[71] Fix | Delete
*
[72] Fix | Delete
* @var Meta_Tags_Context
[73] Fix | Delete
*/
[74] Fix | Delete
protected $context;
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* The front end integration.
[78] Fix | Delete
*
[79] Fix | Delete
* @var Front_End_Integration
[80] Fix | Delete
*/
[81] Fix | Delete
protected $front_end;
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* The helpers surface.
[85] Fix | Delete
*
[86] Fix | Delete
* @var Helpers_Surface
[87] Fix | Delete
*/
[88] Fix | Delete
protected $helpers;
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* The replace vars helper
[92] Fix | Delete
*
[93] Fix | Delete
* @var WPSEO_Replace_Vars
[94] Fix | Delete
*/
[95] Fix | Delete
protected $replace_vars;
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* Collection of properties dynamically set via the magic __get() method.
[99] Fix | Delete
*
[100] Fix | Delete
* @var array<string, mixed> Key is the property name.
[101] Fix | Delete
*/
[102] Fix | Delete
private $properties_bin = [];
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Create a meta value object.
[106] Fix | Delete
*
[107] Fix | Delete
* @param Meta_Tags_Context $context The indexable presentation.
[108] Fix | Delete
* @param ContainerInterface $container The DI container.
[109] Fix | Delete
*/
[110] Fix | Delete
public function __construct(
[111] Fix | Delete
Meta_Tags_Context $context,
[112] Fix | Delete
ContainerInterface $container
[113] Fix | Delete
) {
[114] Fix | Delete
$this->container = $container;
[115] Fix | Delete
$this->context = $context;
[116] Fix | Delete
[117] Fix | Delete
$this->helpers = $this->container->get( Helpers_Surface::class );
[118] Fix | Delete
$this->replace_vars = $this->container->get( WPSEO_Replace_Vars::class );
[119] Fix | Delete
$this->front_end = $this->container->get( Front_End_Integration::class );
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Returns the output as would be presented in the head.
[124] Fix | Delete
*
[125] Fix | Delete
* @return object The HTML and JSON presentation of the head metadata.
[126] Fix | Delete
*/
[127] Fix | Delete
public function get_head() {
[128] Fix | Delete
$presenters = $this->get_presenters();
[129] Fix | Delete
[130] Fix | Delete
/** This filter is documented in src/integrations/front-end-integration.php */
[131] Fix | Delete
$presentation = \apply_filters( 'wpseo_frontend_presentation', $this->context->presentation, $this->context );
[132] Fix | Delete
[133] Fix | Delete
$html_output = '';
[134] Fix | Delete
$json_head_fields = [];
[135] Fix | Delete
[136] Fix | Delete
foreach ( $presenters as $presenter ) {
[137] Fix | Delete
$presenter->presentation = $presentation;
[138] Fix | Delete
$presenter->replace_vars = $this->replace_vars;
[139] Fix | Delete
$presenter->helpers = $this->helpers;
[140] Fix | Delete
[141] Fix | Delete
$html_output .= $this->create_html_presentation( $presenter );
[142] Fix | Delete
$json_field = $this->create_json_field( $presenter );
[143] Fix | Delete
[144] Fix | Delete
// Only use the output of presenters that could successfully present their data.
[145] Fix | Delete
if ( $json_field !== null && ! empty( $json_field->key ) ) {
[146] Fix | Delete
$json_head_fields[ $json_field->key ] = $json_field->value;
[147] Fix | Delete
}
[148] Fix | Delete
}
[149] Fix | Delete
$html_output = \trim( $html_output );
[150] Fix | Delete
[151] Fix | Delete
return (object) [
[152] Fix | Delete
'html' => $html_output,
[153] Fix | Delete
'json' => $json_head_fields,
[154] Fix | Delete
];
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Magic getter for presenting values through the appropriate presenter, if it exists.
[159] Fix | Delete
*
[160] Fix | Delete
* @param string $name The property to get.
[161] Fix | Delete
*
[162] Fix | Delete
* @return mixed The value, as presented by the appropriate presenter.
[163] Fix | Delete
*/
[164] Fix | Delete
public function __get( $name ) {
[165] Fix | Delete
if ( \array_key_exists( $name, $this->properties_bin ) ) {
[166] Fix | Delete
return $this->properties_bin[ $name ];
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
/** This filter is documented in src/integrations/front-end-integration.php */
[170] Fix | Delete
$presentation = \apply_filters( 'wpseo_frontend_presentation', $this->context->presentation, $this->context );
[171] Fix | Delete
[172] Fix | Delete
if ( ! isset( $presentation->{$name} ) ) {
[173] Fix | Delete
if ( isset( $this->context->{$name} ) ) {
[174] Fix | Delete
$this->properties_bin[ $name ] = $this->context->{$name};
[175] Fix | Delete
return $this->properties_bin[ $name ];
[176] Fix | Delete
}
[177] Fix | Delete
return null;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
$presenter_namespace = 'Yoast\WP\SEO\Presenters\\';
[181] Fix | Delete
$parts = \explode( '_', $name );
[182] Fix | Delete
if ( $parts[0] === 'twitter' ) {
[183] Fix | Delete
$presenter_namespace .= 'Twitter\\';
[184] Fix | Delete
$parts = \array_slice( $parts, 1 );
[185] Fix | Delete
}
[186] Fix | Delete
elseif ( $parts[0] === 'open' && $parts[1] === 'graph' ) {
[187] Fix | Delete
$presenter_namespace .= 'Open_Graph\\';
[188] Fix | Delete
$parts = \array_slice( $parts, 2 );
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
$presenter_class = $presenter_namespace . \implode( '_', \array_map( 'ucfirst', $parts ) ) . '_Presenter';
[192] Fix | Delete
[193] Fix | Delete
if ( \class_exists( $presenter_class ) ) {
[194] Fix | Delete
/**
[195] Fix | Delete
* The indexable presenter.
[196] Fix | Delete
*
[197] Fix | Delete
* @var Abstract_Indexable_Presenter
[198] Fix | Delete
*/
[199] Fix | Delete
$presenter = new $presenter_class();
[200] Fix | Delete
$presenter->presentation = $presentation;
[201] Fix | Delete
$presenter->helpers = $this->helpers;
[202] Fix | Delete
$presenter->replace_vars = $this->replace_vars;
[203] Fix | Delete
$value = $presenter->get();
[204] Fix | Delete
}
[205] Fix | Delete
else {
[206] Fix | Delete
$value = $presentation->{$name};
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
$this->properties_bin[ $name ] = $value;
[210] Fix | Delete
return $this->properties_bin[ $name ];
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* Magic isset for ensuring properties on the presentation are recognised.
[215] Fix | Delete
*
[216] Fix | Delete
* @param string $name The property to get.
[217] Fix | Delete
*
[218] Fix | Delete
* @return bool Whether or not the requested property exists.
[219] Fix | Delete
*/
[220] Fix | Delete
public function __isset( $name ) {
[221] Fix | Delete
if ( \array_key_exists( $name, $this->properties_bin ) ) {
[222] Fix | Delete
return true;
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
return isset( $this->context->presentation->{$name} );
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
/**
[229] Fix | Delete
* Prevents setting dynamic properties and overwriting the value of declared properties
[230] Fix | Delete
* from an inaccessible context.
[231] Fix | Delete
*
[232] Fix | Delete
* @param string $name The property name.
[233] Fix | Delete
* @param mixed $value The property value.
[234] Fix | Delete
*
[235] Fix | Delete
* @return void
[236] Fix | Delete
*
[237] Fix | Delete
* @throws Forbidden_Property_Mutation_Exception Set is never meant to be called.
[238] Fix | Delete
*/
[239] Fix | Delete
public function __set( $name, $value ) { // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- __set must have a name and value - PHPCS #3715.
[240] Fix | Delete
throw Forbidden_Property_Mutation_Exception::cannot_set_because_property_is_immutable( $name );
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
/**
[244] Fix | Delete
* Prevents unsetting dynamic properties and unsetting declared properties
[245] Fix | Delete
* from an inaccessible context.
[246] Fix | Delete
*
[247] Fix | Delete
* @param string $name The property name.
[248] Fix | Delete
*
[249] Fix | Delete
* @return void
[250] Fix | Delete
*
[251] Fix | Delete
* @throws Forbidden_Property_Mutation_Exception Unset is never meant to be called.
[252] Fix | Delete
*/
[253] Fix | Delete
public function __unset( $name ) {
[254] Fix | Delete
throw Forbidden_Property_Mutation_Exception::cannot_unset_because_property_is_immutable( $name );
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
/**
[258] Fix | Delete
* Strips all nested dependencies from the debug info.
[259] Fix | Delete
*
[260] Fix | Delete
* @return array
[261] Fix | Delete
*/
[262] Fix | Delete
public function __debugInfo() {
[263] Fix | Delete
return [ 'context' => $this->context ];
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
/**
[267] Fix | Delete
* Returns all presenters.
[268] Fix | Delete
*
[269] Fix | Delete
* @return Abstract_Indexable_Presenter[]
[270] Fix | Delete
*/
[271] Fix | Delete
protected function get_presenters() {
[272] Fix | Delete
$presenters = $this->front_end->get_presenters( $this->context->page_type, $this->context );
[273] Fix | Delete
[274] Fix | Delete
if ( $this->context->page_type === 'Date_Archive' ) {
[275] Fix | Delete
/**
[276] Fix | Delete
* Define a filter that removes objects of type Rel_Next_Presenter or Rel_Prev_Presenter from a list.
[277] Fix | Delete
*
[278] Fix | Delete
* @param object $presenter The presenter to verify.
[279] Fix | Delete
*
[280] Fix | Delete
* @return bool True if the presenter is not a Rel_Next or Rel_Prev presenter.
[281] Fix | Delete
*/
[282] Fix | Delete
$callback = static function ( $presenter ) {
[283] Fix | Delete
return ! \is_a( $presenter, Rel_Next_Presenter::class )
[284] Fix | Delete
&& ! \is_a( $presenter, Rel_Prev_Presenter::class );
[285] Fix | Delete
};
[286] Fix | Delete
$presenters = \array_filter( $presenters, $callback );
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
return $presenters;
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
/**
[293] Fix | Delete
* Uses the presenter to create a line of HTML.
[294] Fix | Delete
*
[295] Fix | Delete
* @param Abstract_Indexable_Presenter $presenter The presenter.
[296] Fix | Delete
*
[297] Fix | Delete
* @return string
[298] Fix | Delete
*/
[299] Fix | Delete
protected function create_html_presentation( $presenter ) {
[300] Fix | Delete
$presenter_output = $presenter->present();
[301] Fix | Delete
if ( ! empty( $presenter_output ) ) {
[302] Fix | Delete
return $presenter_output . \PHP_EOL;
[303] Fix | Delete
}
[304] Fix | Delete
return '';
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
/**
[308] Fix | Delete
* Converts a presenter's key and value to JSON.
[309] Fix | Delete
*
[310] Fix | Delete
* @param Abstract_Indexable_Presenter $presenter The presenter whose key and value are to be converted to JSON.
[311] Fix | Delete
*
[312] Fix | Delete
* @return object|null
[313] Fix | Delete
*/
[314] Fix | Delete
protected function create_json_field( $presenter ) {
[315] Fix | Delete
if ( $presenter->get_key() === 'NO KEY PROVIDED' ) {
[316] Fix | Delete
return null;
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
$value = $presenter->get();
[320] Fix | Delete
if ( empty( $value ) ) {
[321] Fix | Delete
return null;
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
return (object) [
[325] Fix | Delete
'key' => $presenter->escape_key(),
[326] Fix | Delete
'value' => $value,
[327] Fix | Delete
];
[328] Fix | Delete
}
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function