Changeset 34535 for trunk/src/wp-includes/comment-functions.php
- Timestamp:
- 09/25/2015 05:10:40 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-functions.php
r34534 r34535 822 822 * 823 823 * @global wpdb $wpdb 824 * 825 * @param int $comment_ID Comment ID. 826 * @param array $args Optional args. 824 * @param int $comment_ID Comment ID. 825 * @param array $args { 826 * Array of optional arguments. 827 * @type string $type Limit paginated comments to those matching a given type. Accepts 'comment', 828 * 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'. 829 * Default is 'all'. 830 * @type int $per_page Per-page count to use when calculating pagination. Defaults to the value of the 831 * 'comments_per_page' option. 832 * @type int|string $max_depth If greater than 1, comment page will be determined for the top-level parent of 833 * `$comment_ID`. Defaults to the value of the 'thread_comments_depth' option. 834 * } * 827 835 * @return int|null Comment page number or null on error. 828 836 */ … … 856 864 return get_page_of_comment( $comment->comment_parent, $args ); 857 865 858 $allowedtypes = array( 859 'comment' => '', 860 'pingback' => 'pingback', 861 'trackback' => 'trackback', 866 $comment_args = array( 867 'type' => $args['type'], 868 'post_ID' => $comment->comment_post_ID, 869 'fields' => 'ids', 870 'status' => 'approve', 871 'date_query' => array( 872 array( 873 'column' => "$wpdb->comments.comment_date_gmt", 874 'before' => $comment->comment_date_gmt, 875 ) 876 ), 862 877 ); 863 878 864 $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : ''; 865 866 // Count comments older than this one 867 $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); 879 $older_comment_ids = get_comments( $comment_args ); 880 $older_comment_count = count( $older_comment_ids ); 868 881 869 882 // No older comments? Then it's page #1. 870 if ( 0 == $older coms)883 if ( 0 == $older_comment_count ) 871 884 return 1; 872 885 873 886 // Divide comments older than this one by comments per page to get this comment's page number 874 return ceil( ( $older coms+ 1 ) / $args['per_page'] );887 return ceil( ( $older_comment_count + 1 ) / $args['per_page'] ); 875 888 } 876 889
Note: See TracChangeset
for help on using the changeset viewer.