all repos — wp-webmention-again @ 3104f058054b4d66c9c5a0fdbe6e4a8b169bd4ae

Unnamed repository; edit this file 'description' to name the repository.

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
commit

3104f058054b4d66c9c5a0fdbe6e4a8b169bd4ae

parent

19d08abac337561253490499173401f469e2f6f2

2 files changed, 20 insertions(+), 1 deletions(-)

jump to
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.'); + } + } /**