Make WordPress Core

Changeset 48622


Ignore:
Timestamp:
07/26/2020 04:05:39 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename the $id parameter in various category functions for clarity.

See #49542.

File:
1 edited

Legend:

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

    r48586 r48622  
    3838 * @since 4.8.0 The `$visited` parameter was deprecated and renamed to `$deprecated`.
    3939 *
    40  * @param int    $id        Category ID.
    41  * @param bool   $link       Optional. Whether to format with link. Default false.
    42  * @param string $separator  Optional. How to separate categories. Default '/'.
    43  * @param bool   $nicename   Optional. Whether to use nice name for display. Default false.
    44  * @param array  $deprecated Not used.
     40 * @param int    $category_id Category ID.
     41 * @param bool   $link        Optional. Whether to format with link. Default false.
     42 * @param string $separator   Optional. How to separate categories. Default '/'.
     43 * @param bool   $nicename    Optional. Whether to use nice name for display. Default false.
     44 * @param array  $deprecated  Not used.
    4545 * @return string|WP_Error A list of category parents on success, WP_Error on failure.
    4646 */
    47 function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) {
     47function get_category_parents( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) {
    4848
    4949    if ( ! empty( $deprecated ) ) {
     
    5959    );
    6060
    61     return get_term_parents_list( $id, 'category', $args );
     61    return get_term_parents_list( $category_id, 'category', $args );
    6262}
    6363
     
    7272 * @since 0.71
    7373 *
    74  * @param int $id Optional. The post ID. Defaults to current post ID.
     74 * @param int $post_id Optional. The post ID. Defaults to current post ID.
    7575 * @return WP_Term[] Array of WP_Term objects, one for each category assigned to the post.
    7676 */
    77 function get_the_category( $id = false ) {
    78     $categories = get_the_terms( $id, 'category' );
     77function get_the_category( $post_id = false ) {
     78    $categories = get_the_terms( $post_id, 'category' );
    7979    if ( ! $categories || is_wp_error( $categories ) ) {
    8080        $categories = array();
     
    9191     *
    9292     * @since 3.1.0
    93      * @since 4.4.0 Added `$id` parameter.
     93     * @since 4.4.0 Added `$post_id` parameter.
    9494     *
    9595     * @param WP_Term[] $categories An array of categories to return for the post.
    96      * @param int|false $id         ID of the post.
     96     * @param int|false $post_id    ID of the post.
    9797     */
    98     return apply_filters( 'get_the_categories', $categories, $id );
     98    return apply_filters( 'get_the_categories', $categories, $post_id );
    9999}
    100100
     
    133133function get_the_category_list( $separator = '', $parents = '', $post_id = false ) {
    134134    global $wp_rewrite;
     135
    135136    if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) {
    136137        /** This filter is documented in wp-includes/category-template.php */
     
    11411142 * @since 2.3.0
    11421143 *
    1143  * @param int $id Post ID.
     1144 * @param int $post_id Post ID.
    11441145 * @return array|false|WP_Error Array of tag objects on success, false on failure.
    11451146 */
    1146 function get_the_tags( $id = 0 ) {
     1147function get_the_tags( $post_id = 0 ) {
     1148    $terms = get_the_terms( $post_id, 'post_tag' );
    11471149
    11481150    /**
     
    11551157     * @param WP_Term[] $terms An array of tags for the given post.
    11561158     */
    1157     return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
     1159    return apply_filters( 'get_the_tags', $terms );
    11581160}
    11591161
     
    11631165 * @since 2.3.0
    11641166 *
    1165  * @param string $before Optional. String to use before tags.
    1166  * @param string $sep    Optional. String to use between the tags.
    1167  * @param string $after  Optional. String to use after tags.
    1168  * @param int    $id    Optional. Post ID. Defaults to the current post.
     1167 * @param string $before  Optional. String to use before tags.
     1168 * @param string $sep     Optional. String to use between the tags.
     1169 * @param string $after   Optional. String to use after tags.
     1170 * @param int    $post_id Optional. Post ID. Defaults to the current post.
    11691171 * @return string|false|WP_Error A list of tags on success, false if there are no terms, WP_Error on failure.
    11701172 */
    1171 function get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 ) {
     1173function get_the_tag_list( $before = '', $sep = '', $after = '', $post_id = 0 ) {
     1174    $tag_list = get_the_term_list( $post_id, 'post_tag', $before, $sep, $after );
    11721175
    11731176    /**
     
    11801183     * @param string $sep      String to use between the tags.
    11811184     * @param string $after    String to use after tags.
    1182      * @param int    $id       Post ID.
     1185     * @param int    $post_id  Post ID.
    11831186     */
    1184     return apply_filters( 'the_tags', get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id );
     1187    return apply_filters( 'the_tags', $tag_list, $before, $sep, $after, $post_id );
    11851188}
    11861189
     
    12871290 * @since 2.5.0
    12881291 *
    1289  * @param int    $id       Post ID.
     1292 * @param int    $post_id  Post ID.
    12901293 * @param string $taxonomy Taxonomy name.
    12911294 * @param string $before   Optional. Before list.
     
    12941297 * @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
    12951298 */
    1296 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
    1297     $terms = get_the_terms( $id, $taxonomy );
     1299function get_the_term_list( $post_id, $taxonomy, $before = '', $sep = '', $after = '' ) {
     1300    $terms = get_the_terms( $post_id, $taxonomy );
    12981301
    12991302    if ( is_wp_error( $terms ) ) {
     
    14001403 * @since 2.5.0
    14011404 *
    1402  * @param int    $id       Post ID.
     1405 * @param int    $post_id  Post ID.
    14031406 * @param string $taxonomy Taxonomy name.
    14041407 * @param string $before   Optional. Before list.
     
    14071410 * @return void|false Void on success, false on failure.
    14081411 */
    1409 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
    1410     $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
     1412function the_terms( $post_id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
     1413    $term_list = get_the_term_list( $post_id, $taxonomy, $before, $sep, $after );
    14111414
    14121415    if ( is_wp_error( $term_list ) ) {
Note: See TracChangeset for help on using the changeset viewer.