From c243d7070e83fa7d440d395636386573f5f7b688 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sun, 27 Sep 2015 02:22:24 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@34625 git-svn-id: http://core.svn.wordpress.org/trunk@34589 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/category-template.php | 12 +++++++++++- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 019854d127..355b46b2e9 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -175,7 +175,17 @@ function get_the_category_list( $separator = '', $parents='', $post_id = false ) return apply_filters( 'the_category', '', $separator, $parents ); } - $categories = get_the_category( $post_id ); + /** + * Filter the categories before building the category list. + * + * @since 4.4.0 + * + * @param array $categories An array of the post's categories. + * @param int|bool $post_id ID of the post we're retrieving categories for. When `false`, we assume the + * current post in the loop. + */ + $categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id ); + if ( empty( $categories ) ) { /** This filter is documented in wp-includes/category-template.php */ return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 4870ab0868..42c8c3ba31 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34624'; +$wp_version = '4.4-alpha-34625'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.