summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/sharedaddy')
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.css353
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.js348
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/custom.pngbin0 -> 1364 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/designfloat.pngbin0 -> 870 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/digg.pngbin0 -> 1449 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/divider.pngbin0 -> 945 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/draggy.pngbin0 -> 958 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/email.pngbin0 -> 1380 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/ember.pngbin0 -> 653 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/facebook.pngbin0 -> 838 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/feed.pngbin0 -> 805 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/googleplus1.pngbin0 -> 1288 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-smart.pngbin0 -> 2566 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin.pngbin0 -> 1150 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/loading.gifbin0 -> 2530 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/print.pngbin0 -> 1485 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/reddit.pngbin0 -> 918 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/rss.pngbin0 -> 907 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/share-bg.pngbin0 -> 938 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/sharing-hidden.pngbin0 -> 3696 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-digg.pngbin0 -> 2024 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-facebook.pngbin0 -> 2278 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-like.pngbin0 -> 2108 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-reddit.pngbin0 -> 2845 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.pngbin0 -> 3199 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-twitter.pngbin0 -> 3018 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/stumbleupon.pngbin0 -> 818 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/twitter.pngbin0 -> 485 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/wordpress.pngbin0 -> 1621 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/readme.txt129
-rw-r--r--plugins/jetpack/modules/sharedaddy/screenshot-1.jpgbin0 -> 58951 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/screenshot-2.jpgbin0 -> 27511 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharedaddy.php126
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharedaddy.pot404
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-service.php529
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-sources.php1076
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.css278
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.js234
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.php417
39 files changed, 3894 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.css b/plugins/jetpack/modules/sharedaddy/admin-sharing.css
new file mode 100644
index 00000000..80c4fb89
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.css
@@ -0,0 +1,353 @@
+#services-config {
+ background: #f1f1f1;
+ border: 1px #e3e3e3 solid;
+ border-radius: 6px;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ margin-top:15px;
+ min-width: 700px;
+ width: 100%;
+ float: left;
+ margin-bottom: 25px;
+}
+
+#available-services,#enabled-services,#live-preview{
+ padding:20px 20px 0px 20px;
+ width: 100%;
+}
+
+#enabled-services {
+ padding: 20px;
+}
+
+#live-preview {
+ padding: 20px 20px 10px 20px;
+}
+
+#available-services{
+ border-bottom: 1px #e3e3e3 solid;
+}
+
+#available-services h3,#enabled-services h3,#live-preview h3{
+ padding: 0px;
+ margin-top: 0px;
+}
+
+.description{
+ width: 180px;
+ vertical-align: top;
+}
+
+.description p{
+ font-size: 11px;
+}
+
+.services {
+ padding: 0px 20px;
+ vertical-align: top;
+}
+
+.services ul{
+}
+
+.services ul li {
+ float: left;
+ border: 1px #e3e3e3 solid;
+ border-radius: 6px;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ padding: 5px 10px 5px 24px;
+ margin-right: 10px;
+ cursor: move;
+}
+
+.services ul li.divider {
+ border: none;
+ padding: 0;
+ background: none;
+ cursor: default;
+}
+
+.preview {
+ float: left !important;
+}
+
+
+.services ul li#facebook, .preview-facebook div.option-smart-off{background: #FFF url(images/facebook.png) no-repeat 4px 5px;}
+.services ul li#twitter, .preview-twitter div.option-smart-off{background: #FFF url(images/twitter.png) no-repeat 4px 5px;}
+.services ul li#wordpress, .preview-wordpress{background: #FFF url(images/wordpress.png) no-repeat 4px 5px;}
+.services ul li#digg, .preview-digg div.option-smart-off{background: #FFF url(images/digg.png) no-repeat 4px 5px;}
+.services ul li#reddit, .preview-reddit div.option-smart-off{background: #FFF url(images/reddit.png) no-repeat 4px 5px;}
+.services ul li#stumbleupon, .preview-stumbleupon div.option-smart-off{background: #FFF url(images/stumbleupon.png) no-repeat 4px 5px;}
+.services ul li#email, .preview-email{background: #FFF url(images/email.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#print, .preview-print{background: #FFF url(images/print.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#press-this, .preview-press-this{background: #FFF url(images/wordpress.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#linkedin, .preview-linkedin div.option-smart-off{background: #FFF url(images/linkedin.png) no-repeat 4px 5px;}
+.services ul li#google-plus-1,.preview-google-plus-1{background: #FFF url(images/googleplus1.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li.share-custom, .preview-custom{background: #FFF url(images/custom.png) no-repeat 4px 5px; no-repeat 4px 5px; padding-right: 10px;}
+
+/****************************************************************************/
+
+.preview li.preview-item {
+ margin: 0 15px 0 0;
+ background-position: 0px 5px;
+ padding: 5px 0px 5px 20px;
+ border: none;
+ cursor: default;
+}
+
+.preview li.preview-digg, .preview li.preview-reddit, .preview li.preview-stumbleupon, .preview li.preview-facebook, .preview li.preview-twitter, .preview li.preview-linkedin {
+ padding: 0;
+}
+
+.preview-digg .option-smart-off, .preview-reddit .option-smart-off, .preview-stumbleupon .option-smart-off, .preview-facebook .option-smart-off, .preview-twitter .option-smart-off, .preview-linkedin .option-smart-off {
+ background-position: 0px 5px !important;
+ padding: 5px 0px 5px 20px;
+}
+
+.preview-digg .option-smart-on {
+ background: #FFF url(images/smart-digg.png) no-repeat top left;
+ width:76px;
+ height:17px;
+ margin-top: 5px;
+}
+
+.preview-reddit .option-smart-on {
+ background: #FFF url(images/smart-reddit.png) no-repeat top left;
+ width:104px;
+ height:21px;
+ margin-top: 3px;
+}
+
+.preview-stumbleupon .option-smart-on {
+ background: #FFF url(images/smart-stumbleupon.png) no-repeat top left;
+ width: 74px;
+ height: 18px;
+ margin-top: 4px;
+}
+
+.preview-facebook .option-smart-like {
+ background: #FFF url(images/smart-like.png) no-repeat top left;
+ width:50px;
+ height:20px;
+ margin-top: 3px;
+}
+
+.preview-facebook .option-smart-on {
+ background: #FFF url(images/smart-facebook.png) no-repeat top left;
+ width:60px;
+ height:18px;
+ margin-top: 4px;
+}
+
+.preview-twitter .option-smart-on {
+ background: #FFF url(images/smart-twitter.png) no-repeat top left;
+ width:92px;
+ height:20px;
+ margin-top: 3px;
+}
+
+.preview-linkedin .option-smart-on {
+ background: #FFF url(images/linkedin-smart.png) no-repeat top center;
+ width:99px;
+ height:22px;
+ margin-top: 3px;
+}
+
+.preview-google-plus-1 .option-smart-on {
+ max-width: 70px;
+ width: 15px;
+ height: 15px;
+ margin-top: 4px;
+}
+
+.services .preview li.share-custom {
+ border-radius: 6px;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ background:url("images/sharing-hidden.png") no-repeat scroll 0px center #FFFFFF;
+ border: 1px solid #D8D8D8;
+ float: left;
+ line-height: 22px;
+ padding: 0 8px 0 21px;
+ margin: 1px 0 0 0;
+}
+
+.services .preview li.share-custom a {
+ color: #333;
+ text-decoration: none;
+}
+
+.services ul li.end-fix {
+ clear:both;
+ float:none;
+ visibility:hidden;
+ padding:0;
+ margin:0;
+ height:20px;
+ width:0;
+}
+
+#enabled-services{
+ border-top: 1px #FFF solid;
+ border-bottom: 1px #e3e3e3 solid;
+}
+
+#enabled-services h2{
+ font-size:20px;
+ padding-top:0px;
+ font-weight: normal !important;
+ color: #999;
+}
+
+#live-preview h2{
+ font-size:20px;
+ font-weight: normal !important;
+ color: #e3e3e3;
+}
+
+#live-preview{
+ background: #FFF;
+ border-bottom-left-radius:6px 6px;
+ border-bottom-right-radius:6px 6px;
+ -moz-border-radius-bottomleft: 6px;
+ -moz-border-radius-bottomright: 6px;
+}
+
+.clearing{
+ clear: both;
+}
+
+.options-toggle{
+}
+ #available-services .options-toggle {
+ display: none;
+ }
+
+ .services ul li.options{
+ padding-right: 0px;
+ }
+
+ .options .options-left{
+ float: left;
+ }
+
+ .options .options-toggle{
+ float: left;
+ width: 24px;
+ height: 26px;
+ margin-top:-6px;
+ margin-left: 5px;
+ margin-bottom:-5px;
+ }
+
+ html>body .options .options-toggle{
+ float: right;
+ }
+
+ .options-open .options-toggle{
+ margin-top:-5px;
+ }
+
+ .input label{
+ font-size: 11px;
+ line-height: 16px;
+ }
+
+ .advanced-form {
+ padding: 10px 14px 8px 10px;
+ margin-left: -24px;
+ display: none;
+ border-top: 1px #e3e3e3 solid;
+ margin-top:4px;
+ }
+
+
+ .services ul li.options-open .advanced-form{
+ display: block;
+ }
+
+ .utility{
+ float: right;
+ padding-top:10px;
+ padding-right: 10px;
+ font-size: 10px;
+ }
+
+ .advanced input[type=submit]{
+ float: left;
+ margin-top:10px;
+ margin-right: 10px;
+ }
+
+.services li.dropzone {
+ border: 1px dashed #999;
+ background: #e3e3e3;
+}
+
+.advanced-form .form-table th {
+ width: auto !important;
+}
+
+.advanced-form .button-secondary {
+ margin-top: 0 !important;
+}
+
+#share-drop-target {
+}
+
+#hidden-drop-target {
+ background: #e1e1e1;
+ border: 1px solid #cdcdcd;
+ border-radius: 6px;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ width: 29%;
+ padding: 10px;
+ vertical-align: top;
+}
+
+#hidden-drop-target p {
+ font-size: 10px;
+ margin: 0 0 10px 0;
+
+}
+
+.sharing-hidden .inner {
+ position: absolute;
+ border: 2px solid #6e6e6e;
+ padding: 15px 0px;
+ background: #fff;
+}
+
+
+.sharing-hidden ul {
+ background: #fff url('images/share-bg.png') repeat-y center center;
+ margin: 0 !important;
+}
+
+.services .sharing-hidden li {
+ margin: 0px 10px 0px 10px;
+ background-color: transparent;
+ width: 100px;
+}
+
+.sharing-hidden .preview-digg, .sharing-hidden .preview-reddit, .sharing-hidden .preview-stumbleupon, .sharing-hidden .preview-facebook, .sharing-hidden .preview-twitter, .sharing-hidden .preview-linkedin, .sharing-hidden .preview-google-plus-1 {
+ width: 120px !important;
+}
+
+.sharing-hidden li.share-end {
+ clear: both;
+ height: 0;
+ padding: 0px !important;
+ margin: 0px !important;
+ width: 0;
+ visibility: hidden;
+ float: none;
+}
+
+.preview .sharing-label {
+ font-weight: bold;
+ border: 0;
+ padding: 4px 6px 0 0;
+}
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.js b/plugins/jetpack/modules/sharedaddy/admin-sharing.js
new file mode 100644
index 00000000..4a93eab8
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.js
@@ -0,0 +1,348 @@
+(function($) {
+ $( document ).ready(function() {
+ function enable_share_button() {
+ $( '.preview a.sharing-anchor' ).unbind( 'mouseenter mouseenter' ).hover( function() {
+ if ( $( this ).data( 'hasappeared' ) !== true ) {
+ var item = $( this ).parents( 'li:first' ).find( '.inner' );
+ var original = $( this ).parents( '.share-custom' );
+
+ // Create a timer to make the area appear if the mouse hovers for a period
+ var timer = setTimeout( function() {
+
+ $( item ).css( {
+ left: $( original ).position().left + 'px',
+ top: $( original ).position().top + $( original ).height() + 3 + 'px'
+ } ).slideDown( 200, function() {
+ // Mark the item as have being appeared by the hover
+ $( original ).data( 'hasappeared', true ).data( 'hasoriginal', true ).data( 'hasitem', false );
+
+ // Remove all special handlers
+ $( item ).mouseleave( handler_item_leave ).mouseenter( handler_item_enter );
+ $( original ).mouseleave( handler_original_leave ).mouseenter( handler_original_enter );
+
+ // Add a special handler to quickly close the item
+ $( original ).click( close_it );
+ } );
+
+ // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area
+ var handler_item_leave = function() {
+ $( original ).data( 'hasitem', false );
+
+ if ( $( original ).data( 'hasoriginal' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $( original ).data( 'timer2', timer );
+ }
+ };
+
+ var handler_item_enter = function() {
+ $( original ).data( 'hasitem', true );
+ clearTimeout( $( original ).data( 'timer2' ) );
+ }
+
+ var handler_original_leave = function() {
+ $( original ).data( 'hasoriginal', false );
+
+ if ( $( original ).data( 'hasitem' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $( original ).data( 'timer2', timer );
+ }
+ };
+
+ var handler_original_enter = function() {
+ $( original ).data( 'hasoriginal', true );
+ clearTimeout( $( original ).data( 'timer2' ) );
+ };
+
+ var close_it = function() {
+ item.slideUp( 200 );
+
+ // Clear all hooks
+ $( original ).unbind( 'mouseleave', handler_original_leave ).unbind( 'mouseenter', handler_original_enter );
+ $( item ).unbind( 'mouseleave', handler_item_leave ).unbind( 'mouseenter', handler_item_leave );
+ $( original ).data( 'hasappeared', false );
+ $( original ).unbind( 'click', close_it );
+ return false;
+ };
+ }, 200 );
+
+ // Remember the timer so we can detect it on the mouseout
+ $( this ).data( 'timer', timer );
+ }
+ }, function() {
+ // Mouse out - remove any timer
+ clearTimeout( $( this ).data( 'timer' ) );
+ $( this ).data( 'timer', false );
+ } );
+ }
+
+ function update_preview() {
+ var item;
+
+ // Clear the live preview
+ $( '#live-preview ul.preview li' ).remove();
+
+ // Add label
+ if ( $( '#save-enabled-shares input[name=visible]' ).val() != '' || $( '#save-enabled-shares input[name=hidden]' ).val() != '' )
+ $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .sharing-label' ).clone() );
+
+ // Re-insert all the enabled items
+ $( 'ul.services-enabled li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ var service = $( this ).attr( 'id' );
+
+ $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .preview-' + service ).clone() );
+ }
+ } );
+
+ // Add any preview items
+ if ( $( '#save-enabled-shares input[name=hidden]' ).val() != '' ) {
+ // Add share button
+ $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .share-custom' ).clone() );
+ $( '#live-preview ul.preview li.share-custom ul li' ).remove();
+
+ // Add rest of the items
+ $( 'ul.services-hidden li' ).each( function( pos, item ) {
+ if ( $( this ).hasClass( 'service' ) ) {
+ var service = $( this ).attr( 'id' );
+
+ $( '#live-preview ul.preview li.share-custom ul' ).append( $( '#live-preview ul.archive .preview-' + service ).clone() );
+
+ if ( pos % 2 == 1 )
+ $( '#live-preview ul.preview li.share-custom ul' ).append( '<li class="share-end"></div>' );
+ }
+ } );
+
+ enable_share_button();
+ }
+
+ // Button style
+ if ( $( 'select[name=button_style]' ).val() == 'icon' )
+ $( '#live-preview ul.preview .option' ).html( '&nbsp;' ); // Remove the text
+ else if ( $( 'select[name=button_style]' ).val() == 'text' ) {
+ $( '#live-preview ul.preview li.advanced' ).each( function() {
+ if ( $( this ).find( '.option' ).hasClass( 'option-smart-on' ) === false && $( this ).find( '.option' ).hasClass( 'option-smart-like' ) === false )
+ $( this ).attr( 'class', 'advanced preview-item' );
+ } );
+ }
+ }
+
+ function sharing_option_changed() {
+ var item = this;
+
+ // Loading icon
+ $( this ).parents( 'li:first' ).css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
+
+ // Save
+ $( this ).parents( 'form' ).ajaxSubmit( function( response ) {
+ if ( response.indexOf( '<!---' ) >= 0 ) {
+ var button = response.substring( 0, response.indexOf( '<!--->' ) );
+ var preview = response.substring( response.indexOf( '<!--->' ) + 6 );
+
+ if ( $( item ).is( ':submit' ) === true ) {
+ // Update the DOM using a bit of cut/paste technology
+
+ $( item ).parents( 'li:first' ).replaceWith( button );
+
+ init_handlers();
+ }
+
+ $( '#live-preview ul.archive li.preview-' + $( item ).parents( 'form' ).find( 'input[name=service]' ).val() ).replaceWith( preview );
+ }
+
+ // Update preview
+ update_preview();
+
+ // Restore the icon
+ $( item ).parents( 'li:first' ).removeAttr( 'style' );
+ } );
+
+ if ( $( item ).is( ':submit' ) === true )
+ return false;
+ return true;
+ }
+
+ function save_services() {
+ $( '#enabled-services h3 img' ).show();
+
+ // Update the display to reflect the changes
+ $( '#enabled-services li' ).addClass( 'options' );
+ $( '#available-services li' ).removeClass( 'options' );
+
+ // Toggle various dividers/help texts
+ if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) {
+ $( '#drag-instructions' ).hide();
+ }
+ else {
+ $( '#drag-instructions' ).show();
+ }
+
+ if ( $( '#enabled-services li.service' ).length > 0 ) {
+ $( '#live-preview .services h2' ).hide();
+ }
+ else {
+ $( '#live-preview .services h2' ).show();
+ }
+
+ // Gather the modules
+ var visible = [], hidden = [];
+
+ $( 'ul.services-enabled li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ // Ready for saving
+ visible[visible.length] = $( this ).attr( 'id' );
+ }
+ } );
+
+ $( 'ul.services-hidden li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ // Ready for saving
+ hidden[hidden.length] = $( this ).attr( 'id' );
+ }
+ } );
+
+ // Set the hidden element values
+ $( '#save-enabled-shares input[name=visible]' ).val( visible.join( ',' ) );
+ $( '#save-enabled-shares input[name=hidden]' ).val( hidden.join( ',' ) );
+
+ update_preview();
+
+ // Save it
+ $( '#save-enabled-shares' ).ajaxSubmit( function() {
+ $( '#enabled-services h3 img' ).hide();
+ } );
+ }
+
+ $( '#enabled-services .services ul' ).sortable( {
+ receive: function( event, ui ) {
+ save_services();
+ },
+ stop: function() {
+ save_services();
+ $( 'li.service' ).enableSelection(); // Fixes a problem with Chrome
+ },
+ over: function( event, ui ) {
+ $( this ).find( 'ul' ).addClass( 'dropping' );
+
+ // Ensure the 'end-fix' is at the end
+ $( '#enabled-services li.end-fix' ).remove()
+ $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
+ },
+ out: function( event, ui ) {
+ $( this ).find( 'ul' ).removeClass( 'dropping' );
+
+ // Ensure the 'end-fix' is at the end
+ $( '#enabled-services li.end-fix' ).remove()
+ $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
+ },
+ helper: function( event, ui ) {
+ ui.find( '.advanced-form' ).hide();
+
+ return ui.clone();
+ },
+ start: function( event, ui ) {
+ // Make sure that the advanced section is closed
+ $( '.advanced-form' ).hide();
+ $( 'li.service' ).disableSelection(); // Fixes a problem with Chrome
+ },
+ placeholder: 'dropzone',
+ opacity: 0.8,
+ delay: 150,
+ forcePlaceholderSize: true,
+ items: 'li',
+ connectWith: '#available-services ul, #enabled-services .services ul',
+ cancel: '.advanced-form'
+ } );
+
+ $( '#available-services ul' ).sortable( {
+ opacity: 0.8,
+ delay: 150,
+ cursor: 'move',
+ connectWith: '#enabled-services .services ul',
+ placeholder: 'dropzone',
+ forcePlaceholderSize: true,
+ start: function() {
+ $( '.advanced-form' ).hide();
+ }
+ } );
+
+ // Advanced options toggle
+ $( '.options-toggle' ).live( 'click', function() {
+ var was_visible = $( this ).parents( 'li:first' ).find( '.advanced-form' ).is( ':visible' );
+
+ // Hide everything
+ $( '.advanced-form' ).slideUp( 200 );
+
+ if ( !was_visible )
+ $( this ).parents( 'li:first' ).find( '.advanced-form' ).slideDown( 200 );
+ } );
+
+ // Live preview 'hidden' button
+ $( '.preview-hidden a' ).click( function() {
+ $( this ).parent().find( '.preview' ).toggle();
+ return false;
+ } );
+
+ // Add service
+ $( '#new-service form' ).ajaxForm( {
+ beforeSubmit: function() {
+ $( '#new-service-form .error' ).hide();
+ $( '#new-service-form img' ).show();
+ $( '#new-service-form input[type=submit]' ).attr( 'disabled', true );
+ },
+ success: function( response ) {
+ $( '#new-service-form img' ).hide();
+
+ if ( response == '1' ) {
+ $( '#new-service-form .inerror' ).removeClass( 'inerror' ).addClass( 'error' );
+ $( '#new-service-form .error' ).show();
+ $( '#new-service-form input[type=submit]' ).attr( 'disabled', false );
+ }
+ else {
+ document.location.reload();
+ }
+ }
+ }
+ );
+
+ function init_handlers() {
+ // Hook up all advanced options
+ $( '.advanced-form form input[type=checkbox]' ).unbind( 'click' ).click( sharing_option_changed );
+ $( '.advanced-form form select' ).unbind( 'change' ).change( sharing_option_changed );
+ $( '.advanced-form form input[type=submit]' ).unbind( 'click' ).click( sharing_option_changed );
+
+ $( '.advanced-form form a.remove' ).unbind( 'click' ).click( function() {
+ var form = $( this ).parents( 'form' );
+
+ form.find( 'input[name=action]' ).val( 'sharing_delete_service' );
+
+ // Loading icon
+ $( this ).parents( 'li:first' ).css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
+
+ // Save
+ $( this ).parents( 'form' ).ajaxSubmit( function( response ) {
+ // Remove the item
+ form.parents( 'li:first' ).fadeOut( function() {
+ $( this ).remove();
+
+ // Update preview
+ update_preview();
+ } );
+ } );
+
+ return false;
+ } );
+ }
+
+ $( 'select[name=button_style]' ).change( function() {
+ update_preview();
+ return true;
+ } );
+
+ $( 'input[name=sharing_label]' ).blur( function() {
+ $('#live-preview ul.preview li.sharing-label').html( $( '<div/>' ).text( $( this ).val() ).html() );
+ } );
+
+ init_handlers();
+ enable_share_button();
+ } );
+})( jQuery );
diff --git a/plugins/jetpack/modules/sharedaddy/images/custom.png b/plugins/jetpack/modules/sharedaddy/images/custom.png
new file mode 100644
index 00000000..6d2f495e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/custom.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/designfloat.png b/plugins/jetpack/modules/sharedaddy/images/designfloat.png
new file mode 100644
index 00000000..62e8f32d
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/designfloat.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/digg.png b/plugins/jetpack/modules/sharedaddy/images/digg.png
new file mode 100644
index 00000000..8524fa53
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/digg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/divider.png b/plugins/jetpack/modules/sharedaddy/images/divider.png
new file mode 100644
index 00000000..709e7f97
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/divider.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/draggy.png b/plugins/jetpack/modules/sharedaddy/images/draggy.png
new file mode 100644
index 00000000..fcdd3989
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/draggy.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/email.png b/plugins/jetpack/modules/sharedaddy/images/email.png
new file mode 100644
index 00000000..2ea4d7b0
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/email.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/ember.png b/plugins/jetpack/modules/sharedaddy/images/ember.png
new file mode 100644
index 00000000..1a285a2a
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/ember.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/facebook.png b/plugins/jetpack/modules/sharedaddy/images/facebook.png
new file mode 100644
index 00000000..8850a80b
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/facebook.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/feed.png b/plugins/jetpack/modules/sharedaddy/images/feed.png
new file mode 100644
index 00000000..b0f72ffe
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/feed.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/googleplus1.png b/plugins/jetpack/modules/sharedaddy/images/googleplus1.png
new file mode 100644
index 00000000..22cb1df8
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/googleplus1.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
new file mode 100644
index 00000000..a828ad6f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin.png b/plugins/jetpack/modules/sharedaddy/images/linkedin.png
new file mode 100644
index 00000000..a5e0340e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/loading.gif b/plugins/jetpack/modules/sharedaddy/images/loading.gif
new file mode 100644
index 00000000..85b99d46
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/loading.gif
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/print.png b/plugins/jetpack/modules/sharedaddy/images/print.png
new file mode 100644
index 00000000..19a245fa
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/print.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/reddit.png b/plugins/jetpack/modules/sharedaddy/images/reddit.png
new file mode 100644
index 00000000..25a849f8
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/reddit.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/rss.png b/plugins/jetpack/modules/sharedaddy/images/rss.png
new file mode 100644
index 00000000..0f06c7f1
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/rss.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/share-bg.png b/plugins/jetpack/modules/sharedaddy/images/share-bg.png
new file mode 100644
index 00000000..f74ed039
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/share-bg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png
new file mode 100644
index 00000000..96072621
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
new file mode 100644
index 00000000..ce654de4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-facebook.png b/plugins/jetpack/modules/sharedaddy/images/smart-facebook.png
new file mode 100644
index 00000000..18de01f7
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-facebook.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like.png b/plugins/jetpack/modules/sharedaddy/images/smart-like.png
new file mode 100644
index 00000000..98cfc345
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-like.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
new file mode 100644
index 00000000..4788a507
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
new file mode 100644
index 00000000..8851447c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
new file mode 100644
index 00000000..e14da3e8
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png
new file mode 100644
index 00000000..af4e9564
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter.png b/plugins/jetpack/modules/sharedaddy/images/twitter.png
new file mode 100644
index 00000000..1734a8a4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress.png b/plugins/jetpack/modules/sharedaddy/images/wordpress.png
new file mode 100644
index 00000000..6b560450
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/wordpress.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/readme.txt b/plugins/jetpack/modules/sharedaddy/readme.txt
new file mode 100644
index 00000000..b2fd2bd3
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/readme.txt
@@ -0,0 +1,129 @@
+=== Sharedaddy ===
+Contributors: eoigal, johnny5, donncha, polldaddy, automattic
+Tags: share, sharing, email, twitter, facebook, print, reddit, stumbleupon, digg
+Requires at least: 3.0
+Tested up to: 3.1
+Stable tag: trunk
+
+Share your posts with Twitter, Facebook, and a host of other services
+
+== Description ==
+
+Share your posts with Twitter, Facebook, and a host of other services. You can configure services to appear as icons, text, or both. Some services have additional options to display smart buttons, such as Twitter, which will update the number of times the post has been shared.
+
+The following services are included:
+
+* Twitter
+* Facebook
+* Reddit
+* StumbleUpon
+* PressThis
+* Digg
+* Print
+* Email
+
+Additionally you can define your own custom services.
+
+[wpvideo WV0JOwY2]
+
+The plugin is available in the following languages:
+
+* English
+* Japanese, thanks to Naoko McCracken
+* Portuguese, thanks to WordPress Portugal
+* Spanish, thanks to elarequi
+* German, thanks to Jott und die Welt
+* French, thanks to Dario Spagnolo / Aurélie Rochelle
+* Brazilian Portuguese, thanks to Gabriel Reguly
+* Dutch, thanks to Chantal Coolsma
+* Serbian, thanks to Milan Dinić
+
+If you have a translation please send it us and we would be glad to include it for everyone to use!
+
+The following plugins extend Sharedaddy:
+
+* [Mixi Check](http://wordpress.org/extend/plugins/mixi-check/) - support for Mixi
+
+For more detailed information about using this plugin you can refer to these pages:
+
+* http://support.wordpress.com/sharing/
+* http://ryanmarkel.com/2010/08/26/adding-a-custom-sharing-service-to-wordpress-com/
+* http://ryanmarkel.com/2010/08/31/adding-specific-sharing-services-to-sharedaddy/
+* http://wpgarage.com/tips/how-to-add-a-linkedin-share-button-to-sharedaddy/
+
+Note: You will need PHP5 to use this plugin
+
+== Installation ==
+
+Upload the plugin to your blog and activate it. Configure your sharing services from the Settings > Sharing dashboard page
+
+== Screenshots ==
+
+1. Manage sharing services
+2. Share posts
+
+== Changelog ==
+= 0.1 =
+* Initial release
+
+= 0.2 =
+* Fix incorrect link in plugin page
+* Remove debug from JS code
+
+= 0.2.1 =
+* Add Japanese translation, thanks Naoko!
+
+= 0.2.2 =
+* Add Portuguese translation, thanks WordPress Portugal!
+
+= 0.2.3 =
+* Add Spanish, thanks to elarequi!
+
+= 0.2.4 =
+* Fix incorrect icon reference
+
+= 0.2.5 =
+* Add German, thanks to Jott und die Welt!
+* Optimize loading of Digg JS
+
+= 0.2.6 =
+* Add French, thanks to Dario Spagnolo / Aurélie Rochelle!
+
+= 0.2.7 =
+* Add Brazilian Portuguese, thanks to Gabriel
+* Add Dutch, thanks to Chantal
+
+= 0.2.8 =
+* Update Spanish translation (thanks to elarequi)
+* Change CSS link to use wp_enqueue (props to Barry)
+* Add %post_full_url% to custom service tags
+* Fixed removal of sharing option in quickedit (props to dimadin)
+* Add service ID to sharing_permalink filter (props to dimadin)
+* Email service loading.gif is included in the plugin
+* Better RTL support, cleanup style issues in some themes (props to Lance)
+
+= 0.2.9 =
+* Add Serbian translation (thanks to Milan Dinić)
+* Fix double = in Facebook share and rawurlencode like button for better theme compat (props to Lance)
+* Add %post_tags% to custom service tags
+* Allow Facebook like button width to change
+* Language domain fixes (props to dimadin)
+* Add language context to service names
+* Add 'sharing_show' filter to allow custom determination of whether to show sharing links
+* Add option to disable CSS and JS (so it can be moved in theme, if required)
+* Better support for non-multibyte blogs
+
+= 0.2.10 =
+* Restore fixes to Twitter link
+
+= 0.2.11 =
+* Updated German language (thanks to infected)
+* Further improvements to localisation (thanks to Milan Dinić)
+
+= 0.2.12 =
+* Theme placement improvements
+* Add Danish width to Facebook
+* Fix invalid HTML in Twitter iframe
+
+= 0.2.13 =
+* Add Google+1 button
diff --git a/plugins/jetpack/modules/sharedaddy/screenshot-1.jpg b/plugins/jetpack/modules/sharedaddy/screenshot-1.jpg
new file mode 100644
index 00000000..ec13343c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/screenshot-1.jpg
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/screenshot-2.jpg b/plugins/jetpack/modules/sharedaddy/screenshot-2.jpg
new file mode 100644
index 00000000..2679d8b5
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/screenshot-2.jpg
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/sharedaddy.php b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
new file mode 100644
index 00000000..a7146019
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
@@ -0,0 +1,126 @@
+<?php
+/*
+Plugin Name: Sharedaddy
+Description: The most super duper sharing tool on the interwebs.
+Version: 0.2.12
+Author: Automattic, Inc.
+Author URI: http://automattic.com/
+Plugin URI: http://en.blog.wordpress.com/2010/08/24/more-ways-to-share/
+*/
+
+require_once plugin_dir_path( __FILE__ ).'sharing.php';
+
+function sharing_email_send_post( $data ) {
+ $content = sprintf( __( '%1$s (%2$s) thinks you may be interested in the following post:'."\n\n", 'jetpack' ), $data['name'], $data['source'] );
+ $content .= $data['post']->post_title."\n";
+ $content .= get_permalink( $data['post']->ID )."\n";
+
+ wp_mail( $data['target'], '['.__( 'Shared Post', 'jetpack' ).'] '.$data['post']->post_title, $content );
+}
+
+function sharing_add_meta_box() {
+ $post_types = get_post_types( array( 'public' => true ) );
+
+ foreach( $post_types as $post_type ) {
+ add_meta_box( 'sharing_meta', __( 'Sharing', 'jetpack' ), 'sharing_meta_box_content', $post_type, 'advanced', 'high' );
+ }
+}
+
+function sharing_meta_box_content( $post ) {
+ $sharing_checked = get_post_meta( $post->ID, 'sharing_disabled', false );
+
+ if ( empty( $sharing_checked ) || $sharing_checked === false )
+ $sharing_checked = ' checked="checked"';
+ else
+ $sharing_checked = '';
+
+ echo '<p><label for="enable_post_sharing"><input name="enable_post_sharing" id="enable_post_sharing" value="1"' . $sharing_checked . ' type="checkbox"> ' . __( 'Show sharing buttons on this post.', 'jetpack' ) . '</label><input type="hidden" name="sharing_status_hidden" value="1" /></p>';
+}
+
+function sharing_meta_box_save( $post_id ) {
+ if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
+ return $post_id;
+
+ // Record sharing disable
+ if ( current_user_can( 'edit_post', $post_id ) ) {
+ if ( isset( $_POST['sharing_status_hidden'] ) ) {
+ if ( !isset( $_POST['enable_post_sharing'] ) ) {
+ update_post_meta( $post_id, 'sharing_disabled', 1 );
+ } else {
+ delete_post_meta( $post_id, 'sharing_disabled' );
+ }
+ }
+ }
+
+ return $post_id;
+}
+
+function sharing_meta_box_protected( $protected, $meta_key, $meta_type ) {
+ if ( 'sharing_disabled' == $meta_key )
+ $protected = true;
+
+ return $protected;
+}
+
+add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 3 );
+
+function sharing_plugin_settings( $links ) {
+ $settings_link = '<a href="options-general.php?page=sharing.php">'.__( 'Settings', 'jetpack' ).'</a>';
+ array_unshift( $links, $settings_link );
+ return $links;
+}
+
+function sharing_add_plugin_settings($links, $file) {
+ if ( $file == basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ) ) {
+ $links[] = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
+ $links[] = '<a href="http://support.wordpress.com/sharing/">' . __( 'Support', 'jetpack' ) . '</a>';
+ }
+
+ return $links;
+}
+
+function sharing_restrict_to_single( $services ) {
+ // This removes Press This from non-multisite blogs - doesnt make much sense
+ if ( is_multisite() === false ) {
+ unset( $services['press-this'] );
+ }
+
+ return $services;
+}
+
+function sharing_init() {
+ if ( get_option( 'sharedaddy_disable_resources' ) ) {
+ add_filter( 'sharing_js', 'sharing_disable_js' );
+ remove_action( 'wp_head', 'sharing_add_header', 1 );
+ }
+}
+
+function sharing_disable_js() {
+ return false;
+}
+
+function sharing_global_resources() {
+ $disable = get_option( 'sharedaddy_disable_resources' );
+?>
+<tr valign="top">
+ <th scope="row"><label for="disable_css"><?php _e( 'Disable CSS and JS', 'jetpack' ); ?></label></th>
+ <td>
+ <input id="disable_css" type="checkbox" name="disable_resourcse" <?php if ( $disable == 1 ) echo ' checked="checked"'; ?>/> <small><em><?php _e( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' ); ?></em></small>
+ </td>
+</tr>
+<?php
+}
+
+function shareing_global_resources_save() {
+ update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resourcse'] ) ? 1 : 0 );
+}
+
+add_action( 'init', 'sharing_init' );
+add_action( 'admin_init', 'sharing_add_meta_box' );
+add_action( 'save_post', 'sharing_meta_box_save' );
+add_action( 'sharing_email_send_post', 'sharing_email_send_post' );
+add_action( 'sharing_global_options', 'sharing_global_resources' );
+add_action( 'sharing_admin_update', 'shareing_global_resources_save' );
+add_filter( 'sharing_services', 'sharing_restrict_to_single' );
+add_action( 'plugin_action_links_'.basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 );
+add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 );
diff --git a/plugins/jetpack/modules/sharedaddy/sharedaddy.pot b/plugins/jetpack/modules/sharedaddy/sharedaddy.pot
new file mode 100644
index 00000000..7af247cb
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharedaddy.pot
@@ -0,0 +1,404 @@
+# Translation of the WordPress plugin Sharedaddy 0.2.9 by Automattic, Inc..
+# Copyright (C) 2010 Automattic, Inc.
+# This file is distributed under the same license as the Sharedaddy package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Sharedaddy 0.2.9\n"
+"Report-Msgid-Bugs-To: http://wordpress.org/tag/sharedaddy\n"
+"POT-Creation-Date: 2010-12-16 16:35+0000\n"
+"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: sharedaddy.php:14
+#, php-format
+msgid ""
+"%1$s (%2$s) thinks you may be interested in the following post:\n"
+"\n"
+msgstr ""
+
+#: sharedaddy.php:18
+msgid "Shared Post"
+msgstr ""
+
+#: sharedaddy.php:22 sharedaddy.php:23 sharing.php:49
+msgid "Sharing"
+msgstr ""
+
+#: sharedaddy.php:34
+msgid "Show sharing buttons on this post."
+msgstr ""
+
+#: sharedaddy.php:57 sharedaddy.php:64
+msgid "Settings"
+msgstr ""
+
+#: sharedaddy.php:65
+msgid "Support"
+msgstr ""
+
+#: sharedaddy.php:97
+msgid "Disable CSS and JS"
+msgstr ""
+
+#: sharedaddy.php:99
+msgid "Advanced - you must include these in your theme for Sharedaddy to work"
+msgstr ""
+
+#: sharing-service.php:194
+msgid "Share this:"
+msgstr ""
+
+#: sharing-service.php:434 sharing-sources.php:620 sharing.php:230
+#: sharing.php:271
+msgid "Share"
+msgstr ""
+
+#: sharing-sources.php:127
+msgid "Email"
+msgstr ""
+
+#: sharing-sources.php:169
+msgid "This post has been shared!"
+msgstr ""
+
+#: sharing-sources.php:170
+#, php-format
+msgid "You have shared this post with %s"
+msgstr ""
+
+#: sharing-sources.php:171
+msgid "Close"
+msgstr ""
+
+#: sharing-sources.php:193
+msgctxt "share to"
+msgid "Email"
+msgstr ""
+
+#: sharing-sources.php:193
+msgid "Click to email this to a friend"
+msgstr ""
+
+#: sharing-sources.php:207
+msgid "Send to Email Address"
+msgstr ""
+
+#: sharing-sources.php:215
+msgid "Your Name"
+msgstr ""
+
+#: sharing-sources.php:218
+msgid "Your Email Address"
+msgstr ""
+
+#: sharing-sources.php:226
+msgid "Send Email"
+msgstr ""
+
+#: sharing-sources.php:227
+msgid "Cancel"
+msgstr ""
+
+#: sharing-sources.php:230
+msgid "Post was not sent - check your email addresses!"
+msgstr ""
+
+#: sharing-sources.php:234
+msgid "Email check failed, please try again"
+msgstr ""
+
+#: sharing-sources.php:238
+msgid "Sorry, your blog cannot share posts by email."
+msgstr ""
+
+#: sharing-sources.php:257
+msgid "Twitter"
+msgstr ""
+
+#: sharing-sources.php:264
+msgctxt "share to"
+msgid "Twitter"
+msgstr ""
+
+#: sharing-sources.php:264
+msgid "Click to share on Twitter"
+msgstr ""
+
+#: sharing-sources.php:334 sharing-sources.php:411 sharing-sources.php:462
+#: sharing-sources.php:568
+msgid "Use smart button"
+msgstr ""
+
+#: sharing-sources.php:352
+msgid "StumbleUpon"
+msgstr ""
+
+#: sharing-sources.php:363
+msgctxt "share to"
+msgid "StumbleUpon"
+msgstr ""
+
+#: sharing-sources.php:363
+msgid "Click to share on StumbleUpon"
+msgstr ""
+
+#: sharing-sources.php:429 sharing-sources.php:436
+msgid "Reddit"
+msgstr ""
+
+#: sharing-sources.php:436
+msgid "Click to share on Reddit"
+msgstr ""
+
+#: sharing-sources.php:506
+msgid "Digg"
+msgstr ""
+
+#: sharing-sources.php:515 sharing-sources.php:519
+msgid "Click to Digg this post"
+msgstr ""
+
+#: sharing-sources.php:519
+msgctxt "share to"
+msgid "Digg"
+msgstr ""
+
+#: sharing-sources.php:601
+msgid "Facebook"
+msgstr ""
+
+#: sharing-sources.php:651
+msgctxt "share to"
+msgid "Facebook"
+msgstr ""
+
+#: sharing-sources.php:651
+msgid "Share on Facebook"
+msgstr ""
+
+#: sharing-sources.php:673
+msgid "Default button"
+msgstr ""
+
+#: sharing-sources.php:674
+msgid "Share button"
+msgstr ""
+
+#: sharing-sources.php:675
+msgid "Like button"
+msgstr ""
+
+#: sharing-sources.php:720
+msgid "Print"
+msgstr ""
+
+#: sharing-sources.php:724
+msgctxt "share to"
+msgid "Print"
+msgstr ""
+
+#: sharing-sources.php:724
+msgid "Click to print"
+msgstr ""
+
+#: sharing-sources.php:730
+msgid "Press This"
+msgstr ""
+
+#: sharing-sources.php:758
+msgctxt "share to"
+msgid "Press This"
+msgstr ""
+
+#: sharing-sources.php:758
+msgid "Click to Press This!"
+msgstr ""
+
+#: sharing-sources.php:789
+msgid "Click to share"
+msgstr ""
+
+#: sharing-sources.php:839
+msgid "Label"
+msgstr ""
+
+#: sharing-sources.php:844
+msgid "URL"
+msgstr ""
+
+#: sharing-sources.php:849
+msgid "Icon"
+msgstr ""
+
+#: sharing-sources.php:856
+msgid "Save"
+msgstr ""
+
+#: sharing-sources.php:857
+msgid "Remove Service"
+msgstr ""
+
+#: sharing.php:49 sharing.php:154
+msgid "Sharing Settings"
+msgstr ""
+
+#: sharing.php:144
+msgid "Warning! Multibyte support missing!"
+msgstr ""
+
+#: sharing.php:145
+#, php-format
+msgid ""
+"This plugin will work without it, but multibyte support is used <a href=\"%s"
+"\">if available</a>. You may see minor problems with Tweets and other "
+"sharing services."
+msgstr ""
+
+#: sharing.php:149
+msgid "Settings have been saved"
+msgstr ""
+
+#: sharing.php:160
+msgid "Available Services"
+msgstr ""
+
+#: sharing.php:161
+msgid "Drag and drop the services you'd like to enable into the box below."
+msgstr ""
+
+#: sharing.php:162
+msgid "Add a new service"
+msgstr ""
+
+#: sharing.php:182
+msgid "Enabled Services"
+msgstr ""
+
+#: sharing.php:185
+msgid "Services dragged here will appear individually."
+msgstr ""
+
+#: sharing.php:188
+msgid "Drag and drop available services here"
+msgstr ""
+
+#: sharing.php:199
+msgid "Services dragged here will be hidden behind a share button."
+msgstr ""
+
+#: sharing.php:214
+msgid "Live Preview"
+msgstr ""
+
+#: sharing.php:217
+msgid "Sharing is off. Please add services above to enable"
+msgstr ""
+
+#: sharing.php:299
+msgid "Default button style"
+msgstr ""
+
+#: sharing.php:302
+msgid "Icon + text"
+msgstr ""
+
+#: sharing.php:303
+msgid "Icon only"
+msgstr ""
+
+#: sharing.php:304
+msgid "Text only"
+msgstr ""
+
+#: sharing.php:309
+msgid "Sharing label"
+msgstr ""
+
+#: sharing.php:315
+msgid "Open links in"
+msgstr ""
+
+#: sharing.php:318
+msgid "New window"
+msgstr ""
+
+#: sharing.php:319
+msgid "Same window"
+msgstr ""
+
+#: sharing.php:324
+msgid "Show sharing buttons on"
+msgstr ""
+
+#: sharing.php:327
+msgid "Posts, pages, and index pages"
+msgstr ""
+
+#: sharing.php:328
+msgid "Posts and pages only"
+msgstr ""
+
+#: sharing.php:329
+msgid "Index pages only"
+msgstr ""
+
+#: sharing.php:339
+msgid "Save Changes"
+msgstr ""
+
+#: sharing.php:350
+msgid "Service name"
+msgstr ""
+
+#: sharing.php:356
+msgid "Sharing URL"
+msgstr ""
+
+#: sharing.php:360
+msgid "You can add the following variables to your service sharing URL:"
+msgstr ""
+
+#: sharing.php:365
+msgid "Icon URL"
+msgstr ""
+
+#: sharing.php:368
+msgid "Enter the URL of a 16x16px icon you want to use for this service."
+msgstr ""
+
+#: sharing.php:374
+msgid "Create Share"
+msgstr ""
+
+#: sharing.php:384
+msgid ""
+"An error occurred creating your new sharing service - please check you gave "
+"valid details."
+msgstr ""
+
+#. Plugin Name of the plugin/theme
+msgid "Sharedaddy"
+msgstr ""
+
+#. Plugin URI of the plugin/theme
+msgid "http://en.blog.wordpress.com/2010/08/24/more-ways-to-share/"
+msgstr ""
+
+#. Description of the plugin/theme
+msgid "The most super duper sharing tool on the interwebs."
+msgstr ""
+
+#. Author of the plugin/theme
+msgid "Automattic, Inc."
+msgstr ""
+
+#. Author URI of the plugin/theme
+msgid "http://automattic.com/"
+msgstr ""
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php
new file mode 100644
index 00000000..073044d4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php
@@ -0,0 +1,529 @@
+<?php
+
+include_once dirname( __FILE__ ).'/sharing-sources.php';
+
+define( 'WP_SHARING_PLUGIN_VERSION', '0.3' );
+
+class Sharing_Service {
+ private $global = false;
+
+ /**
+ * Gets a generic list of all services, without any config
+ */
+ public function get_all_services_blog() {
+ $options = get_option( 'sharing-options' );
+
+ $all = $this->get_all_services();
+ $services = array();
+
+ foreach ( $all AS $id => $name ) {
+ if ( isset( $all[$id] ) ) {
+ $config = array();
+
+ // Pre-load custom modules otherwise they won't know who they are
+ if ( substr( $id, 0, 7 ) == 'custom-' && is_array( $options[$id] ) )
+ $config = $options[$id];
+
+ $services[$id] = new $all[$id]( $id, $config );
+ }
+ }
+
+ return $services;
+ }
+
+ /**
+ * Gets a list of all available service names and classes
+ */
+ private function get_all_services() {
+ // Default services
+ $services = array(
+ 'email' => 'Share_Email',
+ 'print' => 'Share_Print',
+ 'digg' => 'Share_Digg',
+ 'facebook' => 'Share_Facebook',
+ 'linkedin' => 'Share_LinkedIn',
+ 'reddit' => 'Share_Reddit',
+ 'stumbleupon' => 'Share_Stumbleupon',
+ 'twitter' => 'Share_Twitter',
+ 'press-this' => 'Share_PressThis',
+ 'google-plus-1' => 'Share_GooglePlus1'
+ );
+
+ // Add any custom services in
+ $options = $this->get_global_options();
+ foreach ( (array)$options['custom'] AS $custom_id ) {
+ $services[$custom_id] = 'Share_Custom';
+ }
+
+ return apply_filters( 'sharing_services', $services );
+ }
+
+ public function new_service( $label, $url, $icon ) {
+ // Validate
+ $label = trim( wp_html_excerpt( wp_kses( $label, array() ), 30 ) );
+ $url = trim( esc_url_raw( $url ) );
+ $icon = trim( esc_url_raw( $icon ) );
+
+ if ( $label && $url && $icon ) {
+ $options = get_option( 'sharing-options' );
+ if ( !is_array( $options ) )
+ $options = array();
+
+ $service_id = 'custom-'.time();
+
+ // Add a new custom service
+ $options['global']['custom'][] = $service_id;
+
+ update_option( 'sharing-options', $options );
+
+ // Create a custom service and set the options for it
+ $service = new Share_Custom( $service_id, array( 'name' => $label, 'url' => $url, 'icon' => $icon ) );
+ $this->set_service( $service_id, $service );
+
+ // Return the service
+ return $service;
+ }
+
+ return false;
+ }
+
+ public function delete_service( $service_id ) {
+ $service = $this->get_service( $service_id );
+
+ if ( $service ) {
+ $options = get_option( 'sharing-options' );
+ if ( isset( $options[$service_id] ) )
+ unset( $options[$service_id] );
+
+ $key = array_search( $service_id, $options['global']['custom'] );
+ if ( $key !== false )
+ unset( $options['global']['custom'][$key] );
+
+ update_option( 'sharing-options', $options );
+ return true;
+ }
+
+ return false;
+ }
+
+ public function set_blog_services( array $visible, array $hidden ) {
+ $services = $this->get_all_services();
+ // Validate the services
+ $available = array_keys( $services );
+
+ // Only allow services that we have defined
+ $hidden = array_intersect( $hidden, $available );
+ $visible = array_intersect( $visible, $available );
+
+ // Ensure we don't have the same ones in hidden and visible
+ $hidden = array_diff( $hidden, $visible );
+
+ do_action( 'sharing_get_services_state', array(
+ 'services' => $services,
+ 'available' => $available,
+ 'hidden' => $hidden,
+ 'visible' => $visible,
+ 'currently_enabled' => $this->get_blog_services()
+ ) );
+
+ update_option( 'sharing-services', array( 'visible' => $visible, 'hidden' => $hidden ) );
+ }
+
+ public function get_blog_services() {
+ $options = get_option( 'sharing-options' );
+ $enabled = get_option( 'sharing-services' );
+ $services = $this->get_all_services();
+
+ if ( !is_array( $options ) )
+ $options = array( 'global' => $this->get_global_options() );
+
+ $global = $options['global'];
+
+ // Default services
+ if ( !is_array( $enabled ) ) {
+ $enabled = array(
+ 'visible' => array(),
+ 'hidden' => array()
+ );
+
+ $enabled = apply_filters( 'sharing_default_services', $enabled );
+ }
+
+ // Cleanup after any filters that may have produced duplicate services
+ $enabled['visible'] = array_unique( $enabled['visible'] );
+ $enabled['hidden'] = array_unique( $enabled['hidden'] );
+
+ // Form the enabled services
+ $blog = array( 'visible' => array(), 'hidden' => array() );
+
+ foreach ( $blog AS $area => $stuff ) {
+ foreach ( (array)$enabled[$area] AS $service ) {
+ if ( isset( $services[$service] ) ) {
+ $blog[$area][$service] = new $services[$service]( $service, array_merge( $global, isset( $options[$service] ) ? $options[$service] : array() ) );
+ }
+ }
+ }
+
+ $blog = apply_filters( 'sharing_services_enabled', $blog );
+
+ // Convenience for checking if a service is present
+ $blog['all'] = array_flip( array_merge( array_keys( $blog['visible'] ), array_keys( $blog['hidden'] ) ) );
+ return $blog;
+ }
+
+ public function get_service( $service_name ) {
+ $services = $this->get_blog_services();
+
+ if ( isset( $services['visible'][$service_name] ) )
+ return $services['visible'][$service_name];
+
+ if ( isset( $services['hidden'][$service_name] ) )
+ return $services['hidden'][$service_name];
+
+ return false;
+ }
+
+ public function set_global_options( $data ) {
+ $options = get_option( 'sharing-options' );
+
+ // No options yet
+ if ( ! is_array( $options ) )
+ $options = array();
+
+ // Defaults
+ $options['global'] = array(
+ 'button_style' => 'icon-text',
+ 'sharing_label' => __( 'Share this:', 'jetpack' ),
+ 'open_links' => 'same',
+ 'show' => array( 'post', 'page' ),
+ 'custom' => isset( $options['global']['custom'] ) ? $options['global']['custom'] : array()
+ );
+
+ $options['global'] = apply_filters( 'sharing_default_global', $options['global'] );
+
+ // Validate options and set from our data
+ if ( isset( $data['button_style'] ) && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text' ) ) )
+ $options['global']['button_style'] = $data['button_style'];
+
+ if ( isset( $data['sharing_label'] ) )
+ $options['global']['sharing_label'] = trim( wp_kses( stripslashes( $data['sharing_label'] ), array() ) );
+
+ if ( isset( $data['open_links'] ) && in_array( $data['open_links'], array( 'new', 'same' ) ) )
+ $options['global']['open_links'] = $data['open_links'];
+
+ $shows = array_values( get_post_types( array( 'public' => true ) ) );
+ $shows[] = 'index';
+
+ if ( isset( $data['show'] ) ) {
+ if ( is_scalar( $data['show'] ) ) {
+ switch ( $data['show'] ) {
+ case 'posts' :
+ $data['show'] = array( 'post', 'page' );
+ break;
+ case 'index' :
+ $data['show'] = array( 'index' );
+ break;
+ case 'posts-index' :
+ $data['show'] = array( 'post', 'page', 'index' );
+ break;
+ }
+ }
+
+ if ( $data['show'] = array_intersect( $data['show'], $shows ) ) {
+ $options['global']['show'] = $data['show'];
+ }
+ } else {
+ $options['global']['show'] = array();
+ }
+
+ update_option( 'sharing-options', $options );
+ return $options['global'];
+ }
+
+ public function get_global_options() {
+ if ( $this->global === false ) {
+ $options = get_option( 'sharing-options' );
+
+ if ( is_array( $options ) && isset( $options['global'] ) )
+ $this->global = $options['global'];
+ else
+ $this->global = $this->set_global_options( $options['global'] );
+ }
+
+ if ( ! isset( $this->global['show'] ) ) {
+ $this->global['show'] = array( 'post', 'page' );
+ } elseif ( is_scalar( $this->global['show'] ) ) {
+ switch ( $this->global['show'] ) {
+ case 'posts' :
+ $this->global['show'] = array( 'post', 'page' );
+ break;
+ case 'index' :
+ $this->global['show'] = array( 'index' );
+ break;
+ case 'posts-index' :
+ $this->global['show'] = array( 'post', 'page', 'index' );
+ break;
+ }
+ }
+ return $this->global;
+ }
+
+ public function set_service( $id, Sharing_Source $service ) {
+ // Update the options for this service
+ $options = get_option( 'sharing-options' );
+
+ // No options yet
+ if ( !is_array( $options ) )
+ $options = array();
+
+ do_action( 'sharing_get_button_state', array( 'id' => $id, 'options' => $options, 'service' => $service ) );
+
+ $options[$id] = $service->get_options();
+
+ update_option( 'sharing-options', array_filter( $options ) );
+ }
+
+ // Soon to come to a .org plugin near you!
+ public function get_total( $service_name = false, $post_id = false ) {
+ global $wpdb, $blog_id;
+ if ( $service_name == false ) {
+ if ( $post_id > 0 ) {
+ // total number of shares for this post
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
+ } else {
+ // total number of shares for this blog
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d", $blog_id ) );
+ }
+ }
+
+ if ( $post_id > 0 )
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $blog_id, $post_id, $service_name ) );
+ else
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $blog_id, $service_name ) );
+ }
+
+ public function get_services_total( $post_id = false ) {
+ $totals = array();
+ $services = $this->get_blog_services();
+
+ if ( !empty( $services ) && isset( $services[ 'all' ] ) )
+ foreach( $services[ 'all' ] as $key => $value ) {
+ $totals[$key] = new Sharing_Service_Total( $key, $this->get_total( $key, $post_id ) );
+ }
+ usort( $totals, array( 'Sharing_Service_Total', 'cmp' ) );
+
+ return $totals;
+ }
+
+ public function get_posts_total() {
+ $totals = array();
+ global $wpdb, $blog_id;
+
+ $my_data = $wpdb->get_results( $wpdb->prepare( "SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d GROUP BY post_id ORDER BY count DESC ", $blog_id ) );
+
+ if ( !empty( $my_data ) )
+ foreach( $my_data as $row )
+ $totals[] = new Sharing_Post_Total( $row->id, $row->total );
+
+ usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
+
+ return $totals;
+ }
+}
+
+class Sharing_Service_Total {
+ var $id = '';
+ var $name = '';
+ var $service = '';
+ var $total = 0;
+
+ public function Sharing_Service_Total( $id, $total ) {
+ $services = new Sharing_Service();
+ $this->id = esc_html( $id );
+ $this->service = $services->get_service( $id );
+ $this->total = (int) $total;
+
+ $this->name = $this->service->get_name();
+ }
+
+ static function cmp( $a, $b ) {
+ if ( $a->total == $b->total )
+ return $a->name < $b->name;
+ return $a->total < $b->total;
+ }
+}
+
+class Sharing_Post_Total {
+ var $id = 0;
+ var $total = 0;
+ var $title = '';
+ var $url = '';
+
+ public function Sharing_Post_Total( $id, $total ) {
+ $this->id = (int) $id;
+ $this->total = (int) $total;
+ $this->title = get_the_title( $this->id );
+ $this->url = get_permalink( $this->id );
+ }
+
+ static function cmp( $a, $b ) {
+ if ( $a->total == $b->total )
+ return $a->id < $b->id;
+ return $a->total < $b->total;
+ }
+}
+
+function sharing_add_footer() {
+ if ( apply_filters( 'sharing_js', true ) )
+ wp_print_scripts( 'sharing-js' );
+
+ $sharer = new Sharing_Service();
+ $enabled = $sharer->get_blog_services();
+ foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) {
+ $service->display_footer();
+ }
+}
+
+function sharing_add_header() {
+ $sharer = new Sharing_Service();
+ $enabled = $sharer->get_blog_services();
+
+ foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) {
+ $service->display_header();
+ }
+
+ if ( count( $enabled['all'] ) > 0 )
+ wp_enqueue_style( 'sharedaddy', plugin_dir_url( __FILE__ ) .'sharing.css' );
+}
+
+function sharing_process_requests() {
+ global $post;
+
+ // Only process if: single post and share=X defined
+ if ( ( is_page() || is_single() ) && isset( $_GET['share'] ) ) {
+ $sharer = new Sharing_Service();
+
+ $service = $sharer->get_service( $_GET['share'] );
+ if ( $service ) {
+ $service->process_request( $post, $_POST );
+ }
+ }
+}
+
+function sharing_display( $text = '' ) {
+ global $post, $wp_current_filter;
+
+ if ( is_preview() ) {
+ return $text;
+ }
+
+ if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
+ return $text;
+ }
+
+ $sharer = new Sharing_Service();
+ $global = $sharer->get_global_options();
+
+ $show = false;
+ if ( !is_feed() ) {
+ if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {
+ $show = true;
+ } elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_archive() || is_search() ) ) {
+ $show = true;
+ }
+ }
+
+ // Pass through a filter for final say so
+ $show = apply_filters( 'sharing_show', $show, $post );
+
+ // Disabled for this post?
+ $switched_status = get_post_meta( $post->ID, 'sharing_disabled', false );
+
+ if ( !empty( $switched_status ) )
+ $show = false;
+
+ $sharing_content = '';
+
+ if ( $show ) {
+ $enabled = $sharer->get_blog_services();
+
+ if ( count( $enabled['all'] ) > 0 ) {
+ global $post;
+
+ $dir = get_option( 'text_direction' );
+
+ // Wrapper
+ $sharing_content .= '<div class="snap_nopreview sharing robots-nocontent">';
+ $sharing_content .= '<ul>';
+
+ // Visible items
+ $visible = '';
+ foreach ( $enabled['visible'] AS $id => $service ) {
+ // Individual HTML for sharing service
+ $visible .= '<li class="share-'.$service->get_class().' share-regular">';
+ $visible .= $service->get_display( $post );
+ $visible .= '</li>';
+ }
+
+ $parts = array();
+ if ( $global['sharing_label'] != '' )
+ $parts[] = '<li class="sharing_label">'.$global['sharing_label'].'</li>';
+
+ $parts[] = $visible;
+ if ( count( $enabled['hidden'] ) > 0 )
+ $parts[] = '<li class="share-custom"><a href="#" class="sharing-anchor">'._x( 'Share', 'dropdown button', 'jetpack' ).'</a></li>';
+
+ if ( $dir == 'rtl' )
+ $parts = array_reverse( $parts );
+
+ $sharing_content .= implode( '', $parts );
+ $sharing_content .= '<li class="share-end"></li></ul>';
+
+ if ( count( $enabled['hidden'] ) > 0 ) {
+ $sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;';
+
+ if ( count( $enabled['hidden'] ) == 1 )
+ $sharing_content .= 'width:150px;';
+
+ $sharing_content .= '">';
+
+ if ( count( $enabled['hidden'] ) == 1 )
+ $sharing_content .= '<ul style="background-image:none;">';
+ else
+ $sharing_content .= '<ul>';
+
+ $count = 1;
+ foreach ( $enabled['hidden'] AS $id => $service ) {
+ // Individual HTML for sharing service
+ $sharing_content .= '<li class="share-'.$service->get_class().'">';
+ $sharing_content .= $service->get_display( $post );
+ $sharing_content .= '</li>';
+
+ if ( ( $count % 2 ) == 0 )
+ $sharing_content .= '<li class="share-end"></li>';
+
+ $count ++;
+ }
+
+ // End of wrapper
+ $sharing_content .= '<li class="share-end"></li></ul></div></div>';
+ }
+
+ $sharing_content .= '<div class="sharing-clear"></div></div>';
+
+ // Register our JS
+ wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), '0.1' );
+ add_action( 'wp_footer', 'sharing_add_footer' );
+ }
+ }
+
+ return $text.$sharing_content;
+}
+
+add_filter( 'the_content', 'sharing_display', 19 );
+add_filter( 'the_excerpt', 'sharing_display', 19 );
+
+// Register our CSS
+add_action( 'wp_head', 'sharing_add_header', 1 );
+
+add_action( 'template_redirect', 'sharing_process_requests' );
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
new file mode 100644
index 00000000..1eb18722
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
@@ -0,0 +1,1076 @@
+<?php
+
+abstract class Sharing_Source {
+ public $button_style;
+ protected $open_links;
+ protected $id;
+
+ public function __construct( $id, array $settings ) {
+ $this->id = $id;
+
+ if ( isset( $settings['button_style'] ) )
+ $this->button_style = $settings['button_style'];
+
+ if ( isset( $settings['open_links'] ) )
+ $this->open_links = $settings['open_links'];
+ }
+
+ public function get_id() {
+ return $this->id;
+ }
+
+ public function get_class() {
+ return $this->id;
+ }
+
+ public function has_custom_button_style() {
+ return false;
+ }
+
+ public function get_link( $url, $text, $title, $query = '' ) {
+ $klasses = array( 'share-'.$this->get_class() );
+
+ if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' )
+ $klasses[] = 'share-icon';
+
+ if ( $this->button_style == 'icon' ) {
+ $text = '';
+ $klasses[] = 'no-text';
+ }
+
+ if ( !empty( $query ) ) {
+ if ( stripos( $url, '?' ) === false )
+ $url .= '?'.$query;
+ else
+ $url .= '&amp;'.$query;
+ }
+
+ if ( $this->button_style == 'text' )
+ $klasses[] = 'no-icon';
+
+ return sprintf( '<a rel="nofollow" class="%s" href="%s"%s title="%s">%s</a>', implode( ' ', $klasses ), $url, ( $this->open_links == 'new' ) ? ' target="_blank"' : '', $title, $text );
+ }
+
+ abstract public function get_name();
+ abstract public function get_display( $post );
+
+ public function display_header() {
+ }
+
+ public function display_footer() {
+ }
+
+ public function has_advanced_options() {
+ return false;
+ }
+
+ public function display_preview() {
+ echo '<div class="option">';
+
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+
+ echo '</div>';
+ }
+
+ public function get_total( $post = false ) {
+ global $wpdb, $blog_id;
+
+ $name = strtolower( $this->get_id() );
+
+ if ( $post == false ) {
+ // get total number of shares for service
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $blog_id, $name ) );
+ }
+
+ //get total shares for a post
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $blog_id, $post->ID, $name ) );
+ }
+
+ public function get_posts_total() {
+ global $wpdb, $blog_id;
+
+ $totals = array();
+ $name = strtolower( $this->get_id() );
+
+ $my_data = $wpdb->get_results( $wpdb->prepare( "SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d AND share_service = %s GROUP BY post_id ORDER BY count DESC ", $blog_id, $name ) );
+
+ if ( !empty( $my_data ) )
+ foreach( $my_data as $row )
+ $totals[] = new Sharing_Post_Total( $row->id, $row->total );
+
+ usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
+
+ return $totals;
+ }
+
+ public function process_request( $post, array $post_data ) {
+ do_action( 'sharing_bump_stats', array( 'service' => $this, 'post' => $post ) );
+ }
+}
+
+abstract class Sharing_Advanced_Source extends Sharing_Source {
+ public function has_advanced_options() {
+ return true;
+ }
+
+ abstract public function display_options();
+ abstract public function update_options( array $data );
+ abstract public function get_options();
+}
+
+
+class Share_Email extends Sharing_Source {
+ public function get_name() {
+ return __( 'Email', 'jetpack' );
+ }
+
+ // Default does nothing
+ public function process_request( $post, array $post_data ) {
+ $ajax = false;
+ if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' )
+ $ajax = true;
+
+ $source_email = $target_email = $source_name = false;
+
+ if ( isset( $post_data['source_email'] ) && is_email( $post_data['source_email'] ) )
+ $source_email = $post_data['source_email'];
+
+ if ( isset( $post_data['target_email'] ) && is_email( $post_data['target_email'] ) )
+ $target_email = $post_data['target_email'];
+
+ if ( isset( $post_data['source_name'] ) )
+ $source_name = $post_data['source_name'];
+
+ // Test email
+ $error = 1; // Failure in data
+ if ( $source_email && $target_email && $source_name ) {
+ if ( apply_filters( 'sharing_email_check', true, $post, $post_data ) ) {
+ $data = array(
+ 'post' => $post,
+ 'source' => $source_email,
+ 'target' => $target_email,
+ 'name' => $source_name
+ );
+
+ if ( ( $data = apply_filters( 'sharing_email_can_send', $data ) ) !== false ) {
+ // Record stats
+ parent::process_request( $data['post'], $post_data );
+
+ do_action( 'sharing_email_send_post', $data );
+ }
+
+ // Return a positive regardless of whether the user is subscribed or not
+ if ( $ajax ) {
+?>
+<div class="response">
+ <div class="response-title"><?php _e( 'This post has been shared!', 'jetpack' ); ?></div>
+ <div class="response-sub"><?php printf( __( 'You have shared this post with %s', 'jetpack' ), esc_html( $target_email ) ); ?></div>
+ <div class="response-close"><a href="#" class="sharing_cancel"><?php _e( 'Close', 'jetpack' ); ?></a></div>
+</div>
+<?php
+ }
+ else
+ wp_safe_redirect( get_permalink( $post->ID ).'?shared=email' );
+
+ die();
+ }
+ else
+ $error = 2; // Email check failed
+ }
+
+ if ( $ajax )
+ echo $error;
+ else
+ wp_safe_redirect( get_permalink( $post->ID ).'?shared=email&msg=fail' );
+
+ die();
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Email', 'share to', 'jetpack' ), __( 'Click to email this to a friend', 'jetpack' ), 'share=email' );
+ }
+
+ /**
+ * Outputs the hidden email dialog
+ */
+
+ public function display_footer() {
+ global $current_user;
+
+ $visible = $status = false;
+?>
+ <div id="sharing_email" style="<?php if ( $visible === false ) echo 'display: none;'; ?>">
+ <form action="" method="post">
+ <label for="target_email"><?php _e( 'Send to Email Address', 'jetpack' ) ?></label>
+ <input type="text" name="target_email" id="target_email" value="" />
+
+ <?php if ( is_user_logged_in() ) : ?>
+ <input type="hidden" name="source_name" value="<?php echo esc_attr( $current_user->display_name ); ?>" />
+ <input type="hidden" name="source_email" value="<?php echo esc_attr( $current_user->user_email ); ?>" />
+ <?php else : ?>
+
+ <label for="source_name"><?php _e( 'Your Name', 'jetpack' ) ?></label>
+ <input type="text" name="source_name" id="source_name" value="" />
+
+ <label for="source_email"><?php _e( 'Your Email Address', 'jetpack' ) ?></label>
+ <input type="text" name="source_email" id="source_email" value="" />
+
+ <?php endif; ?>
+
+ <?php do_action( 'sharing_email_dialog', 'sharedaddy' ); ?>
+
+ <img style="float: right; display: none" class="loading" src="<?php echo plugin_dir_url( __FILE__ ); ?>images/loading.gif" alt="loading" width="16" height="16" />
+ <input type="submit" value="<?php _e( 'Send Email', 'jetpack' ); ?>" class="sharing_send" />
+ <a href="#cancel" class="sharing_cancel"><?php _e( 'Cancel', 'jetpack' ); ?></a>
+
+ <div class="errors errors-1" style="display: none;">
+ <?php _e( 'Post was not sent - check your email addresses!', 'jetpack' ); ?>
+ </div>
+
+ <div class="errors errors-2" style="display: none;">
+ <?php _e( 'Email check failed, please try again', 'jetpack' ); ?>
+ </div>
+
+ <div class="errors errors-3" style="display: none;">
+ <?php _e( 'Sorry, your blog cannot share posts by email.', 'jetpack' ); ?>
+ </div>
+ </form>
+ </div>
+<?php
+ }
+}
+
+class Share_Twitter extends Sharing_Advanced_Source {
+ private $smart = true;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = $settings['smart'];
+ }
+
+ public function get_name() {
+ return __( 'Twitter', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart == 'smart' )
+ return '<div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&amp;counturl=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) ) . '&amp;count=horizontal&amp;text=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . ': " style="width:97px; height:20px;"></iframe></div>';
+ else
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Twitter', 'share to', 'jetpack' ), __( 'Click to share on Twitter', 'jetpack' ), 'share=twitter' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $post_title = apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id );
+ $post_link = apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id );
+
+ $twitter_url = '';
+ if ( function_exists( 'mb_stripos' ) )
+ $mb = true;
+ else
+ $mb = false;
+
+ if ( ( $mb && ( mb_strlen( $post_title ) + 1 + mb_strlen( $post_link ) ) > 140 ) || ( !$mb && ( strlen( $post_title ) + 1 + strlen( $post_link ) ) > 140 ) ) {
+ if ( $mb ) {
+ $twitter_url = 'http://twitter.com/?status=' . rawurlencode( ( mb_substr( $post_title, 0, (140 - mb_strlen ( $post_link ) - 4 ) ) ) . '... ' . $post_link );
+ } else {
+ $twitter_url = 'http://twitter.com/?status=' . rawurlencode( ( substr( $post_title, 0, (140 - strlen ( $post_link ) - 4 ) ) ) . '... ' . $post_link );
+ }
+ }
+ else {
+ $twitter_url = 'http://twitter.com/?status=' . rawurlencode( $post_title . ' ' . $post_link );
+ }
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Twitter
+ wp_redirect( $twitter_url );
+ die();
+ }
+
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php
+ if ( !$this->smart ) {
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ }
+ ?>
+ </div>
+<?php
+ }
+
+ public function update_options( array $data ) {
+ $this->smart = false;
+
+ if ( isset( $data['smart'] ) )
+ $this->smart = true;
+ }
+
+ public function get_options() {
+ return array(
+ 'smart' => $this->smart
+ );
+ }
+
+ public function display_options() {
+?>
+ <div class="input">
+ <label>
+ <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/>
+
+ <?php _e( 'Use smart button', 'jetpack' ); ?>
+ </label>
+ </div>
+<?php
+ }
+}
+
+class Share_Stumbleupon extends Sharing_Advanced_Source {
+ private $smart = false;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = $settings['smart'];
+ }
+
+ public function get_name() {
+ return __( 'StumbleUpon', 'jetpack' );
+ }
+
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart == 'smart' )
+ return '<div class="stumbleupon_button"><iframe src="http://www.stumbleupon.com/badge/embed/1/?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&amp;title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:74px; height: 18px;" allowTransparency="true"></iframe></div>';
+ else
+ return $this->get_link( get_permalink( $post->ID ), _x( 'StumbleUpon', 'share to', 'jetpack' ), __( 'Click to share on StumbleUpon', 'jetpack' ), 'share=stumbleupon' );
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php
+ if ( !$this->smart ) {
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ }
+ ?>
+ </div>
+<?php
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $stumbleupon_url = 'http://www.stumbleupon.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Stumbleupon
+ wp_redirect( $stumbleupon_url );
+ die();
+ }
+
+ public function update_options( array $data ) {
+ $this->smart = false;
+
+ if ( isset( $data['smart'] ) )
+ $this->smart = true;
+ }
+
+ public function get_options() {
+ return array(
+ 'smart' => $this->smart
+ );
+ }
+
+ public function display_options() {
+?>
+ <div class="input">
+ <label>
+ <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/>
+
+ <?php _e( 'Use smart button', 'jetpack' ); ?>
+ </label>
+ </div>
+<?php
+ }
+}
+
+class Share_Reddit extends Sharing_Advanced_Source {
+ private $smart = false;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = $settings['smart'];
+ }
+
+ public function get_name() {
+ return __( 'Reddit', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart == 'smart' )
+ return '<div class="reddit_button"><iframe src="http://www.reddit.com/static/button/button1.html?width=120&amp;url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&amp;title=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '" height="22" width="120" scrolling="no" frameborder="0"></iframe></div>';
+ else
+ return $this->get_link( get_permalink( $post->ID ), __( 'Reddit', 'share to', 'jetpack' ), __( 'Click to share on Reddit', 'jetpack' ), 'share=reddit' );
+ }
+
+ public function update_options( array $data ) {
+ $this->smart = false;
+
+ if ( isset( $data['smart'] ) )
+ $this->smart = true;
+ }
+
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function get_options() {
+ return array(
+ 'smart' => $this->smart
+ );
+ }
+
+ public function display_options() {
+?>
+ <div class="input">
+ <label>
+ <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/>
+
+ <?php _e( 'Use smart button', 'jetpack' ); ?>
+ </label>
+ </div>
+<?php
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php
+ if ( !$this->smart ) {
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ }
+ ?>
+ </div>
+<?php
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $reddit_url = 'http://reddit.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Reddit
+ wp_redirect( $reddit_url );
+ die();
+ }
+}
+
+class Share_Digg extends Sharing_Advanced_Source {
+ private $smart = false;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = $settings['smart'];
+ }
+
+ public function get_name() {
+ return __( 'Digg', 'jetpack' );
+ }
+
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart ) {
+ $url = $this->get_link( 'http://digg.com/submit?url='. urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&amp;title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ), 'Digg', __( 'Click to Digg this post', 'jetpack' ) );
+ return '<div class="digg_button">' . str_replace( 'class="', 'class="DiggThisButton DiggCompact ', $url ) . '</div>';
+ }
+ else
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Digg', 'share to', 'jetpack' ), __( 'Click to Digg this post', 'jetpack' ), 'share=digg' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $digg_url = 'http://digg.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Digg
+ wp_redirect( $digg_url );
+ die();
+ }
+
+ public function display_header() {
+ if ( $this->smart ) {
+?>
+<script type="text/javascript">
+(function() {
+ var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
+ s.type = 'text/javascript';
+ s.async = true;
+ s.src = 'http://widgets.digg.com/buttons.js';
+ s1.parentNode.insertBefore(s, s1);
+})();
+</script>
+<?php
+ }
+ }
+
+ public function update_options( array $data ) {
+ $this->smart = false;
+
+ if ( isset( $data['smart'] ) )
+ $this->smart = true;
+ }
+
+ public function get_options() {
+ return array(
+ 'smart' => $this->smart
+ );
+ }
+
+ public function display_options() {
+?>
+ <div class="input">
+ <label>
+ <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/>
+
+ <?php _e( 'Use smart button', 'jetpack' ); ?>
+ </label>
+ </div>
+<?php
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php
+ if ( !$this->smart ) {
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ }
+ ?>
+ </div>
+<?php
+ }
+}
+
+class Share_LinkedIn extends Sharing_Advanced_Source {
+ private $smart = true;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = (bool) $settings['smart'];
+ }
+
+ public function get_name() {
+ return __( 'LinkedIn', 'jetpack' );
+ }
+
+ public function has_custom_button_style() {
+ return (bool) $this->smart;
+ }
+
+ public function display_header() {
+ }
+
+ public function get_display( $post ) {
+ static $added_linkedin_js = false;
+ $proto = ( is_ssl() ) ? 'https://' : 'http://';
+ $permalink = get_permalink( $post->ID );
+ $display = '';
+
+ if( $this->smart ) {
+
+ // So we don't spit out the linkedin js for each post on index pages
+ if( ! $added_linkedin_js ) {
+ $display .= sprintf( '<script type="text/javascript" src="%splatform.linkedin.com/in.js"></script>', $proto );
+ $added_linkedin_js = true;
+ }
+
+ $display .= sprintf( '<div class="linkedin_button"><script type="in/share" data-url="%s" data-counter="right"></script></div>', esc_url( $permalink ) );
+
+ } else {
+
+ $display = $this->get_link( $permalink, _x( 'LinkedIn', 'share to', 'jetpack' ), __( 'Click to share on LinkedIn', 'jetpack' ), 'share=linkedin' );
+
+ }
+ return $display;
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $post_link = apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id );
+
+ // http://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource}
+
+ $encoded_title = rawurlencode( $post->post_title );
+ if( strlen( $encoded_title ) > 200 )
+ $encoded_title = substr( $encoded_title, 0, 197 ) . '...';
+
+ $encoded_summary = rawurlencode( get_the_excerpt() );
+ if( strlen( $encoded_summary ) > 256 )
+ $encoded_summary = substr( $encoded_summary, 0, 253 ) . '...';
+
+ $source = get_bloginfo( 'name' );
+
+ $query = add_query_arg( array(
+ 'title' => $encoded_title,
+ 'url' => rawurlencode( $post_link ),
+ 'source' => rawurlencode( $source ),
+ 'summary' => $encoded_summary,
+ ) );
+
+ $linkedin_url = 'http://www.linkedin.com/shareArticle?mini=true' . $query;
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to LinkedIn
+ wp_redirect( $linkedin_url );
+ die();
+ }
+
+ public function update_options( array $data ) {
+ $this->smart = false;
+
+ if ( isset( $data['smart'] ) )
+ $this->smart = true;
+ }
+
+ public function get_options() {
+ return array(
+ 'smart' => $this->smart
+ );
+ }
+
+ public function display_options() {
+ ?><div class="input">
+ <label>
+ <input name="smart" type="checkbox"<?php checked( $this->smart ); ?>/>
+ <?php _e( 'Use smart button', 'jetpack' ); ?>
+ </label>
+ </div><?php
+ }
+
+ public function display_preview() {
+ ?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php
+ if ( ! $this->smart ) {
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ } ?>
+ </div><?php
+ }
+}
+
+class Share_Facebook extends Sharing_Advanced_Source {
+ private $share_type = 'default';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['share_type'] ) )
+ $this->share_type = $settings['share_type'];
+ }
+
+ public function get_name() {
+ return __( 'Facebook', 'jetpack' );
+ }
+
+ public function has_custom_button_style() {
+ return $this->share_type != 'default';
+ }
+
+ public function display_header() {
+ if ( $this->share_type == 'share' ) {
+ // Set the open graph description, otherwise Facebook may pick up some random text from the page
+ global $post;
+
+ if ( $post && $post->ID > 0 )
+ echo '<meta property="og:description" content="'.esc_attr( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ).'" />';
+ }
+ }
+
+ function guess_locale_from_lang( $lang ) {
+ $lang = strtolower( str_replace( '-', '_', $lang ) );
+ if ( 5 == strlen( $lang ) )
+ $lang = substr( $lang, 0, 3 ) . strtoupper( substr( $lang, 3, 2 ) ); // Already in xx_xx, just make sure it's uppered
+ else if ( 3 == strlen( $lang ) )
+ $lang = $lang; // Don't know what to do with these
+ else
+ $lang = $lang . '_' . strtoupper( $lang ); // Sometimes this gives a workable locale
+ return $lang;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->share_type == 'share' ) {
+ return '<div class="facebook_button"><a name="fb_share" rel="nofollow" type="button" share_url="' . apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) . '" href="http://www.facebook.com/sharer.php?u=' . rawurlencode( get_permalink( $post->ID ) ) . '&t=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '">'.__( 'Share' , 'jetpack' ).'</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>';
+ } else if ( $this->share_type == 'like' ) {
+ $url = 'http://www.facebook.com/plugins/like.php?href=' . rawurlencode( get_permalink( $post->ID ) ) . '&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=21';
+
+ // Default widths to suit English
+ $inner_w = 90;
+
+ // Locale-specific widths/overrides
+ $widths = array(
+ 'de' => array( 'width' => 100, 'locale' => 'de_DE' ),
+ 'da' => array( 'width' => 120, 'locale' => 'da_DK' ),
+ 'fi' => array( 'width' => 100, 'locale' => 'fi_FI' ),
+ );
+
+ $widths = apply_filters( 'sharing_facebook_like_widths', $widths );
+
+ // Fix the button to the blogs locale and then adjust the width
+ $locale = str_replace( '-', '_', get_locale() );
+
+ if ( isset( $widths[substr( $locale, 0, 2 )] ) ) {
+ $inner_w = $widths[substr( $locale, 0, 2 )]['width'];
+ $locale = $widths[substr( $locale, 0, 2 )]['locale'];
+ } else {
+ $locale = $this->guess_locale_from_lang( get_locale() );
+ }
+
+ if ( $locale && 'en_US' != $locale )
+ $url .= '&amp;locale=' . $locale;
+
+ $url .= '&amp;width='.$inner_w;
+ return '<div class="like_button"><iframe src="'.$url.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.( $inner_w + 6 ).'px; height:21px;" allowTransparency="true"></iframe></div>';
+ }
+
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Facebook', 'share to', 'jetpack' ), __( 'Share on Facebook', 'jetpack' ), 'share=facebook' );
+ }
+
+
+ public function update_options( array $data ) {
+ $this->share_type = 'default';
+
+ if ( isset( $data['share_type'] ) && in_array( $data['share_type'], array( 'default', 'like', 'share' ) ) )
+ $this->share_type = $data['share_type'];
+ }
+
+ public function get_options() {
+ return array(
+ 'share_type' => $this->share_type
+ );
+ }
+
+ public function display_options() {
+?>
+ <div class="input">
+ <label>
+ <select name="share_type">
+ <option value="default"<?php if ( $this->share_type == 'default' ) echo ' selected="selected"'; ?>><?php _e( 'Default button', 'jetpack' ); ?></option>
+ <option value="share"<?php if ( $this->share_type == 'share' ) echo ' selected="selected"'; ?>><?php _e( 'Share button', 'jetpack' ); ?></option>
+ <option value="like"<?php if ( $this->share_type == 'like' ) echo ' selected="selected"'; ?>><?php _e( 'Like button', 'jetpack' ); ?></option>
+ </select>
+ </label>
+ </div>
+<?php
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-<?php
+
+ if ( $this->share_type == 'share' ) {
+ echo ( 'on">' );
+ echo '&nbsp;';
+ }
+ elseif ( $this->share_type == 'like' ) {
+ echo ( 'like">' );
+ echo '&nbsp;';
+ }
+ else {
+ echo ( 'off">' );
+ if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
+ echo $this->get_name();
+ else
+ echo '&nbsp;';
+ }
+ ?>
+ </div>
+<?php
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $fb_url = 'http://www.facebook.com/sharer.php?u=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&t=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Facebook
+ wp_redirect( $fb_url );
+ die();
+ }
+}
+
+class Share_Print extends Sharing_Source {
+ public function get_name() {
+ return __( 'Print', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( get_permalink( $post->ID ). ( ( is_single() || is_page() ) ? '#print': '' ), _x( 'Print', 'share to', 'jetpack' ), __( 'Click to print', 'jetpack' ) );
+ }
+}
+
+class Share_PressThis extends Sharing_Source {
+ public function get_name() {
+ return __( 'Press This', 'jetpack' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ global $current_user;
+
+ $blogs = get_blogs_of_user( $current_user->ID );
+ if ( empty( $blogs ) ) {
+ wp_safe_redirect( get_permalink( $post->ID ) );
+ die();
+ }
+
+ $blog = current( $blogs );
+
+ $url = $blog->siteurl.'/wp-admin/press-this.php?u='.urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ).'&t='.urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ).'&v=4';
+
+ if ( isset( $_GET['sel'] ) )
+ $url .= '&s='.urlencode( $_GET['sel'] );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Press This
+ wp_safe_redirect( $url );
+ die();
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Press This', 'share to', 'jetpack' ), __( 'Click to Press This!', 'jetpack' ), 'share=press-this' );
+ }
+}
+
+class Share_GooglePlus1 extends Sharing_Source {
+ private $state = false;
+
+ public function get_name() {
+ return __( 'Google +1', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ return '<div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="' . esc_attr( get_permalink( $post->ID ) ) . '"></div></div>';
+ }
+
+ public function display_preview() {
+?>
+ <div class="option option-smart-on"></div>
+<?php
+ }
+
+ public function get_state() {
+ return $this->state;
+ }
+
+ public function process_request( $post, array $post_data ) {
+
+ if ( isset( $post_data['state'] ) ) {
+ $this->state = $post_data['state'];
+ }
+ // Record stats
+ parent::process_request( $post, $post_data );
+ die();
+ }
+
+ public function display_footer() {
+ global $post;
+?>
+ <script type="text/javascript" charset="utf-8">
+ function sharing_plusone( obj ) {
+ jQuery.ajax( {
+ url: '<?php echo get_permalink( $post->ID ) . '?share=google-plus-1'; ?>',
+ type: 'POST',
+ data: obj
+ } );
+ }
+ </script>
+ <script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
+<?php
+ }
+
+ public function get_total( $post = false ) {
+ global $wpdb, $blog_id;
+
+ $name = strtolower( $this->get_id() );
+
+ if ( $post == false ) {
+ // get total number of shares for service
+ return $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $blog_id, $name ) );
+ }
+
+ //get total shares for a post
+ return $wpdb->get_var( $wpdb->prepare( "SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $blog_id, $post->ID, $name ) );
+ }
+}
+
+class Share_Custom extends Sharing_Advanced_Source {
+ private $name;
+ private $icon;
+ private $url;
+
+ public function get_class() {
+ return 'custom';
+ }
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['name'] ) )
+ $this->name = $settings['name'];
+
+ if ( isset( $settings['icon'] ) )
+ $this->icon = $settings['icon'];
+
+ if ( isset( $settings['url'] ) )
+ $this->url = $settings['url'];
+ }
+
+ public function get_name() {
+ return $this->name;
+ }
+
+ public function get_display( $post ) {
+ $str = $this->get_link( get_permalink( $post->ID ), esc_html( $this->name ), __( 'Click to share', 'jetpack' ), 'share='.$this->id );
+ return str_replace( 'class="', 'style="background:url(' . esc_url( $this->icon ) . ') no-repeat center left;" class="', $str );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $url = $this->url;
+ $url = str_replace( '%post_url%', urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ), $url );
+ $url = str_replace( '%post_full_url%', urlencode( get_permalink( $post->ID ) ), $url );
+ $url = str_replace( '%post_title%', urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ), $url );
+
+ if ( strpos( $url, '%post_tags%' ) !== false ) {
+ $tags = get_the_tags( $post->ID );
+ $tagged = '';
+
+ if ( $tags ) {
+ foreach ( $tags AS $tag ) {
+ $tagged[] = urlencode( $tag->name );
+ }
+
+ $tagged = implode( ',', $tagged );
+ }
+
+ $url = str_replace( '%post_tags%', $tagged, $url );
+ }
+
+ if ( strpos( $url, '%post_excerpt%' ) !== false ) {
+ $url_excerpt = $post->post_excerpt;
+ if ( empty( $url_excerpt ) )
+ $url_excerpt = $post->post_content;
+
+ $url_excerpt = strip_tags( strip_shortcodes( $url_excerpt ) );
+ $url_excerpt = wp_html_excerpt( $url_excerpt, 100 );
+ $url_excerpt = rtrim( preg_replace( '/[^ .]*$/', '', $url_excerpt ) );
+ $url = str_replace( '%post_excerpt%', urlencode( $url_excerpt ), $url );
+ }
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect
+ wp_redirect( $url );
+ die();
+ }
+
+ public function display_options() {
+?>
+<div class="input">
+ <table class="form-table">
+ <tbody>
+ <tr>
+ <th scope="row"><?php _e( 'Label', 'jetpack' ); ?></th>
+ <td><input type="text" name="name" value="<?php echo esc_attr( $this->name ); ?>" /></td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e( 'URL', 'jetpack' ); ?></th>
+ <td><input type="text" name="url" value="<?php echo esc_attr( $this->url ); ?>" /></td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e( 'Icon', 'jetpack' ); ?></th>
+ <td><input type="text" name="icon" value="<?php echo esc_attr( $this->icon ); ?>" /></td>
+ </tr>
+
+ <tr>
+ <th scope="row"></th>
+ <td>
+ <input class="button-secondary" type="submit"value="<?php _e( 'Save', 'jetpack' ); ?>" />
+ <a href="#" class="remove"><small><?php _e( 'Remove Service', 'jetpack' ); ?></small></a>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<?php
+ }
+
+ public function update_options( array $data ) {
+ $name = trim( wp_html_excerpt( wp_kses( stripslashes( $data['name'] ), array() ), 30 ) );
+ $url = trim( esc_url_raw( $data['url'] ) );
+ $icon = trim( esc_url_raw( $data['icon'] ) );
+
+ if ( $name )
+ $this->name = $name;
+
+ if ( $url )
+ $this->url = $url;
+
+ if ( $icon )
+ $this->icon = $icon;
+ }
+
+ public function get_options() {
+ return array(
+ 'name' => $this->name,
+ 'icon' => $this->icon,
+ 'url' => $this->url,
+ );
+ }
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.css b/plugins/jetpack/modules/sharedaddy/sharing.css
new file mode 100644
index 00000000..e5874f29
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing.css
@@ -0,0 +1,278 @@
+.sharing {
+ padding: 0 0 10px 0;
+}
+
+.sharing_label {
+ line-height: 24px;
+ padding: 10px 10px 0 0;
+ float: left;
+ font-weight: bold;
+}
+
+.sharing ul, .sharing-hidden ul {
+ list-style: none outside none !important;
+ padding: 0 !important;
+ margin: 0 !important;
+ float: left;
+ text-indent: 0 !important;
+}
+
+.sharing li, .sharing-hidden li {
+ display: list-item !important;
+ list-style: none outside none !important;
+ float: left;
+ padding: 10px 0 0 0 !important;
+ margin: 0 10px 0 0 !important;
+ background: none !important;
+}
+
+.sharing li div, .sharing-hidden li div {
+ margin: 0 !important;
+}
+
+.sharing li:before, .sharing-hidden li:before {
+ content: none !important;
+}
+
+
+.sharing li a, .sharing-hidden li a {
+ padding: 0px 0 0 20px;
+ line-height: 24px;
+ display: block;
+}
+
+.sharing li.share-regular a, .sharing-hidden li a, .sharing li.share-regular a:hover, .sharing-hidden li a:hover {
+ border: none !important;
+}
+
+.share-custom a.sharing-anchor{
+ color: #666;
+ font-size:11px;
+ font-family: arial, tahoma, verdana, sans-serif;
+ text-decoration: none;
+}
+
+.sharing li.share-custom{
+
+}
+
+.sharing-hidden a{
+ color: #666;
+}
+
+.sharing a.share-twitter,.sharing-hidden a.share-twitter { background: url('images/twitter.png') no-repeat center left; }
+.sharing a.share-facebook,.sharing-hidden a.share-facebook { background: url('images/facebook.png') no-repeat center left; }
+.sharing a.share-email,.sharing-hidden a.share-email { background: url('images/email.png') no-repeat center left; }
+.sharing a.share-digg,.sharing-hidden a.share-digg { background: url('images/digg.png') no-repeat center left; }
+.sharing a.share-stumbleupon,.sharing-hidden a.share-stumbleupon { background: url('images/stumbleupon.png') no-repeat center left; }
+.sharing a.share-reddit,.sharing-hidden a.share-reddit { background: url('images/reddit.png') no-repeat center left; }
+.sharing a.share-print,.sharing-hidden a.share-print { background: url('images/print.png') no-repeat center left; }
+.sharing a.share-press-this,.sharing-hidden a.share-press-this { background: url('images/wordpress.png') no-repeat center left; }
+.sharing a.share-linkedin,.sharing-hidden a.share-linkedin { background: url('images/linkedin.png') no-repeat center left; }
+.sharing a.share-google-plus-1,.sharing-hidden a.share-google-plus-1 { background: url('images/googleplus1.png') no-repeat center left; }
+
+.sharing div.twitter_button { padding: 4px 0; }
+.sharing div.reddit_button { padding: 4px 0 0 0; }
+.sharing div.stumbleupon_button { padding: 4px; }
+.sharing div.digg_button { font-size: 0px; padding: 0 0 0 0; }
+.sharing div.facebook_button { font-size: 0px; padding: 5px 0; height: 18px;}
+.sharing div.like_button { font-size: 0px; padding: 4px 0; height: 18px;}
+.sharing div.linkedin_button { padding-top: 4px; line-height: 16px; }
+.sharing div.googleplus1_button { padding-top: 4px; line-height: 16px; }
+
+.sharing-hidden li {
+ width: 130px;
+}
+
+.sharing-hidden div.twitter_button { padding: 0; }
+.sharing-hidden div.reddit_button { padding: 0; }
+.sharing-hidden div.stumbleupon_button { padding: 0; }
+.sharing-hidden div.digg_button { font-size: 0px; padding: 0; }
+.sharing-hidden div.facebook_button { font-size: 0px; padding: 0;}
+.sharing-hidden div.like_button { font-size: 0px; padding: 0;}
+.sharing-hidden div.linkedin_button { padding: 0; }
+.sharing-hidden div.googleplus1_button { padding: 0; }
+
+
+.sharing div.facebook_button a, .sharing-hidden.facebook_button a {
+ line-height: none;
+ padding: 0;
+}
+
+#sharing_email {
+ background-color: #fff;
+ padding: 15px;
+ width: 312px;
+ position: absolute;
+ border: 2px solid #6e6e6e;
+ z-index: 1001;
+ text-align: left;
+}
+
+#sharing_email .errors {
+ color: #fff;
+ background-color: #771a09;
+ font-size: 11px;
+ padding: 5px 8px;
+ line-height: 11px;
+ margin: 10px 0 0 0;
+}
+
+#sharing_email label {
+ font-size: 11px;
+ color: #333;
+ font-weight: bold;
+ display: block;
+ padding: 0 0 4px 0;
+ text-align: left;
+}
+
+#sharing_email input[type="text"] {
+ width: 100%;
+ margin-bottom: 12px;
+}
+
+#sharing_email .sharing_send {
+}
+
+#sharing_email .sharing_cancel {
+ padding: 0 0 0 10px;
+ font-size: 11px;
+}
+
+#sharing_email .recaptcha {
+ width: 312px;
+ height: 123px;
+ margin: 10px 0 14px 0;
+}
+
+#sharing_background {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: black;
+ z-index: 1000;
+}
+
+.sharing-hidden {
+ padding: 10px 0 0 0;
+}
+
+.sharing-hidden .inner {
+ border: 2px solid #6e6e6e;
+ padding: 15px 0 15px 0;
+ background: #fff;
+ position: absolute;
+ top: 0;
+ left: 0;
+ margin: 0px !important;
+ width: 300px;
+ z-index: 1000;
+}
+
+.sharing-hidden ul {
+ background: white url('images/share-bg.png') repeat-y center center;
+ margin: 0 !important;
+}
+
+.sharing-hidden li {
+ padding-left:10px !important;
+ padding-right:10px !important;
+ padding-top:0px !important;
+ margin: 0 !important;
+ margin-bottom:10px !important;
+}
+
+.sharing-hidden li a {
+ padding-right: 20px;
+ font-size: 11px;
+ line-height: 16px;
+ display: block;
+ text-decoration: none !important;
+ border-bottom: 0px !important;
+
+}
+
+.sharing-hidden li a.no-text{
+ width: 16px;
+ height:16px;
+}
+
+.sharing li a.no-text{
+ width: 16px;
+ height: 16px;
+ margin-top: 4px;
+ padding: 0px !important;
+}
+
+.sharing li a.no-icon {
+ background: none !important;
+ padding-left: 0 !important;
+}
+
+.sharing li.share-end, .sharing-hidden li.share-end {
+ clear: both;
+ height: 0;
+ padding: 0px !important;
+ margin: 0px !important;
+ width: 0;
+ visibility: hidden;
+ float: none;
+}
+
+.sharing .sharing-anchor {
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border: 1px solid #d8d8d8;
+ float: left;
+ line-height: 20px;
+ padding: 0 8px 0 21px;
+ background: #fff url('images/sharing-hidden.png') no-repeat 0px center;
+ font-weight: normal;
+}
+
+.sharing-clear {
+ clear: left;
+}
+
+.response {
+}
+
+.response-title {
+ font-size: 12px;
+ line-height: 18px;
+ font-weight: bold;
+}
+
+.response-sub {
+ font-size: 11px;
+ line-height: 24px;
+}
+
+.response-close .sharing_cancel {
+ padding: 0px !important;
+}
+
+li.share-email, li.share-custom a.sharing-anchor {
+ display: none !important;
+}
+
+li.share-service-visible {
+ display: list-item !important;
+}
+
+li.share-custom a.sharing-anchor.share-service-visible {
+ display: inline !important;
+}
+
+/* =RTL
+-------------------------------------------------------------- */
+body.rtl .sharing ul {
+ float: right;
+}
+body.rtl .sharing li {
+ margin: 0 0 0 10px !important;
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js
new file mode 100644
index 00000000..90b19e8e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing.js
@@ -0,0 +1,234 @@
+(function($){
+ $.fn.extend( {
+ share_is_email: function( value ) {
+ return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test( this.val() );
+ }
+ } );
+
+ $( document ).ready(function() {
+ $( '.sharing a.sharing-anchor' ).click( function() {
+ return false;
+ } );
+
+ $( '.sharing a' ).each( function() {
+ if ( $( this ).attr( 'href' ) && $( this ).attr( 'href' ).indexOf( 'share=' ) != -1 )
+ $( this ).attr( 'href', $( this ).attr( 'href' ) + '&nb=1' );
+ } );
+
+ // Show hidden buttons
+ $( '.sharing a.sharing-anchor' ).hover( function() {
+ if ( $( this ).data( 'hasappeared' ) !== true ) {
+ var item = $( this ).parents( 'div:first' ).find( '.inner' );
+ var original = $( this );
+
+ // Create a timer to make the area appear if the mouse hovers for a period
+ var timer = setTimeout( function() {
+ $( '#sharing_email' ).slideUp( 200 );
+
+ $( item ).css( {
+ left: $( original ).position().left + 'px',
+ top: $( original ).position().top + $( original ).height() + 3 + 'px'
+ } ).slideDown( 200, function() {
+ // Mark the item as have being appeared by the hover
+ $( original ).data( 'hasappeared', true ).data( 'hasoriginal', true ).data( 'hasitem', false );
+
+ // Remove all special handlers
+ $( item ).mouseleave( handler_item_leave ).mouseenter( handler_item_enter );
+ $( original ).mouseleave( handler_original_leave ).mouseenter( handler_original_enter );
+
+ // Add a special handler to quickly close the item
+ $( original ).click( close_it );
+ } );
+
+ // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area
+ var handler_item_leave = function() {
+ $( original ).data( 'hasitem', false );
+
+ if ( $( original ).data( 'hasoriginal' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $( original ).data( 'timer2', timer );
+ }
+ };
+
+ var handler_item_enter = function() {
+ $( original ).data( 'hasitem', true );
+ clearTimeout( $( original ).data( 'timer2' ) );
+ }
+
+ var handler_original_leave = function() {
+ $( original ).data( 'hasoriginal', false );
+
+ if ( $( original ).data( 'hasitem' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $( original ).data( 'timer2', timer );
+ }
+ };
+
+ var handler_original_enter = function() {
+ $( original ).data( 'hasoriginal', true );
+ clearTimeout( $( original ).data( 'timer2' ) );
+ };
+
+ var close_it = function() {
+ item.slideUp( 200 );
+
+ // Clear all hooks
+ $( original ).unbind( 'mouseleave', handler_original_leave ).unbind( 'mouseenter', handler_original_enter );
+ $( item ).unbind( 'mouseleave', handler_item_leave ).unbind( 'mouseenter', handler_item_leave );
+ $( original ).data( 'hasappeared', false );
+ $( original ).unbind( 'click', close_it );
+ return false;
+ };
+ }, 200 );
+
+ // Remember the timer so we can detect it on the mouseout
+ $( this ).data( 'timer', timer );
+ }
+ }, function() {
+ // Mouse out - remove any timer
+ clearTimeout( $( this ).data( 'timer' ) );
+ $( this ).data( 'timer', false );
+ } );
+
+ // Add click functionality
+ $( '.sharing ul' ).each( function( item ) {
+ printUrl = function ( uniqueId, urlToPrint ) {
+ $( 'body:first' ).append( '<iframe style="position:fixed;top:100;left:100;height:1px;width:1px;border:none;" id="printFrame-' + uniqueId + '" name="printFrame-' + uniqueId + '" src="' + urlToPrint + '" onload="frames[\'printFrame-' + uniqueId + '\'].focus();frames[\'printFrame-' + uniqueId + '\'].print();"></iframe>' )
+ };
+
+ // Print button
+ $( this ).find( '.share-print a' ).click( function() {
+ ref = $( this ).attr( 'href' );
+
+ var do_print = function() {
+ if ( ref.indexOf( '#print' ) == -1 ) {
+ uid = new Date().getTime();
+ printUrl( uid , ref );
+ }
+ else
+ print();
+ }
+
+ // Is the button in a dropdown?
+ if ( $( this ).parents( '.sharing-hidden' ).length > 0 ) {
+ $( this ).parents( '.inner' ).slideUp( 0, function() {
+ do_print();
+ } );
+ }
+ else
+ do_print();
+
+ return false;
+ } );
+
+ // Press This button
+ $( this ).find( '.share-press-this a' ).click( function() {
+ var s = '';
+
+ if ( window.getSelection )
+ s = window.getSelection();
+ else if( document.getSelection )
+ s = document.getSelection();
+ else if( document.selection )
+ s = document.selection.createRange().text;
+
+ if ( s )
+ $( this ).attr( 'href', $( this ).attr( 'href' ) + '&sel=' + encodeURI( s ) );
+
+ if ( !window.open( $( this ).attr( 'href' ), 't', 'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570' ) )
+ document.location.href = $( this ).attr( 'href' );
+
+ return false;
+ } );
+
+ // Email button
+ $( this ).find( '.share-email a' ).click( function() {
+ var url = $( this ).attr( 'href' );
+
+ if ( $( '#sharing_email' ).is( ':visible' ) )
+ $( '#sharing_email' ).slideUp( 200 );
+ else {
+ $( '.sharing .inner' ).slideUp();
+
+ $( '#sharing_email .response' ).remove();
+ $( '#sharing_email form' ).show();
+ $( '#sharing_email form input[type=submit]' ).removeAttr( 'disabled' );
+ $( '#sharing_email form a.sharing_cancel' ).show();
+
+ // Show dialog
+ $( '#sharing_email' ).css( {
+ left: $( this ).offset().left + 'px',
+ top: $( this ).offset().top + $( this ).height() + 'px'
+ } ).slideDown( 200 );
+
+ // Hook up other buttons
+ $( '#sharing_email a.sharing_cancel' ).unbind( 'click' ).click( function() {
+ $( '#sharing_email .errors' ).hide();
+ $( '#sharing_email' ).slideUp( 200 );
+ $( '#sharing_background' ).fadeOut();
+ return false;
+ } );
+
+ // Submit validation
+ $( '#sharing_email input[type=submit]' ).unbind( 'click' ).click( function() {
+ var form = $( this ).parents( 'form' );
+
+ // Disable buttons + enable loading icon
+ $( this ).attr( 'disabled', 'disabled' );
+ form.find( 'a.sharing_cancel' ).hide();
+ form.find( 'img.loading' ).show();
+
+ $( '#sharing_email .errors' ).hide();
+ $( '#sharing_email .error' ).removeClass( 'error' );
+
+ if ( $( '#sharing_email input[name=source_email]' ).share_is_email() == false )
+ $( '#sharing_email input[name=source_email]' ).addClass( 'error' );
+
+ if ( $( '#sharing_email input[name=target_email]' ).share_is_email() == false )
+ $( '#sharing_email input[name=target_email]' ).addClass( 'error' );
+
+ if ( $( '#sharing_email .error' ).length == 0 ) {
+ // AJAX send the form
+ $.ajax( {
+ url: url,
+ type: 'POST',
+ data: form.serialize(),
+ success: function( response ) {
+ form.find( 'img.loading' ).hide();
+
+ if ( response == '1' || response == '2' || response == '3' ) {
+ $( '#sharing_email .errors-' + response ).show();
+ form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
+ form.find( 'a.sharing_cancel' ).show();
+ }
+ else {
+ $( '#sharing_email form' ).hide();
+ $( '#sharing_email' ).append( response );
+ $( '#sharing_email a.sharing_cancel' ).click( function() {
+ $( '#sharing_email' ).slideUp( 200 );
+ $( '#sharing_background' ).fadeOut();
+ return false;
+ } );
+ }
+ }
+ } );
+
+ return false;
+ }
+
+ form.find( 'img.loading' ).hide();
+ form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
+ form.find( 'a.sharing_cancel' ).show();
+ $( '#sharing_email .errors-1' ).show();
+
+ return false;
+ } );
+ }
+
+ return false;
+ } );
+ } );
+
+ $( 'li.share-email, li.share-custom a.sharing-anchor' ).addClass( 'share-service-visible' );
+ } );
+})( jQuery );
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.php b/plugins/jetpack/modules/sharedaddy/sharing.php
new file mode 100644
index 00000000..26422edc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing.php
@@ -0,0 +1,417 @@
+<?php
+
+class Sharing_Admin {
+ public function __construct() {
+ if ( !defined( 'WP_SHARING_PLUGIN_URL' ) ) {
+ define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
+ define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
+ }
+
+ require_once WP_SHARING_PLUGIN_DIR.'sharing-service.php';
+
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
+ add_action( 'admin_menu', array( $this, 'subscription_menu' ) );
+
+ // Catch AJAX
+ add_action( 'wp_ajax_sharing_save_services', array( $this, 'ajax_save_services' ) );
+ add_action( 'wp_ajax_sharing_save_options', array( $this, 'ajax_save_options' ) );
+ add_action( 'wp_ajax_sharing_new_service', array( $this, 'ajax_new_service' ) );
+ add_action( 'wp_ajax_sharing_delete_service', array( $this, 'ajax_delete_service' ) );
+ }
+
+ public function sharing_head() {
+ wp_enqueue_script( 'sharing-js', WP_SHARING_PLUGIN_URL.'admin-sharing.js', array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ), 1 );
+ wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL.'admin-sharing.css', false, WP_SHARING_PLUGIN_VERSION );
+
+ add_thickbox();
+ }
+
+ public function admin_init() {
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) )
+ $this->process_requests();
+ }
+
+ public function process_requests() {
+ if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
+ $sharer = new Sharing_Service();
+ $sharer->set_global_options( $_POST );
+ do_action( 'sharing_admin_update' );
+
+ wp_safe_redirect( admin_url( 'options-general.php?page=sharing&update=saved' ) );
+ die();
+ }
+ }
+
+ public function subscription_menu( $user ) {
+ $hook = add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'manage_options', 'sharing', array( $this, 'management_page' ) );
+
+ // Insert our CSS and JS
+ add_action( "load-$hook", array( $this, 'sharing_head' ) );
+ }
+
+ public function ajax_save_services() {
+ if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) && isset( $_POST['hidden'] ) && isset( $_POST['visible'] ) ) {
+ $sharer = new Sharing_Service();
+
+ $sharer->set_blog_services( explode( ',', $_POST['visible'] ), explode( ',', $_POST['hidden'] ) );
+ die();
+ }
+ }
+
+ public function ajax_new_service() {
+ if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['sharing_name'] ) && isset( $_POST['sharing_url'] ) && isset( $_POST['sharing_icon'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-new_service' ) ) {
+ $sharer = new Sharing_Service();
+ if ( $service = $sharer->new_service( $_POST['sharing_name'], $_POST['sharing_url'], $_POST['sharing_icon'] ) ) {
+ $this->output_service( $service->get_id(), $service );
+ echo '<!--->';
+ $service->button_style = 'icon-text';
+ $this->output_preview( $service );
+
+ die();
+ }
+ }
+
+ // Fail
+ die( '1' );
+ }
+
+ public function ajax_delete_service() {
+ if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_'.$_POST['service'] ) ) {
+ $sharer = new Sharing_Service();
+ $sharer->delete_service( $_POST['service'] );
+ }
+ }
+
+ public function ajax_save_options() {
+ if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_'.$_POST['service'] ) ) {
+ $sharer = new Sharing_Service();
+ $service = $sharer->get_service( $_POST['service'] );
+
+ if ( $service && $service instanceof Sharing_Advanced_Source ) {
+ $service->update_options( $_POST );
+
+ $sharer->set_service( $_POST['service'], $service );
+ }
+
+ $this->output_service( $service->get_id(), $service, true );
+ echo '<!--->';
+ $service->button_style = 'icon-text';
+ $this->output_preview( $service );
+ die();
+ }
+ }
+
+ public function output_preview( $service ) {
+ $klasses = array( 'advanced', 'preview-item');
+
+ if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
+ $klasses[] = 'preview-'.$service->get_class();
+
+ if ( $service->get_class() != $service->get_id() )
+ $klasses[] = 'preview-'.$service->get_id();
+ }
+
+ echo '<li class="'.implode( ' ', $klasses ).'">';
+ $service->display_preview();
+ echo '</li>';
+ }
+
+ public function output_service( $id, $service, $show_dropdown = false ) {
+?>
+ <li class="service advanced<?php if ( $show_dropdown ) echo ' options'; ?> share-<?php echo $service->get_class(); ?>" id="<?php echo $service->get_id(); ?>">
+ <span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span><?php if ( $service->has_advanced_options() ) : ?><span class="options-toggle" style="background: url(<?php echo admin_url( '/images/menu-bits.gif' ); ?>) no-repeat 0px -110px;">&nbsp;</span>
+ <br style="clear:both;" />
+ <div class="advanced-form">
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
+ <?php $service->display_options(); ?>
+
+ <input type="hidden" name="action" value="sharing_save_options" />
+ <input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" />
+
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_'.$id );?>" />
+ </form>
+ </div>
+ <?php endif; ?>
+ </li>
+<?php
+ }
+
+ public function management_page() {
+ $sharer = new Sharing_Service();
+ $enabled = $sharer->get_blog_services();
+ $global = $sharer->get_global_options();
+
+ $shows = array_values( get_post_types( array( 'public' => true ) ) );
+ array_unshift( $shows, 'index' );
+
+ if ( false == function_exists( 'mb_stripos' ) ) {
+ echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
+ echo "<p>" . sprintf( __( 'This plugin will work without it, but multibyte support is used <a href="%s">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ), "http://www.php.net/manual/en/mbstring.installation.php" ) . '</p></div>';
+ }
+
+ if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' )
+ echo '<div class="updated"><p>'.__( 'Settings have been saved', 'jetpack' ).'</p></div>';
+?>
+
+ <div class="wrap">
+ <div class="icon32" id="icon-options-general"><br /></div>
+ <h2><?php _e( 'Sharing Settings', 'jetpack' ); ?></h2>
+
+ <div id="services-config">
+ <table id="available-services">
+ <tr>
+ <td class="description">
+ <h3><?php _e( 'Available Services', 'jetpack' ); ?></h3>
+ <p><?php _e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
+ <p><a href="#TB_inline?height=395&amp;width=600&amp;inlineId=new-service" title="<?php echo esc_attr( __( 'Add a new service', 'jetpack' ) ); ?>" class="thickbox"><?php _e( 'Add a new service', 'jetpack' ); ?></a></p>
+ </td>
+ <td class="services">
+ <ul class="services-available" style="height: 100px;">
+ <?php foreach ( $sharer->get_all_services_blog() AS $id => $service ) : ?>
+ <?php
+ if ( !isset( $enabled['all'][$id] ) )
+ $this->output_service( $id, $service );
+ ?>
+ <?php endforeach; ?>
+ </ul>
+ <br class="clearing" />
+ </td>
+ </tr>
+ </table>
+
+ <table id="enabled-services">
+ <tr>
+ <td class="description">
+ <h3>
+ <?php _e( 'Enabled Services', 'jetpack' ); ?>
+ <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
+ </h3>
+ <p><?php _e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
+ </td>
+ <td class="services" id="share-drop-target">
+ <h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Drag and drop available services here', 'jetpack' ); ?></h2>
+
+ <ul class="services-enabled">
+ <?php foreach ( $enabled['visible'] AS $id => $service ) : ?>
+ <?php $this->output_service( $id, $service, true ); ?>
+ <?php endforeach; ?>
+
+ <li class="end-fix"></li>
+ </ul>
+ </td>
+ <td id="hidden-drop-target" class="services">
+ <p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
+
+ <ul class="services-hidden">
+ <?php foreach ( $enabled['hidden'] AS $id => $service ) : ?>
+ <?php $this->output_service( $id, $service, true ); ?>
+ <?php endforeach; ?>
+ <li class="end-fix"></li>
+ </ul>
+ </td>
+ </tr>
+ </table>
+
+ <table id="live-preview">
+ <tr>
+ <td class="description">
+ <h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3>
+ </td>
+ <td class="services">
+ <h2<?php if ( count( $enabled['all'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Sharing is off. Please add services above to enable', 'jetpack' ); ?></h2>
+
+ <ul class="preview">
+ <?php if ( count( $enabled['all'] ) > 0 ) : ?>
+ <li class="sharing-label"><?php echo esc_html( $global['sharing_label'] ); ?></li>
+ <?php endif; ?>
+
+ <?php foreach ( $enabled['visible'] AS $id => $service ) : ?>
+ <?php $this->output_preview( $service ); ?>
+ <?php endforeach; ?>
+
+ <?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
+ <li class="share-custom">
+ <a href="#" class="sharing-anchor"><?php _ex( 'Share', 'dropdown button', 'jetpack' ); ?></a>
+
+ <div class="sharing-hidden">
+ <div class="inner" style="display: none;">
+ <ul>
+ <?php
+ $count = 1;
+
+ foreach ( $enabled['hidden'] AS $id => $service ) {
+ $this->output_preview( $service );
+
+ if ( ( $count % 2 ) == 0 )
+ echo '<li class="share-end"></li>';
+
+ $count++;
+ }
+ ?>
+ <li class="share-end"></li>
+ </ul>
+ </div>
+ </div>
+ </li>
+ <?php endif; ?>
+ </ul>
+
+ <ul class="archive" style="display: none">
+ <li class="sharing-label"><?php echo esc_html( $global['sharing_label'] ); ?></li>
+
+ <?php foreach ( $sharer->get_all_services_blog() AS $id => $service ) : ?>
+ <?php
+ if ( isset( $enabled['visible'][$id] ) )
+ $service = $enabled['visible'][$id];
+ elseif ( isset( $enabled['hidden'][$id] ) )
+ $service = $enabled['hidden'][$id];
+
+ $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later
+ $this->output_preview( $service );
+ ?>
+ <?php endforeach; ?>
+
+ <li class="share-custom">
+ <a href="#" class="sharing-anchor"><?php _ex( 'Share', 'dropdown button', 'jetpack' ); ?></a>
+
+ <div class="sharing-hidden">
+ <div class="inner" style="display: none;">
+ <ul>
+ <li/>
+ </ul>
+ </div>
+ </div>
+ </li>
+ </ul>
+ <br class="clearing" />
+ </td>
+ </tr>
+ </table>
+
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="save-enabled-shares">
+ <input type="hidden" name="action" value="sharing_save_services" />
+ <input type="hidden" name="visible" value="<?php echo implode( ',', array_keys( $enabled['visible'] ) ); ?>" />
+ <input type="hidden" name="hidden" value="<?php echo implode( ',', array_keys( $enabled['hidden'] ) ); ?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
+ </form>
+ </div>
+
+ <form method="post" action="">
+ <table class="form-table">
+ <tbody>
+ <tr valign="top">
+ <th scope="row"><label><?php _e( 'Default button style', 'jetpack' ); ?></label></th>
+ <td>
+ <select name="button_style">
+ <option<?php if ( $global['button_style'] == 'icon-text' ) echo ' selected="selected"';?> value="icon-text"><?php _e( 'Icon + text', 'jetpack' ); ?></option>
+ <option<?php if ( $global['button_style'] == 'icon' ) echo ' selected="selected"';?> value="icon"><?php _e( 'Icon only', 'jetpack' ); ?></option>
+ <option<?php if ( $global['button_style'] == 'text' ) echo ' selected="selected"';?> value="text"><?php _e( 'Text only', 'jetpack' ); ?></option>
+ </select>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><label><?php _e( 'Sharing label', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><label><?php _e( 'Open links in', 'jetpack' ); ?></label></th>
+ <td>
+ <select name="open_links">
+ <option<?php if ( $global['open_links'] == 'new' ) echo ' selected="selected"';?> value="new"><?php _e( 'New window', 'jetpack' ); ?></option>
+ <option<?php if ( $global['open_links'] == 'same' ) echo ' selected="selected"';?> value="same"><?php _e( 'Same window', 'jetpack' ); ?></option>
+ </select>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><label><?php _e( 'Show sharing buttons on', 'jetpack' ); ?></label></th>
+ <td>
+ <?php
+ $br = false;
+ foreach ( $shows as $show ) :
+ if ( 'index' == $show ) {
+ $label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
+ } else {
+ $post_type_object = get_post_type_object( $show );
+ $label = $post_type_object->labels->name;
+ }
+ ?>
+ <?php if ( $br ) echo '<br />'; ?><label><input type="checkbox"<?php checked( in_array( $show, $global['show'] ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
+ <?php $br = true; endforeach; ?>
+ </td>
+ </tr>
+
+ <?php do_action( 'sharing_global_options' ); ?>
+ </tbody>
+ </table>
+
+ <p class="submit">
+ <input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'jetpack' ); ?>" />
+ </p>
+
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
+ </form>
+
+ <div id="new-service" style="display: none">
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-service-form">
+ <table class="form-table">
+ <tbody>
+ <tr valign="top">
+ <th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_name" size="40" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row" width="100"><label><?php _e( 'Sharing URL', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_url" size="40" />
+
+ <p><?php _e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
+ <code>%post_title%</code>, <code>%post_url%</code>, <code>%post_full_url%</code>, <code>%post_excerpt%</code>, <code>%post_full_url%</code>, <code>%post_tags%</code></p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row" width="100"><label><?php _e( 'Icon URL', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_icon" size="40" />
+ <p><?php _e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p>
+ </td>
+ </tr>
+ <tr valign="top" width="100">
+ <th scope="row"></th>
+ <td>
+ <input type="submit" class="button-secondary" value="<?php _e( 'Create Share', 'jetpack' ); ?>" />
+ <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
+ </td>
+ </tr>
+
+ <?php do_action( 'sharing_new_service_form' ); ?>
+ </tbody>
+ </table>
+
+ <div class="inerror" style="display: none; margin-top: 15px">
+ <p><?php _e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p>
+ </div>
+
+ <input type="hidden" name="action" value="sharing_new_service" />
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
+ </form>
+ </div>
+ </div>
+
+ <script type="text/javascript">
+ var sharing_loading_icon = '<?php echo esc_js( admin_url( "/images/loading.gif" ) ); ?>';
+ </script>
+<?php
+ }
+}
+
+function sharing_admin_init() {
+ global $sharing_admin;
+
+ $sharing_admin = new Sharing_Admin();
+}
+
+add_action( 'init', 'sharing_admin_init' );