wp_scheduled_delete [ WordPress Function ]
wp_scheduled_delete ( No parameters )
| Defined at: |
|
Benzer Fonksiyonlar: wp_schedule_event, wp_unschedule_event, wp_reschedule_event, wp_cache_delete, wp_schedule_single_event
Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
Source
<?php
function wp_scheduled_delete() {
global $wpdb;
$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ( (array) $posts_to_delete as $post ) {
$post_id = (int) $post['post_id'];
if ( !$post_id )
continue;
$del_post = get_post($post_id);
if ( !$del_post || 'trash' != $del_post->post_status ) {
delete_post_meta($post_id, '_wp_trash_meta_status');
delete_post_meta($post_id, '_wp_trash_meta_time');
} else {
wp_delete_post($post_id);
}
}
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ( (array) $comments_to_delete as $comment ) {
$comment_id = (int) $comment['comment_id'];
if ( !$comment_id )
continue;
$del_comment = get_comment($comment_id);
if ( !$del_comment || 'trash' != $del_comment->comment_approved ) {
delete_comment_meta($comment_id, '_wp_trash_meta_time');
delete_comment_meta($comment_id, '_wp_trash_meta_status');
} else {
wp_delete_comment($comment_id);
}
}
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Ticket #11442 - WordPress Trac
This patch prevents wp_scheduled_delete() from deleting a comment with trash meta that isn't currently in the trash. Provides coverage for posts as well.
core.trac.wordpress.org - wp_scheduled_delete (WordPress Function) - WPSeek.com
WordPress lookup for wp_scheduled_delete, a WordPress Function. wpseek. com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - wp config - Turn Off Automatic Trash Deletion? - WordPress
Jan 25, 2011 ... function my_remove_schedule_delete() { remove_action( 'wp_scheduled_delete' , 'wp_scheduled_delete' ); } add_action( 'init', ...
wordpress.stackexchange.com - plesk - Why is wp-cron taking up so many resources? - Server Fault
Apr 22, 2010... Apr 23, 2010 @ 12:21 (1272025294) Once Daily wp_scheduled_delete. Running CentoOS 5/plesk 9.3/php as FastCGI/suExec with WP 2.9.2 ...
serverfault.com