WPSEO_Meta::remove_meta_if_default()
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.
- $prev_value(строка)
- The old meta value.
По умолчанию: ''
Код WPSEO_Meta::remove_meta_if_default() WPSEO Meta::remove meta if default Yoast 24.9
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. }