_add_block_template_info() – Attempts to add custom template information to the template item.

You appear to be a bot. Output may be restricted

Description

Attempts to add custom template information to the template item.

Usage

$array = _add_block_template_info( $template_item );

Parameters

$template_item
( array ) required – Template to add information to (requires 'slug' field).

Returns

array Template item.

Source

File name: wordpress/wp-includes/block-template-utils.php
Lines:

1 to 13 of 13
function _add_block_template_info( $template_item ) {
  if ( ! wp_theme_has_theme_json() ) {
    return $template_item;
  }

  $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
  if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
    $template_item['title']     = $theme_data[ $template_item['slug'] ]['title'];
    $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes'];
  }

  return $template_item;
}
 

 View on GitHub View on Trac