wp/wp-includes/template.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    14  * the use of locate_template(). Allows for more generic template location
    14  * the use of locate_template(). Allows for more generic template location
    15  * without the use of the other get_*_template() functions.
    15  * without the use of the other get_*_template() functions.
    16  *
    16  *
    17  * @since 1.5.0
    17  * @since 1.5.0
    18  *
    18  *
    19  * @param string $type      Filename without extension.
    19  * @param string   $type      Filename without extension.
    20  * @param array  $templates An optional list of template candidates
    20  * @param string[] $templates An optional list of template candidates.
    21  * @return string Full path to template file.
    21  * @return string Full path to template file.
    22  */
    22  */
    23 function get_query_template( $type, $templates = array() ) {
    23 function get_query_template( $type, $templates = array() ) {
    24 	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
    24 	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
    25 
    25 
    28 	}
    28 	}
    29 
    29 
    30 	/**
    30 	/**
    31 	 * Filters the list of template filenames that are searched for when retrieving a template to use.
    31 	 * Filters the list of template filenames that are searched for when retrieving a template to use.
    32 	 *
    32 	 *
       
    33 	 * The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file
       
    34 	 * extension and any non-alphanumeric characters delimiting words -- of the file to load.
    33 	 * The last element in the array should always be the fallback template for this query type.
    35 	 * The last element in the array should always be the fallback template for this query type.
    34 	 *
    36 	 *
    35 	 * Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',
    37 	 * Possible hook names include:
    36 	 * 'embed', 'home', 'frontpage', 'privacypolicy', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.
    38 	 *
       
    39 	 *  - `404_template_hierarchy`
       
    40 	 *  - `archive_template_hierarchy`
       
    41 	 *  - `attachment_template_hierarchy`
       
    42 	 *  - `author_template_hierarchy`
       
    43 	 *  - `category_template_hierarchy`
       
    44 	 *  - `date_template_hierarchy`
       
    45 	 *  - `embed_template_hierarchy`
       
    46 	 *  - `frontpage_template_hierarchy`
       
    47 	 *  - `home_template_hierarchy`
       
    48 	 *  - `index_template_hierarchy`
       
    49 	 *  - `page_template_hierarchy`
       
    50 	 *  - `paged_template_hierarchy`
       
    51 	 *  - `privacypolicy_template_hierarchy`
       
    52 	 *  - `search_template_hierarchy`
       
    53 	 *  - `single_template_hierarchy`
       
    54 	 *  - `singular_template_hierarchy`
       
    55 	 *  - `tag_template_hierarchy`
       
    56 	 *  - `taxonomy_template_hierarchy`
    37 	 *
    57 	 *
    38 	 * @since 4.7.0
    58 	 * @since 4.7.0
    39 	 *
    59 	 *
    40 	 * @param array $templates A list of template candidates, in descending order of priority.
    60 	 * @param string[] $templates A list of template candidates, in descending order of priority.
    41 	 */
    61 	 */
    42 	$templates = apply_filters( "{$type}_template_hierarchy", $templates );
    62 	$templates = apply_filters( "{$type}_template_hierarchy", $templates );
    43 
    63 
    44 	$template = locate_template( $templates );
    64 	$template = locate_template( $templates );
       
    65 
       
    66 	$template = locate_block_template( $template, $type, $templates );
    45 
    67 
    46 	/**
    68 	/**
    47 	 * Filters the path of the queried template by type.
    69 	 * Filters the path of the queried template by type.
    48 	 *
    70 	 *
    49 	 * The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file
    71 	 * The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file
    50 	 * extension and any non-alphanumeric characters delimiting words -- of the file to load.
    72 	 * extension and any non-alphanumeric characters delimiting words -- of the file to load.
    51 	 * This hook also applies to various types of files loaded as part of the Template Hierarchy.
    73 	 * This hook also applies to various types of files loaded as part of the Template Hierarchy.
    52 	 *
    74 	 *
    53 	 * Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',
    75 	 * Possible hook names include:
    54 	 * 'embed', 'home', 'frontpage', 'privacypolicy', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.
    76 	 *
       
    77 	 *  - `404_template`
       
    78 	 *  - `archive_template`
       
    79 	 *  - `attachment_template`
       
    80 	 *  - `author_template`
       
    81 	 *  - `category_template`
       
    82 	 *  - `date_template`
       
    83 	 *  - `embed_template`
       
    84 	 *  - `frontpage_template`
       
    85 	 *  - `home_template`
       
    86 	 *  - `index_template`
       
    87 	 *  - `page_template`
       
    88 	 *  - `paged_template`
       
    89 	 *  - `privacypolicy_template`
       
    90 	 *  - `search_template`
       
    91 	 *  - `single_template`
       
    92 	 *  - `singular_template`
       
    93 	 *  - `tag_template`
       
    94 	 *  - `taxonomy_template`
    55 	 *
    95 	 *
    56 	 * @since 1.5.0
    96 	 * @since 1.5.0
    57 	 * @since 4.8.0 The `$type` and `$templates` parameters were added.
    97 	 * @since 4.8.0 The `$type` and `$templates` parameters were added.
    58 	 *
    98 	 *
    59 	 * @param string $template  Path to the template. See locate_template().
    99 	 * @param string   $template  Path to the template. See locate_template().
    60 	 * @param string $type      Sanitized filename without extension.
   100 	 * @param string   $type      Sanitized filename without extension.
    61 	 * @param array  $templates A list of template candidates, in descending order of priority.
   101 	 * @param string[] $templates A list of template candidates, in descending order of priority.
    62 	 */
   102 	 */
    63 	return apply_filters( "{$type}_template", $template, $type, $templates );
   103 	return apply_filters( "{$type}_template", $template, $type, $templates );
    64 }
   104 }
    65 
   105 
    66 /**
   106 /**