Skip to content

Commit

Permalink
Declare Syndication globally in a more explicit way.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philipjohn committed Dec 18, 2017
1 parent 08b6c42 commit 49ee621
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions includes/class-wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) ) );
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion push-syndication.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 49ee621

Please sign in to comment.