PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 All 502 releases
← All changes | src/class-tracking.php +22 -27 12.8.316.2 View file →
@@ -7,10 +7,12 @@
7 7
8 8 namespace Automattic\Jetpack\Plugin;
9 9
10 10 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
11 -use Automattic\Jetpack\IP\Utils as IP_Utils;
12 11 use Automattic\Jetpack\Tracking as Tracks;
12 +use IXR_Error;
13 +use WP_Error;
14 +use WP_User;
13 15
14 16 /**
15 17 * Tracks class.
16 18 */
@@ -22,25 +24,27 @@
22 24 *
23 25 * @access private
24 26 */
25 27 private $tracking;
28 +
26 29 /**
27 - * Prevents the Tracking from being intialized more then once.
30 + * Prevents the Tracking from being initialized more than once.
28 31 *
29 32 * @var bool
30 33 */
31 - private $initalized = false;
34 + private static $initialized = false;
32 35
33 36 /**
34 37 * Initialization function.
35 38 */
36 39 public function init() {
37 - if ( $this->initalized ) {
40 + if ( static::$initialized ) {
38 41 return;
39 42 }
40 - $this->initalized = true;
41 - $this->tracking = new Tracks( 'jetpack' );
42 43
44 + static::$initialized = true;
45 + $this->tracking = new Tracks( 'jetpack' );
46 +
43 47 // For tracking stuff via js/ajax.
44 48 add_action( 'admin_enqueue_scripts', array( $this->tracking, 'enqueue_tracks_scripts' ) );
45 49
46 50 add_action( 'jetpack_activate_module', array( $this, 'jetpack_activate_module' ), 1, 1 );
@@ -45,9 +49,8 @@
45 49
46 50 add_action( 'jetpack_activate_module', array( $this, 'jetpack_activate_module' ), 1, 1 );
47 51 add_action( 'jetpack_deactivate_module', array( $this, 'jetpack_deactivate_module' ), 1, 1 );
48 52 add_action( 'jetpack_user_authorized', array( $this, 'jetpack_user_authorized' ) );
49 - add_action( 'wp_login_failed', array( $this, 'wp_login_failed' ) );
50 53
51 54 // Tracking XMLRPC server events.
52 55 add_action( 'jetpack_xmlrpc_server_event', array( $this, 'jetpack_xmlrpc_server_event' ), 10, 4 );
53 56
@@ -113,10 +116,10 @@
113 116 * Track that we've begun verifying the secrets.
114 117 *
115 118 * @access public
116 119 *
117 - * @param string $action Type of secret (one of 'register', 'authorize', 'publicize').
118 - * @param \WP_User $user The user object.
120 + * @param string $action Type of secret (one of 'register', 'authorize', 'publicize').
121 + * @param WP_User $user The user object.
119 122 */
120 123 public function jetpack_verify_secrets_begin( $action, $user ) {
121 124 $this->tracking->record_user_event( "jpc_verify_{$action}_begin", array(), $user );
122 125 }
@@ -125,10 +128,10 @@
125 128 * Track that we've succeeded in verifying the secrets.
126 129 *
127 130 * @access public
128 131 *
129 - * @param string $action Type of secret (one of 'register', 'authorize', 'publicize').
130 - * @param \WP_User $user The user object.
132 + * @param string $action Type of secret (one of 'register', 'authorize', 'publicize').
133 + * @param WP_User $user The user object.
131 134 */
132 135 public function jetpack_verify_secrets_success( $action, $user ) {
133 136 $this->tracking->record_user_event( "jpc_verify_{$action}_success", array(), $user );
134 137 }
@@ -137,11 +140,11 @@
137 140 * Track that we've failed verifying the secrets.
138 141 *
139 142 * @access public
140 143 *
141 - * @param string $action Type of secret (one of 'register', 'authorize', 'publicize').
142 - * @param \WP_User $user The user object.
143 - * @param \WP_Error $error Error object.
144 + * @param string $action Type of secret (one of 'register', 'authorize', 'publicize').
145 + * @param WP_User $user The user object.
146 + * @param WP_Error $error Error object.
144 147 */
145 148 public function jetpack_verify_secrets_fail( $action, $user, $error ) {
146 149 $this->tracking->record_user_event(
147 150 "jpc_verify_{$action}_fail",
@@ -155,20 +158,12 @@
155 158
156 159 /**
157 160 * Track a failed login attempt.
158 161 *
159 - * @access public
160 - *
161 - * @param string $login Username or email address.
162 + * @deprecated 13.9 Method is not longer in use.
162 163 */
163 - public function wp_login_failed( $login ) {
164 - $this->tracking->record_user_event(
165 - 'failed_login',
166 - array(
167 - 'origin_ip' => IP_Utils::get_ip(),
168 - 'login' => $login,
169 - )
170 - );
164 + public function wp_login_failed() {
165 + _deprecated_function( __METHOD__, '13.9' );
171 166 }
172 167
173 168 /**
174 169 * Track a connection failure at the registration step.
@@ -175,9 +170,9 @@
175 170 *
176 171 * @access public
177 172 *
178 173 * @param string|int $error The error code.
179 - * @param \WP_Error $registered The error object.
174 + * @param WP_Error $registered The error object.
180 175 */
181 176 public function jetpack_connection_register_fail( $error, $registered ) {
182 177 $this->tracking->record_user_event(
183 178 'jpc_register_fail',
@@ -219,9 +214,9 @@
219 214 $parameters = array(
220 215 'error_code' => $parameters->get_error_code(),
221 216 'error_message' => $parameters->get_error_message(),
222 217 );
223 - } elseif ( is_a( $parameters, '\\IXR_Error' ) ) {
218 + } elseif ( is_a( $parameters, IXR_Error::class ) ) {
224 219 $parameters = array(
225 220 'error_code' => $parameters->code,
226 221 'error_message' => $parameters->message,
227 222 );