wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
get_block_file_template › WordPress Function
Seit5.9.0
Veraltetn/v
› get_block_file_template ( $id, $template_type = 'wp_template' )
Parameter: (2) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Retrieves a unified template object based on a theme file.
This is a fallback of get_block_template(), used when no templates are found in the database.Ähnliche Funktionen: get_block_template, get_block_templates, _get_block_template_file, get_single_template, get_home_template
Quellcode
function get_block_file_template( $id, $template_type = 'wp_template' ) { /** * Filters the block template object before the theme file discovery takes place. * * Return a non-null value to bypass the WordPress theme file discovery. * * @since 5.9.0 * * @param WP_Block_Template|null $block_template Return block template object to short-circuit the default query, * or null to allow WP to run its normal queries. * @param string $id Template unique identifier (example: 'theme_slug//template_slug'). * @param string $template_type Template type. Either 'wp_template' or 'wp_template_part'. */ $block_template = apply_filters( 'pre_get_block_file_template', null, $id, $template_type ); if ( ! is_null( $block_template ) ) { return $block_template; } $parts = explode( '//', $id, 2 ); if ( count( $parts ) < 2 ) { /** This filter is documented in wp-includes/block-template-utils.php */ return apply_filters( 'get_block_file_template', null, $id, $template_type ); } list( $theme, $slug ) = $parts; if ( get_stylesheet() === $theme ) { $template_file = _get_block_template_file( $template_type, $slug ); if ( null !== $template_file ) { $block_template = _build_block_template_result_from_file( $template_file, $template_type ); /** This filter is documented in wp-includes/block-template-utils.php */ return apply_filters( 'get_block_file_template', $block_template, $id, $template_type ); } } $block_template = WP_Block_Templates_Registry::get_instance()->get_by_slug( $slug ); /** * Filters the block template object after it has been (potentially) fetched from the theme file. * * @since 5.9.0 * * @param WP_Block_Template|null $block_template The found block template, or null if there is none. * @param string $id Template unique identifier (example: 'theme_slug//template_slug'). * @param string $template_type Template type. Either 'wp_template' or 'wp_template_part'. */ return apply_filters( 'get_block_file_template', $block_template, $id, $template_type ); }