Commit b6cf151c authored by lucha's avatar lucha Committed by lechuck
Browse files

PubSubHubbub 1.6.3

parent 0cdccdb1
<?php
// a PHP client library for pubsubhubbub
// as defined at http://code.google.com/p/pubsubhubbub/
// written by Josh Fraser | joshfraser.com | josh@eventvue.com
// written by Josh Fraser | joshfraser.com | joshfraz@gmail.com
// modified by Matthias Pfefferle | notizblog.org | matthias@pfefferle.org
// Released under Apache License 2.0
......@@ -68,6 +68,7 @@ class PshbPublisher {
$options = array(CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post_string,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => "PubSubHubbub-Publisher-PHP/1.0");
$ch = curl_init();
......@@ -86,4 +87,4 @@ class PshbPublisher {
return false;
}
}
?>
\ No newline at end of file
?>
<?php
// a PHP client library for pubsubhubbub
// as defined at http://code.google.com/p/pubsubhubbub/
// written by Josh Fraser | joshfraser.com | josh@eventvue.com
// written by Josh Fraser | joshfraser.com | joshfraz@gmail.com
// modified by Matthias Pfefferle | notizblog.org | matthias@pfefferle.org
// Released under Apache License 2.0
......@@ -17,7 +17,7 @@ class PshbSubscriber {
protected $callback_url;
protected $credentials;
// accepted values are "async" and "sync"
protected $verify = "sync";
protected $verify = "async";
protected $verify_token;
protected $lease_seconds;
......@@ -104,7 +104,7 @@ class PshbSubscriber {
return false;
}
//
// discover the hub url
public function find_hub($topic_url) {
$self = $topic_url;
$xml = $this->http($topic_url);
......@@ -145,6 +145,7 @@ class PshbSubscriber {
$this->topic_url = $self;
}
// getter
public function get_topic_url() {
return $this->topic_url;
}
......
......@@ -3,14 +3,14 @@
Plugin Name: PubSubHubbub
Plugin URI: http://code.google.com/p/pubsubhubbub/
Description: A better way to tell the world when your blog is updated.
Version: 1.6
Version: 1.6.3
Author: Josh Fraser, Matthias Pfefferle
Author Email: josh@eventvue.com
Author Email: joshfraz@gmail.com
Author URI: http://wordpress.org/extend/plugins/pubsubhubbub/
*/
include("publisher.php");
include("subscriber.php");
include("pubsubhubbub-php/publisher.php");
include("pubsubhubbub-php/subscriber.php");
// the ability for other plugins to hook into the PuSH code based on a
// fix by Stephen Paul Weber (http://singpolyma.net)
......@@ -86,6 +86,7 @@ function pshb_publish_post($post_id) {
return $post_id;
}
add_action('publish_post', 'pshb_publish_post');
// function that is called whenever a new comment is published
function pshb_publish_comment($comment_id) {
......@@ -100,13 +101,18 @@ function pshb_publish_comment($comment_id) {
return $comment_id;
}
add_action('comment_post', 'pshb_publish_comment');
// to our atom feed
function pshb_add_atom_link_tag() {
$hub_urls = pshb_get_pubsub_endpoints();
foreach ($hub_urls as $hub_url) {
echo '<link rel="hub" href="'.$hub_url.'" />';
}
}
add_action('atom_head', 'pshb_add_atom_link_tag');
add_action('comments_atom_head', 'pshb_add_atom_link_tag');
//add_action('wp_head', 'pshb_add_atom_link_tag');
function pshb_add_rss_link_tag() {
$hub_urls = pshb_get_pubsub_endpoints();
......@@ -114,16 +120,23 @@ function pshb_add_rss_link_tag() {
echo '<atom:link rel="hub" href="'.$hub_url.'"/>';
}
}
add_action('rss_head', 'pshb_add_rss_link_tag');
add_action('rdf_header', 'pshb_add_rss_link_tag');
add_action('rss2_head', 'pshb_add_rss_link_tag');
add_action('commentsrss2_head', 'pshb_add_rss_link_tag');
function pshb_add_rdf_ns_link() {
echo 'xmlns:atom="http://www.w3.org/2005/Atom"';
}
add_action('rdf_ns', 'pshb_add_rdf_ns_link');
// hack to add the atom definition to the RSS feed
// start capturing the feed output. this is run at priority 9 (before output)
function pshb_start_rss_link_tag() {
ob_start();
}
add_action('do_feed_rss', 'pshb_start_rss_link_tag', 9); // run before output
// this is run at priority 11 (after output)
// add in the xmlns atom definition link
......@@ -134,11 +147,13 @@ function pshb_end_rss_link_tag() {
// change <rss version="X.XX"> to <rss version="X.XX" xmlns:atom="http://www.w3.org/2005/Atom">
echo preg_replace($pattern, $replacement, $feed);
}
add_action('do_feed_rss', 'pshb_end_rss_link_tag', 11); // run after output
// add a link to our settings page in the WP menu
function pshb_add_plugin_menu() {
add_options_page('PubSubHubbub Settings', 'PubSubHubbub', 'administrator', __FILE__, 'pshb_add_settings_page');
}
add_action('admin_menu', 'pshb_add_plugin_menu');
// get the endpoints from the wordpress options table
// valid parameters are "publish" or "subscribe"
......@@ -149,7 +164,7 @@ function pshb_get_pubsub_endpoints() {
// if no values have been set, revert to the defaults (pubsubhubbub on app engine & superfeedr)
if (!$endpoints) {
$hub_urls[] = "http://pubsubhubbub.appspot.com";
$hub_urls[] = "http://superfeedr.com/hubbub";
$hub_urls[] = "http://pubsubhubbub.superfeedr.com";
}
// clean out any blank values
......@@ -221,6 +236,7 @@ function pshb_add_settings_link( $links, $file ) {
}
return $links;
}
add_filter('plugin_action_links', 'pshb_add_settings_link', 10, 2);
// adds some query vars
function pshb_query_var($vars) {
......@@ -231,6 +247,7 @@ function pshb_query_var($vars) {
$vars[] = 'pubsubhubbub';
return $vars;
}
add_filter('query_vars', 'pshb_query_var');
// parses the request
function pshb_parse_request() {
......@@ -259,6 +276,7 @@ function pshb_parse_request() {
exit;
}
}
add_action('parse_request', 'pshb_parse_request');
// remove something from the option list
function pshb_remove_from_option($url, $option) {
......@@ -279,47 +297,18 @@ function pshb_template_redirect() {
|| (is_feed() && !is_comment_feed() && !is_archive())) {
$hub_urls = pshb_get_pubsub_endpoints();
foreach ($hub_urls as $hub_url) {
header('Link: <'.$hub_url.'>; rel=hub');
header('Link: <'.$hub_url.'>; rel=hub', false);
}
header('Link: <'.( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'].'>; rel=self');
header('Link: <'.( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'].'>; rel=self', false);
}
}
// attach the handler that gets called every time you publish a post
add_action('publish_post', 'pshb_publish_post');
// attach the handler that gets called every time you get a comment
add_action('comment_post', 'pshb_publish_comment');
// add the link to our settings page in the WP menu structure
add_action('admin_menu', 'pshb_add_plugin_menu');
add_action('template_redirect', 'pshb_template_redirect');
// keep WPMU happy
add_action('admin_init', 'pshb_register_my_settings');
function pshb_register_my_settings() {
register_setting('my_settings_group','pubsub_endpoints');
}
// add the link tag that points to the hub in the header of our template...
// to our atom feed
add_action('atom_head', 'pshb_add_atom_link_tag');
add_action('comments_atom_head', 'pshb_add_atom_link_tag');
// to our RSS 0.92 feed (requires a bit of a hack to include the ATOM namespace definition)
add_action('do_feed_rss', 'pshb_start_rss_link_tag', 9); // run before output
add_action('do_feed_rss', 'pshb_end_rss_link_tag', 11); // run after output
add_action('rss_head', 'pshb_add_rss_link_tag');
// to our RDF / RSS 1 feed
add_action('rdf_ns', 'pshb_add_rdf_ns_link');
add_action('rdf_header', 'pshb_add_rss_link_tag');
// to our RSS 2 feed
add_action('rss2_head', 'pshb_add_rss_link_tag');
add_action('commentsrss2_head', 'pshb_add_rss_link_tag');
// to our main HTML header -- not sure if we want to include this long-term or not.
add_action('wp_head', 'pshb_add_atom_link_tag');
add_action('template_redirect', 'pshb_template_redirect');
add_filter('plugin_action_links', 'pshb_add_settings_link', 10, 2);
add_filter('query_vars', 'pshb_query_var');
add_action('parse_request', 'pshb_parse_request');
add_action('admin_init', 'pshb_register_my_settings');
/**
* beeing backwards compatible
......
=== Plugin Name ===
Contributors: joshfraz, pfefferle
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5426516
Tags: pubsubhubbub
Requires at least: 2.5
Tested up to: 3.3
Stable tag: 1.6
Tested up to: 3.5.1
Stable tag: 1.6.3
A better way to tell the world when your blog is updated.
== Description ==
This [PubSubHubbub](http://code.google.com/p/pubsubhubbub/ "PubSubHubbub") plugin is a simple way to let people know in real-time when your blog is updated. PubSubHubbub is quickly gaining adoption and is already being used by Google Reader, Google Alerts, FriendFeed and more.
This [PubSubHubbub](http://code.google.com/p/pubsubhubbub/ "PubSubHubbub") plugin is a simple way to let people know in real-time when your blog is updated. PubSubHubbub is widely adopted and is used by Google Reader, Google Alerts and many other services.
This plugin:
* Now supports multiple hubs!
* Sends realtime notifications when you update your blog
* Supports multi-user installations (Wordpress MU)
* Supports multiple hubs
* Supports all of the feed formats used by WordPress, not just ATOM and RSS2
* Announces which hubs you are using by adding `<link rel="hub" ...>` declarations to your template header and ATOM feed
* Adds `<atom:link rel="hub" ...>` to your RSS feeds along with the necessary XMLNS declaration for RSS 0.92/1.0
......@@ -22,7 +23,7 @@ This plugin:
By default this plugin will ping the following hubs:
* [Demo hub on Google App Engine](http://pubsubhubbub.appspot.com "Demo hub on Google App Engine")
* [SuperFeedr](http://superfeedr.com/hubbub "SuperFeedr")
* [SuperFeedr](http://pubsubhubbub.superfeedr.com "SuperFeedr")
Please contact me if you operate a hub that you would like to be included as a default option.
......@@ -49,6 +50,13 @@ and [Matthias Pfefferle](http://pfefferle.org "Matthias Pfefferle") at [Notizblo
== Changelog ==
= 1.6.3 =
* Update hub URL for SuperFeedr (now pubsubhubbub.superfeedr.com)
* Update credits and documentation
= 1.6.1 =
* Bug fixes
= 1.6 =
* Added comment-feed support
* Added simple subscriber functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment