jetpack
Last commit date
3rd-party
6 years ago
_inc
6 years ago
bin
6 years ago
css
6 years ago
extensions
6 years ago
images
6 years ago
json-endpoints
6 years ago
languages
6 years ago
modules
6 years ago
sal
6 years ago
src
6 years ago
vendor
6 years ago
views
7 years ago
.svnignore
12 years ago
CODE-OF-CONDUCT.md
9 years ago
changelog.txt
6 years ago
class.frame-nonce-preview.php
6 years ago
class.jetpack-admin.php
6 years ago
class.jetpack-affiliate.php
6 years ago
class.jetpack-autoupdate.php
6 years ago
class.jetpack-bbpress-json-api-compat.php
6 years ago
class.jetpack-cli.php
6 years ago
class.jetpack-client-server.php
6 years ago
class.jetpack-connection-banner.php
6 years ago
class.jetpack-data.php
6 years ago
class.jetpack-debugger.php
7 years ago
class.jetpack-error.php
10 years ago
class.jetpack-gutenberg.php
6 years ago
class.jetpack-heartbeat.php
6 years ago
class.jetpack-idc.php
6 years ago
class.jetpack-ixr-client.php
6 years ago
class.jetpack-modules-list-table.php
6 years ago
class.jetpack-network-sites-list-table.php
6 years ago
class.jetpack-network.php
6 years ago
class.jetpack-plan.php
6 years ago
class.jetpack-post-images.php
6 years ago
class.jetpack-twitter-cards.php
6 years ago
class.jetpack-user-agent.php
6 years ago
class.jetpack-xmlrpc-server.php
6 years ago
class.jetpack.php
6 years ago
class.json-api-endpoints.php
6 years ago
class.json-api.php
6 years ago
class.photon.php
6 years ago
composer.json
6 years ago
functions.compat.php
6 years ago
functions.cookies.php
6 years ago
functions.gallery.php
6 years ago
functions.global.php
6 years ago
functions.opengraph.php
6 years ago
functions.photon.php
6 years ago
jest.config.js
6 years ago
jetpack.php
6 years ago
json-api-config.php
10 years ago
json-endpoints.php
7 years ago
load-jetpack.php
6 years ago
locales.php
7 years ago
readme.txt
6 years ago
require-lib.php
6 years ago
uninstall.php
6 years ago
wpml-config.xml
10 years ago
class.jetpack-client-server.php
113 lines
| 1 | <?php |
| 2 | |
| 3 | use Automattic\Jetpack\Connection\Client; |
| 4 | use Automattic\Jetpack\Connection\Manager as Connection_Manager; |
| 5 | use Automattic\Jetpack\Connection\Utils as Connection_Utils; |
| 6 | use Automattic\Jetpack\Roles; |
| 7 | use Automattic\Jetpack\Tracking; |
| 8 | |
| 9 | /** |
| 10 | * Client = Plugin |
| 11 | * Client Server = API Methods the Plugin must respond to |
| 12 | */ |
| 13 | class Jetpack_Client_Server { |
| 14 | |
| 15 | /** |
| 16 | * Authorizations |
| 17 | */ |
| 18 | function client_authorize() { |
| 19 | $data = stripslashes_deep( $_GET ); |
| 20 | $data['auth_type'] = 'client'; |
| 21 | $roles = new Roles(); |
| 22 | $role = $roles->translate_current_user_to_role(); |
| 23 | $redirect = isset( $data['redirect'] ) ? esc_url_raw( (string) $data['redirect'] ) : ''; |
| 24 | |
| 25 | check_admin_referer( "jetpack-authorize_{$role}_{$redirect}" ); |
| 26 | |
| 27 | $tracking = new Tracking(); |
| 28 | |
| 29 | $manager = new Connection_Manager(); |
| 30 | $result = $manager->authorize( $data ); |
| 31 | |
| 32 | if ( is_wp_error( $result ) ) { |
| 33 | Jetpack::state( 'error', $result->get_error_code() ); |
| 34 | |
| 35 | $tracking->record_user_event( |
| 36 | 'jpc_client_authorize_fail', |
| 37 | array( |
| 38 | 'error_code' => $result->get_error_code(), |
| 39 | 'error_message' => $result->get_error_message(), |
| 40 | ) |
| 41 | ); |
| 42 | } else { |
| 43 | /** |
| 44 | * Fires after the Jetpack client is authorized to communicate with WordPress.com. |
| 45 | * |
| 46 | * @since 4.2.0 |
| 47 | * |
| 48 | * @param int Jetpack Blog ID. |
| 49 | */ |
| 50 | do_action( 'jetpack_client_authorized', Jetpack_Options::get_option( 'id' ) ); |
| 51 | } |
| 52 | |
| 53 | if ( wp_validate_redirect( $redirect ) ) { |
| 54 | // Exit happens below in $this->do_exit() |
| 55 | wp_safe_redirect( $redirect ); |
| 56 | } else { |
| 57 | // Exit happens below in $this->do_exit() |
| 58 | wp_safe_redirect( Jetpack::admin_url() ); |
| 59 | } |
| 60 | |
| 61 | $tracking->record_user_event( 'jpc_client_authorize_success' ); |
| 62 | |
| 63 | $this->do_exit(); |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | * @deprecated 8.0 Use Automattic\Jetpack\Connection\Manager::authorize() instead. |
| 68 | */ |
| 69 | function authorize( $data = array() ) { |
| 70 | _deprecated_function( __METHOD__, 'jetpack-8.0', 'Automattic\\Jetpack\\Connection\\Manager::authorize' ); |
| 71 | $manager = new Connection_Manager(); |
| 72 | return $manager->authorize( $data ); |
| 73 | } |
| 74 | |
| 75 | public static function deactivate_plugin( $probable_file, $probable_title ) { |
| 76 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 77 | if ( is_plugin_active( $probable_file ) ) { |
| 78 | deactivate_plugins( $probable_file ); |
| 79 | return 1; |
| 80 | } else { |
| 81 | // If the plugin is not in the usual place, try looking through all active plugins. |
| 82 | $active_plugins = Jetpack::get_active_plugins(); |
| 83 | foreach ( $active_plugins as $plugin ) { |
| 84 | $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
| 85 | if ( $data['Name'] == $probable_title ) { |
| 86 | deactivate_plugins( $plugin ); |
| 87 | return 1; |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * @deprecated since 8.0.0 Use Automattic\Jetpack\Connection\Manager::get_token() instead. |
| 97 | * |
| 98 | * @return object|WP_Error |
| 99 | */ |
| 100 | function get_token( $data ) { |
| 101 | _deprecated_function( __METHOD__, 'jetpack-8.0', 'Automattic\\Jetpack\\Connection\\Manager\\get_token' ); |
| 102 | return Jetpack::connection()->get_token( $data ); |
| 103 | } |
| 104 | |
| 105 | public function get_jetpack() { |
| 106 | return Jetpack::init(); |
| 107 | } |
| 108 | |
| 109 | public function do_exit() { |
| 110 | exit; |
| 111 | } |
| 112 | } |
| 113 |