Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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() ); |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | $tracking->record_user_event( |
||
| 36 | 'jpc_client_authorize_fail', |
||
| 37 | array( |
||
| 38 | 'error_code' => $result->get_error_code(), |
||
|
0 ignored issues
–
show
The method
get_error_code() does not seem to exist on object<WP_Error>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 39 | 'error_message' => $result->get_error_message(), |
||
|
0 ignored issues
–
show
The method
get_error_message() does not seem to exist on object<WP_Error>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 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 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.