summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/sharedaddy')
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.css191
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.js90
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.pngbin0 -> 2384 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/comments@2x.pngbin0 -> 1980 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/contact-form@2x.pngbin0 -> 1504 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/custom@2x.pngbin0 -> 2068 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/digg@2x.pngbin0 -> 1793 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/divider@2x.pngbin0 -> 1037 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/draggy@2x.pngbin0 -> 1030 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/email.pngbin1380 -> 316 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/email@2x.pngbin0 -> 1848 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/ember.pngbin653 -> 570 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.pngbin0 -> 1307 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/facebook@2x.pngbin0 -> 1533 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/googleplus1.pngbin1288 -> 574 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.pngbin0 -> 1815 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.pngbin0 -> 2245 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.pngbin0 -> 3828 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.pngbin0 -> 1694 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.pngbin0 -> 2589 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-smart.pngbin2566 -> 2245 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.pngbin0 -> 3828 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.pngbin0 -> 2404 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.pngbin0 -> 3574 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin.pngbin417 -> 381 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin@2x.pngbin0 -> 1865 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/more.pngbin0 -> 395 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/more@2x.pngbin0 -> 1719 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/pinterest.pngbin0 -> 6407 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/pinterest@2x.pngbin0 -> 2231 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/print.pngbin1485 -> 316 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/print@2x.pngbin0 -> 1973 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/reddit@2x.pngbin0 -> 2421 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/rss@2x.pngbin0 -> 2696 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/share-bg.pngbin938 -> 933 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/sharing-hidden.pngbin3696 -> 2929 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.pngbin0 -> 1027 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-digg.pngbin2024 -> 1644 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.pngbin0 -> 2068 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.pngbin0 -> 1751 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.pngbin0 -> 926 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.pngbin0 -> 2394 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-like.pngbin2108 -> 1965 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-like@2x.pngbin0 -> 2278 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-pinterest.pngbin0 -> 7463 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.pngbin0 -> 3480 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-reddit.pngbin2845 -> 2423 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.pngbin0 -> 3522 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.pngbin3199 -> 552 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.pngbin0 -> 2993 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-tumblr.pngbin0 -> 1568 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.pngbin0 -> 5032 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-twitter.pngbin3018 -> 1427 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.pngbin0 -> 3179 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/stumbleupon.pngbin818 -> 638 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.pngbin0 -> 2276 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/tumblr.pngbin0 -> 1941 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/tumblr@2x.pngbin0 -> 1847 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/twitter.pngbin485 -> 523 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/twitter@2x.pngbin0 -> 2223 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/wordpress.pngbin1621 -> 1586 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/wordpress@2x.pngbin0 -> 2265 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/recaptchalib.php277
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharedaddy.php68
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-service.php116
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-sources.php817
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.css595
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.js173
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.php206
69 files changed, 1612 insertions, 921 deletions
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.css b/plugins/jetpack/modules/sharedaddy/admin-sharing.css
index 80c4fb89..fd0e3d43 100644
--- a/plugins/jetpack/modules/sharedaddy/admin-sharing.css
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.css
@@ -57,7 +57,7 @@
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
padding: 5px 10px 5px 24px;
- margin-right: 10px;
+ margin-right: 5px !important;
cursor: move;
}
@@ -70,21 +70,78 @@
.preview {
float: left !important;
+ width: 98%;
}
+.services ul.preview li, .services ul.archive li {
+ border: none;
+}
+
+
+.services ul li#facebook, #available-services .preview-facebook div.option-smart-off{background: #FFF url(images/facebook.png) no-repeat 4px 5px;}
+.services ul li#twitter, #available-services .preview-twitter div.option-smart-off{background: #FFF url(images/twitter.png?1) no-repeat 4px 5px;}
+.services ul li#wordpress, #available-services .preview-wordpress{background: #FFF url(images/wordpress.png) no-repeat 4px 5px;}
+.services ul li#digg, #available-services .preview-digg div.option-smart-off{background: #FFF url(images/digg.png) no-repeat 4px 5px;}
+.services ul li#reddit, #available-services .preview-reddit div.option-smart-off{background: #FFF url(images/reddit.png) no-repeat 4px 5px;}
+.services ul li#stumbleupon, #available-services .preview-stumbleupon div.option-smart-off{background: #FFF url(images/stumbleupon.png) no-repeat 4px 5px;}
+.services ul li#email, #available-services .preview-email{background: #FFF url(images/email.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#print, #available-services .preview-print{background: #FFF url(images/print.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#press-this, #available-services .preview-press-this{background: #FFF url(images/wordpress.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#linkedin, #available-services .preview-linkedin div.option-smart-off{background: #FFF url(images/linkedin.png) no-repeat 4px 5px;}
+.services ul li#tumblr,#available-services .preview-tumblr{background: #FFF url(images/tumblr.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#google-plus-1,#available-services .preview-google-plus-1{background: #FFF url(images/googleplus1.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li#pinterest,#available-services .preview-pinterest{background: #FFF url(images/pinterest.png) no-repeat 4px 5px; padding-right: 10px;}
+.services ul li.share-custom, #available-services .preview-custom{background: #FFF url(images/custom.png) no-repeat 4px 5px; no-repeat 4px 5px; padding-right: 10px;}
+
+
+
+@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
+
+ .services ul li#facebook, #available-services .preview-facebook div.option-smart-off{background: #FFF url(images/facebook@2x.png) no-repeat 4px 5px;}
+ .services ul li#twitter, #available-services .preview-twitter div.option-smart-off{background: #FFF url(images/twitter@2x.png?1) no-repeat 4px 5px;}
+ .services ul li#wordpress, #available-services .preview-wordpress{background: #FFF url(images/wordpress@2x.png?1) no-repeat 4px 5px;}
+ .services ul li#digg, #available-services .preview-digg div.option-smart-off{background: #FFF url(images/digg@2x.png) no-repeat 4px 5px;}
+ .services ul li#reddit, #available-services .preview-reddit div.option-smart-off{background: #FFF url(images/reddit@2x.png) no-repeat 4px 5px;}
+ .services ul li#stumbleupon, #available-services .preview-stumbleupon div.option-smart-off{background: #FFF url(images/stumbleupon@2x.png) no-repeat 4px 5px;}
+ .services ul li#email, #available-services .preview-email{background: #FFF url(images/email@2x.png) no-repeat 4px 5px; padding-right: 10px;}
+ .services ul li#print, #available-services .preview-print{background: #FFF url(images/print@2x.png) no-repeat 4px 5px; padding-right: 10px;}
+ .services ul li#press-this, #available-services .preview-press-this{background: #FFF url(images/wordpress@2x.png) no-repeat 4px 5px; padding-right: 10px;}
+ .services ul li#linkedin, #available-services .preview-linkedin div.option-smart-off{background: #FFF url(images/linkedin@2x.png) no-repeat 4px 5px;}
+ .services ul li#tumblr,#available-services .preview-tumblr{background: #FFF url(images/tumblr@2x.png) no-repeat 4px 5px; padding-right: 10px;}
+ .services ul li#google-plus-1,#available-services .preview-google-plus-1{background: #FFF url(images/googleplus1@2x.png) no-repeat 4px 5px; padding-right: 10px;}
+ .services ul li#pinterest,#available-services .preview-pinterest{background: #FFF url(images/pinterest@2x.png) no-repeat 4px 5px; padding-right: 10px;}
+ .services ul li.share-custom, #available-services .preview-custom{background: #FFF url(images/custom@2x.png) no-repeat 4px 5px; no-repeat 4px 5px; padding-right: 10px;}
+
+ .services ul li#facebook, #available-services .preview-facebook div.option-smart-off,
+ .services ul li#twitter, #available-services .preview-twitter div.option-smart-off,
+ .services ul li#wordpress, #available-services .preview-wordpress,
+ .services ul li#digg, #available-services .preview-digg div.option-smart-off,
+ .services ul li#reddit, #available-services .preview-reddit div.option-smart-off,
+ .services ul li#stumbleupon, #available-services .preview-stumbleupon div.option-smart-off,
+ .services ul li#email, #available-services .preview-email,
+ .services ul li#print, #available-services .preview-print,
+ .services ul li#press-this, #available-services .preview-press-this,
+ .services ul li#linkedin, #available-services .preview-linkedin div.option-smart-off,
+ .services ul li#tumblr,#available-services .preview-tumblr,
+ .services ul li#google-plus-1,#available-services .preview-google-plus-1,
+ .services ul li#pinterest,#available-services .preview-pinterest,
+ .services ul li.share-custom, #available-services .preview-custom{
+ background-size: 16px 16px;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+}
-.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;}
/****************************************************************************/
@@ -96,77 +153,81 @@
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 {
+.preview li.preview-digg,
+.preview li.preview-reddit,
+.preview li.preview-stumbleupon,
+.preview li.preview-facebook,
+.preview li.preview-twitter,
+.preview li.preview-linkedin,
+.preview li.preview-tumblr {
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;
+ margin-top: 2px;
}
.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;
+ margin-top: 1px;
}
-.preview-facebook .option-smart-like {
+.preview-facebook .option-smart-on {
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;
+ background: #FFF url(images/smart-twitter.png?1) 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;
+ margin-top: 1px;
}
.preview-google-plus-1 .option-smart-on {
+ background: #FFF url(images/smart-googleplus1.png) no-repeat top left;
max-width: 70px;
- width: 15px;
- height: 15px;
- margin-top: 4px;
+ width: 60px;
+ height: 20px;
+}
+
+.preview-tumblr .option-smart-on {
+ background: #FFF url(images/smart-tumblr.png) no-repeat top left;
+ width: 62px;
+ height: 20px;
+}
+
+.preview-pinterest .option-smart-on {
+ background: #FFF url(images/smart-pinterest.png) no-repeat top left;
+ width: 58px;
+ height: 20px;
}
+div.sharedaddy .preview-google-plus-1 .no-text { width: 60px; }
+
.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;
@@ -217,38 +278,11 @@
.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;
@@ -262,11 +296,6 @@
margin-top:4px;
}
-
- .services ul li.options-open .advanced-form{
- display: block;
- }
-
.utility{
float: right;
padding-top:10px;
@@ -322,18 +351,12 @@
.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 {
@@ -351,3 +374,19 @@
border: 0;
padding: 4px 6px 0 0;
}
+
+#services-config a.remove {
+ background: #ddd;
+ color: #fff;
+ padding: 0px 4px 2px;
+ border-radius: 15px;
+ -moz-border-radius: 15px;
+ -webkit-border-radius: 15px;
+ text-decoration: none;
+ font-weight: bold;
+ font-size: 10px;
+}
+
+#services-config a.remove:hover {
+ background: #f00;
+}
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.js b/plugins/jetpack/modules/sharedaddy/admin-sharing.js
index 4a93eab8..a11d469f 100644
--- a/plugins/jetpack/modules/sharedaddy/admin-sharing.js
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.js
@@ -3,12 +3,11 @@
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' );
+ var item = $( '.sharing-hidden .inner' );
+ var original = $( this ).parents( 'li' );
// 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'
@@ -77,6 +76,7 @@
function update_preview() {
var item;
+ var button_style = $( '#button_style' ).val();
// Clear the live preview
$( '#live-preview ul.preview li' ).remove();
@@ -89,41 +89,45 @@
$( '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() );
+ $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive li.preview-' + service ).clone() );
}
} );
- // Add any preview items
+ // Add any hidden 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();
+ $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .share-more' ).parent().clone() );
+
+ $( '.sharing-hidden ul li' ).remove();
- // Add rest of the items
+ // Add hidden items into the inner panel
$( '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>' );
+ $( '.sharing-hidden .inner ul' ).append( $( '#live-preview ul.archive .preview-' + service ).clone() );
}
} );
enable_share_button();
}
+
+ $( '#live-preview div.sharedaddy' ).removeClass( 'sd-social-icon' );
+ $( '#live-preview li.advanced' ).removeClass( 'no-icon' );
// 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' );
+ if ( 'icon' == button_style ) {
+ $( '#live-preview ul.preview div span' ).html( '&nbsp;' ).parent().addClass( 'no-text' ); // Remove text label
+ $( '#live-preview div.sharedaddy' ).addClass( 'sd-social-icon' );
+ } else if ( 'official' == button_style ) {
+ $( '#live-preview ul.preview .advanced' ).each( function( i ) {
+ if ( !$( this ).hasClass( 'preview-press-this' ) && !$( this ).hasClass( 'preview-email' ) && !$( this ).hasClass( 'preview-print' ) && !$( this ).hasClass( 'share-custom' ) ) {
+ $( this ).find( '.option a span' ).html( '' ).parent().removeClass( 'sd-button' ).parent().attr( 'class', 'option option-smart-on' );
+ }
} );
- }
+ } else if ( 'text' == button_style ) {
+ $( '#live-preview li.advanced' ).addClass( 'no-icon' );
+ }
+
}
function sharing_option_changed() {
@@ -142,8 +146,6 @@
// 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 );
@@ -164,10 +166,6 @@
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();
@@ -264,18 +262,7 @@
$( '.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();
@@ -287,7 +274,7 @@
beforeSubmit: function() {
$( '#new-service-form .error' ).hide();
$( '#new-service-form img' ).show();
- $( '#new-service-form input[type=submit]' ).attr( 'disabled', true );
+ $( '#new-service-form input[type=submit]' ).prop( 'disabled', true );
},
success: function( response ) {
$( '#new-service-form img' ).hide();
@@ -295,31 +282,24 @@
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 );
+ $( '#new-service-form input[type=submit]' ).prop( 'disabled', false );
}
else {
- document.location.reload();
+ document.location = document.location.href.replace( /&create_new_service=true/i, '' );
}
}
}
);
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' );
+ $( '#services-config a.remove' ).unbind( 'click' ).click( function() {
+ var form = $( this ).parent().next();
- 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 ) {
+ form.ajaxSubmit( function( response ) {
// Remove the item
form.parents( 'li:first' ).fadeOut( function() {
$( this ).remove();
@@ -333,13 +313,13 @@
} );
}
- $( 'select[name=button_style]' ).change( function() {
+ $( '#button_style' ).change( function() {
update_preview();
return true;
- } );
+ } ).change();
$( 'input[name=sharing_label]' ).blur( function() {
- $('#live-preview ul.preview li.sharing-label').html( $( '<div/>' ).text( $( this ).val() ).html() );
+ $('#live-preview h3.sd-title').html( $( '<div/>' ).text( $( this ).val() ).html() );
} );
init_handlers();
diff --git a/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png b/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png
new file mode 100644
index 00000000..8c5858c0
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/comments@2x.png b/plugins/jetpack/modules/sharedaddy/images/comments@2x.png
new file mode 100644
index 00000000..7558243c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/comments@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png b/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png
new file mode 100644
index 00000000..504450fd
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/custom@2x.png b/plugins/jetpack/modules/sharedaddy/images/custom@2x.png
new file mode 100644
index 00000000..57521606
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/custom@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/digg@2x.png b/plugins/jetpack/modules/sharedaddy/images/digg@2x.png
new file mode 100644
index 00000000..db79f166
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/digg@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/divider@2x.png b/plugins/jetpack/modules/sharedaddy/images/divider@2x.png
new file mode 100644
index 00000000..1c985389
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/divider@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png b/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png
new file mode 100644
index 00000000..03c3ee91
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/email.png b/plugins/jetpack/modules/sharedaddy/images/email.png
index 2ea4d7b0..e7f69f6d 100644
--- a/plugins/jetpack/modules/sharedaddy/images/email.png
+++ b/plugins/jetpack/modules/sharedaddy/images/email.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/email@2x.png b/plugins/jetpack/modules/sharedaddy/images/email@2x.png
new file mode 100644
index 00000000..13f658c2
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/email@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/ember.png b/plugins/jetpack/modules/sharedaddy/images/ember.png
index 1a285a2a..4ab956e0 100644
--- a/plugins/jetpack/modules/sharedaddy/images/ember.png
+++ b/plugins/jetpack/modules/sharedaddy/images/ember.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png b/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png
new file mode 100644
index 00000000..59912d76
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png b/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png
new file mode 100644
index 00000000..a88a52f6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/googleplus1.png b/plugins/jetpack/modules/sharedaddy/images/googleplus1.png
index 22cb1df8..5f0a05e5 100644
--- a/plugins/jetpack/modules/sharedaddy/images/googleplus1.png
+++ b/plugins/jetpack/modules/sharedaddy/images/googleplus1.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.png b/plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.png
new file mode 100644
index 00000000..26054392
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png
new file mode 100644
index 00000000..92816042
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png
new file mode 100644
index 00000000..f8402fb6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png
new file mode 100644
index 00000000..4a09a2d1
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png
new file mode 100644
index 00000000..f995d57a
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
index a828ad6f..92816042 100644
--- a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png
new file mode 100644
index 00000000..f8402fb6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png
new file mode 100644
index 00000000..c5edb5e2
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png
new file mode 100644
index 00000000..06dcf8bc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin.png b/plugins/jetpack/modules/sharedaddy/images/linkedin.png
index 0d727c2c..79e3570c 100644
--- a/plugins/jetpack/modules/sharedaddy/images/linkedin.png
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png
new file mode 100644
index 00000000..b626250b
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/more.png b/plugins/jetpack/modules/sharedaddy/images/more.png
new file mode 100644
index 00000000..efe3bc7c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/more.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/more@2x.png b/plugins/jetpack/modules/sharedaddy/images/more@2x.png
new file mode 100644
index 00000000..a55e8e79
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/more@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/pinterest.png b/plugins/jetpack/modules/sharedaddy/images/pinterest.png
new file mode 100644
index 00000000..cd5e6940
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/pinterest.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png b/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png
new file mode 100644
index 00000000..5efebd91
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/print.png b/plugins/jetpack/modules/sharedaddy/images/print.png
index 19a245fa..5f4c53ba 100644
--- a/plugins/jetpack/modules/sharedaddy/images/print.png
+++ b/plugins/jetpack/modules/sharedaddy/images/print.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/print@2x.png b/plugins/jetpack/modules/sharedaddy/images/print@2x.png
new file mode 100644
index 00000000..7fa0c2a2
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/print@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png b/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png
new file mode 100644
index 00000000..03d005ae
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/rss@2x.png b/plugins/jetpack/modules/sharedaddy/images/rss@2x.png
new file mode 100644
index 00000000..812b9098
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/rss@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/share-bg.png b/plugins/jetpack/modules/sharedaddy/images/share-bg.png
index f74ed039..bfd196ff 100644
--- a/plugins/jetpack/modules/sharedaddy/images/share-bg.png
+++ 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
index 96072621..c87f825e 100644
--- a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png
+++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png
new file mode 100644
index 00000000..c8129fbc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
index ce654de4..8753421c 100644
--- a/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png
new file mode 100644
index 00000000..1a76fd5e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png
new file mode 100644
index 00000000..7fa8606c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.png b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.png
new file mode 100644
index 00000000..ba593f5a
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.png
new file mode 100644
index 00000000..0bb999a4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like.png b/plugins/jetpack/modules/sharedaddy/images/smart-like.png
index 98cfc345..e1ac8263 100644
--- a/plugins/jetpack/modules/sharedaddy/images/smart-like.png
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-like.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png
new file mode 100644
index 00000000..4b99fa57
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png
new file mode 100644
index 00000000..16138cfc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png
new file mode 100644
index 00000000..aab464d6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
index 4788a507..a8c4c6e6 100644
--- a/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png
new file mode 100644
index 00000000..5b1fa3eb
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
index 8851447c..922d84b9 100644
--- a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png
new file mode 100644
index 00000000..82f3b88c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png
new file mode 100644
index 00000000..ca902bdc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png
new file mode 100644
index 00000000..e5b39877
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
index e14da3e8..a5537328 100644
--- a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png
new file mode 100644
index 00000000..fcf26f40
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png
index af4e9564..5b4858f7 100644
--- a/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png
+++ b/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.png b/plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.png
new file mode 100644
index 00000000..8e05201d
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/tumblr.png b/plugins/jetpack/modules/sharedaddy/images/tumblr.png
new file mode 100644
index 00000000..cc4775c6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/tumblr.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png b/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png
new file mode 100644
index 00000000..31ee7847
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter.png b/plugins/jetpack/modules/sharedaddy/images/twitter.png
index 1734a8a4..ec41046e 100644
--- a/plugins/jetpack/modules/sharedaddy/images/twitter.png
+++ b/plugins/jetpack/modules/sharedaddy/images/twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png
new file mode 100644
index 00000000..cd4a0967
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress.png b/plugins/jetpack/modules/sharedaddy/images/wordpress.png
index 6b560450..c07bdb72 100644
--- a/plugins/jetpack/modules/sharedaddy/images/wordpress.png
+++ b/plugins/jetpack/modules/sharedaddy/images/wordpress.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png b/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png
new file mode 100644
index 00000000..563b5cbc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/recaptchalib.php b/plugins/jetpack/modules/sharedaddy/recaptchalib.php
new file mode 100644
index 00000000..a9716772
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/recaptchalib.php
@@ -0,0 +1,277 @@
+<?php
+/*
+ * This is a PHP library that handles calling reCAPTCHA.
+ * - Documentation and latest version
+ * http://recaptcha.net/plugins/php/
+ * - Get a reCAPTCHA API Key
+ * https://www.google.com/recaptcha/admin/create
+ * - Discussion group
+ * http://groups.google.com/group/recaptcha
+ *
+ * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
+ * AUTHORS:
+ * Mike Crawford
+ * Ben Maurer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * The reCAPTCHA server URL's
+ */
+define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
+define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
+define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
+
+/**
+ * Encodes the given data into a query string format
+ * @param $data - array of string elements to be encoded
+ * @return string - encoded request
+ */
+function _recaptcha_qsencode ($data) {
+ $req = "";
+ foreach ( $data as $key => $value )
+ $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
+
+ // Cut the last '&'
+ $req=substr($req,0,strlen($req)-1);
+ return $req;
+}
+
+
+
+/**
+ * Submits an HTTP POST to a reCAPTCHA server
+ * @param string $host
+ * @param string $path
+ * @param array $data
+ * @param int port
+ * @return array response
+ */
+function _recaptcha_http_post($host, $path, $data, $port = 80) {
+
+ $req = _recaptcha_qsencode ($data);
+
+ $http_request = "POST $path HTTP/1.0\r\n";
+ $http_request .= "Host: $host\r\n";
+ $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
+ $http_request .= "Content-Length: " . strlen($req) . "\r\n";
+ $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
+ $http_request .= "\r\n";
+ $http_request .= $req;
+
+ $response = '';
+ if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
+ die ('Could not open socket');
+ }
+
+ fwrite($fs, $http_request);
+
+ while ( !feof($fs) )
+ $response .= fgets($fs, 1160); // One TCP-IP packet
+ fclose($fs);
+ $response = explode("\r\n\r\n", $response, 2);
+
+ return $response;
+}
+
+
+
+/**
+ * Gets the challenge HTML (javascript and non-javascript version).
+ * This is called from the browser, and the resulting reCAPTCHA HTML widget
+ * is embedded within the HTML form it was called from.
+ * @param string $pubkey A public key for reCAPTCHA
+ * @param string $error The error given by reCAPTCHA (optional, default is null)
+ * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
+
+ * @return string - The HTML to be embedded in the user's form.
+ */
+function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
+{
+ if ($pubkey == null || $pubkey == '') {
+ die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+ }
+
+ if ($use_ssl) {
+ $server = RECAPTCHA_API_SECURE_SERVER;
+ } else {
+ $server = RECAPTCHA_API_SERVER;
+ }
+
+ $errorpart = "";
+ if ($error) {
+ $errorpart = "&amp;error=" . $error;
+ }
+ return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
+
+ <noscript>
+ <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
+ <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
+ <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
+ </noscript>';
+}
+
+
+
+
+/**
+ * A ReCaptchaResponse is returned from recaptcha_check_answer()
+ */
+class ReCaptchaResponse {
+ var $is_valid;
+ var $error;
+}
+
+
+/**
+ * Calls an HTTP POST function to verify if the user's guess was correct
+ * @param string $privkey
+ * @param string $remoteip
+ * @param string $challenge
+ * @param string $response
+ * @param array $extra_params an array of extra variables to post to the server
+ * @return ReCaptchaResponse
+ */
+function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
+{
+ if ($privkey == null || $privkey == '') {
+ die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+ }
+
+ if ($remoteip == null || $remoteip == '') {
+ die ("For security reasons, you must pass the remote ip to reCAPTCHA");
+ }
+
+
+
+ //discard spam submissions
+ if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
+ $recaptcha_response = new ReCaptchaResponse();
+ $recaptcha_response->is_valid = false;
+ $recaptcha_response->error = 'incorrect-captcha-sol';
+ return $recaptcha_response;
+ }
+
+ $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
+ array (
+ 'privatekey' => $privkey,
+ 'remoteip' => $remoteip,
+ 'challenge' => $challenge,
+ 'response' => $response
+ ) + $extra_params
+ );
+
+ $answers = explode ("\n", $response [1]);
+ $recaptcha_response = new ReCaptchaResponse();
+
+ if (trim ($answers [0]) == 'true') {
+ $recaptcha_response->is_valid = true;
+ }
+ else {
+ $recaptcha_response->is_valid = false;
+ $recaptcha_response->error = $answers [1];
+ }
+ return $recaptcha_response;
+
+}
+
+/**
+ * gets a URL where the user can sign up for reCAPTCHA. If your application
+ * has a configuration page where you enter a key, you should provide a link
+ * using this function.
+ * @param string $domain The domain where the page is hosted
+ * @param string $appname The name of your application
+ */
+function recaptcha_get_signup_url ($domain = null, $appname = null) {
+ return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
+}
+
+function _recaptcha_aes_pad($val) {
+ $block_size = 16;
+ $numpad = $block_size - (strlen ($val) % $block_size);
+ return str_pad($val, strlen ($val) + $numpad, chr($numpad));
+}
+
+/* Mailhide related code */
+
+function _recaptcha_aes_encrypt($val,$ky) {
+ if (! function_exists ("mcrypt_encrypt")) {
+ die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
+ }
+ $mode=MCRYPT_MODE_CBC;
+ $enc=MCRYPT_RIJNDAEL_128;
+ $val=_recaptcha_aes_pad($val);
+ return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
+}
+
+
+function _recaptcha_mailhide_urlbase64 ($x) {
+ return strtr(base64_encode ($x), '+/', '-_');
+}
+
+/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
+function recaptcha_mailhide_url($pubkey, $privkey, $email) {
+ if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
+ die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
+ "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
+ }
+
+
+ $ky = pack('H*', $privkey);
+ $cryptmail = _recaptcha_aes_encrypt ($email, $ky);
+
+ return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
+}
+
+/**
+ * gets the parts of the email to expose to the user.
+ * eg, given johndoe@example,com return ["john", "example.com"].
+ * the email is then displayed as john...@example.com
+ */
+function _recaptcha_mailhide_email_parts ($email) {
+ $arr = preg_split("/@/", $email );
+
+ if (strlen ($arr[0]) <= 4) {
+ $arr[0] = substr ($arr[0], 0, 1);
+ } else if (strlen ($arr[0]) <= 6) {
+ $arr[0] = substr ($arr[0], 0, 3);
+ } else {
+ $arr[0] = substr ($arr[0], 0, 4);
+ }
+ return $arr;
+}
+
+/**
+ * Gets html to display an email address given a public an private key.
+ * to get a key, go to:
+ *
+ * http://www.google.com/recaptcha/mailhide/apikey
+ */
+function recaptcha_mailhide_html($pubkey, $privkey, $email) {
+ $emailparts = _recaptcha_mailhide_email_parts ($email);
+ $url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
+
+ return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
+ "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
+
+}
+
+
+?> \ No newline at end of file
diff --git a/plugins/jetpack/modules/sharedaddy/sharedaddy.php b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
index a7146019..727005e7 100644
--- a/plugins/jetpack/modules/sharedaddy/sharedaddy.php
+++ b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
@@ -2,7 +2,7 @@
/*
Plugin Name: Sharedaddy
Description: The most super duper sharing tool on the interwebs.
-Version: 0.2.12
+Version: 0.3.1
Author: Automattic, Inc.
Author URI: http://automattic.com/
Plugin URI: http://en.blog.wordpress.com/2010/08/24/more-ways-to-share/
@@ -42,17 +42,19 @@ function sharing_meta_box_save( $post_id ) {
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' );
+ if ( isset( $_POST['post_type'] ) && ( 'post' == $_POST['post_type'] || 'page' == $_POST['post_type'] ) ) {
+ 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;
+
+ return $post_id;
}
function sharing_meta_box_protected( $protected, $meta_key, $meta_type ) {
@@ -99,28 +101,52 @@ function sharing_disable_js() {
return false;
}
+if ( !function_exists( 'sharing_register_post_for_share_counts' ) ) {
+ function sharing_register_post_for_share_counts() {}
+}
+
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>
+ <input id="disable_css" type="checkbox" name="disable_resources" <?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 );
+function sharing_global_resources_save() {
+ update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 );
+}
+
+function sharing_email_dialog() {
+ echo '<div class="recaptcha" id="sharing_recaptcha"></div><input type="hidden" name="recaptcha_public_key" id="recaptcha_public_key" value="'.(defined( 'RECAPTCHA_PUBLIC_KEY' ) ? esc_attr( RECAPTCHA_PUBLIC_KEY ) : '').'" />';
+}
+
+function sharing_email_check( $true, $post, $data ) {
+ require_once plugin_dir_path( __FILE__ ).'recaptchalib.php';
+
+ $recaptcha_result = recaptcha_check_answer( RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $data["recaptcha_challenge_field"], $data["recaptcha_response_field"] );
+
+ return $recaptcha_result->is_valid;
}
-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 );
+// Only run if PHP5
+if ( version_compare( phpversion(), '5.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', 'sharing_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 );
+
+ if ( defined( 'RECAPTCHA_PRIVATE_KEY' ) ) {
+ add_action( 'sharing_email_dialog', 'sharing_email_dialog' );
+ add_filter( 'sharing_email_check', 'sharing_email_check', 10, 3 );
+ }
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php
index 1b765cb6..82d7293d 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing-service.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php
@@ -2,7 +2,7 @@
include_once dirname( __FILE__ ).'/sharing-sources.php';
-define( 'WP_SHARING_PLUGIN_VERSION', '0.3' );
+define( 'WP_SHARING_PLUGIN_VERSION', '0.3.1' );
class Sharing_Service {
private $global = false;
@@ -46,7 +46,9 @@ class Sharing_Service {
'stumbleupon' => 'Share_Stumbleupon',
'twitter' => 'Share_Twitter',
'press-this' => 'Share_PressThis',
- 'google-plus-1' => 'Share_GooglePlus1'
+ 'google-plus-1' => 'Share_GooglePlus1',
+ 'tumblr' => 'Share_Tumblr',
+ 'pinterest' => 'Share_Pinterest',
);
// Add any custom services in
@@ -88,22 +90,16 @@ class Sharing_Service {
}
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;
- }
+ $options = get_option( 'sharing-options' );
+ if ( isset( $options[$service_id] ) )
+ unset( $options[$service_id] );
- return false;
+ $key = array_search( $service_id, $options['global']['custom'] );
+ if ( $key !== false )
+ unset( $options['global']['custom'][$key] );
+
+ update_option( 'sharing-options', $options );
+ return true;
}
public function set_blog_services( array $visible, array $hidden ) {
@@ -166,6 +162,10 @@ class Sharing_Service {
$blog = apply_filters( 'sharing_services_enabled', $blog );
+ // Add CSS for NASCAR
+ if ( count( $blog['visible'] ) || count( $blog['hidden'] ) )
+ add_filter( 'post_flair_block_css', 'post_flair_service_enabled_sharing' );
+
// Convenience for checking if a service is present
$blog['all'] = array_flip( array_merge( array_keys( $blog['visible'] ), array_keys( $blog['hidden'] ) ) );
return $blog;
@@ -187,7 +187,7 @@ class Sharing_Service {
$options = get_option( 'sharing-options' );
// No options yet
- if ( ! is_array( $options ) )
+ if ( !is_array( $options ) )
$options = array();
// Defaults
@@ -202,25 +202,17 @@ class Sharing_Service {
$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' ) ) )
+ if ( isset( $data['button_style'] ) && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text', 'official' ) ) )
$options['global']['button_style'] = $data['button_style'];
- if ( isset( $data['sharing_label'] ) ) {
- $new_label = trim( wp_kses( stripslashes( $data['sharing_label'] ), array() ) );
-
- if ( 0 === strcmp( $new_label, $options['global']['sharing_label'] ) ) {
- $options['global']['sharing_label'] = FALSE;
- } else {
- $options['global']['sharing_label'] = $new_label;
- }
- }
+ 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'] ) {
@@ -291,22 +283,25 @@ class Sharing_Service {
}
// Soon to come to a .org plugin near you!
- public function get_total( $service_name = false, $post_id = false ) {
+ public function get_total( $service_name = false, $post_id = false, $_blog_id = false ) {
global $wpdb, $blog_id;
+ if ( !$_blog_id ) {
+ $_blog_id = $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 ) );
+ 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 ) );
+ 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 ) );
+ 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 ) );
+ 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 ) {
@@ -398,10 +393,11 @@ function sharing_add_header() {
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' );
+ wp_enqueue_style( 'sharedaddy', plugin_dir_url( __FILE__ ) .'sharing.css', array(), WP_SHARING_PLUGIN_VERSION );
}
+add_action( 'wp_head', 'sharing_add_header', 1 );
function sharing_process_requests() {
global $post;
@@ -416,6 +412,7 @@ function sharing_process_requests() {
}
}
}
+add_action( 'template_redirect', 'sharing_process_requests' );
function sharing_display( $text = '' ) {
global $post, $wp_current_filter;
@@ -427,7 +424,7 @@ function sharing_display( $text = '' ) {
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
return $text;
}
-
+
$sharer = new Sharing_Service();
$global = $sharer->get_global_options();
@@ -448,7 +445,11 @@ function sharing_display( $text = '' ) {
if ( !empty( $switched_status ) )
$show = false;
-
+
+ // Allow to be used on P2 ajax requests for latest posts.
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && 'get_latest_posts' == $_REQUEST['action'] )
+ $show = true;
+
$sharing_content = '';
if ( $show ) {
@@ -460,29 +461,27 @@ function sharing_display( $text = '' ) {
$dir = get_option( 'text_direction' );
// Wrapper
- $sharing_content .= '<div class="snap_nopreview sharing robots-nocontent">';
- $sharing_content .= '<ul>';
+ $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';
+ if ( $global['sharing_label'] != '' )
+ $sharing_content .= '<h3 class="sd-title">' . $global['sharing_label'] . '</h3>';
+ $sharing_content .= '<div class="sd-content"><ul>';
// Visible items
$visible = '';
- foreach ( $enabled['visible'] AS $id => $service ) {
+ 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>';
+ $visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display( $post ) . '</li>';
}
$parts = array();
-
- if ( FALSE === $global['sharing_label'] ) {
- $parts[] = '<li class="sharing_label">' . __( 'Share this:', 'jetpack' ) . '</li>';
- } elseif ( '' != $global['sharing_label'] ) {
- $parts[] = '<li class="sharing_label">' . esc_html( $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 ( count( $enabled['hidden'] ) > 0 ) {
+ if ( count( $enabled['visible'] ) > 0 )
+ $expand = __( 'More', 'jetpack' );
+ else
+ $expand = __( 'Share', 'jetpack' );
+ $parts[] = '<li><a href="#" class="sharing-anchor sd-button share-more"><span>'.$expand.'</span></a></li>';
+ }
if ( $dir == 'rtl' )
$parts = array_reverse( $parts );
@@ -504,7 +503,7 @@ function sharing_display( $text = '' ) {
$sharing_content .= '<ul>';
$count = 1;
- foreach ( $enabled['hidden'] AS $id => $service ) {
+ 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 );
@@ -520,10 +519,10 @@ function sharing_display( $text = '' ) {
$sharing_content .= '<li class="share-end"></li></ul></div></div>';
}
- $sharing_content .= '<div class="sharing-clear"></div></div>';
+ $sharing_content .= '<div class="sharing-clear"></div></div></div></div>';
// Register our JS
- wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), '0.1' );
+ wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), '20120131' );
add_action( 'wp_footer', 'sharing_add_footer' );
}
}
@@ -533,8 +532,3 @@ function sharing_display( $text = '' ) {
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
index 2734d820..bd8b2eb9 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing-sources.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
@@ -2,6 +2,7 @@
abstract class Sharing_Source {
public $button_style;
+ public $smart;
protected $open_links;
protected $id;
@@ -13,6 +14,9 @@ abstract class Sharing_Source {
if ( isset( $settings['open_links'] ) )
$this->open_links = $settings['open_links'];
+
+ if ( isset( $settings['smart'] ) )
+ $this->smart = $settings['smart'];
}
public function get_id() {
@@ -27,8 +31,8 @@ abstract class Sharing_Source {
return false;
}
- public function get_link( $url, $text, $title, $query = '' ) {
- $klasses = array( 'share-'.$this->get_class() );
+ public function get_link( $url, $text, $title, $query = '', $id = false ) {
+ $klasses = array( 'share-'.$this->get_class(), 'sd-button' );
if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' )
$klasses[] = 'share-icon';
@@ -48,7 +52,15 @@ abstract class Sharing_Source {
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 );
+ return sprintf(
+ '<a rel="nofollow" class="%s" href="%s"%s title="%s"%s><span>%s</span></a>',
+ implode( ' ', $klasses ),
+ $url,
+ ( $this->open_links == 'new' ) ? ' target="_blank"' : '',
+ $title,
+ ( $id ? ' id="' . esc_attr( $id ) . '"' : '' ),
+ $text
+ );
}
abstract public function get_name();
@@ -65,14 +77,32 @@ abstract class Sharing_Source {
}
public function display_preview() {
- echo '<div class="option">';
+ $text = '&nbsp;';
+ if ( !$this->smart )
+ if ( $this->button_style != 'icon' )
+ $text = $this->get_name();
- if ( $this->button_style == 'text' || $this->button_style == 'icon-text' )
- echo $this->get_name();
- else
- echo '&nbsp;';
+ $klasses = array( 'share-'.$this->get_class(), 'sd-button' );
+
+ if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' )
+ $klasses[] = 'share-icon';
+
+ if ( $this->button_style == 'icon' )
+ $klasses[] = 'no-text';
- echo '</div>';
+ if ( $this->button_style == 'text' )
+ $klasses[] = 'no-icon';
+
+ $link = sprintf(
+ '<a rel="nofollow" class="%s" href="javascript:void(0);return false;" title="%s"><span>%s</span></a>',
+ implode( ' ', $klasses ),
+ $this->get_name(),
+ $text
+ );
+ ?>
+ <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>">
+ <?php echo $link; ?>
+ </div><?php
}
public function get_total( $post = false ) {
@@ -85,7 +115,7 @@ abstract class Sharing_Source {
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
+ // 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 ) );
}
@@ -109,6 +139,31 @@ abstract class Sharing_Source {
public function process_request( $post, array $post_data ) {
do_action( 'sharing_bump_stats', array( 'service' => $this, 'post' => $post ) );
}
+
+ public function js_dialog( $name, $params = array() ) {
+ $defaults = array(
+ 'menubar' => 1,
+ 'resizable' => 1,
+ 'width' => 600,
+ 'height' => 400,
+ );
+ $params = array_merge( $defaults, $params );
+ $opts = array();
+ foreach( $params as $key => $val ) {
+ $opts[] = "$key=$val";
+ }
+ $opts = implode( ',', $opts );
+ ?>
+ <script type="text/javascript" charset="utf-8">
+ jQuery(document).ready(function(){
+ jQuery( '.share-<?php echo $name; ?>' ).click(function(){
+ window.open( jQuery(this).attr( 'href' ), 'wpcom<?php echo $name; ?>', '<?php echo $opts; ?>' );
+ return false;
+ });
+ });
+ </script>
+ <?php
+ }
}
abstract class Sharing_Advanced_Source extends Sharing_Source {
@@ -123,6 +178,16 @@ abstract class Sharing_Advanced_Source extends Sharing_Source {
class Share_Email extends Sharing_Source {
+ var $shortname = 'email';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
+ }
+
public function get_name() {
return __( 'Email', 'jetpack' );
}
@@ -162,7 +227,7 @@ class Share_Email extends Sharing_Source {
do_action( 'sharing_email_send_post', $data );
}
- // Return a positive regardless of whether the user is subscribed or not
+ // Return a positive regardless of whether the user is subscribed or not
if ( $ajax ) {
?>
<div class="response">
@@ -196,13 +261,12 @@ class Share_Email extends Sharing_Source {
/**
* 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;'; ?>">
+ <div id="sharing_email" style="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="" />
@@ -220,9 +284,9 @@ class Share_Email extends Sharing_Source {
<?php endif; ?>
- <?php do_action( 'sharing_email_dialog', 'sharedaddy' ); ?>
+ <?php do_action( 'sharing_email_dialog', 'jetpack' ); ?>
- <img style="float: right; display: none" class="loading" src="<?php echo plugin_dir_url( __FILE__ ); ?>images/loading.gif" alt="loading" width="16" height="16" />
+ <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>
@@ -243,51 +307,90 @@ class Share_Email extends Sharing_Source {
}
}
-class Share_Twitter extends Sharing_Advanced_Source {
- private $smart = true;
-
+class Share_Twitter extends Sharing_Source {
+ var $shortname = 'twitter';
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( isset( $settings['smart'] ) )
- $this->smart = $settings['smart'];
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
}
public function get_name() {
return __( 'Twitter', 'jetpack' );
}
+ function sharing_twitter_via( $post ) {
+ return '';
+
+ // Default 'via' is always us.
+ $via = preg_replace( '/(https?:\/\/)|(\.)|(\/)/i', '', home_url() );
+
+ // Allow themes to customize the via
+ return apply_filters( 'sharing_twitter_via', $via, $post->ID );
+ }
+
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' );
- }
+ $via = $this->sharing_twitter_via( $post );
+
+ if ( $via ) {
+ $via = sprintf( '&via=%1$s', rawurlencode( $via ) );
+ } else {
+ $via = '';
+ }
+ if ( $this->smart ) {
+ return '<div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="' . esc_url( 'http://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&counturl=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) ) . '&count=horizontal&text=' . rawurlencode( $post->post_title . ':' ) . $via ) . '" style="width:101px; height:20px;"></iframe></div>';
+ } else {
+ if ( 'icon-text' == $this->button_style || 'text' == $this->button_style )
+ sharing_register_post_for_share_counts( $post->ID );
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Twitter', 'share to', 'jetpack' ), __( 'Click to share on Twitter', 'jetpack' ), 'share=twitter', 'sharing-twitter-' . $post->ID );
+ }
+ }
public function process_request( $post, array $post_data ) {
- $post_title = apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id );
+ $post_title = $post->post_title;
$post_link = apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id );
+
+ if ( function_exists( 'mb_stripos' ) ) {
+ $strlen = 'mb_strlen';
+ $substr = 'mb_substr';
+ } else {
+ $strlen = 'strlen';
+ $substr = 'substr';
+ }
- $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 );
- }
+ $via = $this->sharing_twitter_via( $post );
+ if ( $via ) {
+ $related = false;
+ $sig = " via @$via";
+ } else {
+ $via = false;
+ $related = false;
+ $sig = '';
}
- else {
- $twitter_url = 'http://twitter.com/?status=' . rawurlencode( $post_title . ' ' . $post_link );
+
+ $suffix_length = $strlen( " {$post_link}{$sig}" );
+
+ // $sig is handled by twitter in their 'via' argument.
+ // $post_link is handled by twitter in their 'url' argument.
+ if ( 140 < $strlen( $post_title ) + $suffix_length ) {
+ // The -1 is for "\xE2\x80\xA6", a UTF-8 ellipsis.
+ $text = $substr( $post_title, 0, 140 - $suffix_length - 1 ) . "\xE2\x80\xA6";
+ } else {
+ $text = $post_title;
}
-
+
// Record stats
parent::process_request( $post, $post_data );
+ $url = $post_link;
+ $twitter_url = add_query_arg(
+ urlencode_deep( compact( 'via', 'related', 'text', 'url' ) ),
+ sprintf( '%s://twitter.com/intent/tweet', ( is_ssl() ? 'https' : 'http' ) )
+ );
+
// Redirect to Twitter
wp_redirect( $twitter_url );
die();
@@ -296,56 +399,21 @@ class Share_Twitter extends Sharing_Advanced_Source {
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
+ public function display_footer() {
+ $this->js_dialog( $this->shortname, array( 'height' => 350 ) );
}
}
-class Share_Stumbleupon extends Sharing_Advanced_Source {
- private $smart = false;
-
+class Share_Stumbleupon extends Sharing_Source {
+ var $shortname = 'stumbleupon';
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( isset( $settings['smart'] ) )
- $this->smart = $settings['smart'];
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
}
public function get_name() {
@@ -357,29 +425,14 @@ class Share_Stumbleupon extends Sharing_Advanced_Source {
}
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>';
+ if ( $this->smart )
+ return '<div class="stumbleupon_button"><iframe src="http://www.stumbleupon.com/badge/embed/1/?url=' . urlencode( get_permalink( $post->ID ) ) . '&amp;title=' . urlencode( $post->post_title ) . '" 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 ) );
+ $stumbleupon_url = 'http://www.stumbleupon.com/submit?url=' . urlencode( get_permalink( $post->ID ) ) . '&title=' . urlencode( $post->post_title );
// Record stats
parent::process_request( $post, $post_data );
@@ -388,41 +441,17 @@ class Share_Stumbleupon extends Sharing_Advanced_Source {
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;
-
+class Share_Reddit extends Sharing_Source {
+ var $shortname = 'reddit';
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( isset( $settings['smart'] ) )
- $this->smart = $settings['smart'];
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
}
public function get_name() {
@@ -430,58 +459,14 @@ class Share_Reddit extends Sharing_Advanced_Source {
}
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>';
+ if ( $this->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( $post->post_title ) . '" 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 ) );
+ $reddit_url = 'http://reddit.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( $post->post_title );
// Record stats
parent::process_request( $post, $post_data );
@@ -492,14 +477,15 @@ class Share_Reddit extends Sharing_Advanced_Source {
}
}
-class Share_Digg extends Sharing_Advanced_Source {
- private $smart = false;
-
+class Share_Digg extends Sharing_Source {
+ var $shortname = 'digg';
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( isset( $settings['smart'] ) )
- $this->smart = $settings['smart'];
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
}
public function get_name() {
@@ -512,15 +498,15 @@ class Share_Digg extends Sharing_Advanced_Source {
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' ) );
+ $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( $post->post_title ), 'Digg', __( 'Click to Digg this post' ) );
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' ), 'share=digg' );
}
- 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 ) );
+ $digg_url = 'http://digg.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( $post->post_title );
// Record stats
parent::process_request( $post, $post_data );
@@ -545,56 +531,17 @@ class Share_Digg extends Sharing_Advanced_Source {
<?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;
-
+class Share_LinkedIn extends Sharing_Source {
+ var $shortname = 'linkedin';
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( isset( $settings['smart'] ) )
- $this->smart = (bool) $settings['smart'];
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
}
public function get_name() {
@@ -602,37 +549,28 @@ class Share_LinkedIn extends Sharing_Advanced_Source {
}
public function has_custom_button_style() {
- return (bool) $this->smart;
- }
-
- public function display_header() {
+ return $this->smart;
}
-
+
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;
- }
-
+ if ( $this->smart )
$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' );
-
- }
+ else
+ $display = $this->get_link( $permalink, _x( 'LinkedIn', 'share to', 'jetpack' ), __( 'Click to share on LinkedIn', 'jetpack' ), 'share=linkedin', 'sharing-linkedin-' . $post->ID );
+
+ if ( 'icon-text' == $this->button_style || 'text' == $this->button_style )
+ sharing_register_post_for_share_counts( $post->ID );
+
return $display;
}
public function process_request( $post, array $post_data ) {
+
+ setup_postdata( $post );
+
$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}
@@ -641,7 +579,7 @@ class Share_LinkedIn extends Sharing_Advanced_Source {
if( strlen( $encoded_title ) > 200 )
$encoded_title = substr( $encoded_title, 0, 197 ) . '...';
- $encoded_summary = rawurlencode( get_the_excerpt() );
+ $encoded_summary = rawurlencode( strip_tags( get_the_excerpt() ) );
if( strlen( $encoded_summary ) > 256 )
$encoded_summary = substr( $encoded_summary, 0, 253 ) . '...';
@@ -664,43 +602,16 @@ class Share_LinkedIn extends Sharing_Advanced_Source {
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
+ public function display_footer() {
+ if ( !$this->smart )
+ $this->js_dialog( $this->shortname, array( 'width' => 580, 'height' => 450 ) );
+ else
+ echo '<script type="text/javascript" src="//platform.linkedin.com/in.js"></script>';
}
}
-class Share_Facebook extends Sharing_Advanced_Source {
+class Share_Facebook extends Sharing_Source {
+ var $shortname = 'facebook';
private $share_type = 'default';
public function __construct( $id, array $settings ) {
@@ -708,54 +619,46 @@ class Share_Facebook extends Sharing_Advanced_Source {
if ( isset( $settings['share_type'] ) )
$this->share_type = $settings['share_type'];
+
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
}
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 ) {
if ( 'en' == $lang || 'en_US' == $lang || !$lang ) {
return 'en_US';
}
-
+
if ( !class_exists( 'GP_Locales' ) ) {
require JETPACK__PLUGIN_DIR . 'locales.php';
}
-
+
// Jetpack: get_locale() returns 'it_IT';
$locale = GP_Locales::by_field( 'wp_locale', $lang );
-
+
if ( !$locale || empty( $locale->facebook_locale ) ) {
return false;
}
-
+
return $locale->facebook_locale;
}
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' ) {
+ if ( $this->smart ) {
$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(
'bg_BG' => 120,
@@ -770,14 +673,13 @@ class Share_Facebook extends Sharing_Advanced_Source {
);
$widths = apply_filters( 'sharing_facebook_like_widths', $widths );
-
- // Fix the button to the blogs locale and then adjust the width
+
$locale = $this->guess_locale_from_lang( get_locale() );
if ( $locale ) {
if ( 'en_US' != $locale ) {
$url .= '&amp;locale=' . $locale;
}
-
+
if ( isset( $widths[$locale] ) ) {
$inner_w = $widths[$locale];
}
@@ -786,64 +688,14 @@ class Share_Facebook extends Sharing_Advanced_Source {
$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
+
+ if ( 'icon-text' == $this->button_style || 'text' == $this->button_style )
+ sharing_register_post_for_share_counts( $post->ID );
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Facebook', 'share to', 'jetpack' ), __( 'Share on Facebook', 'jetpack' ), 'share=facebook', 'sharing-facebook-' . $post->ID );
}
- 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 ) );
+ $fb_url = 'http://www.facebook.com/sharer.php?u=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&t=' . urlencode( $post->post_title );
// Record stats
parent::process_request( $post, $post_data );
@@ -852,9 +704,23 @@ class Share_Facebook extends Sharing_Advanced_Source {
wp_redirect( $fb_url );
die();
}
+
+ public function display_footer() {
+ $this->js_dialog( $this->shortname );
+ }
}
class Share_Print extends Sharing_Source {
+ var $shortname = 'print';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
+ }
+
public function get_name() {
return __( 'Print', 'jetpack' );
}
@@ -865,6 +731,16 @@ class Share_Print extends Sharing_Source {
}
class Share_PressThis extends Sharing_Source {
+ var $shortname = 'pressthis';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
+ }
+
public function get_name() {
return __( 'Press This', 'jetpack' );
}
@@ -874,13 +750,13 @@ class Share_PressThis extends Sharing_Source {
$blogs = get_blogs_of_user( $current_user->ID );
if ( empty( $blogs ) ) {
- wp_safe_redirect( get_permalink( $post->ID ) );
+ 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';
+ $url = $blog->siteurl.'/wp-admin/press-this.php?u='.urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ).'&t='.urlencode( $post->post_title ).'&v=4';
if ( isset( $_GET['sel'] ) )
$url .= '&s='.urlencode( $_GET['sel'] );
@@ -898,28 +774,42 @@ class Share_PressThis extends Sharing_Source {
}
}
-class Share_GooglePlus1 extends Sharing_Source {
+class Share_GooglePlus1 extends Sharing_Source {
+ var $shortname = 'googleplus1';
private $state = false;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = 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>';
- }
+ // Smart or not, return the G+ button
+ return '<div class="googleplus1_button"><g:plusone size="medium" callback="sharing_plusone" href="' . esc_attr( get_permalink( $post->ID ) ) . '"></g:plusone></div>';
+ }
public function display_preview() {
-?>
- <div class="option option-smart-on"></div>
-<?php
+ ?>
+ <div class="option option-smart-on">
+ <a href="javascript:void(0);return false;" class="share-<?php echo $this->shortname; ?>">
+ <span></span>
+ </a>
+ </div><?php
}
public function get_state() {
return $this->state;
}
- public function process_request( $post, array $post_data ) {
+ public function process_request( $post, array $post_data ) {
if ( isset( $post_data['state'] ) ) {
$this->state = $post_data['state'];
@@ -964,6 +854,8 @@ class Share_Custom extends Sharing_Advanced_Source {
private $name;
private $icon;
private $url;
+ public $smart = true;
+ var $shortname;
public function get_class() {
return 'custom';
@@ -971,9 +863,13 @@ class Share_Custom extends Sharing_Advanced_Source {
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
+
+ $opts = $this->get_options();
- if ( isset( $settings['name'] ) )
+ if ( isset( $settings['name'] ) ) {
$this->name = $settings['name'];
+ $this->shortname = preg_replace( '/[^a-z0-9]*/', '', $settings['name'] );
+ }
if ( isset( $settings['icon'] ) )
$this->icon = $settings['icon'];
@@ -988,14 +884,14 @@ class Share_Custom extends Sharing_Advanced_Source {
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 );
+ return str_replace( '<span>', '<span style="background-image:url(' . esc_url( $this->icon ) . ');">', $str );
}
public function process_request( $post, array $post_data ) {
- $url = $this->url;
+ $url = str_replace( '&amp;', '&', $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 );
+ $url = str_replace( '%post_title%', urlencode( $post->post_title ), $url );
if ( strpos( $url, '%post_tags%' ) !== false ) {
$tags = get_the_tags( $post->ID );
@@ -1054,7 +950,7 @@ class Share_Custom extends Sharing_Advanced_Source {
<tr>
<th scope="row"></th>
<td>
- <input class="button-secondary" type="submit"value="<?php _e( 'Save', 'jetpack' ); ?>" />
+ <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>
@@ -1086,4 +982,163 @@ class Share_Custom extends Sharing_Advanced_Source {
'url' => $this->url,
);
}
+
+ public function display_preview() {
+ $opts = $this->get_options();
+
+ $text = '&nbsp;';
+ if ( !$this->smart )
+ if ( $this->button_style != 'icon' )
+ $text = $this->get_name();
+
+ $klasses = array( 'share-'.$this->shortname );
+
+ if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' )
+ $klasses[] = 'share-icon';
+
+ if ( $this->button_style == 'icon' ) {
+ $text = '';
+ $klasses[] = 'no-text';
+ }
+
+ if ( $this->button_style == 'text' )
+ $klasses[] = 'no-icon';
+
+ $link = sprintf(
+ '<a rel="nofollow" class="%s" href="javascript:void(0);return false;" title="%s"><span style="background-image:url(%s) !important;background-position:left center;background-repeat:no-repeat;">%s</span></a>',
+ implode( ' ', $klasses ),
+ $this->get_name(),
+ esc_url( $opts['icon'] ),
+ $text
+ );
+ ?>
+ <div class="option option-smart-off">
+ <?php echo $link ; ?>
+ </div><?php
+ }
+}
+
+
+class Share_Tumblr extends Sharing_Source {
+ var $shortname = 'tumblr';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
+ }
+
+ public function get_name() {
+ return __( 'Tumblr', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart )
+ return '<a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:62px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;">Share on Tumblr</a>';
+ else
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Tumblr's sharing endpoint (a la their bookmarklet)
+ $url = 'http://www.tumblr.com/share?v=3&u=' . rawurlencode( get_permalink( $post->ID ) ) . '&t=' . rawurlencode( $post->post_title ) . '&s=';
+ wp_redirect( $url );
+ die();
+ }
+ // http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s=
+ public function display_footer() {
+ if ( $this->smart ) {
+ ?><script type="text/javascript" src="http://platform.tumblr.com/v1/share.js"></script><?php
+ } else {
+ $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ }
+ }
+}
+
+class Share_Pinterest extends Sharing_Source {
+ var $shortname = 'pinterest';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style )
+ $this->smart = true;
+ else
+ $this->smart = false;
+ }
+
+ public function get_name() {
+ return __( 'Pinterest', 'jetpack' );
+ }
+
+ public function get_post_image( $content ) {
+ $image = '';
+
+ if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
+ $thumb_id = get_post_thumbnail_id();
+ $thumb = wp_get_attachment_image_src( $thumb_id );
+ $image = remove_query_arg( array('w', 'h'), $thumb[0] );
+ } else if ( preg_match_all('/<img (.+?)>/', $content, $matches) ) {
+ foreach ( $matches[1] as $attrs ) {
+ $media = $img = array();
+ foreach ( wp_kses_hair( $attrs, array( 'http', 'https' ) ) as $attr )
+ $img[$attr['name']] = $attr['value'];
+ if ( !isset( $img['src'] ) || 0 !== strpos( $img['src'], 'http' ) ) {
+ continue;
+ }
+ else {
+ $image = $img['src'];
+ break;
+ }
+ }
+ }
+
+ return $image;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart )
+ return '<div class="pinterest_button"><a href="http://pinterest.com/pin/create/button/?url='. rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&description=' . rawurlencode( esc_attr( $post->post_title ) ) . '&media=' . rawurlencode( esc_url( $this->get_post_image( $post->post_content ) ) ) . '" class="pin-it-button" count-layout="horizontal"> '. __( 'Pin It', 'sharedaddy') .'</a></div>';
+ else
+ return $this->get_link( get_permalink( $post->ID ), _x( 'Pinterest', 'share to', 'jetpack' ), __( 'Click to share on Pinterest', 'jetpack' ), 'share=pinterest' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $pinterest_url = 'http://pinterest.com/pin/create/button/?url=' . rawurlencode( get_permalink( $post->ID ) ) . '&description=' . rawurlencode( esc_attr( $post->post_title ) ) . '&media=' . rawurlencode( esc_url( $this->get_post_image( $post->post_content ) ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Pinterest
+ wp_redirect( $pinterest_url );
+ die();
+ }
+
+ public function display_footer() {
+ if ( !$this->smart ) {
+ $this->js_dialog( $this->shortname, array( 'width' => 650, 'height' => 280 ) );
+ } else {
+?>
+ <script type="text/javascript">
+ function pinterest_async_load() {
+ var s = document.createElement("script");
+ s.type = "text/javascript";
+ s.async = true;
+ s.src = window.location.protocol + "//assets.pinterest.com/js/pinit.js";
+ var x = document.getElementsByTagName("script")[0];
+ x.parentNode.insertBefore(s, x);
+ }
+ jQuery(document).on('ready post-load', function() {
+ pinterest_async_load();
+ });
+ </script>
+<?php
+ }
+ }
+
+
}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.css b/plugins/jetpack/modules/sharedaddy/sharing.css
index e5874f29..fb45c924 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.css
+++ b/plugins/jetpack/modules/sharedaddy/sharing.css
@@ -1,271 +1,485 @@
-.sharing {
- padding: 0 0 10px 0;
+div.sharedaddy ul,
+div.sharedaddy li {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ border: none;
+ background: none;
}
-.sharing_label {
- line-height: 24px;
- padding: 10px 10px 0 0;
- float: left;
+div.sharedaddy,
+#content div.sharedaddy,
+#main div.sharedaddy {
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+ font-size: 12px;
+ clear: both;
+}
+
+div.sharedaddy,
+div.sharedaddy div {
+ -webkit-border-radius: 0 !important;
+ -moz-border-radius: 0 !important;
+ border-radius: 0 !important;
+}
+
+div.sharedaddy h3,
+#content div.sharedaddy h3,
+#main div.sharedaddy h3,
+#primary div.sharedaddy h3 {
+ font-size: 12px;
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+ margin: 3px 0;
+ padding: 0;
+ text-transform: none;
+ letter-spacing: 0;
+ line-height: 1;
font-weight: bold;
+ width: 15.625%; /* 100px / 640px */ float: left;
+ position: static;
+ background: none;
+ border: none;
}
-.sharing ul, .sharing-hidden ul {
- list-style: none outside none !important;
- padding: 0 !important;
+.rtl div.sharedaddy h3,
+.rtl #content div.sharedaddy h3,
+.rtl #main div.sharedaddy h3,
+.rtl #primary div.sharedaddy h3 {
+ float: right;
+ text-align: right;
+}
+
+div.sharedaddy ul,
+div.sharedaddy li {
margin: 0 !important;
- float: left;
- text-indent: 0 !important;
+ padding: 0 !important;
+ text-indent: 0;
}
-.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;
+div.sharedaddy li::before {
+ content: "";
}
-.sharing li div, .sharing-hidden li div {
+div.sharedaddy div.sharing-clear {
margin: 0 !important;
+ padding: 0 !important;
+}
+
+div.sharedaddy div.pd-rating {
+ margin: 0;
+ min-height: 23px;
}
-.sharing li:before, .sharing-hidden li:before {
- content: none !important;
+div.sharedaddy a,
+div.sharedaddy a:link,
+div.sharedaddy a:visited {
+ font-style: normal;
}
+/* ClearFix trick */
-.sharing li a, .sharing-hidden li a {
- padding: 0px 0 0 20px;
- line-height: 24px;
+div.sharedaddy:before,
+div.sharedaddy:after,
+div.sharedaddy .sd-block:before,
+div.sharedaddy .sd-block:after,
+div.sharedaddy ul:before,
+div.sharedaddy ul:after {
+ content: "\0020";
display: block;
+ height: 0;
+ overflow: hidden;
}
-.sharing li.share-regular a, .sharing-hidden li a, .sharing li.share-regular a:hover, .sharing-hidden li a:hover {
- border: none !important;
+div.sharedaddy:after,
+div.sharedaddy .sd-block:after,
+div.sharedaddy ul:after {
+ clear: both;
}
-.share-custom a.sharing-anchor{
- color: #666;
- font-size:11px;
- font-family: arial, tahoma, verdana, sans-serif;
- text-decoration: none;
+div.sharedaddy,
+div.sharedaddy .sd-block,
+div.sharedaddy ul {
+ zoom: 1;
}
-.sharing li.share-custom{
+/* =Base Styles
+-------------------------------------------------------------- */
+
+div.sharedaddy div.sd-block {
+ border-top: 1px solid #ddd;
+ border-top: 1px solid rgba(0,0,0,.13);
+ padding: 10px 0 5px;
+ margin: 0;
+ width: 100% !important;
}
-.sharing-hidden a{
- color: #666;
+div.sharedaddy.sharedaddy-dark .sd-block {
+ border-top-color: #222;
+ border-top-color: rgba(50,50,50,.5);
+}
+
+div.sharedaddy .sd-content {
+ width: 82.125%; /* 530px / 640px */
+ float: right;
+ margin: 0;
}
-.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;
+div.sharedaddy .sd-content ul {
+ margin: 0;
+}
+
+div.sharedaddy .sd-content li {
+ float: left;
+ margin: 0 5px 5px 0 !important;
+ display: block;
+}
+
+.rtl div.sharedaddy .sd-content {
+ float: right;
+}
+
+.rtl div.sharedaddy .sd-content li {
+ float: right;
+ margin: 0 0 5px 5px !important;
+}
+
+/* Base Button .sd-button */
+
+div.sharedaddy a.sd-button {
+ margin: 0;
padding: 0;
+ display: inline-block;
+ background: #efefef;
+ background: -moz-linear-gradient(top, #f7f7f7 0%, #efefef 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#efefef));
+ background: -webkit-linear-gradient(top, #f7f7f7 0%,#efefef 100%);
+ background: -o-linear-gradient(top, #f7f7f7 0%,#efefef 100%);
+ background: -ms-linear-gradient(top, #f7f7f7 0%,#efefef 100%);
+ background: linear-gradient(top, #f7f7f7 0%,#efefef 100%);
+ border-radius: 3px;
+ border: 1px solid #ddd !important;
+ box-shadow: inset 0 1px 0 #fff;
+ color: #000 !important;
+ text-decoration: none;
+ line-height: 1;
+ font-size: 12px;
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+ font-weight: normal;
}
-#sharing_email {
- background-color: #fff;
- padding: 15px;
- width: 312px;
- position: absolute;
- border: 2px solid #6e6e6e;
- z-index: 1001;
- text-align: left;
+div.sharedaddy a.sd-button:hover {
+ color: #000;
+ text-shadow: 0 1px 0 #fff;
+ border-color: #ccc;
+ background: #eee;
+ background: -moz-linear-gradient(top, #efefef 0%, #eee 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#efefef), color-stop(100%,#eee));
+ background: -webkit-linear-gradient(top, #efefef 0%,#eee 100%);
+ background: -o-linear-gradient(top, #efefef 0%,#eee 100%);
+ background: -ms-linear-gradient(top, #efefef 0%,#eee 100%);
+ background: linear-gradient(top, #efefef 0%,#eee 100%);
}
-#sharing_email .errors {
- color: #fff;
- background-color: #771a09;
- font-size: 11px;
- padding: 5px 8px;
- line-height: 11px;
- margin: 10px 0 0 0;
+div.sharedaddy a.sd-button:active {
+ background-color: #efefef;
+ box-shadow: inset 0 -1px 0 #fff;
+ border-color: #ddd;
}
-#sharing_email label {
- font-size: 11px;
- color: #333;
- font-weight: bold;
+a.sd-button > span {
+ padding: 4px 8px;
display: block;
- padding: 0 0 4px 0;
- text-align: left;
+ opacity: .8;
+ line-height: 1;
+ text-shadow: none;
}
-#sharing_email input[type="text"] {
- width: 100%;
- margin-bottom: 12px;
+a.sd-button:hover span {
+ opacity: 1;
}
-#sharing_email .sharing_send {
+.sd-button span.share-count {
+ font-size: 90%;
+ color: #666;
+ margin-left: 5px;
}
-#sharing_email .sharing_cancel {
- padding: 0 0 0 10px;
- font-size: 11px;
+.rtl .sd-button span.share-count {
+ margin-right: 5px;
}
-#sharing_email .recaptcha {
- width: 312px;
- height: 123px;
- margin: 10px 0 14px 0;
+/* Button Style Options */
+
+.sd-social-icon-text a.sd-button > span,
+a.sd-button > span {
+ padding: 3px 5px 3px 23px;
+ background-position: 2px center;
+ background-repeat: no-repeat;
+}
+
+.sd-social-icon a.sd-button > span {
+ padding: 3px;
+ width: 16px;
+ height: 16px;
+ text-indent: -9999px;
+ background-position: center center;
+ background-repeat: no-repeat;
}
-#sharing_background {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: black;
- z-index: 1000;
+.sd-social-text a.sd-button > span {
+ background: none !important;
+ padding-left: 5px
}
-.sharing-hidden {
- padding: 10px 0 0 0;
+.sd-social-official li {
+ height: 21px;
}
-.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;
+div.sharedaddy .no-text {
+ width: 21px;
+ height: 21px;
}
-.sharing-hidden ul {
- background: white url('images/share-bg.png') repeat-y center center;
- margin: 0 !important;
+div.sharedaddy .no-text a {
+ text-decoration: none;
}
-.sharing-hidden li {
- padding-left:10px !important;
- padding-right:10px !important;
- padding-top:0px !important;
- margin: 0 !important;
- margin-bottom:10px !important;
+div.sharedaddy .no-icon a span, div.sharedaddy li.no-icon div a span {
+ padding-left: 5px;
+ background-image: none;
}
-.sharing-hidden li a {
- padding-right: 20px;
- font-size: 11px;
- line-height: 16px;
- display: block;
- text-decoration: none !important;
- border-bottom: 0px !important;
+.rtl .sd-social-icon-text a.sd-button > span,
+.rtl a.sd-button > span {
+ padding: 3px 23px 3px 5px;
+ background-position: 98% center;
+}
+.rtl .sd-social-text a.sd-button > span {
+ padding-left: 0;
+ padding-right: 5px
}
-.sharing-hidden li a.no-text{
- width: 16px;
- height:16px;
+.rtl div.sharedaddy .no-icon a span, .rtl div.sharedaddy li.no-icon div a span {
+ padding-left: 0;
+ padding-right: 5px
}
-.sharing li a.no-text{
- width: 16px;
- height: 16px;
- margin-top: 4px;
- padding: 0px !important;
+/* Icons */
+
+li.share-facebook a.sd-button > span {
+ background-image: url('images/facebook.png');
}
-.sharing li a.no-icon {
- background: none !important;
- padding-left: 0 !important;
+li.share-tumblr a.sd-button > span {
+ background-image: url('images/tumblr.png');
}
-.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;
+li.share-twitter a.sd-button > span {
+ background-image: url('images/twitter.png?1');
}
-.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;
+li.share-linkedin a.sd-button > span {
+ background-image: url('images/linkedin.png');
}
-.sharing-clear {
- clear: left;
+li.share-press-this a.sd-button > span {
+ background-image: url('images/wordpress.png');
}
-.response {
+li.share-digg a.sd-button > span {
+ background-image: url('images/digg.png');
}
-.response-title {
- font-size: 12px;
- line-height: 18px;
- font-weight: bold;
+li.share-stumbleupon a.sd-button > span {
+ background-image: url('images/stumbleupon.png');
}
-.response-sub {
- font-size: 11px;
- line-height: 24px;
+li.share-reddit a.sd-button > span {
+ background-image: url('images/reddit.png');
}
-.response-close .sharing_cancel {
- padding: 0px !important;
+li.share-pinterest a.sd-button > span {
+ background-image: url('images/pinterest.png');
}
-li.share-email, li.share-custom a.sharing-anchor {
- display: none !important;
+li.share-email a.sd-button > span {
+ background-image: url('images/email.png');
}
-li.share-service-visible {
- display: list-item !important;
+li.share-print a.sd-button > span {
+ background-image: url('images/print.png');
}
-li.share-custom a.sharing-anchor.share-service-visible {
- display: inline !important;
+a.sd-button.share-more span {
+ background-image: url('images/more.png');
+}
+
+@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
+
+ li.share-facebook a.sd-button > span {
+ background-image: url('images/facebook@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-tumblr a.sd-button > span {
+ background-image: url('images/tumblr@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-twitter a.sd-button > span {
+ background-image: url('images/twitter@2x.png?1');
+ background-size: 16px 16px;
+ }
+
+ li.share-linkedin a.sd-button > span {
+ background-image: url('images/linkedin@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-press-this a.sd-button > span {
+ background-image: url('images/wordpress@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-digg a.sd-button > span {
+ background-image: url('images/digg@2x.png?1');
+ background-size: 16px 16px;
+ }
+
+ li.share-stumbleupon a.sd-button > span {
+ background-image: url('images/stumbleupon@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-reddit a.sd-button > span {
+ background-image: url('images/reddit@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-pinterest a.sd-button > span {
+ background-image: url('images/pinterest@2x.png');
+ background-size: 16px 16px;
+ }
+
+ li.share-email a.sd-button > span {
+ background-image: url('images/email@2x.png?1');
+ background-size: 16px 16px;
+ }
+
+ li.share-print a.sd-button > span {
+ background-image: url('images/print@2x.png');
+ background-size: 16px 16px;
+ }
+
+ a.sd-button.share-more span {
+ background-image: url('images/more@2x.png?1');
+ background-size: 16px 16px;
+ }
+
+}
+
+
+/* Special case for non-smart implementations of Google+ button */
+
+div.sharedaddy .sd-content ul li.share-google-plus-1 {
+ line-height: 90%;
+ margin-bottom: 2px !important;
+ min-height: 20px;
+}
+
+div.sharedaddy .sd-social-official .sd-content ul li.share-google-plus-1 {
+ padding-top: 0;
+}
+
+/* More pannel */
+
+div.sharedaddy .sharing-hidden .inner {
+ max-width: 250px;
+ padding: 15px 15px 10px;
+ position: absolute;
+ margin-left: -100px;
+ z-index: 1001;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ -moz-border-radius: 3px !important;
+ -webkit-border-radius: 3px !important;
+ border-radius: 3px !important;
+ -moz-box-shadow: 0px 2px 8px #ccc;
+ -webkit-box-shadow: 0px 2px 8px #ccc;
+ box-shadow: 0px 2px 8px #ccc;
+ -webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, .2);
+ -moz-box-shadow: 0px 2px 8px rgba(0, 0, 0, .2);
+ box-shadow: 0px 2px 8px rgba(0, 0, 0, .2);
+}
+
+.rtl div.sharedaddy .sharing-hidden .inner {
+ margin-left: 0;
+ margin-right: -100px;
+}
+
+div.sharedaddy.sharedaddy-dark .sharing-hidden .inner {
+ border-color: #222;
+}
+
+div.sd-content a.sd-button > span {
+ line-height: 1.5em;
+}
+
+#sharing_email {
+ background-color: #FFFFFF;
+ border: 1px solid #CCCCCC;
+ border-radius: 3px 3px 3px 3px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
+ margin-left: -120px;
+ padding: 15px;
+ position: absolute;
+ text-align: left;
+ width: 312px;
+ z-index: 1001;
+}
+
+div.sharedaddy.sharedaddy-dark #sharing_email {
+ border-color: #FFFFFF;
+}
+
+#sharing_email .errors {
+ background-color: #771A09;
+ color: #FFFFFF;
+ font-size: 11px;
+ line-height: 11px;
+ margin: 10px 0 0;
+ padding: 5px 8px;
+}
+
+#sharing_email label {
+ color: #333333;
+ display: block;
+ font-size: 11px;
+ font-weight: bold;
+ padding: 0 0 4px;
+ text-align: left;
+ text-shadow: none;
+}
+
+#sharing_email input[type="text"] {
+ background: none repeat scroll 0 0 #FFFFFF;
+ border: 1px solid #CCCCCC;
+ color: #333333;
+ margin-bottom: 12px;
+ width: 98.5%;
+}
+
+#sharing_email .sharing_cancel {
+ font-size: 11px;
+ padding: 0 0 0 10px;
+ text-shadow: none;
+}
+
+#sharing_email .recaptcha {
+ height: 123px;
+ margin: 10px 0 14px;
+ width: 312px;
}
/* =RTL
@@ -276,3 +490,14 @@ body.rtl .sharing ul {
body.rtl .sharing li {
margin: 0 0 0 10px !important;
}
+.rtl #sharing_email {
+ margin-left: 0;
+ margin-right: -120px;
+ text-align: right;
+}
+.rtl #sharing_email .sharing_cancel {
+ padding: 0 10px 0 0;
+}
+.rtl #sharing_email label {
+ text-align: right;
+} \ No newline at end of file
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js
index 9a288457..a6c29494 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.js
+++ b/plugins/jetpack/modules/sharedaddy/sharing.js
@@ -1,22 +1,64 @@
+var WPCOMSharing = {
+ get_counts : function( url ) {
+ if ( jQuery( '#sharing-facebook-' + WPCOM_sharing_counts[ url ] ).length )
+ jQuery.getScript( 'https://graph.facebook.com/' + encodeURIComponent( url ) + '?callback=WPCOMSharing.update_facebook_count' );
+ if ( jQuery( '#sharing-twitter-' + WPCOM_sharing_counts[ url ] ).length )
+ jQuery.getScript( 'http://urls.api.twitter.com/1/urls/count.json?callback=WPCOMSharing.update_twitter_count&url=' + encodeURIComponent( url ) );
+ if ( jQuery( '#sharing-linkedin-' + WPCOM_sharing_counts[ url ] ).length )
+ jQuery.getScript( 'http://www.linkedin.com/countserv/count/share?format=jsonp&callback=WPCOMSharing.update_linkedin_count&url=' + encodeURIComponent( url ) );
+ },
+ update_facebook_count : function( data ) {
+ if ( 'undefined' != typeof data.shares && ( data.shares * 1 ) > 0 ) {
+ WPCOMSharing.inject_share_count( 'sharing-facebook-' + WPCOM_sharing_counts[ data.id ], data.shares );
+ }
+ },
+ update_twitter_count : function( data ) {
+ if ( 'undefined' != typeof data.count && ( data.count * 1 ) > 0 ) {
+ WPCOMSharing.inject_share_count( 'sharing-twitter-' + WPCOM_sharing_counts[ data.url ], data.count );
+ }
+ },
+ update_linkedin_count : function( data ) {
+ if ( 'undefined' != typeof data.count && ( data.count * 1 ) > 0 ) {
+ WPCOMSharing.inject_share_count( 'sharing-linkedin-' + WPCOM_sharing_counts[ data.url ], data.count );
+ }
+ },
+ inject_share_count : function( dom_id, count ) {
+ jQuery( '#' + dom_id + ' span' ).append( '<span class="share-count">' + WPCOMSharing.format_count( count ) + '</span>' );
+ },
+ format_count : function( count ) {
+ if ( count < 1000 )
+ return count;
+ if ( count >= 1000 && count < 10000 )
+ return String( count ).substring( 0, 1 ) + 'K+';
+ return '10K+';
+ }
+};
+
(function($){
- $.fn.extend( {
+ $.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() );
+ 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() );
+ }
+ } );
+
+ if ( 'undefined' != typeof WPCOM_sharing_counts ) {
+ for ( var url in WPCOM_sharing_counts ) {
+ WPCOMSharing.get_counts( url );
}
- } );
+ }
$( document ).on( 'ready post-load', function() {
- var $more_sharing_buttons = $( '.sharing a.sharing-anchor' );
+ var $more_sharing_buttons = $( '.sharedaddy a.sharing-anchor' );
$more_sharing_buttons.click( function() {
return false;
} );
- $( '.sharing a' ).each( function() {
+ $( '.sharedaddy a' ).each( function() {
if ( $( this ).attr( 'href' ) && $( this ).attr( 'href' ).indexOf( 'share=' ) != -1 )
$( this ).attr( 'href', $( this ).attr( 'href' ) + '&nb=1' );
} );
-
+
// Show hidden buttons
// Touchscreen device: use click.
@@ -29,14 +71,14 @@
// We're in the middle of some other event's animation
return;
}
-
+
if ( true === $more_sharing_pane.data( 'justSlid' ) ) {
// We just finished some other event's animation - don't process click event so that slow-to-react-clickers don't get confused
return;
}
-
+
$( '#sharing_email' ).slideUp( 200 );
-
+
$more_sharing_pane.css( {
left: $more_sharing_button.position().left + 'px',
top: $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px'
@@ -53,7 +95,7 @@
// Create a timer to make the area appear if the mouse hovers for a period
var timer = setTimeout( function() {
$( '#sharing_email' ).slideUp( 200 );
-
+
$more_sharing_pane.data( 'justSlid', true );
$more_sharing_pane.css( {
left: $more_sharing_button.position().left + 'px',
@@ -61,7 +103,7 @@
} ).slideDown( 200, function() {
// Mark the item as have being appeared by the hover
$more_sharing_button.data( 'hasoriginal', true ).data( 'hasitem', false );
-
+
// Remove all special handlers
$more_sharing_pane.mouseleave( handler_item_leave ).mouseenter( handler_item_enter );
$more_sharing_button.mouseleave( handler_original_leave ).mouseenter( handler_original_enter );
@@ -69,36 +111,36 @@
$more_sharing_pane.data( 'justSlid', false );
}, 300 );
} );
-
+
// 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() {
$more_sharing_button.data( 'hasitem', false );
-
+
if ( $more_sharing_button.data( 'hasoriginal' ) === false ) {
var timer = setTimeout( close_it, 800 );
$more_sharing_button.data( 'timer2', timer );
}
};
-
+
var handler_item_enter = function() {
$more_sharing_button.data( 'hasitem', true );
clearTimeout( $more_sharing_button.data( 'timer2' ) );
- }
-
+ }
+
var handler_original_leave = function() {
$more_sharing_button.data( 'hasoriginal', false );
-
+
if ( $more_sharing_button.data( 'hasitem' ) === false ) {
var timer = setTimeout( close_it, 800 );
$more_sharing_button.data( 'timer2', timer );
}
};
-
+
var handler_original_enter = function() {
$more_sharing_button.data( 'hasoriginal', true );
clearTimeout( $more_sharing_button.data( 'timer2' ) );
};
-
+
var close_it = function() {
$more_sharing_pane.data( 'justSlid', true );
$more_sharing_pane.slideUp( 200, function() {
@@ -106,14 +148,14 @@
$more_sharing_pane.data( 'justSlid', false );
}, 300 );
} );
-
+
// Clear all hooks
$more_sharing_button.unbind( 'mouseleave', handler_original_leave ).unbind( 'mouseenter', handler_original_enter );
$more_sharing_pane.unbind( 'mouseleave', handler_item_leave ).unbind( 'mouseenter', handler_item_leave );
return false;
};
}, 200 );
-
+
// Remember the timer so we can detect it on the mouseout
$more_sharing_button.data( 'timer', timer );
}
@@ -125,17 +167,17 @@
$more_sharing_buttons.data( 'timer', false );
} );
}
-
+
// Add click functionality
- $( '.sharing ul' ).each( function( item ) {
+ $( '.sharedaddy 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() {
+ $( this ).find( 'a.share-print' ).click( function() {
ref = $( this ).attr( 'href' );
-
+
var do_print = function() {
if ( ref.indexOf( '#print' ) == -1 ) {
uid = new Date().getTime();
@@ -144,7 +186,7 @@
else
print();
}
-
+
// Is the button in a dropdown?
if ( $( this ).parents( '.sharing-hidden' ).length > 0 ) {
$( this ).parents( '.inner' ).slideUp( 0, function() {
@@ -156,11 +198,11 @@
return false;
} );
-
+
// Press This button
- $( this ).find( '.share-press-this a' ).click( function() {
+ $( this ).find( 'a.share-press-this' ).click( function() {
var s = '';
-
+
if ( window.getSelection )
s = window.getSelection();
else if( document.getSelection )
@@ -171,32 +213,39 @@
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' ) )
+ 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() {
+ $( this ).find( 'a.share-email' ).click( function() {
var url = $( this ).attr( 'href' );
-
+
if ( $( '#sharing_email' ).is( ':visible' ) )
$( '#sharing_email' ).slideUp( 200 );
else {
- $( '.sharing .inner' ).slideUp();
+ $( '.sharedaddy .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();
+
+ var key = '';
+ if ( $( '#recaptcha_public_key' ).length > 0 )
+ key = $( '#recaptcha_public_key' ).val();
+
+ // Update the recaptcha
+ Recaptcha.create( key, 'sharing_recaptcha' );
// 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();
@@ -204,25 +253,25 @@
$( '#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' );
+ $( this ).prop( 'disabled', true );
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( {
@@ -236,6 +285,7 @@
$( '#sharing_email .errors-' + response ).show();
form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
form.find( 'a.sharing_cancel' ).show();
+ Recaptcha.reload();
}
else {
$( '#sharing_email form' ).hide();
@@ -248,10 +298,10 @@
}
}
} );
-
+
return false;
}
-
+
form.find( 'img.loading' ).hide();
form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
form.find( 'a.sharing_cancel' ).show();
@@ -260,11 +310,42 @@
return false;
} );
}
-
+
return false;
} );
} );
-
+
$( 'li.share-email, li.share-custom a.sharing-anchor' ).addClass( 'share-service-visible' );
} );
})( jQuery );
+
+// Recaptcha code
+var RecaptchaTemplates={};RecaptchaTemplates.VertHtml='<table id="recaptcha_table" class="recaptchatable" > <tr> <td colspan="6" class=\'recaptcha_r1_c1\'></td> </tr> <tr> <td class=\'recaptcha_r2_c1\'></td> <td colspan="4" class=\'recaptcha_image_cell\'><div id="recaptcha_image"></div></td> <td class=\'recaptcha_r2_c2\'></td> </tr> <tr> <td rowspan="6" class=\'recaptcha_r3_c1\'></td> <td colspan="4" class=\'recaptcha_r3_c2\'></td> <td rowspan="6" class=\'recaptcha_r3_c3\'></td> </tr> <tr> <td rowspan="3" class=\'recaptcha_r4_c1\' height="49"> <div class="recaptcha_input_area"> <label for="recaptcha_response_field" class="recaptcha_input_area_text"><span id="recaptcha_instructions_image" class="recaptcha_only_if_image recaptcha_only_if_no_incorrect_sol"></span><span id="recaptcha_instructions_audio" class="recaptcha_only_if_no_incorrect_sol recaptcha_only_if_audio"></span><span id="recaptcha_instructions_error" class="recaptcha_only_if_incorrect_sol"></span></label><br/> <input name="recaptcha_response_field" id="recaptcha_response_field" type="text" /> </div> </td> <td rowspan="4" class=\'recaptcha_r4_c2\'></td> <td><a id=\'recaptcha_reload_btn\'><img id=\'recaptcha_reload\' width="25" height="17" /></a></td> <td rowspan="4" class=\'recaptcha_r4_c4\'></td> </tr> <tr> <td><a id=\'recaptcha_switch_audio_btn\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="16" alt="" /></a><a id=\'recaptcha_switch_img_btn\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="16" alt=""/></a></td> </tr> <tr> <td><a id=\'recaptcha_whatsthis_btn\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a></td> </tr> <tr> <td class=\'recaptcha_r7_c1\'></td> <td class=\'recaptcha_r8_c1\'></td> </tr> </table> ';RecaptchaTemplates.CleanCss=".recaptchatable td img{display:block}.recaptchatable .recaptcha_image_cell center img{height:57px}.recaptchatable .recaptcha_image_cell center{height:57px}.recaptchatable .recaptcha_image_cell{background-color:white;height:57px;padding:7px!important}.recaptchatable,#recaptcha_area tr,#recaptcha_area td,#recaptcha_area th{margin:0!important;border:0!important;border-collapse:collapse!important;vertical-align:middle!important}.recaptchatable *{margin:0;padding:0;border:0;color:black;position:static;top:auto;left:auto;right:auto;bottom:auto;text-align:left!important}.recaptchatable #recaptcha_image{margin:auto;border:1px solid #dfdfdf!important}.recaptchatable a img{border:0}.recaptchatable a,.recaptchatable a:hover{-moz-outline:none;border:0!important;padding:0!important;text-decoration:none;color:blue;background:none!important;font-weight:normal}.recaptcha_input_area{position:relative!important;background:none!important}.recaptchatable label.recaptcha_input_area_text{border:1px solid #dfdfdf!important;margin:0!important;padding:0!important;position:static!important;top:auto!important;left:auto!important;right:auto!important;bottom:auto!important}.recaptcha_theme_red label.recaptcha_input_area_text,.recaptcha_theme_white label.recaptcha_input_area_text{color:black!important}.recaptcha_theme_blackglass label.recaptcha_input_area_text{color:white!important}.recaptchatable #recaptcha_response_field{font-size:11pt}.recaptcha_theme_blackglass #recaptcha_response_field,.recaptcha_theme_white #recaptcha_response_field{border:1px solid gray}.recaptcha_theme_red #recaptcha_response_field{border:1px solid #cca940}.recaptcha_audio_cant_hear_link{font-size:7pt;color:black}.recaptchatable{line-height:1em;border:1px solid #dfdfdf!important}.recaptcha_error_text{color:red}";RecaptchaTemplates.CleanHtml='<table id="recaptcha_table" class="recaptchatable"> <tr height="73"> <td class=\'recaptcha_image_cell\' width="302"><center><div id="recaptcha_image"></div></center></td> <td style="padding: 10px 7px 7px 7px;"> <a id=\'recaptcha_reload_btn\'><img id=\'recaptcha_reload\' width="25" height="18" alt="" /></a> <a id=\'recaptcha_switch_audio_btn\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="15" alt="" /></a><a id=\'recaptcha_switch_img_btn\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="15" alt=""/></a> <a id=\'recaptcha_whatsthis_btn\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a> </td> <td style="padding: 18px 7px 18px 7px;"> <img id=\'recaptcha_logo\' alt="" width="71" height="36" /> </td> </tr> <tr> <td style="padding-left: 7px;"> <div class="recaptcha_input_area" style="padding-top: 2px; padding-bottom: 7px;"> <input style="border: 1px solid #3c3c3c; width: 302px;" name="recaptcha_response_field" id="recaptcha_response_field" type="text" /> </div> </td> <td></td> <td style="padding: 4px 7px 12px 7px;"> <img id="recaptcha_tagline" width="71" height="17" /> </td> </tr> </table> ';RecaptchaTemplates.ContextHtml='<table id="recaptcha_table" class="recaptchatable"> <tr> <td colspan="6" class=\'recaptcha_r1_c1\'></td> </tr> <tr> <td class=\'recaptcha_r2_c1\'></td> <td colspan="4" class=\'recaptcha_image_cell\'><div id="recaptcha_image"></div></td> <td class=\'recaptcha_r2_c2\'></td> </tr> <tr> <td rowspan="6" class=\'recaptcha_r3_c1\'></td> <td colspan="4" class=\'recaptcha_r3_c2\'></td> <td rowspan="6" class=\'recaptcha_r3_c3\'></td> </tr> <tr> <td rowspan="3" class=\'recaptcha_r4_c1\' height="49"> <div class="recaptcha_input_area"> <label for="recaptcha_response_field" class="recaptcha_input_area_text"><span id="recaptcha_instructions_context" class="recaptcha_only_if_image recaptcha_only_if_no_incorrect_sol"></span><span id="recaptcha_instructions_audio" class="recaptcha_only_if_no_incorrect_sol recaptcha_only_if_audio"></span><span id="recaptcha_instructions_error" class="recaptcha_only_if_incorrect_sol"></span></label><br/> <input name="recaptcha_response_field" id="recaptcha_response_field" type="text" /> </div> </td> <td rowspan="4" class=\'recaptcha_r4_c2\'></td> <td><a id=\'recaptcha_reload_btn\'><img id=\'recaptcha_reload\' width="25" height="17" /></a></td> <td rowspan="4" class=\'recaptcha_r4_c4\'></td> </tr> <tr> <td><a id=\'recaptcha_switch_audio_btn\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="16" alt="" /></a><a id=\'recaptcha_switch_img_btn\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="16" alt=""/></a></td> </tr> <tr> <td><a id=\'recaptcha_whatsthis_btn\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a></td> </tr> <tr> <td class=\'recaptcha_r7_c1\'></td> <td class=\'recaptcha_r8_c1\'></td> </tr> </table> ';RecaptchaTemplates.VertCss=".recaptchatable td img{display:block}.recaptchatable .recaptcha_r1_c1{background:url(IMGROOT/sprite.png) 0 -63px no-repeat;width:318px;height:9px}.recaptchatable .recaptcha_r2_c1{background:url(IMGROOT/sprite.png) -18px 0 no-repeat;width:9px;height:57px}.recaptchatable .recaptcha_r2_c2{background:url(IMGROOT/sprite.png) -27px 0 no-repeat;width:9px;height:57px}.recaptchatable .recaptcha_r3_c1{background:url(IMGROOT/sprite.png) 0 0 no-repeat;width:9px;height:63px}.recaptchatable .recaptcha_r3_c2{background:url(IMGROOT/sprite.png) -18px -57px no-repeat;width:300px;height:6px}.recaptchatable .recaptcha_r3_c3{background:url(IMGROOT/sprite.png) -9px 0 no-repeat;width:9px;height:63px}.recaptchatable .recaptcha_r4_c1{background:url(IMGROOT/sprite.png) -43px 0 no-repeat;width:171px;height:49px}.recaptchatable .recaptcha_r4_c2{background:url(IMGROOT/sprite.png) -36px 0 no-repeat;width:7px;height:57px}.recaptchatable .recaptcha_r4_c4{background:url(IMGROOT/sprite.png) -214px 0 no-repeat;width:97px;height:57px}.recaptchatable .recaptcha_r7_c1{background:url(IMGROOT/sprite.png) -43px -49px no-repeat;width:171px;height:8px}.recaptchatable .recaptcha_r8_c1{background:url(IMGROOT/sprite.png) -43px -49px no-repeat;width:25px;height:8px}.recaptchatable .recaptcha_image_cell center img{height:57px}.recaptchatable .recaptcha_image_cell center{height:57px}.recaptchatable .recaptcha_image_cell{background-color:white;height:57px}#recaptcha_area,#recaptcha_table{width:318px!important}.recaptchatable,#recaptcha_area tr,#recaptcha_area td,#recaptcha_area th{margin:0!important;border:0!important;padding:0!important;border-collapse:collapse!important;vertical-align:middle!important}.recaptchatable *{margin:0;padding:0;border:0;font-family:helvetica,sans-serif;font-size:8pt;color:black;position:static;top:auto;left:auto;right:auto;bottom:auto;text-align:left!important}.recaptchatable #recaptcha_image{margin:auto}.recaptchatable img{border:0!important;margin:0!important;padding:0!important}.recaptchatable a,.recaptchatable a:hover{-moz-outline:none;border:0!important;padding:0!important;text-decoration:none;color:blue;background:none!important;font-weight:normal}.recaptcha_input_area{position:relative!important;width:146px!important;height:45px!important;margin-left:20px!important;margin-right:5px!important;margin-top:4px!important;background:none!important}.recaptchatable label.recaptcha_input_area_text{margin:0!important;padding:0!important;position:static!important;top:auto!important;left:auto!important;right:auto!important;bottom:auto!important;background:none!important;height:auto!important;width:auto!important}.recaptcha_theme_red label.recaptcha_input_area_text,.recaptcha_theme_white label.recaptcha_input_area_text{color:black!important}.recaptcha_theme_blackglass label.recaptcha_input_area_text{color:white!important}.recaptchatable #recaptcha_response_field{width:145px!important;position:absolute!important;bottom:7px!important;padding:0!important;margin:0!important;font-size:10pt}.recaptcha_theme_blackglass #recaptcha_response_field,.recaptcha_theme_white #recaptcha_response_field{border:1px solid gray}.recaptcha_theme_red #recaptcha_response_field{border:1px solid #cca940}.recaptcha_audio_cant_hear_link{font-size:7pt;color:black}.recaptchatable{line-height:1em}#recaptcha_instructions_error{color:red!important}";var RecaptchaStr_en={visual_challenge:"Get a visual challenge",audio_challenge:"Get an audio challenge",refresh_btn:"Get a new challenge",instructions_visual:"Type the two words:",instructions_context:"Type the words in the boxes:",instructions_audio:"Type what you hear:",help_btn:"Help",play_again:"Play sound again",cant_hear_this:"Download sound as MP3",incorrect_try_again:"Incorrect. Try again."},RecaptchaStr_de={visual_challenge:"Visuelle Aufgabe generieren",audio_challenge:"Audio-Aufgabe generieren",
+refresh_btn:"Neue Aufgabe generieren",instructions_visual:"Gib die 2 W\u00f6rter ein:",instructions_context:"",instructions_audio:"Gib die 8 Ziffern ein:",help_btn:"Hilfe",incorrect_try_again:"Falsch. Nochmals versuchen!"},RecaptchaStr_es={visual_challenge:"Obt\u00e9n un reto visual",audio_challenge:"Obt\u00e9n un reto audible",refresh_btn:"Obt\u00e9n un nuevo reto",instructions_visual:"Escribe las 2 palabras:",instructions_context:"",instructions_audio:"Escribe los 8 n\u00fameros:",help_btn:"Ayuda",
+incorrect_try_again:"Incorrecto. Otro intento."},RecaptchaStr_fr={visual_challenge:"D\u00e9fi visuel",audio_challenge:"D\u00e9fi audio",refresh_btn:"Nouveau d\u00e9fi",instructions_visual:"Entrez les deux mots:",instructions_context:"",instructions_audio:"Entrez les huit chiffres:",help_btn:"Aide",incorrect_try_again:"Incorrect."},RecaptchaStr_nl={visual_challenge:"Test me via een afbeelding",audio_challenge:"Test me via een geluidsfragment",refresh_btn:"Nieuwe uitdaging",instructions_visual:"Type de twee woorden:",
+instructions_context:"",instructions_audio:"Type de acht cijfers:",help_btn:"Help",incorrect_try_again:"Foute invoer."},RecaptchaStr_pt={visual_challenge:"Obter um desafio visual",audio_challenge:"Obter um desafio sonoro",refresh_btn:"Obter um novo desafio",instructions_visual:"Escreva as 2 palavras:",instructions_context:"",instructions_audio:"Escreva os 8 numeros:",help_btn:"Ajuda",incorrect_try_again:"Incorrecto. Tenta outra vez."},RecaptchaStr_ru={visual_challenge:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",
+audio_challenge:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0437\u0432\u0443\u043a\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",refresh_btn:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",instructions_visual:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430:",instructions_context:"",instructions_audio:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u0447\u0438\u0441\u0435\u043b:",
+help_btn:"\u041f\u043e\u043c\u043e\u0449\u044c",incorrect_try_again:"\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e."},RecaptchaStr_tr={visual_challenge:"G\u00f6rsel deneme",audio_challenge:"\u0130\u015fitsel deneme",refresh_btn:"Yeni deneme",instructions_visual:"\u0130ki kelimeyi yaz\u0131n:",instructions_context:"",instructions_audio:"Sekiz numaray\u0131 yaz\u0131n:",help_btn:"Yard\u0131m (\u0130ngilizce)",incorrect_try_again:"Yanl\u0131\u015f. Bir daha deneyin."},RecaptchaStr_it=
+{visual_challenge:"Modalit\u00e0 visiva",audio_challenge:"Modalit\u00e0 auditiva",refresh_btn:"Chiedi due nuove parole",instructions_visual:"Scrivi le due parole:",instructions_context:"",instructions_audio:"Trascrivi ci\u00f2 che senti:",help_btn:"Aiuto",incorrect_try_again:"Scorretto. Riprova."},RecaptchaLangMap={en:RecaptchaStr_en,de:RecaptchaStr_de,es:RecaptchaStr_es,fr:RecaptchaStr_fr,nl:RecaptchaStr_nl,pt:RecaptchaStr_pt,ru:RecaptchaStr_ru,tr:RecaptchaStr_tr,it:RecaptchaStr_it};var RecaptchaStr=RecaptchaStr_en,RecaptchaOptions,RecaptchaDefaultOptions={tabindex:0,theme:"red",callback:null,lang:"en",custom_theme_widget:null,custom_translations:null,includeContext:false},Recaptcha={widget:null,timer_id:-1,style_set:false,theme:null,type:"image",ajax_verify_cb:null,$:function(a){return typeof a=="string"?document.getElementById(a):a},create:function(a,b,c){Recaptcha.destroy();if(b)Recaptcha.widget=Recaptcha.$(b);Recaptcha._init_options(c);Recaptcha._call_challenge(a)},destroy:function(){var a=
+Recaptcha.$("recaptcha_challenge_field");a&&a.parentNode.removeChild(a);Recaptcha.timer_id!=-1&&clearInterval(Recaptcha.timer_id);Recaptcha.timer_id=-1;if(a=Recaptcha.$("recaptcha_image"))a.innerHTML="";if(Recaptcha.widget){if(Recaptcha.theme!="custom")Recaptcha.widget.innerHTML="";else Recaptcha.widget.style.display="none";Recaptcha.widget=null}},focus_response_field:function(){var a=Recaptcha.$;a=a("recaptcha_response_field");a.focus()},get_challenge:function(){if(typeof RecaptchaState=="undefined")return null;
+return RecaptchaState.challenge},get_response:function(){var a=Recaptcha.$;a=a("recaptcha_response_field");if(!a)return null;return a.value},ajax_verify:function(a){Recaptcha.ajax_verify_cb=a;a=Recaptcha._get_api_server()+"/ajaxverify?c="+encodeURIComponent(Recaptcha.get_challenge())+"&response="+encodeURIComponent(Recaptcha.get_response());Recaptcha._add_script(a)},_ajax_verify_callback:function(a){Recaptcha.ajax_verify_cb(a)},_get_api_server:function(){var a=window.location.protocol,b;b=typeof _RecaptchaOverrideApiServer!=
+"undefined"?_RecaptchaOverrideApiServer:"www.google.com/recaptcha/api";return a+"//"+b},_call_challenge:function(a){a=Recaptcha._get_api_server()+"/challenge?k="+a+"&ajax=1&cachestop="+Math.random();if(typeof RecaptchaOptions.extra_challenge_params!="undefined")a+="&"+RecaptchaOptions.extra_challenge_params;if(RecaptchaOptions.includeContext)a+="&includeContext=1";Recaptcha._add_script(a)},_add_script:function(a){var b=document.createElement("script");b.type="text/javascript";b.src=a;Recaptcha._get_script_area().appendChild(b)},
+_get_script_area:function(){var a=document.getElementsByTagName("head");return a=!a||a.length<1?document.body:a[0]},_hash_merge:function(a){var b={};for(var c in a)for(var d in a[c])b[d]=a[c][d];if(b.theme=="context")b.includeContext=true;return b},_init_options:function(a){RecaptchaOptions=Recaptcha._hash_merge([RecaptchaDefaultOptions,a||{}])},challenge_callback:function(){Recaptcha._reset_timer();RecaptchaStr=Recaptcha._hash_merge([RecaptchaStr_en,RecaptchaLangMap[RecaptchaOptions.lang]||{},RecaptchaOptions.custom_translations||
+{}]);window.addEventListener&&window.addEventListener("unload",function(){Recaptcha.destroy()},false);Recaptcha._is_ie()&&window.attachEvent&&window.attachEvent("onbeforeunload",function(){});if(navigator.userAgent.indexOf("KHTML")>0){var a=document.createElement("iframe");a.src="about:blank";a.style.height="0px";a.style.width="0px";a.style.visibility="hidden";a.style.border="none";var b=document.createTextNode("This frame prevents back/forward cache problems in Safari.");a.appendChild(b);document.body.appendChild(a)}Recaptcha._finish_widget()},
+_add_css:function(a){var b=document.createElement("style");b.type="text/css";if(b.styleSheet)if(navigator.appVersion.indexOf("MSIE 5")!=-1)document.write("<style type='text/css'>"+a+"</style>");else b.styleSheet.cssText=a;else if(navigator.appVersion.indexOf("MSIE 5")!=-1)document.write("<style type='text/css'>"+a+"</style>");else{a=document.createTextNode(a);b.appendChild(a)}Recaptcha._get_script_area().appendChild(b)},_set_style:function(a){if(!Recaptcha.style_set){Recaptcha.style_set=true;Recaptcha._add_css(a+
+"\n\n.recaptcha_is_showing_audio .recaptcha_only_if_image,.recaptcha_isnot_showing_audio .recaptcha_only_if_audio,.recaptcha_had_incorrect_sol .recaptcha_only_if_no_incorrect_sol,.recaptcha_nothad_incorrect_sol .recaptcha_only_if_incorrect_sol{display:none !important}")}},_init_builtin_theme:function(){var a=Recaptcha.$,b=RecaptchaStr,c=RecaptchaState,d,e;c=c.server;if(c[c.length-1]=="/")c=c.substring(0,c.length-1);var f=c+"/img/"+Recaptcha.theme;if(Recaptcha.theme=="clean"){c=RecaptchaTemplates.CleanCss;
+d=RecaptchaTemplates.CleanHtml;e="png"}else{if(Recaptcha.theme=="context"){c=RecaptchaTemplates.VertCss;d=RecaptchaTemplates.ContextHtml}else{c=RecaptchaTemplates.VertCss;d=RecaptchaTemplates.VertHtml}e="gif"}c=c.replace(/IMGROOT/g,f);Recaptcha._set_style(c);Recaptcha.widget.innerHTML="<div id='recaptcha_area'>"+d+"</div>";a("recaptcha_reload").src=f+"/refresh."+e;a("recaptcha_switch_audio").src=f+"/audio."+e;a("recaptcha_switch_img").src=f+"/text."+e;a("recaptcha_whatsthis").src=f+"/help."+e;if(Recaptcha.theme==
+"clean"){a("recaptcha_logo").src=f+"/logo."+e;a("recaptcha_tagline").src=f+"/tagline."+e}a("recaptcha_reload").alt=b.refresh_btn;a("recaptcha_switch_audio").alt=b.audio_challenge;a("recaptcha_switch_img").alt=b.visual_challenge;a("recaptcha_whatsthis").alt=b.help_btn;a("recaptcha_reload_btn").href="javascript:Recaptcha.reload ();";a("recaptcha_reload_btn").title=b.refresh_btn;a("recaptcha_switch_audio_btn").href="javascript:Recaptcha.switch_type('audio');";a("recaptcha_switch_audio_btn").title=b.audio_challenge;
+a("recaptcha_switch_img_btn").href="javascript:Recaptcha.switch_type('image');";a("recaptcha_switch_img_btn").title=b.visual_challenge;a("recaptcha_whatsthis_btn").href=Recaptcha._get_help_link();a("recaptcha_whatsthis_btn").target="_blank";a("recaptcha_whatsthis_btn").title=b.help_btn;a("recaptcha_whatsthis_btn").onclick=function(){Recaptcha.showhelp();return false};a("recaptcha_table").className="recaptchatable recaptcha_theme_"+Recaptcha.theme;a("recaptcha_instructions_image")&&a("recaptcha_instructions_image").appendChild(document.createTextNode(b.instructions_visual));
+a("recaptcha_instructions_context")&&a("recaptcha_instructions_context").appendChild(document.createTextNode(b.instructions_context));a("recaptcha_instructions_audio")&&a("recaptcha_instructions_audio").appendChild(document.createTextNode(b.instructions_audio));a("recaptcha_instructions_error")&&a("recaptcha_instructions_error").appendChild(document.createTextNode(b.incorrect_try_again))},_finish_widget:function(){var a=Recaptcha.$,b=RecaptchaState,c=RecaptchaOptions,d=c.theme;switch(d){case "red":case "white":case "blackglass":case "clean":case "custom":case "context":break;
+default:d="red";break}if(!Recaptcha.theme)Recaptcha.theme=d;Recaptcha.theme!="custom"?Recaptcha._init_builtin_theme():Recaptcha._set_style("");d=document.createElement("span");d.id="recaptcha_challenge_field_holder";d.style.display="none";a("recaptcha_response_field").parentNode.insertBefore(d,a("recaptcha_response_field"));a("recaptcha_response_field").setAttribute("autocomplete","off");a("recaptcha_image").style.width="300px";a("recaptcha_image").style.height="57px";Recaptcha.should_focus=false;
+Recaptcha._set_challenge(b.challenge,"image");if(c.tabindex){a("recaptcha_response_field").tabIndex=c.tabindex;if(Recaptcha.theme!="custom"){a("recaptcha_whatsthis_btn").tabIndex=c.tabindex;a("recaptcha_switch_img_btn").tabIndex=c.tabindex;a("recaptcha_switch_audio_btn").tabIndex=c.tabindex;a("recaptcha_reload_btn").tabIndex=c.tabindex}}if(Recaptcha.widget)Recaptcha.widget.style.display="";c.callback&&c.callback()},switch_type:function(a){var b=Recaptcha;b.type=a;b.reload(b.type=="audio"?"a":"v")},
+reload:function(a){var b=Recaptcha,c=RecaptchaState;if(typeof a=="undefined")a="r";c=c.server+"reload?c="+c.challenge+"&k="+c.site+"&reason="+a+"&type="+b.type+"&lang="+RecaptchaOptions.lang;if(RecaptchaOptions.includeContext)c+="&includeContext=1";if(typeof RecaptchaOptions.extra_challenge_params!="undefined")c+="&"+RecaptchaOptions.extra_challenge_params;if(b.type=="audio")c+=RecaptchaOptions.audio_beta_12_08?"&audio_beta_12_08=1":"&new_audio_default=1";b.should_focus=a!="t";b._add_script(c)},finish_reload:function(a,
+b){RecaptchaState.is_incorrect=false;Recaptcha._set_challenge(a,b)},_set_challenge:function(a,b){var c=Recaptcha,d=RecaptchaState,e=c.$;d.challenge=a;c.type=b;e("recaptcha_challenge_field_holder").innerHTML="<input type='hidden' name='recaptcha_challenge_field' id='recaptcha_challenge_field' value='"+d.challenge+"'/>";if(b=="audio")e("recaptcha_image").innerHTML=Recaptcha.getAudioCaptchaHtml();else if(b=="image"){var f=d.server+"image?c="+d.challenge;e("recaptcha_image").innerHTML="<img style='display:block;' height='57' width='300' src='"+
+f+"'/>"}Recaptcha._css_toggle("recaptcha_had_incorrect_sol","recaptcha_nothad_incorrect_sol",d.is_incorrect);Recaptcha._css_toggle("recaptcha_is_showing_audio","recaptcha_isnot_showing_audio",b=="audio");c._clear_input();c.should_focus&&c.focus_response_field();c._reset_timer()},_reset_timer:function(){var a=RecaptchaState;clearInterval(Recaptcha.timer_id);Recaptcha.timer_id=setInterval("Recaptcha.reload('t');",(a.timeout-300)*1E3)},showhelp:function(){window.open(Recaptcha._get_help_link(),"recaptcha_popup",
+"width=460,height=570,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes")},_clear_input:function(){var a=Recaptcha.$("recaptcha_response_field");a.value=""},_displayerror:function(a){var b=Recaptcha.$;b("recaptcha_image").innerHTML="";b("recaptcha_image").appendChild(document.createTextNode(a))},reloaderror:function(a){Recaptcha._displayerror(a)},_is_ie:function(){return navigator.userAgent.indexOf("MSIE")>0&&!window.opera},_css_toggle:function(a,b,c){var d=Recaptcha.widget;
+if(!d)d=document.body;var e=d.className;e=e.replace(RegExp("(^|\\s+)"+a+"(\\s+|$)")," ");e=e.replace(RegExp("(^|\\s+)"+b+"(\\s+|$)")," ");e+=" "+(c?a:b);d.className=e},_get_help_link:function(){var a=RecaptchaOptions.lang;return"http://recaptcha.net/popuphelp/"+(a=="en"?"":a+".html")},playAgain:function(){var a=Recaptcha.$;a("recaptcha_image").innerHTML=Recaptcha.getAudioCaptchaHtml()},getAudioCaptchaHtml:function(){var a=Recaptcha,b=RecaptchaState,c=b.server+"image?c="+b.challenge;if(c.indexOf("https://")==
+0)c="http://"+c.substring(8);b=b.server+"/img/audiocaptcha.swf?v2";a=a._is_ie()?'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="audiocaptcha" width="0" height="0" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="'+b+'" /><param name="quality" value="high" /><param name="bgcolor" value="#869ca7" /><param name="allowScriptAccess" value="always" /></object><br/>':'<embed src="'+b+'" quality="high" bgcolor="#869ca7" width="0" height="0" name="audiocaptcha" align="middle" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed> ';
+c=(Recaptcha.checkFlashVer()?'<br/><a class="recaptcha_audio_cant_hear_link" href="#" onclick="Recaptcha.playAgain(); return false;">'+RecaptchaStr.play_again+"</a>":"")+'<br/><a class="recaptcha_audio_cant_hear_link" target="_blank" href="'+c+'">'+RecaptchaStr.cant_hear_this+"</a>";return a+c},gethttpwavurl:function(){var a=RecaptchaState;if(Recaptcha.type=="audio"){a=a.server+"image?c="+a.challenge;if(a.indexOf("https://")==0)a="http://"+a.substring(8);return a}return""},checkFlashVer:function(){var a=
+navigator.appVersion.indexOf("MSIE")!=-1?true:false,b=navigator.appVersion.toLowerCase().indexOf("win")!=-1?true:false,c=navigator.userAgent.indexOf("Opera")!=-1?true:false,d=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){a=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";a=navigator.plugins["Shockwave Flash"+a].description;a=a.split(" ");a=a[2].split(".");d=a[0]}}else if(a&&b&&!c)try{var e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),
+f=e.GetVariable("$version");d=f.split(" ")[1].split(",")[0]}catch(g){}return d>=9},getlang:function(){return RecaptchaOptions.lang}};
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.php b/plugins/jetpack/modules/sharedaddy/sharing.php
index 48f30767..3dd6f8d4 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing.php
@@ -9,19 +9,24 @@ class Sharing_Admin {
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' ) );
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
+ add_action( 'admin_menu', array( &$this, 'subscription_menu' ) );
+
+ // Insert our CSS and JS
+ add_action( 'load-settings_page_sharing', array( &$this, 'sharing_head' ) );
// 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' ) );
+ 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 );
+ wp_enqueue_script( 'sharing-js', WP_SHARING_PLUGIN_URL.'admin-sharing.js', array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ), 2 );
+ wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL.'admin-sharing.css', false, WP_SHARING_PLUGIN_VERSION );
+ wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL.'sharing.css', false, WP_SHARING_PLUGIN_VERSION );
+ wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array( ), 2 );
add_thickbox();
}
@@ -43,10 +48,7 @@ class Sharing_Admin {
}
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' ) );
+ add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'publish_posts', 'sharing', array( &$this, 'management_page' ) );
}
public function ajax_save_services() {
@@ -102,35 +104,38 @@ class Sharing_Admin {
}
public function output_preview( $service ) {
- $klasses = array( 'advanced', 'preview-item');
+ $klasses = array( 'advanced', 'preview-item' );
- if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
+ if (
+ 'googleplus1' == $service->shortname
+ ||
+ $service->button_style != 'text'
+ ||
+ $service->has_custom_button_style()
+ ) {
$klasses[] = 'preview-'.$service->get_class();
+ $klasses[] = 'share-'.$service->get_class();
- if ( $service->get_class() != $service->get_id() )
+ if ( $service->get_class() != $service->get_id() )
$klasses[] = 'preview-'.$service->get_id();
}
echo '<li class="'.implode( ' ', $klasses ).'">';
- $service->display_preview();
+ echo $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>
+ <li class="service advanced 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 ( 0 === strpos( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?>
+ <span class="close"><a href="#" class="remove">&times;</a></span>
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
+ <input type="hidden" name="action" value="sharing_delete_service" />
+ <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>
<?php endif; ?>
</li>
<?php
@@ -157,6 +162,13 @@ class Sharing_Admin {
<div class="icon32" id="icon-options-general"><br /></div>
<h2><?php _e( 'Sharing Settings', 'jetpack' ); ?></h2>
+ <?php do_action( 'pre_admin_screen_sharing' ) ?>
+
+ <?php if ( current_user_can( 'manage_options' ) ) : ?>
+
+ <h3><?php _e( 'Sharing Buttons' ) ?></h3>
+ <p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.' ) ?></p>
+
<div id="services-config">
<table id="available-services">
<tr>
@@ -192,7 +204,7 @@ class Sharing_Admin {
<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 foreach ( $enabled['visible'] as $id => $service ) : ?>
<?php $this->output_service( $id, $service, true ); ?>
<?php endforeach; ?>
@@ -203,7 +215,7 @@ class Sharing_Admin {
<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 foreach ( $enabled['hidden'] as $id => $service ) : ?>
<?php $this->output_service( $id, $service, true ); ?>
<?php endforeach; ?>
<li class="end-fix"></li>
@@ -218,71 +230,56 @@ class Sharing_Admin {
<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">
+ <h2<?php if ( count( $enabled['all'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
+ <div class="sharedaddy sd-sharing-enabled">
<?php if ( count( $enabled['all'] ) > 0 ) : ?>
- <li class="sharing-label"><?php echo esc_html( $global['sharing_label'] ); ?></li>
+ <h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3>
<?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="sd-content">
+ <ul class="preview">
+ <?php foreach ( $enabled['visible'] as $id => $service ) : ?>
+ <?php $this->output_preview( $service ); ?>
+ <?php endforeach; ?>
+
+ <?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
+ <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
+ <?php endif; ?>
+ </ul>
+
+ <?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
<div class="sharing-hidden">
- <div class="inner" style="display: none;">
+ <div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>">
+ <?php if ( count( $enabled['hidden'] ) == 1 ) : ?>
+ <ul style="background-image:none;">
+ <?php else: ?>
<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>
+ <?php endif; ?>
+
+ <?php foreach ( $enabled['hidden'] as $id => $service ) {
+ $this->output_preview( $service );
+ }?>
+ </ul>
</div>
</div>
- </li>
- <?php endif; ?>
- </ul>
+ <?php endif; ?>
- <ul class="archive" style="display: none">
- <li class="sharing-label"><?php echo esc_html( $global['sharing_label'] ); ?></li>
+ <ul class="archive" style="display:none;">
+ <?php
+ foreach ( $sharer->get_all_services_blog() as $id => $service ) :
+ if ( isset( $enabled['visible'][$id] ) )
+ $service = $enabled['visible'][$id];
+ elseif ( isset( $enabled['hidden'][$id] ) )
+ $service = $enabled['hidden'][$id];
- <?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>
+ $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later
+ $service->smart = false;
+ $this->output_preview( $service );
+ endforeach; ?>
+ <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
+ </ul>
+ <div class="sharing-clear"></div>
+ </div>
+ </div>
<br class="clearing" />
</td>
</tr>
@@ -300,19 +297,20 @@ class Sharing_Admin {
<table class="form-table">
<tbody>
<tr valign="top">
- <th scope="row"><label><?php _e( 'Default button style', 'jetpack' ); ?></label></th>
+ <th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th>
<td>
- <select name="button_style">
+ <select name="button_style" id="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>
+ <option<?php if ( $global['button_style'] == 'official' ) echo ' selected="selected"';?> value="official"><?php _e( 'Official buttons', '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 ( FALSE === $global['sharing_label'] ) ? __( 'Share this:', 'jetpack' ) : $global['sharing_label']; ?>" />
+ <input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" />
</td>
</tr>
<tr valign="top">
@@ -325,7 +323,7 @@ class Sharing_Admin {
</td>
</tr>
<tr valign="top">
- <th scope="row"><label><?php _e( 'Show sharing buttons on', 'jetpack' ); ?></label></th>
+ <th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
<td>
<?php
$br = false;
@@ -360,13 +358,13 @@ class Sharing_Admin {
<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" />
+ <input type="text" name="sharing_name" id="new_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" />
+ <input type="text" name="sharing_url" id="new_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>
@@ -375,14 +373,14 @@ class Sharing_Admin {
<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" />
+ <input type="text" name="sharing_icon" id="new_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' ); ?>" />
+ <input type="submit" class="button-primary" value="<?php _e( 'Create Share Button', 'jetpack' ); ?>" />
<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</td>
</tr>
@@ -391,6 +389,8 @@ class Sharing_Admin {
</tbody>
</table>
+ <?php do_action( 'post_admin_screen_sharing' ) ?>
+
<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>
@@ -399,10 +399,24 @@ class Sharing_Admin {
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
</form>
</div>
+
+
+ <?php endif; ?>
+
+
</div>
<script type="text/javascript">
var sharing_loading_icon = '<?php echo esc_js( admin_url( "/images/loading.gif" ) ); ?>';
+ <?php if ( isset( $_GET['create_new_service'] ) && 'true' == $_GET['create_new_service'] ) : ?>
+ jQuery(document).ready(function() {
+ // Prefill new service box and then open it
+ jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( $_GET['name'] ); ?>' );
+ jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( $_GET['url'] ); ?>' );
+ jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( $_GET['icon'] ); ?>' );
+ jQuery( '#add-a-new-service' ).click();
+ });
+ <?php endif; ?>
</script>
<?php
}