Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: render_block_core_template_part_post

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
54                 * Fires when a block template part is loaded from a template post stored in the database.
55                 *
56                 * @since 5.9.0
57                 *
58                 * @param string  $template_part_id   The requested template part namespaced to the theme.
59                 * @param array   $attributes         The block attributes.
60                 * @param WP_Post $template_part_post The template part post object.
61                 * @param string  $content            The template part content.
62                 */
63                do_action( 'render_block_core_template_part_post', $template_part_id, $attributes, $template_part_post, $content );
64           } else {
65                // Else, if the template part was provided by the active theme,
66                // render the corresponding file content.
67                $parent_theme_folders        = get_block_theme_folders( get_template() );
68                $child_theme_folders         = get_block_theme_folders( get_stylesheet() );
69                $child_theme_part_file_path  = get_theme_file_path( '/' . $child_theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
70                $parent_theme_part_file_path = get_theme_file_path( '/' . $parent_theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
71                $template_part_file_path     = 0 === validate_file( $attributes['slug'] ) && file_exists( $child_theme_part_file_path ) ? $child_theme_part_file_path : $parent_theme_part_file_path;
72                if ( 0 === validate_file( $attributes['slug'] ) && file_exists( $template_part_file_path ) ) {