Version Description
- fixed "plugin name"
- nicer docs
- WordPress coding standard
Download this release
Release Info
Developer | pfefferle |
Plugin | WebSub/PubSubHubbub |
Version | 1.7.0 |
Comparing to | |
See all releases |
Code changes from version 1.6.5 to 1.7.0
- publisher.php +82 -75
- pubsubhubbub.php +241 -187
- readme.txt +14 -9
publisher.php
CHANGED
@@ -12,79 +12,86 @@
|
|
12 |
* @author Matthias Pfefferle
|
13 |
*/
|
14 |
class PshbPublisher {
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
-
?>
|
12 |
* @author Matthias Pfefferle
|
13 |
*/
|
14 |
class PshbPublisher {
|
15 |
+
protected $hub_url;
|
16 |
+
protected $last_response;
|
17 |
+
|
18 |
+
// create a new Publisher
|
19 |
+
public function __construct($hub_url) {
|
20 |
+
|
21 |
+
if ( ! isset( $hub_url ) ) {
|
22 |
+
throw new Exception( 'Please specify a hub url' );
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( ! preg_match( '|^https?://|i', $hub_url ) ) {
|
26 |
+
throw new Exception( 'The specified hub url does not appear to be valid: ' . $hub_url );
|
27 |
+
}
|
28 |
+
|
29 |
+
$this->hub_url = $hub_url;
|
30 |
+
}
|
31 |
+
|
32 |
+
// accepts either a single url or an array of urls
|
33 |
+
public function publish_update( $topic_urls, $http_function = false ) {
|
34 |
+
if ( ! isset( $topic_urls ) ) {
|
35 |
+
throw new Exception( 'Please specify a topic url' );
|
36 |
+
}
|
37 |
+
|
38 |
+
// check that we're working with an array
|
39 |
+
if ( ! is_array( $topic_urls ) ) {
|
40 |
+
$topic_urls = array( $topic_urls );
|
41 |
+
}
|
42 |
+
|
43 |
+
// set the mode to publish
|
44 |
+
$post_string = 'hub.mode=publish';
|
45 |
+
// loop through each topic url
|
46 |
+
foreach ( $topic_urls as $topic_url ) {
|
47 |
+
// lightweight check that we're actually working w/ a valid url
|
48 |
+
if ( ! preg_match( '|^https?://|i', $topic_url ) ) {
|
49 |
+
throw new Exception( 'The specified topic url does not appear to be valid: ' . $topic_url );
|
50 |
+
}
|
51 |
+
|
52 |
+
// append the topic url parameters
|
53 |
+
$post_string .= '&hub.url=' . urlencode( $topic_url );
|
54 |
+
}
|
55 |
+
|
56 |
+
// make the http post request and return true/false
|
57 |
+
// easy to over-write to use your own http function
|
58 |
+
if ( $http_function ) {
|
59 |
+
return $http_function( $this->hub_url, $post_string );
|
60 |
+
} else {
|
61 |
+
return $this->http_post( $this->hub_url, $post_string );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// returns any error message from the latest request
|
66 |
+
public function last_response() {
|
67 |
+
return $this->last_response;
|
68 |
+
}
|
69 |
+
|
70 |
+
// default http function that uses curl to post to the hub endpoint
|
71 |
+
private function http_post( $url, $post_string ) {
|
72 |
+
// add any additional curl options here
|
73 |
+
$options = array(
|
74 |
+
CURLOPT_URL => $url,
|
75 |
+
CURLOPT_POST => true,
|
76 |
+
CURLOPT_POSTFIELDS => $post_string,
|
77 |
+
CURLOPT_RETURNTRANSFER => true,
|
78 |
+
CURLOPT_USERAGENT => 'PubSubHubbub-Publisher-PHP/1.0',
|
79 |
+
);
|
80 |
+
|
81 |
+
$ch = curl_init();
|
82 |
+
curl_setopt_array( $ch, $options );
|
83 |
+
|
84 |
+
$response = curl_exec( $ch );
|
85 |
+
$this->last_response = $response;
|
86 |
+
$info = curl_getinfo( $ch );
|
87 |
+
|
88 |
+
curl_close( $ch );
|
89 |
+
|
90 |
+
// all good
|
91 |
+
if ( 204 == $info['http_code'] ) {
|
92 |
+
return true;
|
93 |
+
}
|
94 |
+
|
95 |
+
return false;
|
96 |
+
}
|
97 |
}
|
|
pubsubhubbub.php
CHANGED
@@ -3,251 +3,305 @@
|
|
3 |
Plugin Name: PubSubHubbub
|
4 |
Plugin URI: http://code.google.com/p/pubsubhubbub/
|
5 |
Description: A better way to tell the world when your blog is updated.
|
6 |
-
Version: 1.
|
7 |
Author: Josh Fraser, Matthias Pfefferle
|
8 |
Author Email: joshfraz@gmail.com
|
9 |
Author URI: http://wordpress.org/extend/plugins/pubsubhubbub/
|
10 |
*/
|
11 |
|
12 |
-
include(
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
-
|
32 |
-
function
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
}
|
40 |
-
add_action('publish_post', 'pshb_publish_post');
|
41 |
|
42 |
-
|
43 |
-
function
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
|
|
48 |
|
49 |
-
|
50 |
}
|
51 |
-
add_action('comment_post', 'pshb_publish_comment');
|
52 |
|
53 |
-
|
|
|
|
|
54 |
function pshb_add_atom_link_tag() {
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
}
|
60 |
-
add_action('atom_head', 'pshb_add_atom_link_tag');
|
61 |
-
add_action('comments_atom_head', 'pshb_add_atom_link_tag');
|
62 |
-
//add_action('wp_head', 'pshb_add_atom_link_tag');
|
63 |
|
|
|
|
|
|
|
64 |
function pshb_add_rss_link_tag() {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
}
|
70 |
-
add_action('rss_head', 'pshb_add_rss_link_tag');
|
71 |
-
add_action('rdf_header', 'pshb_add_rss_link_tag');
|
72 |
-
add_action('rss2_head', 'pshb_add_rss_link_tag');
|
73 |
-
add_action('commentsrss2_head', 'pshb_add_rss_link_tag');
|
74 |
|
|
|
|
|
|
|
75 |
function pshb_add_rdf_ns_link() {
|
76 |
-
|
77 |
}
|
78 |
-
add_action('rdf_ns', 'pshb_add_rdf_ns_link');
|
79 |
|
80 |
-
|
81 |
-
|
|
|
|
|
82 |
function pshb_start_rss_link_tag() {
|
83 |
-
|
84 |
}
|
85 |
-
add_action('do_feed_rss', 'pshb_start_rss_link_tag', 9); // run before output
|
86 |
|
87 |
-
|
88 |
-
|
|
|
|
|
89 |
function pshb_end_rss_link_tag() {
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
}
|
96 |
-
add_action('do_feed_rss', 'pshb_end_rss_link_tag', 11); // run after output
|
97 |
|
98 |
-
|
|
|
|
|
99 |
function pshb_add_plugin_menu() {
|
100 |
-
|
101 |
}
|
102 |
-
add_action('admin_menu', 'pshb_add_plugin_menu');
|
103 |
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
106 |
function pshb_get_pubsub_endpoints() {
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
}
|
127 |
|
128 |
-
|
|
|
|
|
|
|
|
|
129 |
function pshb_get_feed_urls() {
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
}
|
139 |
|
140 |
-
|
|
|
|
|
|
|
|
|
141 |
function pshb_get_comment_feed_urls() {
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
<li><a href='http://www.onlineaspect.com'>Subscribe to Online Aspect</a></li>
|
191 |
-
<li><a href='http://www.twitter.com/joshfraser'>Follow Josh Fraser on twitter</a></li>
|
192 |
-
<li><a href='http://code.google.com/p/pubsubhubbub/'>Learn more about the PubSubHubbub protocol</a></li>
|
193 |
-
</ul>
|
194 |
-
</div>
|
195 |
</div>
|
196 |
|
197 |
<?php }
|
198 |
|
199 |
-
|
|
|
|
|
200 |
function pshb_add_settings_link( $links, $file ) {
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
}
|
207 |
-
add_filter('plugin_action_links', 'pshb_add_settings_link', 10, 2);
|
208 |
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
210 |
function pshb_query_var($vars) {
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
}
|
218 |
-
add_filter('query_vars', 'pshb_query_var');
|
219 |
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
222 |
function pshb_template_redirect() {
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
238 |
}
|
239 |
-
add_action('template_redirect', 'pshb_template_redirect');
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
|
|
|
|
244 |
}
|
245 |
-
add_action('admin_init', '
|
246 |
|
247 |
/**
|
248 |
* beeing backwards compatible
|
|
|
|
|
249 |
* @deprecated
|
250 |
*/
|
251 |
-
function publish_to_hub($deprecated = null, $feed_urls)
|
252 |
-
|
253 |
}
|
3 |
Plugin Name: PubSubHubbub
|
4 |
Plugin URI: http://code.google.com/p/pubsubhubbub/
|
5 |
Description: A better way to tell the world when your blog is updated.
|
6 |
+
Version: 1.7.0
|
7 |
Author: Josh Fraser, Matthias Pfefferle
|
8 |
Author Email: joshfraz@gmail.com
|
9 |
Author URI: http://wordpress.org/extend/plugins/pubsubhubbub/
|
10 |
*/
|
11 |
|
12 |
+
include( 'publisher.php' );
|
13 |
|
14 |
+
/**
|
15 |
+
* the ability for other plugins to hook into the PuSH code
|
16 |
+
*
|
17 |
+
* @param array $feed_urls a list of feed urls you want to publish
|
18 |
+
*/
|
19 |
+
function pshb_publish_to_hub( $feed_urls ) {
|
20 |
+
// remove dups (ie. they all point to feedburner)
|
21 |
+
$feed_urls = array_unique( $feed_urls );
|
22 |
+
// get the list of hubs
|
23 |
+
$hub_urls = pshb_get_pubsub_endpoints();
|
24 |
+
// loop through each hub
|
25 |
+
foreach ( $hub_urls as $hub_url ) {
|
26 |
+
$p = new PshbPublisher( $hub_url );
|
27 |
+
// publish the update to each hub
|
28 |
+
if ( ! $p->publish_update( $feed_urls ) ) {
|
29 |
+
// TODO: add better error handling here
|
30 |
+
}
|
31 |
+
}
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
* function that is called whenever a new post is published
|
36 |
+
*
|
37 |
+
* @param int $post_id the post-id
|
38 |
+
* @return int the post-id
|
39 |
+
*/
|
40 |
+
function pshb_publish_post( $post_id ) {
|
41 |
+
// get default feeds
|
42 |
+
$feed_urls = pshb_get_feed_urls();
|
43 |
|
44 |
+
// publish them
|
45 |
+
pshb_publish_to_hub( $feed_urls );
|
46 |
|
47 |
+
return $post_id;
|
48 |
}
|
49 |
+
add_action( 'publish_post', 'pshb_publish_post' );
|
50 |
|
51 |
+
/**
|
52 |
+
* function that is called whenever a new comment is published
|
53 |
+
*
|
54 |
+
* @param int $comment_id the comment-id
|
55 |
+
* @return int the comment-id
|
56 |
+
*/
|
57 |
+
function pshb_publish_comment( $comment_id ) {
|
58 |
+
// get default comment-feeds
|
59 |
+
$feed_urls = pshb_get_comment_feed_urls();
|
60 |
|
61 |
+
// publish them
|
62 |
+
pshb_publish_to_hub( $feed_urls );
|
63 |
|
64 |
+
return $comment_id;
|
65 |
}
|
66 |
+
add_action( 'comment_post', 'pshb_publish_comment' );
|
67 |
|
68 |
+
/**
|
69 |
+
* add hub-<link> to the atom feed
|
70 |
+
*/
|
71 |
function pshb_add_atom_link_tag() {
|
72 |
+
$hub_urls = pshb_get_pubsub_endpoints();
|
73 |
+
foreach ( $hub_urls as $hub_url ) {
|
74 |
+
echo '<link rel="hub" href="'.$hub_url.'" />';
|
75 |
+
}
|
76 |
}
|
77 |
+
add_action( 'atom_head', 'pshb_add_atom_link_tag' );
|
78 |
+
add_action( 'comments_atom_head', 'pshb_add_atom_link_tag' );
|
|
|
79 |
|
80 |
+
/**
|
81 |
+
* add hub-<link> to the rss/rdf feed
|
82 |
+
*/
|
83 |
function pshb_add_rss_link_tag() {
|
84 |
+
$hub_urls = pshb_get_pubsub_endpoints();
|
85 |
+
foreach ( $hub_urls as $hub_url ) {
|
86 |
+
echo '<atom:link rel="hub" href="'.$hub_url.'"/>';
|
87 |
+
}
|
88 |
}
|
89 |
+
add_action( 'rss_head', 'pshb_add_rss_link_tag' );
|
90 |
+
add_action( 'rdf_header', 'pshb_add_rss_link_tag' );
|
91 |
+
add_action( 'rss2_head', 'pshb_add_rss_link_tag' );
|
92 |
+
add_action( 'commentsrss2_head', 'pshb_add_rss_link_tag' );
|
93 |
|
94 |
+
/**
|
95 |
+
* add atom namespace to rdf-feed
|
96 |
+
*/
|
97 |
function pshb_add_rdf_ns_link() {
|
98 |
+
echo ' xmlns:atom="http://www.w3.org/2005/Atom" ' . PHP_EOL;
|
99 |
}
|
100 |
+
add_action( 'rdf_ns', 'pshb_add_rdf_ns_link' );
|
101 |
|
102 |
+
/**
|
103 |
+
* hack to add the atom definition to the RSS feed
|
104 |
+
* start capturing the feed output. this is run at priority 9 (before output)
|
105 |
+
*/
|
106 |
function pshb_start_rss_link_tag() {
|
107 |
+
ob_start();
|
108 |
}
|
109 |
+
add_action( 'do_feed_rss', 'pshb_start_rss_link_tag', 9 ); // run before output
|
110 |
|
111 |
+
/**
|
112 |
+
* this is run at priority 11 (after output)
|
113 |
+
* add in the xmlns atom definition link
|
114 |
+
*/
|
115 |
function pshb_end_rss_link_tag() {
|
116 |
+
$feed = ob_get_clean();
|
117 |
+
$pattern = '/<rss version="(.+)">/i';
|
118 |
+
$replacement = '<rss version="$1" xmlns:atom="http://www.w3.org/2005/Atom">';
|
119 |
+
// change <rss version="X.XX"> to <rss version="X.XX" xmlns:atom="http://www.w3.org/2005/Atom">
|
120 |
+
echo preg_replace( $pattern, $replacement, $feed );
|
121 |
}
|
122 |
+
add_action( 'do_feed_rss', 'pshb_end_rss_link_tag', 11 ); // run after output
|
123 |
|
124 |
+
/**
|
125 |
+
* add a link to our settings page in the WP menu
|
126 |
+
*/
|
127 |
function pshb_add_plugin_menu() {
|
128 |
+
add_options_page( 'PubSubHubbub Settings', 'PubSubHubbub', 'administrator', 'pubsubhubbub', 'pshb_add_settings_page' );
|
129 |
}
|
130 |
+
add_action( 'admin_menu', 'pshb_add_plugin_menu' );
|
131 |
|
132 |
+
/**
|
133 |
+
* get the endpoints from the wordpress options table
|
134 |
+
* valid parameters are "publish" or "subscribe"
|
135 |
+
*
|
136 |
+
* @uses apply_filters() Calls 'pshb_hub_urls' filter
|
137 |
+
*/
|
138 |
function pshb_get_pubsub_endpoints() {
|
139 |
+
$endpoints = get_option( 'pubsub_endpoints' );
|
140 |
+
$hub_urls = explode( PHP_EOL, $endpoints );
|
141 |
+
|
142 |
+
// if no values have been set, revert to the defaults (pubsubhubbub on app engine & superfeedr)
|
143 |
+
if ( ! $endpoints ) {
|
144 |
+
$hub_urls[] = 'http://pubsubhubbub.appspot.com';
|
145 |
+
$hub_urls[] = 'http://pubsubhubbub.superfeedr.com';
|
146 |
+
}
|
147 |
+
|
148 |
+
// clean out any blank values
|
149 |
+
foreach ( $hub_urls as $key => $value ) {
|
150 |
+
if ( is_null( $value ) || '' == $value ) {
|
151 |
+
unset( $hub_urls[ $key ] );
|
152 |
+
} else {
|
153 |
+
$hub_urls[ $key ] = trim( $hub_urls[ $key ] );
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
return apply_filters( 'pshb_hub_urls', $hub_urls );
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* helper function to get feed urls
|
162 |
+
*
|
163 |
+
* @uses apply_filters() Calls 'pshb_feed_urls' filter
|
164 |
+
*/
|
165 |
function pshb_get_feed_urls() {
|
166 |
+
// we want to notify the hub for every feed
|
167 |
+
$feed_urls = array();
|
168 |
+
$feed_urls[] = get_bloginfo( 'atom_url' );
|
169 |
+
$feed_urls[] = get_bloginfo( 'rss_url' );
|
170 |
+
$feed_urls[] = get_bloginfo( 'rdf_url' );
|
171 |
+
$feed_urls[] = get_bloginfo( 'rss2_url' );
|
172 |
+
|
173 |
+
return apply_filters( 'pshb_feed_urls', $feed_urls );
|
174 |
}
|
175 |
|
176 |
+
/**
|
177 |
+
* helper function to get comment-feed urls
|
178 |
+
*
|
179 |
+
* @uses apply_filters() Calls 'pshb_comment_feed_urls' filter
|
180 |
+
*/
|
181 |
function pshb_get_comment_feed_urls() {
|
182 |
+
// we want to notify the hub for every feed
|
183 |
+
$feed_urls = array();
|
184 |
+
$feed_urls[] = get_bloginfo( 'comments_atom_url' );
|
185 |
+
$feed_urls[] = get_bloginfo( 'comments_rss2_url' );
|
186 |
+
|
187 |
+
return apply_filters( 'pshb_comment_feed_urls', $feed_urls );
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* write the content for our settings page that allows you to
|
192 |
+
* define your endpoints
|
193 |
+
*/
|
194 |
+
function pshb_add_settings_page() {
|
195 |
+
?>
|
196 |
+
<div class="wrap">
|
197 |
+
<h2><?php _e( 'Define custom hubs', 'pubsubhubbub' ); ?></h2>
|
198 |
+
|
199 |
+
<form method="post" action="options.php">
|
200 |
+
<?php //wp_nonce_field('update-options'); ?>
|
201 |
+
<!-- starting -->
|
202 |
+
<?php settings_fields( 'pubsubhubbub_options' ); ?>
|
203 |
+
<?php do_settings_sections( 'pubsubhubbub_options' ); ?>
|
204 |
+
<!-- ending -->
|
205 |
+
|
206 |
+
<?php
|
207 |
+
// load the existing pubsub endpoint list from the wordpress options table
|
208 |
+
$pubsub_endpoints = trim( implode( PHP_EOL, pshb_get_pubsub_endpoints() ), PHP_EOL );
|
209 |
+
?>
|
210 |
+
|
211 |
+
<table class="form-table">
|
212 |
+
<tr valign="top">
|
213 |
+
<th scope="row"><?php _e( 'Hubs (one per line)', 'pubsubhubbub' ); ?></th>
|
214 |
+
<td><textarea name="pubsub_endpoints" rows="10" cols="50" class="large-text"><?php echo $pubsub_endpoints; ?></textarea></td>
|
215 |
+
</tr>
|
216 |
+
</table>
|
217 |
+
|
218 |
+
<?php submit_button(); ?>
|
219 |
+
|
220 |
+
</form>
|
221 |
+
|
222 |
+
<p><strong><?php _e( 'Thanks for using PubSubHubbub!', 'pubsubhubbub' ); ?></strong></p>
|
223 |
+
|
224 |
+
<p><?php _e( 'Visit these links to learn more about PubSubHubbub and the author of this plugin:', 'pubsubhubbub' ); ?></p>
|
225 |
+
<ul>
|
226 |
+
<li>Subscribe to <a href='http://www.onlineaspect.com'>Online Aspect</a> or <a href='http://notizblog.org/'>notizBlog</a> (german)</li>
|
227 |
+
<li>Follow <a href='http://twitter.com/joshfraser'>Josh Fraser</a> or <a href='http://twitter.com/pfefferle'>Matthias Pfefferle</a> on twitter</li>
|
228 |
+
<li><a href='http://code.google.com/p/pubsubhubbub/'><?php _e( 'Learn more about the PubSubHubbub protocol', 'pubsubhubbub' ); ?></a></li>
|
229 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
230 |
</div>
|
231 |
|
232 |
<?php }
|
233 |
|
234 |
+
/**
|
235 |
+
* add a settings link next to deactive / edit
|
236 |
+
*/
|
237 |
function pshb_add_settings_link( $links, $file ) {
|
238 |
+
if ( 'pubsubhubbub/pubsubhubbub.php' == $file && function_exists( 'admin_url' ) ) {
|
239 |
+
$settings_link = '<a href="' . admin_url( 'options-general.php?page=pubsubhubbub' ) . '">' . __( 'Settings' ) . '</a>';
|
240 |
+
array_unshift( $links, $settings_link ); // before other links
|
241 |
+
}
|
242 |
+
return $links;
|
243 |
}
|
244 |
+
add_filter( 'plugin_action_links', 'pshb_add_settings_link', 10, 2 );
|
245 |
|
246 |
+
/**
|
247 |
+
* adds some query vars
|
248 |
+
*
|
249 |
+
* @param array $vars a list of query-vars
|
250 |
+
* @return array the list with the added PuSH params
|
251 |
+
*/
|
252 |
function pshb_query_var($vars) {
|
253 |
+
$vars[] = 'hub_mode';
|
254 |
+
$vars[] = 'hub_challenge';
|
255 |
+
$vars[] = 'hub_topic';
|
256 |
+
$vars[] = 'hub_url';
|
257 |
+
$vars[] = 'pubsubhubbub';
|
258 |
+
return $vars;
|
259 |
}
|
260 |
+
add_filter( 'query_vars', 'pshb_query_var' );
|
261 |
|
262 |
+
/**
|
263 |
+
* adds link headers as defined in the curren v0.4 draft
|
264 |
+
*
|
265 |
+
* @link https://github.com/pubsubhubbub/PubSubHubbub/issues/2
|
266 |
+
*/
|
267 |
function pshb_template_redirect() {
|
268 |
+
global $wp;
|
269 |
+
|
270 |
+
// get all feeds
|
271 |
+
$feed_urls = pshb_get_feed_urls();
|
272 |
+
$comment_feed_urls = pshb_get_comment_feed_urls();
|
273 |
+
|
274 |
+
// get current url
|
275 |
+
$urls = array_unique( array_merge( $feed_urls, $comment_feed_urls ) );
|
276 |
+
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
277 |
+
|
278 |
+
// check if current url is one of the feed urls
|
279 |
+
if ( in_array( $current_url, $urls ) ) {
|
280 |
+
$hub_urls = pshb_get_pubsub_endpoints();
|
281 |
+
// add all "hub" headers
|
282 |
+
foreach ( $hub_urls as $hub_url ) {
|
283 |
+
header( 'Link: <'.$hub_url.'>; rel="hub"', false );
|
284 |
+
}
|
285 |
+
// add the "self" header
|
286 |
+
header( 'Link: <'.$current_url.'>; rel="self"', false );
|
287 |
+
}
|
288 |
}
|
289 |
+
add_action( 'template_redirect', 'pshb_template_redirect' );
|
290 |
|
291 |
+
/**
|
292 |
+
* keep WPMU happy
|
293 |
+
*/
|
294 |
+
function pshb_register_settings() {
|
295 |
+
register_setting( 'pubsubhubbub_options','pubsub_endpoints' );
|
296 |
}
|
297 |
+
add_action( 'admin_init', 'pshb_register_settings' );
|
298 |
|
299 |
/**
|
300 |
* beeing backwards compatible
|
301 |
+
* based on a fix by Stephen Paul Weber (http://singpolyma.net)
|
302 |
+
*
|
303 |
* @deprecated
|
304 |
*/
|
305 |
+
function publish_to_hub( $deprecated = null, $feed_urls ) {
|
306 |
+
pshb_publish_to_hub( $feed_urls );
|
307 |
}
|
readme.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
===
|
2 |
Contributors: joshfraz, pfefferle
|
3 |
-
Tags: pubsubhubbub
|
4 |
Requires at least: 2.5
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
A better way to tell the world when your blog is updated.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
This [PubSubHubbub](
|
13 |
|
14 |
This plugin:
|
15 |
|
@@ -17,7 +17,7 @@ This plugin:
|
|
17 |
* Supports multi-user installations (Wordpress MU)
|
18 |
* Supports multiple hubs
|
19 |
* Supports all of the feed formats used by WordPress, not just ATOM and RSS2
|
20 |
-
* Supports latest spec ([Version 0.4](
|
21 |
* Announces which hubs you are using by adding `<link rel="hub" ...>` declarations to your template header and ATOM feed
|
22 |
* Adds `<atom:link rel="hub" ...>` to your RSS feeds along with the necessary XMLNS declaration for RSS 0.92/1.0
|
23 |
|
@@ -38,7 +38,7 @@ Please contact me if you operate a hub that you would like to be included as a d
|
|
38 |
|
39 |
= Where can I learn more about the PubSubHubbub protocol? =
|
40 |
|
41 |
-
You can visit [
|
42 |
|
43 |
= Where can I learn more about the authors of this plugin? =
|
44 |
|
@@ -51,6 +51,11 @@ and [Matthias Pfefferle](http://pfefferle.org "Matthias Pfefferle") at [Notizblo
|
|
51 |
|
52 |
== Changelog ==
|
53 |
|
|
|
|
|
|
|
|
|
|
|
54 |
= 1.6.5 =
|
55 |
* hotfix
|
56 |
|
@@ -67,7 +72,7 @@ and [Matthias Pfefferle](http://pfefferle.org "Matthias Pfefferle") at [Notizblo
|
|
67 |
* Bug fixes
|
68 |
|
69 |
= 1.6 =
|
70 |
-
* Added comment-feed support
|
71 |
* Added simple subscriber functions
|
72 |
* Added link header
|
73 |
|
@@ -93,4 +98,4 @@ and [Matthias Pfefferle](http://pfefferle.org "Matthias Pfefferle") at [Notizblo
|
|
93 |
== Upgrade Notice ==
|
94 |
|
95 |
= 1.4 =
|
96 |
-
Upgrade eliminates conflicts with other Wordpress plugins
|
1 |
+
=== PubSubHubbub ===
|
2 |
Contributors: joshfraz, pfefferle
|
3 |
+
Tags: pubsubhubbub, webhooks, pubsub
|
4 |
Requires at least: 2.5
|
5 |
+
Tested up to: 3.7.1
|
6 |
+
Stable tag: 1.7.0
|
7 |
|
8 |
A better way to tell the world when your blog is updated.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
This [PubSubHubbub](https://github.com/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.
|
13 |
|
14 |
This plugin:
|
15 |
|
17 |
* Supports multi-user installations (Wordpress MU)
|
18 |
* Supports multiple hubs
|
19 |
* Supports all of the feed formats used by WordPress, not just ATOM and RSS2
|
20 |
+
* Supports latest spec ([Version 0.4](http://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html))
|
21 |
* Announces which hubs you are using by adding `<link rel="hub" ...>` declarations to your template header and ATOM feed
|
22 |
* Adds `<atom:link rel="hub" ...>` to your RSS feeds along with the necessary XMLNS declaration for RSS 0.92/1.0
|
23 |
|
38 |
|
39 |
= Where can I learn more about the PubSubHubbub protocol? =
|
40 |
|
41 |
+
You can visit [PubSubHubbub on Github](https://github.com/pubsubhubbub/ "PubSubHubbub on Github")
|
42 |
|
43 |
= Where can I learn more about the authors of this plugin? =
|
44 |
|
51 |
|
52 |
== Changelog ==
|
53 |
|
54 |
+
= 1.7.0 =
|
55 |
+
* fixed "plugin name"
|
56 |
+
* nicer docs
|
57 |
+
* WordPress coding standard
|
58 |
+
|
59 |
= 1.6.5 =
|
60 |
* hotfix
|
61 |
|
72 |
* Bug fixes
|
73 |
|
74 |
= 1.6 =
|
75 |
+
* Added comment-feed support
|
76 |
* Added simple subscriber functions
|
77 |
* Added link header
|
78 |
|
98 |
== Upgrade Notice ==
|
99 |
|
100 |
= 1.4 =
|
101 |
+
Upgrade eliminates conflicts with other Wordpress plugins
|