WPSEO_Option_Titles::retain_variable_keys
Make sure that any set option values relating to post_types and/or taxonomies are retained, even when that post_type or taxonomy may not yet have been registered.
{@internal Overrule the abstract class version of this to make sure one extra renamed variable key does not get removed. IMPORTANT: keep this method in line with the parent on which it is based!}}
Метод класса: WPSEO_Option_Titles{}
Хуки из метода
Возвращает
Строку[].
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->retain_variable_keys( $dirty, $clean );
- $dirty(string[]) (обязательный)
- Original option as retrieved from the database.
- $clean(string[]) (обязательный)
- Filtered option where any options which shouldn't be in our option have already been removed and any options which weren't set have been set to their defaults.
Код WPSEO_Option_Titles::retain_variable_keys() WPSEO Option Titles::retain variable keys Yoast 27.4
protected function retain_variable_keys( $dirty, $clean ) {
if ( ( is_array( $this->variable_array_key_patterns ) && $this->variable_array_key_patterns !== [] ) && ( is_array( $dirty ) && $dirty !== [] ) ) {
// Add the extra pattern.
$patterns = $this->variable_array_key_patterns;
$patterns[] = 'tax-hideeditbox-';
/**
* Allow altering the array with variable array key patterns.
*
* @param array $patterns Array with the variable array key patterns.
*/
$patterns = apply_filters( 'wpseo_option_titles_variable_array_key_patterns', $patterns );
foreach ( $dirty as $key => $value ) {
// Do nothing if already in filtered option array.
if ( isset( $clean[ $key ] ) ) {
continue;
}
foreach ( $patterns as $pattern ) {
if ( strpos( $key, $pattern ) === 0 ) {
$clean[ $key ] = $value;
break;
}
}
}
}
return $clean;
}