PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 9.9.3
Jetpack – WP Security, Backup, Speed, & Growth v9.9.3
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 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / class.jetpack-client-server.php

class.jetpack-client-server.php in Jetpack – WP Security, Backup, Speed, & Growth 9.9.3, at class.jetpack-client-server.php

99 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Automattic\Jetpack\Connection\Webhooks;
4
5 /**
6 * Client = Plugin
7 * Client Server = API Methods the Plugin must respond to
8 */
9 class Jetpack_Client_Server {
10
11 /**
12 * Handle the client authorization error.
13 *
14 * @param WP_Error $error The error object.
15 */
16 public static function client_authorize_error( $error ) {
17 if ( $error instanceof WP_Error ) {
18 Jetpack::state( 'error', $error->get_error_code() );
19 }
20 }
21
22 /**
23 * The user is already authorized, we set the Jetpack state and adjust the redirect URL.
24 *
25 * @return string
26 */
27 public static function client_authorize_already_authorized_url() {
28 Jetpack::state( 'message', 'already_authorized' );
29 return Jetpack::admin_url();
30 }
31
32 /**
33 * The authorization processing has started.
34 */
35 public static function client_authorize_processing() {
36 Jetpack::log( 'authorize' );
37 }
38
39 /**
40 * The authorization has completed (successfully or not), and the redirect URL is empty.
41 * We set the Jetpack Dashboard as the default URL.
42 *
43 * @return string
44 */
45 public static function client_authorize_fallback_url() {
46 return Jetpack::admin_url();
47 }
48
49 /**
50 * Authorization handler.
51 *
52 * @deprecated since Jetpack 9.5.0
53 * @see Webhooks::handle_authorize()
54 */
55 public function client_authorize() {
56 _deprecated_function( __METHOD__, 'jetpack-9.5.0', 'Automattic\\Jetpack\\Connection\\Webhooks::handle_authorize' );
57 ( new Webhooks() )->handle_authorize();
58 }
59
60 public static function deactivate_plugin( $probable_file, $probable_title ) {
61 include_once ABSPATH . 'wp-admin/includes/plugin.php';
62 if ( is_plugin_active( $probable_file ) ) {
63 deactivate_plugins( $probable_file );
64 return 1;
65 } else {
66 // If the plugin is not in the usual place, try looking through all active plugins.
67 $active_plugins = Jetpack::get_active_plugins();
68 foreach ( $active_plugins as $plugin ) {
69 $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
70 if ( $data['Name'] == $probable_title ) {
71 deactivate_plugins( $plugin );
72 return 1;
73 }
74 }
75 }
76
77 return 0;
78 }
79
80 /**
81 * @deprecated since Jetpack 9.5.0
82 * @see Jetpack::init()
83 */
84 public function get_jetpack() {
85 _deprecated_function( __METHOD__, 'jetpack-9.5.0', 'Jetpack::init' );
86 return Jetpack::init();
87 }
88
89 /**
90 * No longer used.
91 *
92 * @deprecated since Jetpack 9.5.0
93 */
94 public function do_exit() {
95 _deprecated_function( __METHOD__, 'jetpack-9.5.0' );
96 exit;
97 }
98 }
99