Version Description
- optimized the DB load
- added help section
- better code encapsulation
Download this release
Release Info
Developer | pfefferle |
Plugin | WebSub/PubSubHubbub |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.2 to 3.0.0
- .svnignore +1 -0
- includes/class-pubsubhubbub-admin.php +103 -0
- includes/class-pubsubhubbub-publisher.php +147 -0
- includes/class-pubsubhubbub-topics.php +63 -0
- includes/class-pubsubhubbub.php +12 -0
- includes/deprecated.php +2 -2
- includes/functions.php +22 -96
- includes/pubsubhubbub-publisher.php +0 -70
- languages/pubsubhubbub.pot +127 -17
- pubsubhubbub.php +30 -155
- readme.txt +32 -8
- templates/settings-page.php +21 -31
.svnignore
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
.travis.yml
|
6 |
.codeclimate.yml
|
7 |
.data
|
|
|
8 |
Gruntfile.js
|
9 |
LINGUAS
|
10 |
Makefile
|
5 |
.travis.yml
|
6 |
.codeclimate.yml
|
7 |
.data
|
8 |
+
.svnignore
|
9 |
Gruntfile.js
|
10 |
LINGUAS
|
11 |
Makefile
|
includes/class-pubsubhubbub-admin.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WebSub/PubSubHubbub admin class
|
4 |
+
*/
|
5 |
+
class Pubsubhubbub_Admin {
|
6 |
+
/**
|
7 |
+
* Add a link to our settings page in the WP menu
|
8 |
+
*/
|
9 |
+
public static function add_plugin_menu() {
|
10 |
+
$options_page = add_options_page(
|
11 |
+
'WebSub/PubSubHubbub Settings',
|
12 |
+
'WebSub/PubSubHubbub',
|
13 |
+
'administrator',
|
14 |
+
'pubsubhubbub',
|
15 |
+
array(
|
16 |
+
'Pubsubhubbub_Admin',
|
17 |
+
'add_settings_page',
|
18 |
+
)
|
19 |
+
);
|
20 |
+
|
21 |
+
add_action( 'load-' . $options_page, array( 'Pubsubhubbub_Admin', 'add_help_tab' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Write the content for our settings page that allows you to
|
26 |
+
* define your endpoints
|
27 |
+
*/
|
28 |
+
public static function add_settings_page() {
|
29 |
+
load_template( plugin_dir_path( __FILE__ ) . '../templates/settings-page.php' );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Register PubSubHubbub settings
|
34 |
+
*/
|
35 |
+
public static function register_settings() {
|
36 |
+
register_setting(
|
37 |
+
'pubsubhubbub', 'pubsubhubbub_endpoints', array(
|
38 |
+
'type' => 'string',
|
39 |
+
'description' => __( 'The WebSub/PubSubHubbub endpoints', 'pubsubhubbub' ),
|
40 |
+
'show_in_rest' => true,
|
41 |
+
'default' => '',
|
42 |
+
)
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
public static function add_help_tab() {
|
47 |
+
get_current_screen()->add_help_tab(
|
48 |
+
array(
|
49 |
+
'id' => 'overview',
|
50 |
+
'title' => __( 'Overview', 'pubsubhubbub' ),
|
51 |
+
'content' => '<p>' . __( 'WebSub provides a common mechanism for communication between publishers of any kind of Web content and their subscribers, based on HTTP web hooks. Subscription requests are relayed through hubs, which validate and verify the request. Hubs then distribute new and updated content to subscribers when it becomes available. WebSub was previously known as PubSubHubbub.', 'pubsubhubbub' ) . '</p>',
|
52 |
+
)
|
53 |
+
);
|
54 |
+
|
55 |
+
get_current_screen()->add_help_tab(
|
56 |
+
array(
|
57 |
+
'id' => 'screencast',
|
58 |
+
'title' => __( 'Terms', 'pubsubhubbub' ),
|
59 |
+
'content' =>
|
60 |
+
'<p>
|
61 |
+
<strong>' . __( 'Publisher', 'pubsubhubbub' ) . '</strong><br />' .
|
62 |
+
__( 'A WebSub Publisher is an implementation that advertises a topic and hub URL on one or more resource URLs.', 'pubsubhubbub' ) .
|
63 |
+
'</p>' .
|
64 |
+
'<p>
|
65 |
+
<strong>' . __( 'Subscriber', 'pubsubhubbub' ) . '</strong><br />' .
|
66 |
+
__( 'A WebSub Subscriber is an implementation that discovers the hub and topic URL given a resource URL, subscribes to updates at the hub, and accepts content distribution requests from the hub. The subscriber MAY support authenticated content distribution.', 'pubsubhubbub' ) .
|
67 |
+
'</p>' .
|
68 |
+
'<p>
|
69 |
+
<strong>' . __( 'Hub', 'pubsubhubbub' ) . '</strong><br />' .
|
70 |
+
__( 'A WebSub Hub is an implementation that handles subscription requests and distributes the content to subscribers when the corresponding topic URL has been updated. Hubs MUST support subscription requests with a secret and deliver authenticated requests when requested. Hubs MUST deliver the full contents of the topic URL in the request, and MAY reduce the payload to a diff if the content type supports it.', 'pubsubhubbub' ) .
|
71 |
+
'</p>',
|
72 |
+
)
|
73 |
+
);
|
74 |
+
|
75 |
+
get_current_screen()->add_help_tab(
|
76 |
+
array(
|
77 |
+
'id' => 'indieweb',
|
78 |
+
'title' => __( 'The IndieWeb', 'pubsubhubbub' ),
|
79 |
+
'content' =>
|
80 |
+
'<p>' . __( 'The IndieWeb is a people-focused alternative to the "corporate web".', 'pubsubhubbub' ) . '</p>' .
|
81 |
+
'<p>
|
82 |
+
<strong>' . __( 'Your content is yours', 'pubsubhubbub' ) . '</strong><br />' .
|
83 |
+
__( 'When you post something on the web, it should belong to you, not a corporation. Too many companies have gone out of business and lost all of their users’ data. By joining the IndieWeb, your content stays yours and in your control.', 'pubsubhubbub' ) .
|
84 |
+
'</p>' .
|
85 |
+
'<p>
|
86 |
+
<strong>' . __( 'You are better connected', 'pubsubhubbub' ) . '</strong><br />' .
|
87 |
+
__( 'Your articles and status messages can go to all services, not just one, allowing you to engage with everyone. Even replies and likes on other services can come back to your site so they’re all in one place.', 'pubsubhubbub' ) .
|
88 |
+
'</p>' .
|
89 |
+
'<p>
|
90 |
+
<strong>' . __( 'You are in control', 'pubsubhubbub' ) . '</strong><br />' .
|
91 |
+
__( 'You can post anything you want, in any format you want, with no one monitoring you. In addition, you share simple readable links such as example.com/ideas. These links are permanent and will always work.', 'pubsubhubbub' ) .
|
92 |
+
'</p>',
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
get_current_screen()->set_help_sidebar(
|
97 |
+
'<p><strong>' . __( 'For more information:', 'pubsubhubbub' ) . '</strong></p>' .
|
98 |
+
'<p>' . __( '<a href="https://indieweb.org/WebSub">IndieWeb Wiki page</a>', 'pubsubhubbub' ) . '</p>' .
|
99 |
+
'<p>' . __( '<a href="https://websub.rocks/">Test suite</a>', 'pubsubhubbub' ) . '</p>' .
|
100 |
+
'<p>' . __( '<a href="https://www.w3.org/TR/websub/">W3C Spec</a>', 'pubsubhubbub' ) . '</p>'
|
101 |
+
);
|
102 |
+
}
|
103 |
+
}
|
includes/class-pubsubhubbub-publisher.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WebSub/PubSubHubbub publisher class
|
4 |
+
*/
|
5 |
+
class PubSubHubbub_Publisher {
|
6 |
+
/**
|
7 |
+
* Function that is called whenever a new post is published
|
8 |
+
*
|
9 |
+
* @param int $post_id the post-id
|
10 |
+
* @return int the post-id
|
11 |
+
*/
|
12 |
+
public static function publish_post( $post_id ) {
|
13 |
+
// we want to notify the hub for every feed
|
14 |
+
$feed_urls = array();
|
15 |
+
$feed_urls[] = get_bloginfo( 'atom_url' );
|
16 |
+
$feed_urls[] = get_bloginfo( 'rdf_url' );
|
17 |
+
$feed_urls[] = get_bloginfo( 'rss2_url' );
|
18 |
+
|
19 |
+
if ( current_theme_supports( 'microformats2' ) ) {
|
20 |
+
$feed_urls[] = site_url( '/' );
|
21 |
+
}
|
22 |
+
|
23 |
+
$feed_urls = apply_filters( 'pubsubhubbub_feed_urls', $feed_urls, $post_id );
|
24 |
+
|
25 |
+
// publish them
|
26 |
+
self::publish_to_hub( $feed_urls );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Function that is called whenever a new comment is published
|
31 |
+
*
|
32 |
+
* @param int $comment_id the comment-id
|
33 |
+
* @return int the comment-id
|
34 |
+
*/
|
35 |
+
public static function publish_comment( $comment_id ) {
|
36 |
+
// get default comment-feeds
|
37 |
+
$feed_urls = array();
|
38 |
+
$feed_urls[] = get_bloginfo( 'comments_atom_url' );
|
39 |
+
$feed_urls[] = get_bloginfo( 'comments_rss2_url' );
|
40 |
+
|
41 |
+
$feed_urls = apply_filters( 'pubsubhubbub_comment_feed_urls', $feed_urls, $comment_id );
|
42 |
+
|
43 |
+
// publish them
|
44 |
+
self::publish_to_hub( $feed_urls );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Accepts either a single url or an array of urls
|
49 |
+
*
|
50 |
+
* @param string|array $topic_urls a single topic url or an array of topic urls
|
51 |
+
*/
|
52 |
+
public static function publish_update( $topic_urls, $hub_url ) {
|
53 |
+
if ( ! isset( $hub_url ) ) {
|
54 |
+
return new WP_Error( 'missing_hub_url', __( 'Please specify a hub url', 'pubsubhubbub' ) );
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( ! preg_match( '|^https?://|i', $hub_url ) ) {
|
58 |
+
/* translators: %s is the $hub_url */
|
59 |
+
return new WP_Error( 'invalid_hub_url', sprintf( __( 'The specified hub url does not appear to be valid: %s', 'pubsubhubbub' ), $hub_url ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
if ( ! isset( $topic_urls ) ) {
|
63 |
+
return new WP_Error( 'missing_topic_url', __( 'Please specify a topic url', 'pubsubhubbub' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
// check that we're working with an array
|
67 |
+
if ( ! is_array( $topic_urls ) ) {
|
68 |
+
$topic_urls = array( $topic_urls );
|
69 |
+
}
|
70 |
+
|
71 |
+
// set the mode to publish
|
72 |
+
$post_string = 'hub.mode=publish';
|
73 |
+
// loop through each topic url
|
74 |
+
foreach ( $topic_urls as $topic_url ) {
|
75 |
+
// lightweight check that we're actually working w/ a valid url
|
76 |
+
if ( preg_match( '|^https?://|i', $topic_url ) ) {
|
77 |
+
// append the topic url parameters
|
78 |
+
$post_string .= '&hub.url=' . esc_url( $topic_url );
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
$wp_version = get_bloginfo( 'version' );
|
83 |
+
$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
|
84 |
+
|
85 |
+
$args = array(
|
86 |
+
'timeout' => 100,
|
87 |
+
'limit_response_size' => 1048576,
|
88 |
+
'redirection' => 20,
|
89 |
+
'user-agent' => "$user_agent; PubSubHubbub/WebSub",
|
90 |
+
'body' => $post_string,
|
91 |
+
);
|
92 |
+
|
93 |
+
// make the http post request
|
94 |
+
return wp_remote_post( $hub_url, $args );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* The ability for other plugins to hook into the PuSH code
|
99 |
+
*
|
100 |
+
* @param array $feed_urls a list of feed urls you want to publish
|
101 |
+
*/
|
102 |
+
public static function publish_to_hub( $feed_urls ) {
|
103 |
+
// remove dups (ie. they all point to feedburner)
|
104 |
+
$feed_urls = array_unique( $feed_urls );
|
105 |
+
|
106 |
+
// get the list of hubs
|
107 |
+
$hub_urls = self::get_hubs();
|
108 |
+
|
109 |
+
// loop through each hub
|
110 |
+
foreach ( $hub_urls as $hub_url ) {
|
111 |
+
// publish the update to each hub
|
112 |
+
$response = self::publish_update( $feed_urls, $hub_url );
|
113 |
+
|
114 |
+
do_action( 'pubsubhubbub_publish_update_response', $response );
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get the endpoints from the WordPress options table
|
120 |
+
* valid parameters are "publish" or "subscribe"
|
121 |
+
*
|
122 |
+
* @uses apply_filters() Calls 'pubsubhubbub_hub_urls' filter
|
123 |
+
*/
|
124 |
+
public static function get_hubs() {
|
125 |
+
$endpoints = get_option( 'pubsubhubbub_endpoints' );
|
126 |
+
$hub_urls = explode( PHP_EOL, $endpoints );
|
127 |
+
|
128 |
+
// if no values have been set, revert to the defaults (websub on app engine & superfeedr)
|
129 |
+
if ( ! $endpoints || ! $hub_urls || ! is_array( $hub_urls ) ) {
|
130 |
+
$hub_urls = array(
|
131 |
+
'https://pubsubhubbub.appspot.com',
|
132 |
+
'https://pubsubhubbub.superfeedr.com',
|
133 |
+
);
|
134 |
+
}
|
135 |
+
|
136 |
+
// clean out any blank values
|
137 |
+
foreach ( $hub_urls as $key => $value ) {
|
138 |
+
if ( empty( $value ) ) {
|
139 |
+
unset( $hub_urls[ $key ] );
|
140 |
+
} else {
|
141 |
+
$hub_urls[ $key ] = trim( $hub_urls[ $key ] );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
return apply_filters( 'pubsubhubbub_hub_urls', $hub_urls );
|
146 |
+
}
|
147 |
+
}
|
includes/class-pubsubhubbub-topics.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WebSub/PubSubHubbub topics class
|
4 |
+
*/
|
5 |
+
class Pubsubhubbub_Topics {
|
6 |
+
/**
|
7 |
+
* Add hub-<link> to the Atom feed
|
8 |
+
*/
|
9 |
+
public static function add_atom_link_tag() {
|
10 |
+
// check if current url is one of the feed urls
|
11 |
+
if ( ! pubsubhubbub_show_discovery() ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
$hub_urls = pubsubhubbub_get_hubs();
|
16 |
+
|
17 |
+
foreach ( $hub_urls as $hub_url ) {
|
18 |
+
printf( '<link rel="hub" href="%s" />', $hub_url ) . PHP_EOL;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Add hub-<link> to the RSS/RDF feed
|
24 |
+
*/
|
25 |
+
public static function add_rss_link_tag() {
|
26 |
+
// check if current url is one of the feed urls
|
27 |
+
if ( ! pubsubhubbub_show_discovery() ) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
$hub_urls = pubsubhubbub_get_hubs();
|
32 |
+
|
33 |
+
foreach ( $hub_urls as $hub_url ) {
|
34 |
+
printf( '<atom:link rel="hub" href="%s"/>', $hub_url ) . PHP_EOL;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Add Atom namespace to rdf-feed
|
40 |
+
*/
|
41 |
+
public static function add_rss_ns_link() {
|
42 |
+
echo ' xmlns:atom="http://www.w3.org/2005/Atom" ' . PHP_EOL;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Adds link headers as defined in the current v0.4 draft
|
47 |
+
*/
|
48 |
+
public static function template_redirect() {
|
49 |
+
// check if current url is one of the feed urls
|
50 |
+
if ( ! pubsubhubbub_show_discovery() ) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
$hub_urls = pubsubhubbub_get_hubs();
|
55 |
+
// add all "hub" headers
|
56 |
+
foreach ( $hub_urls as $hub_url ) {
|
57 |
+
header( sprintf( 'Link: <%s>; rel="hub"', $hub_url ), false );
|
58 |
+
}
|
59 |
+
|
60 |
+
// add the "self" header
|
61 |
+
header( sprintf( 'Link: <%s>; rel="self"', pubsubhubbub_get_self_link() ), false );
|
62 |
+
}
|
63 |
+
}
|
includes/class-pubsubhubbub.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WebSub/PubSubHubbub class
|
4 |
+
*/
|
5 |
+
class Pubsubhubbub {
|
6 |
+
/**
|
7 |
+
* Load the plugin textdomain.
|
8 |
+
*/
|
9 |
+
public static function load_textdomain() {
|
10 |
+
load_plugin_textdomain( 'pubsubhubbub', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
11 |
+
}
|
12 |
+
}
|
includes/deprecated.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @deprecated
|
7 |
*/
|
8 |
function publish_to_hub( $deprecated = null, $feed_urls ) {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
/**
|
@@ -17,7 +17,7 @@ function publish_to_hub( $deprecated = null, $feed_urls ) {
|
|
17 |
* @deprecated
|
18 |
*/
|
19 |
function pshb_publish_to_hub( $feed_urls ) {
|
20 |
-
|
21 |
}
|
22 |
|
23 |
/**
|
6 |
* @deprecated
|
7 |
*/
|
8 |
function publish_to_hub( $deprecated = null, $feed_urls ) {
|
9 |
+
PubSubHubbub_Publisher::publish_to_hub( $feed_urls );
|
10 |
}
|
11 |
|
12 |
/**
|
17 |
* @deprecated
|
18 |
*/
|
19 |
function pshb_publish_to_hub( $feed_urls ) {
|
20 |
+
PubSubHubbub_Publisher::publish_to_hub( $feed_urls );
|
21 |
}
|
22 |
|
23 |
/**
|
includes/functions.php
CHANGED
@@ -5,102 +5,45 @@
|
|
5 |
* @param array $feed_urls a list of feed urls you want to publish
|
6 |
*/
|
7 |
function pubsubhubbub_publish_to_hub( $feed_urls ) {
|
8 |
-
|
9 |
-
|
10 |
-
// remove dups (ie. they all point to feedburner)
|
11 |
-
$feed_urls = array_unique( $feed_urls );
|
12 |
-
|
13 |
-
pubsubhubbub_update_topic_urls( $feed_urls );
|
14 |
-
|
15 |
-
// get the list of hubs
|
16 |
-
$hub_urls = pubsubhubbub_get_hubs();
|
17 |
-
|
18 |
-
// loop through each hub
|
19 |
-
foreach ( $hub_urls as $hub_url ) {
|
20 |
-
$p = new PubSubHubbub_Publisher( $hub_url );
|
21 |
-
// publish the update to each hub
|
22 |
-
$response = $p->publish_update( $feed_urls );
|
23 |
-
|
24 |
-
do_action( 'pubsubhubbub_publish_update_response', $response );
|
25 |
-
}
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
-
*
|
30 |
* valid parameters are "publish" or "subscribe"
|
31 |
*
|
32 |
-
*
|
33 |
*/
|
34 |
function pubsubhubbub_get_hubs() {
|
35 |
-
|
36 |
-
$hub_urls = explode( PHP_EOL, $endpoints );
|
37 |
-
|
38 |
-
// if no values have been set, revert to the defaults (websub on app engine & superfeedr)
|
39 |
-
if ( ! $endpoints || ! $hub_urls || ! is_array( $hub_urls ) ) {
|
40 |
-
$hub_urls = array(
|
41 |
-
'https://pubsubhubbub.appspot.com',
|
42 |
-
'https://pubsubhubbub.superfeedr.com',
|
43 |
-
);
|
44 |
-
}
|
45 |
-
|
46 |
-
// clean out any blank values
|
47 |
-
foreach ( $hub_urls as $key => $value ) {
|
48 |
-
if ( empty( $value ) ) {
|
49 |
-
unset( $hub_urls[ $key ] );
|
50 |
-
} else {
|
51 |
-
$hub_urls[ $key ] = trim( $hub_urls[ $key ] );
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
return apply_filters( 'pubsubhubbub_hub_urls', $hub_urls );
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
*
|
61 |
-
* @
|
62 |
*/
|
63 |
-
function
|
64 |
-
|
65 |
-
return;
|
66 |
-
}
|
67 |
-
|
68 |
-
$topic_urls = pubsubhubbub_get_topic_urls();
|
69 |
-
$topic_urls = array_merge( $topic_urls, $urls );
|
70 |
|
71 |
-
|
72 |
-
|
|
|
73 |
|
74 |
-
|
75 |
-
* Return topic urls
|
76 |
-
*
|
77 |
-
* @return array list of urls
|
78 |
-
*/
|
79 |
-
function pubsubhubbub_get_topic_urls() {
|
80 |
-
$default_feeds = array(
|
81 |
-
get_bloginfo( 'atom_url' ),
|
82 |
-
get_bloginfo( 'rdf_url' ),
|
83 |
-
get_bloginfo( 'rss2_url' ),
|
84 |
-
//get_bloginfo( 'comments_atom_url' ),
|
85 |
-
//get_bloginfo( 'comments_rss2_url' ),
|
86 |
-
);
|
87 |
|
88 |
-
$
|
|
|
89 |
|
90 |
-
if (
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
|
94 |
-
return $
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Check if link supports PubSubHubbub or WebSub
|
99 |
-
*
|
100 |
-
* @return boolean
|
101 |
-
*/
|
102 |
-
function pubsubhubbub_show_discovery() {
|
103 |
-
return (boolean) pubsubhubbub_get_self_link();
|
104 |
}
|
105 |
|
106 |
/**
|
@@ -109,22 +52,5 @@ function pubsubhubbub_show_discovery() {
|
|
109 |
* @return boolean
|
110 |
*/
|
111 |
function pubsubhubbub_get_self_link() {
|
112 |
-
|
113 |
-
$urls = pubsubhubbub_get_topic_urls();
|
114 |
-
|
115 |
-
$current_url = home_url( add_query_arg( null, null ) );
|
116 |
-
$current_url = untrailingslashit( $current_url );
|
117 |
-
$current_url = preg_replace( '/^https?:\/\//i', '', $current_url );
|
118 |
-
|
119 |
-
$matches = preg_grep( '/^https?:\/\/' . preg_quote( $current_url, '/' ) . '\/?$/i', $urls );
|
120 |
-
|
121 |
-
if ( empty( $matches ) ) {
|
122 |
-
return false;
|
123 |
-
}
|
124 |
-
|
125 |
-
if ( count( $matches ) >= 2 ) {
|
126 |
-
return home_url( add_query_arg( null, null ) );
|
127 |
-
}
|
128 |
-
|
129 |
-
return current( $matches );
|
130 |
}
|
5 |
* @param array $feed_urls a list of feed urls you want to publish
|
6 |
*/
|
7 |
function pubsubhubbub_publish_to_hub( $feed_urls ) {
|
8 |
+
PubSubHubbub_Publisher::publish_to_hub( $feed_urls );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
11 |
/**
|
12 |
+
* Get the endpoints from the WordPress options table
|
13 |
* valid parameters are "publish" or "subscribe"
|
14 |
*
|
15 |
+
* @uses apply_filters() Calls 'pubsubhubbub_hub_urls' filter
|
16 |
*/
|
17 |
function pubsubhubbub_get_hubs() {
|
18 |
+
return PubSubHubbub_Publisher::get_hubs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* Check if link supports PubSubHubbub or WebSub
|
23 |
*
|
24 |
+
* @return boolean
|
25 |
*/
|
26 |
+
function pubsubhubbub_show_discovery() {
|
27 |
+
global $withcomments;
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
if ( ! $withcomments ) {
|
30 |
+
$withcomments = 0;
|
31 |
+
}
|
32 |
|
33 |
+
$show_discovery = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
$supported_feed_types = apply_filters( 'pubsubhubbub_show_discovery_for_feed_types', array( 'atom', 'rss2', 'rdf' ) );
|
36 |
+
$supported_comment_feed_types = apply_filters( 'pubsubhubbub_show_discovery_for_comment_feed_types', array( 'atom', 'rss2' ) );
|
37 |
|
38 |
+
if (
|
39 |
+
( is_feed( $supported_feed_types ) && ! is_archive() && ! is_singular() && 0 == $withcomments ) ||
|
40 |
+
( is_feed( $supported_comment_feed_types ) && 1 == $withcomments ) ||
|
41 |
+
( is_home() && current_theme_supports( 'microformats2' ) )
|
42 |
+
) {
|
43 |
+
$show_discovery = true;
|
44 |
}
|
45 |
|
46 |
+
return apply_filters( 'pubsubhubbub_show_discovery', $show_discovery );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
52 |
* @return boolean
|
53 |
*/
|
54 |
function pubsubhubbub_get_self_link() {
|
55 |
+
return trailingslashit( home_url( add_query_arg( null, null ) ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
includes/pubsubhubbub-publisher.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// a PHP client library for pubsubhubbub
|
3 |
-
// as defined at http://code.google.com/p/pubsubhubbub/
|
4 |
-
// written by Josh Fraser | joshfraser.com | josh@eventvue.com
|
5 |
-
// modified by Matthias Pfefferle | notizblog.org | matthias@pfefferle.org
|
6 |
-
// Released under Apache License 2.0
|
7 |
-
|
8 |
-
/**
|
9 |
-
* A pubsubhubbub publisher
|
10 |
-
*
|
11 |
-
* @author Josh Fraser
|
12 |
-
* @author Matthias Pfefferle
|
13 |
-
*/
|
14 |
-
class PubSubHubbub_Publisher {
|
15 |
-
protected $hub_url;
|
16 |
-
|
17 |
-
// create a new Publisher
|
18 |
-
public function __construct( $hub_url ) {
|
19 |
-
|
20 |
-
if ( ! isset( $hub_url ) ) {
|
21 |
-
throw new Exception( 'Please specify a hub url' );
|
22 |
-
}
|
23 |
-
|
24 |
-
if ( ! preg_match( '|^https?://|i', $hub_url ) ) {
|
25 |
-
throw new Exception( 'The specified hub url does not appear to be valid: ' . $hub_url );
|
26 |
-
}
|
27 |
-
|
28 |
-
$this->hub_url = $hub_url;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* accepts either a single url or an array of urls
|
33 |
-
*
|
34 |
-
* @param string|array $topic_urls a single topic url or an array of topic urls
|
35 |
-
*/
|
36 |
-
public function publish_update( $topic_urls ) {
|
37 |
-
if ( ! isset( $topic_urls ) ) {
|
38 |
-
throw new Exception( 'Please specify a topic url' );
|
39 |
-
}
|
40 |
-
|
41 |
-
// check that we're working with an array
|
42 |
-
if ( ! is_array( $topic_urls ) ) {
|
43 |
-
$topic_urls = array( $topic_urls );
|
44 |
-
}
|
45 |
-
|
46 |
-
// set the mode to publish
|
47 |
-
$post_string = 'hub.mode=publish';
|
48 |
-
// loop through each topic url
|
49 |
-
foreach ( $topic_urls as $topic_url ) {
|
50 |
-
// lightweight check that we're actually working w/ a valid url
|
51 |
-
if ( preg_match( '|^https?://|i', $topic_url ) ) {
|
52 |
-
// append the topic url parameters
|
53 |
-
$post_string .= '&hub.url=' . esc_url( $topic_url );
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
$wp_version = get_bloginfo( 'version' );
|
58 |
-
$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
|
59 |
-
$args = array(
|
60 |
-
'timeout' => 100,
|
61 |
-
'limit_response_size' => 1048576,
|
62 |
-
'redirection' => 20,
|
63 |
-
'user-agent' => "$user_agent; PubSubHubbub/WebSub",
|
64 |
-
'body' => $post_string,
|
65 |
-
);
|
66 |
-
|
67 |
-
// make the http post request
|
68 |
-
return wp_remote_post( $this->hub_url, $args );
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/pubsubhubbub.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the MIT.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: WebSub/PubSubHubbub
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pubsubhubbub\n"
|
7 |
-
"POT-Creation-Date: 2018-02
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -13,34 +13,144 @@ msgstr ""
|
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
"X-Generator: grunt-wp-i18n 0.5.4\n"
|
15 |
|
16 |
-
#: pubsubhubbub.php:
|
17 |
-
msgid "
|
18 |
msgstr ""
|
19 |
|
20 |
-
|
21 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
msgstr ""
|
23 |
|
24 |
-
#:
|
25 |
-
msgid "
|
26 |
msgstr ""
|
27 |
|
28 |
-
#:
|
29 |
-
msgid "
|
|
|
|
|
|
|
|
|
30 |
msgstr ""
|
31 |
|
32 |
-
#:
|
33 |
-
msgid "
|
34 |
msgstr ""
|
35 |
|
36 |
-
#:
|
37 |
msgid ""
|
38 |
-
"
|
39 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
msgstr ""
|
41 |
|
42 |
-
#: templates/settings-page.php:
|
43 |
-
msgid "
|
44 |
msgstr ""
|
45 |
|
46 |
#. Plugin URI of the plugin/theme
|
2 |
# This file is distributed under the MIT.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: WebSub/PubSubHubbub 3.0.0\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pubsubhubbub\n"
|
7 |
+
"POT-Creation-Date: 2018-07-02 15:10:24+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
"X-Generator: grunt-wp-i18n 0.5.4\n"
|
15 |
|
16 |
+
#: includes/class-pubsubhubbub-admin.php:39
|
17 |
+
msgid "The WebSub/PubSubHubbub endpoints"
|
18 |
msgstr ""
|
19 |
|
20 |
+
#: includes/class-pubsubhubbub-admin.php:50
|
21 |
+
msgid "Overview"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: includes/class-pubsubhubbub-admin.php:51
|
25 |
+
msgid ""
|
26 |
+
"WebSub provides a common mechanism for communication between publishers of "
|
27 |
+
"any kind of Web content and their subscribers, based on HTTP web hooks. "
|
28 |
+
"Subscription requests are relayed through hubs, which validate and verify "
|
29 |
+
"the request. Hubs then distribute new and updated content to subscribers "
|
30 |
+
"when it becomes available. WebSub was previously known as PubSubHubbub."
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: includes/class-pubsubhubbub-admin.php:58
|
34 |
+
msgid "Terms"
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: includes/class-pubsubhubbub-admin.php:61
|
38 |
+
msgid "Publisher"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: includes/class-pubsubhubbub-admin.php:62 templates/settings-page.php:9
|
42 |
+
msgid ""
|
43 |
+
"A WebSub Publisher is an implementation that advertises a topic and hub URL "
|
44 |
+
"on one or more resource URLs."
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: includes/class-pubsubhubbub-admin.php:65
|
48 |
+
msgid "Subscriber"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: includes/class-pubsubhubbub-admin.php:66
|
52 |
+
msgid ""
|
53 |
+
"A WebSub Subscriber is an implementation that discovers the hub and topic "
|
54 |
+
"URL given a resource URL, subscribes to updates at the hub, and accepts "
|
55 |
+
"content distribution requests from the hub. The subscriber MAY support "
|
56 |
+
"authenticated content distribution."
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: includes/class-pubsubhubbub-admin.php:69
|
60 |
+
msgid "Hub"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: includes/class-pubsubhubbub-admin.php:70
|
64 |
+
msgid ""
|
65 |
+
"A WebSub Hub is an implementation that handles subscription requests and "
|
66 |
+
"distributes the content to subscribers when the corresponding topic URL has "
|
67 |
+
"been updated. Hubs MUST support subscription requests with a secret and "
|
68 |
+
"deliver authenticated requests when requested. Hubs MUST deliver the full "
|
69 |
+
"contents of the topic URL in the request, and MAY reduce the payload to a "
|
70 |
+
"diff if the content type supports it."
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: includes/class-pubsubhubbub-admin.php:78
|
74 |
+
msgid "The IndieWeb"
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: includes/class-pubsubhubbub-admin.php:80
|
78 |
+
msgid "The IndieWeb is a people-focused alternative to the \"corporate web\"."
|
79 |
msgstr ""
|
80 |
|
81 |
+
#: includes/class-pubsubhubbub-admin.php:82
|
82 |
+
msgid "Your content is yours"
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: includes/class-pubsubhubbub-admin.php:83
|
86 |
+
msgid ""
|
87 |
+
"When you post something on the web, it should belong to you, not a "
|
88 |
+
"corporation. Too many companies have gone out of business and lost all of "
|
89 |
+
"their users’ data. By joining the IndieWeb, your content stays yours and in "
|
90 |
+
"your control."
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: includes/class-pubsubhubbub-admin.php:86
|
94 |
+
msgid "You are better connected"
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: includes/class-pubsubhubbub-admin.php:87
|
98 |
msgid ""
|
99 |
+
"Your articles and status messages can go to all services, not just one, "
|
100 |
+
"allowing you to engage with everyone. Even replies and likes on other "
|
101 |
+
"services can come back to your site so they’re all in one place."
|
102 |
+
msgstr ""
|
103 |
+
|
104 |
+
#: includes/class-pubsubhubbub-admin.php:90
|
105 |
+
msgid "You are in control"
|
106 |
+
msgstr ""
|
107 |
+
|
108 |
+
#: includes/class-pubsubhubbub-admin.php:91
|
109 |
+
msgid ""
|
110 |
+
"You can post anything you want, in any format you want, with no one "
|
111 |
+
"monitoring you. In addition, you share simple readable links such as "
|
112 |
+
"example.com/ideas. These links are permanent and will always work."
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: includes/class-pubsubhubbub-admin.php:97
|
116 |
+
msgid "For more information:"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: includes/class-pubsubhubbub-admin.php:98
|
120 |
+
msgid "<a href=\"https://indieweb.org/WebSub\">IndieWeb Wiki page</a>"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: includes/class-pubsubhubbub-admin.php:99
|
124 |
+
msgid "<a href=\"https://websub.rocks/\">Test suite</a>"
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: includes/class-pubsubhubbub-admin.php:100
|
128 |
+
msgid "<a href=\"https://www.w3.org/TR/websub/\">W3C Spec</a>"
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: includes/class-pubsubhubbub-publisher.php:54
|
132 |
+
msgid "Please specify a hub url"
|
133 |
+
msgstr ""
|
134 |
+
|
135 |
+
#: includes/class-pubsubhubbub-publisher.php:59
|
136 |
+
#. translators: %s is the $hub_url
|
137 |
+
msgid "The specified hub url does not appear to be valid: %s"
|
138 |
+
msgstr ""
|
139 |
+
|
140 |
+
#: includes/class-pubsubhubbub-publisher.php:63
|
141 |
+
msgid "Please specify a topic url"
|
142 |
+
msgstr ""
|
143 |
+
|
144 |
+
#. Plugin Name of the plugin/theme
|
145 |
+
msgid "WebSub/PubSubHubbub"
|
146 |
+
msgstr ""
|
147 |
+
|
148 |
+
#: templates/settings-page.php:7
|
149 |
+
msgid "Publisher Settings"
|
150 |
msgstr ""
|
151 |
|
152 |
+
#: templates/settings-page.php:18
|
153 |
+
msgid "Hubs <small>(one per line)</small>"
|
154 |
msgstr ""
|
155 |
|
156 |
#. Plugin URI of the plugin/theme
|
pubsubhubbub.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WebSub/PubSubHubbub
|
4 |
* Plugin URI: https://github.com/pubsubhubbub/wordpress-pubsubhubbub/
|
5 |
* Description: A better way to tell the world when your blog is updated.
|
6 |
-
* Version:
|
7 |
* Author: Matthias Pfefferle
|
8 |
* Author URI: https://notiz.blog/
|
9 |
* License: MIT
|
@@ -12,180 +12,55 @@
|
|
12 |
* Domain Path: /languages
|
13 |
*/
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Initialize plugin
|
22 |
-
*/
|
23 |
-
public static function init() {
|
24 |
-
require_once( dirname( __FILE__ ) . '/includes/functions.php' );
|
25 |
-
|
26 |
-
add_action( 'publish_post', array( 'PubSubHubbub_Plugin', 'publish_post' ) );
|
27 |
-
//add_action( 'comment_post', array( 'PubSubHubbub_Plugin', 'publish_comment' ) );
|
28 |
-
|
29 |
-
add_action( 'atom_head', array( 'PubSubHubbub_Plugin', 'add_atom_link_tag' ) );
|
30 |
-
add_action( 'comments_atom_head', array( 'PubSubHubbub_Plugin', 'add_atom_link_tag' ) );
|
31 |
-
|
32 |
-
add_action( 'rdf_header', array( 'PubSubHubbub_Plugin', 'add_rss_link_tag' ) );
|
33 |
-
add_action( 'rss2_head', array( 'PubSubHubbub_Plugin', 'add_rss_link_tag' ) );
|
34 |
-
add_action( 'commentsrss2_head', array( 'PubSubHubbub_Plugin', 'add_rss_link_tag' ) );
|
35 |
-
|
36 |
-
add_action( 'rdf_ns', array( 'PubSubHubbub_Plugin', 'add_rss_ns_link' ) );
|
37 |
-
|
38 |
-
add_action( 'admin_menu', array( 'PubSubHubbub_Plugin', 'add_plugin_menu' ) );
|
39 |
-
add_action( 'admin_init', array( 'PubSubHubbub_Plugin', 'register_settings' ) );
|
40 |
-
|
41 |
-
add_filter( 'plugin_action_links', array( 'PubSubHubbub_Plugin', 'add_settings_link' ), 10, 2 );
|
42 |
-
|
43 |
-
add_action( 'template_redirect', array( 'PubSubHubbub_Plugin', 'template_redirect' ) );
|
44 |
-
|
45 |
-
require_once( dirname( __FILE__ ) . '/includes/deprecated.php' );
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Function that is called whenever a new post is published
|
50 |
-
*
|
51 |
-
* @param int $post_id the post-id
|
52 |
-
* @return int the post-id
|
53 |
-
*/
|
54 |
-
public static function publish_post( $post_id ) {
|
55 |
-
// we want to notify the hub for every feed
|
56 |
-
$feed_urls = array();
|
57 |
-
$feed_urls[] = get_bloginfo( 'atom_url' );
|
58 |
-
$feed_urls[] = get_bloginfo( 'rdf_url' );
|
59 |
-
$feed_urls[] = get_bloginfo( 'rss2_url' );
|
60 |
-
|
61 |
-
$feed_urls = apply_filters( 'pubsubhubbub_feed_urls', $feed_urls, $post_id );
|
62 |
-
|
63 |
-
// publish them
|
64 |
-
pubsubhubbub_publish_to_hub( $feed_urls );
|
65 |
-
}
|
66 |
|
67 |
/**
|
68 |
-
*
|
69 |
-
*
|
70 |
-
* @param int $comment_id the comment-id
|
71 |
-
* @return int the comment-id
|
72 |
*/
|
73 |
-
|
74 |
-
// get default comment-feeds
|
75 |
-
$feed_urls = array();
|
76 |
-
$feed_urls[] = get_bloginfo( 'comments_atom_url' );
|
77 |
-
$feed_urls[] = get_bloginfo( 'comments_rss2_url' );
|
78 |
-
|
79 |
-
$feed_urls = apply_filters( 'pubsubhubbub_comment_feed_urls', $feed_urls, $comment_id );
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
}
|
84 |
|
85 |
/**
|
86 |
-
*
|
87 |
*/
|
88 |
-
|
89 |
-
// check if current url is one of the feed urls
|
90 |
-
if ( ! pubsubhubbub_show_discovery() ) {
|
91 |
-
return;
|
92 |
-
}
|
93 |
-
|
94 |
-
$hub_urls = pubsubhubbub_get_hubs();
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
}
|
99 |
-
}
|
100 |
|
101 |
/**
|
102 |
-
*
|
103 |
*/
|
104 |
-
|
105 |
-
// check if current url is one of the feed urls
|
106 |
-
if ( ! pubsubhubbub_show_discovery() ) {
|
107 |
-
return;
|
108 |
-
}
|
109 |
|
110 |
-
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Add atom namespace to rdf-feed
|
119 |
-
*/
|
120 |
-
public static function add_rss_ns_link() {
|
121 |
-
echo ' xmlns:atom="http://www.w3.org/2005/Atom" ' . PHP_EOL;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Add a link to our settings page in the WP menu
|
126 |
-
*/
|
127 |
-
public static function add_plugin_menu() {
|
128 |
-
add_options_page(
|
129 |
-
'WebSub/PubSubHubbub Settings',
|
130 |
-
'WebSub/PubSubHubbub',
|
131 |
-
'administrator',
|
132 |
-
'pubsubhubbub',
|
133 |
-
array(
|
134 |
-
'PubSubHubbub_Plugin',
|
135 |
-
'add_settings_page',
|
136 |
-
)
|
137 |
-
);
|
138 |
-
}
|
139 |
|
140 |
-
|
141 |
-
* Write the content for our settings page that allows you to
|
142 |
-
* define your endpoints
|
143 |
-
*/
|
144 |
-
public static function add_settings_page() {
|
145 |
-
load_template( plugin_dir_path( __FILE__ ) . 'templates/settings-page.php' );
|
146 |
-
}
|
147 |
|
148 |
-
|
149 |
-
* Add a settings link next to deactive / edit
|
150 |
-
*/
|
151 |
-
public static function add_settings_link( $links, $file ) {
|
152 |
-
if ( 'pubsubhubbub/pubsubhubbub.php' == $file && function_exists( 'admin_url' ) ) {
|
153 |
-
$settings_link = '<a href="' . admin_url( 'options-general.php?page=pubsubhubbub' ) . '">' . __( 'Settings' ) . '</a>';
|
154 |
-
array_unshift( $links, $settings_link ); // before other links
|
155 |
-
}
|
156 |
-
return $links;
|
157 |
-
}
|
158 |
|
159 |
/**
|
160 |
-
*
|
161 |
*/
|
162 |
-
|
163 |
-
// check if current url is one of the feed urls
|
164 |
-
if ( ! pubsubhubbub_show_discovery() ) {
|
165 |
-
return false;
|
166 |
-
}
|
167 |
-
|
168 |
-
$hub_urls = pubsubhubbub_get_hubs();
|
169 |
-
// add all "hub" headers
|
170 |
-
foreach ( $hub_urls as $hub_url ) {
|
171 |
-
header( sprintf( 'Link: <%s>; rel="hub"', $hub_url ), false );
|
172 |
-
}
|
173 |
|
174 |
-
|
175 |
-
header( sprintf( 'Link: <%s>; rel="self"', pubsubhubbub_get_self_link() ), false );
|
176 |
-
}
|
177 |
|
178 |
/**
|
179 |
-
*
|
180 |
*/
|
181 |
-
|
182 |
-
register_setting( 'pubsubhubbub_options', 'pubsubhubbub_endpoints' );
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Load the plugin textdomain.
|
187 |
-
*/
|
188 |
-
public static function load_textdomain() {
|
189 |
-
load_plugin_textdomain( 'pubsubhubbub', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
190 |
-
}
|
191 |
}
|
|
|
|
3 |
* Plugin Name: WebSub/PubSubHubbub
|
4 |
* Plugin URI: https://github.com/pubsubhubbub/wordpress-pubsubhubbub/
|
5 |
* Description: A better way to tell the world when your blog is updated.
|
6 |
+
* Version: 3.0.0
|
7 |
* Author: Matthias Pfefferle
|
8 |
* Author URI: https://notiz.blog/
|
9 |
* License: MIT
|
12 |
* Domain Path: /languages
|
13 |
*/
|
14 |
|
15 |
+
/**
|
16 |
+
* Initialize plugin
|
17 |
+
*/
|
18 |
+
function pubsubhubbub_init() {
|
19 |
+
require_once( dirname( __FILE__ ) . '/includes/functions.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
+
* Publisher integration
|
|
|
|
|
|
|
23 |
*/
|
24 |
+
require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-publisher.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
add_action( 'publish_post', array( 'PubSubHubbub_Publisher', 'publish_post' ) );
|
27 |
+
//add_action( 'comment_post', array( 'PubSubHubbub_Publisher', 'publish_comment' ) );
|
|
|
28 |
|
29 |
/**
|
30 |
+
* Admin panel
|
31 |
*/
|
32 |
+
require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-admin.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
add_action( 'admin_init', array( 'PubSubHubbub_Admin', 'register_settings' ) );
|
35 |
+
add_action( 'admin_menu', array( 'Pubsubhubbub_Admin', 'add_plugin_menu' ) );
|
|
|
|
|
36 |
|
37 |
/**
|
38 |
+
* Feed integrations
|
39 |
*/
|
40 |
+
require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-topics.php' );
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
add_action( 'atom_head', array( 'Pubsubhubbub_Topics', 'add_atom_link_tag' ) );
|
43 |
+
add_action( 'rdf_header', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) );
|
44 |
+
add_action( 'rss2_head', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) );
|
45 |
|
46 |
+
add_action( 'comments_atom_head', array( 'Pubsubhubbub_Topics', 'add_atom_link_tag' ) );
|
47 |
+
add_action( 'commentsrss2_head', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
add_action( 'rdf_ns', array( 'Pubsubhubbub_Topics', 'add_rss_ns_link' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
add_action( 'template_redirect', array( 'Pubsubhubbub_Topics', 'template_redirect' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
/**
|
54 |
+
* Main class
|
55 |
*/
|
56 |
+
require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
add_action( 'init', array( 'PubSubHubbub', 'load_textdomain' ) );
|
|
|
|
|
59 |
|
60 |
/**
|
61 |
+
* Deprecated functions
|
62 |
*/
|
63 |
+
require_once( dirname( __FILE__ ) . '/includes/deprecated.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
+
|
66 |
+
add_action( 'plugins_loaded', 'pubsubhubbub_init' );
|
readme.txt
CHANGED
@@ -3,14 +3,14 @@ Contributors: pfefferle, joshfraz
|
|
3 |
Donate link: https://notiz.blog/donate/
|
4 |
Tags: webhooks, websub, puhsubhubbub, pubsub, ping, push, indieweb, openweb, ostatus
|
5 |
Requires at least: 4.5
|
6 |
-
Tested up to: 4.9.
|
7 |
-
Stable tag:
|
8 |
|
9 |
A better way to tell the world when your blog is updated.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
This 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.
|
14 |
|
15 |
This plugin:
|
16 |
|
@@ -20,9 +20,8 @@ This plugin:
|
|
20 |
* Supports all of the feed formats used by WordPress, not just ATOM and RSS2
|
21 |
* Supports latest specs
|
22 |
* PubSubHubbub [Version 0.4](https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html)
|
23 |
-
* WebSub [
|
24 |
-
* Announces which hubs you are using by adding `<link rel="hub" ...>` declarations to your template header and
|
25 |
-
* Adds `<atom:link rel="hub" ...>` to your RSS feeds along with the necessary XMLNS declaration for RSS 0.92/1.0
|
26 |
|
27 |
By default this plugin will ping the following hubs:
|
28 |
|
@@ -39,13 +38,32 @@ Please contact me if you operate a hub that you would like to be included as a d
|
|
39 |
|
40 |
== Frequently Asked Questions ==
|
41 |
|
|
|
|
|
|
|
|
|
42 |
= Where can I learn more about the WebSub protocol? =
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
= Where can I learn more about the PubsSubHubbub protocol? =
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
== Screenshots ==
|
51 |
|
@@ -55,6 +73,12 @@ You can visit [PubsSubHubbub on Github](https://github.com/pubsubhubbub "PubsSub
|
|
55 |
|
56 |
Project maintained on github at [pubsubhubbub/wordpress-pubsubhubbub](https://github.com/pubsubhubbub/wordpress-pubsubhubbub).
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
= 2.2.2 =
|
59 |
|
60 |
* temporarily remove comment-feed support to be more GDPR compliant
|
3 |
Donate link: https://notiz.blog/donate/
|
4 |
Tags: webhooks, websub, puhsubhubbub, pubsub, ping, push, indieweb, openweb, ostatus
|
5 |
Requires at least: 4.5
|
6 |
+
Tested up to: 4.9.7
|
7 |
+
Stable tag: 3.0.0
|
8 |
|
9 |
A better way to tell the world when your blog is updated.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
This plugin is a simple way to let people know in real-time when your blog is updated. PubSubHubbub/WebSub is widely adopted and is used by Google Reader, Google Alerts and many other services. Subscription requests are relayed through hubs, which validate and verify the request. Hubs then distribute new and updated content to subscribers when it becomes available.
|
14 |
|
15 |
This plugin:
|
16 |
|
20 |
* Supports all of the feed formats used by WordPress, not just ATOM and RSS2
|
21 |
* Supports latest specs
|
22 |
* PubSubHubbub [Version 0.4](https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html)
|
23 |
+
* WebSub [W3C Version](https://www.w3.org/TR/websub/)
|
24 |
+
* Announces which hubs you are using by adding `<link rel="hub" ...>` declarations to your template header and Atom feed
|
|
|
25 |
|
26 |
By default this plugin will ping the following hubs:
|
27 |
|
38 |
|
39 |
== Frequently Asked Questions ==
|
40 |
|
41 |
+
= What is WebSub? =
|
42 |
+
|
43 |
+
WebSub provides a common mechanism for communication between publishers of any kind of Web content and their subscribers, based on HTTP web hooks. Subscription requests are relayed through hubs, which validate and verify the request. Hubs then distribute new and updated content to subscribers when it becomes available. WebSub was previously known as PubSubHubbub.
|
44 |
+
|
45 |
= Where can I learn more about the WebSub protocol? =
|
46 |
|
47 |
+
* [W3C Spec](https://www.w3.org/TR/websub/ "W3C Spec")
|
48 |
+
* [WebSub on Github](https://github.com/w3c/websub "WebSub on Github")
|
49 |
+
* [WebSub.rocks - a WebSub validator](https://websub.rocks/ "WebSub.rocks")
|
50 |
|
51 |
= Where can I learn more about the PubsSubHubbub protocol? =
|
52 |
|
53 |
+
* [PubsSubHubbub on Github](https://github.com/pubsubhubbub "PubsSubHubbub on Github")
|
54 |
+
* [Latest Spec (0.4)](http://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html)
|
55 |
+
|
56 |
+
= What is a Hub? =
|
57 |
+
|
58 |
+
A WebSub Hub is an implementation that handles subscription requests and distributes the content to subscribers when the corresponding topic URL has been updated. Hubs MUST support subscription requests with a secret and deliver authenticated requests when requested. Hubs MUST deliver the full contents of the topic URL in the request, and MAY reduce the payload to a diff if the content type supports it.
|
59 |
+
|
60 |
+
= What is a Publisher? =
|
61 |
+
|
62 |
+
A WebSub Publisher is an implementation that advertises a topic and hub URL on one or more resource URLs.
|
63 |
+
|
64 |
+
= What is a Subscriber? =
|
65 |
+
|
66 |
+
A WebSub Subscriber is an implementation that discovers the hub and topic URL given a resource URL, subscribes to updates at the hub, and accepts content distribution requests from the hub. The subscriber MAY support authenticated content distribution.
|
67 |
|
68 |
== Screenshots ==
|
69 |
|
73 |
|
74 |
Project maintained on github at [pubsubhubbub/wordpress-pubsubhubbub](https://github.com/pubsubhubbub/wordpress-pubsubhubbub).
|
75 |
|
76 |
+
= 3.0.0 =
|
77 |
+
|
78 |
+
* optimized the DB load
|
79 |
+
* added help section
|
80 |
+
* better code encapsulation
|
81 |
+
|
82 |
= 2.2.2 =
|
83 |
|
84 |
* temporarily remove comment-feed support to be more GDPR compliant
|
templates/settings-page.php
CHANGED
@@ -1,41 +1,31 @@
|
|
1 |
<div class="wrap">
|
2 |
-
<
|
3 |
|
4 |
-
<
|
|
|
5 |
|
6 |
-
<
|
7 |
-
<!-- starting -->
|
8 |
-
<?php settings_fields( 'pubsubhubbub_options' ); ?>
|
9 |
-
<?php do_settings_sections( 'pubsubhubbub_options' ); ?>
|
10 |
-
<!-- ending -->
|
11 |
|
12 |
-
|
13 |
-
// load the existing pubsub endpoint list from the wordpress options table
|
14 |
-
$pubsubhubbub_endpoints = trim( implode( PHP_EOL, pubsubhubbub_get_hubs() ), PHP_EOL );
|
15 |
-
?>
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
</tr>
|
22 |
-
</table>
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
<ul>
|
33 |
-
<?php foreach ( pubsubhubbub_get_topic_urls() as $topic_url ) { ?>
|
34 |
-
<li><pre><?php echo $topic_url; ?></pre></li>
|
35 |
-
<?php } ?>
|
36 |
-
</ul>
|
37 |
-
|
38 |
-
<hr />
|
39 |
-
|
40 |
-
<p><strong><?php _e( 'Thanks for using WebSub/PubSubHubbub!', 'pubsubhubbub' ); ?></strong></p>
|
41 |
</div>
|
1 |
<div class="wrap">
|
2 |
+
<h1><?php esc_html_e( 'WebSub/PubSubHubbub', 'pubsubhubbub' ); ?></h1>
|
3 |
|
4 |
+
<form method="post" action="options.php">
|
5 |
+
<?php settings_fields( 'pubsubhubbub' ); ?>
|
6 |
|
7 |
+
<h2 class="title"><?php esc_html_e( 'Publisher Settings', 'pubsubhubbub' ); ?></h2>
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
<p><?php esc_html_e( 'A WebSub Publisher is an implementation that advertises a topic and hub URL on one or more resource URLs.', 'pubsubhubbub' ); ?></p>
|
|
|
|
|
|
|
10 |
|
11 |
+
<?php
|
12 |
+
// load the existing pubsub endpoint list from the WordPress options table
|
13 |
+
$pubsubhubbub_endpoints = trim( implode( PHP_EOL, pubsubhubbub_get_hubs() ), PHP_EOL );
|
14 |
+
?>
|
|
|
|
|
15 |
|
16 |
+
<table class="form-table">
|
17 |
+
<tr valign="top">
|
18 |
+
<th scope="row"><?php _e( 'Hubs <small>(one per line)</small>', 'pubsubhubbub' ); ?></th>
|
19 |
+
<td>
|
20 |
+
<textarea name="pubsubhubbub_endpoints" id="pubsubhubbub_endpoints" rows="10" cols="50" class="large-text"><?php echo $pubsubhubbub_endpoints; ?></textarea>
|
21 |
+
</td>
|
22 |
+
</tr>
|
23 |
+
</table>
|
24 |
|
25 |
+
<?php do_settings_fields( 'pubsubhubbub', 'publisher' ); ?>
|
26 |
|
27 |
+
<?php do_settings_sections( 'pubsubhubbub' ); ?>
|
28 |
|
29 |
+
<?php submit_button(); ?>
|
30 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
</div>
|