diff options
Diffstat (limited to 'plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php')
-rw-r--r-- | plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php b/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php index f37dbf88..d97cf077 100644 --- a/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php +++ b/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php @@ -50,20 +50,22 @@ class Manager { * * @todo Implement a proper nonce verification. */ - public function init() { - $this->setup_xmlrpc_handlers( + public static function configure() { + $manager = new self(); + + $manager->setup_xmlrpc_handlers( $_GET, // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $this->is_active(), - $this->verify_xml_rpc_signature() + $manager->is_active(), + $manager->verify_xml_rpc_signature() ); - if ( $this->is_active() ) { - add_filter( 'xmlrpc_methods', array( $this, 'public_xmlrpc_methods' ) ); + if ( $manager->is_active() ) { + add_filter( 'xmlrpc_methods', array( $manager, 'public_xmlrpc_methods' ) ); } else { - add_action( 'rest_api_init', array( $this, 'initialize_rest_api_registration_connector' ) ); + add_action( 'rest_api_init', array( $manager, 'initialize_rest_api_registration_connector' ) ); } - add_action( 'jetpack_clean_nonces', array( $this, 'clean_nonces' ) ); + add_action( 'jetpack_clean_nonces', array( $manager, 'clean_nonces' ) ); if ( ! wp_next_scheduled( 'jetpack_clean_nonces' ) ) { wp_schedule_event( time(), 'hourly', 'jetpack_clean_nonces' ); } @@ -335,7 +337,7 @@ class Manager { if ( empty( $token_key ) || - empty( $version ) || strval( JETPACK__API_VERSION ) !== $version + empty( $version ) || strval( Utils::get_jetpack_api_version() ) !== $version ) { return new \WP_Error( 'malformed_token', 'Malformed token in request', compact( 'signature_details' ) ); } @@ -526,7 +528,7 @@ class Manager { * @return string|int Returns the ID of the connection owner or False if no connection owner found. */ public function get_connection_owner_id() { - $user_token = $this->get_access_token( JETPACK_MASTER_USER ); + $user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); $connection_owner = false; if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { $connection_owner = $user_token->external_user_id; @@ -601,7 +603,7 @@ class Manager { * @return object|false False if no connection owner found. */ public function get_connection_owner() { - $user_token = $this->get_access_token( JETPACK_MASTER_USER ); + $user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); $connection_owner = false; if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { @@ -623,7 +625,7 @@ class Manager { $user_id = get_current_user_id(); } - $user_token = $this->get_access_token( JETPACK_MASTER_USER ); + $user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id; } @@ -714,10 +716,8 @@ class Manager { */ public function api_url( $relative_url ) { $api_base = Constants::get_constant( 'JETPACK__API_BASE' ); - $version = Constants::get_constant( 'JETPACK__API_VERSION' ); - $api_base = $api_base ? $api_base : 'https://jetpack.wordpress.com/jetpack.'; - $version = $version ? '/' . $version . '/' : '/1/'; + $version = '/' . Utils::get_jetpack_api_version() . '/'; /** * Filters the API URL that Jetpack uses for server communication. @@ -1556,6 +1556,7 @@ class Manager { return new \WP_Error( 'unknown', '', $code ); } + /* translators: Error description string. */ $error_description = isset( $json->error_description ) ? sprintf( __( 'Error Details: %s', 'jetpack' ), (string) $json->error_description ) : ''; return new \WP_Error( (string) $json->error, $error_description, $code ); |