summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/publicize/ui.php')
-rw-r--r--plugins/jetpack/modules/publicize/ui.php236
1 files changed, 147 insertions, 89 deletions
diff --git a/plugins/jetpack/modules/publicize/ui.php b/plugins/jetpack/modules/publicize/ui.php
index 7d946766..6847c6d4 100644
--- a/plugins/jetpack/modules/publicize/ui.php
+++ b/plugins/jetpack/modules/publicize/ui.php
@@ -8,7 +8,7 @@ class Publicize_UI {
/**
* Contains an instance of class 'publicize' which loads Keyring, sets up services, etc.
*/
- var $publicize;
+ public $publicize;
/**
* Hooks into WordPress to display the various pieces of UI and load our assets
@@ -18,6 +18,15 @@ class Publicize_UI {
$this->publicize = $publicize = new Publicize;
+ add_action( 'init', array( $this, 'init' ) );
+ }
+
+ function init() {
+ // Show only to users with the capability required to create/delete global connections.
+ if ( ! current_user_can( $this->publicize->GLOBAL_CAP ) ) {
+ return;
+ }
+
// assets (css, js)
add_action( 'load-settings_page_sharing', array( &$this, 'load_assets' ) );
add_action( 'admin_head-post.php', array( &$this, 'post_page_metabox_assets' ) );
@@ -42,9 +51,12 @@ class Publicize_UI {
function management_page() { ?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
- <h2><?php _e( 'Sharing Settings', 'jetpack' ); ?></h2>
+ <h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
- <?php do_action( 'pre_admin_screen_sharing' ) ?>
+ <?php
+ /** This action is documented in modules/sharedaddy/sharing.php */
+ do_action( 'pre_admin_screen_sharing' );
+ ?>
</div> <?php
}
@@ -102,53 +114,55 @@ class Publicize_UI {
$_blog_id = get_current_blog_id();
?>
- <form action="" id="publicize-form">
- <h3 id="publicize"><?php _e( 'Publicize', 'jetpack' ) ?></h3>
-
- <?php
- if ( !empty( $_GET['action'] ) && 'deny' == $_GET['action'] )
- $this->denied_notice();
- ?>
-
- <p>
- <?php esc_html_e( 'Connect your blog to popular social networking sites and automatically share new posts with your friends.', 'jetpack' ) ?>
- <?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' ); ?>
- </p>
-
- <?php
- if ( $this->in_jetpack )
- $doc_link = "http://jetpack.me/support/publicize/";
- else
- $doc_link = "http://en.support.wordpress.com/publicize/";
- ?>
-
- <p>&rarr; <a href="<?php echo esc_url( $doc_link ); ?>" target="_blank"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p>
-
- <div id="publicize-services-block">
- <?php
- $services = $this->publicize->get_services( 'all' );
- $total_num_of_services = count ( $services );
- $service_num = 0;?>
-
- <div class='left'>
-
- <?php
- foreach ( $services as $name => $service ) :
- $connect_url = $this->publicize->connect_url( $name );
- if ( $service_num == ( round ( ( $total_num_of_services / 2 ), 0 ) ) )
- echo "</div><div class='right'>";
- $service_num++;
- ?>
- <div class="publicize-service-entry" <?php if ( $service_num > 0 ): ?>class="connected"<?php endif; ?> >
- <div id="<?php echo esc_attr( $name ); ?>" class="publicize-service-left">
- <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>
- </div>
+ <form action="" id="publicize-form">
+ <h2 id="publicize"><?php _e( 'Publicize', 'jetpack' ) ?></h2>
+
+ <?php
+ if ( ! empty( $_GET['action'] ) && 'deny' == $_GET['action'] ) {
+ $this->denied_notice();
+ }
+ ?>
+
+ <p>
+ <?php esc_html_e( 'Connect your blog to popular social networking sites and automatically share new posts with your friends.', 'jetpack' ) ?>
+ <?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' ); ?>
+ </p>
+
+ <?php
+ if ( $this->in_jetpack ) {
+ $doc_link = "http://jetpack.me/support/publicize/";
+ } else {
+ $doc_link = "http://en.support.wordpress.com/publicize/";
+ }
+ ?>
+
+ <p>&rarr; <a href="<?php echo esc_url( $doc_link ); ?>" target="_blank"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p>
+
+ <div id="publicize-services-block">
+ <?php
+ $services = $this->publicize->get_services( 'all' );
+ $total_num_of_services = count ( $services );
+ $service_num = 0;?>
+ <div class='left'>
- <div class="publicize-service-right">
- <?php if ( $this->publicize->is_enabled( $name ) && $connections = $this->publicize->get_connections( $name ) ) : ?>
- <ul>
- <?php
+ <?php
+ foreach ( $services as $name => $service ) :
+ $connect_url = $this->publicize->connect_url( $name );
+ if ( $service_num == ( round ( ( $total_num_of_services / 2 ), 0 ) ) )
+ echo "</div><div class='right'>";
+ $service_num++;
+ ?>
+ <div class="publicize-service-entry" <?php if ( $service_num > 0 ): ?>class="connected"<?php endif; ?> >
+ <div id="<?php echo esc_attr( $name ); ?>" class="publicize-service-left">
+ <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>
+ </div>
+
+
+ <div class="publicize-service-right">
+ <?php if ( $this->publicize->is_enabled( $name ) && $connections = $this->publicize->get_connections( $name ) ) : ?>
+ <ul>
+ <?php
foreach( $connections as $c ) :
$id = $this->publicize->get_connection_id( $c );
$disconnect_url = $this->publicize->disconnect_url( $name, $id );
@@ -202,47 +216,39 @@ class Publicize_UI {
<?php
endforeach;
- ?>
- </ul>
- <?php endif; ?>
+ ?>
+ </ul>
+ <?php endif; ?>
- <?php
- $connections = $this->publicize->get_connections( $name );
- if ( empty ( $connections ) ) { ?>
+ <?php
+ $connections = $this->publicize->get_connections( $name );
+ if ( empty ( $connections ) ) { ?>
<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>
- <?php } else { ?>
+ <?php } else { ?>
<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>
<?php } ?>
-
-
- <?php
- $help = apply_filters( 'publicize_help_text_' . $name, false );
- if ( $help ) {
- echo ' <a href="javascript:void(0);" title="' . esc_attr( $help ) . '" class="publicize-info">?</a>';
- }
- ?>
</div>
</div>
<?php endforeach; ?>
</div>
<script>
- (function($){
- $('.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' ) ); ?>' ) ) {
+ (function($){
+ $('.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' ) ); ?>' ) ) {
return true;
} else {
- e.preventDefault();
- return false;
- }
- })
- })(jQuery);
- </script>
- </div>
+ e.preventDefault();
+ return false;
+ }
+ })
+ })(jQuery);
+ </script>
+ </div>
<?php wp_nonce_field( "wpas_posts_{$_blog_id}", "_wpas_posts_{$_blog_id}_nonce" ); ?>
<input type="hidden" id="wpas_ajax_blog_id" name="wpas_ajax_blog_id" value="<?php echo $_blog_id; ?>" />
- </form><?php
+ </form><?php
}
@@ -288,7 +294,7 @@ class Publicize_UI {
/**
* CSS for styling the publicize message box and counter that displays on the post page.
- * There is also some Javascript for length counting and some basic display effects.
+ * There is also some JavaScript for length counting and some basic display effects.
*/
function post_page_metabox_assets() {
global $post;
@@ -306,8 +312,8 @@ class Publicize_UI {
<script type="text/javascript">
jQuery( function($) {
var wpasTitleCounter = $( '#wpas-title-counter' ),
- wpasTwitterCheckbox = $( '.wpas-submit-twitter' ).size(),
- wpasTitle = $('#wpas-title').keyup( function() {
+ wpasTwitterCheckbox = $( '.wpas-submit-twitter' ).size(),
+ wpasTitle = $('#wpas-title').keyup( function() {
var length = wpasTitle.val().length;
wpasTitleCounter.text( length );
if ( wpasTwitterCheckbox && length > 140 ) {
@@ -315,8 +321,8 @@ jQuery( function($) {
} else {
wpasTitleCounter.removeClass( 'wpas-twitter-length-limit' );
}
- } ),
- authClick = false;
+ } ),
+ authClick = false;
$('#publicize-disconnected-form-show').click( function() {
$('#publicize-form').slideDown( 'fast' );
@@ -391,7 +397,7 @@ jQuery( function($) {
$( '.pub-service' ).click( function() {
var service = $(this).data( 'service' ),
- fakebox = '<input id="wpas-submit-' + service + '" type="hidden" value="1" name="wpas[submit][' + service + ']" />';
+ fakebox = '<input id="wpas-submit-' + service + '" type="hidden" value="1" name="wpas[submit][' + service + ']" />';
$( '#add-publicize-check' ).append( fakebox );
} );
@@ -553,13 +559,27 @@ jQuery( function($) {
elseif ( ! empty( $connection['connection_data'] ) )
$connection_data = $connection['connection_data'];
- if ( !$continue = apply_filters( 'wpas_submit_post?', true, $post->ID, $name, $connection_data ) )
+ /**
+ * Filter whether a post should be publicized to a given service.
+ *
+ * @module publicize
+ *
+ * @since 2.0.0
+ *
+ * @param bool true Should the post be publicized to a given service? Default to true.
+ * @param int $post->ID Post ID.
+ * @param string $name Service name.
+ * @param array $connection_data Array of information about all Publicize details for the site.
+ */
+ if ( ! $continue = apply_filters( 'wpas_submit_post?', true, $post->ID, $name, $connection_data ) ) {
continue;
+ }
- if ( !empty( $connection->unique_id ) )
+ if ( ! empty( $connection->unique_id ) ) {
$unique_id = $connection->unique_id;
- else if ( !empty( $connection['connection_data']['token_id'] ) )
+ } else if ( ! empty( $connection['connection_data']['token_id'] ) ) {
$unique_id = $connection['connection_data']['token_id'];
+ }
// Should we be skipping this one?
$skip = (
@@ -595,20 +615,46 @@ jQuery( function($) {
$hidden_checkbox = false;
if ( !$done && ( 0 == $cmeta['connection_data']['user_id'] && !current_user_can( $this->publicize->GLOBAL_CAP ) ) ) {
$disabled = ' disabled="disabled"';
- $hidden_checkbox = true;
+ /**
+ * Filters the checkboxes for global connections with non-prilvedged users.
+ *
+ * @module publicize
+ *
+ * @since 3.7.0
+ *
+ * @param bool $checked Indicates if this connection should be enabled. Default true.
+ * @param int $post->ID ID of the current post
+ * @param string $name Name of the connection (Facebook, Twitter, etc)
+ * @param array $connection Array of data about the connection.
+ */
+ $hidden_checkbox = apply_filters( 'publicize_checkbox_global_default', true, $post->ID, $name, $connection );
}
// Determine the state of the checkbox (on/off) and allow filtering
$checked = $skip != 1 || $done;
+ /**
+ * Filter the checkbox state of each Publicize connection appearing in the post editor.
+ *
+ * @module publicize
+ *
+ * @since 2.0.1
+ *
+ * @param bool $checked Should the Publicize checkbox be enabled for a given service.
+ * @param int $post->ID Post ID.
+ * @param string $name Service name.
+ * @param array $connection Array of connection details.
+ */
$checked = apply_filters( 'publicize_checkbox_default', $checked, $post->ID, $name, $connection );
// Force the checkbox to be checked if the post was DONE, regardless of what the filter does
- if ( $done )
+ if ( $done ) {
$checked = true;
+ }
// This post has been handled, so disable everything
- if ( $all_done )
+ if ( $all_done ) {
$disabled = ' disabled="disabled"';
+ }
$label = sprintf(
_x( '%1$s: %2$s', 'Service: Account connected as', 'jetpack' ),
@@ -638,11 +684,12 @@ jQuery( function($) {
}
}
- if ( $title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true ) )
+ if ( $title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true ) ) {
$title = esc_html( $title );
- else
+ } else {
$title = '';
- ?>
+ }
+ ?>
</ul>
@@ -698,7 +745,18 @@ jQuery( function($) {
<a href="#" id="publicize-disconnected-form-show"><?php _e( 'Show', 'jetpack' ); ?></a><br />
<?php endif; ?>
- <?php echo apply_filters( 'publicize_form', $publicize_form ); ?>
+ <?php
+ /**
+ * Filter the Publicize details form.
+ *
+ * @module publicize
+ *
+ * @since 2.0.0
+ *
+ * @param string $publicize_form Publicize Details form appearing above Publish button in the editor.
+ */
+ echo apply_filters( 'publicize_form', $publicize_form );
+ ?>
</div> <?php // #publicize
}