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-inclu...
File: meta.php
if ( $delete_all ) {
[500] Fix | Delete
$data = (array) $object_ids;
[501] Fix | Delete
} else {
[502] Fix | Delete
$data = array( $object_id );
[503] Fix | Delete
}
[504] Fix | Delete
wp_cache_delete_multiple( $data, $meta_type . '_meta' );
[505] Fix | Delete
[506] Fix | Delete
/**
[507] Fix | Delete
* Fires immediately after deleting metadata of a specific type.
[508] Fix | Delete
*
[509] Fix | Delete
* The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
[510] Fix | Delete
* (post, comment, term, user, or any other type with an associated meta table).
[511] Fix | Delete
*
[512] Fix | Delete
* Possible hook names include:
[513] Fix | Delete
*
[514] Fix | Delete
* - `deleted_post_meta`
[515] Fix | Delete
* - `deleted_comment_meta`
[516] Fix | Delete
* - `deleted_term_meta`
[517] Fix | Delete
* - `deleted_user_meta`
[518] Fix | Delete
*
[519] Fix | Delete
* @since 2.9.0
[520] Fix | Delete
*
[521] Fix | Delete
* @param string[] $meta_ids An array of metadata entry IDs to delete.
[522] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[523] Fix | Delete
* @param string $meta_key Metadata key.
[524] Fix | Delete
* @param mixed $_meta_value Metadata value.
[525] Fix | Delete
*/
[526] Fix | Delete
do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
[527] Fix | Delete
[528] Fix | Delete
// Old-style action.
[529] Fix | Delete
if ( 'post' === $meta_type ) {
[530] Fix | Delete
/**
[531] Fix | Delete
* Fires immediately after deleting metadata for a post.
[532] Fix | Delete
*
[533] Fix | Delete
* @since 2.9.0
[534] Fix | Delete
*
[535] Fix | Delete
* @param string[] $meta_ids An array of metadata entry IDs to delete.
[536] Fix | Delete
*/
[537] Fix | Delete
do_action( 'deleted_postmeta', $meta_ids );
[538] Fix | Delete
}
[539] Fix | Delete
[540] Fix | Delete
return true;
[541] Fix | Delete
}
[542] Fix | Delete
[543] Fix | Delete
/**
[544] Fix | Delete
* Retrieves the value of a metadata field for the specified object type and ID.
[545] Fix | Delete
*
[546] Fix | Delete
* If the meta field exists, a single value is returned if `$single` is true,
[547] Fix | Delete
* or an array of values if it's false.
[548] Fix | Delete
*
[549] Fix | Delete
* If the meta field does not exist, the result depends on get_metadata_default().
[550] Fix | Delete
* By default, an empty string is returned if `$single` is true, or an empty array
[551] Fix | Delete
* if it's false.
[552] Fix | Delete
*
[553] Fix | Delete
* @since 2.9.0
[554] Fix | Delete
*
[555] Fix | Delete
* @see get_metadata_raw()
[556] Fix | Delete
* @see get_metadata_default()
[557] Fix | Delete
*
[558] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[559] Fix | Delete
* or any other object type with an associated meta table.
[560] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[561] Fix | Delete
* @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
[562] Fix | Delete
* the specified object. Default empty string.
[563] Fix | Delete
* @param bool $single Optional. If true, return only the first value of the specified `$meta_key`.
[564] Fix | Delete
* This parameter has no effect if `$meta_key` is not specified. Default false.
[565] Fix | Delete
* @return mixed An array of values if `$single` is false.
[566] Fix | Delete
* The value of the meta field if `$single` is true.
[567] Fix | Delete
* False for an invalid `$object_id` (non-numeric, zero, or negative value),
[568] Fix | Delete
* or if `$meta_type` is not specified.
[569] Fix | Delete
* An empty string if a valid but non-existing object ID is passed.
[570] Fix | Delete
*/
[571] Fix | Delete
function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) {
[572] Fix | Delete
$value = get_metadata_raw( $meta_type, $object_id, $meta_key, $single );
[573] Fix | Delete
if ( ! is_null( $value ) ) {
[574] Fix | Delete
return $value;
[575] Fix | Delete
}
[576] Fix | Delete
[577] Fix | Delete
return get_metadata_default( $meta_type, $object_id, $meta_key, $single );
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
/**
[581] Fix | Delete
* Retrieves raw metadata value for the specified object.
[582] Fix | Delete
*
[583] Fix | Delete
* @since 5.5.0
[584] Fix | Delete
*
[585] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[586] Fix | Delete
* or any other object type with an associated meta table.
[587] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[588] Fix | Delete
* @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
[589] Fix | Delete
* the specified object. Default empty string.
[590] Fix | Delete
* @param bool $single Optional. If true, return only the first value of the specified `$meta_key`.
[591] Fix | Delete
* This parameter has no effect if `$meta_key` is not specified. Default false.
[592] Fix | Delete
* @return mixed An array of values if `$single` is false.
[593] Fix | Delete
* The value of the meta field if `$single` is true.
[594] Fix | Delete
* False for an invalid `$object_id` (non-numeric, zero, or negative value),
[595] Fix | Delete
* or if `$meta_type` is not specified.
[596] Fix | Delete
* Null if the value does not exist.
[597] Fix | Delete
*/
[598] Fix | Delete
function get_metadata_raw( $meta_type, $object_id, $meta_key = '', $single = false ) {
[599] Fix | Delete
if ( ! $meta_type || ! is_numeric( $object_id ) ) {
[600] Fix | Delete
return false;
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
$object_id = absint( $object_id );
[604] Fix | Delete
if ( ! $object_id ) {
[605] Fix | Delete
return false;
[606] Fix | Delete
}
[607] Fix | Delete
[608] Fix | Delete
/**
[609] Fix | Delete
* Short-circuits the return value of a meta field.
[610] Fix | Delete
*
[611] Fix | Delete
* The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
[612] Fix | Delete
* (post, comment, term, user, or any other type with an associated meta table).
[613] Fix | Delete
* Returning a non-null value will effectively short-circuit the function.
[614] Fix | Delete
*
[615] Fix | Delete
* Possible filter names include:
[616] Fix | Delete
*
[617] Fix | Delete
* - `get_post_metadata`
[618] Fix | Delete
* - `get_comment_metadata`
[619] Fix | Delete
* - `get_term_metadata`
[620] Fix | Delete
* - `get_user_metadata`
[621] Fix | Delete
*
[622] Fix | Delete
* @since 3.1.0
[623] Fix | Delete
* @since 5.5.0 Added the `$meta_type` parameter.
[624] Fix | Delete
*
[625] Fix | Delete
* @param mixed $value The value to return, either a single metadata value or an array
[626] Fix | Delete
* of values depending on the value of `$single`. Default null.
[627] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[628] Fix | Delete
* @param string $meta_key Metadata key.
[629] Fix | Delete
* @param bool $single Whether to return only the first value of the specified `$meta_key`.
[630] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[631] Fix | Delete
* or any other object type with an associated meta table.
[632] Fix | Delete
*/
[633] Fix | Delete
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type );
[634] Fix | Delete
if ( null !== $check ) {
[635] Fix | Delete
if ( $single && is_array( $check ) ) {
[636] Fix | Delete
return $check[0];
[637] Fix | Delete
} else {
[638] Fix | Delete
return $check;
[639] Fix | Delete
}
[640] Fix | Delete
}
[641] Fix | Delete
[642] Fix | Delete
$meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' );
[643] Fix | Delete
[644] Fix | Delete
if ( ! $meta_cache ) {
[645] Fix | Delete
$meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
[646] Fix | Delete
if ( isset( $meta_cache[ $object_id ] ) ) {
[647] Fix | Delete
$meta_cache = $meta_cache[ $object_id ];
[648] Fix | Delete
} else {
[649] Fix | Delete
$meta_cache = null;
[650] Fix | Delete
}
[651] Fix | Delete
}
[652] Fix | Delete
[653] Fix | Delete
if ( ! $meta_key ) {
[654] Fix | Delete
return $meta_cache;
[655] Fix | Delete
}
[656] Fix | Delete
[657] Fix | Delete
if ( isset( $meta_cache[ $meta_key ] ) ) {
[658] Fix | Delete
if ( $single ) {
[659] Fix | Delete
return maybe_unserialize( $meta_cache[ $meta_key ][0] );
[660] Fix | Delete
} else {
[661] Fix | Delete
return array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] );
[662] Fix | Delete
}
[663] Fix | Delete
}
[664] Fix | Delete
[665] Fix | Delete
return null;
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
/**
[669] Fix | Delete
* Retrieves default metadata value for the specified meta key and object.
[670] Fix | Delete
*
[671] Fix | Delete
* By default, an empty string is returned if `$single` is true, or an empty array
[672] Fix | Delete
* if it's false.
[673] Fix | Delete
*
[674] Fix | Delete
* @since 5.5.0
[675] Fix | Delete
*
[676] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[677] Fix | Delete
* or any other object type with an associated meta table.
[678] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[679] Fix | Delete
* @param string $meta_key Metadata key.
[680] Fix | Delete
* @param bool $single Optional. If true, return only the first value of the specified `$meta_key`.
[681] Fix | Delete
* This parameter has no effect if `$meta_key` is not specified. Default false.
[682] Fix | Delete
* @return mixed An array of default values if `$single` is false.
[683] Fix | Delete
* The default value of the meta field if `$single` is true.
[684] Fix | Delete
*/
[685] Fix | Delete
function get_metadata_default( $meta_type, $object_id, $meta_key, $single = false ) {
[686] Fix | Delete
if ( $single ) {
[687] Fix | Delete
$value = '';
[688] Fix | Delete
} else {
[689] Fix | Delete
$value = array();
[690] Fix | Delete
}
[691] Fix | Delete
[692] Fix | Delete
/**
[693] Fix | Delete
* Filters the default metadata value for a specified meta key and object.
[694] Fix | Delete
*
[695] Fix | Delete
* The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
[696] Fix | Delete
* (post, comment, term, user, or any other type with an associated meta table).
[697] Fix | Delete
*
[698] Fix | Delete
* Possible filter names include:
[699] Fix | Delete
*
[700] Fix | Delete
* - `default_post_metadata`
[701] Fix | Delete
* - `default_comment_metadata`
[702] Fix | Delete
* - `default_term_metadata`
[703] Fix | Delete
* - `default_user_metadata`
[704] Fix | Delete
*
[705] Fix | Delete
* @since 5.5.0
[706] Fix | Delete
*
[707] Fix | Delete
* @param mixed $value The value to return, either a single metadata value or an array
[708] Fix | Delete
* of values depending on the value of `$single`.
[709] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[710] Fix | Delete
* @param string $meta_key Metadata key.
[711] Fix | Delete
* @param bool $single Whether to return only the first value of the specified `$meta_key`.
[712] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[713] Fix | Delete
* or any other object type with an associated meta table.
[714] Fix | Delete
*/
[715] Fix | Delete
$value = apply_filters( "default_{$meta_type}_metadata", $value, $object_id, $meta_key, $single, $meta_type );
[716] Fix | Delete
[717] Fix | Delete
if ( ! $single && ! wp_is_numeric_array( $value ) ) {
[718] Fix | Delete
$value = array( $value );
[719] Fix | Delete
}
[720] Fix | Delete
[721] Fix | Delete
return $value;
[722] Fix | Delete
}
[723] Fix | Delete
[724] Fix | Delete
/**
[725] Fix | Delete
* Determines if a meta field with the given key exists for the given object ID.
[726] Fix | Delete
*
[727] Fix | Delete
* @since 3.3.0
[728] Fix | Delete
*
[729] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[730] Fix | Delete
* or any other object type with an associated meta table.
[731] Fix | Delete
* @param int $object_id ID of the object metadata is for.
[732] Fix | Delete
* @param string $meta_key Metadata key.
[733] Fix | Delete
* @return bool Whether a meta field with the given key exists.
[734] Fix | Delete
*/
[735] Fix | Delete
function metadata_exists( $meta_type, $object_id, $meta_key ) {
[736] Fix | Delete
if ( ! $meta_type || ! is_numeric( $object_id ) ) {
[737] Fix | Delete
return false;
[738] Fix | Delete
}
[739] Fix | Delete
[740] Fix | Delete
$object_id = absint( $object_id );
[741] Fix | Delete
if ( ! $object_id ) {
[742] Fix | Delete
return false;
[743] Fix | Delete
}
[744] Fix | Delete
[745] Fix | Delete
/** This filter is documented in wp-includes/meta.php */
[746] Fix | Delete
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true, $meta_type );
[747] Fix | Delete
if ( null !== $check ) {
[748] Fix | Delete
return (bool) $check;
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
$meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' );
[752] Fix | Delete
[753] Fix | Delete
if ( ! $meta_cache ) {
[754] Fix | Delete
$meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
[755] Fix | Delete
$meta_cache = $meta_cache[ $object_id ];
[756] Fix | Delete
}
[757] Fix | Delete
[758] Fix | Delete
if ( isset( $meta_cache[ $meta_key ] ) ) {
[759] Fix | Delete
return true;
[760] Fix | Delete
}
[761] Fix | Delete
[762] Fix | Delete
return false;
[763] Fix | Delete
}
[764] Fix | Delete
[765] Fix | Delete
/**
[766] Fix | Delete
* Retrieves metadata by meta ID.
[767] Fix | Delete
*
[768] Fix | Delete
* @since 3.3.0
[769] Fix | Delete
*
[770] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[771] Fix | Delete
*
[772] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[773] Fix | Delete
* or any other object type with an associated meta table.
[774] Fix | Delete
* @param int $meta_id ID for a specific meta row.
[775] Fix | Delete
* @return stdClass|false {
[776] Fix | Delete
* Metadata object, or boolean `false` if the metadata doesn't exist.
[777] Fix | Delete
*
[778] Fix | Delete
* @type string $meta_key The meta key.
[779] Fix | Delete
* @type mixed $meta_value The unserialized meta value.
[780] Fix | Delete
* @type string $meta_id Optional. The meta ID when the meta type is any value except 'user'.
[781] Fix | Delete
* @type string $umeta_id Optional. The meta ID when the meta type is 'user'.
[782] Fix | Delete
* @type string $post_id Optional. The object ID when the meta type is 'post'.
[783] Fix | Delete
* @type string $comment_id Optional. The object ID when the meta type is 'comment'.
[784] Fix | Delete
* @type string $term_id Optional. The object ID when the meta type is 'term'.
[785] Fix | Delete
* @type string $user_id Optional. The object ID when the meta type is 'user'.
[786] Fix | Delete
* }
[787] Fix | Delete
*/
[788] Fix | Delete
function get_metadata_by_mid( $meta_type, $meta_id ) {
[789] Fix | Delete
global $wpdb;
[790] Fix | Delete
[791] Fix | Delete
if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) {
[792] Fix | Delete
return false;
[793] Fix | Delete
}
[794] Fix | Delete
[795] Fix | Delete
$meta_id = (int) $meta_id;
[796] Fix | Delete
if ( $meta_id <= 0 ) {
[797] Fix | Delete
return false;
[798] Fix | Delete
}
[799] Fix | Delete
[800] Fix | Delete
$table = _get_meta_table( $meta_type );
[801] Fix | Delete
if ( ! $table ) {
[802] Fix | Delete
return false;
[803] Fix | Delete
}
[804] Fix | Delete
[805] Fix | Delete
/**
[806] Fix | Delete
* Short-circuits the return value when fetching a meta field by meta ID.
[807] Fix | Delete
*
[808] Fix | Delete
* The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
[809] Fix | Delete
* (post, comment, term, user, or any other type with an associated meta table).
[810] Fix | Delete
* Returning a non-null value will effectively short-circuit the function.
[811] Fix | Delete
*
[812] Fix | Delete
* Possible hook names include:
[813] Fix | Delete
*
[814] Fix | Delete
* - `get_post_metadata_by_mid`
[815] Fix | Delete
* - `get_comment_metadata_by_mid`
[816] Fix | Delete
* - `get_term_metadata_by_mid`
[817] Fix | Delete
* - `get_user_metadata_by_mid`
[818] Fix | Delete
*
[819] Fix | Delete
* @since 5.0.0
[820] Fix | Delete
*
[821] Fix | Delete
* @param stdClass|null $value The value to return.
[822] Fix | Delete
* @param int $meta_id Meta ID.
[823] Fix | Delete
*/
[824] Fix | Delete
$check = apply_filters( "get_{$meta_type}_metadata_by_mid", null, $meta_id );
[825] Fix | Delete
if ( null !== $check ) {
[826] Fix | Delete
return $check;
[827] Fix | Delete
}
[828] Fix | Delete
[829] Fix | Delete
$id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
[830] Fix | Delete
[831] Fix | Delete
$meta = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE $id_column = %d", $meta_id ) );
[832] Fix | Delete
[833] Fix | Delete
if ( empty( $meta ) ) {
[834] Fix | Delete
return false;
[835] Fix | Delete
}
[836] Fix | Delete
[837] Fix | Delete
if ( isset( $meta->meta_value ) ) {
[838] Fix | Delete
$meta->meta_value = maybe_unserialize( $meta->meta_value );
[839] Fix | Delete
}
[840] Fix | Delete
[841] Fix | Delete
return $meta;
[842] Fix | Delete
}
[843] Fix | Delete
[844] Fix | Delete
/**
[845] Fix | Delete
* Updates metadata by meta ID.
[846] Fix | Delete
*
[847] Fix | Delete
* @since 3.3.0
[848] Fix | Delete
*
[849] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[850] Fix | Delete
*
[851] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[852] Fix | Delete
* or any other object type with an associated meta table.
[853] Fix | Delete
* @param int $meta_id ID for a specific meta row.
[854] Fix | Delete
* @param string $meta_value Metadata value. Must be serializable if non-scalar.
[855] Fix | Delete
* @param string|false $meta_key Optional. You can provide a meta key to update it. Default false.
[856] Fix | Delete
* @return bool True on successful update, false on failure.
[857] Fix | Delete
*/
[858] Fix | Delete
function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false ) {
[859] Fix | Delete
global $wpdb;
[860] Fix | Delete
[861] Fix | Delete
// Make sure everything is valid.
[862] Fix | Delete
if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) {
[863] Fix | Delete
return false;
[864] Fix | Delete
}
[865] Fix | Delete
[866] Fix | Delete
$meta_id = (int) $meta_id;
[867] Fix | Delete
if ( $meta_id <= 0 ) {
[868] Fix | Delete
return false;
[869] Fix | Delete
}
[870] Fix | Delete
[871] Fix | Delete
$table = _get_meta_table( $meta_type );
[872] Fix | Delete
if ( ! $table ) {
[873] Fix | Delete
return false;
[874] Fix | Delete
}
[875] Fix | Delete
[876] Fix | Delete
$column = sanitize_key( $meta_type . '_id' );
[877] Fix | Delete
$id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
[878] Fix | Delete
[879] Fix | Delete
/**
[880] Fix | Delete
* Short-circuits updating metadata of a specific type by meta ID.
[881] Fix | Delete
*
[882] Fix | Delete
* The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
[883] Fix | Delete
* (post, comment, term, user, or any other type with an associated meta table).
[884] Fix | Delete
* Returning a non-null value will effectively short-circuit the function.
[885] Fix | Delete
*
[886] Fix | Delete
* Possible hook names include:
[887] Fix | Delete
*
[888] Fix | Delete
* - `update_post_metadata_by_mid`
[889] Fix | Delete
* - `update_comment_metadata_by_mid`
[890] Fix | Delete
* - `update_term_metadata_by_mid`
[891] Fix | Delete
* - `update_user_metadata_by_mid`
[892] Fix | Delete
*
[893] Fix | Delete
* @since 5.0.0
[894] Fix | Delete
*
[895] Fix | Delete
* @param null|bool $check Whether to allow updating metadata for the given type.
[896] Fix | Delete
* @param int $meta_id Meta ID.
[897] Fix | Delete
* @param mixed $meta_value Meta value. Must be serializable if non-scalar.
[898] Fix | Delete
* @param string|false $meta_key Meta key, if provided.
[899] Fix | Delete
*/
[900] Fix | Delete
$check = apply_filters( "update_{$meta_type}_metadata_by_mid", null, $meta_id, $meta_value, $meta_key );
[901] Fix | Delete
if ( null !== $check ) {
[902] Fix | Delete
return (bool) $check;
[903] Fix | Delete
}
[904] Fix | Delete
[905] Fix | Delete
// Fetch the meta and go on if it's found.
[906] Fix | Delete
$meta = get_metadata_by_mid( $meta_type, $meta_id );
[907] Fix | Delete
if ( $meta ) {
[908] Fix | Delete
$original_key = $meta->meta_key;
[909] Fix | Delete
$object_id = $meta->{$column};
[910] Fix | Delete
[911] Fix | Delete
/*
[912] Fix | Delete
* If a new meta_key (last parameter) was specified, change the meta key,
[913] Fix | Delete
* otherwise use the original key in the update statement.
[914] Fix | Delete
*/
[915] Fix | Delete
if ( false === $meta_key ) {
[916] Fix | Delete
$meta_key = $original_key;
[917] Fix | Delete
} elseif ( ! is_string( $meta_key ) ) {
[918] Fix | Delete
return false;
[919] Fix | Delete
}
[920] Fix | Delete
[921] Fix | Delete
$meta_subtype = get_object_subtype( $meta_type, $object_id );
[922] Fix | Delete
[923] Fix | Delete
// Sanitize the meta.
[924] Fix | Delete
$_meta_value = $meta_value;
[925] Fix | Delete
$meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype );
[926] Fix | Delete
$meta_value = maybe_serialize( $meta_value );
[927] Fix | Delete
[928] Fix | Delete
// Format the data query arguments.
[929] Fix | Delete
$data = array(
[930] Fix | Delete
'meta_key' => $meta_key,
[931] Fix | Delete
'meta_value' => $meta_value,
[932] Fix | Delete
);
[933] Fix | Delete
[934] Fix | Delete
// Format the where query arguments.
[935] Fix | Delete
$where = array();
[936] Fix | Delete
$where[ $id_column ] = $meta_id;
[937] Fix | Delete
[938] Fix | Delete
/** This action is documented in wp-includes/meta.php */
[939] Fix | Delete
do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
[940] Fix | Delete
[941] Fix | Delete
if ( 'post' === $meta_type ) {
[942] Fix | Delete
/** This action is documented in wp-includes/meta.php */
[943] Fix | Delete
do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
[944] Fix | Delete
}
[945] Fix | Delete
[946] Fix | Delete
// Run the update query, all fields in $data are %s, $where is a %d.
[947] Fix | Delete
$result = $wpdb->update( $table, $data, $where, '%s', '%d' );
[948] Fix | Delete
if ( ! $result ) {
[949] Fix | Delete
return false;
[950] Fix | Delete
}
[951] Fix | Delete
[952] Fix | Delete
// Clear the caches.
[953] Fix | Delete
wp_cache_delete( $object_id, $meta_type . '_meta' );
[954] Fix | Delete
[955] Fix | Delete
/** This action is documented in wp-includes/meta.php */
[956] Fix | Delete
do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
[957] Fix | Delete
[958] Fix | Delete
if ( 'post' === $meta_type ) {
[959] Fix | Delete
/** This action is documented in wp-includes/meta.php */
[960] Fix | Delete
do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
[961] Fix | Delete
}
[962] Fix | Delete
[963] Fix | Delete
return true;
[964] Fix | Delete
}
[965] Fix | Delete
[966] Fix | Delete
// And if the meta was not found.
[967] Fix | Delete
return false;
[968] Fix | Delete
}
[969] Fix | Delete
[970] Fix | Delete
/**
[971] Fix | Delete
* Deletes metadata by meta ID.
[972] Fix | Delete
*
[973] Fix | Delete
* @since 3.3.0
[974] Fix | Delete
*
[975] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[976] Fix | Delete
*
[977] Fix | Delete
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
[978] Fix | Delete
* or any other object type with an associated meta table.
[979] Fix | Delete
* @param int $meta_id ID for a specific meta row.
[980] Fix | Delete
* @return bool True on successful delete, false on failure.
[981] Fix | Delete
*/
[982] Fix | Delete
function delete_metadata_by_mid( $meta_type, $meta_id ) {
[983] Fix | Delete
global $wpdb;
[984] Fix | Delete
[985] Fix | Delete
// Make sure everything is valid.
[986] Fix | Delete
if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) {
[987] Fix | Delete
return false;
[988] Fix | Delete
}
[989] Fix | Delete
[990] Fix | Delete
$meta_id = (int) $meta_id;
[991] Fix | Delete
if ( $meta_id <= 0 ) {
[992] Fix | Delete
return false;
[993] Fix | Delete
}
[994] Fix | Delete
[995] Fix | Delete
$table = _get_meta_table( $meta_type );
[996] Fix | Delete
if ( ! $table ) {
[997] Fix | Delete
return false;
[998] Fix | Delete
}
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function