Automattic\WooCommerce\Blocks
BlockPatterns::parse_categories()
Parse prefixed categories from the PTK patterns into the actual WooCommerce categories.
Method of the class: BlockPatterns{}
No Hooks.
Return
Array
. The parsed patterns.
Usage
// private - for code of main (parent) class only $result = $this->parse_categories( $patterns );
- $patterns(array) (required)
- The patterns to parse.
BlockPatterns::parse_categories() BlockPatterns::parse categories code WC 9.4.2
private function parse_categories( array $patterns ) { return array_map( function ( $pattern ) { $pattern['categories'] = array_map( function ( $category ) { foreach ( self::CATEGORIES_PREFIXES as $prefix ) { if ( strpos( $category['title'], $prefix ) !== false ) { $parsed_category = str_replace( $prefix, '', $category['title'] ); $parsed_category = str_replace( '_', ' ', $parsed_category ); $category['title'] = ucfirst( $parsed_category ); } } return $category; }, $pattern['categories'] ); return $pattern; }, $patterns ); }