PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 2.7.5
Jetpack – WP Security, Backup, Speed, & Growth v2.7.5
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 / modules / publicize / ui.php
ui.php
688 lines 24.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Only user facing pieces of Publicize are found here.
5 */
6 class Publicize_UI {
7
8 /**
9 * Contains an instance of class 'publicize' which loads Keyring, sets up services, etc.
10 */
11 var $publicize;
12
13 /**
14 * Hooks into WordPress to display the various pieces of UI and load our assets
15 */
16 function __construct() {
17 global $publicize;
18
19 $this->publicize = $publicize = new Publicize;
20
21 // assets (css, js)
22 add_action( 'load-settings_page_sharing', array( &$this, 'load_assets' ) );
23 add_action( 'admin_head-post.php', array( &$this, 'post_page_metabox_assets' ) );
24 add_action( 'admin_head-post-new.php', array( &$this, 'post_page_metabox_assets' ) );
25
26 // management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen)
27 add_action( 'pre_admin_screen_sharing', array( &$this, 'admin_page' ) );
28 add_action( 'post_submitbox_misc_actions', array( &$this, 'post_page_metabox' ) );
29 }
30
31 /**
32 * If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still
33 */
34 function sharing_menu() {
35 add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'publish_posts', 'sharing', array( &$this, 'management_page' ) );
36 }
37
38
39 /**
40 * Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists.
41 */
42 function management_page() { ?>
43 <div class="wrap">
44 <div class="icon32" id="icon-options-general"><br /></div>
45 <h2><?php _e( 'Sharing Settings', 'jetpack' ); ?></h2>
46
47 <?php do_action( 'pre_admin_screen_sharing' ) ?>
48
49 </div> <?php
50 }
51
52 /**
53 * styling for the sharing screen and popups
54 * JS for the options and switching
55 */
56 function load_assets() {
57 wp_enqueue_script(
58 'publicize',
59 plugins_url( 'assets/publicize.js', __FILE__ ),
60 array( 'jquery', 'thickbox' ),
61 '20121019'
62 );
63
64 wp_enqueue_style(
65 'publicize',
66 plugins_url( 'assets/publicize.css', __FILE__ ),
67 array(),
68 '20120925'
69 );
70
71 add_thickbox();
72 }
73
74 public static function connected_notice( $service_name ) { ?>
75 <div class='updated'>
76 <p><?php printf( __( 'You have successfully connected your blog with your %s account.', 'jetpack' ), Publicize::get_service_label( $service_name ) ); ?></p>
77 </div><?php
78 }
79
80 public static function denied_notice() { ?>
81 <div class='updated'>
82 <p><?php _e ( "You have chosen not to connect your blog. Please click 'accept' when prompted if you wish to connect your accounts.", 'jetpack' ); ?></p>
83 </div><?php
84 }
85
86 /**
87 * Lists the current user's publicized accounts for the blog
88 * looks exactly like Publicize v1 for now, UI and functionality updates will come after the move to keyring
89 */
90 function admin_page() {
91 $_blog_id = get_current_blog_id();
92 ?>
93
94 <form action="" id="publicize-form">
95 <h3 id="publicize"><?php _e( 'Publicize', 'jetpack' ) ?></h3>
96
97 <?php
98 if ( !empty( $_GET['action'] ) && 'deny' == $_GET['action'] )
99 $this->denied_notice();
100 ?>
101
102 <p>
103 <?php esc_html_e( 'Connect your blog to popular social networking sites and automatically share new posts with your friends.', 'jetpack' ) ?>
104 <?php esc_html_e( 'You can make a connection for just yourself or for all users on your blog. Shared connections are marked with the (Shared) text.', 'jetpack' ); ?>
105 </p>
106
107 <?php
108 if ( $this->in_jetpack )
109 $doc_link = "http://jetpack.me/support/publicize/";
110 else
111 $doc_link = "http://en.support.wordpress.com/publicize/";
112 ?>
113
114 <p>&rarr; <a href="<?php echo esc_url( $doc_link ); ?>" target="_blank"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p>
115
116 <div id="publicize-services-block">
117 <?php
118 $services = $this->publicize->get_services( 'all' );
119 $total_num_of_services = count ( $services );
120 $service_num = 0;?>
121
122 <div class='left'>
123
124 <?php
125 foreach ( $services as $name => $service ) :
126 $connect_url = $this->publicize->connect_url( $name );
127 if ( $service_num == ( round ( ( $total_num_of_services / 2 ), 0 ) ) )
128 echo "</div><div class='right'>";
129 $service_num++;
130 ?>
131 <div class="publicize-service-entry" <?php if ( $service_num > 0 ): ?>class="connected"<?php endif; ?> >
132 <div id="<?php echo esc_attr( $name ); ?>" class="publicize-service-left">
133 <a href="<?php echo esc_url( $connect_url ); ?>" id="service-link-<?php echo esc_attr( $name ); ?>" target="_top"><?php echo $this->publicize->get_service_label( $name ); ?></a>
134 </div>
135
136
137 <div class="publicize-service-right">
138 <?php if ( $this->publicize->is_enabled( $name ) && $connections = $this->publicize->get_connections( $name ) ) : ?>
139 <ul>
140 <?php
141 foreach( $connections as $c ) :
142 $id = $this->publicize->get_connection_id( $c );
143 $disconnect_url = $this->publicize->disconnect_url( $name, $id );
144
145 $cmeta = $this->publicize->get_connection_meta( $c );
146 $profile_link = $this->publicize->get_profile_link( $name, $c );
147 $connection_display = $this->publicize->get_display_name( $name, $c );
148
149 $options_nonce = wp_create_nonce( 'options_page_' . $name . '_' . $id ); ?>
150
151 <?php if ( $this->publicize->show_options_popup( $name, $c ) ): ?>
152 <script type="text/javascript">
153 jQuery(document).ready( function($) {
154 showOptionsPage.call(
155 this,
156 '<?php echo esc_js( $name ); ?>',
157 '<?php echo esc_js( $options_nonce ); ?>',
158 '<?php echo esc_js( $id ); ?>'
159 );
160 } );
161 </script>
162 <?php endif; ?>
163
164 <li class="publicize-connection" data-connection-id="<?php echo esc_attr( $id ); ?>">
165 <?php
166 if ( !empty( $profile_link ) ) : ?>
167
168 </style>
169 <?php esc_html_e( 'Connected as:', 'jetpack' ); ?>
170 <a class="publicize-profile-link" href="<?php echo esc_url( $profile_link ); ?>" target="_top">
171 <?php echo esc_html( $connection_display ); ?>
172 </a><?php
173 else :
174 echo esc_html( $connection_display );
175 endif;
176 ?>
177
178 <?php if ( 0 == $cmeta['connection_data']['user_id'] ) : ?>
179 <small>(<?php esc_html_e( 'Shared', 'jetpack' ); ?>)</small>
180
181 <?php if ( current_user_can( $this->publicize->GLOBAL_CAP ) ) : ?>
182 <a class="pub-disconnect-button" title="<?php esc_html_e( 'Disconnect', 'jetpack' ); ?>" href="<?php echo esc_url( $disconnect_url ); ?>" target="_top">×</a>
183 <?php endif; ?>
184
185 <?php else : ?>
186 <a class="pub-disconnect-button" title="<?php esc_html_e( 'Disconnect', 'jetpack' ); ?>" href="<?php echo esc_url( $disconnect_url ); ?>" target="_top">×</a>
187 <?php endif; ?>
188
189 <br/>
190 <div class="pub-connection-test test-in-progress" id="pub-connection-test-<?php echo esc_attr( $id ); ?>" >
191 </div>
192 </li>
193
194 <?php
195 endforeach;
196 ?>
197 </ul>
198 <?php endif; ?>
199
200
201
202 <?php
203 $connections = $this->publicize->get_connections( $name );
204 if ( empty ( $connections ) ) { ?>
205 <a id="<?php echo esc_attr( $name ); ?>" class="publicize-add-connection button" href="<?php echo esc_url( $connect_url ); ?>" target="_top"><?php echo esc_html( __( 'Connect', 'jetpack' ) ); ?></a>
206 <?php } else { ?>
207 <a id="<?php echo esc_attr( $name ); ?>" class="publicize-add-connection button add-new" href="<?php echo esc_url( $connect_url ); ?>" target="_top"><?php echo esc_html( __( 'Add New', 'jetpack' ) ); ?></a>
208 <?php } ?>
209
210
211 <?php
212 $help = apply_filters( 'publicize_help_text_' . $name, false );
213 if ( $help ) {
214 echo ' <a href="javascript:void(0);" title="' . esc_attr( $help ) . '" class="publicize-info">?</a>';
215 }
216 ?>
217 </div>
218 </div>
219 <?php endforeach; ?>
220 </div>
221 <script>
222 (function($){
223 $('.pub-disconnect-button').on('click', function(e){ if ( confirm( '<?php echo esc_js( __( 'Are you sure you want to stop Publicizing posts to this connection?', 'jetpack' ) ); ?>' ) ) {
224 return true;
225 } else {
226 e.preventDefault();
227 return false;
228 }
229 })
230 })(jQuery);
231 </script>
232 </div>
233
234 <?php wp_nonce_field( "wpas_posts_{$_blog_id}", "_wpas_posts_{$_blog_id}_nonce" ); ?>
235 <input type="hidden" id="wpas_ajax_blog_id" name="wpas_ajax_blog_id" value="<?php echo $_blog_id; ?>" />
236 </form><?php
237
238 }
239
240 public static function global_checkbox( $service_name, $id ) {
241 global $publicize;
242 if ( current_user_can( $publicize->GLOBAL_CAP ) ) : ?>
243 <p>
244 <input id="globalize_<?php echo $service_name; ?>" type="checkbox" name="global" value="<?php echo wp_create_nonce( 'publicize-globalize-' . $id ) ?>" />
245 <label for="globalize_<?php echo $service_name; ?>"><?php _e( 'Make this connection available to all users of this blog?', 'jetpack' ); ?></label>
246 </p>
247 <?php endif;
248 }
249
250 function broken_connection( $service_name, $id ) { ?>
251 <div id="thickbox-content">
252 <div class='error'>
253 <p><?php printf( __( 'There was a problem connecting to %s. Please disconnect and try again.', 'jetpack' ), Publicize::get_service_label( $service_name ) ); ?></p>
254 </div>
255 </div><?php
256 }
257
258 public static function options_page_other( $service_name ) {
259 // Nonce check
260 check_admin_referer( "options_page_{$service_name}_" . $_REQUEST['connection'] );
261 ?>
262 <div id="thickbox-content">
263 <?php
264 ob_start();
265 Publicize_UI::connected_notice( $service_name );
266 $update_notice = ob_get_clean();
267 if ( ! empty( $update_notice ) )
268 echo $update_notice;
269 ?>
270
271 <?php Publicize_UI::global_checkbox( $service_name, $_REQUEST['connection'] ); ?>
272
273 <p style="text-align: center;">
274 <input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>" class="button <?php echo $service_name; ?>-options save-options" name="save" data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>" rel="<?php echo wp_create_nonce( 'save_'.$service_name.'_token_' . $_REQUEST['connection'] ) ?>" />
275 </p> <br />
276 </div>
277 <?php
278 }
279
280 /**
281 * CSS for styling the publicize message box and counter that displays on the post page.
282 * There is also some Javascript for length counting and some basic display effects.
283 */
284 function post_page_metabox_assets() {
285 global $post;
286 $user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
287
288 $default_prefix = $this->publicize->default_prefix;
289 $default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) );
290
291 $default_message = $this->publicize->default_message;
292 $default_message = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_message ) );
293
294 $default_suffix = $this->publicize->default_suffix;
295 $default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) ); ?>
296
297 <script type="text/javascript">
298 jQuery( function($) {
299 var wpasTitleCounter = $( '#wpas-title-counter' ),
300 wpasTwitterCheckbox = $( '.wpas-submit-twitter' ).size(),
301 wpasTitle = $('#wpas-title').keyup( function() {
302 var length = wpasTitle.val().length;
303 wpasTitleCounter.text( length );
304 if ( wpasTwitterCheckbox && length > 140 ) {
305 wpasTitleCounter.addClass( 'wpas-twitter-length-limit' );
306 } else {
307 wpasTitleCounter.removeClass( 'wpas-twitter-length-limit' );
308 }
309 } ),
310 authClick = false;
311
312 $('#publicize-disconnected-form-show').click( function() {
313 $('#publicize-form').slideDown( 'fast' );
314 $(this).hide();
315 } );
316
317 $('#publicize-disconnected-form-hide').click( function() {
318 $('#publicize-form').slideUp( 'fast' );
319 $('#publicize-disconnected-form-show').show();
320 } );
321
322 $('#publicize-form-edit').click( function() {
323 $('#publicize-form').slideDown( 'fast', function() {
324 wpasTitle.focus();
325 if ( !wpasTitle.text() ) {
326 var url = $('#shortlink').size() ? $('#shortlink').val() : '';
327
328 var defaultMessage = $.trim( '<?php printf( $default_prefix, 'url' ); printf( $default_message, '$("#title").val()', 'url' ); printf( $default_suffix, 'url' ); ?>' );
329
330 wpasTitle.append( defaultMessage.replace( /<[^>]+>/g,'') );
331
332 var selBeg = defaultMessage.indexOf( $("#title").val() );
333 if ( selBeg < 0 ) {
334 selBeg = 0;
335 selEnd = 0;
336 } else {
337 selEnd = selBeg + $("#title").val().length;
338 }
339
340 var domObj = wpasTitle.get(0);
341 if ( domObj.setSelectionRange ) {
342 domObj.setSelectionRange( selBeg, selEnd );
343 } else if ( domObj.createTextRange ) {
344 var r = domObj.createTextRange();
345 r.moveStart( 'character', selBeg );
346 r.moveEnd( 'character', selEnd );
347 r.select();
348 }
349 }
350 wpasTitle.keyup();
351 } );
352 $('#publicize-defaults').hide();
353 $(this).hide();
354 return false;
355 } );
356
357 $('#publicize-form-hide').click( function() {
358 var newList = $.map( $('#publicize-form').slideUp( 'fast' ).find( ':checked' ), function( el ) {
359 return $.trim( $(el).parent( 'label' ).text() );
360 } );
361 $('#publicize-defaults').html( '<strong>' + newList.join( '</strong>, <strong>' ) + '</strong>' ).show();
362 $('#publicize-form-edit').show();
363 return false;
364 } );
365
366 $('.authorize-link').click( function() {
367 if ( authClick ) {
368 return false;
369 }
370 authClick = true;
371 $(this).after( '<img src="images/loading.gif" class="alignleft" style="margin: 0 .5em" />' );
372 $.ajaxSetup( { async: false } );
373 autosave();
374 return true;
375 } );
376
377 $( '.pub-service' ).click( function() {
378 var service = $(this).data( 'service' ),
379 fakebox = '<input id="wpas-submit-' + service + '" type="hidden" value="1" name="wpas[submit][' + service + ']" />';
380 $( '#add-publicize-check' ).append( fakebox );
381 } );
382
383 publicizeConnTestStart = function() {
384 $( '#pub-connection-tests' )
385 .removeClass( 'below-h2' )
386 .removeClass( 'error' )
387 .removeClass( 'publicize-token-refresh-message' )
388 .addClass( 'test-in-progress' )
389 .html( '' );
390 $.post( ajaxurl, { action: 'test_publicize_conns' }, publicizeConnTestComplete );
391 }
392
393 publicizeConnRefreshClick = function( event ) {
394 event.preventDefault();
395 var popupURL = event.currentTarget.href;
396 var popupTitle = event.currentTarget.title;
397 // open a popup window
398 // when it is closed, kick off the tests again
399 var popupWin = window.open( popupURL, popupTitle, '' );
400 var popupWinTimer= window.setInterval( function() {
401 if ( popupWin.closed !== false ) {
402 window.clearInterval( popupWinTimer );
403 publicizeConnTestStart();
404 }
405 }, 500 );
406 }
407
408 publicizeConnTestComplete = function( response ) {
409 var testsSelector = $( '#pub-connection-tests' );
410 testsSelector
411 .removeClass( 'test-in-progress' )
412 .removeClass( 'below-h2' )
413 .removeClass( 'error' )
414 .removeClass( 'publicize-token-refresh-message' )
415 .html( '' );
416
417 // If any of the tests failed, show some stuff
418 var somethingShownAlready = false;
419 $.each( response.data, function( index, testResult ) {
420 // find the li for this connection
421 if ( ! testResult.connectionTestPassed ) {
422 if ( ! somethingShownAlready ) {
423 testsSelector
424 .addClass( 'below-h2' )
425 .addClass( 'error' )
426 .addClass( 'publicize-token-refresh-message' )
427 .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>" );
428 somethingShownAlready = true;
429 }
430
431 if ( testResult.userCanRefresh ) {
432 testsSelector.append( '<p/>' );
433 $( '<a/>', {
434 'class' : 'pub-refresh-button button',
435 'title' : testResult.refreshText,
436 'href' : testResult.refreshURL,
437 'text' : testResult.refreshText,
438 'target' : '_refresh_' + testResult.serviceName
439 } )
440 .appendTo( testsSelector.children().last() )
441 .click( publicizeConnRefreshClick );
442 }
443 }
444 } );
445 }
446
447 $( document ).ready( function() {
448 // If we have the #pub-connection-tests div present, kick off the connection test
449 if ( $( '#pub-connection-tests' ).length ) {
450 publicizeConnTestStart();
451 }
452 } );
453
454 } );
455 </script>
456
457 <style type="text/css">
458 #publicize {
459 line-height: 1.5;
460 }
461 #publicize ul {
462 margin: 4px 0 4px 6px;
463 }
464 #publicize li {
465 margin: 0;
466 }
467 #publicize textarea {
468 margin: 4px 0 0;
469 width: 100%
470 }
471 #publicize ul.not-connected {
472 list-style: square;
473 padding-left: 1em;
474 }
475 .post-new-php .authorize-link, .post-php .authorize-link {
476 line-height: 1.5em;
477 }
478 .post-new-php .authorize-message, .post-php .authorize-message {
479 margin-bottom: 0;
480 }
481 #poststuff #publicize .updated p {
482 margin: .5em 0;
483 }
484 .wpas-twitter-length-limit {
485 color: red;
486 }
487 </style><?php
488 }
489
490 /**
491 * Controls the metabox that is displayed on the post page
492 * Allows the user to customize the message that will be sent out to the social network, as well as pick which
493 * networks to publish to. Also displays the character counter and some other information.
494 */
495 function post_page_metabox() {
496 global $post;
497
498 if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) )
499 return;
500
501 $user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
502 $services = $this->publicize->get_services( 'connected' );
503 $available_services = $this->publicize->get_services( 'all' );
504
505 if ( ! is_array( $available_services ) )
506 $available_services = array();
507
508 if ( ! is_array( $services ) )
509 $services = array();
510
511 $active = array(); ?>
512
513 <div id="publicize" class="misc-pub-section misc-pub-section-last">
514 <?php
515 _e( 'Publicize:', 'jetpack' );
516
517 if ( 0 < count( $services ) ) :
518 ob_start();
519 ?>
520
521 <div id="publicize-form" class="hide-if-js">
522 <ul>
523
524 <?php
525 // We can set an _all flag to indicate that this post is completely done as
526 // far as Publicize is concerned. Jetpack uses this approach. All published posts in Jetpack
527 // have Publicize disabled.
528 $all_done = get_post_meta( $post->ID, $this->publicize->POST_DONE . 'all', true ) || ( $this->in_jetpack && 'publish' == $post->post_status );
529
530 // We don't allow Publicizing to the same external id twice, to prevent spam
531 $service_id_done = (array) get_post_meta( $post->ID, $this->publicize->POST_SERVICE_DONE, true );
532
533 foreach ( $services as $name => $connections ) {
534 foreach ( $connections as $connection ) {
535 $connection_data = '';
536 if ( method_exists( $connection, 'get_meta' ) )
537 $connection_data = $connection->get_meta( 'connection_data' );
538 elseif ( ! empty( $connection['connection_data'] ) )
539 $connection_data = $connection['connection_data'];
540
541 if ( !$continue = apply_filters( 'wpas_submit_post?', true, $post->ID, $name, $connection_data ) )
542 continue;
543
544 if ( !empty( $connection->unique_id ) )
545 $unique_id = $connection->unique_id;
546 else if ( !empty( $connection['connection_data']['token_id'] ) )
547 $unique_id = $connection['connection_data']['token_id'];
548
549 // Should we be skipping this one?
550 $skip = (
551 get_post_meta( $post->ID, $this->publicize->POST_SKIP . $unique_id, true )
552 ||
553 (
554 is_array( $connection )
555 &&
556 (
557 ( isset( $connection['meta']['external_id'] ) && ! empty( $service_id_done[ $name ][ $connection['meta']['external_id'] ] ) )
558 ||
559 // Jetpack's connection data looks a little different.
560 ( isset( $connection['external_id'] ) && ! empty( $service_id_done[ $name ][ $connection['external_id'] ] ) )
561 )
562 )
563 );
564
565 // Was this connections (OR, old-format service) already Publicized to?
566 $done = ( 1 == get_post_meta( $post->ID, $this->publicize->POST_DONE . $unique_id, true ) || 1 == get_post_meta( $post->ID, $this->publicize->POST_DONE . $name, true ) ); // New and old style flags
567
568 // If this one has already been publicized to, don't let it happen again
569 $disabled = '';
570 if ( $done )
571 $disabled = ' disabled="disabled"';
572
573 // If this is a global connection and this user doesn't have enough permissions to modify
574 // those connections, don't let them change it
575 $cmeta = $this->publicize->get_connection_meta( $connection );
576 $hidden_checkbox = false;
577 if ( !$done && ( 0 == $cmeta['connection_data']['user_id'] && !current_user_can( $this->publicize->GLOBAL_CAP ) ) ) {
578 $disabled = ' disabled="disabled"';
579 $hidden_checkbox = true;
580 }
581
582 // Determine the state of the checkbox (on/off) and allow filtering
583 $checked = $skip != 1 || $done;
584 $checked = apply_filters( 'publicize_checkbox_default', $checked, $post->ID, $name, $connection );
585
586 // Force the checkbox to be checked if the post was DONE, regardless of what the filter does
587 if ( $done )
588 $checked = true;
589
590 // This post has been handled, so disable everything
591 if ( $all_done )
592 $disabled = ' disabled="disabled"';
593
594 $label = sprintf(
595 _x( '%1$s: %2$s', 'Service: Account connected as', 'jetpack' ),
596 esc_html( $this->publicize->get_service_label( $name ) ),
597 esc_html( $this->publicize->get_display_name( $name, $connection ) )
598 );
599 if ( !$skip || $done ) {
600 $active[] = $label;
601 }
602 ?>
603 <li>
604 <label for="wpas-submit-<?php echo esc_attr( $unique_id ); ?>">
605 <input type="checkbox" name="wpas[submit][<?php echo $unique_id; ?>]" id="wpas-submit-<?php echo $unique_id; ?>" class="wpas-submit-<?php echo $name; ?>" value="1" <?php
606 checked( true, $checked );
607 echo $disabled;
608 ?> />
609 <?php
610 if ( $hidden_checkbox ) {
611 // Need to submit a value to force a global connection to post
612 echo '<input type="hidden" name="wpas[submit][' . $unique_id . ']" value="1" />';
613 }
614 echo esc_html( $label );
615 ?>
616 </label>
617 </li>
618 <?php
619 }
620 }
621
622 if ( $title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true ) )
623 $title = esc_html( $title );
624 else
625 $title = '';
626 ?>
627
628 </ul>
629
630 <label for="wpas-title"><?php _e( 'Custom Message:', 'jetpack' ); ?></label>
631 <span id="wpas-title-counter" class="alignright hide-if-no-js">0</span>
632
633 <textarea name="wpas_title" id="wpas-title"<?php disabled( $all_done ); ?>><?php echo $title; ?></textarea>
634
635 <a href="#" class="hide-if-no-js" id="publicize-form-hide"><?php _e( 'Hide', 'jetpack' ); ?></a>
636 <input type="hidden" name="wpas[0]" value="1" />
637
638 </div>
639 <div id="pub-connection-tests"></div>
640 <?php // #publicize-form
641
642 $publicize_form = ob_get_clean();
643 else :
644 echo "&nbsp;" . __( 'Not Connected', 'jetpack' );
645 ob_start();
646 ?>
647
648 <div id="publicize-form" class="hide-if-js">
649 <div id="add-publicize-check" style="display: none;"></div>
650
651 <strong><?php _e( 'Connect to', 'jetpack' ); ?>:</strong>
652
653 <ul class="not-connected">
654 <?php foreach ( $available_services as $service_name => $service ) : ?>
655 <li>
656 <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 ) ) ); ?>" target="_blank" href="<?php echo $this->publicize->connect_url( $service_name ); ?>">
657 <?php echo esc_html( $this->publicize->get_service_label( $service_name ) ); ?>
658 </a>
659 </li>
660 <?php endforeach; ?>
661 </ul>
662
663 <?php if ( 0 < count( $services ) ) : ?>
664 <a href="#" class="hide-if-no-js" id="publicize-form-hide"><?php _e( 'Hide', 'jetpack' ); ?></a>
665 <?php else : ?>
666 <a href="#" class="hide-if-no-js" id="publicize-disconnected-form-hide"><?php _e( 'Hide', 'jetpack' ); ?></a>
667 <?php endif; ?>
668 </div> <?php // #publicize-form
669
670 $publicize_form = ob_get_clean();
671 endif;
672 ?>
673
674 <span id="publicize-defaults"><strong><?php echo join( '</strong>, <strong>', array_map( 'esc_html', $active ) ); ?></strong></span>
675
676 <?php if ( 0 < count( $services ) ) : ?>
677 <a href="#" id="publicize-form-edit"><?php _e( 'Edit', 'jetpack' ); ?></a>&nbsp;<a href="<?php echo admin_url( 'options-general.php?page=sharing' ); ?>" target="_blank"><?php _e( 'Settings', 'jetpack' ); ?></a><br />
678 <?php else : ?>
679 <a href="#" id="publicize-disconnected-form-show"><?php _e( 'Show', 'jetpack' ); ?></a><br />
680 <?php endif; ?>
681
682 <?php echo apply_filters( 'publicize_form', $publicize_form ); ?>
683
684 </div> <?php // #publicize
685 }
686
687 }
688