Skip to content

Instantly share code, notes, and snippets.

@pfefferle
Created October 11, 2010 15:48
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 pfefferle/620744 to your computer and use it in GitHub Desktop.
Save pfefferle/620744 to your computer and use it in GitHub Desktop.
<?php
function publish_to_hub($post_id) {
// we want to notify the hub for every feed
$feed_urls = array();
$feed_urls = apply_filters('push_feed_urls', $feed_urls); // <-- a filter to add some more feeds
$feed_urls[] = get_bloginfo('atom_url');
$feed_urls[] = get_bloginfo('rss_url');
$feed_urls[] = get_bloginfo('rdf_url');
$feed_urls[] = get_bloginfo('rss2_url');
// remove dups (ie. they all point to feedburner)
$feed_urls = array_unique($feed_urls);
// get the list of hubs
$hub_urls = get_pubsub_endpoints();
// loop through each hub
foreach ($hub_urls as $hub_url) {
$p = new Publisher($hub_url);
// publish the update to each hub
if (!$p->publish_update($feed_urls, "http_post_wp")) {
// TODO: add better error handling here
}
}
return $post_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment