Version Description
Download this release
Release Info
Developer | pfefferle |
Plugin | WebSub/PubSubHubbub |
Version | 2.0.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 2.0.1
- includes/functions.php +1 -1
- publisher.php +0 -97
- pubsubhubbub.php +1 -1
- readme.txt +1 -1
includes/functions.php
CHANGED
@@ -36,7 +36,7 @@ function pubsubhubbub_get_hubs() {
|
|
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 || ! is_array( $
|
40 |
$hub_urls[] = 'https://pubsubhubbub.appspot.com';
|
41 |
$hub_urls[] = 'https://pubsubhubbub.superfeedr.com';
|
42 |
}
|
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[] = 'https://pubsubhubbub.appspot.com';
|
41 |
$hub_urls[] = 'https://pubsubhubbub.superfeedr.com';
|
42 |
}
|
publisher.php
DELETED
@@ -1,97 +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 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,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: 2.0.
|
7 |
* Author: Matthias Pfefferle
|
8 |
* Author URI: https://notiz.blog/
|
9 |
* License: MIT
|
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: 2.0.1
|
7 |
* Author: Matthias Pfefferle
|
8 |
* Author URI: https://notiz.blog/
|
9 |
* License: MIT
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://14101978.de
|
|
4 |
Tags: webhooks, websub, puhsubhubbub, pubsub, ping, push, indieweb, openweb, ostatus
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 4.7.4
|
7 |
-
Stable tag: 2.0.
|
8 |
|
9 |
A better way to tell the world when your blog is updated.
|
10 |
|
4 |
Tags: webhooks, websub, puhsubhubbub, pubsub, ping, push, indieweb, openweb, ostatus
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 4.7.4
|
7 |
+
Stable tag: 2.0.1
|
8 |
|
9 |
A better way to tell the world when your blog is updated.
|
10 |
|