| 1 |
<?php |
| 2 |
namespace Bricksable\Classes; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
class Bricksable_Helpers { |
| 9 |
|
| 10 |
/** |
| 11 |
* Get Bricks Templates |
| 12 |
* |
| 13 |
* @param string $exclude_template_id Bricks Template ID. |
| 14 |
* @return array |
| 15 |
* @since 1.2.5 |
| 16 |
*/ |
| 17 |
public static function get_templates_list( $exclude_template_id = '' ) { |
| 18 |
$templates = get_posts( |
| 19 |
array( |
| 20 |
'post_type' => BRICKS_DB_TEMPLATE_SLUG, |
| 21 |
'posts_per_page' => -1, |
| 22 |
'meta_query' => array( |
| 23 |
array( |
| 24 |
'key' => BRICKS_DB_TEMPLATE_TYPE, |
| 25 |
'value' => array( 'section', 'content' ), |
| 26 |
), |
| 27 |
), |
| 28 |
'post_status' => 'publish', |
| 29 |
) |
| 30 |
); |
| 31 |
|
| 32 |
$list = array(); |
| 33 |
|
| 34 |
foreach ( $templates as $template ) { |
| 35 |
if ( $exclude_template_id === $template->ID ) { |
| 36 |
continue; |
| 37 |
} |
| 38 |
|
| 39 |
$list[ $template->ID ] = $template->post_title; |
| 40 |
} |
| 41 |
|
| 42 |
return $list; |
| 43 |
} |
| 44 |
} |
| 45 |
|