Insert Comment with Meta
wp_insert_comment has a modification that allows comment meta to be added to a comment at the time it is created.
// If metadata is provided, store it.
if
( isset(
$commentdata
[
'comment_meta'
] ) &&
is_array
(
$commentdata
[
'comment_meta'
] ) ) {
foreach
(
$commentdata
[
'comment_meta'
]
as
$meta_key
=>
$meta_value
) {
add_comment_meta(
$comment
->comment_ID,
$meta_key
,
$meta_value
, true );
}
}
So, if there is an array in $commentdata called comment_meta, save those keys as comment_meta.
Changes due Pingback
In WordPress 4.5, a slight change will allow the retrieved source code of a site that has sent a pingback to WordPress to be accessible in $commentdata as ‘remote_source_original’. But more importantly, there is now a pathway to access this data in action ‘comment_post’
do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata );
Comment Notification Changes
A lot of this came out of a problem I had last June where updates to comments to make them more rich…in this case pingbacks/webmentions/etc were happening after the notification was sent out. So now, notifications also are triggered by ‘comment_post’.
What Do I Want to Build?
All of these little changes serve to enhance the work I’ve been trying to do with webmentions.