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/clone/wp-conte.../plugins/wordpres.../src/helpers
File: indexable-to-postmeta-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Models\Indexable;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* A helper object to map indexable data to postmeta.
[7] Fix | Delete
*/
[8] Fix | Delete
class Indexable_To_Postmeta_Helper {
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* The Meta helper.
[12] Fix | Delete
*
[13] Fix | Delete
* @var Meta_Helper
[14] Fix | Delete
*/
[15] Fix | Delete
public $meta;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* The map of yoast to post meta.
[19] Fix | Delete
*
[20] Fix | Delete
* @var array
[21] Fix | Delete
*/
[22] Fix | Delete
protected $yoast_to_postmeta = [
[23] Fix | Delete
'title' => [
[24] Fix | Delete
'post_meta_key' => 'title',
[25] Fix | Delete
'map_method' => 'simple_map',
[26] Fix | Delete
],
[27] Fix | Delete
'description' => [
[28] Fix | Delete
'post_meta_key' => 'metadesc',
[29] Fix | Delete
'map_method' => 'simple_map',
[30] Fix | Delete
],
[31] Fix | Delete
'open_graph_title' => [
[32] Fix | Delete
'post_meta_key' => 'opengraph-title',
[33] Fix | Delete
'map_method' => 'simple_map',
[34] Fix | Delete
],
[35] Fix | Delete
'open_graph_description' => [
[36] Fix | Delete
'post_meta_key' => 'opengraph-description',
[37] Fix | Delete
'map_method' => 'simple_map',
[38] Fix | Delete
],
[39] Fix | Delete
'twitter_title' => [
[40] Fix | Delete
'post_meta_key' => 'twitter-title',
[41] Fix | Delete
'map_method' => 'simple_map',
[42] Fix | Delete
],
[43] Fix | Delete
'twitter_description' => [
[44] Fix | Delete
'post_meta_key' => 'twitter-description',
[45] Fix | Delete
'map_method' => 'simple_map',
[46] Fix | Delete
],
[47] Fix | Delete
'canonical' => [
[48] Fix | Delete
'post_meta_key' => 'canonical',
[49] Fix | Delete
'map_method' => 'simple_map',
[50] Fix | Delete
],
[51] Fix | Delete
'primary_focus_keyword' => [
[52] Fix | Delete
'post_meta_key' => 'focuskw',
[53] Fix | Delete
'map_method' => 'simple_map',
[54] Fix | Delete
],
[55] Fix | Delete
'open_graph_image' => [
[56] Fix | Delete
'post_meta_key' => 'opengraph-image',
[57] Fix | Delete
'map_method' => 'social_image_map',
[58] Fix | Delete
],
[59] Fix | Delete
'open_graph_image_id' => [
[60] Fix | Delete
'post_meta_key' => 'opengraph-image-id',
[61] Fix | Delete
'map_method' => 'social_image_map',
[62] Fix | Delete
],
[63] Fix | Delete
'twitter_image' => [
[64] Fix | Delete
'post_meta_key' => 'twitter-image',
[65] Fix | Delete
'map_method' => 'social_image_map',
[66] Fix | Delete
],
[67] Fix | Delete
'twitter_image_id' => [
[68] Fix | Delete
'post_meta_key' => 'twitter-image-id',
[69] Fix | Delete
'map_method' => 'social_image_map',
[70] Fix | Delete
],
[71] Fix | Delete
'is_robots_noindex' => [
[72] Fix | Delete
'post_meta_key' => 'meta-robots-noindex',
[73] Fix | Delete
'map_method' => 'noindex_map',
[74] Fix | Delete
],
[75] Fix | Delete
'is_robots_nofollow' => [
[76] Fix | Delete
'post_meta_key' => 'meta-robots-nofollow',
[77] Fix | Delete
'map_method' => 'nofollow_map',
[78] Fix | Delete
],
[79] Fix | Delete
'meta_robots_adv' => [
[80] Fix | Delete
'post_meta_key' => 'meta-robots-adv',
[81] Fix | Delete
'map_method' => 'robots_adv_map',
[82] Fix | Delete
],
[83] Fix | Delete
];
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Indexable_To_Postmeta_Helper constructor.
[87] Fix | Delete
*
[88] Fix | Delete
* @param Meta_Helper $meta The Meta helper.
[89] Fix | Delete
*/
[90] Fix | Delete
public function __construct( Meta_Helper $meta ) {
[91] Fix | Delete
$this->meta = $meta;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Creates postmeta from a Yoast indexable.
[96] Fix | Delete
*
[97] Fix | Delete
* @param Indexable $indexable The Yoast indexable.
[98] Fix | Delete
*
[99] Fix | Delete
* @return void
[100] Fix | Delete
*/
[101] Fix | Delete
public function map_to_postmeta( $indexable ) {
[102] Fix | Delete
foreach ( $this->yoast_to_postmeta as $indexable_column => $map_info ) {
[103] Fix | Delete
\call_user_func( [ $this, $map_info['map_method'] ], $indexable, $map_info['post_meta_key'], $indexable_column );
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Uses a simple set_value for non-empty data.
[109] Fix | Delete
*
[110] Fix | Delete
* @param Indexable $indexable The Yoast indexable.
[111] Fix | Delete
* @param string $post_meta_key The post_meta key that will be populated.
[112] Fix | Delete
* @param string $indexable_column The indexable data that will be mapped to post_meta.
[113] Fix | Delete
*
[114] Fix | Delete
* @return void
[115] Fix | Delete
*/
[116] Fix | Delete
public function simple_map( $indexable, $post_meta_key, $indexable_column ) {
[117] Fix | Delete
if ( empty( $indexable->{$indexable_column} ) ) {
[118] Fix | Delete
return;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
$this->meta->set_value( $post_meta_key, $indexable->{$indexable_column}, $indexable->object_id );
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* Map social image data only if social image is explicitly set.
[126] Fix | Delete
*
[127] Fix | Delete
* @param Indexable $indexable The Yoast indexable.
[128] Fix | Delete
* @param string $post_meta_key The post_meta key that will be populated.
[129] Fix | Delete
* @param string $indexable_column The indexable data that will be mapped to post_meta.
[130] Fix | Delete
*
[131] Fix | Delete
* @return void
[132] Fix | Delete
*/
[133] Fix | Delete
public function social_image_map( $indexable, $post_meta_key, $indexable_column ) {
[134] Fix | Delete
if ( empty( $indexable->{$indexable_column} ) ) {
[135] Fix | Delete
return;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
switch ( $indexable_column ) {
[139] Fix | Delete
case 'open_graph_image':
[140] Fix | Delete
case 'open_graph_image_id':
[141] Fix | Delete
$source = $indexable->open_graph_image_source;
[142] Fix | Delete
break;
[143] Fix | Delete
case 'twitter_image':
[144] Fix | Delete
case 'twitter_image_id':
[145] Fix | Delete
$source = $indexable->twitter_image_source;
[146] Fix | Delete
break;
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
// Map the social image data only when the social image is explicitly set.
[150] Fix | Delete
if ( $source === 'set-by-user' || $source === 'imported' ) {
[151] Fix | Delete
$value = (string) $indexable->{$indexable_column};
[152] Fix | Delete
[153] Fix | Delete
$this->meta->set_value( $post_meta_key, $value, $indexable->object_id );
[154] Fix | Delete
}
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Deletes the noindex post_meta key if no noindex in the indexable. Populates the post_meta key appropriately if there is noindex in the indexable.
[159] Fix | Delete
*
[160] Fix | Delete
* @param Indexable $indexable The Yoast indexable.
[161] Fix | Delete
* @param string $post_meta_key The post_meta key that will be populated.
[162] Fix | Delete
*
[163] Fix | Delete
* @return void
[164] Fix | Delete
*/
[165] Fix | Delete
public function noindex_map( $indexable, $post_meta_key ) {
[166] Fix | Delete
if ( \is_null( $indexable->is_robots_noindex ) ) {
[167] Fix | Delete
$this->meta->delete( $post_meta_key, $indexable->object_id );
[168] Fix | Delete
return;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
if ( $indexable->is_robots_noindex === false ) {
[172] Fix | Delete
$this->meta->set_value( $post_meta_key, 2, $indexable->object_id );
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
if ( $indexable->is_robots_noindex === true ) {
[176] Fix | Delete
$this->meta->set_value( $post_meta_key, 1, $indexable->object_id );
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Deletes the nofollow post_meta key if no nofollow in the indexable or if nofollow is false. Populates the post_meta key appropriately if there is a true nofollow in the indexable.
[182] Fix | Delete
*
[183] Fix | Delete
* @param Indexable $indexable The Yoast indexable.
[184] Fix | Delete
* @param string $post_meta_key The post_meta key that will be populated.
[185] Fix | Delete
*
[186] Fix | Delete
* @return void
[187] Fix | Delete
*/
[188] Fix | Delete
public function nofollow_map( $indexable, $post_meta_key ) {
[189] Fix | Delete
if ( \is_null( $indexable->is_robots_nofollow ) || $indexable->is_robots_nofollow === false ) {
[190] Fix | Delete
$this->meta->delete( $post_meta_key, $indexable->object_id );
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
if ( $indexable->is_robots_nofollow === true ) {
[194] Fix | Delete
$this->meta->set_value( $post_meta_key, 1, $indexable->object_id );
[195] Fix | Delete
}
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Deletes the nofollow post_meta key if no nofollow in the indexable or if nofollow is false. Populates the post_meta key appropriately if there is a true nofollow in the indexable.
[200] Fix | Delete
*
[201] Fix | Delete
* @param Indexable $indexable The Yoast indexable.
[202] Fix | Delete
* @param string $post_meta_key The post_meta key that will be populated.
[203] Fix | Delete
*
[204] Fix | Delete
* @return void
[205] Fix | Delete
*/
[206] Fix | Delete
public function robots_adv_map( $indexable, $post_meta_key ) {
[207] Fix | Delete
$adv_settings_to_be_imported = [];
[208] Fix | Delete
$no_adv_settings = true;
[209] Fix | Delete
[210] Fix | Delete
if ( $indexable->is_robots_noimageindex === true ) {
[211] Fix | Delete
$adv_settings_to_be_imported[] = 'noimageindex';
[212] Fix | Delete
$no_adv_settings = false;
[213] Fix | Delete
}
[214] Fix | Delete
if ( $indexable->is_robots_noarchive === true ) {
[215] Fix | Delete
$adv_settings_to_be_imported[] = 'noarchive';
[216] Fix | Delete
$no_adv_settings = false;
[217] Fix | Delete
}
[218] Fix | Delete
if ( $indexable->is_robots_nosnippet === true ) {
[219] Fix | Delete
$adv_settings_to_be_imported[] = 'nosnippet';
[220] Fix | Delete
$no_adv_settings = false;
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
if ( $no_adv_settings === true ) {
[224] Fix | Delete
$this->meta->delete( $post_meta_key, $indexable->object_id );
[225] Fix | Delete
return;
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
$this->meta->set_value( $post_meta_key, \implode( ',', $adv_settings_to_be_imported ), $indexable->object_id );
[229] Fix | Delete
}
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function