mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Add some error feedback to ajax comment moderation. see #9261
git-svn-id: https://develop.svn.wordpress.org/trunk@10681 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1014,9 +1014,10 @@ function wp_new_comment( $commentdata ) {
|
||||
*
|
||||
* @param int $comment_id Comment ID.
|
||||
* @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete'.
|
||||
* @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false.
|
||||
* @return bool False on failure or deletion and true on success.
|
||||
*/
|
||||
function wp_set_comment_status($comment_id, $comment_status) {
|
||||
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
|
||||
global $wpdb;
|
||||
|
||||
switch ( $comment_status ) {
|
||||
@@ -1040,8 +1041,12 @@ function wp_set_comment_status($comment_id, $comment_status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !$wpdb->query($query) )
|
||||
return false;
|
||||
if ( !$wpdb->query($query) ) {
|
||||
if ( $wp_error )
|
||||
return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
clean_comment_cache($comment_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user