No Description

ui.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <?php
  2. /**
  3. * Only user facing pieces of Publicize are found here.
  4. */
  5. class Publicize_UI {
  6. /**
  7. * Contains an instance of class 'publicize' which loads Keyring, sets up services, etc.
  8. */
  9. public $publicize;
  10. /**
  11. * @var string URL to Sharing settings page in wordpress.com
  12. */
  13. protected $publicize_settings_url = '';
  14. /**
  15. * Hooks into WordPress to display the various pieces of UI and load our assets
  16. */
  17. function __construct() {
  18. global $publicize;
  19. $this->publicize = $publicize = new Publicize;
  20. add_action( 'init', array( $this, 'init' ) );
  21. }
  22. function init() {
  23. $this->publicize_settings_url = publicize_calypso_url();
  24. // Show only to users with the capability required to manage their Publicize connections.
  25. if ( ! $this->publicize->current_user_can_access_publicize_data() ) {
  26. return;
  27. }
  28. // assets (css, js)
  29. if ( $this->in_jetpack ) {
  30. add_action( 'load-settings_page_sharing', array( $this, 'load_assets' ) );
  31. }
  32. add_action( 'admin_head-post.php', array( $this, 'post_page_metabox_assets' ) );
  33. add_action( 'admin_head-post-new.php', array( $this, 'post_page_metabox_assets' ) );
  34. // management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen)
  35. add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page' ) );
  36. add_action( 'post_submitbox_misc_actions', array( $this, 'post_page_metabox' ) );
  37. }
  38. /**
  39. * If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still
  40. */
  41. function sharing_menu() {
  42. add_submenu_page(
  43. 'options-general.php',
  44. esc_html__( 'Sharing Settings', 'jetpack' ),
  45. esc_html__( 'Sharing', 'jetpack' ),
  46. 'publish_posts',
  47. 'sharing',
  48. array( $this, 'wrapper_admin_page' )
  49. );
  50. }
  51. function wrapper_admin_page() {
  52. Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ) );
  53. }
  54. /**
  55. * Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists.
  56. */
  57. function management_page() { ?>
  58. <div class="wrap">
  59. <div class="icon32" id="icon-options-general"><br /></div>
  60. <h1><?php esc_html_e( 'Sharing Settings', 'jetpack' ); ?></h1>
  61. <?php
  62. /** This action is documented in modules/sharedaddy/sharing.php */
  63. do_action( 'pre_admin_screen_sharing' );
  64. ?>
  65. </div> <?php
  66. }
  67. /**
  68. * styling for the sharing screen and popups
  69. * JS for the options and switching
  70. */
  71. function load_assets() {
  72. Jetpack_Admin_Page::load_wrapper_styles();
  73. }
  74. /**
  75. * Lists the current user's publicized accounts for the blog
  76. * looks exactly like Publicize v1 for now, UI and functionality updates will come after the move to keyring
  77. */
  78. function admin_page() {
  79. ?>
  80. <h2 id="publicize"><?php esc_html_e( 'Publicize', 'jetpack' ) ?></h2>
  81. <p><?php esc_html_e( 'Connect social media services to automatically share new posts.', 'jetpack' ) ?></p>
  82. <h4><?php
  83. printf(
  84. wp_kses(
  85. __( "We've made some updates to Publicize. Please visit the <a href='%s' class='jptracks' data-jptracks-name='legacy_publicize_settings'>WordPress.com sharing page</a> to manage your publicize connections or use the button below.", 'jetpack' ),
  86. array( 'a' => array( 'href' => array(), 'class' => array(), 'data-jptracks-name' => array() ) )
  87. ),
  88. esc_url( publicize_calypso_url() )
  89. );
  90. ?>
  91. </h4>
  92. <a href="<?php echo esc_url( publicize_calypso_url() ); ?>" class="button button-primary jptracks" data-jptracks-name='legacy_publicize_settings'><?php esc_html_e( 'Publicize Settings', 'jetpack' ); ?></a>
  93. <?php
  94. }
  95. /**
  96. * CSS for styling the publicize message box and counter that displays on the post page.
  97. * There is also some JavaScript for length counting and some basic display effects.
  98. */
  99. function post_page_metabox_assets() {
  100. global $post;
  101. $user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
  102. $default_prefix = $this->publicize->default_prefix;
  103. $default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) );
  104. $default_message = $this->publicize->default_message;
  105. $default_message = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_message ) );
  106. $default_suffix = $this->publicize->default_suffix;
  107. $default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) );
  108. $max_length = defined( 'JETPACK_PUBLICIZE_TWITTER_LENGTH' ) ? JETPACK_PUBLICIZE_TWITTER_LENGTH : 280;
  109. $max_length = $max_length - 24; // t.co link, space
  110. ?>
  111. <script type="text/javascript">
  112. jQuery( function($) {
  113. var wpasTitleCounter = $( '#wpas-title-counter' ),
  114. wpasTwitterCheckbox = $( '.wpas-submit-twitter' ).length,
  115. postTitle = $( '#title' ),
  116. wpasTitle = $( '#wpas-title' ).keyup( function() {
  117. var postTitleVal,
  118. length = wpasTitle.val().length;
  119. if ( ! length ) {
  120. length = wpasTitle.attr( 'placeholder' ).length;
  121. }
  122. wpasTitleCounter.text( length ).trigger( 'change' );
  123. } ),
  124. authClick = false;
  125. wpasTitleCounter.on( 'change', function( e ) {
  126. if ( wpasTwitterCheckbox && parseInt( $( e.currentTarget ).text(), 10 ) > <?php echo (int) $max_length; ?> ) {
  127. wpasTitleCounter.addClass( 'wpas-twitter-length-limit' );
  128. } else {
  129. wpasTitleCounter.removeClass( 'wpas-twitter-length-limit' );
  130. }
  131. } );
  132. // Keep the postTitle and the placeholder in sync
  133. postTitle.on( 'keyup', function( e ) {
  134. var url = $( '#sample-permalink' ).text();
  135. var defaultMessage = $.trim( '<?php printf( $default_prefix, 'url' ); printf( $default_message, 'e.currentTarget.value', 'url' ); printf( $default_suffix, 'url' ); ?>' )
  136. .replace( /<[^>]+>/g,'');
  137. wpasTitle.attr( 'placeholder', defaultMessage );
  138. wpasTitle.trigger( 'keyup' );
  139. } );
  140. // set the initial placeholder
  141. postTitle.trigger( 'keyup' );
  142. // If a custom message has been provided, open the UI so the author remembers
  143. if ( wpasTitle.val() && ! wpasTitle.prop( 'disabled' ) && wpasTitle.attr( 'placeholder' ) !== wpasTitle.val() ) {
  144. $( '#publicize-form' ).show();
  145. $( '#publicize-defaults' ).hide();
  146. $( '#publicize-form-edit' ).hide();
  147. }
  148. $('#publicize-disconnected-form-show').click( function() {
  149. $('#publicize-form').slideDown( 'fast' );
  150. $(this).hide();
  151. } );
  152. $('#publicize-disconnected-form-hide').click( function() {
  153. $('#publicize-form').slideUp( 'fast' );
  154. $('#publicize-disconnected-form-show').show();
  155. } );
  156. $('#publicize-form-edit').click( function() {
  157. $('#publicize-form').slideDown( 'fast', function() {
  158. var selBeg = 0, selEnd = 0;
  159. wpasTitle.focus();
  160. if ( ! wpasTitle.text() ) {
  161. wpasTitle.text( wpasTitle.attr( 'placeholder' ) );
  162. selBeg = wpasTitle.text().indexOf( postTitle.val() );
  163. if ( selBeg < 0 ) {
  164. selBeg = 0;
  165. } else {
  166. selEnd = selBeg + postTitle.val().length;
  167. }
  168. var domObj = wpasTitle.get(0);
  169. if ( domObj.setSelectionRange ) {
  170. domObj.setSelectionRange( selBeg, selEnd );
  171. } else if ( domObj.createTextRange ) {
  172. var r = domObj.createTextRange();
  173. r.moveStart( 'character', selBeg );
  174. r.moveEnd( 'character', selEnd );
  175. r.select();
  176. }
  177. }
  178. } );
  179. $('#publicize-defaults').hide();
  180. $(this).hide();
  181. return false;
  182. } );
  183. $('#publicize-form-hide').click( function() {
  184. var newList = $.map( $('#publicize-form').slideUp( 'fast' ).find( ':checked' ), function( el ) {
  185. return $.trim( $(el).parent( 'label' ).text() );
  186. } );
  187. $('#publicize-defaults').html( '<strong>' + newList.join( '</strong>, <strong>' ) + '</strong>' ).show();
  188. $('#publicize-form-edit').show();
  189. return false;
  190. } );
  191. $('.authorize-link').click( function() {
  192. if ( authClick ) {
  193. return false;
  194. }
  195. authClick = true;
  196. $(this).after( '<img src="images/loading.gif" class="alignleft" style="margin: 0 .5em" />' );
  197. $.ajaxSetup( { async: false } );
  198. if ( window.wp && window.wp.autosave ) {
  199. window.wp.autosave.server.triggerSave();
  200. } else {
  201. autosave();
  202. }
  203. return true;
  204. } );
  205. $( '.pub-service' ).click( function() {
  206. var service = $(this).data( 'service' ),
  207. fakebox = '<input id="wpas-submit-' + service + '" type="hidden" value="1" name="wpas[submit][' + service + ']" />';
  208. $( '#add-publicize-check' ).append( fakebox );
  209. } );
  210. publicizeConnTestStart = function() {
  211. $( '#pub-connection-tests' )
  212. .removeClass( 'below-h2' )
  213. .removeClass( 'error' )
  214. .removeClass( 'publicize-token-refresh-message' )
  215. .addClass( 'test-in-progress' )
  216. .html( '' );
  217. $.post( ajaxurl, { action: 'test_publicize_conns' }, publicizeConnTestComplete );
  218. }
  219. publicizeConnRefreshClick = function( event ) {
  220. event.preventDefault();
  221. var popupURL = event.currentTarget.href;
  222. var popupTitle = event.currentTarget.title;
  223. // open a popup window
  224. // when it is closed, kick off the tests again
  225. var popupWin = window.open( popupURL, popupTitle, '' );
  226. var popupWinTimer= window.setInterval( function() {
  227. if ( popupWin.closed !== false ) {
  228. window.clearInterval( popupWinTimer );
  229. publicizeConnTestStart();
  230. }
  231. }, 500 );
  232. }
  233. publicizeConnTestComplete = function( response ) {
  234. var testsSelector = $( '#pub-connection-tests' );
  235. testsSelector
  236. .removeClass( 'test-in-progress' )
  237. .removeClass( 'below-h2' )
  238. .removeClass( 'error' )
  239. .removeClass( 'publicize-token-refresh-message' )
  240. .html( '' );
  241. // If any of the tests failed, show some stuff
  242. var somethingShownAlready = false;
  243. var facebookNotice = false;
  244. $.each( response.data, function( index, testResult ) {
  245. // find the li for this connection
  246. if ( ! testResult.connectionTestPassed && testResult.userCanRefresh ) {
  247. if ( ! somethingShownAlready ) {
  248. testsSelector
  249. .addClass( 'below-h2' )
  250. .addClass( 'error' )
  251. .addClass( 'publicize-token-refresh-message' )
  252. .append( "<p><?php echo esc_html( __( 'Before you hit Publish, please refresh the following connection(s) to make sure we can Publicize your post:', 'jetpack' ) ); ?></p>" );
  253. somethingShownAlready = true;
  254. }
  255. if ( testResult.userCanRefresh ) {
  256. testsSelector.append( '<p/>' );
  257. $( '<a/>', {
  258. 'class' : 'pub-refresh-button button',
  259. 'title' : testResult.refreshText,
  260. 'href' : testResult.refreshURL,
  261. 'text' : testResult.refreshText,
  262. 'target' : '_refresh_' + testResult.serviceName
  263. } )
  264. .appendTo( testsSelector.children().last() )
  265. .click( publicizeConnRefreshClick );
  266. }
  267. }
  268. if( ! testResult.connectionTestPassed && ! testResult.userCanRefresh ) {
  269. $( '#wpas-submit-' + testResult.unique_id ).prop( "checked", false ).prop( "disabled", true );
  270. if ( ! facebookNotice ) {
  271. var message = '<p>'
  272. + testResult.connectionTestMessage
  273. + '</p><p>'
  274. + ' <a class="button" href="<?php echo esc_url( $this->publicize_settings_url ); ?>" rel="noopener noreferrer" target="_blank">'
  275. + '<?php echo esc_html( __( 'Update Your Sharing Settings' ,'jetpack' ) ); ?>'
  276. + '</a>'
  277. + '<p>';
  278. testsSelector
  279. .addClass( 'below-h2' )
  280. .addClass( 'error' )
  281. .addClass( 'publicize-token-refresh-message' )
  282. .append( message );
  283. facebookNotice = true;
  284. }
  285. }
  286. } );
  287. }
  288. $( document ).ready( function() {
  289. // If we have the #pub-connection-tests div present, kick off the connection test
  290. if ( $( '#pub-connection-tests' ).length ) {
  291. publicizeConnTestStart();
  292. }
  293. } );
  294. } );
  295. </script>
  296. <style type="text/css">
  297. #publicize {
  298. line-height: 1.5;
  299. }
  300. #publicize ul {
  301. margin: 4px 0 4px 6px;
  302. }
  303. #publicize li {
  304. margin: 0;
  305. }
  306. #publicize textarea {
  307. margin: 4px 0 0;
  308. width: 100%
  309. }
  310. #publicize ul.not-connected {
  311. list-style: square;
  312. padding-left: 1em;
  313. }
  314. .publicize__notice-warning {
  315. display: block;
  316. padding: 7px 10px;
  317. margin: 5px 0;
  318. border-left-width: 4px;
  319. border-left-style: solid;
  320. font-size: 12px;
  321. box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  322. }
  323. .publicize-external-link {
  324. display: block;
  325. text-decoration: none;
  326. margin-top: 8px;
  327. }
  328. .publicize-external-link__text {
  329. text-decoration: underline;
  330. }
  331. #publicize-title:before {
  332. content: "\f237";
  333. font: normal 20px/1 dashicons;
  334. speak: none;
  335. margin-left: -1px;
  336. padding-right: 3px;
  337. vertical-align: top;
  338. -webkit-font-smoothing: antialiased;
  339. color: #8c8f94;
  340. }
  341. .post-new-php .authorize-link, .post-php .authorize-link {
  342. line-height: 1.5em;
  343. }
  344. .post-new-php .authorize-message, .post-php .authorize-message {
  345. margin-bottom: 0;
  346. }
  347. #poststuff #publicize .updated p {
  348. margin: .5em 0;
  349. }
  350. .wpas-twitter-length-limit {
  351. color: red;
  352. }
  353. .publicize__notice-warning .dashicons {
  354. font-size: 16px;
  355. text-decoration: none;
  356. }
  357. </style><?php
  358. }
  359. /**
  360. * @param string $service_label Service's human-readable Label ("Facebook", "Twitter", ...)
  361. * @param string $display_name Connection's human-readable Username ("@jetpack", ...)
  362. * @return string
  363. */
  364. private function connection_label( $service_label, $display_name ) {
  365. return sprintf(
  366. /* translators: %1$s: Service Name (Facebook, Twitter, ...), %2$s: Username on Service (@jetpack, ...) */
  367. __( '%1$s: %2$s', 'jetpack' ),
  368. $service_label,
  369. $display_name
  370. );
  371. }
  372. /**
  373. * Extracts the connections that require reauthentication, for example, LinkedIn, when it switched v1 to v2 of its API.
  374. *
  375. * @return array Connections that must be reauthenticated
  376. */
  377. function get_must_reauth_connections() {
  378. $must_reauth = array();
  379. $connections = $this->publicize->get_connections( 'linkedin' );
  380. if ( is_array( $connections ) ) {
  381. foreach ( $connections as $index => $connection ) {
  382. if ( $this->publicize->is_invalid_linkedin_connection( $connection ) ) {
  383. $must_reauth[ $index ] = 'LinkedIn';
  384. }
  385. }
  386. }
  387. return $must_reauth;
  388. }
  389. /**
  390. * Controls the metabox that is displayed on the post page
  391. * Allows the user to customize the message that will be sent out to the social network, as well as pick which
  392. * networks to publish to. Also displays the character counter and some other information.
  393. */
  394. function post_page_metabox() {
  395. global $post;
  396. if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) )
  397. return;
  398. $user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
  399. $connections_data = $this->publicize->get_filtered_connection_data();
  400. $available_services = $this->publicize->get_services( 'all' );
  401. if ( ! is_array( $available_services ) )
  402. $available_services = array();
  403. if ( ! is_array( $connections_data ) )
  404. $connections_data = array();
  405. ?>
  406. <div id="publicize" class="misc-pub-section misc-pub-section-last">
  407. <span id="publicize-title">
  408. <?php
  409. esc_html_e( 'Publicize:', 'jetpack' );
  410. if ( 0 < count( $connections_data ) ) :
  411. $publicize_form = $this->get_metabox_form_connected( $connections_data );
  412. $must_reauth = $this->get_must_reauth_connections();
  413. if ( ! empty( $must_reauth ) ) {
  414. foreach ( $must_reauth as $connection_name ) {
  415. ?>
  416. <span class="notice-warning publicize__notice-warning">
  417. <?php
  418. /* translators: %s is the name of a Pubilicize service like "LinkedIn" */
  419. printf( esc_html__(
  420. 'Your %s connection needs to be reauthenticated to continue working – head to Sharing to take care of it.',
  421. 'jetpack'
  422. ), $connection_name );
  423. ?>
  424. <a
  425. class="publicize-external-link"
  426. href="<?php echo publicize_calypso_url() ?>"
  427. target="_blank"
  428. >
  429. <span class="publicize-external-link__text"><?php esc_html_e( 'Go to Sharing settings', 'jetpack' ); ?></span>
  430. <span class="dashicons dashicons-external"></span>
  431. </a>
  432. </span>
  433. <?php
  434. }
  435. ?>
  436. <?php
  437. }
  438. $labels = array();
  439. foreach ( $connections_data as $connection_data ) {
  440. if ( ! $connection_data['enabled'] ) {
  441. continue;
  442. }
  443. $labels[] = sprintf(
  444. '<strong>%s</strong>',
  445. esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) )
  446. );
  447. }
  448. ?>
  449. <span id="publicize-defaults"><?php echo join( ', ', $labels ); ?></span>
  450. <a href="#" id="publicize-form-edit"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a>&nbsp;<a href="<?php echo esc_url( $this->publicize_settings_url ); ?>" rel="noopener noreferrer" target="_blank"><?php _e( 'Settings', 'jetpack' ); ?></a><br />
  451. <?php
  452. else :
  453. $publicize_form = $this->get_metabox_form_disconnected( $available_services );
  454. ?>
  455. <strong><?php echo __( 'Not Connected', 'jetpack' ); ?></strong>
  456. <a href="#" id="publicize-disconnected-form-show"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a><br />
  457. <?php
  458. endif;
  459. ?>
  460. </span>
  461. <?php
  462. /**
  463. * Filter the Publicize details form.
  464. *
  465. * @module publicize
  466. *
  467. * @since 2.0.0
  468. *
  469. * @param string $publicize_form Publicize Details form appearing above Publish button in the editor.
  470. */
  471. echo apply_filters( 'publicize_form', $publicize_form );
  472. ?>
  473. </div> <?php // #publicize
  474. }
  475. /**
  476. * Generates HTML content for connections form.
  477. *
  478. * @since 6.7
  479. *
  480. * @global WP_Post $post The current post instance being published.
  481. *
  482. * @param array $connections_data
  483. *
  484. * @return array {
  485. * Array of content for generating connection form.
  486. *
  487. * @type string HTML content of form
  488. * @type array {
  489. * Array of connection labels for active connections only.
  490. *
  491. * @type string Connection label string.
  492. * }
  493. * }
  494. */
  495. private function get_metabox_form_connected( $connections_data ) {
  496. global $post;
  497. $all_done = $this->publicize->post_is_done_sharing();
  498. $all_connections_done = true;
  499. ob_start();
  500. ?>
  501. <div id="publicize-form" class="hide-if-js">
  502. <ul>
  503. <?php
  504. foreach ( $connections_data as $connection_data ) {
  505. $all_connections_done = $all_connections_done && $connection_data['done'];
  506. ?>
  507. <li>
  508. <label for="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>">
  509. <input
  510. type="checkbox"
  511. name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]"
  512. id="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>"
  513. class="wpas-submit-<?php echo esc_attr( $connection_data['service_name'] ); ?>"
  514. value="1"
  515. <?php
  516. checked( true, $connection_data['enabled'] );
  517. disabled( false, $connection_data['toggleable'] );
  518. ?>
  519. />
  520. <?php if ( $connection_data['enabled'] && ! $connection_data['toggleable'] ) : // Need to submit a value to force a global connection to POST ?>
  521. <input
  522. type="hidden"
  523. name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]"
  524. value="1"
  525. />
  526. <?php endif; ?>
  527. <?php echo esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) ); ?>
  528. </label>
  529. </li>
  530. <?php
  531. }
  532. $title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true );
  533. if ( ! $title ) {
  534. $title = '';
  535. }
  536. $all_done = $all_done || $all_connections_done;
  537. ?>
  538. </ul>
  539. <label for="wpas-title"><?php _e( 'Custom Message:', 'jetpack' ); ?></label>
  540. <span id="wpas-title-counter" class="alignright hide-if-no-js">0</span>
  541. <textarea name="wpas_title" id="wpas-title"<?php disabled( $all_done ); ?>><?php echo esc_textarea( $title ); ?></textarea>
  542. <a href="#" class="hide-if-no-js button" id="publicize-form-hide"><?php esc_html_e( 'OK', 'jetpack' ); ?></a>
  543. <input type="hidden" name="wpas[0]" value="1" />
  544. </div>
  545. <?php if ( ! $all_done ) : ?>
  546. <div id="pub-connection-tests"></div>
  547. <?php endif; ?>
  548. <?php // #publicize-form
  549. return ob_get_clean();
  550. }
  551. private function get_metabox_form_disconnected( $available_services ) {
  552. ob_start();
  553. ?><div id="publicize-form" class="hide-if-js">
  554. <div id="add-publicize-check" style="display: none;"></div>
  555. <?php _e( 'Connect to', 'jetpack' ); ?>:
  556. <ul class="not-connected">
  557. <?php foreach ( $available_services as $service_name => $service ) : ?>
  558. <li>
  559. <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' ), $this->publicize->get_service_label( $service_name ) ) ); ?>" rel="noopener noreferrer" target="_blank" href="<?php echo esc_url( $this->publicize->connect_url( $service_name ) ); ?>">
  560. <?php echo esc_html( $this->publicize->get_service_label( $service_name ) ); ?>
  561. </a>
  562. </li>
  563. <?php endforeach; ?>
  564. </ul>
  565. <a href="#" class="hide-if-no-js button" id="publicize-disconnected-form-hide"><?php esc_html_e( 'OK', 'jetpack' ); ?></a>
  566. </div><?php // #publicize-form
  567. return ob_get_clean();
  568. }
  569. }