updated plugin Jetpack Protect
version 1.1.1
This commit is contained in:
@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.46.3] - 2022-11-08
|
||||
### Changed
|
||||
- Updated package dependencies. [#27289]
|
||||
|
||||
## [1.46.2] - 2022-11-07
|
||||
### Changed
|
||||
- Updated package dependencies. [#27278]
|
||||
|
||||
## [1.46.1] - 2022-11-01
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.46.0] - 2022-10-25
|
||||
### Changed
|
||||
- Use blog token to unlink users from WPCOM. [#26705]
|
||||
|
||||
## [1.45.5] - 2022-10-25
|
||||
### Added
|
||||
- Connection: expose BlogId in the global state [#26978]
|
||||
|
||||
## [1.45.4] - 2022-10-13
|
||||
### Changed
|
||||
- Updated package dependencies. [#26791]
|
||||
|
||||
## [1.45.3] - 2022-10-05
|
||||
### Changed
|
||||
- Updated package dependencies. [#26568]
|
||||
|
||||
### Fixed
|
||||
- Clean connection errors after successful blog token restore. [#26489]
|
||||
|
||||
## [1.45.2] - 2022-09-21
|
||||
### Fixed
|
||||
- Check request body error type before creating wp error. [#26304]
|
||||
|
||||
## [1.45.1] - 2022-09-20
|
||||
### Fixed
|
||||
- Rename the initial state key to ensure compatibility with the JS package. [#26259]
|
||||
|
||||
## [1.45.0] - 2022-09-08
|
||||
### Changed
|
||||
- Add option to JP options [#25979]
|
||||
|
||||
## [1.44.0] - 2022-08-29
|
||||
### Added
|
||||
- Connection: verify REST API errors.
|
||||
@ -678,6 +721,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Separate the connection library into its own package.
|
||||
|
||||
[1.46.3]: https://github.com/Automattic/jetpack-connection/compare/v1.46.2...v1.46.3
|
||||
[1.46.2]: https://github.com/Automattic/jetpack-connection/compare/v1.46.1...v1.46.2
|
||||
[1.46.1]: https://github.com/Automattic/jetpack-connection/compare/v1.46.0...v1.46.1
|
||||
[1.46.0]: https://github.com/Automattic/jetpack-connection/compare/v1.45.5...v1.46.0
|
||||
[1.45.5]: https://github.com/Automattic/jetpack-connection/compare/v1.45.4...v1.45.5
|
||||
[1.45.4]: https://github.com/Automattic/jetpack-connection/compare/v1.45.3...v1.45.4
|
||||
[1.45.3]: https://github.com/Automattic/jetpack-connection/compare/v1.45.2...v1.45.3
|
||||
[1.45.2]: https://github.com/Automattic/jetpack-connection/compare/v1.45.1...v1.45.2
|
||||
[1.45.1]: https://github.com/Automattic/jetpack-connection/compare/v1.45.0...v1.45.1
|
||||
[1.45.0]: https://github.com/Automattic/jetpack-connection/compare/v1.44.0...v1.45.0
|
||||
[1.44.0]: https://github.com/Automattic/jetpack-connection/compare/v1.43.1...v1.44.0
|
||||
[1.43.1]: https://github.com/Automattic/jetpack-connection/compare/v1.43.0...v1.43.1
|
||||
[1.43.0]: https://github.com/Automattic/jetpack-connection/compare/v1.42.0...v1.43.0
|
||||
|
@ -8,7 +8,7 @@
|
||||
"automattic/jetpack-admin-ui": "^0.2",
|
||||
"automattic/jetpack-constants": "^1.6",
|
||||
"automattic/jetpack-roles": "^1.4",
|
||||
"automattic/jetpack-status": "^1.14",
|
||||
"automattic/jetpack-status": "^1.15",
|
||||
"automattic/jetpack-redirect": "^1.7"
|
||||
},
|
||||
"require-dev": {
|
||||
@ -34,7 +34,8 @@
|
||||
"phpunit": [
|
||||
"./vendor/phpunit/phpunit/phpunit --colors=always"
|
||||
],
|
||||
"post-update-cmd": "php -r \"copy('vendor/automattic/wordbless/src/dbless-wpdb.php', 'wordpress/wp-content/db.php');\"",
|
||||
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
|
||||
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
|
||||
"test-coverage": [
|
||||
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/clover.xml\""
|
||||
],
|
||||
@ -55,7 +56,7 @@
|
||||
"link-template": "https://github.com/Automattic/jetpack-connection/compare/v${old}...v${new}"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-trunk": "1.44.x-dev"
|
||||
"dev-trunk": "1.46.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => 'd9dbf909a3d10fb26f39');
|
||||
<?php return array('dependencies' => array(), 'version' => 'a96178e4d62fb695caa0');
|
||||
|
@ -1 +1 @@
|
||||
(()=>{var e={775:e=>{let n;window._tkq=window._tkq||[];const t=console.error;const o={initialize:function(e,n){o.setUser(e,n),o.identifyUser()},mc:{bumpStat:function(e,n){const t=function(e,n){let t="";if("object"==typeof e)for(const n in e)t+="&x_"+encodeURIComponent(n)+"="+encodeURIComponent(e[n]);else t="&x_"+encodeURIComponent(e)+"="+encodeURIComponent(n);return t}(e,n);(new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom-no-pv"+t+"&t="+Math.random()}},tracks:{recordEvent:function(e,n){n=n||{},0===e.indexOf("jetpack_")?window._tkq.push(["recordEvent",e,n]):t('- Event name must be prefixed by "jetpack_"')},recordPageView:function(e){o.tracks.recordEvent("jetpack_page_view",{path:e})}},setUser:function(e,t){n={ID:e,username:t}},identifyUser:function(){n&&window._tkq.push(["identifyUser",n.ID,n.username])},clearedIdentity:function(){window._tkq.push(["clearIdentity"])}};e.exports=o}},n={};var t=function t(o){var r=n[o];if(void 0!==r)return r.exports;var i=n[o]={exports:{}};return e[o](i,i.exports,t),i.exports}(775);window.analytics=t})();
|
||||
!function(){var e={775:function(e){let n;window._tkq=window._tkq||[];const t=console.error;const o={initialize:function(e,n){o.setUser(e,n),o.identifyUser()},mc:{bumpStat:function(e,n){const t=function(e,n){let t="";if("object"==typeof e)for(const n in e)t+="&x_"+encodeURIComponent(n)+"="+encodeURIComponent(e[n]);else t="&x_"+encodeURIComponent(e)+"="+encodeURIComponent(n);return t}(e,n);(new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom-no-pv"+t+"&t="+Math.random()}},tracks:{recordEvent:function(e,n){n=n||{},0===e.indexOf("jetpack_")?window._tkq.push(["recordEvent",e,n]):t('- Event name must be prefixed by "jetpack_"')},recordPageView:function(e){o.tracks.recordEvent("jetpack_page_view",{path:e})}},setUser:function(e,t){n={ID:e,username:t}},identifyUser:function(){n&&window._tkq.push(["identifyUser",n.ID,n.username])},clearedIdentity:function(){window._tkq.push(["clearIdentity"])}};e.exports=o}},n={};var t=function t(o){var r=n[o];if(void 0!==r)return r.exports;var i=n[o]={exports:{}};return e[o](i,i.exports,t),i.exports}(775);window.analytics=t}();
|
@ -127,8 +127,7 @@ class Jetpack_Options {
|
||||
'partner_coupon', // (string) A Jetpack partner issued coupon to promote a sale together with Jetpack.
|
||||
'partner_coupon_added', // (string) A date for when `partner_coupon` was added, so we can auto-purge after a certain time interval.
|
||||
'dismissed_backup_review_restore', // (bool) Determines if the component review request is dismissed for successful restore requests.
|
||||
'dismissed_backup_review_time_based', // (bool) Determines if the component review request is dismissed for subscription time based requests.
|
||||
|
||||
'dismissed_backup_review_backups', // (bool) Determines if the component review request is dismissed for successful backup requests.
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -710,7 +710,7 @@ class Error_Handler {
|
||||
}
|
||||
|
||||
$body = json_decode( $body_raw, true );
|
||||
if ( empty( $body['error'] ) ) {
|
||||
if ( empty( $body['error'] ) || ( ! is_string( $body['error'] ) && ! is_int( $body['error'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,15 +30,15 @@ class Initial_State {
|
||||
global $wp_version;
|
||||
|
||||
return array(
|
||||
'apiRoot' => esc_url_raw( rest_url() ),
|
||||
'apiNonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ),
|
||||
'connectionStatus' => REST_Connector::connection_status( false ),
|
||||
'userConnectionData' => REST_Connector::get_user_connection_data( false ),
|
||||
'connectedPlugins' => REST_Connector::get_connection_plugins( false ),
|
||||
'wpVersion' => $wp_version,
|
||||
'siteSuffix' => ( new Status() )->get_site_suffix(),
|
||||
'connectionVerifiedErrors' => Error_Handler::get_instance()->get_verified_errors(),
|
||||
'apiRoot' => esc_url_raw( rest_url() ),
|
||||
'apiNonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ),
|
||||
'connectionStatus' => REST_Connector::connection_status( false ),
|
||||
'userConnectionData' => REST_Connector::get_user_connection_data( false ),
|
||||
'connectedPlugins' => REST_Connector::get_connection_plugins( false ),
|
||||
'wpVersion' => $wp_version,
|
||||
'siteSuffix' => ( new Status() )->get_site_suffix(),
|
||||
'connectionErrors' => Error_Handler::get_instance()->get_verified_errors(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ use Automattic\Jetpack\Status;
|
||||
use Automattic\Jetpack\Terms_Of_Service;
|
||||
use Automattic\Jetpack\Tracking;
|
||||
use Jetpack_IXR_Client;
|
||||
use Jetpack_Options;
|
||||
use WP_Error;
|
||||
use WP_User;
|
||||
|
||||
@ -831,7 +832,12 @@ class Manager {
|
||||
* @return Boolean Whether the disconnection of the user was successful.
|
||||
*/
|
||||
public function disconnect_user( $user_id = null, $can_overwrite_primary_user = false, $force_disconnect_locally = false ) {
|
||||
$user_id = empty( $user_id ) ? get_current_user_id() : (int) $user_id;
|
||||
$user_id = empty( $user_id ) ? get_current_user_id() : (int) $user_id;
|
||||
$is_primary_user = Jetpack_Options::get_option( 'master_user' ) === $user_id;
|
||||
|
||||
if ( $is_primary_user && ! $can_overwrite_primary_user ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Attempt to disconnect the user from WordPress.com.
|
||||
$is_disconnected_from_wpcom = $this->unlink_user_from_wpcom( $user_id );
|
||||
@ -839,7 +845,7 @@ class Manager {
|
||||
$is_disconnected_locally = false;
|
||||
if ( $is_disconnected_from_wpcom || $force_disconnect_locally ) {
|
||||
// Disconnect the user locally.
|
||||
$is_disconnected_locally = $this->get_tokens()->disconnect_user( $user_id, $can_overwrite_primary_user );
|
||||
$is_disconnected_locally = $this->get_tokens()->disconnect_user( $user_id );
|
||||
|
||||
if ( $is_disconnected_locally ) {
|
||||
// Delete cached connected user data.
|
||||
@ -855,6 +861,10 @@ class Manager {
|
||||
* @param int $user_id The current user's ID.
|
||||
*/
|
||||
do_action( 'jetpack_unlinked_user', $user_id );
|
||||
|
||||
if ( $is_primary_user ) {
|
||||
Jetpack_Options::delete_option( 'master_user' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,15 +874,13 @@ class Manager {
|
||||
/**
|
||||
* Request to wpcom for a user to be unlinked from their WordPress.com account
|
||||
*
|
||||
* @access public
|
||||
* @param int $user_id The user identifier.
|
||||
*
|
||||
* @param Integer $user_id the user identifier.
|
||||
*
|
||||
* @return Boolean Whether the disconnection of the user was successful.
|
||||
* @return bool Whether the disconnection of the user was successful.
|
||||
*/
|
||||
public function unlink_user_from_wpcom( $user_id ) {
|
||||
// Attempt to disconnect the user from WordPress.com.
|
||||
$xml = new Jetpack_IXR_Client( compact( 'user_id' ) );
|
||||
$xml = new Jetpack_IXR_Client();
|
||||
|
||||
$xml->query( 'jetpack.unlink_user', $user_id );
|
||||
if ( $xml->isError() ) {
|
||||
@ -2416,6 +2424,8 @@ class Manager {
|
||||
return new WP_Error( 'jetpack_secret', '', $code );
|
||||
}
|
||||
|
||||
Error_Handler::get_instance()->delete_all_errors();
|
||||
|
||||
return $this->get_tokens()->update_blog_token( (string) $json->jetpack_secret );
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace Automattic\Jetpack\Connection;
|
||||
*/
|
||||
class Package_Version {
|
||||
|
||||
const PACKAGE_VERSION = '1.44.0';
|
||||
const PACKAGE_VERSION = '1.46.3';
|
||||
|
||||
const PACKAGE_SLUG = 'connection';
|
||||
|
||||
|
@ -432,6 +432,8 @@ class REST_Connector {
|
||||
* @return \WP_REST_Response|array
|
||||
*/
|
||||
public static function get_user_connection_data( $rest_response = true ) {
|
||||
$blog_id = \Jetpack_Options::get_option( 'id' );
|
||||
|
||||
$connection = new Manager();
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
@ -464,6 +466,7 @@ class REST_Connector {
|
||||
'isMaster' => $is_master_user,
|
||||
'username' => $current_user->user_login,
|
||||
'id' => $current_user->ID,
|
||||
'blogId' => $blog_id,
|
||||
'wpcomUser' => $wpcom_user_data,
|
||||
'gravatar' => get_avatar_url( $current_user->ID, 64, 'mm', '', array( 'force_display' => true ) ),
|
||||
'permissions' => array(
|
||||
|
@ -487,18 +487,19 @@ class Tokens {
|
||||
*
|
||||
* @todo Refactor to properly load the XMLRPC client independently.
|
||||
*
|
||||
* @param Integer $user_id the user identifier.
|
||||
* @param bool $can_overwrite_primary_user Allow for the primary user to be disconnected.
|
||||
* @return Boolean Whether the disconnection of the user was successful.
|
||||
* @param int $user_id The user identifier.
|
||||
* @param bool|null $deprecated Deprecated.
|
||||
*
|
||||
* @return bool Whether the disconnection of the user was successful.
|
||||
*/
|
||||
public function disconnect_user( $user_id, $can_overwrite_primary_user = false ) {
|
||||
public function disconnect_user( $user_id, $deprecated = null ) {
|
||||
$tokens = $this->get_user_tokens();
|
||||
if ( ! $tokens ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( Jetpack_Options::get_option( 'master_user' ) === $user_id && ! $can_overwrite_primary_user ) {
|
||||
return false;
|
||||
if ( null !== $deprecated ) {
|
||||
_deprecated_argument( __METHOD__, '1.46.0', 'Parameter $can_overwrite_primary_user is deprecated' );
|
||||
}
|
||||
|
||||
if ( ! isset( $tokens[ $user_id ] ) ) {
|
||||
|
Reference in New Issue
Block a user