WordPress.org

Make WordPress Core

Changeset 34625


Ignore:
Timestamp:
09/27/2015 02:21:43 AM (5 years ago)
Author:
boonebgorges
Message:

Introduce 'the_category_list' filter.

Used to filter categories as structured data, before building markup in
get_the_category_list().

We use this filter in addition to upstream filters (such as
'get_the_categories'`) because those upstream filters are used in numerous
contexts, while 'the_category_list' is always used for generating markup
for display.

Props KevinB, ericlewis, SergeyBiryukov, DrewAPicture.
Fixes #9227.

File:
1 edited

Legend:

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

    r34624 r34625  
    176176    }
    177177
    178     $categories = get_the_category( $post_id );
     178    /**
     179     * Filter the categories before building the category list.
     180     *
     181     * @since 4.4.0
     182     *
     183     * @param array    $categories An array of the post's categories.
     184     * @param int|bool $post_id    ID of the post we're retrieving categories for. When `false`, we assume the
     185     *                             current post in the loop.
     186     */
     187    $categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id );
     188
    179189    if ( empty( $categories ) ) {
    180190        /** This filter is documented in wp-includes/category-template.php */
Note: See TracChangeset for help on using the changeset viewer.