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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../inc
File: class-wpseo-meta.php
[500] Fix | Delete
case ( $field_def['type'] === 'textarea' ):
[501] Fix | Delete
if ( is_string( $meta_value ) ) {
[502] Fix | Delete
// Remove line breaks and tabs.
[503] Fix | Delete
// @todo [JRF => Yoast] Verify that line breaks and the likes aren't allowed/recommended in meta header fields.
[504] Fix | Delete
$meta_value = str_replace( [ "\n", "\r", "\t", ' ' ], ' ', $meta_value );
[505] Fix | Delete
$clean = WPSEO_Utils::sanitize_text_field( trim( $meta_value ) );
[506] Fix | Delete
}
[507] Fix | Delete
break;
[508] Fix | Delete
[509] Fix | Delete
case ( $field_def['type'] === 'multiselect' ):
[510] Fix | Delete
$clean = $meta_value;
[511] Fix | Delete
break;
[512] Fix | Delete
[513] Fix | Delete
case ( $field_def['type'] === 'text' ):
[514] Fix | Delete
default:
[515] Fix | Delete
if ( is_string( $meta_value ) ) {
[516] Fix | Delete
$clean = WPSEO_Utils::sanitize_text_field( trim( $meta_value ) );
[517] Fix | Delete
}
[518] Fix | Delete
[519] Fix | Delete
break;
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
$clean = apply_filters( 'wpseo_sanitize_post_meta_' . $meta_key, $clean, $meta_value, $field_def, $meta_key );
[523] Fix | Delete
[524] Fix | Delete
return $clean;
[525] Fix | Delete
}
[526] Fix | Delete
[527] Fix | Delete
/**
[528] Fix | Delete
* Validate a meta-robots-adv meta value.
[529] Fix | Delete
*
[530] Fix | Delete
* @todo [JRF => Yoast] Verify that this logic for the prioritisation is correct.
[531] Fix | Delete
*
[532] Fix | Delete
* @param array|string $meta_value The value to validate.
[533] Fix | Delete
*
[534] Fix | Delete
* @return string Clean value.
[535] Fix | Delete
*/
[536] Fix | Delete
public static function validate_meta_robots_adv( $meta_value ) {
[537] Fix | Delete
$clean = self::$meta_fields['advanced']['meta-robots-adv']['default_value'];
[538] Fix | Delete
$options = self::$meta_fields['advanced']['meta-robots-adv']['options'];
[539] Fix | Delete
[540] Fix | Delete
if ( is_string( $meta_value ) ) {
[541] Fix | Delete
$meta_value = explode( ',', $meta_value );
[542] Fix | Delete
}
[543] Fix | Delete
[544] Fix | Delete
if ( is_array( $meta_value ) && $meta_value !== [] ) {
[545] Fix | Delete
$meta_value = array_map( 'trim', $meta_value );
[546] Fix | Delete
[547] Fix | Delete
// Individual selected entries.
[548] Fix | Delete
$cleaning = [];
[549] Fix | Delete
foreach ( $meta_value as $value ) {
[550] Fix | Delete
if ( isset( $options[ $value ] ) ) {
[551] Fix | Delete
$cleaning[] = $value;
[552] Fix | Delete
}
[553] Fix | Delete
}
[554] Fix | Delete
[555] Fix | Delete
if ( $cleaning !== [] ) {
[556] Fix | Delete
$clean = implode( ',', $cleaning );
[557] Fix | Delete
}
[558] Fix | Delete
unset( $cleaning, $value );
[559] Fix | Delete
}
[560] Fix | Delete
[561] Fix | Delete
return $clean;
[562] Fix | Delete
}
[563] Fix | Delete
[564] Fix | Delete
/**
[565] Fix | Delete
* Prevent saving of default values and remove potential old value from the database if replaced by a default.
[566] Fix | Delete
*
[567] Fix | Delete
* @param bool $check The current status to allow updating metadata for the given type.
[568] Fix | Delete
* @param int $object_id ID of the current object for which the meta is being updated.
[569] Fix | Delete
* @param string $meta_key The full meta key (including prefix).
[570] Fix | Delete
* @param string $meta_value New meta value.
[571] Fix | Delete
* @param string $prev_value The old meta value.
[572] Fix | Delete
*
[573] Fix | Delete
* @return bool|null True = stop saving, null = continue saving.
[574] Fix | Delete
*/
[575] Fix | Delete
public static function remove_meta_if_default( $check, $object_id, $meta_key, $meta_value, $prev_value = '' ) {
[576] Fix | Delete
/* If it's one of our meta fields, check against default. */
[577] Fix | Delete
if ( isset( self::$fields_index[ $meta_key ] ) && self::meta_value_is_default( $meta_key, $meta_value ) === true ) {
[578] Fix | Delete
if ( $prev_value !== '' ) {
[579] Fix | Delete
delete_post_meta( $object_id, $meta_key, $prev_value );
[580] Fix | Delete
}
[581] Fix | Delete
else {
[582] Fix | Delete
delete_post_meta( $object_id, $meta_key );
[583] Fix | Delete
}
[584] Fix | Delete
[585] Fix | Delete
return true; // Stop saving the value.
[586] Fix | Delete
}
[587] Fix | Delete
[588] Fix | Delete
return $check; // Go on with the normal execution (update) in meta.php.
[589] Fix | Delete
}
[590] Fix | Delete
[591] Fix | Delete
/**
[592] Fix | Delete
* Prevent adding of default values to the database.
[593] Fix | Delete
*
[594] Fix | Delete
* @param bool $check The current status to allow adding metadata for the given type.
[595] Fix | Delete
* @param int $object_id ID of the current object for which the meta is being added.
[596] Fix | Delete
* @param string $meta_key The full meta key (including prefix).
[597] Fix | Delete
* @param string $meta_value New meta value.
[598] Fix | Delete
*
[599] Fix | Delete
* @return bool|null True = stop saving, null = continue saving.
[600] Fix | Delete
*/
[601] Fix | Delete
public static function dont_save_meta_if_default( $check, $object_id, $meta_key, $meta_value ) {
[602] Fix | Delete
/* If it's one of our meta fields, check against default. */
[603] Fix | Delete
if ( isset( self::$fields_index[ $meta_key ] ) && self::meta_value_is_default( $meta_key, $meta_value ) === true ) {
[604] Fix | Delete
return true; // Stop saving the value.
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
return $check; // Go on with the normal execution (add) in meta.php.
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
/**
[611] Fix | Delete
* Is the given meta value the same as the default value ?
[612] Fix | Delete
*
[613] Fix | Delete
* @param string $meta_key The full meta key (including prefix).
[614] Fix | Delete
* @param mixed $meta_value The value to check.
[615] Fix | Delete
*
[616] Fix | Delete
* @return bool
[617] Fix | Delete
*/
[618] Fix | Delete
public static function meta_value_is_default( $meta_key, $meta_value ) {
[619] Fix | Delete
return ( isset( self::$defaults[ $meta_key ] ) && $meta_value === self::$defaults[ $meta_key ] );
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
/**
[623] Fix | Delete
* Get a custom post meta value.
[624] Fix | Delete
*
[625] Fix | Delete
* Returns the default value if the meta value has not been set.
[626] Fix | Delete
*
[627] Fix | Delete
* {@internal Unfortunately there isn't a filter available to hook into before returning
[628] Fix | Delete
* the results for get_post_meta(), get_post_custom() and the likes. That
[629] Fix | Delete
* would have been the preferred solution.}}
[630] Fix | Delete
*
[631] Fix | Delete
* @param string $key Internal key of the value to get (without prefix).
[632] Fix | Delete
* @param int $postid Post ID of the post to get the value for.
[633] Fix | Delete
*
[634] Fix | Delete
* @return string All 'normal' values returned from get_post_meta() are strings.
[635] Fix | Delete
* Objects and arrays are possible, but not used by this plugin
[636] Fix | Delete
* and therefore discarted (except when the special 'serialized' field def
[637] Fix | Delete
* value is set to true - only used by add-on plugins for now).
[638] Fix | Delete
* Will return the default value if no value was found.
[639] Fix | Delete
* Will return empty string if no default was found (not one of our keys) or
[640] Fix | Delete
* if the post does not exist.
[641] Fix | Delete
*/
[642] Fix | Delete
public static function get_value( $key, $postid = 0 ) {
[643] Fix | Delete
global $post;
[644] Fix | Delete
[645] Fix | Delete
$postid = absint( $postid );
[646] Fix | Delete
if ( $postid === 0 ) {
[647] Fix | Delete
if ( ( isset( $post ) && is_object( $post ) ) && ( isset( $post->post_status ) && $post->post_status !== 'auto-draft' ) ) {
[648] Fix | Delete
$postid = $post->ID;
[649] Fix | Delete
}
[650] Fix | Delete
else {
[651] Fix | Delete
return '';
[652] Fix | Delete
}
[653] Fix | Delete
}
[654] Fix | Delete
[655] Fix | Delete
$custom = get_post_custom( $postid ); // Array of strings or empty array.
[656] Fix | Delete
$table_key = self::$meta_prefix . $key;
[657] Fix | Delete
[658] Fix | Delete
// Populate the field_def using the field_index lookup array.
[659] Fix | Delete
$field_def = [];
[660] Fix | Delete
if ( isset( self::$fields_index[ $table_key ] ) ) {
[661] Fix | Delete
$field_def = self::$meta_fields[ self::$fields_index[ $table_key ]['subset'] ][ self::$fields_index[ $table_key ]['key'] ];
[662] Fix | Delete
}
[663] Fix | Delete
[664] Fix | Delete
// Check if we have a custom post meta entry.
[665] Fix | Delete
if ( isset( $custom[ $table_key ][0] ) ) {
[666] Fix | Delete
$unserialized = maybe_unserialize( $custom[ $table_key ][0] );
[667] Fix | Delete
[668] Fix | Delete
// Check if it is already unserialized.
[669] Fix | Delete
if ( $custom[ $table_key ][0] === $unserialized ) {
[670] Fix | Delete
return $custom[ $table_key ][0];
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
// Check whether we need to unserialize it.
[674] Fix | Delete
if ( isset( $field_def['serialized'] ) && $field_def['serialized'] === true ) {
[675] Fix | Delete
// Ok, serialize value expected/allowed.
[676] Fix | Delete
return $unserialized;
[677] Fix | Delete
}
[678] Fix | Delete
}
[679] Fix | Delete
[680] Fix | Delete
// Meta was either not found or found, but object/array while not allowed to be.
[681] Fix | Delete
if ( isset( self::$defaults[ self::$meta_prefix . $key ] ) ) {
[682] Fix | Delete
// Update the default value to the current post type.
[683] Fix | Delete
switch ( $key ) {
[684] Fix | Delete
case 'schema_page_type':
[685] Fix | Delete
case 'schema_article_type':
[686] Fix | Delete
return '';
[687] Fix | Delete
}
[688] Fix | Delete
[689] Fix | Delete
return self::$defaults[ self::$meta_prefix . $key ];
[690] Fix | Delete
}
[691] Fix | Delete
[692] Fix | Delete
/*
[693] Fix | Delete
* Shouldn't ever happen, means not one of our keys as there will always be a default available
[694] Fix | Delete
* for all our keys.
[695] Fix | Delete
*/
[696] Fix | Delete
return '';
[697] Fix | Delete
}
[698] Fix | Delete
[699] Fix | Delete
/**
[700] Fix | Delete
* Update a meta value for a post.
[701] Fix | Delete
*
[702] Fix | Delete
* @param string $key The internal key of the meta value to change (without prefix).
[703] Fix | Delete
* @param mixed $meta_value The value to set the meta to.
[704] Fix | Delete
* @param int $post_id The ID of the post to change the meta for.
[705] Fix | Delete
*
[706] Fix | Delete
* @return bool Whether the value was changed.
[707] Fix | Delete
*/
[708] Fix | Delete
public static function set_value( $key, $meta_value, $post_id ) {
[709] Fix | Delete
/*
[710] Fix | Delete
* Slash the data, because `update_metadata` will unslash it and we have already unslashed it.
[711] Fix | Delete
* Related issue: https://github.com/Yoast/YoastSEO.js/issues/2158
[712] Fix | Delete
*/
[713] Fix | Delete
$meta_value = wp_slash( $meta_value );
[714] Fix | Delete
[715] Fix | Delete
return update_post_meta( $post_id, self::$meta_prefix . $key, $meta_value );
[716] Fix | Delete
}
[717] Fix | Delete
[718] Fix | Delete
/**
[719] Fix | Delete
* Deletes a meta value for a post.
[720] Fix | Delete
*
[721] Fix | Delete
* @param string $key The internal key of the meta value to change (without prefix).
[722] Fix | Delete
* @param int $post_id The ID of the post to delete the meta for.
[723] Fix | Delete
*
[724] Fix | Delete
* @return bool Whether the delete was successful or not.
[725] Fix | Delete
*/
[726] Fix | Delete
public static function delete( $key, $post_id ) {
[727] Fix | Delete
return delete_post_meta( $post_id, self::$meta_prefix . $key );
[728] Fix | Delete
}
[729] Fix | Delete
[730] Fix | Delete
/**
[731] Fix | Delete
* Used for imports, this functions imports the value of $old_metakey into $new_metakey for those post
[732] Fix | Delete
* where no WPSEO meta data has been set.
[733] Fix | Delete
* Optionally deletes the $old_metakey values.
[734] Fix | Delete
*
[735] Fix | Delete
* @param string $old_metakey The old key of the meta value.
[736] Fix | Delete
* @param string $new_metakey The new key, usually the WPSEO meta key (including prefix).
[737] Fix | Delete
* @param bool $delete_old Whether to delete the old meta key/value-sets.
[738] Fix | Delete
*
[739] Fix | Delete
* @return void
[740] Fix | Delete
*/
[741] Fix | Delete
public static function replace_meta( $old_metakey, $new_metakey, $delete_old = false ) {
[742] Fix | Delete
global $wpdb;
[743] Fix | Delete
[744] Fix | Delete
/*
[745] Fix | Delete
* Get only those rows where no wpseo meta values exist for the same post
[746] Fix | Delete
* (with the exception of linkdex as that will be set independently of whether the post has been edited).
[747] Fix | Delete
*
[748] Fix | Delete
* {@internal Query is pretty well optimized this way.}}
[749] Fix | Delete
*/
[750] Fix | Delete
$query = $wpdb->prepare(
[751] Fix | Delete
"
[752] Fix | Delete
SELECT `a`.*
[753] Fix | Delete
FROM {$wpdb->postmeta} AS a
[754] Fix | Delete
WHERE `a`.`meta_key` = %s
[755] Fix | Delete
AND NOT EXISTS (
[756] Fix | Delete
SELECT DISTINCT `post_id` , count( `meta_id` ) AS count
[757] Fix | Delete
FROM {$wpdb->postmeta} AS b
[758] Fix | Delete
WHERE `a`.`post_id` = `b`.`post_id`
[759] Fix | Delete
AND `meta_key` LIKE %s
[760] Fix | Delete
AND `meta_key` <> %s
[761] Fix | Delete
GROUP BY `post_id`
[762] Fix | Delete
)
[763] Fix | Delete
;",
[764] Fix | Delete
$old_metakey,
[765] Fix | Delete
$wpdb->esc_like( self::$meta_prefix . '%' ),
[766] Fix | Delete
self::$meta_prefix . 'linkdex'
[767] Fix | Delete
);
[768] Fix | Delete
$oldies = $wpdb->get_results( $query );
[769] Fix | Delete
[770] Fix | Delete
if ( is_array( $oldies ) && $oldies !== [] ) {
[771] Fix | Delete
foreach ( $oldies as $old ) {
[772] Fix | Delete
update_post_meta( $old->post_id, $new_metakey, $old->meta_value );
[773] Fix | Delete
}
[774] Fix | Delete
}
[775] Fix | Delete
[776] Fix | Delete
// Delete old keys.
[777] Fix | Delete
if ( $delete_old === true ) {
[778] Fix | Delete
delete_post_meta_by_key( $old_metakey );
[779] Fix | Delete
}
[780] Fix | Delete
}
[781] Fix | Delete
[782] Fix | Delete
/**
[783] Fix | Delete
* General clean-up of the saved meta values.
[784] Fix | Delete
* - Remove potentially lingering old meta keys;
[785] Fix | Delete
* - Remove all default and invalid values.
[786] Fix | Delete
*
[787] Fix | Delete
* @return void
[788] Fix | Delete
*/
[789] Fix | Delete
public static function clean_up() {
[790] Fix | Delete
global $wpdb;
[791] Fix | Delete
[792] Fix | Delete
/*
[793] Fix | Delete
* Clean up '_yoast_wpseo_meta-robots'.
[794] Fix | Delete
*
[795] Fix | Delete
* Retrieve all '_yoast_wpseo_meta-robots' meta values and convert if no new values found.
[796] Fix | Delete
*
[797] Fix | Delete
* {@internal Query is pretty well optimized this way.}}
[798] Fix | Delete
*
[799] Fix | Delete
* @todo [JRF => Yoast] Find out all possible values which the old '_yoast_wpseo_meta-robots' could contain
[800] Fix | Delete
* to convert the data correctly.
[801] Fix | Delete
*/
[802] Fix | Delete
$query = $wpdb->prepare(
[803] Fix | Delete
"
[804] Fix | Delete
SELECT `a`.*
[805] Fix | Delete
FROM {$wpdb->postmeta} AS a
[806] Fix | Delete
WHERE `a`.`meta_key` = %s
[807] Fix | Delete
AND NOT EXISTS (
[808] Fix | Delete
SELECT DISTINCT `post_id` , count( `meta_id` ) AS count
[809] Fix | Delete
FROM {$wpdb->postmeta} AS b
[810] Fix | Delete
WHERE `a`.`post_id` = `b`.`post_id`
[811] Fix | Delete
AND ( `meta_key` = %s
[812] Fix | Delete
OR `meta_key` = %s )
[813] Fix | Delete
GROUP BY `post_id`
[814] Fix | Delete
)
[815] Fix | Delete
;",
[816] Fix | Delete
self::$meta_prefix . 'meta-robots',
[817] Fix | Delete
self::$meta_prefix . 'meta-robots-noindex',
[818] Fix | Delete
self::$meta_prefix . 'meta-robots-nofollow'
[819] Fix | Delete
);
[820] Fix | Delete
$oldies = $wpdb->get_results( $query );
[821] Fix | Delete
[822] Fix | Delete
if ( is_array( $oldies ) && $oldies !== [] ) {
[823] Fix | Delete
foreach ( $oldies as $old ) {
[824] Fix | Delete
$old_values = explode( ',', $old->meta_value );
[825] Fix | Delete
foreach ( $old_values as $value ) {
[826] Fix | Delete
if ( $value === 'noindex' ) {
[827] Fix | Delete
update_post_meta( $old->post_id, self::$meta_prefix . 'meta-robots-noindex', 1 );
[828] Fix | Delete
}
[829] Fix | Delete
elseif ( $value === 'nofollow' ) {
[830] Fix | Delete
update_post_meta( $old->post_id, self::$meta_prefix . 'meta-robots-nofollow', 1 );
[831] Fix | Delete
}
[832] Fix | Delete
}
[833] Fix | Delete
}
[834] Fix | Delete
}
[835] Fix | Delete
unset( $query, $oldies, $old, $old_values, $value );
[836] Fix | Delete
[837] Fix | Delete
// Delete old keys.
[838] Fix | Delete
delete_post_meta_by_key( self::$meta_prefix . 'meta-robots' );
[839] Fix | Delete
[840] Fix | Delete
/*
[841] Fix | Delete
* Remove all default values and (most) invalid option values.
[842] Fix | Delete
* Invalid option values for the multiselect (meta-robots-adv) field will be dealt with seperately.
[843] Fix | Delete
*
[844] Fix | Delete
* {@internal Some of the defaults have changed in v1.5, but as the defaults will
[845] Fix | Delete
* be removed and new defaults will now automatically be passed when no
[846] Fix | Delete
* data found, this update is automatic (as long as we remove the old
[847] Fix | Delete
* values which we do in the below routine).}}
[848] Fix | Delete
*
[849] Fix | Delete
* {@internal Unfortunately we can't use the normal delete_meta() with key/value combination
[850] Fix | Delete
* as '' (empty string) values will be ignored and would result in all metas
[851] Fix | Delete
* with that key being deleted, not just the empty fields.
[852] Fix | Delete
* Still, the below implementation is largely based on the delete_meta() function.}}
[853] Fix | Delete
*/
[854] Fix | Delete
$query = [];
[855] Fix | Delete
[856] Fix | Delete
foreach ( self::$meta_fields as $subset => $field_group ) {
[857] Fix | Delete
foreach ( $field_group as $key => $field_def ) {
[858] Fix | Delete
if ( ! isset( $field_def['default_value'] ) ) {
[859] Fix | Delete
continue;
[860] Fix | Delete
}
[861] Fix | Delete
[862] Fix | Delete
if ( isset( $field_def['options'] ) && is_array( $field_def['options'] ) && $field_def['options'] !== [] ) {
[863] Fix | Delete
$valid = $field_def['options'];
[864] Fix | Delete
// Remove the default value from the valid options.
[865] Fix | Delete
unset( $valid[ $field_def['default_value'] ] );
[866] Fix | Delete
$valid = array_keys( $valid );
[867] Fix | Delete
[868] Fix | Delete
$query[] = $wpdb->prepare(
[869] Fix | Delete
"( meta_key = %s AND meta_value NOT IN ( '" . implode( "','", esc_sql( $valid ) ) . "' ) )",
[870] Fix | Delete
self::$meta_prefix . $key
[871] Fix | Delete
);
[872] Fix | Delete
unset( $valid );
[873] Fix | Delete
}
[874] Fix | Delete
elseif ( is_string( $field_def['default_value'] ) && $field_def['default_value'] !== '' ) {
[875] Fix | Delete
$query[] = $wpdb->prepare(
[876] Fix | Delete
'( meta_key = %s AND meta_value = %s )',
[877] Fix | Delete
self::$meta_prefix . $key,
[878] Fix | Delete
$field_def['default_value']
[879] Fix | Delete
);
[880] Fix | Delete
}
[881] Fix | Delete
else {
[882] Fix | Delete
$query[] = $wpdb->prepare(
[883] Fix | Delete
"( meta_key = %s AND meta_value = '' )",
[884] Fix | Delete
self::$meta_prefix . $key
[885] Fix | Delete
);
[886] Fix | Delete
}
[887] Fix | Delete
}
[888] Fix | Delete
}
[889] Fix | Delete
unset( $subset, $field_group, $key, $field_def );
[890] Fix | Delete
[891] Fix | Delete
$query = "SELECT meta_id FROM {$wpdb->postmeta} WHERE " . implode( ' OR ', $query ) . ';';
[892] Fix | Delete
$meta_ids = $wpdb->get_col( $query );
[893] Fix | Delete
[894] Fix | Delete
if ( is_array( $meta_ids ) && $meta_ids !== [] ) {
[895] Fix | Delete
// WP native action.
[896] Fix | Delete
do_action( 'delete_post_meta', $meta_ids, null, null, null );
[897] Fix | Delete
[898] Fix | Delete
$query = "DELETE FROM {$wpdb->postmeta} WHERE meta_id IN( " . implode( ',', $meta_ids ) . ' )';
[899] Fix | Delete
$count = $wpdb->query( $query );
[900] Fix | Delete
[901] Fix | Delete
if ( $count ) {
[902] Fix | Delete
foreach ( $meta_ids as $object_id ) {
[903] Fix | Delete
wp_cache_delete( $object_id, 'post_meta' );
[904] Fix | Delete
}
[905] Fix | Delete
[906] Fix | Delete
// WP native action.
[907] Fix | Delete
do_action( 'deleted_post_meta', $meta_ids, null, null, null );
[908] Fix | Delete
}
[909] Fix | Delete
}
[910] Fix | Delete
unset( $query, $meta_ids, $count, $object_id );
[911] Fix | Delete
[912] Fix | Delete
/*
[913] Fix | Delete
* Deal with the multiselect (meta-robots-adv) field.
[914] Fix | Delete
*
[915] Fix | Delete
* Removes invalid option combinations, such as 'none,noarchive'.
[916] Fix | Delete
*
[917] Fix | Delete
* Default values have already been removed, so we should have a small result set and
[918] Fix | Delete
* (hopefully) even smaller set of invalid results.
[919] Fix | Delete
*/
[920] Fix | Delete
$query = $wpdb->prepare(
[921] Fix | Delete
"SELECT meta_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s",
[922] Fix | Delete
self::$meta_prefix . 'meta-robots-adv'
[923] Fix | Delete
);
[924] Fix | Delete
$oldies = $wpdb->get_results( $query );
[925] Fix | Delete
[926] Fix | Delete
if ( is_array( $oldies ) && $oldies !== [] ) {
[927] Fix | Delete
foreach ( $oldies as $old ) {
[928] Fix | Delete
$clean = self::validate_meta_robots_adv( $old->meta_value );
[929] Fix | Delete
[930] Fix | Delete
if ( $clean !== $old->meta_value ) {
[931] Fix | Delete
if ( $clean !== self::$meta_fields['advanced']['meta-robots-adv']['default_value'] ) {
[932] Fix | Delete
update_metadata_by_mid( 'post', $old->meta_id, $clean );
[933] Fix | Delete
}
[934] Fix | Delete
else {
[935] Fix | Delete
delete_metadata_by_mid( 'post', $old->meta_id );
[936] Fix | Delete
}
[937] Fix | Delete
}
[938] Fix | Delete
}
[939] Fix | Delete
}
[940] Fix | Delete
unset( $query, $oldies, $old, $clean );
[941] Fix | Delete
[942] Fix | Delete
do_action( 'wpseo_meta_clean_up' );
[943] Fix | Delete
}
[944] Fix | Delete
[945] Fix | Delete
/**
[946] Fix | Delete
* Recursively merge a variable number of arrays, using the left array as base,
[947] Fix | Delete
* giving priority to the right array.
[948] Fix | Delete
*
[949] Fix | Delete
* Difference with native array_merge_recursive():
[950] Fix | Delete
* array_merge_recursive converts values with duplicate keys to arrays rather than
[951] Fix | Delete
* overwriting the value in the first array with the duplicate value in the second array.
[952] Fix | Delete
*
[953] Fix | Delete
* array_merge_recursive_distinct does not change the data types of the values in the arrays.
[954] Fix | Delete
* Matching keys' values in the second array overwrite those in the first array, as is the
[955] Fix | Delete
* case with array_merge.
[956] Fix | Delete
*
[957] Fix | Delete
* Freely based on information found on http://www.php.net/manual/en/function.array-merge-recursive.php
[958] Fix | Delete
*
[959] Fix | Delete
* {@internal Should be moved to a general utility class.}}
[960] Fix | Delete
*
[961] Fix | Delete
* @return array
[962] Fix | Delete
*/
[963] Fix | Delete
public static function array_merge_recursive_distinct() {
[964] Fix | Delete
[965] Fix | Delete
$arrays = func_get_args();
[966] Fix | Delete
if ( count( $arrays ) < 2 ) {
[967] Fix | Delete
if ( $arrays === [] ) {
[968] Fix | Delete
return [];
[969] Fix | Delete
}
[970] Fix | Delete
else {
[971] Fix | Delete
return $arrays[0];
[972] Fix | Delete
}
[973] Fix | Delete
}
[974] Fix | Delete
[975] Fix | Delete
$merged = array_shift( $arrays );
[976] Fix | Delete
[977] Fix | Delete
foreach ( $arrays as $array ) {
[978] Fix | Delete
foreach ( $array as $key => $value ) {
[979] Fix | Delete
if ( is_array( $value ) && ( isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) ) {
[980] Fix | Delete
$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
[981] Fix | Delete
}
[982] Fix | Delete
else {
[983] Fix | Delete
$merged[ $key ] = $value;
[984] Fix | Delete
}
[985] Fix | Delete
}
[986] Fix | Delete
unset( $key, $value );
[987] Fix | Delete
}
[988] Fix | Delete
[989] Fix | Delete
return $merged;
[990] Fix | Delete
}
[991] Fix | Delete
[992] Fix | Delete
/**
[993] Fix | Delete
* Counts the total of all the keywords being used for posts except the given one.
[994] Fix | Delete
*
[995] Fix | Delete
* @param string $keyword The keyword to be counted.
[996] Fix | Delete
* @param int $post_id The id of the post to which the keyword belongs.
[997] Fix | Delete
*
[998] Fix | Delete
* @return array
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function