abilities
4 days ago
connectors
4 days ago
health
4 days ago
identity-crisis
1 month ago
sso
1 month ago
traits
9 months ago
webhooks
9 months ago
class-authorize-json-api.php
1 month ago
class-client.php
4 days ago
class-connection-assets.php
1 year ago
class-connection-notice.php
8 months ago
class-error-handler.php
4 days ago
class-external-storage.php
4 months ago
class-heartbeat.php
1 month ago
class-initial-state.php
4 weeks ago
class-manager.php
4 days ago
class-nonce-handler.php
9 months ago
class-package-version-tracker.php
1 month ago
class-package-version.php
4 days ago
class-partner-coupon.php
2 months ago
class-partner.php
2 years ago
class-plugin-storage.php
8 months ago
class-plugin.php
9 months ago
class-rest-authentication.php
4 days ago
class-rest-connector.php
4 days ago
class-secrets.php
9 months ago
class-server-sandbox.php
2 months ago
class-site-health.php
4 days ago
class-terms-of-service.php
4 days ago
class-tokens-locks.php
9 months ago
class-tokens.php
4 days ago
class-tracking.php
4 days ago
class-urls.php
6 months ago
class-user-account-status.php
4 days ago
class-users-connection-admin.php
2 months ago
class-utils.php
2 years ago
class-webhooks.php
1 month ago
class-xmlrpc-async-call.php
2 years ago
class-xmlrpc-connector.php
9 months ago
interface-manager.php
4 years ago
interface-storage-provider.php
6 months ago
class-tokens-locks.php
79 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The Jetpack Connection Tokens Locks class file. |
| 4 | * |
| 5 | * @package automattic/jetpack-connection |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\Connection; |
| 9 | |
| 10 | /** |
| 11 | * |
| 12 | * Jetpack Connection tokens cleanup during migration. |
| 13 | * This class encapsulates plugin or tool specific code that activates token lock upon migration. |
| 14 | * |
| 15 | * The connection tokens are locked to the current domain. |
| 16 | * If the database is imported on another site (domain name doesn't match), the tokens get removed. |
| 17 | * |
| 18 | * @see https://github.com/Automattic/jetpack/pull/23597 |
| 19 | * @see \Automattic\Jetpack\Connection\Tokens::is_locked() |
| 20 | * |
| 21 | * @phan-constructor-used-for-side-effects |
| 22 | */ |
| 23 | class Tokens_Locks { |
| 24 | |
| 25 | /** |
| 26 | * Whether the class has been initialized. |
| 27 | * |
| 28 | * @var bool |
| 29 | */ |
| 30 | private static $is_initialized = false; |
| 31 | |
| 32 | /** |
| 33 | * Run the initializers if they haven't been run already. |
| 34 | */ |
| 35 | public function __construct() { |
| 36 | if ( static::$is_initialized ) { |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | $this->init_aiowpm(); |
| 41 | |
| 42 | static::$is_initialized = true; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Set the token lock for AIOWPM plugin export. |
| 47 | * |
| 48 | * @param array $params The filter parameters. |
| 49 | * |
| 50 | * @return array |
| 51 | */ |
| 52 | public function aiowpm_set_lock( $params ) { |
| 53 | ( new Tokens() )->set_lock(); |
| 54 | return $params; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Remove the token lock for AIOWPM plugin export. |
| 59 | * |
| 60 | * @param array $params The filter parameters. |
| 61 | * |
| 62 | * @return array |
| 63 | */ |
| 64 | public function aiowpm_remove_lock( $params ) { |
| 65 | ( new Tokens() )->remove_lock(); |
| 66 | return $params; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Initialize the All-in-One-WP-Migration plugin hooks. |
| 71 | * |
| 72 | * @return void |
| 73 | */ |
| 74 | private function init_aiowpm() { |
| 75 | add_filter( 'ai1wm_export', array( $this, 'aiowpm_set_lock' ), 180 ); |
| 76 | add_filter( 'ai1wm_export', array( $this, 'aiowpm_remove_lock' ), 250 ); |
| 77 | } |
| 78 | } |
| 79 |