adding option for trashed posts to send deleted notifications while displaying 410 Gone pages for any trashed but not entirelly delete posts

This commit is contained in:
Peter Molnar 2016-06-15 15:47:22 +00:00
parent 19d08abac3
commit 3104f05805
2 changed files with 20 additions and 1 deletions

View file

@ -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 {

View file

@ -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.');
}
}
/**