modified file w3-total-cache
This commit is contained in:
@ -31,12 +31,13 @@ class Interactions {
|
||||
return false;
|
||||
}
|
||||
|
||||
$in_reply_to = \esc_url_raw( $activity['object']['inReplyTo'] );
|
||||
$comment_post_id = \url_to_postid( $in_reply_to );
|
||||
$parent_comment = object_id_to_comment( $in_reply_to );
|
||||
$in_reply_to = \esc_url_raw( $activity['object']['inReplyTo'] );
|
||||
$comment_post_id = \url_to_postid( $in_reply_to );
|
||||
$parent_comment_id = url_to_commentid( $in_reply_to );
|
||||
|
||||
// save only replys and reactions
|
||||
if ( ! $comment_post_id && $parent_comment ) {
|
||||
if ( ! $comment_post_id && $parent_comment_id ) {
|
||||
$parent_comment = get_comment( $parent_comment_id );
|
||||
$comment_post_id = $parent_comment->comment_post_ID;
|
||||
}
|
||||
|
||||
@ -53,15 +54,14 @@ class Interactions {
|
||||
|
||||
$commentdata = array(
|
||||
'comment_post_ID' => $comment_post_id,
|
||||
'comment_author' => \esc_attr( $meta['name'] ),
|
||||
'comment_author' => isset( $meta['name'] ) ? \esc_attr( $meta['name'] ) : \esc_attr( $meta['preferredUsername'] ),
|
||||
'comment_author_url' => \esc_url_raw( $meta['url'] ),
|
||||
'comment_content' => \addslashes( $activity['object']['content'] ),
|
||||
'comment_type' => 'comment',
|
||||
'comment_author_email' => '',
|
||||
'comment_parent' => $parent_comment ? $parent_comment->comment_ID : 0,
|
||||
'comment_parent' => $parent_comment_id ? $parent_comment_id : 0,
|
||||
'comment_meta' => array(
|
||||
'source_id' => \esc_url_raw( $activity['object']['id'] ),
|
||||
'source_url' => \esc_url_raw( $activity['object']['url'] ),
|
||||
'protocol' => 'activitypub',
|
||||
),
|
||||
);
|
||||
@ -70,6 +70,10 @@ class Interactions {
|
||||
$commentdata['comment_meta']['avatar_url'] = \esc_url_raw( $meta['icon']['url'] );
|
||||
}
|
||||
|
||||
if ( isset( $activity['object']['url'] ) ) {
|
||||
$commentdata['comment_meta']['source_url'] = \esc_url_raw( $activity['object']['url'] );
|
||||
}
|
||||
|
||||
// disable flood control
|
||||
\remove_action( 'check_comment_flood', 'check_comment_flood_db', 10 );
|
||||
// do not require email for AP entries
|
||||
@ -77,7 +81,7 @@ class Interactions {
|
||||
// No nonce possible for this submission route
|
||||
\add_filter(
|
||||
'akismet_comment_nonce',
|
||||
function() {
|
||||
function () {
|
||||
return 'inactive';
|
||||
}
|
||||
);
|
||||
@ -98,20 +102,20 @@ class Interactions {
|
||||
*
|
||||
* @param array $activity The activity-object
|
||||
*
|
||||
* @return array|false The commentdata or false on failure
|
||||
* @return array|string|int|\WP_Error|false The commentdata or false on failure
|
||||
*/
|
||||
public static function update_comment( $activity ) {
|
||||
$meta = get_remote_metadata_by_actor( $activity['actor'] );
|
||||
|
||||
//Determine comment_ID
|
||||
$object_comment_id = url_to_commentid( \esc_url_raw( $activity['object']['id'] ) );
|
||||
$comment = object_id_to_comment( \esc_url_raw( $activity['object']['id'] ) );
|
||||
$commentdata = \get_comment( $comment, ARRAY_A );
|
||||
|
||||
if ( ! $object_comment_id ) {
|
||||
if ( ! $commentdata ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//found a local comment id
|
||||
$commentdata = \get_comment( $object_comment_id, ARRAY_A );
|
||||
$commentdata['comment_author'] = \esc_attr( $meta['name'] ? $meta['name'] : $meta['preferredUsername'] );
|
||||
$commentdata['comment_content'] = \addslashes( $activity['object']['content'] );
|
||||
if ( isset( $meta['icon']['url'] ) ) {
|
||||
@ -125,20 +129,24 @@ class Interactions {
|
||||
// No nonce possible for this submission route
|
||||
\add_filter(
|
||||
'akismet_comment_nonce',
|
||||
function() {
|
||||
function () {
|
||||
return 'inactive';
|
||||
}
|
||||
);
|
||||
\add_filter( 'wp_kses_allowed_html', array( self::class, 'allowed_comment_html' ), 10, 2 );
|
||||
|
||||
$comment = \wp_update_comment( $commentdata, true );
|
||||
$state = \wp_update_comment( $commentdata, true );
|
||||
|
||||
\remove_filter( 'wp_kses_allowed_html', array( self::class, 'allowed_comment_html' ), 10 );
|
||||
\remove_filter( 'pre_option_require_name_email', '__return_false' );
|
||||
// re-add flood control
|
||||
\add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
|
||||
|
||||
return $comment;
|
||||
if ( 1 === $state ) {
|
||||
return $commentdata;
|
||||
} else {
|
||||
return $state; // Either `false` or a `WP_Error` instance or `0` or `1`!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user