Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Block_Templates::build_template_result_from_post( WP_Post $post )
Build a unified template object based on a WP_Post object.
Parameters Parameters
- $post
-
(WP_Post) (Required) Template post.
Return Return
(WP_Block_Template|WP_Error) Template.
Source Source
File: includes/class-llms-block-templates.php
private function build_template_result_from_post( $post ) { $terms = get_the_terms( $post, 'wp_theme' ); if ( is_wp_error( $terms ) ) { return $terms; } if ( ! $terms ) { return new \WP_Error( 'template_missing_theme', __( 'No theme is defined for this template.', 'lifterlms' ) ); } $theme = $terms[0]->name; $template = new WP_Block_Template(); $template->wp_id = $post->ID; $template->id = $theme . '//' . $post->post_name; $template->theme = $theme; $template->content = $post->post_content; $template->slug = $post->post_name; $template->source = 'custom'; $template->type = $post->post_type; $template->description = $post->post_excerpt; $template->title = $post->post_title; $template->status = $post->post_status; $template->has_theme_file = true; $template->is_custom = false; $template->post_types = array(); // Don't appear in any Edit Post template selector dropdown. /** * Set the 'plugin' origin * if it doesn't come from from the current theme (or its parent). */ if ( ! in_array( $theme, array( get_template(), get_stylesheet() ), true ) ) { $template->origin = 'plugin'; } return $template; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |