all repos — wp-webmention-again @ 3ed6606fab9eab60d387c35163308a6b023bf90e

adding delete mention support, this time it's actually working
Peter Molnar hello@petermolnar.eu
Wed, 15 Jun 2016 16:20:54 +0000
commit

3ed6606fab9eab60d387c35163308a6b023bf90e

parent

3104f058054b4d66c9c5a0fdbe6e4a8b169bd4ae

2 files changed, 22 insertions(+), 8 deletions(-)

jump to
M sender.phpsender.php

@@ -120,7 +120,8 @@ return false;

} // send delete messages when trashed - if ( 'publish' != $new_status || 'trash' != $new_status ) { + if ( 'publish' != $new_status && 'trash' != $new_status ) { + static::debug( "Ignoring post; neither published nor trashed" ); return false; } else {

@@ -131,6 +132,9 @@ static::debug("Trying to get urls for #{$post->ID}", 6);

// try to avoid redirects, so no shortlink is sent for now as source $source = get_permalink( $post->ID ); + + if ( 'trash' == $new_status ) + $source = str_replace( '__trashed', '', $source ); // process the content as if it was the_content() $content = static::get_the_content( $post );

@@ -223,7 +227,7 @@ // try sending

$s = static::send( $send->source, $send->target ); if ( false == $s ) { - static::debug( " sending failed: ", 5); + static::debug( " sending failed", 5); } else { static::debug( " sending succeeded!", 5);

@@ -251,18 +255,23 @@ // stop selfpings on the same URL

if ( isset( $options['disable_selfpings_same_url'] ) && $options['disable_selfpings_same_url'] == '1' && $source === $target - ) - return false; + ) { + static::debug("Refusing to selfping the same url", 6); + return false; + } // stop selfpings on the same domain if ( isset( $options['disable_selfpings_same_domain'] ) && $options['disable_selfpings_same_domain'] == '1' && parse_url( $source, PHP_URL_HOST ) == parse_url( $target, PHP_URL_HOST ) - ) - return false; + ) { + static::debug("Refusing to selfping the self domain", 6); + return false; + } // discover the webmention endpoint $webmention_server_url = static::discover_endpoint( $target ); + static::debug("Endpoint discovered as: {$webmention_server_url}", 6); // if I can't find an endpoint, perhaps you can! $webmention_server_url = apply_filters( 'webmention_server_url', $webmention_server_url, $target );
M wp-webmention-again.phpwp-webmention-again.php

@@ -93,14 +93,19 @@

} public static function lookfordeleted() { - $url = substr( rtrim( ltrim( $_SERVER['REQUEST_URI'], '/' ), '/' ), 0, 191 ) . '__trashed'; + $url = substr( trim( $_SERVER['REQUEST_URI'], '/' ), 0, 191 ); + + if ( empty($url) ) + return false; + $query = new WP_Query( array ( - 'name' => $url, + 'name' => $url . '__trashed', 'post_status' => 'trash', 'post_type' => 'any' )); if ( ! empty( $query->posts ) && $query->is_singular ) { + static::debug("Found deleted post for {$url}"); status_header(410); nocache_headers(); die('This post was removed.');