mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 15:31:42 +01:00
Use WP_Comment_Query
to query comments in get_approved_comments()
.
Props dancameron. See #12668. Built from https://develop.svn.wordpress.org/trunk@30098 git-svn-id: http://core.svn.wordpress.org/trunk@30098 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e68c17cb7b
commit
3be72a13de
@ -128,14 +128,21 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
|
||||
* Retrieve the approved comments for post $post_id.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @uses $wpdb
|
||||
*
|
||||
* @param int $post_id The ID of the post
|
||||
* @return array $comments The approved comments
|
||||
* @param int $post_id The ID of the post.
|
||||
* @param array $args Optional. WP_Comment_Query args.
|
||||
* @return array $comments The approved comments.
|
||||
*/
|
||||
function get_approved_comments($post_id) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id));
|
||||
function get_approved_comments( $post_id = 0, $args = array() ) {
|
||||
$defaults = array(
|
||||
'status' => 1,
|
||||
'post_id' => $post_id,
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$query = new WP_Comment_Query;
|
||||
return $query->query( $r );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.1-alpha-30097';
|
||||
$wp_version = '4.1-alpha-30098';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user