Automattic\WooCommerce\Blocks\Patterns
PTKPatternsStore::map_categories
Change the categories of the patterns to match the ones used in the CYS flow
Method of the class: PTKPatternsStore{}
No Hooks.
Returns
Array. The patterns with the categories mapped.
Usage
// private - for code of main (parent) class only $result = $this->map_categories( $patterns );
- $patterns(array) (required)
- The patterns to map categories for.
PTKPatternsStore::map_categories() PTKPatternsStore::map categories code WC 10.6.2
private function map_categories( array $patterns ) {
return array_map(
function ( $pattern ) {
if ( isset( $pattern['categories'] ) ) {
foreach ( $pattern['categories'] as $key => $category ) {
if ( isset( $category['slug'] ) && isset( self::CATEGORY_MAPPING[ $key ] ) ) {
$new_category = self::CATEGORY_MAPPING[ $key ];
unset( $pattern['categories'][ $key ] );
$pattern['categories'][ $new_category ]['slug'] = $new_category;
$pattern['categories'][ $new_category ]['title'] = ucfirst( $new_category );
}
}
}
return $pattern;
},
$patterns
);
}