PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 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 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-publicize/src/class-keyring-helper.php +18 -56 16.2 → 16.3 View file →
@@ -12,9 +12,10 @@
12 12 use Jetpack_IXR_Client;
13 13 use Jetpack_Options;
14 14
15 15 /**
16 - * A series of utilities to interact with a Keyring instance.
16 + * Starts Keyring connection requests and removes Publicize connections, both
17 + * through public-api.
17 18 */
18 19 class Keyring_Helper {
19 20 /**
20 21 * Class instance
@@ -23,15 +24,8 @@
23 24 */
24 25 private static $instance = null;
25 26
26 27 /**
27 - * Whether the `sharing` page is registered.
28 - *
29 - * @var bool
30 - */
31 - private static $is_sharing_page_registered = false;
32 -
33 - /**
34 28 * Initialize instance.
35 29 */
36 30 public static function init() {
37 31 if ( null === self::$instance ) {
@@ -40,27 +34,13 @@
40 34
41 35 return self::$instance;
42 36 }
43 37
38 + /**
39 + * Services whose connection request starts from the site. Jetpack Social's
40 + * networks start theirs from WordPress.com instead.
41 + */
44 42 const SERVICES = array(
45 - 'facebook' => array(
46 - 'for' => 'publicize',
47 - ),
48 - 'twitter' => array(
49 - 'for' => 'publicize',
50 - ),
51 - 'linkedin' => array(
52 - 'for' => 'publicize',
53 - ),
54 - 'tumblr' => array(
55 - 'for' => 'publicize',
56 - ),
57 - 'path' => array(
58 - 'for' => 'publicize',
59 - ),
60 - 'google_plus' => array(
61 - 'for' => 'publicize',
62 - ),
63 43 'google_site_verification' => array(
64 44 'for' => 'other',
65 45 ),
66 46 );
@@ -103,9 +83,9 @@
103 83 return $url;
104 84 }
105 85
106 86 /**
107 - * Build a connection URL (sharing settings page with unique query args to create a connection).
87 + * Build a connection URL (admin URL with unique query args to create a connection).
108 88 *
109 89 * @param string $service_name Service name.
110 90 * @param string $for Feature name.
111 91 */
@@ -123,9 +103,9 @@
123 103 );
124 104 }
125 105
126 106 /**
127 - * Build a URL to refresh a connection (sharing settings page with unique query args to refresh a connection).
107 + * Build a URL to refresh a connection (admin URL with unique query args to refresh a connection).
128 108 * Similar to connect_url, but with a refresh parameter.
129 109 *
130 110 * @param string $service_name Service name.
131 111 * @param string $for Feature name.
@@ -145,9 +125,9 @@
145 125 );
146 126 }
147 127
148 128 /**
149 - * Build a URL to delete a connection (sharing settings page with unique query args to delete a connection).
129 + * Build a URL to delete a connection (admin URL with unique query args to delete a connection).
150 130 *
151 131 * @param string $service_name Service name.
152 132 * @param string $id Connection ID.
153 133 */
@@ -165,9 +145,9 @@
165 145 );
166 146 }
167 147
168 148 /**
169 - * Build contents handling Keyring connection management into Sharing settings screen.
149 + * Handle a Keyring connection request or deletion started from connect_url(), refresh_url() or disconnect_url().
170 150 */
171 151 public static function intercept_request() {
172 152 if ( ! empty( $_GET['publicize_action'] ) && isset( $_GET['action'] ) ) {
173 153 $service_name = null;
@@ -226,39 +206,21 @@
226 206 $service_name,
227 207 urlencode_deep(
228 208 $custom_inputs +
229 209 array(
230 - 'action' => 'request',
231 - 'redirect_uri' => add_query_arg( array( 'action' => 'done' ), menu_page_url( 'sharing', false ) ),
232 - 'for' => $for,
233 - // required flag that says this connection is intended for publicize.
234 - 'siteurl' => site_url(),
235 - 'state' => $user->ID,
236 - 'blog_id' => $wpcom_blog_id,
237 - 'secret_1' => $verification['secret_1'],
238 - 'secret_2' => $verification['secret_2'],
239 - 'eol' => $verification['exp'],
210 + 'action' => 'request',
211 + 'for' => $for,
212 + 'siteurl' => site_url(),
213 + 'state' => $user->ID,
214 + 'blog_id' => $wpcom_blog_id,
215 + 'secret_1' => $verification['secret_1'],
216 + 'secret_2' => $verification['secret_2'],
217 + 'eol' => $verification['exp'],
240 218 )
241 219 )
242 220 );
243 221 wp_redirect( $redirect ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- The API URL is an external URL and is filterable.
244 222 exit( 0 );
245 -
246 - case 'completed':
247 - /*
248 - * We do not use a nonce here,
249 - * since we're populating a local cache of
250 - * the Publicize connections that were created and stored on WordPress.com.
251 - */
252 - $xml = new Jetpack_IXR_Client();
253 - $xml->query( 'jetpack.fetchPublicizeConnections' );
254 -
255 - if ( ! $xml->isError() ) {
256 - $response = $xml->getResponse();
257 - Jetpack_Options::update_option( 'publicize_connections', $response );
258 - }
259 -
260 - break;
261 223
262 224 case 'delete':
263 225 $id = isset( $_GET['id'] ) ? filter_var( wp_unslash( $_GET['id'] ) ) : null;
264 226