Make WordPress Core


Ignore:
Timestamp:
03/07/2021 12:30:38 PM (6 years ago)
Author:
johnbillion
Message:

Docs: Add examples of possible names for various hooks whose name contains a dynamic portion.

This provides greater discoverability of such hooks in search results on the Code Reference site as well as increased clarity when reading the source.

See #50734, #52628

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/template.php

    r48370 r50505  
    1717 * @since 1.5.0
    1818 *
    19  * @param string $type      Filename without extension.
    20  * @param array  $templates An optional list of template candidates
     19 * @param string   $type      Filename without extension.
     20 * @param string[] $templates An optional list of template candidates.
    2121 * @return string Full path to template file.
    2222 */
     
    3131         * Filters the list of template filenames that are searched for when retrieving a template to use.
    3232         *
     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.
    3335         * The last element in the array should always be the fallback template for this query type.
    3436         *
    35          * Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',
    36          * 'embed', 'home', 'frontpage', 'privacypolicy', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.
     37         * Possible hook names include:
     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`
    3757         *
    3858         * @since 4.7.0
    3959         *
    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.
    4161         */
    4262        $templates = apply_filters( "{$type}_template_hierarchy", $templates );
     
    5171         * This hook also applies to various types of files loaded as part of the Template Hierarchy.
    5272         *
    53          * Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',
    54          * 'embed', 'home', 'frontpage', 'privacypolicy', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.
     73         * Possible hook names include:
     74         *
     75         *  - `404_template`
     76         *  - `archive_template`
     77         *  - `attachment_template`
     78         *  - `author_template`
     79         *  - `category_template`
     80         *  - `date_template`
     81         *  - `embed_template`
     82         *  - `frontpage_template`
     83         *  - `home_template`
     84         *  - `index_template`
     85         *  - `page_template`
     86         *  - `paged_template`
     87         *  - `privacypolicy_template`
     88         *  - `search_template`
     89         *  - `single_template`
     90         *  - `singular_template`
     91         *  - `tag_template`
     92         *  - `taxonomy_template`
    5593         *
    5694         * @since 1.5.0
    5795         * @since 4.8.0 The `$type` and `$templates` parameters were added.
    5896         *
    59          * @param string $template  Path to the template. See locate_template().
    60          * @param string $type      Sanitized filename without extension.
    61          * @param array $templates A list of template candidates, in descending order of priority.
     97         * @param string   $template  Path to the template. See locate_template().
     98         * @param string   $type      Sanitized filename without extension.
     99         * @param string[] $templates A list of template candidates, in descending order of priority.
    62100         */
    63101        return apply_filters( "{$type}_template", $template, $type, $templates );
Note: See TracChangeset for help on using the changeset viewer.