jetpack
Last commit date
3rd-party
4 years ago
_inc
4 years ago
css
4 years ago
extensions
4 years ago
images
4 years ago
jetpack_vendor
4 years ago
json-endpoints
3 years ago
modules
1 year ago
sal
4 years ago
src
4 years ago
vendor
4 years ago
views
4 years ago
CHANGELOG.md
4 years ago
LICENSE.txt
5 years ago
SECURITY.md
5 years ago
class-jetpack-connection-status.php
5 years ago
class-jetpack-pre-connection-jitms.php
4 years ago
class-jetpack-recommendations-banner.php
4 years ago
class-jetpack-stats-dashboard-widget.php
4 years ago
class-jetpack-wizard-banner.php
5 years ago
class-jetpack-xmlrpc-methods.php
5 years ago
class.frame-nonce-preview.php
4 years ago
class.jetpack-admin.php
4 years ago
class.jetpack-affiliate.php
4 years ago
class.jetpack-autoupdate.php
4 years ago
class.jetpack-bbpress-json-api.compat.php
5 years ago
class.jetpack-cli.php
4 years ago
class.jetpack-client-server.php
4 years ago
class.jetpack-connection-banner.php
4 years ago
class.jetpack-data.php
5 years ago
class.jetpack-gutenberg.php
4 years ago
class.jetpack-heartbeat.php
4 years ago
class.jetpack-idc.php
4 years ago
class.jetpack-modules-list-table.php
4 years ago
class.jetpack-network-sites-list-table.php
4 years ago
class.jetpack-network.php
4 years ago
class.jetpack-plan.php
4 years ago
class.jetpack-post-images.php
4 years ago
class.jetpack-twitter-cards.php
5 years ago
class.jetpack-user-agent.php
4 years ago
class.jetpack.php
4 years ago
class.json-api-endpoints.php
3 years ago
class.json-api.php
4 years ago
class.photon.php
4 years ago
composer.json
4 years ago
functions.compat.php
5 years ago
functions.cookies.php
5 years ago
functions.gallery.php
6 years ago
functions.global.php
4 years ago
functions.opengraph.php
4 years ago
functions.photon.php
4 years ago
jest.config.js
4 years ago
jetpack.php
1 year ago
json-api-config.php
5 years ago
json-endpoints.php
7 years ago
load-jetpack.php
4 years ago
locales.php
7 years ago
readme.txt
1 year ago
require-lib.php
5 years ago
uninstall.php
5 years ago
wpml-config.xml
10 years ago
class.jetpack-client-server.php
114 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Client = Plugin |
| 4 | * Client Server = API Methods the Plugin must respond to |
| 5 | * |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | use Automattic\Jetpack\Connection\Webhooks; |
| 10 | |
| 11 | /** |
| 12 | * Client = Plugin |
| 13 | * Client Server = API Methods the Plugin must respond to |
| 14 | */ |
| 15 | class Jetpack_Client_Server { |
| 16 | |
| 17 | /** |
| 18 | * Handle the client authorization error. |
| 19 | * |
| 20 | * @param WP_Error $error The error object. |
| 21 | */ |
| 22 | public static function client_authorize_error( $error ) { |
| 23 | if ( $error instanceof WP_Error ) { |
| 24 | Jetpack::state( 'error', $error->get_error_code() ); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * The user is already authorized, we set the Jetpack state and adjust the redirect URL. |
| 30 | * |
| 31 | * @return string |
| 32 | */ |
| 33 | public static function client_authorize_already_authorized_url() { |
| 34 | Jetpack::state( 'message', 'already_authorized' ); |
| 35 | return Jetpack::admin_url(); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * The authorization processing has started. |
| 40 | */ |
| 41 | public static function client_authorize_processing() { |
| 42 | Jetpack::log( 'authorize' ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * The authorization has completed (successfully or not), and the redirect URL is empty. |
| 47 | * We set the Jetpack Dashboard as the default URL. |
| 48 | * |
| 49 | * @return string |
| 50 | */ |
| 51 | public static function client_authorize_fallback_url() { |
| 52 | return Jetpack::admin_url(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Authorization handler. |
| 57 | * |
| 58 | * @deprecated since Jetpack 9.5.0 |
| 59 | * @see Webhooks::handle_authorize() |
| 60 | */ |
| 61 | public function client_authorize() { |
| 62 | _deprecated_function( __METHOD__, 'jetpack-9.5.0', 'Automattic\\Jetpack\\Connection\\Webhooks::handle_authorize' ); |
| 63 | ( new Webhooks() )->handle_authorize(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Deactivate a plugin. |
| 68 | * |
| 69 | * @param string $probable_file Expected plugin file. |
| 70 | * @param string $probable_title Expected plugin title. |
| 71 | * @return int 1 if a plugin was deactivated, 0 if not. |
| 72 | */ |
| 73 | public static function deactivate_plugin( $probable_file, $probable_title ) { |
| 74 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 75 | if ( is_plugin_active( $probable_file ) ) { |
| 76 | deactivate_plugins( $probable_file ); |
| 77 | return 1; |
| 78 | } else { |
| 79 | // If the plugin is not in the usual place, try looking through all active plugins. |
| 80 | $active_plugins = Jetpack::get_active_plugins(); |
| 81 | foreach ( $active_plugins as $plugin ) { |
| 82 | $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
| 83 | if ( $data['Name'] === $probable_title ) { |
| 84 | deactivate_plugins( $plugin ); |
| 85 | return 1; |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get the Jetpack instance. |
| 95 | * |
| 96 | * @deprecated since Jetpack 9.5.0 |
| 97 | * @see Jetpack::init() |
| 98 | */ |
| 99 | public function get_jetpack() { |
| 100 | _deprecated_function( __METHOD__, 'jetpack-9.5.0', 'Jetpack::init' ); |
| 101 | return Jetpack::init(); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * No longer used. |
| 106 | * |
| 107 | * @deprecated since Jetpack 9.5.0 |
| 108 | */ |
| 109 | public function do_exit() { |
| 110 | _deprecated_function( __METHOD__, 'jetpack-9.5.0' ); |
| 111 | exit; |
| 112 | } |
| 113 | } |
| 114 |