From 49ee621f02980b6365e1bc096274cbe175dd6338 Mon Sep 17 00:00:00 2001 From: Philip John Date: Mon, 18 Dec 2017 15:27:31 +0000 Subject: [PATCH] Declare Syndication globally in a more explicit way. Some hosts load plugins differently, and this may impact the way that Syndication is available for reference in some circumstances (such as when running cron jobs), causing Syndication to not be available. This change uses `$GLOBALS` instead of the `global` keyword to more reliably make Syndication available to plugins and themes. --- includes/class-wp-cli.php | 5 ++--- push-syndication.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/class-wp-cli.php b/includes/class-wp-cli.php index 842f64c..678fd5c 100644 --- a/includes/class-wp-cli.php +++ b/includes/class-wp-cli.php @@ -132,7 +132,7 @@ private function _make_em_talk_push() { return; $this->enabled_verbosity = true; - + add_filter( 'syn_pre_push_post_sites', function( $sites, $post_id, $slave_states ) { WP_CLI::line( sprintf( "Processing post_id #%d (%s)", $post_id, get_the_title( $post_id ) ) ); WP_CLI::line( sprintf( "-- pushing to %s sites and deleting from %s sites", number_format( count( $sites['selected_sites'] ) ), number_format( count( $sites['removed_sites'] ) ) ) ); @@ -151,8 +151,7 @@ private function _make_em_talk_push() { } private function _get_syndication_server() { - global $push_syndication_server; - return $push_syndication_server; + return $GLOBALS['push_syndication_server']; } protected function stop_the_insanity() { diff --git a/push-syndication.php b/push-syndication.php index 71a90c5..0f57d87 100644 --- a/push-syndication.php +++ b/push-syndication.php @@ -25,7 +25,7 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) require_once( dirname( __FILE__ ) . '/includes/class-wp-cli.php' ); -$push_syndication_server = new WP_Push_Syndication_Server; +$GLOBALS['push_syndication_server'] = new WP_Push_Syndication_Server; // Create the event counter. require __DIR__ . '/includes/class-syndication-event-counter.php';