查看WP 3.3.2的代码,似乎trash_post
实际上是wp_trash_post
. 从wp_trash_post()
中的函数/wp-includes/post.php
:
do_action(\'wp_trash_post\', $post_id);
add_post_meta($post_id,\'_wp_trash_meta_status\', $post[\'post_status\']);
add_post_meta($post_id,\'_wp_trash_meta_time\', time());
$post[\'post_status\'] = \'trash\';
wp_insert_post($post);
wp_trash_post_comments($post_id);
do_action(\'trashed_post\', $post_id);
所以。。。我会仔细检查你用来设置初始标志的挂钩。
但是,有一个钩子可以用来检测用户何时恢复帖子。它的名字很贴切untrash_post
.
在这里,它是从同一个核心文件执行的:
function wp_untrash_post($post_id = 0) {
if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
return $post;
if ( $post[\'post_status\'] != \'trash\' )
return false;
do_action(\'untrash_post\', $post_id);
$post_status = get_post_meta($post_id, \'_wp_trash_meta_status\', true);
$post[\'post_status\'] = $post_status;
delete_post_meta($post_id, \'_wp_trash_meta_status\');
delete_post_meta($post_id, \'_wp_trash_meta_time\');
wp_insert_post($post);
wp_untrash_post_comments($post_id);
do_action(\'untrashed_post\', $post_id);
return $post;
}