Skip to content

Commit 0bcd628

Browse files
authored
Merge pull request #22 from anatolinicolae/patch-1
fix: empty option on fresh install leads to broken feed links
2 parents b239f8a + 9eb1ff4 commit 0bcd628

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

includes/class-pubsubhubbub-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function register_settings() {
3838
'type' => 'string',
3939
'description' => __( 'The WebSub/PubSubHubbub endpoints', 'pubsubhubbub' ),
4040
'show_in_rest' => true,
41-
'default' => "https://pubsubhubbub.appspot.com\nhttps://pubsubhubbub.superfeedr.com\nhttps://websubhub.com/hub",
41+
'default' => implode( PHP_EOL, Pubsubhubbub::DEFAULT_HUBS ),
4242
'sanitize_callback' => function ( $value ) {
4343
$value = explode( PHP_EOL, $value );
4444
$value = array_filter( array_map( 'trim', $value ) );

includes/class-pubsubhubbub-publisher.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ public static function publish_to_hub( $feed_urls ) {
117117
*/
118118
public static function get_hubs() {
119119
$endpoints = get_option( 'pubsubhubbub_endpoints' );
120-
$hub_urls = explode( PHP_EOL, $endpoints );
120+
121+
// Fail with an empty array when option retrieval fails
122+
if ( ! $endpoints ) {
123+
$hub_urls = Pubsubhubbub::DEFAULT_HUBS;
124+
} else {
125+
$hub_urls = explode( PHP_EOL, $endpoints );
126+
}
121127

122128
return apply_filters( 'pubsubhubbub_hub_urls', $hub_urls );
123129
}

includes/class-pubsubhubbub.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
* The WebSub/PubSubHubbub class
44
*/
55
class Pubsubhubbub {
6+
const DEFAULT_HUBS = array(
7+
'https://pubsubhubbub.appspot.com',
8+
'https://pubsubhubbub.superfeedr.com',
9+
'https://websubhub.com/hub',
10+
);
11+
612
/**
713
* Load the plugin textdomain.
814
*/

pubsubhubbub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function pubsubhubbub_init() {
3131
*/
3232
require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-admin.php' );
3333

34-
add_action( 'admin_init', array( 'PubSubHubbub_Admin', 'register_settings' ) );
34+
add_action( 'init', array( 'PubSubHubbub_Admin', 'register_settings' ) );
3535
add_action( 'admin_menu', array( 'Pubsubhubbub_Admin', 'add_plugin_menu' ) );
3636

3737
/**

0 commit comments

Comments
 (0)