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.


git-svn-id: https://develop.svn.wordpress.org/trunk@38397 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2016-08-27 06:06:50 +00:00
parent a8b98b7924
commit f0af25bd80
4 changed files with 4 additions and 6 deletions

View File

@ -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();

View File

@ -1516,9 +1516,3 @@ class WP_Press_This {
die();
}
}
/**
*
* @global WP_Press_This $wp_press_this
*/
$GLOBALS['wp_press_this'] = new WP_Press_This;

View File

@ -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();

View File

@ -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 = '';