[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> block-template-utils.php (summary)

Utilities used to fetch and create templates and template parts.

File Size: 1024 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 22 functions

  get_block_theme_folders()
  get_allowed_block_template_part_areas()
  get_default_block_template_types()
  _filter_block_template_part_area()
  _get_block_templates_paths()
  _get_block_template_file()
  _get_block_templates_files()
  _add_block_template_info()
  _add_block_template_part_area_info()
  _flatten_blocks()
  _inject_theme_attribute_in_block_template_content()
  _remove_theme_attribute_in_block_template_content()
  _build_block_template_result_from_file()
  _build_block_template_result_from_post()
  get_block_templates()
  get_block_template()
  get_block_file_template()
  block_template_part()
  block_header_area()
  block_footer_area()
  wp_is_theme_directory_ignored()
  wp_generate_block_templates_export_file()

Functions
Functions that are not part of a class:

get_block_theme_folders( $theme_stylesheet = null )   X-Ref
For backward compatibility reasons,
block themes might be using block-templates or block-template-parts,
this function ensures we fallback to these folders properly.

return: string[] {
param: string $theme_stylesheet The stylesheet. Default is to leverage the main theme root.
since: 5.9.0

get_allowed_block_template_part_areas()   X-Ref
Returns a filtered list of allowed area values for template parts.

return: array The supported template part area values.
since: 5.9.0

get_default_block_template_types()   X-Ref
Returns a filtered list of default template types, containing their
localized titles and descriptions.

return: array The default template types.
since: 5.9.0

_filter_block_template_part_area( $type )   X-Ref
Checks whether the input 'area' is a supported value.
Returns the input if supported, otherwise returns the 'uncategorized' value.

return: string Input if supported, else the uncategorized value.
param: string $type Template part area name.
since: 5.9.0

_get_block_templates_paths( $base_directory )   X-Ref
No description

_get_block_template_file( $template_type, $slug )   X-Ref
Retrieves the template file from the theme for a given slug.

return: array|null Template.
param: string $template_type 'wp_template' or 'wp_template_part'.
param: string $slug          Template slug.
since: 5.9.0

_get_block_templates_files( $template_type )   X-Ref
Retrieves the template files from the theme.

return: array Template.
param: string $template_type 'wp_template' or 'wp_template_part'.
since: 5.9.0

_add_block_template_info( $template_item )   X-Ref
Attempts to add custom template information to the template item.

return: array Template item.
param: array $template_item Template to add information to (requires 'slug' field).
since: 5.9.0

_add_block_template_part_area_info( $template_info )   X-Ref
Attempts to add the template part's area information to the input template.

return: array Template info.
param: array $template_info Template to add information to (requires 'type' and 'slug' fields).
since: 5.9.0

_flatten_blocks( &$blocks )   X-Ref
Returns an array containing the references of
the passed blocks and their inner blocks.

return: array block references to the passed blocks and their inner blocks.
param: array $blocks array of blocks.
since: 5.9.0

_inject_theme_attribute_in_block_template_content( $template_content )   X-Ref
Parses wp_template content and injects the active theme's
stylesheet as a theme attribute into each wp_template_part

return: string Updated 'wp_template' content.
param: string $template_content serialized wp_template content.
since: 5.9.0

_remove_theme_attribute_in_block_template_content( $template_content )   X-Ref
Parses a block template and removes the theme attribute from each template part.

return: string Updated block template content.
param: string $template_content Serialized block template content.
since: 5.9.0

_build_block_template_result_from_file( $template_file, $template_type )   X-Ref
Build a unified template object based on a theme file.

return: WP_Block_Template Template.
param: array  $template_file Theme file.
param: string $template_type 'wp_template' or 'wp_template_part'.
since: 5.9.0

_build_block_template_result_from_post( $post )   X-Ref
Build a unified template object based a post Object.

return: WP_Block_Template|WP_Error Template.
param: WP_Post $post Template post.
since: 5.9.0

get_block_templates( $query = array()   X-Ref
Retrieves a list of unified template objects based on a query.

return: array Templates.
param: array  $query {
param: string $template_type 'wp_template' or 'wp_template_part'.
since: 5.8.0

get_block_template( $id, $template_type = 'wp_template' )   X-Ref
Retrieves a single unified template object using its id.

return: WP_Block_Template|null Template.
param: string $id            Template unique identifier (example: theme_slug//template_slug).
param: string $template_type Optional. Template type: `'wp_template'` or '`wp_template_part'`.
since: 5.8.0

get_block_file_template( $id, $template_type = 'wp_template' )   X-Ref
Retrieves a single unified template object using its id.

return: WP_Block_Template|null The found block template, or null if there isn't one.
param: string $id            Template unique identifier (example: theme_slug//template_slug).
param: string $template_type Optional. Template type: `'wp_template'` or '`wp_template_part'`.
since: 5.9.0

block_template_part( $part )   X-Ref
Print a template-part.

param: string $part The template-part to print. Use "header" or "footer".
since: 5.9.0

block_header_area()   X-Ref
Print the header template-part.

since: 5.9.0

block_footer_area()   X-Ref
Print the footer template-part.

since: 5.9.0

wp_is_theme_directory_ignored( $path )   X-Ref
Filters theme directories that should be ignored during export.

return: Bool Whether this file is in an ignored directory.
param: string $path The path of the file in the theme.
since: 6.0.0

wp_generate_block_templates_export_file()   X-Ref
Creates an export of the current templates and
template parts from the site editor at the
specified path in a ZIP file.

return: WP_Error|string Path of the ZIP file or error on failure.
since: 5.9.0
since: 6.0.0 Adds the whole theme to the export archive.



Generated: Sat Apr 27 01:00:02 2024 Cross-referenced by PHPXref 0.7.1