From 3104f058054b4d66c9c5a0fdbe6e4a8b169bd4ae Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Wed, 15 Jun 2016 15:47:22 +0000 Subject: [PATCH] adding option for trashed posts to send deleted notifications while displaying 410 Gone pages for any trashed but not entirelly delete posts --- sender.php | 3 ++- wp-webmention-again.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sender.php b/sender.php index c3fb3b2..c7f0634 100644 --- a/sender.php +++ b/sender.php @@ -119,7 +119,8 @@ class WP_Webmention_Again_Sender extends WP_Webmention_Again { return false; } - if ( 'publish' != $new_status ) { + // send delete messages when trashed + if ( 'publish' != $new_status || 'trash' != $new_status ) { return false; } else { diff --git a/wp-webmention-again.php b/wp-webmention-again.php index e708a8d..eb5da14 100644 --- a/wp-webmention-again.php +++ b/wp-webmention-again.php @@ -88,6 +88,24 @@ class WP_Webmention_Again { // 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.'); + } + } /**