PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 2.6.1
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v2.6.1
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / pattern / pattern.php

pattern.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 2.6.1, at inc/pattern/pattern.php

57 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 include BLOCKSPARE_BASE_DIR .'/inc/template-library/init.php';
3 if(!function_exists('blockspare_register_block_pattern')){
4 function blockspare_register_block_pattern() {
5
6 //Get all blocks from template library
7 $blocks_lists = array();
8
9 $templates_lists = apply_filters( 'blockspare_template_library', $blocks_lists );
10
11 $templates_lists = apply_filters( 'blockspare_template_library', $blocks_lists );
12 $block_pattern_categories =[];
13 foreach($templates_lists as $tl){
14 array_push($block_pattern_categories,$tl['item']);
15 }
16
17 foreach($block_pattern_categories as $cat_name){
18 foreach(array_unique($cat_name) as $name){
19 if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
20 register_block_pattern_category(
21 $name,
22 array( 'label' => $name )
23 );
24 }
25 }
26 }
27
28 $empty_template_array = [];
29 foreach($templates_lists as $template){
30 $new_template_array = [];
31 $new_template_array = array(
32 'title'=>$template['name'],
33 'categories'=>$template['item'],
34 'content'=>$template['content']
35 );
36
37 array_push($empty_template_array,$new_template_array);
38
39 }
40 // Register pattern
41 if(!empty($empty_template_array)){
42 $i=0;
43 foreach($empty_template_array as $new_template){
44 $i++;
45 register_block_pattern(
46 'blockspare/blockspare-pattern-'.$i,
47 $new_template
48
49 );
50 }
51 }
52
53 }
54 add_action('init','blockspare_register_block_pattern');
55 }
56
57