CodeExplorer WP_Block_Template example
function _build_block_template_result_from_file( $template_file,
$template_type ) { $default_template_types =
get_default_block_template_types();
$template_content =
file_get_contents( $template_file['path'
] );
$theme =
get_stylesheet();
$template =
new WP_Block_Template();
$template->id =
$theme . '//' .
$template_file['slug'
];
$template->theme =
$theme;
$template->content =
_inject_theme_attribute_in_block_template_content( $template_content );
$template->slug =
$template_file['slug'
];
$template->source = 'theme';
$template->type =
$template_type;
$template->title = !
empty( $template_file['title'
] ) ?
$template_file['title'
] :
$template_file['slug'
];
$template->status = 'publish';
$template->has_theme_file = true;
$template->is_custom = true;
$template->modified = null;