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-ui.php +91 -245 12.2.3 → 16.3 View file →
@@ -7,11 +7,14 @@
7 7
8 8 namespace Automattic\Jetpack\Publicize;
9 9
10 10 use Automattic\Jetpack\Assets;
11 +use Automattic\Jetpack\Current_Plan;
12 +use Automattic\Jetpack\Publicize\Publicize_Utils as Utils;
13 +use Automattic\Jetpack\Status\Host;
11 14
12 15 /**
13 - * Only user facing pieces of Publicize are found here.
16 + * Classic editor integration: the Publicize metabox on the post screen, and its assets.
14 17 */
15 18 class Publicize_UI {
16 19 /**
17 20 * Contains an instance of class 'Publicize' which loads Keyring, sets up services, etc.
@@ -20,9 +23,9 @@
20 23 */
21 24 public $publicize;
22 25
23 26 /**
24 - * URL to Sharing settings page in wordpress.com
27 + * URL of the admin page where Publicize connections are managed.
25 28 *
26 29 * @var string
27 30 */
28 31 protected $publicize_settings_url = '';
@@ -36,9 +39,9 @@
36 39 $publicize = new Publicize();
37 40 }
38 41 $this->publicize = $publicize;
39 42
40 - add_action( 'init', array( $this, 'init' ) );
43 + add_action( 'admin_init', array( $this, 'init' ) );
41 44 }
42 45
43 46 /**
44 47 * Initialize UI-related functionality.
@@ -43,107 +46,23 @@
43 46 /**
44 47 * Initialize UI-related functionality.
45 48 */
46 49 public function init() {
47 - $this->publicize_settings_url = $this->publicize->publicize_connections_url();
48 -
49 50 // Show only to users with the capability required to manage their Publicize connections.
50 - if ( ! $this->publicize->current_user_can_access_publicize_data() ) {
51 + if ( ! Utils::is_publicize_active() || ! $this->publicize->current_user_can_access_publicize_data() ) {
51 52 return;
52 53 }
53 54
55 + $this->publicize_settings_url = $this->publicize->publicize_connections_url();
56 +
54 57 // Assets (css, js).
55 - add_action( 'load-settings_page_sharing', array( $this, 'load_assets' ) );
56 58 add_action( 'admin_head-post.php', array( $this, 'post_page_metabox_assets' ) );
57 59 add_action( 'admin_head-post-new.php', array( $this, 'post_page_metabox_assets' ) );
58 60
59 - // Management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen).
60 - add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page' ) );
61 61 add_action( 'post_submitbox_misc_actions', array( $this, 'post_page_metabox' ) );
62 62 }
63 63
64 64 /**
65 - * If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still
66 - */
67 - public function sharing_menu() {
68 - add_submenu_page(
69 - 'options-general.php',
70 - esc_html__( 'Sharing Settings', 'jetpack-publicize-pkg' ),
71 - esc_html__( 'Sharing', 'jetpack-publicize-pkg' ),
72 - 'publish_posts',
73 - 'sharing',
74 - array( $this, 'wrapper_admin_page' )
75 - );
76 - }
77 -
78 - /**
79 - * Add admin page with wrapper.
80 - */
81 - public function wrapper_admin_page() {
82 - if ( class_exists( 'Jetpack_Admin_Page' ) ) {
83 - \Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ) );
84 - }
85 - }
86 -
87 - /**
88 - * Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists.
89 - */
90 - public function management_page() {
91 - ?>
92 - <div class="wrap">
93 - <div class="icon32" id="icon-options-general"><br /></div>
94 - <h1><?php esc_html_e( 'Sharing Settings', 'jetpack-publicize-pkg' ); ?></h1>
95 -
96 - <?php
97 - /** This action is documented in modules/sharedaddy/sharing.php */
98 - do_action( 'pre_admin_screen_sharing' );
99 - ?>
100 - </div>
101 - <?php
102 - }
103 -
104 - /**
105 - * Styling for the sharing screen and popups
106 - * JS for the options and switching
107 - */
108 - public function load_assets() {
109 - if ( class_exists( 'Jetpack_Admin_Page' ) ) {
110 - \Jetpack_Admin_Page::load_wrapper_styles();
111 - }
112 - }
113 -
114 - /**
115 - * Lists the current user's publicized accounts for the blog
116 - * looks exactly like Publicize v1 for now, UI and functionality updates will come after the move to keyring
117 - */
118 - public function admin_page() {
119 - ?>
120 - <h2 id="publicize"><?php esc_html_e( 'Jetpack Social', 'jetpack-publicize-pkg' ); ?></h2>
121 - <p><?php esc_html_e( 'Connect social media services to automatically share new posts.', 'jetpack-publicize-pkg' ); ?></p>
122 - <h4>
123 - <?php
124 - printf(
125 - wp_kses(
126 - /* translators: %s is the link to the Publicize page in Calypso */
127 - __( "We've made some updates to Jetpack Social. Please visit the <a href='%s' class='jptracks' data-jptracks-name='legacy_publicize_settings'>WordPress.com sharing page</a> to manage your Jetpack Social connections or use the button below.", 'jetpack-publicize-pkg' ),
128 - array(
129 - 'a' => array(
130 - 'href' => array(),
131 - 'class' => array(),
132 - 'data-jptracks-name' => array(),
133 - ),
134 - )
135 - ),
136 - esc_url( $this->publicize->publicize_connections_url() )
137 - );
138 - ?>
139 - </h4>
140 -
141 - <a href="<?php echo esc_url( $this->publicize->publicize_connections_url() ); ?>" class="button button-primary jptracks" data-jptracks-name='legacy_publicize_settings'><?php esc_html_e( 'Jetpack Social Settings', 'jetpack-publicize-pkg' ); ?></a>
142 - <?php
143 - }
144 -
145 - /**
146 65 * CSS for styling the publicize message box and counter that displays on the post page.
147 66 * There is also some JavaScript for length counting and some basic display effects.
148 67 */
149 68 public function post_page_metabox_assets() {
@@ -152,11 +71,15 @@
152 71 if ( $current_screen && $current_screen->is_block_editor ) {
153 72 return;
154 73 }
155 74
75 + $is_atomic_site = ( new Host() )->is_woa_site();
76 + $is_simple_site = ( new Host() )->is_wpcom_simple();
77 + $site_type = $is_atomic_site ? 'atomic' : ( $is_simple_site ? 'simple' : 'jetpack' );
78 +
156 79 Assets::register_script(
157 - 'jetpack-social-classic-editor-connections',
158 - '../build/classic-editor-connections.js',
80 + 'jetpack-social-classic-editor-options',
81 + '../build/classic-editor.js',
159 82 __FILE__,
160 83 array(
161 84 'in_footer' => true,
162 85 'enqueue' => true,
@@ -162,30 +85,36 @@
162 85 'enqueue' => true,
163 86 'textdomain' => 'jetpack-publicize-pkg',
164 87 )
165 88 );
89 +
166 90 wp_add_inline_script(
167 - 'jetpack-social-classic-editor-connections',
168 - 'var jetpackSocialClassicEditorConnections = ' . wp_json_encode(
91 + 'jetpack-social-classic-editor-options',
92 + 'var jetpackSocialClassicEditorOptions = ' . wp_json_encode(
169 93 array(
170 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
171 - 'connectionsUrl' => esc_url( $this->publicize_settings_url ),
172 - )
94 + 'connectionsUrl' => esc_url( $this->publicize_settings_url ),
95 + 'isEnhancedPublishingEnabled' => $this->publicize->has_enhanced_publishing_feature(),
96 + 'resharePath' => '/wpcom/v2/publicize/share-post/{postId}',
97 + 'refreshConnections' => '/wpcom/v2/publicize/connections?test_connections=1',
98 + 'isReshareSupported' => Current_Plan::supports( 'republicize' ),
99 + 'siteType' => $site_type,
100 + ),
101 + JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP
173 102 ),
174 103 'before'
175 104 );
176 105
177 106 $default_prefix = $this->publicize->default_prefix;
178 - $default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) );
107 + $default_prefix = preg_replace( '/%([0-9])\$s/', '" + %\\1$s + "', wp_json_encode( (string) $default_prefix, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) );
179 108
180 109 $default_message = $this->publicize->default_message;
181 - $default_message = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_message ) );
110 + $default_message = preg_replace( '/%([0-9])\$s/', '" + %\\1$s + "', wp_json_encode( (string) $default_message, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) );
182 111
183 112 $default_suffix = $this->publicize->default_suffix;
184 - $default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) );
113 + $default_suffix = preg_replace( '/%([0-9])\$s/', '" + %\\1$s + "', wp_json_encode( (string) $default_suffix, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) );
185 114
186 - $max_length = defined( 'JETPACK_PUBLICIZE_TWITTER_LENGTH' ) ? JETPACK_PUBLICIZE_TWITTER_LENGTH : 280;
187 - $max_length = $max_length - 24; // t.co link, space.
115 + $max_length = defined( 'JETPACK_PUBLICIZE_TWITTER_LENGTH' ) ? JETPACK_PUBLICIZE_TWITTER_LENGTH : 280;
116 + $max_length -= 24; // t.co link, space.
188 117
189 118 ?>
190 119
191 120 <script type="text/javascript">
@@ -216,9 +145,9 @@
216 145 // Keep the postTitle and the placeholder in sync
217 146 postTitle.on( 'keyup', function( e ) {
218 147 var url = $( '#sample-permalink' ).text();
219 148 <?php // phpcs:ignore ?>
220 - var defaultMessage = $.trim( '<?php printf( $default_prefix, 'url' ); printf( $default_message, 'e.currentTarget.value', 'url' ); printf( $default_suffix, 'url' ); ?>' )
149 + var defaultMessage = $.trim( <?php printf( $default_prefix, 'url' ); ?> + <?php printf( $default_message, 'e.currentTarget.value', 'url' ); ?> + <?php printf( $default_suffix, 'url' ); ?> )
221 150 .replace( /<[^>]+>/g,'');
222 151
223 152 wpasTitle.attr( 'placeholder', defaultMessage );
224 153 wpasTitle.trigger( 'keyup' );
@@ -353,9 +282,9 @@
353 282 }
354 283 .publicize-external-link__text {
355 284 text-decoration: underline;
356 285 }
357 -#publicize-title:before {
286 +#publicize-title::before {
358 287 content: "\f237";
359 288 font: normal 20px/1 dashicons;
360 289 speak: none;
361 290 margin-left: -1px;
@@ -379,8 +308,11 @@
379 308 .publicize__notice-warning .dashicons {
380 309 font-size: 16px;
381 310 text-decoration: none;
382 311 }
312 +.publicize-placeholders-help {
313 + margin: 0.5rem 0 1rem;
314 +}
383 315 </style>
384 316 <?php
385 317 }
386 318
@@ -400,26 +332,8 @@
400 332 );
401 333 }
402 334
403 335 /**
404 - * Extracts the connections that require reauthentication, for example, LinkedIn, when it switched v1 to v2 of its API.
405 - *
406 - * @return array Connections that must be reauthenticated
407 - */
408 - public function get_must_reauth_connections() {
409 - $must_reauth = array();
410 - $connections = $this->publicize->get_connections( 'linkedin' );
411 - if ( is_array( $connections ) ) {
412 - foreach ( $connections as $index => $connection ) {
413 - if ( $this->publicize->is_invalid_linkedin_connection( $connection ) ) {
414 - $must_reauth[ $index ] = 'LinkedIn';
415 - }
416 - }
417 - }
418 - return $must_reauth;
419 - }
420 -
421 - /**
422 336 * Controls the metabox that is displayed on the post page
423 337 * Allows the user to customize the message that will be sent out to the social network, as well as pick which
424 338 * networks to publish to. Also displays the character counter and some other information.
425 339 */
@@ -431,14 +345,8 @@
431 345 }
432 346
433 347 $connections_data = $this->publicize->get_filtered_connection_data();
434 348
435 - $available_services = $this->publicize->get_services( 'all' );
436 -
437 - if ( ! is_array( $available_services ) ) {
438 - $available_services = array();
439 - }
440 -
441 349 if ( ! is_array( $connections_data ) ) {
442 350 $connections_data = array();
443 351 }
444 352 ?>
@@ -449,40 +357,12 @@
449 357
450 358 if ( ! empty( $connections_data ) ) :
451 359 $publicize_form = $this->get_metabox_form_connected( $connections_data );
452 360
453 - $must_reauth = $this->get_must_reauth_connections();
454 - if ( ! empty( $must_reauth ) ) {
455 - foreach ( $must_reauth as $connection_name ) {
456 - ?>
457 - <span class="notice-warning publicize__notice-warning">
458 - <?php
459 - printf(
460 - /* translators: %s is the name of a Jetpack Social service like "LinkedIn" */
461 - esc_html__(
462 - 'Your %s connection needs to be reauthenticated to continue working – head to Sharing to take care of it.',
463 - 'jetpack-publicize-pkg'
464 - ),
465 - $connection_name // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
466 - );
467 - ?>
468 - <a
469 - class="publicize-external-link"
470 - href="<?php echo esc_url( $this->publicize->publicize_connections_url() ); ?>"
471 - target="_blank"
472 - >
473 - <span class="publicize-external-link__text"><?php esc_html_e( 'Go to Sharing settings', 'jetpack-publicize-pkg' ); ?></span>
474 - <span class="dashicons dashicons-external"></span>
475 - </a>
476 - </span>
477 - <?php
478 - }
479 - }
480 -
481 361 $labels = array();
482 362
483 363 foreach ( $connections_data as $connection_data ) {
484 - if ( ! $connection_data['enabled'] || ( isset( $connection_data['is_healthy'] ) && false === $connection_data['is_healthy'] ) ) {
364 + if ( ! $connection_data['enabled'] ) {
485 365 continue;
486 366 }
487 367
488 368 $labels[] = sprintf(
@@ -493,15 +373,15 @@
493 373
494 374 ?>
495 375 <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- labels are already escaped above ?>
496 376 <span id="publicize-defaults"><?php echo implode( ', ', $labels ); ?></span>
497 - <a href="#" id="publicize-form-edit"><?php esc_html_e( 'Edit', 'jetpack-publicize-pkg' ); ?></a>&nbsp;<a href="<?php echo esc_url( $this->publicize->publicize_connections_url( 'jetpack-social-connections-classic-editor' ) ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'Settings', 'jetpack-publicize-pkg' ); ?></a><br />
377 + <a href="#" id="publicize-form-edit"><?php esc_html_e( 'Edit', 'jetpack-publicize-pkg' ); ?></a>&nbsp;<a href="<?php echo esc_url( $this->publicize->publicize_connections_url() ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'Settings', 'jetpack-publicize-pkg' ); ?></a><br />
498 378 <?php
499 379 else :
500 - $publicize_form = $this->get_metabox_form_disconnected( $available_services );
380 + $publicize_form = '';
501 381 ?>
502 382 <strong><?php esc_html_e( 'Not Connected', 'jetpack-publicize-pkg' ); ?></strong>
503 - <a href="<?php echo esc_url( $this->publicize->publicize_connections_url( 'jetpack-social-connections-classic-editor' ) ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'Settings', 'jetpack-publicize-pkg' ); ?></a><br />
383 + <a href="<?php echo esc_url( $this->publicize->publicize_connections_url() ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'Settings', 'jetpack-publicize-pkg' ); ?></a><br />
504 384 <?php
505 385
506 386 endif;
507 387 ?>
@@ -559,12 +439,8 @@
559 439 */
560 440 private function get_metabox_form_connected( $connections_data ) {
561 441 global $post;
562 442
563 - $all_done = $this->publicize->post_is_done_sharing();
564 - $all_connections_done = true;
565 - $broken_connections = array();
566 -
567 443 ob_start();
568 444
569 445 ?>
570 446 <div id="publicize-form" class="hide-if-js">
@@ -571,40 +447,25 @@
571 447 <ul>
572 448 <?php
573 449
574 450 foreach ( $connections_data as $connection_data ) {
575 - $all_connections_done = $all_connections_done && $connection_data['done'];
576 - $connection_healthy = ! isset( $connection_data['is_healthy'] ) || $connection_data['is_healthy'];
577 - if ( ! $connection_healthy ) {
578 - $broken_connections[] = $connection_data;
579 -
580 - }
581 451 ?>
582 452
583 453 <li>
584 454 <label
585 - for="wpas-submit-<?php echo esc_attr( $connection_data['id'] ); ?>"
586 - <?php echo ! $connection_data['toggleable'] ? 'class="wpas-disabled"' : ''; ?>
455 + for="wpas-submit-<?php echo esc_attr( $connection_data['connection_id'] ); ?>"
587 456 >
588 457 <input
589 458 type="checkbox"
590 - name="wpas[submit][<?php echo esc_attr( $connection_data['id'] ); ?>]"
591 - id="wpas-submit-<?php echo esc_attr( $connection_data['id'] ); ?>"
459 + name="wpas[submit][<?php echo esc_attr( $connection_data['connection_id'] ); ?>]"
460 + id="wpas-submit-<?php echo esc_attr( $connection_data['connection_id'] ); ?>"
592 461 class="wpas-submit-<?php echo esc_attr( $connection_data['service_name'] ); ?>"
593 462 value="1"
463 + data-id="<?php echo esc_attr( $connection_data['connection_id'] ); ?>"
594 464 <?php
595 - checked( true, $connection_data['enabled'] && $connection_healthy );
596 - disabled( false, $connection_data['toggleable'] && $connection_healthy );
465 + checked( true, $connection_data['enabled'] );
597 466 ?>
598 467 />
599 - <?php if ( $connection_data['enabled'] && $connection_healthy && ! $connection_data['toggleable'] ) : // Need to submit a value to force a global connection to POST. ?>
600 - <input
601 - type="hidden"
602 - name="wpas[submit][<?php echo esc_attr( $connection_data['id'] ); ?>]"
603 - value="1"
604 - />
605 - <?php endif; ?>
606 -
607 468 <?php echo esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) ); ?>
608 469
609 470 </label>
610 471 </li>
@@ -615,52 +476,55 @@
615 476 if ( ! $title ) {
616 477 $title = '';
617 478 }
618 479
619 - $all_done = $all_done || $all_connections_done;
480 + $is_social_note = 'jetpack-social-note' === get_post_type( $post->ID );
620 481
482 + $is_post_published = 'publish' === get_post_status( $post->ID );
483 +
484 + $templates_enabled = $this->publicize->has_paid_features();
485 +
486 + $placeholders = $this->get_message_placeholders();
487 +
621 488 ?>
622 489
623 490 </ul>
624 491
625 - <label for="wpas-title"><?php esc_html_e( 'Custom Message:', 'jetpack-publicize-pkg' ); ?></label>
626 - <span id="wpas-title-counter" class="alignright hide-if-no-js">0</span>
627 - <textarea name="wpas_title" id="wpas-title"<?php disabled( $all_done ); ?>><?php echo esc_textarea( $title ); ?></textarea>
628 - <a href="#" class="hide-if-no-js button" id="publicize-form-hide"><?php esc_html_e( 'OK', 'jetpack-publicize-pkg' ); ?></a>
629 - <input type="hidden" name="wpas[0]" value="1" />
492 + <?php if ( ! $is_social_note ) : ?>
493 + <label for="wpas-title"><?php esc_html_e( 'Custom Message:', 'jetpack-publicize-pkg' ); ?></label>
494 + <?php if ( ! $templates_enabled ) : ?>
495 + <span id="wpas-title-counter" class="alignright hide-if-no-js">0</span>
496 + <?php endif; ?>
497 + <textarea name="wpas_title" id="wpas-title"><?php echo esc_textarea( $title ); ?></textarea>
498 + <?php if ( $templates_enabled && ! empty( $placeholders ) ) : ?>
499 + <details class="publicize-placeholders-help">
500 + <summary><?php esc_html_e( 'Available placeholders', 'jetpack-publicize-pkg' ); ?></summary>
501 + <p>
502 + <?php esc_html_e( 'Use placeholders to automatically insert post details.', 'jetpack-publicize-pkg' ); ?>
503 + </p>
504 + <ul>
505 + <?php foreach ( $placeholders as $placeholder ) : ?>
506 + <li>
507 + <code><?php echo esc_html( $placeholder['id'] ); ?></code>
508 + &mdash; <?php echo esc_html( $placeholder['label'] ); ?>
509 + </li>
510 + <?php endforeach; ?>
511 + </ul>
512 + </details>
513 + <?php endif; ?>
514 + <a href="#" class="hide-if-no-js button" id="publicize-form-hide"><?php esc_html_e( 'OK', 'jetpack-publicize-pkg' ); ?></a>
515 + <input type="hidden" name="wpas[0]" value="1" />
516 + <?php endif; ?>
517 + <?php if ( $is_post_published && Current_Plan::supports( 'republicize' ) ) : ?>
518 + <button type="button" class="hide-if-no-js button" id="publicize-share-now">
519 + <?php esc_html_e( 'Share now', 'jetpack-publicize-pkg' ); ?>
520 + </button>
521 + <span id="publicize-share-now-notice" class="hidden"></span>
522 + <?php endif; ?>
630 523 </div>
631 524
632 525 <div id="pub-connection-needs-media"></div>
633 -
634 - <?php if ( ! $all_done ) : ?>
635 - <?php if ( $broken_connections ) : ?>
636 - <div id="pub-connection-tests" class="error below-h2 publicize-token-refresh-message">
637 - <?php
638 - printf(
639 - wp_kses(
640 - /* translators: %s is the link to the connections page in Calypso */
641 - _n(
642 - 'One of your social connections is broken. Reconnect it on the <a href="%s" rel="noopener noreferrer" target="_blank">connection management</a> page.',
643 - 'Some of your social connections are broken. Reconnect them on the <a href="%s" rel="noopener noreferrer" target="_blank">connection management</a> page.',
644 - count( $broken_connections ),
645 - 'jetpack-publicize-pkg'
646 - ),
647 - array(
648 - 'a' => array(
649 - 'href' => array(),
650 - 'target' => array(),
651 - 'rel' => array(),
652 - ),
653 - )
654 - ),
655 - esc_url( $this->publicize->publicize_connections_url() )
656 - );
657 - ?>
658 - </div>
659 - <?php else : ?>
660 - <div id="pub-connection-tests"></div>
661 - <?php endif; ?>
662 - <?php endif; ?>
526 + <div id="pub-connection-tests"></div>
663 527 <?php
664 528
665 529 return ob_get_clean();
666 530 }
@@ -665,33 +529,15 @@
665 529 return ob_get_clean();
666 530 }
667 531
668 532 /**
669 - * Metabox that is shown when no services are connected.
533 + * Get the catalogue of placeholders supported in custom Publicize messages.
670 534 *
671 - * @param array $available_services Array of available services for connecting.
535 + * Sourced from WPCOM via `Message_Templates_Placeholders` so the metabox
536 + * hint can never drift from the resolver in `Template_Parser`.
537 + *
538 + * @return array<int, array{id: string, label: string}> Ordered list of placeholders.
672 539 */
673 - private function get_metabox_form_disconnected( $available_services ) {
674 - ob_start();
675 - ?>
676 - <div id="publicize-form" class="hide-if-js">
677 - <div id="add-publicize-check" style="display: none;"></div>
678 -
679 - <?php esc_html_e( 'Connect to', 'jetpack-publicize-pkg' ); ?>:
680 -
681 - <ul class="not-connected">
682 - <?php foreach ( $available_services as $service_name => $service ) : ?>
683 - <li>
684 - <?php /* translators: %s is the name of a Publicize service such as "LinkedIn" */ ?>
685 - <a class="pub-service" data-service="<?php echo esc_attr( $service_name ); ?>" title="<?php echo esc_attr( sprintf( __( 'Connect and share your posts on %s', 'jetpack-publicize-pkg' ), $this->publicize->get_service_label( $service_name ) ) ); ?>" rel="noopener noreferrer" target="_blank" href="<?php echo esc_url( $this->publicize->connect_url( $service_name ) ); ?>">
686 - <?php echo esc_html( $this->publicize->get_service_label( $service_name ) ); ?>
687 - </a>
688 - </li>
689 - <?php endforeach; ?>
690 - </ul>
691 - <a href="#" class="hide-if-no-js button" id="publicize-disconnected-form-hide"><?php esc_html_e( 'OK', 'jetpack-publicize-pkg' ); ?></a>
692 - </div>
693 - <?php
694 -
695 - return ob_get_clean();
540 + private function get_message_placeholders() {
541 + return Message_Templates_Placeholders::get_all();
696 542 }
697 543 }