public
Last active

  • Download Gist
push.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.