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.../httpdocs/clone/wp-inclu...
File: post.php
) {
[3500] Fix | Delete
return wp_trash_post( $post_id );
[3501] Fix | Delete
}
[3502] Fix | Delete
[3503] Fix | Delete
if ( 'attachment' === $post->post_type ) {
[3504] Fix | Delete
return wp_delete_attachment( $post_id, $force_delete );
[3505] Fix | Delete
}
[3506] Fix | Delete
[3507] Fix | Delete
/**
[3508] Fix | Delete
* Filters whether a post deletion should take place.
[3509] Fix | Delete
*
[3510] Fix | Delete
* @since 4.4.0
[3511] Fix | Delete
*
[3512] Fix | Delete
* @param WP_Post|false|null $delete Whether to go forward with deletion.
[3513] Fix | Delete
* @param WP_Post $post Post object.
[3514] Fix | Delete
* @param bool $force_delete Whether to bypass the Trash.
[3515] Fix | Delete
*/
[3516] Fix | Delete
$check = apply_filters( 'pre_delete_post', null, $post, $force_delete );
[3517] Fix | Delete
if ( null !== $check ) {
[3518] Fix | Delete
return $check;
[3519] Fix | Delete
}
[3520] Fix | Delete
[3521] Fix | Delete
/**
[3522] Fix | Delete
* Fires before a post is deleted, at the start of wp_delete_post().
[3523] Fix | Delete
*
[3524] Fix | Delete
* @since 3.2.0
[3525] Fix | Delete
* @since 5.5.0 Added the `$post` parameter.
[3526] Fix | Delete
*
[3527] Fix | Delete
* @see wp_delete_post()
[3528] Fix | Delete
*
[3529] Fix | Delete
* @param int $post_id Post ID.
[3530] Fix | Delete
* @param WP_Post $post Post object.
[3531] Fix | Delete
*/
[3532] Fix | Delete
do_action( 'before_delete_post', $post_id, $post );
[3533] Fix | Delete
[3534] Fix | Delete
delete_post_meta( $post_id, '_wp_trash_meta_status' );
[3535] Fix | Delete
delete_post_meta( $post_id, '_wp_trash_meta_time' );
[3536] Fix | Delete
[3537] Fix | Delete
wp_delete_object_term_relationships( $post_id, get_object_taxonomies( $post->post_type ) );
[3538] Fix | Delete
[3539] Fix | Delete
$parent_data = array( 'post_parent' => $post->post_parent );
[3540] Fix | Delete
$parent_where = array( 'post_parent' => $post_id );
[3541] Fix | Delete
[3542] Fix | Delete
if ( is_post_type_hierarchical( $post->post_type ) ) {
[3543] Fix | Delete
// Point children of this page to its parent, also clean the cache of affected children.
[3544] Fix | Delete
$children_query = $wpdb->prepare(
[3545] Fix | Delete
"SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s",
[3546] Fix | Delete
$post_id,
[3547] Fix | Delete
$post->post_type
[3548] Fix | Delete
);
[3549] Fix | Delete
[3550] Fix | Delete
$children = $wpdb->get_results( $children_query );
[3551] Fix | Delete
[3552] Fix | Delete
if ( $children ) {
[3553] Fix | Delete
$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
[3554] Fix | Delete
}
[3555] Fix | Delete
}
[3556] Fix | Delete
[3557] Fix | Delete
// Do raw query. wp_get_post_revisions() is filtered.
[3558] Fix | Delete
$revision_ids = $wpdb->get_col(
[3559] Fix | Delete
$wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $post_id )
[3560] Fix | Delete
);
[3561] Fix | Delete
[3562] Fix | Delete
// Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
[3563] Fix | Delete
foreach ( $revision_ids as $revision_id ) {
[3564] Fix | Delete
wp_delete_post_revision( $revision_id );
[3565] Fix | Delete
}
[3566] Fix | Delete
[3567] Fix | Delete
// Point all attachments to this post up one level.
[3568] Fix | Delete
$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
[3569] Fix | Delete
[3570] Fix | Delete
wp_defer_comment_counting( true );
[3571] Fix | Delete
[3572] Fix | Delete
$comment_ids = $wpdb->get_col(
[3573] Fix | Delete
$wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $post_id )
[3574] Fix | Delete
);
[3575] Fix | Delete
[3576] Fix | Delete
foreach ( $comment_ids as $comment_id ) {
[3577] Fix | Delete
wp_delete_comment( $comment_id, true );
[3578] Fix | Delete
}
[3579] Fix | Delete
[3580] Fix | Delete
wp_defer_comment_counting( false );
[3581] Fix | Delete
[3582] Fix | Delete
$post_meta_ids = $wpdb->get_col(
[3583] Fix | Delete
$wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id )
[3584] Fix | Delete
);
[3585] Fix | Delete
[3586] Fix | Delete
foreach ( $post_meta_ids as $mid ) {
[3587] Fix | Delete
delete_metadata_by_mid( 'post', $mid );
[3588] Fix | Delete
}
[3589] Fix | Delete
[3590] Fix | Delete
/**
[3591] Fix | Delete
* Fires immediately before a post is deleted from the database.
[3592] Fix | Delete
*
[3593] Fix | Delete
* The dynamic portion of the hook name, `$post->post_type`, refers to
[3594] Fix | Delete
* the post type slug.
[3595] Fix | Delete
*
[3596] Fix | Delete
* @since 6.6.0
[3597] Fix | Delete
*
[3598] Fix | Delete
* @param int $post_id Post ID.
[3599] Fix | Delete
* @param WP_Post $post Post object.
[3600] Fix | Delete
*/
[3601] Fix | Delete
do_action( "delete_post_{$post->post_type}", $post_id, $post );
[3602] Fix | Delete
[3603] Fix | Delete
/**
[3604] Fix | Delete
* Fires immediately before a post is deleted from the database.
[3605] Fix | Delete
*
[3606] Fix | Delete
* @since 1.2.0
[3607] Fix | Delete
* @since 5.5.0 Added the `$post` parameter.
[3608] Fix | Delete
*
[3609] Fix | Delete
* @param int $post_id Post ID.
[3610] Fix | Delete
* @param WP_Post $post Post object.
[3611] Fix | Delete
*/
[3612] Fix | Delete
do_action( 'delete_post', $post_id, $post );
[3613] Fix | Delete
[3614] Fix | Delete
$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
[3615] Fix | Delete
if ( ! $result ) {
[3616] Fix | Delete
return false;
[3617] Fix | Delete
}
[3618] Fix | Delete
[3619] Fix | Delete
/**
[3620] Fix | Delete
* Fires immediately after a post is deleted from the database.
[3621] Fix | Delete
*
[3622] Fix | Delete
* The dynamic portion of the hook name, `$post->post_type`, refers to
[3623] Fix | Delete
* the post type slug.
[3624] Fix | Delete
*
[3625] Fix | Delete
* @since 6.6.0
[3626] Fix | Delete
*
[3627] Fix | Delete
* @param int $post_id Post ID.
[3628] Fix | Delete
* @param WP_Post $post Post object.
[3629] Fix | Delete
*/
[3630] Fix | Delete
do_action( "deleted_post_{$post->post_type}", $post_id, $post );
[3631] Fix | Delete
[3632] Fix | Delete
/**
[3633] Fix | Delete
* Fires immediately after a post is deleted from the database.
[3634] Fix | Delete
*
[3635] Fix | Delete
* @since 2.2.0
[3636] Fix | Delete
* @since 5.5.0 Added the `$post` parameter.
[3637] Fix | Delete
*
[3638] Fix | Delete
* @param int $post_id Post ID.
[3639] Fix | Delete
* @param WP_Post $post Post object.
[3640] Fix | Delete
*/
[3641] Fix | Delete
do_action( 'deleted_post', $post_id, $post );
[3642] Fix | Delete
[3643] Fix | Delete
clean_post_cache( $post );
[3644] Fix | Delete
[3645] Fix | Delete
if ( is_post_type_hierarchical( $post->post_type ) && $children ) {
[3646] Fix | Delete
foreach ( $children as $child ) {
[3647] Fix | Delete
clean_post_cache( $child );
[3648] Fix | Delete
}
[3649] Fix | Delete
}
[3650] Fix | Delete
[3651] Fix | Delete
wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) );
[3652] Fix | Delete
[3653] Fix | Delete
/**
[3654] Fix | Delete
* Fires after a post is deleted, at the conclusion of wp_delete_post().
[3655] Fix | Delete
*
[3656] Fix | Delete
* @since 3.2.0
[3657] Fix | Delete
* @since 5.5.0 Added the `$post` parameter.
[3658] Fix | Delete
*
[3659] Fix | Delete
* @see wp_delete_post()
[3660] Fix | Delete
*
[3661] Fix | Delete
* @param int $post_id Post ID.
[3662] Fix | Delete
* @param WP_Post $post Post object.
[3663] Fix | Delete
*/
[3664] Fix | Delete
do_action( 'after_delete_post', $post_id, $post );
[3665] Fix | Delete
[3666] Fix | Delete
return $post;
[3667] Fix | Delete
}
[3668] Fix | Delete
[3669] Fix | Delete
/**
[3670] Fix | Delete
* Resets the page_on_front, show_on_front, and page_for_post settings when
[3671] Fix | Delete
* a linked page is deleted or trashed.
[3672] Fix | Delete
*
[3673] Fix | Delete
* Also ensures the post is no longer sticky.
[3674] Fix | Delete
*
[3675] Fix | Delete
* @since 3.7.0
[3676] Fix | Delete
* @access private
[3677] Fix | Delete
*
[3678] Fix | Delete
* @param int $post_id Post ID.
[3679] Fix | Delete
*/
[3680] Fix | Delete
function _reset_front_page_settings_for_post( $post_id ) {
[3681] Fix | Delete
$post = get_post( $post_id );
[3682] Fix | Delete
[3683] Fix | Delete
if ( 'page' === $post->post_type ) {
[3684] Fix | Delete
/*
[3685] Fix | Delete
* If the page is defined in option page_on_front or post_for_posts,
[3686] Fix | Delete
* adjust the corresponding options.
[3687] Fix | Delete
*/
[3688] Fix | Delete
if ( get_option( 'page_on_front' ) == $post->ID ) {
[3689] Fix | Delete
update_option( 'show_on_front', 'posts' );
[3690] Fix | Delete
update_option( 'page_on_front', 0 );
[3691] Fix | Delete
}
[3692] Fix | Delete
if ( get_option( 'page_for_posts' ) == $post->ID ) {
[3693] Fix | Delete
update_option( 'page_for_posts', 0 );
[3694] Fix | Delete
}
[3695] Fix | Delete
}
[3696] Fix | Delete
[3697] Fix | Delete
unstick_post( $post->ID );
[3698] Fix | Delete
}
[3699] Fix | Delete
[3700] Fix | Delete
/**
[3701] Fix | Delete
* Moves a post or page to the Trash
[3702] Fix | Delete
*
[3703] Fix | Delete
* If Trash is disabled, the post or page is permanently deleted.
[3704] Fix | Delete
*
[3705] Fix | Delete
* @since 2.9.0
[3706] Fix | Delete
*
[3707] Fix | Delete
* @see wp_delete_post()
[3708] Fix | Delete
*
[3709] Fix | Delete
* @param int $post_id Optional. Post ID. Default is the ID of the global `$post`
[3710] Fix | Delete
* if `EMPTY_TRASH_DAYS` equals true.
[3711] Fix | Delete
* @return WP_Post|false|null Post data on success, false or null on failure.
[3712] Fix | Delete
*/
[3713] Fix | Delete
function wp_trash_post( $post_id = 0 ) {
[3714] Fix | Delete
if ( ! EMPTY_TRASH_DAYS ) {
[3715] Fix | Delete
return wp_delete_post( $post_id, true );
[3716] Fix | Delete
}
[3717] Fix | Delete
[3718] Fix | Delete
$post = get_post( $post_id );
[3719] Fix | Delete
[3720] Fix | Delete
if ( ! $post ) {
[3721] Fix | Delete
return $post;
[3722] Fix | Delete
}
[3723] Fix | Delete
[3724] Fix | Delete
if ( 'trash' === $post->post_status ) {
[3725] Fix | Delete
return false;
[3726] Fix | Delete
}
[3727] Fix | Delete
[3728] Fix | Delete
$previous_status = $post->post_status;
[3729] Fix | Delete
[3730] Fix | Delete
/**
[3731] Fix | Delete
* Filters whether a post trashing should take place.
[3732] Fix | Delete
*
[3733] Fix | Delete
* @since 4.9.0
[3734] Fix | Delete
* @since 6.3.0 Added the `$previous_status` parameter.
[3735] Fix | Delete
*
[3736] Fix | Delete
* @param bool|null $trash Whether to go forward with trashing.
[3737] Fix | Delete
* @param WP_Post $post Post object.
[3738] Fix | Delete
* @param string $previous_status The status of the post about to be trashed.
[3739] Fix | Delete
*/
[3740] Fix | Delete
$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
[3741] Fix | Delete
[3742] Fix | Delete
if ( null !== $check ) {
[3743] Fix | Delete
return $check;
[3744] Fix | Delete
}
[3745] Fix | Delete
[3746] Fix | Delete
/**
[3747] Fix | Delete
* Fires before a post is sent to the Trash.
[3748] Fix | Delete
*
[3749] Fix | Delete
* @since 3.3.0
[3750] Fix | Delete
* @since 6.3.0 Added the `$previous_status` parameter.
[3751] Fix | Delete
*
[3752] Fix | Delete
* @param int $post_id Post ID.
[3753] Fix | Delete
* @param string $previous_status The status of the post about to be trashed.
[3754] Fix | Delete
*/
[3755] Fix | Delete
do_action( 'wp_trash_post', $post_id, $previous_status );
[3756] Fix | Delete
[3757] Fix | Delete
add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status );
[3758] Fix | Delete
add_post_meta( $post_id, '_wp_trash_meta_time', time() );
[3759] Fix | Delete
[3760] Fix | Delete
$post_updated = wp_update_post(
[3761] Fix | Delete
array(
[3762] Fix | Delete
'ID' => $post_id,
[3763] Fix | Delete
'post_status' => 'trash',
[3764] Fix | Delete
)
[3765] Fix | Delete
);
[3766] Fix | Delete
[3767] Fix | Delete
if ( ! $post_updated ) {
[3768] Fix | Delete
return false;
[3769] Fix | Delete
}
[3770] Fix | Delete
[3771] Fix | Delete
wp_trash_post_comments( $post_id );
[3772] Fix | Delete
[3773] Fix | Delete
/**
[3774] Fix | Delete
* Fires after a post is sent to the Trash.
[3775] Fix | Delete
*
[3776] Fix | Delete
* @since 2.9.0
[3777] Fix | Delete
* @since 6.3.0 Added the `$previous_status` parameter.
[3778] Fix | Delete
*
[3779] Fix | Delete
* @param int $post_id Post ID.
[3780] Fix | Delete
* @param string $previous_status The status of the post at the point where it was trashed.
[3781] Fix | Delete
*/
[3782] Fix | Delete
do_action( 'trashed_post', $post_id, $previous_status );
[3783] Fix | Delete
[3784] Fix | Delete
return $post;
[3785] Fix | Delete
}
[3786] Fix | Delete
[3787] Fix | Delete
/**
[3788] Fix | Delete
* Restores a post from the Trash.
[3789] Fix | Delete
*
[3790] Fix | Delete
* @since 2.9.0
[3791] Fix | Delete
* @since 5.6.0 An untrashed post is now returned to 'draft' status by default, except for
[3792] Fix | Delete
* attachments which are returned to their original 'inherit' status.
[3793] Fix | Delete
*
[3794] Fix | Delete
* @param int $post_id Optional. Post ID. Default is the ID of the global `$post`.
[3795] Fix | Delete
* @return WP_Post|false|null Post data on success, false or null on failure.
[3796] Fix | Delete
*/
[3797] Fix | Delete
function wp_untrash_post( $post_id = 0 ) {
[3798] Fix | Delete
$post = get_post( $post_id );
[3799] Fix | Delete
[3800] Fix | Delete
if ( ! $post ) {
[3801] Fix | Delete
return $post;
[3802] Fix | Delete
}
[3803] Fix | Delete
[3804] Fix | Delete
$post_id = $post->ID;
[3805] Fix | Delete
[3806] Fix | Delete
if ( 'trash' !== $post->post_status ) {
[3807] Fix | Delete
return false;
[3808] Fix | Delete
}
[3809] Fix | Delete
[3810] Fix | Delete
$previous_status = get_post_meta( $post_id, '_wp_trash_meta_status', true );
[3811] Fix | Delete
[3812] Fix | Delete
/**
[3813] Fix | Delete
* Filters whether a post untrashing should take place.
[3814] Fix | Delete
*
[3815] Fix | Delete
* @since 4.9.0
[3816] Fix | Delete
* @since 5.6.0 Added the `$previous_status` parameter.
[3817] Fix | Delete
*
[3818] Fix | Delete
* @param bool|null $untrash Whether to go forward with untrashing.
[3819] Fix | Delete
* @param WP_Post $post Post object.
[3820] Fix | Delete
* @param string $previous_status The status of the post at the point where it was trashed.
[3821] Fix | Delete
*/
[3822] Fix | Delete
$check = apply_filters( 'pre_untrash_post', null, $post, $previous_status );
[3823] Fix | Delete
if ( null !== $check ) {
[3824] Fix | Delete
return $check;
[3825] Fix | Delete
}
[3826] Fix | Delete
[3827] Fix | Delete
/**
[3828] Fix | Delete
* Fires before a post is restored from the Trash.
[3829] Fix | Delete
*
[3830] Fix | Delete
* @since 2.9.0
[3831] Fix | Delete
* @since 5.6.0 Added the `$previous_status` parameter.
[3832] Fix | Delete
*
[3833] Fix | Delete
* @param int $post_id Post ID.
[3834] Fix | Delete
* @param string $previous_status The status of the post at the point where it was trashed.
[3835] Fix | Delete
*/
[3836] Fix | Delete
do_action( 'untrash_post', $post_id, $previous_status );
[3837] Fix | Delete
[3838] Fix | Delete
$new_status = ( 'attachment' === $post->post_type ) ? 'inherit' : 'draft';
[3839] Fix | Delete
[3840] Fix | Delete
/**
[3841] Fix | Delete
* Filters the status that a post gets assigned when it is restored from the trash (untrashed).
[3842] Fix | Delete
*
[3843] Fix | Delete
* By default posts that are restored will be assigned a status of 'draft'. Return the value of `$previous_status`
[3844] Fix | Delete
* in order to assign the status that the post had before it was trashed. The `wp_untrash_post_set_previous_status()`
[3845] Fix | Delete
* function is available for this.
[3846] Fix | Delete
*
[3847] Fix | Delete
* Prior to WordPress 5.6.0, restored posts were always assigned their original status.
[3848] Fix | Delete
*
[3849] Fix | Delete
* @since 5.6.0
[3850] Fix | Delete
*
[3851] Fix | Delete
* @param string $new_status The new status of the post being restored.
[3852] Fix | Delete
* @param int $post_id The ID of the post being restored.
[3853] Fix | Delete
* @param string $previous_status The status of the post at the point where it was trashed.
[3854] Fix | Delete
*/
[3855] Fix | Delete
$post_status = apply_filters( 'wp_untrash_post_status', $new_status, $post_id, $previous_status );
[3856] Fix | Delete
[3857] Fix | Delete
delete_post_meta( $post_id, '_wp_trash_meta_status' );
[3858] Fix | Delete
delete_post_meta( $post_id, '_wp_trash_meta_time' );
[3859] Fix | Delete
[3860] Fix | Delete
$post_updated = wp_update_post(
[3861] Fix | Delete
array(
[3862] Fix | Delete
'ID' => $post_id,
[3863] Fix | Delete
'post_status' => $post_status,
[3864] Fix | Delete
)
[3865] Fix | Delete
);
[3866] Fix | Delete
[3867] Fix | Delete
if ( ! $post_updated ) {
[3868] Fix | Delete
return false;
[3869] Fix | Delete
}
[3870] Fix | Delete
[3871] Fix | Delete
wp_untrash_post_comments( $post_id );
[3872] Fix | Delete
[3873] Fix | Delete
/**
[3874] Fix | Delete
* Fires after a post is restored from the Trash.
[3875] Fix | Delete
*
[3876] Fix | Delete
* @since 2.9.0
[3877] Fix | Delete
* @since 5.6.0 Added the `$previous_status` parameter.
[3878] Fix | Delete
*
[3879] Fix | Delete
* @param int $post_id Post ID.
[3880] Fix | Delete
* @param string $previous_status The status of the post at the point where it was trashed.
[3881] Fix | Delete
*/
[3882] Fix | Delete
do_action( 'untrashed_post', $post_id, $previous_status );
[3883] Fix | Delete
[3884] Fix | Delete
return $post;
[3885] Fix | Delete
}
[3886] Fix | Delete
[3887] Fix | Delete
/**
[3888] Fix | Delete
* Moves comments for a post to the Trash.
[3889] Fix | Delete
*
[3890] Fix | Delete
* @since 2.9.0
[3891] Fix | Delete
*
[3892] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3893] Fix | Delete
*
[3894] Fix | Delete
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
[3895] Fix | Delete
* @return mixed|void False on failure.
[3896] Fix | Delete
*/
[3897] Fix | Delete
function wp_trash_post_comments( $post = null ) {
[3898] Fix | Delete
global $wpdb;
[3899] Fix | Delete
[3900] Fix | Delete
$post = get_post( $post );
[3901] Fix | Delete
[3902] Fix | Delete
if ( ! $post ) {
[3903] Fix | Delete
return;
[3904] Fix | Delete
}
[3905] Fix | Delete
[3906] Fix | Delete
$post_id = $post->ID;
[3907] Fix | Delete
[3908] Fix | Delete
/**
[3909] Fix | Delete
* Fires before comments are sent to the Trash.
[3910] Fix | Delete
*
[3911] Fix | Delete
* @since 2.9.0
[3912] Fix | Delete
*
[3913] Fix | Delete
* @param int $post_id Post ID.
[3914] Fix | Delete
*/
[3915] Fix | Delete
do_action( 'trash_post_comments', $post_id );
[3916] Fix | Delete
[3917] Fix | Delete
$comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
[3918] Fix | Delete
[3919] Fix | Delete
if ( ! $comments ) {
[3920] Fix | Delete
return;
[3921] Fix | Delete
}
[3922] Fix | Delete
[3923] Fix | Delete
// Cache current status for each comment.
[3924] Fix | Delete
$statuses = array();
[3925] Fix | Delete
foreach ( $comments as $comment ) {
[3926] Fix | Delete
$statuses[ $comment->comment_ID ] = $comment->comment_approved;
[3927] Fix | Delete
}
[3928] Fix | Delete
add_post_meta( $post_id, '_wp_trash_meta_comments_status', $statuses );
[3929] Fix | Delete
[3930] Fix | Delete
// Set status for all comments to post-trashed.
[3931] Fix | Delete
$result = $wpdb->update( $wpdb->comments, array( 'comment_approved' => 'post-trashed' ), array( 'comment_post_ID' => $post_id ) );
[3932] Fix | Delete
[3933] Fix | Delete
clean_comment_cache( array_keys( $statuses ) );
[3934] Fix | Delete
[3935] Fix | Delete
/**
[3936] Fix | Delete
* Fires after comments are sent to the Trash.
[3937] Fix | Delete
*
[3938] Fix | Delete
* @since 2.9.0
[3939] Fix | Delete
*
[3940] Fix | Delete
* @param int $post_id Post ID.
[3941] Fix | Delete
* @param array $statuses Array of comment statuses.
[3942] Fix | Delete
*/
[3943] Fix | Delete
do_action( 'trashed_post_comments', $post_id, $statuses );
[3944] Fix | Delete
[3945] Fix | Delete
return $result;
[3946] Fix | Delete
}
[3947] Fix | Delete
[3948] Fix | Delete
/**
[3949] Fix | Delete
* Restores comments for a post from the Trash.
[3950] Fix | Delete
*
[3951] Fix | Delete
* @since 2.9.0
[3952] Fix | Delete
*
[3953] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3954] Fix | Delete
*
[3955] Fix | Delete
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
[3956] Fix | Delete
* @return true|void
[3957] Fix | Delete
*/
[3958] Fix | Delete
function wp_untrash_post_comments( $post = null ) {
[3959] Fix | Delete
global $wpdb;
[3960] Fix | Delete
[3961] Fix | Delete
$post = get_post( $post );
[3962] Fix | Delete
[3963] Fix | Delete
if ( ! $post ) {
[3964] Fix | Delete
return;
[3965] Fix | Delete
}
[3966] Fix | Delete
[3967] Fix | Delete
$post_id = $post->ID;
[3968] Fix | Delete
[3969] Fix | Delete
$statuses = get_post_meta( $post_id, '_wp_trash_meta_comments_status', true );
[3970] Fix | Delete
[3971] Fix | Delete
if ( ! $statuses ) {
[3972] Fix | Delete
return true;
[3973] Fix | Delete
}
[3974] Fix | Delete
[3975] Fix | Delete
/**
[3976] Fix | Delete
* Fires before comments are restored for a post from the Trash.
[3977] Fix | Delete
*
[3978] Fix | Delete
* @since 2.9.0
[3979] Fix | Delete
*
[3980] Fix | Delete
* @param int $post_id Post ID.
[3981] Fix | Delete
*/
[3982] Fix | Delete
do_action( 'untrash_post_comments', $post_id );
[3983] Fix | Delete
[3984] Fix | Delete
// Restore each comment to its original status.
[3985] Fix | Delete
$group_by_status = array();
[3986] Fix | Delete
foreach ( $statuses as $comment_id => $comment_status ) {
[3987] Fix | Delete
$group_by_status[ $comment_status ][] = $comment_id;
[3988] Fix | Delete
}
[3989] Fix | Delete
[3990] Fix | Delete
foreach ( $group_by_status as $status => $comments ) {
[3991] Fix | Delete
// Confidence check. This shouldn't happen.
[3992] Fix | Delete
if ( 'post-trashed' === $status ) {
[3993] Fix | Delete
$status = '0';
[3994] Fix | Delete
}
[3995] Fix | Delete
$comments_in = implode( ', ', array_map( 'intval', $comments ) );
[3996] Fix | Delete
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_approved = %s WHERE comment_ID IN ($comments_in)", $status ) );
[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