From f0af25bd8078b98f0be5751aa5d9ee9b8e64c25c Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 27 Aug 2016 06:06:50 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@38397 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 2 ++ src/wp-admin/includes/class-wp-press-this.php | 6 ------ src/wp-admin/press-this.php | 1 + src/wp-includes/link-template.php | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 37fdc72067..e69ca9d232 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/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/src/wp-admin/includes/class-wp-press-this.php b/src/wp-admin/includes/class-wp-press-this.php index 2ac4255107..9b3c1fa599 100644 --- a/src/wp-admin/includes/class-wp-press-this.php +++ b/src/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/src/wp-admin/press-this.php b/src/wp-admin/press-this.php index e0a4c90166..ee30444018 100644 --- a/src/wp-admin/press-this.php +++ b/src/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/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index fb5bfb9e58..917ef766b5 100644 --- a/src/wp-includes/link-template.php +++ b/src/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 = '';