Created
July 14, 2014 14:54
-
-
Save snarfed/5641e1773ba72925f61b to your computer and use it in GitHub Desktop.
use wordpress-webmention hook to add rel-syndication links for bridgy publish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** When I POSSE a post with Bridgy Publish, add a rel-syndication URL. | |
*/ | |
function bridgy_publish_syndication_link($response, $source, $target) { | |
$json = json_decode(wp_remote_retrieve_body($response)); | |
dlog($target); | |
dlog($json); | |
dlog($response); | |
if (!is_wp_error($response) && $json && | |
(strpos($target, 'localhost:8080/publish/facebook') || | |
strpos($target, 'localhost:8080/publish/twitter'))) { | |
if ($json->url) { | |
$post = get_post(the_ID()); | |
$post->post_content .= | |
"\n" . '<a rel="syndication" class="u-syndication" href="' . | |
$json->url . '"></a>'; | |
wp_insert_post($post); | |
} | |
} | |
} | |
add_action('webmention_post_send', 'bridgy_publish_syndication_link'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment