Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: comment.php
* @param int $comment_post_id Post ID.
[3500] Fix | Delete
* @param int $comment_parent Parent comment ID.
[3501] Fix | Delete
*/
[3502] Fix | Delete
do_action( 'comment_reply_to_unapproved_comment', $comment_post_id, $comment_parent );
[3503] Fix | Delete
[3504] Fix | Delete
return new WP_Error( 'comment_reply_to_unapproved_comment', __( 'Sorry, replies to unapproved comments are not allowed.' ), 403 );
[3505] Fix | Delete
}
[3506] Fix | Delete
}
[3507] Fix | Delete
[3508] Fix | Delete
$post = get_post( $comment_post_id );
[3509] Fix | Delete
[3510] Fix | Delete
if ( empty( $post->comment_status ) ) {
[3511] Fix | Delete
[3512] Fix | Delete
/**
[3513] Fix | Delete
* Fires when a comment is attempted on a post that does not exist.
[3514] Fix | Delete
*
[3515] Fix | Delete
* @since 1.5.0
[3516] Fix | Delete
*
[3517] Fix | Delete
* @param int $comment_post_id Post ID.
[3518] Fix | Delete
*/
[3519] Fix | Delete
do_action( 'comment_id_not_found', $comment_post_id );
[3520] Fix | Delete
[3521] Fix | Delete
return new WP_Error( 'comment_id_not_found' );
[3522] Fix | Delete
[3523] Fix | Delete
}
[3524] Fix | Delete
[3525] Fix | Delete
// get_post_status() will get the parent status for attachments.
[3526] Fix | Delete
$status = get_post_status( $post );
[3527] Fix | Delete
[3528] Fix | Delete
if ( ( 'private' === $status ) && ! current_user_can( 'read_post', $comment_post_id ) ) {
[3529] Fix | Delete
return new WP_Error( 'comment_id_not_found' );
[3530] Fix | Delete
}
[3531] Fix | Delete
[3532] Fix | Delete
$status_obj = get_post_status_object( $status );
[3533] Fix | Delete
[3534] Fix | Delete
if ( ! comments_open( $comment_post_id ) ) {
[3535] Fix | Delete
[3536] Fix | Delete
/**
[3537] Fix | Delete
* Fires when a comment is attempted on a post that has comments closed.
[3538] Fix | Delete
*
[3539] Fix | Delete
* @since 1.5.0
[3540] Fix | Delete
*
[3541] Fix | Delete
* @param int $comment_post_id Post ID.
[3542] Fix | Delete
*/
[3543] Fix | Delete
do_action( 'comment_closed', $comment_post_id );
[3544] Fix | Delete
[3545] Fix | Delete
return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );
[3546] Fix | Delete
[3547] Fix | Delete
} elseif ( 'trash' === $status ) {
[3548] Fix | Delete
[3549] Fix | Delete
/**
[3550] Fix | Delete
* Fires when a comment is attempted on a trashed post.
[3551] Fix | Delete
*
[3552] Fix | Delete
* @since 2.9.0
[3553] Fix | Delete
*
[3554] Fix | Delete
* @param int $comment_post_id Post ID.
[3555] Fix | Delete
*/
[3556] Fix | Delete
do_action( 'comment_on_trash', $comment_post_id );
[3557] Fix | Delete
[3558] Fix | Delete
return new WP_Error( 'comment_on_trash' );
[3559] Fix | Delete
[3560] Fix | Delete
} elseif ( ! $status_obj->public && ! $status_obj->private ) {
[3561] Fix | Delete
[3562] Fix | Delete
/**
[3563] Fix | Delete
* Fires when a comment is attempted on a post in draft mode.
[3564] Fix | Delete
*
[3565] Fix | Delete
* @since 1.5.1
[3566] Fix | Delete
*
[3567] Fix | Delete
* @param int $comment_post_id Post ID.
[3568] Fix | Delete
*/
[3569] Fix | Delete
do_action( 'comment_on_draft', $comment_post_id );
[3570] Fix | Delete
[3571] Fix | Delete
if ( current_user_can( 'read_post', $comment_post_id ) ) {
[3572] Fix | Delete
return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
[3573] Fix | Delete
} else {
[3574] Fix | Delete
return new WP_Error( 'comment_on_draft' );
[3575] Fix | Delete
}
[3576] Fix | Delete
} elseif ( post_password_required( $comment_post_id ) ) {
[3577] Fix | Delete
[3578] Fix | Delete
/**
[3579] Fix | Delete
* Fires when a comment is attempted on a password-protected post.
[3580] Fix | Delete
*
[3581] Fix | Delete
* @since 2.9.0
[3582] Fix | Delete
*
[3583] Fix | Delete
* @param int $comment_post_id Post ID.
[3584] Fix | Delete
*/
[3585] Fix | Delete
do_action( 'comment_on_password_protected', $comment_post_id );
[3586] Fix | Delete
[3587] Fix | Delete
return new WP_Error( 'comment_on_password_protected' );
[3588] Fix | Delete
[3589] Fix | Delete
} else {
[3590] Fix | Delete
/**
[3591] Fix | Delete
* Fires before a comment is posted.
[3592] Fix | Delete
*
[3593] Fix | Delete
* @since 2.8.0
[3594] Fix | Delete
*
[3595] Fix | Delete
* @param int $comment_post_id Post ID.
[3596] Fix | Delete
*/
[3597] Fix | Delete
do_action( 'pre_comment_on_post', $comment_post_id );
[3598] Fix | Delete
}
[3599] Fix | Delete
[3600] Fix | Delete
// If the user is logged in.
[3601] Fix | Delete
$user = wp_get_current_user();
[3602] Fix | Delete
if ( $user->exists() ) {
[3603] Fix | Delete
if ( empty( $user->display_name ) ) {
[3604] Fix | Delete
$user->display_name = $user->user_login;
[3605] Fix | Delete
}
[3606] Fix | Delete
[3607] Fix | Delete
$comment_author = $user->display_name;
[3608] Fix | Delete
$comment_author_email = $user->user_email;
[3609] Fix | Delete
$comment_author_url = $user->user_url;
[3610] Fix | Delete
$user_id = $user->ID;
[3611] Fix | Delete
[3612] Fix | Delete
if ( current_user_can( 'unfiltered_html' ) ) {
[3613] Fix | Delete
if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
[3614] Fix | Delete
|| ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_id )
[3615] Fix | Delete
) {
[3616] Fix | Delete
kses_remove_filters(); // Start with a clean slate.
[3617] Fix | Delete
kses_init_filters(); // Set up the filters.
[3618] Fix | Delete
remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
[3619] Fix | Delete
add_filter( 'pre_comment_content', 'wp_filter_kses' );
[3620] Fix | Delete
}
[3621] Fix | Delete
}
[3622] Fix | Delete
} else {
[3623] Fix | Delete
if ( get_option( 'comment_registration' ) ) {
[3624] Fix | Delete
return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to comment.' ), 403 );
[3625] Fix | Delete
}
[3626] Fix | Delete
}
[3627] Fix | Delete
[3628] Fix | Delete
$comment_type = 'comment';
[3629] Fix | Delete
[3630] Fix | Delete
if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
[3631] Fix | Delete
if ( '' == $comment_author_email || '' == $comment_author ) {
[3632] Fix | Delete
return new WP_Error( 'require_name_email', __( '<strong>Error:</strong> Please fill the required fields.' ), 200 );
[3633] Fix | Delete
} elseif ( ! is_email( $comment_author_email ) ) {
[3634] Fix | Delete
return new WP_Error( 'require_valid_email', __( '<strong>Error:</strong> Please enter a valid email address.' ), 200 );
[3635] Fix | Delete
}
[3636] Fix | Delete
}
[3637] Fix | Delete
[3638] Fix | Delete
$commentdata = array(
[3639] Fix | Delete
'comment_post_ID' => $comment_post_id,
[3640] Fix | Delete
);
[3641] Fix | Delete
[3642] Fix | Delete
$commentdata += compact(
[3643] Fix | Delete
'comment_author',
[3644] Fix | Delete
'comment_author_email',
[3645] Fix | Delete
'comment_author_url',
[3646] Fix | Delete
'comment_content',
[3647] Fix | Delete
'comment_type',
[3648] Fix | Delete
'comment_parent',
[3649] Fix | Delete
'user_id'
[3650] Fix | Delete
);
[3651] Fix | Delete
[3652] Fix | Delete
/**
[3653] Fix | Delete
* Filters whether an empty comment should be allowed.
[3654] Fix | Delete
*
[3655] Fix | Delete
* @since 5.1.0
[3656] Fix | Delete
*
[3657] Fix | Delete
* @param bool $allow_empty_comment Whether to allow empty comments. Default false.
[3658] Fix | Delete
* @param array $commentdata Array of comment data to be sent to wp_insert_comment().
[3659] Fix | Delete
*/
[3660] Fix | Delete
$allow_empty_comment = apply_filters( 'allow_empty_comment', false, $commentdata );
[3661] Fix | Delete
if ( '' === $comment_content && ! $allow_empty_comment ) {
[3662] Fix | Delete
return new WP_Error( 'require_valid_comment', __( '<strong>Error:</strong> Please type your comment text.' ), 200 );
[3663] Fix | Delete
}
[3664] Fix | Delete
[3665] Fix | Delete
$check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );
[3666] Fix | Delete
if ( is_wp_error( $check_max_lengths ) ) {
[3667] Fix | Delete
return $check_max_lengths;
[3668] Fix | Delete
}
[3669] Fix | Delete
[3670] Fix | Delete
$comment_id = wp_new_comment( wp_slash( $commentdata ), true );
[3671] Fix | Delete
if ( is_wp_error( $comment_id ) ) {
[3672] Fix | Delete
return $comment_id;
[3673] Fix | Delete
}
[3674] Fix | Delete
[3675] Fix | Delete
if ( ! $comment_id ) {
[3676] Fix | Delete
return new WP_Error( 'comment_save_error', __( '<strong>Error:</strong> The comment could not be saved. Please try again later.' ), 500 );
[3677] Fix | Delete
}
[3678] Fix | Delete
[3679] Fix | Delete
return get_comment( $comment_id );
[3680] Fix | Delete
}
[3681] Fix | Delete
[3682] Fix | Delete
/**
[3683] Fix | Delete
* Registers the personal data exporter for comments.
[3684] Fix | Delete
*
[3685] Fix | Delete
* @since 4.9.6
[3686] Fix | Delete
*
[3687] Fix | Delete
* @param array[] $exporters An array of personal data exporters.
[3688] Fix | Delete
* @return array[] An array of personal data exporters.
[3689] Fix | Delete
*/
[3690] Fix | Delete
function wp_register_comment_personal_data_exporter( $exporters ) {
[3691] Fix | Delete
$exporters['wordpress-comments'] = array(
[3692] Fix | Delete
'exporter_friendly_name' => __( 'WordPress Comments' ),
[3693] Fix | Delete
'callback' => 'wp_comments_personal_data_exporter',
[3694] Fix | Delete
);
[3695] Fix | Delete
[3696] Fix | Delete
return $exporters;
[3697] Fix | Delete
}
[3698] Fix | Delete
[3699] Fix | Delete
/**
[3700] Fix | Delete
* Finds and exports personal data associated with an email address from the comments table.
[3701] Fix | Delete
*
[3702] Fix | Delete
* @since 4.9.6
[3703] Fix | Delete
*
[3704] Fix | Delete
* @param string $email_address The comment author email address.
[3705] Fix | Delete
* @param int $page Comment page number.
[3706] Fix | Delete
* @return array {
[3707] Fix | Delete
* An array of personal data.
[3708] Fix | Delete
*
[3709] Fix | Delete
* @type array[] $data An array of personal data arrays.
[3710] Fix | Delete
* @type bool $done Whether the exporter is finished.
[3711] Fix | Delete
* }
[3712] Fix | Delete
*/
[3713] Fix | Delete
function wp_comments_personal_data_exporter( $email_address, $page = 1 ) {
[3714] Fix | Delete
// Limit us to 500 comments at a time to avoid timing out.
[3715] Fix | Delete
$number = 500;
[3716] Fix | Delete
$page = (int) $page;
[3717] Fix | Delete
[3718] Fix | Delete
$data_to_export = array();
[3719] Fix | Delete
[3720] Fix | Delete
$comments = get_comments(
[3721] Fix | Delete
array(
[3722] Fix | Delete
'author_email' => $email_address,
[3723] Fix | Delete
'number' => $number,
[3724] Fix | Delete
'paged' => $page,
[3725] Fix | Delete
'orderby' => 'comment_ID',
[3726] Fix | Delete
'order' => 'ASC',
[3727] Fix | Delete
'update_comment_meta_cache' => false,
[3728] Fix | Delete
)
[3729] Fix | Delete
);
[3730] Fix | Delete
[3731] Fix | Delete
$comment_prop_to_export = array(
[3732] Fix | Delete
'comment_author' => __( 'Comment Author' ),
[3733] Fix | Delete
'comment_author_email' => __( 'Comment Author Email' ),
[3734] Fix | Delete
'comment_author_url' => __( 'Comment Author URL' ),
[3735] Fix | Delete
'comment_author_IP' => __( 'Comment Author IP' ),
[3736] Fix | Delete
'comment_agent' => __( 'Comment Author User Agent' ),
[3737] Fix | Delete
'comment_date' => __( 'Comment Date' ),
[3738] Fix | Delete
'comment_content' => __( 'Comment Content' ),
[3739] Fix | Delete
'comment_link' => __( 'Comment URL' ),
[3740] Fix | Delete
);
[3741] Fix | Delete
[3742] Fix | Delete
foreach ( (array) $comments as $comment ) {
[3743] Fix | Delete
$comment_data_to_export = array();
[3744] Fix | Delete
[3745] Fix | Delete
foreach ( $comment_prop_to_export as $key => $name ) {
[3746] Fix | Delete
$value = '';
[3747] Fix | Delete
[3748] Fix | Delete
switch ( $key ) {
[3749] Fix | Delete
case 'comment_author':
[3750] Fix | Delete
case 'comment_author_email':
[3751] Fix | Delete
case 'comment_author_url':
[3752] Fix | Delete
case 'comment_author_IP':
[3753] Fix | Delete
case 'comment_agent':
[3754] Fix | Delete
case 'comment_date':
[3755] Fix | Delete
$value = $comment->{$key};
[3756] Fix | Delete
break;
[3757] Fix | Delete
[3758] Fix | Delete
case 'comment_content':
[3759] Fix | Delete
$value = get_comment_text( $comment->comment_ID );
[3760] Fix | Delete
break;
[3761] Fix | Delete
[3762] Fix | Delete
case 'comment_link':
[3763] Fix | Delete
$value = get_comment_link( $comment->comment_ID );
[3764] Fix | Delete
$value = sprintf(
[3765] Fix | Delete
'<a href="%s" target="_blank" rel="noopener">%s</a>',
[3766] Fix | Delete
esc_url( $value ),
[3767] Fix | Delete
esc_html( $value )
[3768] Fix | Delete
);
[3769] Fix | Delete
break;
[3770] Fix | Delete
}
[3771] Fix | Delete
[3772] Fix | Delete
if ( ! empty( $value ) ) {
[3773] Fix | Delete
$comment_data_to_export[] = array(
[3774] Fix | Delete
'name' => $name,
[3775] Fix | Delete
'value' => $value,
[3776] Fix | Delete
);
[3777] Fix | Delete
}
[3778] Fix | Delete
}
[3779] Fix | Delete
[3780] Fix | Delete
$data_to_export[] = array(
[3781] Fix | Delete
'group_id' => 'comments',
[3782] Fix | Delete
'group_label' => __( 'Comments' ),
[3783] Fix | Delete
'group_description' => __( 'User&#8217;s comment data.' ),
[3784] Fix | Delete
'item_id' => "comment-{$comment->comment_ID}",
[3785] Fix | Delete
'data' => $comment_data_to_export,
[3786] Fix | Delete
);
[3787] Fix | Delete
}
[3788] Fix | Delete
[3789] Fix | Delete
$done = count( $comments ) < $number;
[3790] Fix | Delete
[3791] Fix | Delete
return array(
[3792] Fix | Delete
'data' => $data_to_export,
[3793] Fix | Delete
'done' => $done,
[3794] Fix | Delete
);
[3795] Fix | Delete
}
[3796] Fix | Delete
[3797] Fix | Delete
/**
[3798] Fix | Delete
* Registers the personal data eraser for comments.
[3799] Fix | Delete
*
[3800] Fix | Delete
* @since 4.9.6
[3801] Fix | Delete
*
[3802] Fix | Delete
* @param array $erasers An array of personal data erasers.
[3803] Fix | Delete
* @return array An array of personal data erasers.
[3804] Fix | Delete
*/
[3805] Fix | Delete
function wp_register_comment_personal_data_eraser( $erasers ) {
[3806] Fix | Delete
$erasers['wordpress-comments'] = array(
[3807] Fix | Delete
'eraser_friendly_name' => __( 'WordPress Comments' ),
[3808] Fix | Delete
'callback' => 'wp_comments_personal_data_eraser',
[3809] Fix | Delete
);
[3810] Fix | Delete
[3811] Fix | Delete
return $erasers;
[3812] Fix | Delete
}
[3813] Fix | Delete
[3814] Fix | Delete
/**
[3815] Fix | Delete
* Erases personal data associated with an email address from the comments table.
[3816] Fix | Delete
*
[3817] Fix | Delete
* @since 4.9.6
[3818] Fix | Delete
*
[3819] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3820] Fix | Delete
*
[3821] Fix | Delete
* @param string $email_address The comment author email address.
[3822] Fix | Delete
* @param int $page Comment page number.
[3823] Fix | Delete
* @return array {
[3824] Fix | Delete
* Data removal results.
[3825] Fix | Delete
*
[3826] Fix | Delete
* @type bool $items_removed Whether items were actually removed.
[3827] Fix | Delete
* @type bool $items_retained Whether items were retained.
[3828] Fix | Delete
* @type string[] $messages An array of messages to add to the personal data export file.
[3829] Fix | Delete
* @type bool $done Whether the eraser is finished.
[3830] Fix | Delete
* }
[3831] Fix | Delete
*/
[3832] Fix | Delete
function wp_comments_personal_data_eraser( $email_address, $page = 1 ) {
[3833] Fix | Delete
global $wpdb;
[3834] Fix | Delete
[3835] Fix | Delete
if ( empty( $email_address ) ) {
[3836] Fix | Delete
return array(
[3837] Fix | Delete
'items_removed' => false,
[3838] Fix | Delete
'items_retained' => false,
[3839] Fix | Delete
'messages' => array(),
[3840] Fix | Delete
'done' => true,
[3841] Fix | Delete
);
[3842] Fix | Delete
}
[3843] Fix | Delete
[3844] Fix | Delete
// Limit us to 500 comments at a time to avoid timing out.
[3845] Fix | Delete
$number = 500;
[3846] Fix | Delete
$page = (int) $page;
[3847] Fix | Delete
$items_removed = false;
[3848] Fix | Delete
$items_retained = false;
[3849] Fix | Delete
[3850] Fix | Delete
$comments = get_comments(
[3851] Fix | Delete
array(
[3852] Fix | Delete
'author_email' => $email_address,
[3853] Fix | Delete
'number' => $number,
[3854] Fix | Delete
'paged' => $page,
[3855] Fix | Delete
'orderby' => 'comment_ID',
[3856] Fix | Delete
'order' => 'ASC',
[3857] Fix | Delete
'include_unapproved' => true,
[3858] Fix | Delete
)
[3859] Fix | Delete
);
[3860] Fix | Delete
[3861] Fix | Delete
/* translators: Name of a comment's author after being anonymized. */
[3862] Fix | Delete
$anon_author = __( 'Anonymous' );
[3863] Fix | Delete
$messages = array();
[3864] Fix | Delete
[3865] Fix | Delete
foreach ( (array) $comments as $comment ) {
[3866] Fix | Delete
$anonymized_comment = array();
[3867] Fix | Delete
$anonymized_comment['comment_agent'] = '';
[3868] Fix | Delete
$anonymized_comment['comment_author'] = $anon_author;
[3869] Fix | Delete
$anonymized_comment['comment_author_email'] = '';
[3870] Fix | Delete
$anonymized_comment['comment_author_IP'] = wp_privacy_anonymize_data( 'ip', $comment->comment_author_IP );
[3871] Fix | Delete
$anonymized_comment['comment_author_url'] = '';
[3872] Fix | Delete
$anonymized_comment['user_id'] = 0;
[3873] Fix | Delete
[3874] Fix | Delete
$comment_id = (int) $comment->comment_ID;
[3875] Fix | Delete
[3876] Fix | Delete
/**
[3877] Fix | Delete
* Filters whether to anonymize the comment.
[3878] Fix | Delete
*
[3879] Fix | Delete
* @since 4.9.6
[3880] Fix | Delete
*
[3881] Fix | Delete
* @param bool|string $anon_message Whether to apply the comment anonymization (bool) or a custom
[3882] Fix | Delete
* message (string). Default true.
[3883] Fix | Delete
* @param WP_Comment $comment WP_Comment object.
[3884] Fix | Delete
* @param array $anonymized_comment Anonymized comment data.
[3885] Fix | Delete
*/
[3886] Fix | Delete
$anon_message = apply_filters( 'wp_anonymize_comment', true, $comment, $anonymized_comment );
[3887] Fix | Delete
[3888] Fix | Delete
if ( true !== $anon_message ) {
[3889] Fix | Delete
if ( $anon_message && is_string( $anon_message ) ) {
[3890] Fix | Delete
$messages[] = esc_html( $anon_message );
[3891] Fix | Delete
} else {
[3892] Fix | Delete
/* translators: %d: Comment ID. */
[3893] Fix | Delete
$messages[] = sprintf( __( 'Comment %d contains personal data but could not be anonymized.' ), $comment_id );
[3894] Fix | Delete
}
[3895] Fix | Delete
[3896] Fix | Delete
$items_retained = true;
[3897] Fix | Delete
[3898] Fix | Delete
continue;
[3899] Fix | Delete
}
[3900] Fix | Delete
[3901] Fix | Delete
$args = array(
[3902] Fix | Delete
'comment_ID' => $comment_id,
[3903] Fix | Delete
);
[3904] Fix | Delete
[3905] Fix | Delete
$updated = $wpdb->update( $wpdb->comments, $anonymized_comment, $args );
[3906] Fix | Delete
[3907] Fix | Delete
if ( $updated ) {
[3908] Fix | Delete
$items_removed = true;
[3909] Fix | Delete
clean_comment_cache( $comment_id );
[3910] Fix | Delete
} else {
[3911] Fix | Delete
$items_retained = true;
[3912] Fix | Delete
}
[3913] Fix | Delete
}
[3914] Fix | Delete
[3915] Fix | Delete
$done = count( $comments ) < $number;
[3916] Fix | Delete
[3917] Fix | Delete
return array(
[3918] Fix | Delete
'items_removed' => $items_removed,
[3919] Fix | Delete
'items_retained' => $items_retained,
[3920] Fix | Delete
'messages' => $messages,
[3921] Fix | Delete
'done' => $done,
[3922] Fix | Delete
);
[3923] Fix | Delete
}
[3924] Fix | Delete
[3925] Fix | Delete
/**
[3926] Fix | Delete
* Sets the last changed time for the 'comment' cache group.
[3927] Fix | Delete
*
[3928] Fix | Delete
* @since 5.0.0
[3929] Fix | Delete
*/
[3930] Fix | Delete
function wp_cache_set_comments_last_changed() {
[3931] Fix | Delete
wp_cache_set_last_changed( 'comment' );
[3932] Fix | Delete
}
[3933] Fix | Delete
[3934] Fix | Delete
/**
[3935] Fix | Delete
* Updates the comment type for a batch of comments.
[3936] Fix | Delete
*
[3937] Fix | Delete
* @since 5.5.0
[3938] Fix | Delete
*
[3939] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3940] Fix | Delete
*/
[3941] Fix | Delete
function _wp_batch_update_comment_type() {
[3942] Fix | Delete
global $wpdb;
[3943] Fix | Delete
[3944] Fix | Delete
$lock_name = 'update_comment_type.lock';
[3945] Fix | Delete
[3946] Fix | Delete
// Try to lock.
[3947] Fix | Delete
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
[3948] Fix | Delete
[3949] Fix | Delete
if ( ! $lock_result ) {
[3950] Fix | Delete
$lock_result = get_option( $lock_name );
[3951] Fix | Delete
[3952] Fix | Delete
// Bail if we were unable to create a lock, or if the existing lock is still valid.
[3953] Fix | Delete
if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
[3954] Fix | Delete
wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
[3955] Fix | Delete
return;
[3956] Fix | Delete
}
[3957] Fix | Delete
}
[3958] Fix | Delete
[3959] Fix | Delete
// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
[3960] Fix | Delete
update_option( $lock_name, time() );
[3961] Fix | Delete
[3962] Fix | Delete
// Check if there's still an empty comment type.
[3963] Fix | Delete
$empty_comment_type = $wpdb->get_var(
[3964] Fix | Delete
"SELECT comment_ID FROM $wpdb->comments
[3965] Fix | Delete
WHERE comment_type = ''
[3966] Fix | Delete
LIMIT 1"
[3967] Fix | Delete
);
[3968] Fix | Delete
[3969] Fix | Delete
// No empty comment type, we're done here.
[3970] Fix | Delete
if ( ! $empty_comment_type ) {
[3971] Fix | Delete
update_option( 'finished_updating_comment_type', true );
[3972] Fix | Delete
delete_option( $lock_name );
[3973] Fix | Delete
return;
[3974] Fix | Delete
}
[3975] Fix | Delete
[3976] Fix | Delete
// Empty comment type found? We'll need to run this script again.
[3977] Fix | Delete
wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
[3978] Fix | Delete
[3979] Fix | Delete
/**
[3980] Fix | Delete
* Filters the comment batch size for updating the comment type.
[3981] Fix | Delete
*
[3982] Fix | Delete
* @since 5.5.0
[3983] Fix | Delete
*
[3984] Fix | Delete
* @param int $comment_batch_size The comment batch size. Default 100.
[3985] Fix | Delete
*/
[3986] Fix | Delete
$comment_batch_size = (int) apply_filters( 'wp_update_comment_type_batch_size', 100 );
[3987] Fix | Delete
[3988] Fix | Delete
// Get the IDs of the comments to update.
[3989] Fix | Delete
$comment_ids = $wpdb->get_col(
[3990] Fix | Delete
$wpdb->prepare(
[3991] Fix | Delete
"SELECT comment_ID
[3992] Fix | Delete
FROM {$wpdb->comments}
[3993] Fix | Delete
WHERE comment_type = ''
[3994] Fix | Delete
ORDER BY comment_ID DESC
[3995] Fix | Delete
LIMIT %d",
[3996] Fix | Delete
$comment_batch_size
[3997] Fix | Delete
)
[3998] Fix | Delete
);
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function