Yoast\WP\SEO\Integrations\Watchers
Option_Titles_Watcher::check_option() public Yoast 1.0
Checks if one of the relevant options has been changed.
{} Это метод класса: Option_Titles_Watcher{}
Хуков нет.
Возвращает
true/false. Whether or not the ancestors are removed.
Использование
$Option_Titles_Watcher = new Option_Titles_Watcher(); $Option_Titles_Watcher->check_option( $old_value, $new_value );
- $old_value(массив) (обязательный)
- The old value of the option.
- $new_value(массив) (обязательный)
- The new value of the option.
Код Option_Titles_Watcher::check_option() Option Titles Watcher::check option Yoast 15.6.2
public function check_option( $old_value, $new_value ) {
// If this is the first time saving the option, thus when value is false.
if ( $old_value === false ) {
$old_value = [];
}
if ( ! \is_array( $old_value ) || ! \is_array( $new_value ) ) {
return false;
}
$relevant_keys = $this->get_relevant_keys();
if ( empty( $relevant_keys ) ) {
return false;
}
$post_types = [];
foreach ( $relevant_keys as $post_type => $relevant_option ) {
// If both values aren't set they haven't changed.
if ( ! isset( $old_value[ $relevant_option ] ) && ! isset( $new_value[ $relevant_option ] ) ) {
continue;
}
if ( $old_value[ $relevant_option ] !== $new_value[ $relevant_option ] ) {
$post_types[] = $post_type;
}
}
return $this->delete_ancestors( $post_types );
}