adding option for trashed posts to send deleted notifications while displaying 410 Gone pages for any trashed but not entirelly delete posts
Peter Molnar hello@petermolnar.eu
Wed, 15 Jun 2016 15:47:22 +0000
2 files changed,
20 insertions(+),
1 deletions(-)
M
sender.php
→
sender.php
@@ -119,7 +119,8 @@ static::debug( "Whoops, this is not a post.", 6);
return false; } - if ( 'publish' != $new_status ) { + // send delete messages when trashed + if ( 'publish' != $new_status || 'trash' != $new_status ) { return false; } else {
M
wp-webmention-again.php
→
wp-webmention-again.php
@@ -88,6 +88,24 @@
// extend current cron schedules with our entry add_filter( 'cron_schedules', array(&$this, 'add_cron_schedule' ) ); + static::lookfordeleted(); + + } + + public static function lookfordeleted() { + $url = substr( rtrim( ltrim( $_SERVER['REQUEST_URI'], '/' ), '/' ), 0, 191 ) . '__trashed'; + $query = new WP_Query( array ( + 'name' => $url, + 'post_status' => 'trash', + 'post_type' => 'any' + )); + + if ( ! empty( $query->posts ) && $query->is_singular ) { + status_header(410); + nocache_headers(); + die('This post was removed.'); + } + } /**