WPSEO_Meta::remove_meta_if_default()public staticYoast 1.0

Prevent saving of default values and remove potential old value from the database if replaced by a default.

{} Это метод класса: WPSEO_Meta{}

Хуков нет.


true|false|null. True = stop saving, null = continue saving.


$result = WPSEO_Meta::remove_meta_if_default( $check, $object_id, $meta_key, $meta_value, $prev_value );
$check(true|false) (обязательный)
The current status to allow updating metadata for the given type.
$object_id(int) (обязательный)
ID of the current object for which the meta is being updated.
$meta_key(строка) (обязательный)
The full meta key (including prefix).
$meta_value(строка) (обязательный)
New meta value.
The old meta value.
По умолчанию: ''

Код WPSEO_Meta::remove_meta_if_default() Yoast 19.7.1

public static function remove_meta_if_default( $check, $object_id, $meta_key, $meta_value, $prev_value = '' ) {
	/* If it's one of our meta fields, check against default. */
	if ( isset( self::$fields_index[ $meta_key ] ) && self::meta_value_is_default( $meta_key, $meta_value ) === true ) {
		if ( $prev_value !== '' ) {
			delete_post_meta( $object_id, $meta_key, $prev_value );
		else {
			delete_post_meta( $object_id, $meta_key );

		return true; // Stop saving the value.

	return $check; // Go on with the normal execution (update) in meta.php.