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-publicize.php +31 -138 16.3-a.3 → 16.3 View file →
@@ -7,9 +7,8 @@
7 7
8 8 namespace Automattic\Jetpack\Publicize;
9 9
10 10 use Automattic\Jetpack\Connection\Client;
11 -use Automattic\Jetpack\Connection\Tokens;
12 11 use Jetpack_IXR_Client;
13 12 use Jetpack_Options;
14 13 use WP_Error;
15 14 use WP_Post;
@@ -42,12 +41,8 @@
42 41 parent::__construct();
43 42
44 43 add_filter( 'jetpack_xmlrpc_unauthenticated_methods', array( $this, 'register_update_publicize_connections_xmlrpc_method' ) );
45 44
46 - add_action( 'load-settings_page_sharing', array( $this, 'admin_page_load' ), 9 );
47 -
48 - add_action( 'load-settings_page_sharing', array( $this, 'force_user_connection' ) );
49 -
50 45 add_filter( 'jetpack_published_post_flags', array( $this, 'set_post_flags' ), 10, 2 );
51 46
52 47 add_action( 'wp_insert_post', array( $this, 'save_publicized' ), 11, 2 );
53 48
@@ -62,70 +57,51 @@
62 57 }
63 58
64 59 /**
65 60 * Force user connection before showing the Publicize UI.
61 + *
62 + * @deprecated 0.88.0 Settings > Sharing no longer hosts the Publicize UI.
63 + *
64 + * @return void
66 65 */
67 66 public function force_user_connection() {
68 - global $current_user;
69 -
70 - $user_token = ( new Tokens() )->get_access_token( $current_user->ID );
71 - $is_user_connected = $user_token && ! is_wp_error( $user_token );
72 -
73 - // If the user is already connected via Jetpack, then we're good.
74 - if ( $is_user_connected ) {
75 - return;
76 - }
77 -
78 - // If they're not connected, then remove the Publicize UI and tell them they need to connect first.
79 - global $publicize_ui;
80 - remove_action( 'pre_admin_screen_sharing', array( $publicize_ui, 'admin_page' ) );
81 -
82 - // Do we really need `admin_styles`? With the new admin UI, it's breaking some bits.
83 - // Jetpack::init()->admin_styles();.
84 - add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page_warning' ), 1 );
67 + _deprecated_function( __METHOD__, 'publicize-0.88.0' );
85 68 }
86 69
87 70 /**
88 71 * Show a warning when Publicize does not have a connection.
72 + *
73 + * @deprecated 0.88.0 Settings > Sharing no longer hosts the Publicize UI.
74 + *
75 + * @return void
89 76 */
90 77 public function admin_page_warning() {
91 - $jetpack = \Jetpack::init();
92 - $blog_name = get_bloginfo( 'blogname' );
93 - if ( empty( $blog_name ) ) {
94 - $blog_name = home_url( '/' );
95 - }
78 + _deprecated_function( __METHOD__, 'publicize-0.88.0' );
79 + }
96 80
97 - ?>
98 - <div id="message" class="updated jetpack-message jp-connect">
99 - <div class="jetpack-wrap-container">
100 - <div class="jetpack-text-container">
101 - <p>
102 - <?php
103 - printf(
104 - /* translators: %s is the name of the blog */
105 - esc_html( wptexturize( __( "To use Jetpack Social, you'll need to link your %s account to your WordPress.com account using the link below.", 'jetpack-publicize-pkg' ) ) ),
106 - '<strong>' . esc_html( $blog_name ) . '</strong>'
107 - );
108 - ?>
109 - </p>
110 - <p><?php echo esc_html( wptexturize( __( "If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack-publicize-pkg' ) ) ); ?></p>
111 - </div>
112 - <div class="jetpack-install-container">
113 - <p class="submit"><a
114 - href="<?php echo esc_url( $jetpack->build_connect_url( false, menu_page_url( 'sharing', false ) ) ); ?>"
115 - class="button-connector"
116 - id="wpcom-connect"><?php esc_html_e( 'Link account with WordPress.com', 'jetpack-publicize-pkg' ); ?></a>
117 - </p>
118 - <p class="jetpack-install-blurb">
119 - <?php jetpack_render_tos_blurb(); ?>
120 - </p>
121 - </div>
122 - </div>
123 - </div>
124 - <?php
81 + /**
82 + * Show error on settings page if applicable.
83 + *
84 + * @deprecated 0.88.0 Settings > Sharing no longer hosts connection errors.
85 + *
86 + * @return void
87 + */
88 + public function admin_page_load() {
89 + _deprecated_function( __METHOD__, 'publicize-0.88.0' );
125 90 }
126 91
127 92 /**
93 + * Display an error message.
94 + *
95 + * @deprecated 0.88.0 Settings > Sharing no longer hosts connection errors.
96 + *
97 + * @return void
98 + */
99 + public function display_connection_error() {
100 + _deprecated_function( __METHOD__, 'publicize-0.88.0' );
101 + }
102 +
103 + /**
128 104 * Remove a Publicize Connection.
129 105 *
130 106 * @param string $service_name 'facebook', 'twitter', etc.
131 107 * @param string $connection_id Connection ID.
@@ -365,91 +341,8 @@
365 341 */
366 342 public function get_connection_meta( $connection ) {
367 343 $connection['user_id'] = $connection['connection_data']['user_id']; // Allows for shared connections.
368 344 return $connection;
369 - }
370 -
371 - /**
372 - * Show error on settings page if applicable.
373 - */
374 - public function admin_page_load() {
375 - $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
376 -
377 - if ( 'error' === $action ) {
378 - add_action( 'pre_admin_screen_sharing', array( $this, 'display_connection_error' ), 9 );
379 - }
380 - }
381 -
382 - /**
383 - * Display an error message.
384 - */
385 - public function display_connection_error() {
386 - $code = false;
387 - // phpcs:disable WordPress.Security.NonceVerification.Recommended
388 - $service = isset( $_GET['service'] ) ? sanitize_text_field( wp_unslash( $_GET['service'] ) ) : null;
389 - $publicize_error = isset( $_GET['publicize_error'] ) ? sanitize_text_field( wp_unslash( $_GET['publicize_error'] ) ) : null;
390 - // phpcs:enable WordPress.Security.NonceVerification.Recommended
391 -
392 - if ( $service ) {
393 - /* translators: %s is the name of the Jetpack Social service (e.g. Facebook, Twitter) */
394 - $error = sprintf( __( 'There was a problem connecting to %s to create an authorized connection. Please try again in a moment.', 'jetpack-publicize-pkg' ), self::get_service_label( $service ) );
395 - } elseif ( $publicize_error ) {
396 - $code = strtolower( $publicize_error );
397 - switch ( $code ) {
398 - case '400':
399 - $error = __( 'An invalid request was made. This normally means that something intercepted or corrupted the request from your server to the Jetpack Server. Try again and see if it works this time.', 'jetpack-publicize-pkg' );
400 - break;
401 - case 'secret_mismatch':
402 - $error = __( 'We could not verify that your server is making an authorized request. Please try again, and make sure there is nothing interfering with requests from your server to the Jetpack Server.', 'jetpack-publicize-pkg' );
403 - break;
404 - case 'empty_blog_id':
405 - $error = __( 'No blog_id was included in your request. Please try disconnecting Jetpack from WordPress.com and then reconnecting it. Once you have done that, try connecting Jetpack Social again.', 'jetpack-publicize-pkg' );
406 - break;
407 - case 'empty_state':
408 - /* translators: %s is the URL of the Jetpack admin page */
409 - $error = sprintf( __( 'No user information was included in your request. Please make sure that your user account has connected to Jetpack. Connect your user account by going to the <a href="%s">Jetpack page</a> within wp-admin.', 'jetpack-publicize-pkg' ), \Jetpack::admin_url() );
410 - break;
411 - default:
412 - $error = __( 'Something which should never happen, happened. Sorry about that. If you try again, maybe it will work.', 'jetpack-publicize-pkg' );
413 - break;
414 - }
415 - } else {
416 - $error = __( 'There was a problem connecting with Jetpack Social. Please try again in a moment.', 'jetpack-publicize-pkg' );
417 - }
418 - // Using the same formatting/style as Jetpack::admin_notices() error.
419 - ?>
420 - <div id="message" class="jetpack-message jetpack-err">
421 - <div class="squeezer">
422 - <h2>
423 - <?php
424 - echo wp_kses(
425 - $error,
426 - array(
427 - 'a' => array(
428 - 'href' => true,
429 - ),
430 - 'code' => true,
431 - 'strong' => true,
432 - 'br' => true,
433 - 'b' => true,
434 - )
435 - );
436 - ?>
437 - </h2>
438 - <?php if ( $code ) : ?>
439 - <p>
440 - <?php
441 - printf(
442 - /* translators: %s is the name of the error */
443 - esc_html__( 'Error code: %s', 'jetpack-publicize-pkg' ),
444 - esc_html( stripslashes( $code ) )
445 - );
446 - ?>
447 - </p>
448 - <?php endif; ?>
449 - </div>
450 - </div>
451 - <?php
452 345 }
453 346
454 347 /**
455 348 * Show a message that the connection has been removed.