LLMS_Block_Templates::add_llms_block_templates( WP_Block_Template[] $query_result, array $query, array $template_type = 'wp_template' )
Add lifterlms blocks templates.
Parameters Parameters
- $query_result
-
(WP_Block_Template[]) (Required) Array of found block templates.
- $query
-
(array) (Optional) Arguments to retrieve templates.
- 'slug__in'
(array) List of slugs to include. - 'wp_id'
(int) Post ID of customized template.
- 'slug__in'
- $template_type
-
(array) (Optional) wp_template or wp_template_part.
Default value: 'wp_template'
Return Return
(WP_Block_Template[]) Templates.
Source Source
File: includes/class-llms-block-templates.php
return $query_result;
}
$post_type = $query['post_type'] ?? '';
$slugs = $query['slug__in'] ?? array();
// Retrieve templates.
$templates = $this->block_templates( $slugs, $post_type );
/**
* Remove theme override templates who have a customization in the db from $query_result:
* those template blocks will be already retrieved by our LLMS_Block_Templates::block_templates_from_db().
*/
$query_result = array_values(
array_filter(
$query_result,
function( $template ) use ( $templates ) {
$slugs = wp_list_pluck( $templates, 'slug' );
return ( ! in_array( $template->slug, $slugs, true ) );
}
)
);
return array_merge( $query_result, $templates );
}
/**
* Returns an associative array of template titles.
*
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 6.0.0 | Use llms_is_block_theme() in favor of wp_is_block_theme(). |
| 5.8.0 | Introduced. |