From bf21f3f62f3d42bf833242e2636e7ff0970c1487 Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Thu, 29 Sep 2016 13:47:31 +0000 Subject: [PATCH] Comments: Introduce the `wp_update_comment_data` filter. Filters the comment data immediately before it is updated in the database. Props frankiet, dshanske, DrewAPicture. Fixes #36302. Built from https://develop.svn.wordpress.org/trunk@38674 git-svn-id: http://core.svn.wordpress.org/trunk@38617 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 14 ++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 27524c54ec..861ad6b802 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -2027,6 +2027,20 @@ function wp_update_comment($commentarr) { $comment_post_ID = $data['comment_post_ID']; $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP' ); $data = wp_array_slice_assoc( $data, $keys ); + + /** + * Filters the comment data immediately before it is updated in the database. + * + * Note: data being passed to the filter is already unslashed. + * + * @since 4.7.0 + * + * @param array $data The new, processed comment data. + * @param array $comment The old, unslashed comment data. + * @param array $commentarr The new, raw comment data. + */ + $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr ); + $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); clean_comment_cache( $comment_ID ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 8fb76ce701..d402463578 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38673'; +$wp_version = '4.7-alpha-38674'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.