Automattic\WooCommerce\Blocks
BlockPatterns::get_block_patterns
Gets block pattern data from the cache if available
Метод класса: BlockPatterns{}
Хуков нет.
Возвращает
Массив
. Block pattern data.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_block_patterns();
Код BlockPatterns::get_block_patterns() BlockPatterns::get block patterns WC 9.9.5
private function get_block_patterns() { $pattern_data = $this->get_pattern_cache(); if ( is_array( $pattern_data ) ) { return $pattern_data; } $default_headers = array( 'title' => 'Title', 'slug' => 'Slug', 'description' => 'Description', 'viewportWidth' => 'Viewport Width', 'categories' => 'Categories', 'keywords' => 'Keywords', 'blockTypes' => 'Block Types', 'inserter' => 'Inserter', 'featureFlag' => 'Feature Flag', 'templateTypes' => 'Template Types', ); if ( ! file_exists( $this->patterns_path ) ) { return array(); } $files = glob( $this->patterns_path . '/*.php' ); if ( ! $files ) { return array(); } $patterns = array(); foreach ( $files as $file ) { $data = get_file_data( $file, $default_headers ); // We want to store the relative path in the cache, so we can use it later to register the pattern. $data['source'] = str_replace( $this->patterns_path . '/', '', $file ); $patterns[] = $data; } $this->set_pattern_cache( $patterns ); return $patterns; }