WPSEO_Option::array_filter_merge
Helper method - Combines a fixed array of default values with an options array while filtering out any keys which are not in the defaults array.
Метод класса: WPSEO_Option{}
Хуков нет.
Возвращает
Массив. Combined and filtered options array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->array_filter_merge( $options );
- $options(массив|null)
- Current options. If not set, the option defaults for the
$option_keywill be returned.
По умолчанию:null
Код WPSEO_Option::array_filter_merge() WPSEO Option::array filter merge Yoast 27.8
protected function array_filter_merge( $options = null ) {
$defaults = $this->get_defaults();
if ( ! isset( $options ) || $options === false || $options === [] ) {
return $defaults;
}
$options = (array) $options;
/*
$filtered = array();
if ( $defaults !== array() ) {
foreach ( $defaults as $key => $default_value ) {
// @todo should this walk through array subkeys ?
$filtered[ $key ] = ( isset( $options[ $key ] ) ? $options[ $key ] : $default_value );
}
}
*/
$filtered = array_merge( $defaults, $options );
return $filtered;
}