diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/category-template.php --- a/wp/wp-includes/category-template.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/category-template.php Tue Dec 15 13:49:49 2020 +0100 @@ -8,9 +8,10 @@ */ /** - * Retrieve category link URL. + * Retrieves category link URL. * * @since 1.0.0 + * * @see get_term_link() * * @param int|object $category Category ID or object. @@ -31,19 +32,19 @@ } /** - * Retrieve category parents with separator. + * Retrieves category parents with separator. * * @since 1.2.0 * @since 4.8.0 The `$visited` parameter was deprecated and renamed to `$deprecated`. * - * @param int $id Category ID. - * @param bool $link Optional, default is false. Whether to format with link. - * @param string $separator Optional, default is '/'. How to separate categories. - * @param bool $nicename Optional, default is false. Whether to use nice name for display. - * @param array $deprecated Not used. + * @param int $category_id Category ID. + * @param bool $link Optional. Whether to format with link. Default false. + * @param string $separator Optional. How to separate categories. Default '/'. + * @param bool $nicename Optional. Whether to use nice name for display. Default false. + * @param array $deprecated Not used. * @return string|WP_Error A list of category parents on success, WP_Error on failure. */ -function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) { +function get_category_parents( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '4.8.0' ); @@ -57,24 +58,24 @@ 'format' => $format, ); - return get_term_parents_list( $id, 'category', $args ); + return get_term_parents_list( $category_id, 'category', $args ); } /** - * Retrieve post categories. + * Retrieves post categories. * - * This tag may be used outside The Loop by passing a post id as the parameter. + * This tag may be used outside The Loop by passing a post ID as the parameter. * * Note: This function only returns results from the default "category" taxonomy. * For custom taxonomies use get_the_terms(). * * @since 0.71 * - * @param int $id Optional, default to current post ID. The post ID. + * @param int $post_id Optional. The post ID. Defaults to current post ID. * @return WP_Term[] Array of WP_Term objects, one for each category assigned to the post. */ -function get_the_category( $id = false ) { - $categories = get_the_terms( $id, 'category' ); +function get_the_category( $post_id = false ) { + $categories = get_the_terms( $post_id, 'category' ); if ( ! $categories || is_wp_error( $categories ) ) { $categories = array(); } @@ -89,23 +90,23 @@ * Filters the array of categories to return for a post. * * @since 3.1.0 - * @since 4.4.0 Added `$id` parameter. + * @since 4.4.0 Added `$post_id` parameter. * * @param WP_Term[] $categories An array of categories to return for the post. - * @param int|false $id ID of the post. + * @param int|false $post_id ID of the post. */ - return apply_filters( 'get_the_categories', $categories, $id ); + return apply_filters( 'get_the_categories', $categories, $post_id ); } /** - * Retrieve category name based on category ID. + * Retrieves category name based on category ID. * * @since 0.71 * * @param int $cat_ID Category ID. * @return string|WP_Error Category name on success, WP_Error on failure. */ -function get_the_category_by_ID( $cat_ID ) { +function get_the_category_by_ID( $cat_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $cat_ID = (int) $cat_ID; $category = get_term( $cat_ID ); @@ -117,20 +118,28 @@ } /** - * Retrieve category list for a post in either HTML list or custom format. + * Retrieves category list for a post in either HTML list or custom format. + * + * Generally used for quick, delimited (e.g. comma-separated) lists of categories, + * as part of a post entry meta. + * + * For a more powerful, list-based function, see wp_list_categories(). * * @since 1.5.1 * - * @global WP_Rewrite $wp_rewrite + * @see wp_list_categories() + * + * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param string $separator Optional. Separator between the categories. By default, the links are placed * in an unordered list. An empty string will result in the default behavior. - * @param string $parents Optional. How to display the parents. - * @param int $post_id Optional. Post ID to retrieve categories. - * @return string + * @param string $parents Optional. How to display the parents. + * @param int $post_id Optional. Post ID to retrieve categories. + * @return string Category list for a post. */ function get_the_category_list( $separator = '', $parents = '', $post_id = false ) { global $wp_rewrite; + if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) { /** This filter is documented in wp-includes/category-template.php */ return apply_filters( 'the_category', '', $separator, $parents ); @@ -142,8 +151,8 @@ * @since 4.4.0 * * @param WP_Term[] $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. + * @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 ); @@ -155,7 +164,7 @@ $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"'; $thelist = ''; - if ( '' == $separator ) { + if ( '' === $separator ) { $thelist .= '