WordPress.org

Make WordPress Core

Changeset 48140


Ignore:
Timestamp:
06/23/2020 01:51:03 PM (7 weeks ago)
Author:
SergeyBiryukov
Message:

Comments: Remove wp_get_include_unapproved_comments_argument() for now.

The function seems too specific and low-level for an abstraction, is only used in two places, and does not provide a significant benefit in terms of reducing code duplication.

Follow-up to [48133].

See #8973.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r48133 r48140  
    13311331 *
    13321332 * @since 1.5.0
    1333  * @since 5.5.0 Removed the need to use the $user_ID global.
    13341333 *
    13351334 * @global WP_Query   $wp_query         WordPress Query object.
     
    13971396    }
    13981397
    1399     $include_unapproved = wp_get_include_unapproved_comments_argument();
    1400     if ( $include_unapproved ) {
    1401         $comment_args['include_unapproved'] = $include_unapproved;
     1398    if ( is_user_logged_in() ) {
     1399        $comment_args['include_unapproved'] = array( get_current_user_id() );
     1400    } else {
     1401        $unapproved_email = wp_get_unapproved_comment_author_email();
     1402
     1403        if ( $unapproved_email ) {
     1404            $comment_args['include_unapproved'] = array( $unapproved_email );
     1405        }
    14021406    }
    14031407
     
    20982102
    20992103                if ( is_user_logged_in() ) {
    2100                     $comment_args['include_unapproved'] = get_current_user_id();
     2104                    $comment_args['include_unapproved'] = array( get_current_user_id() );
    21012105                } else {
    21022106                    $unapproved_email = wp_get_unapproved_comment_author_email();
  • trunk/src/wp-includes/comment.php

    r48133 r48140  
    10551055 * @param array $args {
    10561056 *      Array of optional arguments.
    1057  *      @type string     $type      Limit paginated comments to those matching a given type. Accepts 'comment',
    1058  *                                  'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'.
    1059  *                                  Default is 'all'.
    1060  *      @type int        $per_page  Per-page count to use when calculating pagination. Defaults to the value of the
    1061  *                                  'comments_per_page' option.
    1062  *      @type int|string $max_depth If greater than 1, comment page will be determined for the top-level parent of
    1063  *                                  `$comment_ID`. Defaults to the value of the 'thread_comments_depth' option.
     1057 *      @type string     $type      Limit paginated comments to those matching a given type.
     1058 *                                  Accepts 'comment', 'trackback', 'pingback', 'pings'
     1059 *                                  (trackbacks and pingbacks), or 'all'. Default 'all'.
     1060 *      @type int        $per_page  Per-page count to use when calculating pagination.
     1061 *                                  Defaults to the value of the 'comments_per_page' option.
     1062 *      @type int|string $max_depth If greater than 1, comment page will be determined
     1063 *                                  for the top-level parent `$comment_ID`.
     1064 *                                  Defaults to the value of the 'thread_comments_depth' option.
    10641065 * } *
    10651066 * @return int|null Comment page number or null on error.
     
    11331134        );
    11341135
    1135         $include_unapproved = wp_get_include_unapproved_comments_argument();
    1136         if ( $include_unapproved ) {
    1137             $comment_args['include_unapproved'] = $include_unapproved;
     1136        if ( is_user_logged_in() ) {
     1137            $comment_args['include_unapproved'] = array( get_current_user_id() );
     1138        } else {
     1139            $unapproved_email = wp_get_unapproved_comment_author_email();
     1140
     1141            if ( $unapproved_email ) {
     1142                $comment_args['include_unapproved'] = array( $unapproved_email );
     1143            }
    11381144        }
    11391145
     
    11481154         *     Array of WP_Comment_Query arguments.
    11491155         *
    1150          *     @type string $type               Limit paginated comments to those matching a given type. Accepts 'comment',
    1151          *                                      'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'.
    1152          *                                      Default is 'all'.
     1156         *     @type string $type               Limit paginated comments to those matching a given type.
     1157         *                                      Accepts 'comment', 'trackback', 'pingback', 'pings'
     1158         *                                      (trackbacks and pingbacks), or 'all'. Default 'all'.
    11531159         *     @type int    $post_id            ID of the post.
    11541160         *     @type string $fields             Comment fields to return.
    1155          *     @type bool   $count              Whether to return a comment count (true) or array of
    1156          *                                      comment objects (false)
     1161         *     @type bool   $count              Whether to return a comment count (true) or array
     1162         *                                      of comment objects (false).
    11571163         *     @type string $status             Comment status.
    11581164         *     @type int    $parent             Parent ID of comment to retrieve children of.
     
    11621168         * }
    11631169         */
    1164         $comment_args        = apply_filters( 'get_page_of_comment_query_args', $comment_args );
     1170        $comment_args = apply_filters( 'get_page_of_comment_query_args', $comment_args );
     1171
    11651172        $comment_query       = new WP_Comment_Query();
    11661173        $older_comment_count = $comment_query->query( $comment_args );
     
    19251932
    19261933    return $commenter_email;
    1927 }
    1928 
    1929 /**
    1930  * Get include unapproved comments query argument.
    1931  *
    1932  * Used to include unapproved comments of currrent commenters to
    1933  * keep them informed their comments were successfully saved.
    1934  *
    1935  * @since 5.5.0
    1936  *
    1937  * @return array The unapproved comments query argument.
    1938  */
    1939 function wp_get_include_unapproved_comments_argument() {
    1940     $user_id            = get_current_user_id();
    1941     $include_unapproved = array();
    1942 
    1943     if ( $user_id ) {
    1944         $include_unapproved = array( $user_id );
    1945     } else {
    1946         $unapproved_email = wp_get_unapproved_comment_author_email();
    1947 
    1948         if ( $unapproved_email ) {
    1949             $include_unapproved = array( $unapproved_email );
    1950         }
    1951     }
    1952 
    1953     return $include_unapproved;
    19541934}
    19551935
Note: See TracChangeset for help on using the changeset viewer.