From 85d63f2af5fccf210e59f3c4adc3fe77b4615147 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 27 Aug 2016 06:07:29 +0000 Subject: [PATCH] Press This: the file for the `WP_Press_This` class should not produce side effects. Similar to what we did in r38355 for `WP_Site_Icon`, drop the instances of `global` instantiation for `$wp_press_this` via loading the file. The variable can be set inline when necessary. In most of those places, if the global is already set, the file does not load and stomp it currently. See #37699. Built from https://develop.svn.wordpress.org/trunk@38397 git-svn-id: http://core.svn.wordpress.org/trunk@38338 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 2 ++ wp-admin/includes/class-wp-press-this.php | 6 ------ wp-admin/press-this.php | 1 + wp-includes/link-template.php | 1 + wp-includes/version.php | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 37fdc72067..e69ca9d232 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -3138,6 +3138,7 @@ function wp_ajax_destroy_sessions() { function wp_ajax_press_this_save_post() { if ( empty( $GLOBALS['wp_press_this'] ) ) { include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); + $GLOBALS['wp_press_this'] = new WP_Press_This(); } $GLOBALS['wp_press_this']->save_post(); @@ -3153,6 +3154,7 @@ function wp_ajax_press_this_save_post() { function wp_ajax_press_this_add_category() { if ( empty( $GLOBALS['wp_press_this'] ) ) { include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); + $GLOBALS['wp_press_this'] = new WP_Press_This(); } $GLOBALS['wp_press_this']->add_category(); diff --git a/wp-admin/includes/class-wp-press-this.php b/wp-admin/includes/class-wp-press-this.php index 2ac4255107..9b3c1fa599 100644 --- a/wp-admin/includes/class-wp-press-this.php +++ b/wp-admin/includes/class-wp-press-this.php @@ -1516,9 +1516,3 @@ class WP_Press_This { die(); } } - -/** - * - * @global WP_Press_This $wp_press_this - */ -$GLOBALS['wp_press_this'] = new WP_Press_This; diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index e0a4c90166..ee30444018 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -24,6 +24,7 @@ if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_obj */ if ( empty( $GLOBALS['wp_press_this'] ) ) { include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); + $GLOBALS['wp_press_this'] = new WP_Press_This(); } $GLOBALS['wp_press_this']->html(); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index fb5bfb9e58..917ef766b5 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -2910,6 +2910,7 @@ function get_shortcut_link() { global $is_IE, $wp_version; include_once( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); + $GLOBALS['wp_press_this'] = new WP_Press_This(); $bookmarklet_version = $GLOBALS['wp_press_this']->version; $link = ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index fbc54e40ea..84a3372c88 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38396'; +$wp_version = '4.7-alpha-38397'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.