PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 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 All 507 releases
jetpack / jetpack_vendor / automattic / jetpack-connection / src / class-tokens-locks.php

class-tokens-locks.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-beta, at jetpack_vendor/automattic/jetpack-connection/src/class-tokens-locks.php

79 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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