Skip to content

Commit

Permalink
FSE: Remove now-obsolete get_template_hierarchy() (#32116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed May 24, 2021
1 parent 412a2c1 commit c746132
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions lib/full-site-editing/template-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,6 @@ function gutenberg_add_template_loader_filters() {

add_action( 'wp_loaded', 'gutenberg_add_template_loader_filters' );

/**
* Get the template hierarchy for a given template type.
*
* Internally, this filters into the "{$type}_template_hierarchy" hook to record the type-specific template hierarchy.
*
* @param string $template_type A template type.
* @return string[] A list of template candidates, in descending order of priority.
*/
function get_template_hierarchy( $template_type ) {
if ( ! in_array( $template_type, gutenberg_get_template_type_slugs(), true ) ) {
return array();
}

$get_template_function = 'get_' . str_replace( '-', '_', $template_type ) . '_template'; // front-page -> get_front_page_template.
$template_hierarchy_filter = str_replace( '-', '', $template_type ) . '_template_hierarchy'; // front-page -> frontpage_template_hierarchy.

$result = array();
$template_hierarchy_filter_function = function( $templates ) use ( &$result ) {
$result = $templates;
return $templates;
};

add_filter( $template_hierarchy_filter, $template_hierarchy_filter_function, 20, 1 );
call_user_func( $get_template_function ); // This invokes template_hierarchy_filter.
remove_filter( $template_hierarchy_filter, $template_hierarchy_filter_function, 20 );

return $result;
}

/**
* Filters into the "{$type}_template" hooks to redirect them to the Full Site Editing template canvas.
*
Expand Down

0 comments on commit c746132

Please sign in to comment.