PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.3.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.3.3
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 3.3.3, at inc/pattern/pattern.php

61 lines 2.4 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 if($tl['content'] !== 'https://www.blockspare.com/'){
15 array_push($block_pattern_categories,$tl['item']);
16 }
17 }
18
19 foreach($block_pattern_categories as $cat_name){
20 foreach(array_unique($cat_name) as $name){
21 if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
22 register_block_pattern_category(
23 $name,
24 array( 'label' => $name )
25 );
26 }
27 }
28 }
29
30 $empty_template_array = [];
31 foreach($templates_lists as $template){
32 if($template['content'] !== 'https://www.blockspare.com/'){
33 $new_template_array = [];
34 $new_template_array = array(
35 'title'=>$template['name'],
36 'categories'=>$template['item'],
37 'content'=>$template['content']
38 );
39
40 array_push($empty_template_array,$new_template_array);
41 }
42
43 }
44 // Register pattern
45 if(!empty($empty_template_array)){
46 $i=0;
47 foreach($empty_template_array as $new_template){
48 $i++;
49 register_block_pattern(
50 'blockspare/blockspare-pattern-'.$i,
51 $new_template
52
53 );
54 }
55 }
56
57 }
58 add_action('init','blockspare_register_block_pattern');
59 }
60
61