* @access public
* @var object WP_Meta_Query
*/
- var $meta_query = false;
+ public $meta_query = false;
/**
* Date query container
* @access public
* @var object WP_Date_Query
*/
- var $date_query = false;
+ public $date_query = false;
+
+ /**
+ * Make private/protected methods readable for backwards compatibility.
+ *
+ * @since 4.0.0
+ * @access public
+ *
+ * @param callable $name Method to call.
+ * @param array $arguments Arguments to pass when calling.
+ * @return mixed|bool Return value of the callback, false otherwise.
+ */
+ public function __call( $name, $arguments ) {
+ return call_user_func_array( array( $this, $name ), $arguments );
+ }
/**
* Execute the query
* @param string|array $query_vars
* @return int|array
*/
- function query( $query_vars ) {
+ public function query( $query_vars ) {
global $wpdb;
$defaults = array(
'author_email' => '',
+ 'fields' => '',
'ID' => '',
'karma' => '',
'number' => '',
* @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
*/
do_action_ref_array( 'pre_get_comments', array( &$this ) );
- extract( $this->query_vars, EXTR_SKIP );
// $args can be whatever, only use the args defined in defaults to compute the key
- $key = md5( serialize( compact(array_keys($defaults)) ) );
+ $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $defaults ) ) ) );
$last_changed = wp_cache_get( 'last_changed', 'comment' );
if ( ! $last_changed ) {
$last_changed = microtime();
}
$cache_key = "get_comments:$key:$last_changed";
- if ( $cache = wp_cache_get( $cache_key, 'comment' ) )
+ if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) {
return $cache;
+ }
- $post_id = absint($post_id);
-
- if ( 'hold' == $status )
+ $status = $this->query_vars['status'];
+ if ( 'hold' == $status ) {
$approved = "comment_approved = '0'";
- elseif ( 'approve' == $status )
+ } elseif ( 'approve' == $status ) {
$approved = "comment_approved = '1'";
- elseif ( ! empty( $status ) && 'all' != $status )
+ } elseif ( ! empty( $status ) && 'all' != $status ) {
$approved = $wpdb->prepare( "comment_approved = %s", $status );
- else
+ } else {
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
+ }
+ $order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC';
- $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC';
+ if ( ! empty( $this->query_vars['orderby'] ) ) {
+ $ordersby = is_array( $this->query_vars['orderby'] ) ?
+ $this->query_vars['orderby'] :
+ preg_split( '/[,\s]/', $this->query_vars['orderby'] );
- if ( ! empty( $orderby ) ) {
- $ordersby = is_array($orderby) ? $orderby : preg_split('/[,\s]/', $orderby);
$allowed_keys = array(
'comment_agent',
'comment_approved',
$orderby = 'comment_date_gmt';
}
- $number = absint($number);
- $offset = absint($offset);
+ $number = absint( $this->query_vars['number'] );
+ $offset = absint( $this->query_vars['offset'] );
- if ( !empty($number) ) {
- if ( $offset )
+ if ( ! empty( $number ) ) {
+ if ( $offset ) {
$limits = 'LIMIT ' . $offset . ',' . $number;
- else
+ } else {
$limits = 'LIMIT ' . $number;
+ }
} else {
$limits = '';
}
- if ( $count )
+ if ( $this->query_vars['count'] ) {
$fields = 'COUNT(*)';
- else
- $fields = '*';
+ } else {
+ switch ( strtolower( $this->query_vars['fields'] ) ) {
+ case 'ids':
+ $fields = "$wpdb->comments.comment_ID";
+ break;
+ default:
+ $fields = "*";
+ break;
+ }
+ }
$join = '';
$where = $approved;
- if ( ! empty($post_id) )
+ $post_id = absint( $this->query_vars['post_id'] );
+ if ( ! empty( $post_id ) ) {
$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
- if ( '' !== $author_email )
- $where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email );
- if ( '' !== $karma )
- $where .= $wpdb->prepare( ' AND comment_karma = %d', $karma );
- if ( 'comment' == $type ) {
+ }
+
+ if ( '' !== $this->query_vars['author_email'] ) {
+ $where .= $wpdb->prepare( ' AND comment_author_email = %s', $this->query_vars['author_email'] );
+ }
+
+ if ( '' !== $this->query_vars['karma'] ) {
+ $where .= $wpdb->prepare( ' AND comment_karma = %d', $this->query_vars['karma'] );
+ }
+
+ if ( 'comment' == $this->query_vars['type'] ) {
$where .= " AND comment_type = ''";
- } elseif( 'pings' == $type ) {
+ } elseif( 'pings' == $this->query_vars['type'] ) {
$where .= ' AND comment_type IN ("pingback", "trackback")';
- } elseif ( ! empty( $type ) ) {
- $where .= $wpdb->prepare( ' AND comment_type = %s', $type );
+ } elseif ( ! empty( $this->query_vars['type'] ) ) {
+ $where .= $wpdb->prepare( ' AND comment_type = %s', $this->query_vars['type'] );
+ }
+
+ if ( '' !== $this->query_vars['parent'] ) {
+ $where .= $wpdb->prepare( ' AND comment_parent = %d', $this->query_vars['parent'] );
}
- if ( '' !== $parent )
- $where .= $wpdb->prepare( ' AND comment_parent = %d', $parent );
- if ( is_array( $user_id ) ) {
- $where .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $user_id ) ) . ')';
- } elseif ( '' !== $user_id ) {
- $where .= $wpdb->prepare( ' AND user_id = %d', $user_id );
+ if ( is_array( $this->query_vars['user_id'] ) ) {
+ $where .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $this->query_vars['user_id'] ) ) . ')';
+ } elseif ( '' !== $this->query_vars['user_id'] ) {
+ $where .= $wpdb->prepare( ' AND user_id = %d', $this->query_vars['user_id'] );
}
- if ( '' !== $search )
- $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );
+ if ( '' !== $this->query_vars['search'] ) {
+ $where .= $this->get_search_sql(
+ $this->query_vars['search'],
+ array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' )
+ );
+ }
+
+ $plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type' ) );
+ $post_fields = array_filter( $plucked );
- $post_fields = array_filter( compact( array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type', ) ) );
if ( ! empty( $post_fields ) ) {
$join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
foreach( $post_fields as $field_name => $field_value )
$groupby = "{$wpdb->comments}.comment_ID";
}
+ $date_query = $this->query_vars['date_query'];
if ( ! empty( $date_query ) && is_array( $date_query ) ) {
$date_query_object = new WP_Date_Query( $date_query, 'comment_date' );
$where .= $date_query_object->get_sql();
* @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
*/
$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
- foreach ( $pieces as $piece )
- $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
- if ( $groupby )
- $groupby = 'GROUP BY ' . $groupby;
+ $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
+ $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
+ $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
+ $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
+ $order = isset( $clauses[ 'order' ] ) ? $clauses[ 'order' ] : '';
+ $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
+ $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : '';
+ if ( $groupby ) {
+ $groupby = 'GROUP BY ' . $groupby;
+ }
$query = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby ORDER BY $orderby $order $limits";
- if ( $count )
+ if ( $this->query_vars['count'] ) {
return $wpdb->get_var( $query );
+ }
+
+ if ( 'ids' == $this->query_vars['fields'] ) {
+ $this->comments = $wpdb->get_col( $query );
+ return array_map( 'intval', $this->comments );
+ }
- $comments = $wpdb->get_results( $query );
+ $results = $wpdb->get_results( $query );
/**
* Filter the comment query results.
*
* @since 3.1.0
*
- * @param array $comments An array of comments.
+ * @param array $results An array of comments.
* @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
*/
- $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) );
+ $comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) );
wp_cache_add( $cache_key, $comments, 'comment' );
* @param array $cols
* @return string
*/
- function get_search_sql( $string, $cols ) {
- $string = esc_sql( like_escape( $string ) );
+ protected function get_search_sql( $string, $cols ) {
+ global $wpdb;
+
+ $like = '%' . $wpdb->esc_like( $string ) . '%';
$searches = array();
- foreach ( $cols as $col )
- $searches[] = "$col LIKE '%$string%'";
+ foreach ( $cols as $col ) {
+ $searches[] = $wpdb->prepare( "$col LIKE %s", $like );
+ }
return ' AND (' . implode(' OR ', $searches) . ')';
}
* @param int $seconds Comment cookie lifetime. Default 30000000.
*/
$comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
- setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
- setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
- setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
+ $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
+ setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
+ setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
+ setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
}
/**
* @param array $commentdata Contains information on the comment
* @return mixed Signifies the approval status (0|1|'spam')
*/
-function wp_allow_comment($commentdata) {
+function wp_allow_comment( $commentdata ) {
global $wpdb;
- extract($commentdata, EXTR_SKIP);
// Simple duplicate check
// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
- $dupe = $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash( $comment_post_ID ), wp_unslash( $comment_parent ), wp_unslash( $comment_author ) );
- if ( $comment_author_email )
- $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", wp_unslash( $comment_author_email ) );
- $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", wp_unslash( $comment_content ) );
- if ( $wpdb->get_var($dupe) ) {
+ $dupe = $wpdb->prepare(
+ "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ",
+ wp_unslash( $commentdata['comment_post_ID'] ),
+ wp_unslash( $commentdata['comment_parent'] ),
+ wp_unslash( $commentdata['comment_author'] )
+ );
+ if ( $commentdata['comment_author_email'] ) {
+ $dupe .= $wpdb->prepare(
+ "OR comment_author_email = %s ",
+ wp_unslash( $commentdata['comment_author_email'] )
+ );
+ }
+ $dupe .= $wpdb->prepare(
+ ") AND comment_content = %s LIMIT 1",
+ wp_unslash( $commentdata['comment_content'] )
+ );
+ if ( $wpdb->get_var( $dupe ) ) {
/**
* Fires immediately after a duplicate comment is detected.
*
* @param array $commentdata Comment data.
*/
do_action( 'comment_duplicate_trigger', $commentdata );
- if ( defined('DOING_AJAX') )
+ if ( defined( 'DOING_AJAX' ) ) {
die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
-
+ }
wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
}
* @param string $comment_author_email Comment author's email.
* @param string $comment_date_gmt GMT date the comment was posted.
*/
- do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
+ do_action(
+ 'check_comment_flood',
+ $commentdata['comment_author_IP'],
+ $commentdata['comment_author_email'],
+ $commentdata['comment_date_gmt']
+ );
- if ( ! empty( $user_id ) ) {
- $user = get_userdata( $user_id );
- $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID));
+ if ( ! empty( $commentdata['user_id'] ) ) {
+ $user = get_userdata( $commentdata['user_id'] );
+ $post_author = $wpdb->get_var( $wpdb->prepare(
+ "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1",
+ $commentdata['comment_post_ID']
+ ) );
}
- if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
+ if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
// The author and the admins get respect.
$approved = 1;
} else {
// Everyone else's comments will be checked.
- if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
+ if ( check_comment(
+ $commentdata['comment_author'],
+ $commentdata['comment_author_email'],
+ $commentdata['comment_author_url'],
+ $commentdata['comment_content'],
+ $commentdata['comment_author_IP'],
+ $commentdata['comment_agent'],
+ $commentdata['comment_type']
+ ) ) {
$approved = 1;
- else
+ } else {
$approved = 0;
- if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
+ }
+
+ if ( wp_blacklist_check(
+ $commentdata['comment_author'],
+ $commentdata['comment_author_email'],
+ $commentdata['comment_author_url'],
+ $commentdata['comment_content'],
+ $commentdata['comment_author_IP'],
+ $commentdata['comment_agent']
+ ) ) {
$approved = 'spam';
+ }
}
/**
clean_comment_cache($comment_id);
- /**
- * Fires immediately before changing the comment's status to 'delete'.
- *
- * @since 1.5.0
- *
- * @param int $comment_id The comment ID.
- * @param string $status The new 'delete' comment status.
- */
+ /** This action is documented in wp-includes/comment.php */
do_action( 'wp_set_comment_status', $comment_id, 'delete' );
+
wp_transition_comment_status('delete', $comment->comment_approved, $comment);
return true;
}
* @uses $wpdb
*
* @param array $commentdata Contains information on the comment.
- * @return int The new comment's ID.
+ * @return int|bool The new comment's ID on success, false on failure.
*/
-function wp_insert_comment($commentdata) {
+function wp_insert_comment( $commentdata ) {
global $wpdb;
- extract(wp_unslash($commentdata), EXTR_SKIP);
-
- if ( ! isset($comment_author_IP) )
- $comment_author_IP = '';
- if ( ! isset($comment_date) )
- $comment_date = current_time('mysql');
- if ( ! isset($comment_date_gmt) )
- $comment_date_gmt = get_gmt_from_date($comment_date);
- if ( ! isset($comment_parent) )
- $comment_parent = 0;
- if ( ! isset($comment_approved) )
- $comment_approved = 1;
- if ( ! isset($comment_karma) )
- $comment_karma = 0;
- if ( ! isset($user_id) )
- $user_id = 0;
- if ( ! isset($comment_type) )
- $comment_type = '';
-
- $data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
- $wpdb->insert($wpdb->comments, $data);
+ $data = wp_unslash( $commentdata );
- $id = (int) $wpdb->insert_id;
+ $comment_author = ! isset( $data['comment_author'] ) ? '' : $data['comment_author'];
+ $comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email'];
+ $comment_author_url = ! isset( $data['comment_author_url'] ) ? '' : $data['comment_author_url'];
+ $comment_author_IP = ! isset( $data['comment_author_IP'] ) ? '' : $data['comment_author_IP'];
+
+ $comment_date = ! isset( $data['comment_date'] ) ? current_time( 'mysql' ) : $data['comment_date'];
+ $comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt'];
+
+ $comment_post_ID = ! isset( $data['comment_post_ID'] ) ? '' : $data['comment_post_ID'];
+ $comment_content = ! isset( $data['comment_content'] ) ? '' : $data['comment_content'];
+ $comment_karma = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma'];
+ $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved'];
+ $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent'];
+ $comment_type = ! isset( $data['comment_type'] ) ? '' : $data['comment_type'];
+ $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent'];
+
+ $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id'];
- if ( $comment_approved == 1 )
- wp_update_comment_count($comment_post_ID);
+ $compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' );
+ if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
+ return false;
+ }
- $comment = get_comment($id);
+ $id = (int) $wpdb->insert_id;
+
+ if ( $comment_approved == 1 ) {
+ wp_update_comment_count( $comment_post_ID );
+ }
+ $comment = get_comment( $id );
/**
* Fires immediately after a comment is inserted into the database.
*
* @since 1.5.0
* @param array $commentdata Contains information on the comment.
- * @return int The ID of the comment after adding.
+ * @return int|bool The ID of the comment on success, false on failure.
*/
function wp_new_comment( $commentdata ) {
+ if ( isset( $commentdata['user_ID'] ) ) {
+ $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
+ }
+
+ $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
+
/**
* Filter a comment's data before it is sanitized and inserted into the database.
*
$commentdata = apply_filters( 'preprocess_comment', $commentdata );
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
- if ( isset($commentdata['user_ID']) )
+ if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
- elseif ( isset($commentdata['user_id']) )
+ } elseif ( isset( $commentdata['user_id'] ) ) {
$commentdata['user_id'] = (int) $commentdata['user_id'];
+ }
$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
$commentdata['comment_approved'] = wp_allow_comment($commentdata);
$comment_ID = wp_insert_comment($commentdata);
+ if ( ! $comment_ID ) {
+ return false;
+ }
/**
* Fires immediately after a comment is inserted into the database.
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
global $wpdb;
- $status = '0';
switch ( $comment_status ) {
case 'hold':
case '0':
$comment = get_comment($comment_id);
/**
- * Fires after a comment status has been updated in the database.
- *
- * The hook also fires immediately before comment status transition hooks are fired.
+ * Fires immediately before transitioning a comment's status from one to another
+ * in the database.
*
* @since 1.5.0
*
- * @param int $comment_id The comment ID.
- * @param string|bool $comment_status The comment status. Possible values include 'hold',
- * 'approve', 'spam', 'trash', or false.
+ * @param int $comment_id Comment ID.
+ * @param string|bool $comment_status Current comment status. Possible values include
+ * 'hold', 'approve', 'spam', 'trash', or false.
*/
do_action( 'wp_set_comment_status', $comment_id, $comment_status );
+
wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
wp_update_comment_count($comment->comment_post_ID);
// First, get all of the original fields
$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
- if ( empty( $comment ) )
+ if ( empty( $comment ) ) {
return 0;
-
+ }
// Escape data pulled from DB.
$comment = wp_slash($comment);
$commentarr = wp_filter_comment( $commentarr );
// Now extract the merged array.
- extract(wp_unslash($commentarr), EXTR_SKIP);
+ $data = wp_unslash( $commentarr );
/**
* Filter the comment content before it is updated in the database.
*
* @param string $comment_content The comment data.
*/
- $comment_content = apply_filters( 'comment_save_pre', $comment_content );
+ $data['comment_content'] = apply_filters( 'comment_save_pre', $data['comment_content'] );
- $comment_date_gmt = get_gmt_from_date($comment_date);
+ $data['comment_date_gmt'] = get_gmt_from_date( $data['comment_date'] );
- if ( !isset($comment_approved) )
- $comment_approved = 1;
- else if ( 'hold' == $comment_approved )
- $comment_approved = 0;
- else if ( 'approve' == $comment_approved )
- $comment_approved = 1;
+ if ( ! isset( $data['comment_approved'] ) ) {
+ $data['comment_approved'] = 1;
+ } else if ( 'hold' == $data['comment_approved'] ) {
+ $data['comment_approved'] = 0;
+ } else if ( 'approve' == $data['comment_approved'] ) {
+ $data['comment_approved'] = 1;
+ }
- $data = compact( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent' );
+ $comment_ID = $data['comment_ID'];
+ $comment_post_ID = $data['comment_post_ID'];
+ $keys = array( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent' );
+ $data = wp_array_slice_assoc( $data, $keys );
$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
- clean_comment_cache($comment_ID);
- wp_update_comment_count($comment_post_ID);
+ clean_comment_cache( $comment_ID );
+ wp_update_comment_count( $comment_post_ID );
/**
* Fires immediately after a comment is updated in the database.
*
}
if ( empty($post->post_excerpt) ) {
- /** This filter is documented in wp-admin/post-template.php */
+ /** This filter is documented in wp-includes/post-template.php */
$excerpt = apply_filters( 'the_content', $post->post_content, $post->ID );
} else {
- /** This filter is documented in wp-admin/post-template.php */
+ /** This filter is documented in wp-includes/post-template.php */
$excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
}
*
* @since 1.2.0
*
- * @param int $post_id Post ID. Not actually used.
+ * @param int $post_id Post ID.
* @return int Same as Post ID from parameter
*/
-function generic_ping($post_id = 0) {
+function generic_ping( $post_id = 0 ) {
$services = get_option('ping_sites');
$services = explode("\n", $services);