Skip to content

Instantly share code, notes, and snippets.

@snarfed
Created July 14, 2014 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snarfed/5641e1773ba72925f61b to your computer and use it in GitHub Desktop.
Save snarfed/5641e1773ba72925f61b to your computer and use it in GitHub Desktop.
use wordpress-webmention hook to add rel-syndication links for bridgy publish
/** 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