Site Kit by Google - Version 1.1.1

Version Description

Download this release

Release Info

Developer flixos90
Plugin Icon 128x128 Site Kit by Google
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.1.0 to 1.1.1

google-site-kit.php CHANGED
@@ -11,7 +11,7 @@
11
* Plugin Name: Site Kit by Google
12
* Plugin URI: https://sitekit.withgoogle.com
13
* Description: Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
14
- * Version: 1.1.0
15
* Author: Google
16
* Author URI: https://opensource.google.com
17
* License: Apache License 2.0
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
24
}
25
26
// Define most essential constants.
27
- define( 'GOOGLESITEKIT_VERSION', '1.1.0' );
28
define( 'GOOGLESITEKIT_PLUGIN_MAIN_FILE', __FILE__ );
29
30
/**
@@ -74,20 +74,6 @@ function googlesitekit_deactivate_plugin( $network_wide ) {
74
75
register_deactivation_hook( __FILE__, 'googlesitekit_deactivate_plugin' );
76
77
- /**
78
- * Handles plugin uninstall.
79
- *
80
- * @access private
81
- */
82
- function googlesitekit_uninstall_plugin() {
83
- if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
84
- return;
85
- }
86
-
87
- do_action( 'googlesitekit_uninstall' );
88
- }
89
- register_uninstall_hook( __FILE__, 'googlesitekit_uninstall_plugin' );
90
-
91
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
92
require_once plugin_dir_path( __FILE__ ) . 'includes/loader.php';
93
}
11
* Plugin Name: Site Kit by Google
12
* Plugin URI: https://sitekit.withgoogle.com
13
* Description: Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
14
+ * Version: 1.1.1
15
* Author: Google
16
* Author URI: https://opensource.google.com
17
* License: Apache License 2.0
24
}
25
26
// Define most essential constants.
27
+ define( 'GOOGLESITEKIT_VERSION', '1.1.1' );
28
define( 'GOOGLESITEKIT_PLUGIN_MAIN_FILE', __FILE__ );
29
30
/**
74
75
register_deactivation_hook( __FILE__, 'googlesitekit_deactivate_plugin' );
76
77
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
78
require_once plugin_dir_path( __FILE__ ) . 'includes/loader.php';
79
}
includes/Core/Util/Reset.php CHANGED
@@ -11,27 +11,12 @@
11
namespace Google\Site_Kit\Core\Util;
12
13
use Google\Site_Kit\Context;
14
- use Google\Site_Kit\Core\Authentication\Clients\OAuth_Client;
15
- use Google\Site_Kit\Core\Authentication\Credentials;
16
- use Google\Site_Kit\Core\Authentication\First_Admin;
17
- use Google\Site_Kit\Core\Authentication\Profile;
18
- use Google\Site_Kit\Core\Authentication\Verification;
19
- use Google\Site_Kit\Core\Authentication\Verification_File;
20
- use Google\Site_Kit\Core\Authentication\Verification_Meta;
21
- use Google\Site_Kit\Core\Storage\Options;
22
- use Google\Site_Kit\Core\Storage\Transients;
23
- use Google\Site_Kit\Core\Storage\User_Options;
24
- use Google\Site_Kit\Modules\AdSense;
25
- use Google\Site_Kit\Modules\Analytics;
26
- use Google\Site_Kit\Modules\Optimize;
27
- use Google\Site_Kit\Modules\PageSpeed_Insights;
28
- use Google\Site_Kit\Modules\Search_Console;
29
- use Google\Site_Kit\Modules\Tag_Manager;
30
31
/**
32
* Class providing functions to reset the plugin.
33
*
34
* @since 1.0.0
35
* @access private
36
* @ignore
37
*/
@@ -45,43 +30,16 @@ final class Reset {
45
*/
46
private $context;
47
48
- /**
49
- * Options object.
50
- *
51
- * @since 1.0.0
52
- * @var Options
53
- */
54
- private $options;
55
-
56
- /**
57
- * Transients object.
58
- *
59
- * @since 1.0.0
60
- * @var Transients
61
- */
62
- private $transients;
63
-
64
/**
65
* Constructor.
66
*
67
* @since 1.0.0
68
*
69
- * @param Context $context Plugin context.
70
- * @param Options $options Optional. Options instance. Default is a new instance.
71
- * @param Transients $transients Optional. Transients instance. Default is a new instance.
72
*/
73
- public function __construct( Context $context, Options $options = null, Transients $transients = null ) {
74
$this->context = $context;
75
-
76
- if ( ! $options ) {
77
- $options = new Options( $this->context );
78
- }
79
- $this->options = $options;
80
-
81
- if ( ! $transients ) {
82
- $transients = new Transients( $this->context );
83
- }
84
- $this->transients = $transients;
85
}
86
87
/**
@@ -90,115 +48,9 @@ final class Reset {
90
* @since 1.0.0
91
*/
92
public function all() {
93
- $this->delete_all_plugin_options();
94
- $this->delete_all_user_metas();
95
- $this->delete_all_transients();
96
-
97
- // Clear options cache.
98
- wp_cache_delete( 'alloptions', 'options' );
99
- }
100
101
- /**
102
- * Deletes all the plugin options.
103
- *
104
- * @since 1.0.0
105
- */
106
- private function delete_all_plugin_options() {
107
- // Deletes all options from the options table.
108
- $this->options->delete( Activation::OPTION_SHOW_ACTIVATION_NOTICE );
109
- $this->options->delete( Activation::OPTION_NEW_SITE_POSTS );
110
- $this->options->delete( Credentials::OPTION );
111
- $this->options->delete( 'googlesitekit-active-modules' );
112
- $this->options->delete( Search_Console::PROPERTY_OPTION );
113
- $this->options->delete( AdSense::OPTION );
114
- $this->options->delete( Analytics::OPTION );
115
- $this->options->delete( 'googlesitekit_analytics_adsense_linked' );
116
- $this->options->delete( PageSpeed_Insights::OPTION );
117
- $this->options->delete( Optimize::OPTION );
118
- $this->options->delete( Tag_Manager::OPTION );
119
- $this->options->delete( First_Admin::OPTION );
120
- $this->options->delete( OAuth_Client::OPTION_PROXY_NONCE );
121
- $this->options->delete( Beta_Migration::OPTION_IS_PRE_PROXY_INSTALL );
122
-
123
- // Clean up old site verification data, moved to user options.
124
- // Also clean up other old unused options.
125
- // @todo remove after RC.
126
- $this->options->delete( Verification::OPTION );
127
- $this->options->delete( Verification_Meta::OPTION );
128
- $this->options->delete( 'googlesitekit_api_key' );
129
- $this->options->delete( 'googlesitekit_available_modules' );
130
- $this->options->delete( 'googlesitekit_secret_token' );
131
- $this->options->delete( 'googlesitekit_project_id' );
132
- $this->options->delete( 'googlesitekit_gcp_project' );
133
- }
134
-
135
- /**
136
- * Deletes all the user stored options in user meta.
137
- *
138
- * @since 1.0.0
139
- */
140
- private function delete_all_user_metas() {
141
- global $wpdb;
142
-
143
- // User option keys are prefixed in single site and multisite when not in network mode.
144
- $key_prefix = $this->context->is_network_mode() ? '' : $wpdb->get_blog_prefix();
145
- $user_query = new \WP_User_Query(
146
- array(
147
- 'fields' => 'id',
148
- 'meta_query' => array(
149
- 'relation' => 'OR',
150
- array(
151
- 'key' => $key_prefix . Verification_Meta::OPTION,
152
- 'compare' => 'EXISTS',
153
- ),
154
- array(
155
- 'key' => $key_prefix . OAuth_Client::OPTION_ACCESS_TOKEN,
156
- 'compare' => 'EXISTS',
157
- ),
158
- array(
159
- 'key' => $key_prefix . OAuth_Client::OPTION_PROXY_ACCESS_CODE,
160
- 'compare' => 'EXISTS',
161
- ),
162
- array(
163
- 'key' => $key_prefix . OAuth_Client::OPTION_ERROR_CODE,
164
- 'compare' => 'EXISTS',
165
- ),
166
- ),
167
- )
168
- );
169
-
170
- $users = $user_query->get_results();
171
-
172
- foreach ( $users as $user_id ) {
173
- // Deletes all user stored options.
174
- $user_options = new User_Options( $this->context, $user_id );
175
- $user_options->delete( OAuth_Client::OPTION_ACCESS_TOKEN );
176
- $user_options->delete( OAuth_Client::OPTION_ACCESS_TOKEN_EXPIRES_IN );
177
- $user_options->delete( OAuth_Client::OPTION_ACCESS_TOKEN_CREATED );
178
- $user_options->delete( OAuth_Client::OPTION_REFRESH_TOKEN );
179
- $user_options->delete( OAuth_Client::OPTION_REDIRECT_URL );
180
- $user_options->delete( OAuth_Client::OPTION_AUTH_SCOPES );
181
- $user_options->delete( OAuth_Client::OPTION_ERROR_CODE );
182
- $user_options->delete( OAuth_Client::OPTION_PROXY_ACCESS_CODE );
183
- $user_options->delete( Verification::OPTION );
184
- $user_options->delete( Verification_Meta::OPTION );
185
- $user_options->delete( Verification_File::OPTION );
186
- $user_options->delete( Profile::OPTION );
187
-
188
- // Clean up old user api key data, moved to options.
189
- // @todo remove after RC.
190
- $user_options->delete( 'googlesitekit_api_key' );
191
- $user_options->delete( 'sitekit_authentication' );
192
- $user_options->delete( 'googlesitekit_stored_nonce_user_id' );
193
- }
194
- }
195
-
196
- /**
197
- * Deletes all the stored transients.
198
- *
199
- * @since 1.0.0
200
- */
201
- private function delete_all_transients() {
202
- $this->transients->delete( 'googlesitekit_verification_meta_tags' );
203
}
204
}
11
namespace Google\Site_Kit\Core\Util;
12
13
use Google\Site_Kit\Context;
14
15
/**
16
* Class providing functions to reset the plugin.
17
*
18
* @since 1.0.0
19
+ * @since 1.1.1 Removed delete_all_plugin_options(), delete_all_user_metas() and delete_all_transients() methods.
20
* @access private
21
* @ignore
22
*/
30
*/
31
private $context;
32
33
/**
34
* Constructor.
35
*
36
* @since 1.0.0
37
+ * @since 1.1.1 Removed $options and $transients params.
38
*
39
+ * @param Context $context Plugin context.
40
*/
41
+ public function __construct( Context $context ) {
42
$this->context = $context;
43
}
44
45
/**
48
* @since 1.0.0
49
*/
50
public function all() {
51
+ $googlesitekit_reset_context = $this->context;
52
53
+ // Call uninstaller.
54
+ require $this->context->path( 'uninstall.php' );
55
}
56
}
includes/Core/Util/Uninstallation.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * Class Google\Site_Kit\Core\Util\Uninstallation
4
- *
5
- * @package Google\Site_Kit
6
- * @copyright 2019 Google LLC
7
- * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
8
- * @link https://sitekit.withgoogle.com
9
- */
10
-
11
- namespace Google\Site_Kit\Core\Util;
12
-
13
- use Google\Site_Kit\Context;
14
-
15
- /**
16
- * Class handling plugin uninstallation.
17
- *
18
- * @since 1.0.0
19
- * @access private
20
- * @ignore
21
- */
22
- final class Uninstallation {
23
-
24
- /**
25
- * Reset object.
26
- *
27
- * @since 1.0.0
28
- * @var Reset
29
- */
30
- private $reset;
31
-
32
- /**
33
- * Constructor.
34
- *
35
- * @since 1.0.0
36
- *
37
- * @param Reset $reset Optional. Reset instance. Default is a new instance.
38
- */
39
- public function __construct( Reset $reset = null ) {
40
- if ( ! $reset ) {
41
- $reset = new Reset( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) );
42
- }
43
- $this->reset = $reset;
44
- }
45
-
46
- /**
47
- * Registers functionality through WordPress hooks.
48
- *
49
- * @since 1.0.0
50
- */
51
- public function register() {
52
- add_action(
53
- 'googlesitekit_uninstall',
54
- function () {
55
- $this->reset->all();
56
- }
57
- );
58
- }
59
- }
includes/Plugin.php CHANGED
@@ -144,12 +144,9 @@ final class Plugin {
144
-999
145
);
146
147
- $reset = new Core\Util\Reset( $this->context, $options );
148
-
149
( new Core\Util\Activation( $this->context, $options, $assets ) )->register();
150
( new Core\Util\Beta_Migration( $this->context ) )->register();
151
( new Core\Util\Migration_1_0_0( $this->context ) )->register();
152
- ( new Core\Util\Uninstallation( $reset ) )->register();
153
154
if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
155
add_filter(
144
-999
145
);
146
147
( new Core\Util\Activation( $this->context, $options, $assets ) )->register();
148
( new Core\Util\Beta_Migration( $this->context ) )->register();
149
( new Core\Util\Migration_1_0_0( $this->context ) )->register();
150
151
if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
152
add_filter(
includes/vendor/composer/autoload_classmap.php CHANGED
@@ -51,7 +51,6 @@ return array(
51
'Google\\Site_Kit\\Core\\Util\\Migration_1_0_0' => $baseDir . '/Core/Util/Migration_1_0_0.php',
52
'Google\\Site_Kit\\Core\\Util\\Reset' => $baseDir . '/Core/Util/Reset.php',
53
'Google\\Site_Kit\\Core\\Util\\Tracking' => $baseDir . '/Core/Util/Tracking.php',
54
- 'Google\\Site_Kit\\Core\\Util\\Uninstallation' => $baseDir . '/Core/Util/Uninstallation.php',
55
'Google\\Site_Kit\\Modules\\AdSense' => $baseDir . '/Modules/AdSense.php',
56
'Google\\Site_Kit\\Modules\\Analytics' => $baseDir . '/Modules/Analytics.php',
57
'Google\\Site_Kit\\Modules\\Optimize' => $baseDir . '/Modules/Optimize.php',
51
'Google\\Site_Kit\\Core\\Util\\Migration_1_0_0' => $baseDir . '/Core/Util/Migration_1_0_0.php',
52
'Google\\Site_Kit\\Core\\Util\\Reset' => $baseDir . '/Core/Util/Reset.php',
53
'Google\\Site_Kit\\Core\\Util\\Tracking' => $baseDir . '/Core/Util/Tracking.php',
54
'Google\\Site_Kit\\Modules\\AdSense' => $baseDir . '/Modules/AdSense.php',
55
'Google\\Site_Kit\\Modules\\Analytics' => $baseDir . '/Modules/Analytics.php',
56
'Google\\Site_Kit\\Modules\\Optimize' => $baseDir . '/Modules/Optimize.php',
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: google
4
Requires at least: 4.7
5
Tested up to: 5.3
6
Requires PHP: 5.4
7
- Stable tag: 1.1.0
8
License: Apache License 2.0
9
License URI: https://www.apache.org/licenses/LICENSE-2.0
10
Tags: google, search-console, analytics, adsense, pagespeed-insights, optimize, tag-manager, site-kit
4
Requires at least: 4.7
5
Tested up to: 5.3
6
Requires PHP: 5.4
7
+ Stable tag: 1.1.1
8
License: Apache License 2.0
9
License URI: https://www.apache.org/licenses/LICENSE-2.0
10
Tags: google, search-console, analytics, adsense, pagespeed-insights, optimize, tag-manager, site-kit
uninstall.php ADDED
@@ -0,0 +1,67 @@
1
+ <?php
2
+ /**
3
+ * Plugin reset and uninstall cleanup.
4
+ *
5
+ * @package Google\Site_Kit
6
+ * @copyright 2019 Google LLC
7
+ * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
8
+ * @link https://sitekit.withgoogle.com
9
+ */
10
+
11
+ namespace Google\Site_Kit;
12
+
13
+ // Bail if not uninstalling or resetting the plugin.
14
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) && empty( $googlesitekit_reset_context ) ) {
15
+ return;
16
+ }
17
+
18
+ global $wpdb;
19
+
20
+ $prefix = 'googlesitekit_%';
21
+
22
+ // Delete options and transients.
23
+ $wpdb->query(
24
+ $wpdb->prepare(
25
+ "DELETE FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name = %s",
26
+ $prefix,
27
+ '_transient_' . $prefix,
28
+ '_transient_timeout_' . $prefix,
29
+ 'googlesitekit-active-modules'
30
+ )
31
+ );
32
+
33
+ // Delete user meta.
34
+ $wpdb->query(
35
+ $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE %s", $wpdb->get_blog_prefix() . $prefix )
36
+ );
37
+
38
+ // Clear network data if multisite and uninstalling or resetting network-wide.
39
+ $conditions = (
40
+ is_multisite()
41
+ &&
42
+ (
43
+ defined( 'WP_UNINSTALL_PLUGIN' )
44
+ ||
45
+ ( ! empty( $googlesitekit_reset_context ) && $googlesitekit_reset_context->is_network_mode() )
46
+ )
47
+ );
48
+
49
+ if ( $conditions ) {
50
+ $wpdb->query(
51
+ $wpdb->prepare(
52
+ "DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE %s OR meta_key LIKE %s OR meta_key LIKE %s OR meta_key = %s",
53
+ $prefix,
54
+ '_site_transient_' . $prefix,
55
+ '_site_transient_timeout_' . $prefix,
56
+ 'googlesitekit-active-modules'
57
+ )
58
+ );
59
+
60
+ // Delete user meta.
61
+ $wpdb->query(
62
+ $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE %s", $prefix )
63
+ );
64
+ }
65
+
66
+ // Clear options cache.
67
+ wp_cache_flush();