Automattic\WooCommerce\Blueprint\Importers
ImportSetSiteOptions::get_restricted_option_names
Find restricted option names among imported keys.
Method of the class: ImportSetSiteOptions{}
No Hooks.
Returns
array<int|string, bool>. Restricted option names as keys.
Usage
// private - for code of main (parent) class only $result = $this->get_restricted_option_names( $keys ): array;
- $keys(array<int|string>) (required)
- Option keys from the blueprint.
ImportSetSiteOptions::get_restricted_option_names() ImportSetSiteOptions::get restricted option names code WC 11.1.2
private function get_restricted_option_names( array $keys ): array {
$restricted_option_names = array();
$database_candidates = array();
foreach ( $keys as $key ) {
$key = (string) $key;
if ( in_array( self::normalize_option_name( $key ), self::RESTRICTED_OPTIONS, true ) ) {
$restricted_option_names[ $key ] = true;
continue;
}
$database_candidates[] = array(
'original' => $key,
'trimmed' => trim( $key ),
);
}
$candidate_names = array_column( $database_candidates, 'trimmed' );
foreach ( $this->get_collation_restricted_option_indexes( $candidate_names ) as $candidate_index ) {
if ( ! isset( $database_candidates[ $candidate_index ] ) ) {
continue;
}
$restricted_option_names[ $database_candidates[ $candidate_index ]['original'] ] = true;
}
return $restricted_option_names;
}