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: open-graph-oembed.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Front_End;
[2] Fix | Delete
[3] Fix | Delete
use WP_Post;
[4] Fix | Delete
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
[5] Fix | Delete
use Yoast\WP\SEO\Conditionals\Open_Graph_Conditional;
[6] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[7] Fix | Delete
use Yoast\WP\SEO\Surfaces\Meta_Surface;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Class Open_Graph_OEmbed.
[11] Fix | Delete
*/
[12] Fix | Delete
class Open_Graph_OEmbed implements Integration_Interface {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* The meta surface.
[16] Fix | Delete
*
[17] Fix | Delete
* @var Meta_Surface
[18] Fix | Delete
*/
[19] Fix | Delete
private $meta;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* The oEmbed data.
[23] Fix | Delete
*
[24] Fix | Delete
* @var array
[25] Fix | Delete
*/
[26] Fix | Delete
private $data;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* The post ID for the current post.
[30] Fix | Delete
*
[31] Fix | Delete
* @var int
[32] Fix | Delete
*/
[33] Fix | Delete
private $post_id;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* The post meta.
[37] Fix | Delete
*
[38] Fix | Delete
* @var Meta|false
[39] Fix | Delete
*/
[40] Fix | Delete
private $post_meta;
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Returns the conditionals based in which this loadable should be active.
[44] Fix | Delete
*
[45] Fix | Delete
* @return array
[46] Fix | Delete
*/
[47] Fix | Delete
public static function get_conditionals() {
[48] Fix | Delete
return [ Front_End_Conditional::class, Open_Graph_Conditional::class ];
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Initializes the integration.
[53] Fix | Delete
*
[54] Fix | Delete
* This is the place to register hooks and filters.
[55] Fix | Delete
*
[56] Fix | Delete
* @return void
[57] Fix | Delete
*/
[58] Fix | Delete
public function register_hooks() {
[59] Fix | Delete
\add_filter( 'oembed_response_data', [ $this, 'set_oembed_data' ], 10, 2 );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Open_Graph_OEmbed constructor.
[64] Fix | Delete
*
[65] Fix | Delete
* @param Meta_Surface $meta The meta surface.
[66] Fix | Delete
*/
[67] Fix | Delete
public function __construct( Meta_Surface $meta ) {
[68] Fix | Delete
$this->meta = $meta;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Callback function to pass to the oEmbed's response data that will enable
[73] Fix | Delete
* support for using the image and title set by the WordPress SEO plugin's fields. This
[74] Fix | Delete
* address the concern where some social channels/subscribed use oEmebed data over Open Graph data
[75] Fix | Delete
* if both are present.
[76] Fix | Delete
*
[77] Fix | Delete
* @link https://developer.wordpress.org/reference/hooks/oembed_response_data/ for hook info.
[78] Fix | Delete
*
[79] Fix | Delete
* @param array $data The oEmbed data.
[80] Fix | Delete
* @param WP_Post $post The current Post object.
[81] Fix | Delete
*
[82] Fix | Delete
* @return array An array of oEmbed data with modified values where appropriate.
[83] Fix | Delete
*/
[84] Fix | Delete
public function set_oembed_data( $data, $post ) {
[85] Fix | Delete
// Data to be returned.
[86] Fix | Delete
$this->data = $data;
[87] Fix | Delete
$this->post_id = $post->ID;
[88] Fix | Delete
$this->post_meta = $this->meta->for_post( $this->post_id );
[89] Fix | Delete
[90] Fix | Delete
if ( ! empty( $this->post_meta ) ) {
[91] Fix | Delete
$this->set_title();
[92] Fix | Delete
$this->set_description();
[93] Fix | Delete
$this->set_image();
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
return $this->data;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Sets the OpenGraph title if configured.
[101] Fix | Delete
*
[102] Fix | Delete
* @return void
[103] Fix | Delete
*/
[104] Fix | Delete
protected function set_title() {
[105] Fix | Delete
$opengraph_title = $this->post_meta->open_graph_title;
[106] Fix | Delete
[107] Fix | Delete
if ( ! empty( $opengraph_title ) ) {
[108] Fix | Delete
$this->data['title'] = $opengraph_title;
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Sets the OpenGraph description if configured.
[114] Fix | Delete
*
[115] Fix | Delete
* @return void
[116] Fix | Delete
*/
[117] Fix | Delete
protected function set_description() {
[118] Fix | Delete
$opengraph_description = $this->post_meta->open_graph_description;
[119] Fix | Delete
[120] Fix | Delete
if ( ! empty( $opengraph_description ) ) {
[121] Fix | Delete
$this->data['description'] = $opengraph_description;
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Sets the image if it has been configured.
[127] Fix | Delete
*
[128] Fix | Delete
* @return void
[129] Fix | Delete
*/
[130] Fix | Delete
protected function set_image() {
[131] Fix | Delete
$images = $this->post_meta->open_graph_images;
[132] Fix | Delete
[133] Fix | Delete
if ( ! \is_array( $images ) ) {
[134] Fix | Delete
return;
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
$image = \reset( $images );
[138] Fix | Delete
[139] Fix | Delete
if ( empty( $image ) || ! isset( $image['url'] ) ) {
[140] Fix | Delete
return;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
$this->data['thumbnail_url'] = $image['url'];
[144] Fix | Delete
[145] Fix | Delete
if ( isset( $image['width'] ) ) {
[146] Fix | Delete
$this->data['thumbnail_width'] = $image['width'];
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
if ( isset( $image['height'] ) ) {
[150] Fix | Delete
$this->data['thumbnail_height'] = $image['height'];
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function