| 1 |
<?php |
| 2 |
/** |
| 3 |
* Register layouts and sections for the Layout block. |
| 4 |
* |
| 5 |
* @package Blockspare |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Blockspare\Layouts; |
| 9 |
include BLOCKSPARE_PLUGIN_DIR .'inc/template-library/init.php'; |
| 10 |
add_action( 'plugins_loaded', __NAMESPACE__ . '\register_components', 11 ); |
| 11 |
/** |
| 12 |
* Registers section and layout components. |
| 13 |
* |
| 14 |
* @since 2.0 |
| 15 |
*/ |
| 16 |
function register_components() { |
| 17 |
$blocks_lists = array(); |
| 18 |
|
| 19 |
$templates = apply_filters( 'blockspare_template_library', $blocks_lists ); |
| 20 |
$get_templates = get_posts(array('post_type'=>'bs_templates','posts_per_page'=>-1)); |
| 21 |
if(!empty($get_templates)){ |
| 22 |
foreach($get_templates as $res){ |
| 23 |
//$get_meta = get_post_meta($res->ID,'bs_template_category'); |
| 24 |
$array=array( |
| 25 |
'type' => 'templates', |
| 26 |
//'item' =>($get_meta)?$get_meta:$res->post_title, |
| 27 |
'item' =>[$res->post_title], |
| 28 |
'key' => 'bs_template_'.$res->ID, |
| 29 |
'name' =>$res->post_title, |
| 30 |
'blockLink'=> get_the_permalink($res->ID), |
| 31 |
'content' =>$res->post_content |
| 32 |
); |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
array_push($templates,$array); |
| 37 |
|
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
if(!empty($templates)){ |
| 44 |
foreach($templates as $temp){ |
| 45 |
|
| 46 |
blockspare_register_layout_component($temp); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|