Initial Commit

This commit is contained in:
Rumperuu 2018-03-21 18:19:20 +00:00
parent 4c352bf02e
commit 1ab6e5f0b0
1085 changed files with 195258 additions and 0 deletions

View file

@ -0,0 +1,400 @@
/**
* Sharedaddy Admin Styles
*/
#services-config {
min-width: 700px;
width: 100%;
float: right;
}
#services-config h3 {
font-weight: normal;
font-size: 15px;
margin: 0;
padding: 8px 10px;
overflow: hidden;
white-space: nowrap;
color: #464646;
}
#available-services, #enabled-services, #live-preview {
padding: 0;
width: 100%;
padding-top: 20px;
border-spacing: 0;
}
#enabled-services .ui-sortable {
min-height: 50px;
}
#enabled-services {
padding-bottom: 20px;
}
#available-services, #enabled-services {
border-bottom: 2px solid #cccccc;
}
#live-preview {
border-bottom: 1px solid #dfdfdf;
padding-bottom: 60px;
}
#available-services h3, #enabled-services h3, #live-preview h3 {
padding: 0px;
margin-top: 0px;
margin-bottom: 1em;
}
body.settings_page_sharing .description {
width: 180px;
vertical-align: top;
}
body.settings_page_sharing .description p {
font-size: 13px;
font-style: italic;
}
body.settings_page_sharing .services {
padding: 0px 20px;
vertical-align: top;
}
body.settings_page_sharing .services ul li {
float: right;
cursor: move;
}
body.settings_page_sharing .services ul li.divider {
border: none;
padding: 0;
background: none;
cursor: default;
}
body.settings_page_sharing ul.services-hidden {
margin-bottom: 0;
}
/* Generic style */
#available-services .service, #enabled-services .service {
margin-left: 10px;
padding: 5px 5px 5px 10px;
border-radius: 3px;
border: 1px solid #bbb;
background: #f8f8f8;
background-repeat: no-repeat;
background-position: center center;
}
#available-services .service:hover, #enabled-services .service:hover {
background: #fff;
border: 1px solid #bbb;
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
/* Generic style icons */
li.service span:before {
color: #555;
display: inline-block;
-webkit-font-smoothing: antialiased;
font: normal 16px/1 'Noticons', 'Genericons';
vertical-align: top;
position: relative;
top: 1px;
margin-left: 3px;
width: 16px;
height: 16px;
text-align: center;
}
li.service.share-print span:before {
content: '\f469';
}
li.service.share-digg span:before {
content: '\f221';
}
li.service.share-email span:before {
content: '\f410';
}
li.service.share-linkedin span:before {
content: '\f207';
}
li.service.share-twitter span:before {
content: '\f202';
}
li.service.share-reddit span:before {
content: '\f222';
}
li.service.share-tumblr span:before {
content: '\f214';
}
li.service.share-pocket span:before {
content: '\f224';
}
li.service.share-skype span:before {
content: '\f220';
}
li.service.share-pinterest span:before {
content: '\f209';
}
li.service.share-google-plus-1 span:before {
content: '\f218';
}
li.service.share-facebook span:before {
content: '\f204';
}
li.service.share-press-this span:before { /* Fixme: remove this button in favor of reblog */
content: '\f205';
}
/**
* Preview section
*/
body.settings_page_sharing ul.preview {
float: right;
margin: 0px;
}
body.settings_page_sharing ul.preview li.preview-item, body.settings_page_sharing ul.preview li.preview-item a {
cursor: default;
text-decoration: none;
}
div.sd-social-icon ul.preview li.preview-item a span,
div.sd-social-icon .inner li.preview-item a span {
display: none;
}
div.sd-social-icon ul.preview li.preview-item.preview-custom a span {
display: inline-block;
}
.services .preview li.share-custom a {
text-decoration: none;
}
.services ul li.end-fix {
clear:both;
float:none;
visibility:hidden;
padding:0;
margin:0;
height:20px;
width:0;
}
#enabled-services h2{
font-size:20px;
padding-top:0px;
font-weight: normal !important;
color: #999;
}
body.settings_page_sharing #live-preview h2 {
font-size:20px;
font-weight: normal !important;
color: #e3e3e3;
}
body.settings_page_sharing .clearing {
clear: both;
}
body.settings_page_sharing .options .options-left {
float: right;
}
body.settings_page_sharing .input label {
font-size: 11px;
line-height: 16px;
}
body.settings_page_sharing .advanced-form {
padding: 10px 10px 8px 14px;
margin-right: -24px;
display: none;
border-top: 1px #e3e3e3 solid;
margin-top:4px;
}
body.settings_page_sharing .utility {
float: left;
padding-top:10px;
padding-left: 10px;
font-size: 10px;
}
body.settings_page_sharing .advanced input[type=submit] {
float: right;
margin-top:10px;
margin-left: 10px;
}
.services li.dropzone {
border: 1px dashed #999;
border-radius: 3px;
background: #e3e3e3;
margin-left: 10px;
padding: 5px;
height: 18px;
}
.advanced-form .form-table th {
width: auto !important;
}
.advanced-form .button-secondary {
margin-top: 0 !important;
}
#hidden-drop-target {
background: #e1e1e1;
border: 1px solid #cdcdcd;
width: 29%;
padding: 10px;
vertical-align: top;
}
#hidden-drop-target p {
font-size: 13px;
font-style: italic;
margin: 0 0 10px 0;
}
/* Official button previews */
.preview li.preview-item {
background-position: 0px 5px;
cursor: default;
}
.preview .option-smart-on {
margin: 3px 0 0 5px;
}
.preview-digg .option-smart-on {
background: url(images/smart-digg.png) no-repeat top right;
background-size: 76px 17px;
width:76px;
height:17px;
margin-top: 2px;
}
.preview-reddit .option-smart-on {
background: url(images/smart-reddit.png) no-repeat top right;
background-size: 104px 21px;
width:104px;
height:21px;
}
.preview-facebook .option-smart-on {
background: url(images/smart-like.png) no-repeat top right;
background-size: 85px 20px;
width:85px;
height:20px;
}
.preview-twitter .option-smart-on {
background: url(images/smart-twitter.png?1) no-repeat top right;
background-size: 60px 20px;
width:60px;
height:20px;
}
.preview-linkedin .option-smart-on {
background: url(images/linkedin-smart.png) no-repeat top center;
background-size: 99px 18px;
width:99px;
height:18px;
margin-top: 1px;
}
.preview-google-plus-1 .option-smart-on {
background: url(images/smart-googleplus1.png) no-repeat top right;
background-size: 96px 20px;
width: 96px;
height: 20px;
}
.preview-tumblr .option-smart-on {
background: url(images/smart-tumblr.png) no-repeat top right;
background-size: 62px 20px;
width: 62px;
height: 20px;
}
.preview-pinterest .option-smart-on {
background: url(images/smart-pinterest.png) no-repeat top right;
background-size: 39px 20px;
width: 39px;
height: 20px;
}
.preview-pocket .option-smart-on {
background: url(images/smart-pocket.png) no-repeat top right;
background-size: 60px 20px;
width: 60px;
height: 20px;
}
.preview-skype .option-smart-on {
background: url(images/smart-skype.png) no-repeat top right;
background-size: 60px 20px;
width: 60px;
height: 20px;
}
/**
* Overflow sharing dialog
*/
.services .sharing-hidden li {
background-color: transparent;
}
.sharing-hidden li.share-end {
clear: both;
height: 0;
padding: 0px !important;
margin: 0px !important;
width: 0;
visibility: hidden;
float: none;
}
.preview .sharing-label {
font-weight: bold;
border: 0;
padding: 4px 0 0 6px;
}
#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;
}
.sd-social-icon .inner a.sd-button span,
.sd-social-icon .inner a.share-icon span {
display: inline-block;
overflow: hidden;
width: 0;
text-indent: 100%;
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,400 @@
/**
* Sharedaddy Admin Styles
*/
#services-config {
min-width: 700px;
width: 100%;
float: left;
}
#services-config h3 {
font-weight: normal;
font-size: 15px;
margin: 0;
padding: 8px 10px;
overflow: hidden;
white-space: nowrap;
color: #464646;
}
#available-services, #enabled-services, #live-preview {
padding: 0;
width: 100%;
padding-top: 20px;
border-spacing: 0;
}
#enabled-services .ui-sortable {
min-height: 50px;
}
#enabled-services {
padding-bottom: 20px;
}
#available-services, #enabled-services {
border-bottom: 2px solid #cccccc;
}
#live-preview {
border-bottom: 1px solid #dfdfdf;
padding-bottom: 60px;
}
#available-services h3, #enabled-services h3, #live-preview h3 {
padding: 0px;
margin-top: 0px;
margin-bottom: 1em;
}
body.settings_page_sharing .description {
width: 180px;
vertical-align: top;
}
body.settings_page_sharing .description p {
font-size: 13px;
font-style: italic;
}
body.settings_page_sharing .services {
padding: 0px 20px;
vertical-align: top;
}
body.settings_page_sharing .services ul li {
float: left;
cursor: move;
}
body.settings_page_sharing .services ul li.divider {
border: none;
padding: 0;
background: none;
cursor: default;
}
body.settings_page_sharing ul.services-hidden {
margin-bottom: 0;
}
/* Generic style */
#available-services .service, #enabled-services .service {
margin-right: 10px;
padding: 5px 10px 5px 5px;
border-radius: 3px;
border: 1px solid #bbb;
background: #f8f8f8;
background-repeat: no-repeat;
background-position: center center;
}
#available-services .service:hover, #enabled-services .service:hover {
background: #fff;
border: 1px solid #bbb;
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
/* Generic style icons */
li.service span:before {
color: #555;
display: inline-block;
-webkit-font-smoothing: antialiased;
font: normal 16px/1 'Noticons', 'Genericons';
vertical-align: top;
position: relative;
top: 1px;
margin-right: 3px;
width: 16px;
height: 16px;
text-align: center;
}
li.service.share-print span:before {
content: '\f469';
}
li.service.share-digg span:before {
content: '\f221';
}
li.service.share-email span:before {
content: '\f410';
}
li.service.share-linkedin span:before {
content: '\f207';
}
li.service.share-twitter span:before {
content: '\f202';
}
li.service.share-reddit span:before {
content: '\f222';
}
li.service.share-tumblr span:before {
content: '\f214';
}
li.service.share-pocket span:before {
content: '\f224';
}
li.service.share-skype span:before {
content: '\f220';
}
li.service.share-pinterest span:before {
content: '\f209';
}
li.service.share-google-plus-1 span:before {
content: '\f218';
}
li.service.share-facebook span:before {
content: '\f204';
}
li.service.share-press-this span:before { /* Fixme: remove this button in favor of reblog */
content: '\f205';
}
/**
* Preview section
*/
body.settings_page_sharing ul.preview {
float: left;
margin: 0px;
}
body.settings_page_sharing ul.preview li.preview-item, body.settings_page_sharing ul.preview li.preview-item a {
cursor: default;
text-decoration: none;
}
div.sd-social-icon ul.preview li.preview-item a span,
div.sd-social-icon .inner li.preview-item a span {
display: none;
}
div.sd-social-icon ul.preview li.preview-item.preview-custom a span {
display: inline-block;
}
.services .preview li.share-custom a {
text-decoration: none;
}
.services ul li.end-fix {
clear:both;
float:none;
visibility:hidden;
padding:0;
margin:0;
height:20px;
width:0;
}
#enabled-services h2{
font-size:20px;
padding-top:0px;
font-weight: normal !important;
color: #999;
}
body.settings_page_sharing #live-preview h2 {
font-size:20px;
font-weight: normal !important;
color: #e3e3e3;
}
body.settings_page_sharing .clearing {
clear: both;
}
body.settings_page_sharing .options .options-left {
float: left;
}
body.settings_page_sharing .input label {
font-size: 11px;
line-height: 16px;
}
body.settings_page_sharing .advanced-form {
padding: 10px 14px 8px 10px;
margin-left: -24px;
display: none;
border-top: 1px #e3e3e3 solid;
margin-top:4px;
}
body.settings_page_sharing .utility {
float: right;
padding-top:10px;
padding-right: 10px;
font-size: 10px;
}
body.settings_page_sharing .advanced input[type=submit] {
float: left;
margin-top:10px;
margin-right: 10px;
}
.services li.dropzone {
border: 1px dashed #999;
border-radius: 3px;
background: #e3e3e3;
margin-right: 10px;
padding: 5px;
height: 18px;
}
.advanced-form .form-table th {
width: auto !important;
}
.advanced-form .button-secondary {
margin-top: 0 !important;
}
#hidden-drop-target {
background: #e1e1e1;
border: 1px solid #cdcdcd;
width: 29%;
padding: 10px;
vertical-align: top;
}
#hidden-drop-target p {
font-size: 13px;
font-style: italic;
margin: 0 0 10px 0;
}
/* Official button previews */
.preview li.preview-item {
background-position: 0px 5px;
cursor: default;
}
.preview .option-smart-on {
margin: 3px 5px 0 0;
}
.preview-digg .option-smart-on {
background: url(images/smart-digg.png) no-repeat top left;
background-size: 76px 17px;
width:76px;
height:17px;
margin-top: 2px;
}
.preview-reddit .option-smart-on {
background: url(images/smart-reddit.png) no-repeat top left;
background-size: 104px 21px;
width:104px;
height:21px;
}
.preview-facebook .option-smart-on {
background: url(images/smart-like.png) no-repeat top left;
background-size: 85px 20px;
width:85px;
height:20px;
}
.preview-twitter .option-smart-on {
background: url(images/smart-twitter.png?1) no-repeat top left;
background-size: 60px 20px;
width:60px;
height:20px;
}
.preview-linkedin .option-smart-on {
background: url(images/linkedin-smart.png) no-repeat top center;
background-size: 99px 18px;
width:99px;
height:18px;
margin-top: 1px;
}
.preview-google-plus-1 .option-smart-on {
background: url(images/smart-googleplus1.png) no-repeat top left;
background-size: 96px 20px;
width: 96px;
height: 20px;
}
.preview-tumblr .option-smart-on {
background: url(images/smart-tumblr.png) no-repeat top left;
background-size: 62px 20px;
width: 62px;
height: 20px;
}
.preview-pinterest .option-smart-on {
background: url(images/smart-pinterest.png) no-repeat top left;
background-size: 39px 20px;
width: 39px;
height: 20px;
}
.preview-pocket .option-smart-on {
background: url(images/smart-pocket.png) no-repeat top left;
background-size: 60px 20px;
width: 60px;
height: 20px;
}
.preview-skype .option-smart-on {
background: url(images/smart-skype.png) no-repeat top left;
background-size: 60px 20px;
width: 60px;
height: 20px;
}
/**
* Overflow sharing dialog
*/
.services .sharing-hidden li {
background-color: transparent;
}
.sharing-hidden li.share-end {
clear: both;
height: 0;
padding: 0px !important;
margin: 0px !important;
width: 0;
visibility: hidden;
float: none;
}
.preview .sharing-label {
font-weight: bold;
border: 0;
padding: 4px 6px 0 0;
}
#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;
}
.sd-social-icon .inner a.sd-button span,
.sd-social-icon .inner a.share-icon span {
display: inline-block;
overflow: hidden;
width: 0;
text-indent: 100%;
}

View file

@ -0,0 +1,440 @@
/* jshint onevar: false, smarttabs: true */
/* global sharing_loading_icon */
(function($) {
$( document ).ready(function() {
function enable_share_button() {
$( '.preview a.sharing-anchor' ).unbind( 'mouseenter mouseenter' ).hover( function() {
if ( $( this ).data( 'hasappeared' ) !== true ) {
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'
} ).slideDown( 200, function() {
// Mark the item as have being appeared by the hover
$( original ).data( 'hasappeared', true ).data( 'hasoriginal', true ).data( 'hasitem', false );
// Remove all special handlers
$( item ).mouseleave( handler_item_leave ).mouseenter( handler_item_enter );
$( original ).mouseleave( handler_original_leave ).mouseenter( handler_original_enter );
// Add a special handler to quickly close the item
$( original ).click( close_it );
} );
// The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area
var handler_item_leave = function() {
$( original ).data( 'hasitem', false );
if ( $( original ).data( 'hasoriginal' ) === false ) {
var timer = setTimeout( close_it, 800 );
$( original ).data( 'timer2', timer );
}
};
var handler_item_enter = function() {
$( original ).data( 'hasitem', true );
clearTimeout( $( original ).data( 'timer2' ) );
};
var handler_original_leave = function() {
$( original ).data( 'hasoriginal', false );
if ( $( original ).data( 'hasitem' ) === false ) {
var timer = setTimeout( close_it, 800 );
$( original ).data( 'timer2', timer );
}
};
var handler_original_enter = function() {
$( original ).data( 'hasoriginal', true );
clearTimeout( $( original ).data( 'timer2' ) );
};
var close_it = function() {
item.slideUp( 200 );
// Clear all hooks
$( original ).unbind( 'mouseleave', handler_original_leave ).unbind( 'mouseenter', handler_original_enter );
$( item ).unbind( 'mouseleave', handler_item_leave ).unbind( 'mouseenter', handler_item_leave );
$( original ).data( 'hasappeared', false );
$( original ).unbind( 'click', close_it );
return false;
};
}, 200 );
// Remember the timer so we can detect it on the mouseout
$( this ).data( 'timer', timer );
}
}, function() {
// Mouse out - remove any timer
clearTimeout( $( this ).data( 'timer' ) );
$( this ).data( 'timer', false );
} );
}
function update_preview() {
var button_style = $( '#button_style' ).val();
// Clear the live preview
$( '#live-preview ul.preview li' ).remove();
// Add label
if ( $( '#save-enabled-shares input[name=visible]' ).val() || $( '#save-enabled-shares input[name=hidden]' ).val() ) {
$( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .sharing-label' ).clone() );
}
// Re-insert all the enabled items
$( 'ul.services-enabled li' ).each( function() {
if ( $( this ).hasClass( 'service' ) ) {
var service = $( this ).attr( 'id' );
$( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive li.preview-' + service ).clone() );
}
} );
// 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-more' ).parent().clone() );
$( '.sharing-hidden ul li' ).remove();
// Add hidden items into the inner panel
$( 'ul.services-hidden li' ).each( function( /*pos, item*/ ) {
if ( $( this ).hasClass( 'service' ) ) {
var service = $( this ).attr( 'id' );
$( '.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 ( 'icon' === button_style ) {
$( '#live-preview ul.preview div span, .sharing-hidden .inner ul div span' ).html( ' ' ).parent().addClass( 'no-text' );
$( '#live-preview div.sharedaddy' ).addClass( 'sd-social-icon' );
} else if ( 'official' === button_style ) {
$( '#live-preview ul.preview .advanced, .sharing-hidden .inner ul .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' );
}
}
window.sharing_option_changed = function() {
var item = this;
// Loading icon
$( this ).parents( 'li:first' ).css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
// Save
$( this ).parents( 'form' ).ajaxSubmit( function( response ) {
if ( response.indexOf( '<!---' ) >= 0 ) {
var button = response.substring( 0, response.indexOf( '<!--->' ) );
var preview = response.substring( response.indexOf( '<!--->' ) + 6 );
if ( $( item ).is( ':submit' ) === true ) {
// Update the DOM using a bit of cut/paste technology
$( item ).parents( 'li:first' ).replaceWith( button );
}
$( '#live-preview ul.archive li.preview-' + $( item ).parents( 'form' ).find( 'input[name=service]' ).val() ).replaceWith( preview );
}
// Update preview
update_preview();
// Restore the icon
$( item ).parents( 'li:first' ).removeAttr( 'style' );
} );
if ( $( item ).is( ':submit' ) === true ) {
return false;
}
return true;
};
function showExtraOptions( service ) {
jQuery( '.' + service + '-extra-options' ).css( { backgroundColor: '#ffffcc' } ).fadeIn();
}
function hideExtraOptions( service ) {
jQuery( '.' + service + '-extra-options' ).fadeOut( 'slow' );
}
function save_services() {
$( '#enabled-services h3 img' ).show();
// Toggle various dividers/help texts
if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) {
$( '#drag-instructions' ).hide();
}
else {
$( '#drag-instructions' ).show();
}
if ( $( '#enabled-services li.service' ).length > 0 ) {
$( '#live-preview .services h2' ).hide();
}
else {
$( '#live-preview .services h2' ).show();
}
// Gather the modules
var visible = [], hidden = [];
$( 'ul.services-enabled li' ).each( function() {
if ( $( this ).hasClass( 'service' ) ) {
// Ready for saving
visible[visible.length] = $( this ).attr( 'id' );
showExtraOptions( $( this ).attr( 'id' ) );
}
} );
$( 'ul.services-available li' ).each( function() {
if ( $( this ).hasClass( 'service' ) ) {
hideExtraOptions( $( this ).attr( 'id' ) );
}
} );
$( 'ul.services-hidden li' ).each( function() {
if ( $( this ).hasClass( 'service' ) ) {
// Ready for saving
hidden[hidden.length] = $( this ).attr( 'id' );
showExtraOptions( $( this ).attr( 'id' ) );
}
} );
// Set the hidden element values
$( '#save-enabled-shares input[name=visible]' ).val( visible.join( ',' ) );
$( '#save-enabled-shares input[name=hidden]' ).val( hidden.join( ',' ) );
update_preview();
// Save it
$( '#save-enabled-shares' ).ajaxSubmit( function() {
$( '#enabled-services h3 img' ).hide();
} );
}
$( '#enabled-services .services ul' ).sortable( {
receive: function( /*event, ui*/ ) {
save_services();
},
stop: function() {
save_services();
$( 'li.service' ).enableSelection(); // Fixes a problem with Chrome
},
over: function( /*event, ui*/ ) {
$( this ).find( 'ul' ).addClass( 'dropping' );
// Ensure the 'end-fix' is at the end
$( '#enabled-services li.end-fix' ).remove();
$( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
},
out: function( /*event, ui*/ ) {
$( this ).find( 'ul' ).removeClass( 'dropping' );
// Ensure the 'end-fix' is at the end
$( '#enabled-services li.end-fix' ).remove();
$( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
},
helper: function( event, ui ) {
ui.find( '.advanced-form' ).hide();
return ui.clone();
},
start: function( /*event, ui*/ ) {
// Make sure that the advanced section is closed
$( '.advanced-form' ).hide();
$( 'li.service' ).disableSelection(); // Fixes a problem with Chrome
},
placeholder: 'dropzone',
opacity: 0.8,
delay: 150,
forcePlaceholderSize: true,
items: 'li',
connectWith: '#available-services ul, #enabled-services .services ul',
cancel: '.advanced-form'
} );
$( '#available-services ul' ).sortable( {
opacity: 0.8,
delay: 150,
cursor: 'move',
connectWith: '#enabled-services .services ul',
placeholder: 'dropzone',
forcePlaceholderSize: true,
start: function() {
$( '.advanced-form' ).hide();
}
} );
// Accessibility keyboard shortcurts
$( '.service' ).on( 'keydown', function ( e ) {
// Reposition if one of the directional keys is pressed
switch ( e.keyCode ) {
case 13: keyboardDragDrop( $( this ) ); break; // Enter
case 32: keyboardDragDrop( $( this ) ); break; // Space
case 37: keyboardChangeOrder( $( this ), 'left' ); break; // Left
case 39: keyboardChangeOrder( $( this ), 'right' ); break; // Right
default: return true; // Exit and bubble
}
e.preventDefault();
});
function keyboardChangeOrder( $this, dir ) {
var thisParent = $this.parent(),
thisParentsChildren = thisParent.find( 'li' ),
thisPosition = thisParentsChildren.index( $this ) + 1,
totalChildren = thisParentsChildren.length - 1,
thisService;
// No need to be able to sort order for the "Available Services" section
if ( thisParent.hasClass( 'services-available' ) ) {
return;
}
if ( 'left' === dir ) {
if ( 1 === thisPosition ) {
return;
}
// Find service to left
var prevSibling = $this.prev();
// Detach this service from DOM
thisService = $this.detach();
// Move it to the appropriate area and add focus back to service
prevSibling.before( thisService );
// Add focus
prevSibling.prev().focus();
}
if ( 'right' === dir ) {
if ( thisPosition === totalChildren ) {
return;
}
// Find service to left
var nextSibling = $this.next();
// Detach this service from DOM
thisService = $this.detach();
// Move it to the appropriate area and add focus back to service
nextSibling.after( thisService );
// Add focus
nextSibling.next().focus();
}
//Save changes
save_services();
}
function keyboardDragDrop( $this ) {
var dropzone,
thisParent = $this.parent();
// Rotate through 3 available dropzones
if ( thisParent.hasClass( 'services-available' ) ) {
dropzone = 'services-enabled';
} else if ( thisParent.hasClass( 'services-enabled' ) ) {
dropzone = 'services-hidden';
} else {
dropzone = 'services-available';
}
// Detach this service from DOM
var thisService = $this.detach();
// Move it to the appropriate area and add focus back to service
$( '.' + dropzone ).prepend( thisService ).find( 'li:first-child' ).focus();
//Save changes
save_services();
}
// Live preview 'hidden' button
$( '.preview-hidden a' ).click( function() {
$( this ).parent().find( '.preview' ).toggle();
return false;
} );
// Add service
$( '#new-service form' ).ajaxForm( {
beforeSubmit: function() {
$( '#new-service-form .error' ).hide();
$( '#new-service-form img' ).show();
$( '#new-service-form input[type=submit]' ).prop( 'disabled', true );
},
success: function( response ) {
$( '#new-service-form img' ).hide();
if ( ( '' + response ) === '1' ) {
$( '#new-service-form .inerror' ).removeClass( 'inerror' ).addClass( 'error' );
$( '#new-service-form .error' ).show();
$( '#new-service-form input[type=submit]' ).prop( 'disabled', false );
}
else {
document.location = document.location.href.replace( /&create_new_service=true/i, '' );
}
}
}
);
function init_handlers() {
$( '#services-config a.remove' ).unbind( 'click' ).click( function() {
var form = $( this ).parent().next();
// Loading icon
$( this ).parents( 'li:first' ).css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
// Save
form.ajaxSubmit( function( /*response*/ ) {
// Remove the item
form.parents( 'li:first' ).fadeOut( function() {
$( this ).remove();
// Update preview
update_preview();
} );
} );
return false;
} );
}
$( '#button_style' ).change( function() {
update_preview();
return true;
} ).change();
$( 'input[name=sharing_label]' ).blur( function() {
$('#live-preview h3.sd-title').text( $( '<div/>' ).text( $( this ).val() ).html() );
} );
init_handlers();
enable_share_button();
} );
})( jQuery );

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,179 @@
<?php
/**
* Class that handles reCAPTCHA.
*/
class Jetpack_ReCaptcha {
/**
* URL to which requests are POSTed.
*
* @const string
*/
const VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
/**
* Site key to use in HTML code.
*
* @var string
*/
private $site_key;
/**
* Shared secret for the site.
*
* @var string
*/
private $secret_key;
/**
* Config for reCAPTCHA instance.
*
* @var array
*/
private $config;
/**
* Error codes returned from reCAPTCHA API.
*
* @see https://developers.google.com/recaptcha/docs/verify
*
* @var array
*/
private $error_codes;
/**
* Create a configured instance to use the reCAPTCHA service.
*
* @param string $site_key Site key to use in HTML code.
* @param string $secret_key Shared secret between site and reCAPTCHA server.
* @param array $config Config array to optionally configure reCAPTCHA instance.
*/
public function __construct( $site_key, $secret_key, $config = array() ) {
$this->site_key = $site_key;
$this->secret_key = $secret_key;
$this->config = wp_parse_args( $config, $this->get_default_config() );
$this->error_codes = array(
'missing-input-secret' => __( 'The secret parameter is missing', 'jetpack' ),
'invalid-input-secret' => __( 'The secret parameter is invalid or malformed', 'jetpack' ),
'missing-input-response' => __( 'The response parameter is missing', 'jetpack' ),
'invalid-input-response' => __( 'The response parameter is invalid or malformed', 'jetpack' ),
'invalid-json' => __( 'Invalid JSON', 'jetpack' ),
'unexpected-response' => __( 'Unexpected response', 'jetpack' ),
);
}
/**
* Get default config for this reCAPTCHA instance.
*
* @return array Default config
*/
public function get_default_config() {
return array(
'language' => get_locale(),
'script_async' => true,
'tag_class' => 'g-recaptcha',
'tag_attributes' => array(
'theme' => 'light',
'type' => 'image',
'tabindex' => 0,
),
);
}
/**
* Calls the reCAPTCHA siteverify API to verify whether the user passes
* CAPTCHA test.
*
* @param string $response The value of 'g-recaptcha-response' in the submitted
* form.
* @param string $remote_ip The end user's IP address.
*
* @return bool|WP_Error Returns true if verified. Otherwise WP_Error is returned.
*/
public function verify( $response, $remote_ip ) {
// No need make a request if response is empty.
if ( empty( $response ) ) {
return new WP_Error( 'missing-input-response', $this->error_codes['missing-input-response'], 400 );
}
$resp = wp_remote_post( self::VERIFY_URL, $this->get_verify_request_params( $response, $remote_ip ) );
if ( is_wp_error( $resp ) ) {
return $resp;
}
$resp_decoded = json_decode( wp_remote_retrieve_body( $resp ), true );
if ( ! $resp_decoded ) {
return new WP_Error( 'invalid-json', $this->error_codes['invalid-json'], 400 );
}
// Default error code and message.
$error_code = 'unexpected-response';
$error_message = $this->error_codes['unexpected-response'];
// Use the first error code if exists.
if ( isset( $resp_decoded['error-codes'] ) && is_array( $resp_decoded['error-codes'] ) ) {
if ( isset( $resp_decoded['error-codes'][0] ) && isset( $this->error_codes[ $resp_decoded['error-codes'][0] ] ) ) {
$error_message = $this->error_codes[ $resp_decoded['error-codes'][0] ];
$error_code = $resp_decoded['error-codes'][0];
}
}
if ( ! isset( $resp_decoded['success'] ) ) {
return new WP_Error( $error_code, $error_message );
}
if ( true !== $resp_decoded['success'] ) {
return new WP_Error( $error_code, $error_message );
}
return true;
}
/**
* Get siteverify request parameters.
*
* @param string $response The value of 'g-recaptcha-response' in the submitted
* form.
* @param string $remote_ip The end user's IP address.
*
* @return array
*/
public function get_verify_request_params( $response, $remote_ip ) {
return array(
'body' => array(
'secret' => $this->secret_key,
'response' => $response,
'remoteip' => $remote_ip,
),
'sslverify' => true,
);
}
/**
* Get reCAPTCHA HTML to render.
*
* @return string
*/
public function get_recaptcha_html() {
return sprintf(
'
<div
class="%s"
data-sitekey="%s"
data-theme="%s"
data-type="%s"
data-tabindex="%s"></div>
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=%s"%s></script>
',
esc_attr( $this->config['tag_class'] ),
esc_attr( $this->site_key ),
esc_attr( $this->config['tag_attributes']['theme'] ),
esc_attr( $this->config['tag_attributes']['type'] ),
esc_attr( $this->config['tag_attributes']['tabindex'] ),
rawurlencode( $this->config['language'] ),
$this->config['script_async'] ? ' async' : ''
);
}
}

View file

@ -0,0 +1,260 @@
<?php
/*
Plugin Name: Sharedaddy
Description: The most super duper sharing tool on the interwebs.
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/
*/
require_once plugin_dir_path( __FILE__ ).'sharing.php';
function sharing_email_send_post( $data ) {
$content = sharing_email_send_post_content( $data );
// Borrowed from wp_mail();
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
$sitename = substr( $sitename, 4 );
}
/** This filter is documented in core/src/wp-includes/pluggable.php */
$from_email = apply_filters( 'wp_mail_from', 'wordpress@' . $sitename );
$headers[] = sprintf( 'From: %1$s <%2$s>', $data['name'], $from_email );
$headers[] = sprintf( 'Reply-To: %1$s <%2$s>', $data['name'], $data['source'] );
wp_mail( $data['target'], '['.__( 'Shared Post', 'jetpack' ).'] '.$data['post']->post_title, $content, $headers );
}
/* Checks for spam using akismet if available. */
/* Return $data as it if email about to be send out is not spam. */
function sharing_email_check_for_spam_via_akismet( $data ) {
if ( ! function_exists( 'akismet_http_post' ) && ! method_exists( 'Akismet', 'http_post' ) )
return $data;
// Prepare the body_request for akismet
$body_request = array(
'blog' => get_option( 'home' ),
'permalink' => get_permalink( $data['post']->ID ),
'comment_type' => 'share',
'comment_author' => $data['name'],
'comment_author_email' => $data['source'],
'comment_content' => sharing_email_send_post_content( $data ),
'user_agent' => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null ),
);
if ( method_exists( 'Akismet', 'http_post' ) ) {
$body_request['user_ip'] = Akismet::get_ip_address();
$response = Akismet::http_post( build_query( $body_request ), 'comment-check' );
} else {
global $akismet_api_host, $akismet_api_port;
$body_request['user_ip'] = ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null );
$response = akismet_http_post( build_query( $body_request ), $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
}
// The Response is spam lets not send the email.
if ( ! empty( $response ) && isset( $response[1] ) && 'true' == trim( $response[1] ) ) { // 'true' is spam
return false; // don't send the email
}
return $data;
}
function sharing_email_send_post_content( $data ) {
/* translators: included in e-mail when post is shared via e-mail. First item is sender's name. Second is sender's e-mail address. */
$content = sprintf( __( '%1$s (%2$s) thinks you may be interested in the following post:', 'jetpack' ), $data['name'], $data['source'] );
$content .= "\n\n";
$content .= $data['post']->post_title."\n";
$content .= get_permalink( $data['post']->ID )."\n";
return $content;
}
function sharing_add_meta_box() {
global $post;
if ( empty( $post ) ) { // If a current post is not defined, such as when editing a comment.
return;
}
/**
* Filter whether to display the Sharing Meta Box or not.
*
* @module sharedaddy
*
* @since 3.8.0
*
* @param bool true Display Sharing Meta Box.
* @param $post Post.
*/
if ( ! apply_filters( 'sharing_meta_box_show', true, $post ) ) {
return;
}
$post_types = get_post_types( array( 'public' => true ) );
/**
* Filter the Sharing Meta Box title.
*
* @module sharedaddy
*
* @since 2.2.0
*
* @param string $var Sharing Meta Box title. Default is "Sharing".
*/
$title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );
if ( $post->ID !== get_option( 'page_for_posts' ) ) {
foreach( $post_types as $post_type ) {
add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'advanced', 'high' );
}
}
}
function sharing_meta_box_content( $post ) {
/**
* Fires before the sharing meta box content.
*
* @module sharedaddy
*
* @since 2.2.0
*
* @param WP_Post $post The post to share.
*/
do_action( 'start_sharing_meta_box_content', $post );
$disabled = get_post_meta( $post->ID, 'sharing_disabled', true ); ?>
<p>
<label for="enable_post_sharing">
<input type="checkbox" name="enable_post_sharing" id="enable_post_sharing" value="1" <?php checked( !$disabled ); ?>>
<?php _e( 'Show sharing buttons.' , 'jetpack'); ?>
</label>
<input type="hidden" name="sharing_status_hidden" value="1" />
</p>
<?php
/**
* Fires after the sharing meta box content.
*
* @module sharedaddy
*
* @since 2.2.0
*
* @param WP_Post $post The post to share.
*/
do_action( 'end_sharing_meta_box_content', $post );
}
function sharing_meta_box_save( $post_id ) {
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
// Record sharing disable
if ( isset( $_POST['post_type'] ) && ( $post_type_object = get_post_type_object( $_POST['post_type'] ) ) && $post_type_object->public ) {
if ( current_user_can( 'edit_post', $post_id ) ) {
if ( isset( $_POST['sharing_status_hidden'] ) ) {
if ( !isset( $_POST['enable_post_sharing'] ) ) {
update_post_meta( $post_id, 'sharing_disabled', 1 );
} else {
delete_post_meta( $post_id, 'sharing_disabled' );
}
}
}
}
return $post_id;
}
function sharing_meta_box_protected( $protected, $meta_key, $meta_type ) {
if ( 'sharing_disabled' == $meta_key )
$protected = true;
return $protected;
}
add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 3 );
function sharing_plugin_settings( $links ) {
$settings_link = '<a href="options-general.php?page=sharing.php">'.__( 'Settings', 'jetpack' ).'</a>';
array_unshift( $links, $settings_link );
return $links;
}
function sharing_add_plugin_settings($links, $file) {
if ( $file == basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ) ) {
$links[] = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
$links[] = '<a href="http://support.wordpress.com/sharing/" target="_blank">' . __( 'Support', 'jetpack' ) . '</a>';
}
return $links;
}
function sharing_restrict_to_single( $services ) {
// This removes Press This from non-multisite blogs - doesn't make much sense
if ( is_multisite() === false ) {
unset( $services['press-this'] );
}
return $services;
}
function sharing_init() {
if ( get_option( 'sharedaddy_disable_resources' ) ) {
add_filter( 'sharing_js', 'sharing_disable_js' );
remove_action( 'wp_head', 'sharing_add_header', 1 );
}
}
function sharing_disable_js() {
return false;
}
function sharing_global_resources() {
$disable = get_option( 'sharedaddy_disable_resources' );
?>
<tr valign="top">
<th scope="row"><label for="disable_css"><?php _e( 'Disable CSS and JS', 'jetpack' ); ?></label></th>
<td>
<input id="disable_css" type="checkbox" name="disable_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 sharing_global_resources_save() {
update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 );
}
function sharing_email_dialog() {
require_once plugin_dir_path( __FILE__ ) . 'recaptcha.php';
$recaptcha = new Jetpack_ReCaptcha( RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY );
echo $recaptcha->get_recaptcha_html(); // xss ok
}
function sharing_email_check( $true, $post, $data ) {
require_once plugin_dir_path( __FILE__ ) . 'recaptcha.php';
$recaptcha = new Jetpack_ReCaptcha( RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY );
$response = ! empty( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
$result = $recaptcha->verify( $response, $_SERVER['REMOTE_ADDR'] );
return ( true === $result );
}
add_action( 'init', 'sharing_init' );
add_action( 'add_meta_boxes', 'sharing_add_meta_box' );
add_action( 'save_post', 'sharing_meta_box_save' );
add_action( 'sharing_email_send_post', 'sharing_email_send_post' );
add_filter( 'sharing_email_can_send', 'sharing_email_check_for_spam_via_akismet' );
add_action( 'sharing_global_options', 'sharing_global_resources', 30 );
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_PUBLIC_KEY' ) && defined( 'RECAPTCHA_PRIVATE_KEY' ) ) {
add_action( 'sharing_email_dialog', 'sharing_email_dialog' );
add_filter( 'sharing_email_check', 'sharing_email_check', 10, 3 );
}

View file

@ -0,0 +1,794 @@
<?php
include_once dirname( __FILE__ ).'/sharing-sources.php';
define( 'WP_SHARING_PLUGIN_VERSION', JETPACK__VERSION );
class Sharing_Service {
private $global = false;
public $default_sharing_label = '';
public function __construct() {
$this->default_sharing_label = __( 'Share this:', 'jetpack' );
}
/**
* Gets a generic list of all services, without any config
*/
public function get_all_services_blog() {
$options = get_option( 'sharing-options' );
$all = $this->get_all_services();
$services = array();
foreach ( $all AS $id => $name ) {
if ( isset( $all[$id] ) ) {
$config = array();
// Pre-load custom modules otherwise they won't know who they are
if ( substr( $id, 0, 7 ) == 'custom-' && is_array( $options[$id] ) )
$config = $options[$id];
$services[$id] = new $all[$id]( $id, $config );
}
}
return $services;
}
/**
* Gets a list of all available service names and classes
*/
public function get_all_services( $include_custom = true ) {
// Default services
// if you update this list, please update the REST API tests
// in bin/tests/api/suites/SharingTest.php
$services = array(
'email' => 'Share_Email',
'print' => 'Share_Print',
'facebook' => 'Share_Facebook',
'linkedin' => 'Share_LinkedIn',
'reddit' => 'Share_Reddit',
'twitter' => 'Share_Twitter',
'press-this' => 'Share_PressThis',
'google-plus-1' => 'Share_GooglePlus1',
'tumblr' => 'Share_Tumblr',
'pinterest' => 'Share_Pinterest',
'pocket' => 'Share_Pocket',
'skype' => 'Share_Skype',
);
if ( $include_custom ) {
// Add any custom services in
$options = $this->get_global_options();
foreach ( (array) $options['custom'] AS $custom_id ) {
$services[$custom_id] = 'Share_Custom';
}
}
/**
* Filters the list of available Sharing Services.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $services Array of all available Sharing Services.
*/
return apply_filters( 'sharing_services', $services );
}
public function new_service( $label, $url, $icon ) {
// Validate
$label = trim( wp_html_excerpt( wp_kses( $label, array() ), 30 ) );
$url = trim( esc_url_raw( $url ) );
$icon = trim( esc_url_raw( $icon ) );
if ( $label && $url && $icon ) {
$options = get_option( 'sharing-options' );
if ( !is_array( $options ) )
$options = array();
$service_id = 'custom-'.time();
// Add a new custom service
$options['global']['custom'][] = $service_id;
if ( false !== $this->global ) {
$this->global['custom'][] = $service_id;
}
update_option( 'sharing-options', $options );
// Create a custom service and set the options for it
$service = new Share_Custom( $service_id, array( 'name' => $label, 'url' => $url, 'icon' => $icon ) );
$this->set_service( $service_id, $service );
// Return the service
return $service;
}
return false;
}
public function delete_service( $service_id ) {
$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;
}
public function set_blog_services( array $visible, array $hidden ) {
$services = $this->get_all_services();
// Validate the services
$available = array_keys( $services );
// Only allow services that we have defined
$hidden = array_intersect( $hidden, $available );
$visible = array_intersect( $visible, $available );
// Ensure we don't have the same ones in hidden and visible
$hidden = array_diff( $hidden, $visible );
/**
* Control the state of the list of sharing services.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $args {
* Array of options describing the state of the sharing services.
*
* @type array $services List of all available service names and classes.
* @type array $available Validated list of all available service names and classes.
* @type array $hidden List of services hidden behind a "More" button.
* @type array $visible List of visible services.
* @type array $this->get_blog_services() Array of Sharing Services currently enabled.
* }
*/
do_action( 'sharing_get_services_state', array(
'services' => $services,
'available' => $available,
'hidden' => $hidden,
'visible' => $visible,
'currently_enabled' => $this->get_blog_services()
) );
update_option( 'sharing-services', array( 'visible' => $visible, 'hidden' => $hidden ) );
}
public function get_blog_services() {
$options = get_option( 'sharing-options' );
$enabled = get_option( 'sharing-services' );
$services = $this->get_all_services();
if ( !is_array( $options ) )
$options = array( 'global' => $this->get_global_options() );
$global = $options['global'];
// Default services
if ( ! is_array( $enabled ) ) {
$enabled = array(
'visible' => array(),
'hidden' => array()
);
/**
* Filters the list of default Sharing Services.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $enabled Array of default Sharing Services.
*/
$enabled = apply_filters( 'sharing_default_services', $enabled );
}
// Cleanup after any filters that may have produced duplicate services
$enabled['visible'] = array_unique( $enabled['visible'] );
$enabled['hidden'] = array_unique( $enabled['hidden'] );
// Form the enabled services
$blog = array( 'visible' => array(), 'hidden' => array() );
foreach ( $blog AS $area => $stuff ) {
foreach ( (array)$enabled[$area] AS $service ) {
if ( isset( $services[$service] ) ) {
$blog[$area][$service] = new $services[$service]( $service, array_merge( $global, isset( $options[$service] ) ? $options[$service] : array() ) );
}
}
}
/**
* Filters the list of enabled Sharing Services.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $blog Array of enabled Sharing Services.
*/
$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;
}
public function get_service( $service_name ) {
$services = $this->get_blog_services();
if ( isset( $services['visible'][$service_name] ) )
return $services['visible'][$service_name];
if ( isset( $services['hidden'][$service_name] ) )
return $services['hidden'][$service_name];
return false;
}
public function set_global_options( $data ) {
$options = get_option( 'sharing-options' );
// No options yet
if ( !is_array( $options ) )
$options = array();
// Defaults
$options['global'] = array(
'button_style' => 'icon-text',
'sharing_label' => $this->default_sharing_label,
'open_links' => 'same',
'show' => array(),
'custom' => isset( $options['global']['custom'] ) ? $options['global']['custom'] : array()
);
/**
* Filters global sharing settings.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $options['global'] Array of global sharing settings.
*/
$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', 'official' ) ) )
$options['global']['button_style'] = $data['button_style'];
if ( isset( $data['sharing_label'] ) ) {
if ( $this->default_sharing_label === $data['sharing_label'] ) {
$options['global']['sharing_label'] = false;
} else {
$options['global']['sharing_label'] = trim( wp_kses( stripslashes( $data['sharing_label'] ), array() ) );
}
}
if ( isset( $data['open_links'] ) && in_array( $data['open_links'], array( 'new', 'same' ) ) )
$options['global']['open_links'] = $data['open_links'];
$shows = array_values( get_post_types( array( 'public' => true ) ) );
$shows[] = 'index';
if ( isset( $data['show'] ) ) {
if ( is_scalar( $data['show'] ) ) {
switch ( $data['show'] ) {
case 'posts' :
$data['show'] = array( 'post', 'page' );
break;
case 'index' :
$data['show'] = array( 'index' );
break;
case 'posts-index' :
$data['show'] = array( 'post', 'page', 'index' );
break;
}
}
if ( $data['show'] = array_intersect( $data['show'], $shows ) ) {
$options['global']['show'] = $data['show'];
}
}
update_option( 'sharing-options', $options );
return $options['global'];
}
public function get_global_options() {
if ( $this->global === false ) {
$options = get_option( 'sharing-options' );
if ( is_array( $options ) && isset( $options['global'] ) )
$this->global = $options['global'];
else
$this->global = $this->set_global_options( $options['global'] );
}
if ( ! isset( $this->global['show'] ) ) {
$this->global['show'] = array( 'post', 'page' );
} elseif ( is_scalar( $this->global['show'] ) ) {
switch ( $this->global['show'] ) {
case 'posts' :
$this->global['show'] = array( 'post', 'page' );
break;
case 'index' :
$this->global['show'] = array( 'index' );
break;
case 'posts-index' :
$this->global['show'] = array( 'post', 'page', 'index' );
break;
}
}
if ( false === $this->global['sharing_label'] ) {
$this->global['sharing_label'] = $this->default_sharing_label;
}
return $this->global;
}
public function set_service( $id, Sharing_Source $service ) {
// Update the options for this service
$options = get_option( 'sharing-options' );
// No options yet
if ( ! is_array( $options ) ) {
$options = array();
}
/**
* Get the state of a sharing button.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param array $args {
* State of a sharing button.
*
* @type string $id Service ID.
* @type array $options Array of all sharing options.
* @type array $service Details about a service.
* }
*/
do_action( 'sharing_get_button_state', array( 'id' => $id, 'options' => $options, 'service' => $service ) );
$options[$id] = $service->get_options();
update_option( 'sharing-options', array_filter( $options ) );
}
// Soon to come to a .org plugin near you!
public function get_total( $service_name = false, $post_id = false, $_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 ) );
} else {
// total number of shares for this blog
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d", $_blog_id ) );
}
}
if ( $post_id > 0 )
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $_blog_id, $post_id, $service_name ) );
else
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $_blog_id, $service_name ) );
}
public function get_services_total( $post_id = false ) {
$totals = array();
$services = $this->get_blog_services();
if ( !empty( $services ) && isset( $services[ 'all' ] ) )
foreach( $services[ 'all' ] as $key => $value ) {
$totals[$key] = new Sharing_Service_Total( $key, $this->get_total( $key, $post_id ) );
}
usort( $totals, array( 'Sharing_Service_Total', 'cmp' ) );
return $totals;
}
public function get_posts_total() {
$totals = array();
global $wpdb, $blog_id;
$my_data = $wpdb->get_results( $wpdb->prepare( "SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d GROUP BY post_id ORDER BY count DESC ", $blog_id ) );
if ( !empty( $my_data ) )
foreach( $my_data as $row )
$totals[] = new Sharing_Post_Total( $row->id, $row->total );
usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
return $totals;
}
}
class Sharing_Service_Total {
public $id = '';
public $name = '';
public $service = '';
public $total = 0;
public function __construct( $id, $total ) {
$services = new Sharing_Service();
$this->id = esc_html( $id );
$this->service = $services->get_service( $id );
$this->total = (int) $total;
$this->name = $this->service->get_name();
}
static function cmp( $a, $b ) {
if ( $a->total == $b->total )
return $a->name < $b->name;
return $a->total < $b->total;
}
}
class Sharing_Post_Total {
public $id = 0;
public $total = 0;
public $title = '';
public $url = '';
public function __construct( $id, $total ) {
$this->id = (int) $id;
$this->total = (int) $total;
$this->title = get_the_title( $this->id );
$this->url = get_permalink( $this->id );
}
static function cmp( $a, $b ) {
if ( $a->total == $b->total )
return $a->id < $b->id;
return $a->total < $b->total;
}
}
function sharing_register_post_for_share_counts( $post_id ) {
global $jetpack_sharing_counts;
if ( ! isset( $jetpack_sharing_counts ) || ! is_array( $jetpack_sharing_counts ) )
$jetpack_sharing_counts = array();
$jetpack_sharing_counts[ (int) $post_id ] = get_permalink( $post_id );
}
function sharing_maybe_enqueue_scripts() {
$sharer = new Sharing_Service();
$global_options = $sharer->get_global_options();
$enqueue = false;
if ( is_singular() && in_array( get_post_type(), $global_options['show'] ) ) {
$enqueue = true;
} elseif ( in_array( 'index', $global_options['show'] ) && ( is_home() || is_front_page() || is_archive() || is_search() || in_array( get_post_type(), $global_options['show'] ) ) ) {
$enqueue = true;
}
/**
* Filter to decide when sharing scripts should be enqueued.
*
* @module sharedaddy
*
* @since 3.2.0
*
* @param bool $enqueue Decide if the sharing scripts should be enqueued.
*/
return (bool) apply_filters( 'sharing_enqueue_scripts', $enqueue );
}
function sharing_add_footer() {
global $jetpack_sharing_counts;
/**
* Filter all JavaScript output by the sharing module.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param bool true Control whether the sharing module should add any JavaScript to the site. Default to true.
*/
if ( apply_filters( 'sharing_js', true ) && sharing_maybe_enqueue_scripts() ) {
/**
* Filter the display of sharing counts next to the sharing buttons.
*
* @module sharedaddy
*
* @since 3.2.0
*
* @param bool true Control the display of counters next to the sharing buttons. Default to true.
*/
if ( apply_filters( 'jetpack_sharing_counts', true ) && is_array( $jetpack_sharing_counts ) && count( $jetpack_sharing_counts ) ) :
$sharing_post_urls = array_filter( $jetpack_sharing_counts );
if ( $sharing_post_urls ) :
?>
<script type="text/javascript">
window.WPCOM_sharing_counts = <?php echo json_encode( array_flip( $sharing_post_urls ) ); ?>;
</script>
<?php
endif;
endif;
wp_enqueue_script( 'sharing-js' );
$sharing_js_options = array(
'lang' => get_base_recaptcha_lang_code(),
/** This filter is documented in modules/sharedaddy/sharing-service.php */
'counts' => apply_filters( 'jetpack_sharing_counts', true )
);
wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options);
}
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) {
$service->display_footer();
}
}
function sharing_add_header() {
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) {
$service->display_header();
}
if ( count( $enabled['all'] ) > 0 && sharing_maybe_enqueue_scripts() ) {
wp_enqueue_style( 'sharedaddy', plugin_dir_url( __FILE__ ) .'sharing.css', array(), JETPACK__VERSION );
wp_enqueue_style( 'genericons' );
}
}
add_action( 'wp_head', 'sharing_add_header', 1 );
function sharing_process_requests() {
global $post;
// Only process if: single post and share=X defined
if ( ( is_page() || is_single() ) && isset( $_GET['share'] ) ) {
$sharer = new Sharing_Service();
$service = $sharer->get_service( $_GET['share'] );
if ( $service ) {
$service->process_request( $post, $_POST );
}
}
}
add_action( 'template_redirect', 'sharing_process_requests', 9 );
function sharing_display( $text = '', $echo = false ) {
global $post, $wp_current_filter;
if ( empty( $post ) )
return $text;
if ( ( is_preview() || is_admin() ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
return $text;
}
// Don't output flair on excerpts
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
return $text;
}
// Don't allow flair to be added to the_content more than once (prevent infinite loops)
$done = false;
foreach ( $wp_current_filter as $filter ) {
if ( 'the_content' == $filter ) {
if ( $done )
return $text;
else
$done = true;
}
}
// check whether we are viewing the front page and whether the front page option is checked
$options = get_option( 'sharing-options' );
$display_options = $options['global']['show'];
if ( is_front_page() && ( is_array( $display_options ) && ! in_array( 'index', $display_options ) ) )
return $text;
if ( is_attachment() && in_array( 'the_excerpt', (array) $wp_current_filter ) ) {
// Many themes run the_excerpt() conditionally on an attachment page, then run the_content().
// We only want to output the sharing buttons once. Let's stick with the_content().
return $text;
}
$sharer = new Sharing_Service();
$global = $sharer->get_global_options();
$show = false;
if ( !is_feed() ) {
if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {
$show = true;
} elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_front_page() || is_archive() || is_search() || in_array( get_post_type(), $global['show'] ) ) ) {
$show = true;
}
}
/**
* Filter to decide if sharing buttons should be displayed.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param bool $show Should the sharing buttons be displayed.
* @param WP_Post $post The post to share.
*/
$show = apply_filters( 'sharing_show', $show, $post );
// Disabled for this post?
$switched_status = get_post_meta( $post->ID, 'sharing_disabled', false );
if ( !empty( $switched_status ) )
$show = false;
// Private post?
$post_status = get_post_status( $post->ID );
if ( 'private' === $post_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 ) {
/**
* Filters the list of enabled Sharing Services.
*
* @module sharedaddy
*
* @since 2.2.3
*
* @param array $sharer->get_blog_services() Array of Sharing Services currently enabled.
*/
$enabled = apply_filters( 'sharing_enabled', $sharer->get_blog_services() );
if ( count( $enabled['all'] ) > 0 ) {
global $post;
$dir = get_option( 'text_direction' );
// Wrapper
$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 ) {
// Individual HTML for sharing service
$visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display( $post ) . '</li>';
}
$parts = array();
$parts[] = $visible;
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 );
$sharing_content .= implode( '', $parts );
$sharing_content .= '<li class="share-end"></li></ul>';
if ( count( $enabled['hidden'] ) > 0 ) {
$sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;';
if ( count( $enabled['hidden'] ) == 1 )
$sharing_content .= 'width:150px;';
$sharing_content .= '">';
if ( count( $enabled['hidden'] ) == 1 )
$sharing_content .= '<ul style="background-image:none;">';
else
$sharing_content .= '<ul>';
$count = 1;
foreach ( $enabled['hidden'] as $id => $service ) {
// Individual HTML for sharing service
$sharing_content .= '<li class="share-'.$service->get_class().'">';
$sharing_content .= $service->get_display( $post );
$sharing_content .= '</li>';
if ( ( $count % 2 ) == 0 )
$sharing_content .= '<li class="share-end"></li>';
$count ++;
}
// End of wrapper
$sharing_content .= '<li class="share-end"></li></ul></div></div>';
}
$sharing_content .= '</div></div></div>';
// Register our JS
if ( defined( 'JETPACK__VERSION' ) ) {
$ver = JETPACK__VERSION;
} else {
$ver = '20141212';
}
wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), $ver );
add_action( 'wp_footer', 'sharing_add_footer' );
}
}
/**
* Filters the content markup of the Jetpack sharing links
*
* @module sharedaddy
*
* @since 3.8.0
*
* @param string $sharing_content Content markup of the Jetpack sharing links
*/
$sharing_markup = apply_filters( 'jetpack_sharing_display_markup', $sharing_content );
if ( $echo )
echo $text . $sharing_markup;
else
return $text . $sharing_markup;
}
add_filter( 'the_content', 'sharing_display', 19 );
add_filter( 'the_excerpt', 'sharing_display', 19 );
function get_base_recaptcha_lang_code() {
$base_recaptcha_lang_code_mapping = array(
'en' => 'en',
'nl' => 'nl',
'fr' => 'fr',
'fr-be' => 'fr',
'fr-ca' => 'fr',
'fr-ch' => 'fr',
'de' => 'de',
'pt' => 'pt',
'pt-br' => 'pt',
'ru' => 'ru',
'es' => 'es',
'tr' => 'tr'
);
$blog_lang_code = function_exists( 'get_blog_lang_code' ) ? get_blog_lang_code() : get_bloginfo( 'language' );
if( isset( $base_recaptcha_lang_code_mapping[ $blog_lang_code ] ) )
return $base_recaptcha_lang_code_mapping[ $blog_lang_code ];
// if no base mapping is found return default 'en'
return 'en';
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,682 @@
/**
* Sharedaddy Base Styles
*
* Contains styles for modules, containers, buttons
*/
/* Master container */
#jp-post-flair {
padding-top: .5em;
}
/* Overall Sharedaddy block title */
div.sharedaddy,
#content div.sharedaddy,
#main div.sharedaddy {
clear: both;
}
div.sharedaddy h3.sd-title {
margin: 0 0 1em 0;
display: inline-block;
line-height: 1.2;
font-size: 9pt;
font-weight: bold;
}
div.sharedaddy h3.sd-title:before {
content: "";
display: block;
width: 100%;
min-width: 30px;
border-top: 1px solid #ddd;
margin-bottom: 1em;
}
body.highlander-light h3.sd-title:before {
border-top: 1px solid rgba(0,0,0,.2);
}
body.highlander-dark h3.sd-title:before {
border-top: 1px solid rgba(255,255,255,.4);
}
/* Sharing services list */
.sd-content ul {
padding: 0 !important;
margin: 0 0 .7em 0 !important;
list-style: none !important;
}
.sd-content ul li {
display: inline-block;
}
.sd-block.sd-gplus {
margin: 0 0 .5em 0;
}
.sd-gplus .sd-content {
font-size: 12px;
}
/* Buttons */
.sd-social-icon .sd-content ul li a.sd-button,
.sd-social-text .sd-content ul li a.sd-button,
.sd-content ul li a.sd-button,
.sd-content ul li .option a.share-ustom, /* Ugh. */
.sd-content ul li.preview-item div.option.option-smart-off a,
.sd-content ul li.advanced a.share-more,
.sd-social-icon-text .sd-content ul li a.sd-button,
.sd-social-official .sd-content>ul>li>a.sd-button,
#sharing_email .sharing_send,
.sd-social-official .sd-content>ul>li .digg_button >a { /* official Digg button no longer works, needs cleaning */
text-decoration: none !important;
display: inline-block;
margin: 0 5px 5px 0;
font-size: 12px;
font-family: "Open Sans", sans-serif;
font-weight: normal;
border-radius: 3px;
color: #777 !important;
background: #f8f8f8;
border: 1px solid #cccccc;
box-shadow: 0 1px 0 rgba(0,0,0,.08);
text-shadow: none;
line-height: 23px;
padding: 1px 8px 0px 5px;
}
.sd-social-text .sd-content ul li a.sd-button span,
.sd-content ul li a.sd-button>span,
.sd-content ul li .option a.share-ustom span, /* Ugh. */
.sd-content ul li.preview-item div.option.option-smart-off a span,
.sd-content ul li.advanced a.share-more span,
.sd-social-icon-text .sd-content ul li a.sd-button>span,
.sd-social-official .sd-content>ul>li>a.sd-button span,
.sd-social-official .sd-content>ul>li .digg_button >a span { /* official Digg button no longer works, needs cleaning */
line-height: 23px;
}
/* Our gray buttons should be smaller when seen with the official ones */
.sd-social-official .sd-content>ul>li>a.sd-button,
.sd-social-official .sd-content .sharing-hidden .inner>ul>li>a.sd-button,
.sd-social-official .sd-content>ul>li .digg_button>a,
.sd-social-official .sd-content .sharing-hidden .inner>ul>li .digg_button>a {
line-height: 17px;
box-shadow: none; /* No shadow on gray buttons between the official ones */
vertical-align: top;
}
.sd-social-official .sd-content>ul>li>a.sd-button:before,
.sd-social-official .sd-content>ul>li .digg_button>a:before,
.sd-social-official .sd-content .sharing-hidden .inner>ul>li>a.sd-button:before,
.sd-social-official .sd-content .sharing-hidden .inner>ul>li .digg_button>a:before {
margin-bottom: -1px;
top: 0;
}
.sd-social-icon .sd-content ul li a.sd-button:hover,
.sd-social-icon .sd-content ul li a.sd-button:active,
.sd-social-text .sd-content ul li a.sd-button:hover,
.sd-social-text .sd-content ul li a.sd-button:active,
.sd-social-icon-text .sd-content ul li a.sd-button:hover,
.sd-social-icon-text .sd-content ul li a.sd-button:active,
.sd-social-official .sd-content>ul>li>a.sd-button:hover,
.sd-social-official .sd-content>ul>li>a.sd-button:active,
.sd-social-official .sd-content>ul>li .digg_button>a:hover,
.sd-social-official .sd-content>ul>li .digg_button>a:active {
color: #555;
background: #fafafa;
border: 1px solid #999999;
}
.sd-social-icon .sd-content ul li a.sd-button:active,
.sd-social-text .sd-content ul li a.sd-button:active,
.sd-social-icon-text .sd-content ul li a.sd-button:active,
.sd-social-official .sd-content>ul>li>a.sd-button:active,
.sd-social-official .sd-content>ul>li .digg_button>a:active {
box-shadow: inset 0 1px 0 rgba(0,0,0,.16);
}
/* All icons */
.sd-content ul li a.sd-button:before {
display: inline-block;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font: normal 16px/1 'Genericons';
vertical-align: top;
position: relative;
top: 3px;
text-align: center;
}
.sd-content ul li {
margin: 0 !important;
padding: 0;
}
/* Text + icon & Official */
.sd-social-icon-text .sd-content ul li a span,
.sd-social-official .sd-content ul li a.sd-button span,
.sd-content ul li.preview-item a.sd-button span {
margin-left: 3px;
}
.sd-content ul li.preview-item.no-icon a.sd-button span {
margin-left: 0;
}
/* Text only */
.sd-social-text .sd-content ul li a:before,
.sd-content ul li.no-icon a:before {
display: none;
}
body .sd-social-text .sd-content ul li.share-custom a span,
body .sd-content ul li.share-custom.no-icon a span {
background-image: none;
background-position: -500px -500px !important; /* hack to work around !important inline style */
background-repeat: no-repeat !important;
padding-left: 0;
height: 0;
line-height: inherit;
}
.sd-social-icon .sd-content ul li a.share-more {
position: relative;
top: 2px;
}
.sd-social-icon .sd-content ul li a.share-more span {
margin-left: 3px;
}
/* Individual icons */
.sd-social-icon .sd-content ul li.share-print a:before,
.sd-social-text .sd-content ul li.share-print a:before,
.sd-content ul li.share-print div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-print a:before,
.sd-social-official .sd-content li.share-print a:before {
content: '\f469';
}
.sd-social-icon .sd-content ul li.share-email a:before,
.sd-social-text .sd-content ul li.share-email a:before,
.sd-content ul li.share-email div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-email a:before,
.sd-social-official .sd-content li.share-email a:before {
content: '\f410';
}
.sd-social-icon .sd-content ul li.share-linkedin a:before,
.sd-social-text .sd-content ul li.share-linkedin a:before,
.sd-content ul li.share-linkedin div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-linkedin a:before {
content: '\f207';
}
.sd-social-icon .sd-content ul li.share-twitter a:before,
.sd-social-text .sd-content ul li.share-twitter a:before,
.sd-content ul li.share-twitter div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-twitter a:before {
content: '\f202';
}
.sd-social-icon .sd-content ul li.share-reddit a:before,
.sd-social-text .sd-content ul li.share-reddit a:before,
.sd-content ul li.share-reddit div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-reddit a:before {
content: '\f222';
}
.sd-social-icon .sd-content ul li.share-tumblr a:before,
.sd-social-text .sd-content ul li.share-tumblr a:before,
.sd-content ul li.share-tumblr div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-tumblr a:before {
content: '\f214';
}
.sd-social-icon .sd-content ul li.share-pocket a:before,
.sd-social-text .sd-content ul li.share-pocket a:before,
.sd-content ul li.share-pocket div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-pocket a:before {
content: '\f224';
}
.sd-social-icon .sd-content ul li.share-skype a:before,
.sd-social-text .sd-content ul li.share-skype a:before,
.sd-content ul li.share-skype div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-skype a:before {
content: '\f220';
}
.sd-social-icon .sd-content ul li.share-pinterest a:before,
.sd-social-text .sd-content ul li.share-pinterest a:before,
.sd-content ul li.share-pinterest div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-pinterest a:before {
content: '\f209';
}
.sd-social-icon .sd-content ul li.share-google-plus-1 a:before,
.sd-social-text .sd-content ul li.share-google-plus-1 a:before,
.sd-content ul li.share-google-plus-1 div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-google-plus-1 a:before {
content: '\f218';
}
.sd-social-icon .sd-content ul li.share-facebook a:before,
.sd-social-text .sd-content ul li.share-facebook a:before,
.sd-content ul li.share-facebook div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-facebook a:before {
content: '\f204';
}
.sd-social-icon .sd-content ul li.share-press-this a:before,
.sd-social-text .sd-content ul li.share-press-this a:before,
.sd-content ul li.share-press-this div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-press-this a:before,
.sd-social-official .sd-content li.share-press-this a:before {
content: '\f205';
}
.sd-social-official .sd-content li.share-press-this a:before {
color: #2ba1cb;
}
.sd-social-icon .sd-content ul a.share-more:before,
.sd-social-text .sd-content ul a.share-more:before,
.sd-content ul li.advanced a.share-more:before,
.sd-social-icon-text .sd-content a.share-more:before,
.sd-social-official .sd-content a.share-more:before {
content: '\f415';
}
.sd-social-official .sd-content a.share-more:before {
color: #2ba1cb;
}
/* Share count */
.sd-social .sd-button .share-count {
background: #2ea2cc;
color: #fff;
-moz-border-radius: 10px;
border-radius: 10px;
display: inline-block;
text-align: center;
font-size: 10px;
padding: 1px 3px;
line-height: 1;
}
/* Official buttons */
.sd-social-official .sd-content ul, .sd-social-official .sd-content ul li {
line-height: 25px !important;
}
.sd-social-official .sd-content>ul>li>a.sd-button span {
line-height: 1;
}
.sd-social-official .sd-content ul:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.sd-social-official .sd-content li.share-press-this a {
margin: 0 0 5px 0;
}
.sd-social-official .sd-content ul>li {
display: block;
float: left;
margin: 0 10px 5px 0 !important;
height: 25px;
}
.sd-social-official .fb-share-button > span {
vertical-align: top !important;
}
.sd-social-official .sd-content .pocket_button iframe {
width: 98px;
}
.sd-social-official .sd-content .skypeShare {
width: 55px;
}
/* Individual official buttons */
.googleplus1_button .g-plus {
vertical-align: top !important;
}
.reddit_button iframe {
margin-top: 1px;
}
.pocket_button iframe, .googleplus1_button iframe, .pinterest_button, .twitter_button, .linkedin_button>span {
margin: 0 !important;
}
body .sd-social-official li.share-print ,
body .sd-social-official li.share-email a,
body .sd-social-official li.share-custom a,
body .sd-social-official li a.share-more,
body .sd-social-official li.share-digg a,
body .sd-social-official li.share-press-this a
{
position: relative;
top: 0;
}
/* Custom icons */
body .sd-social-icon .sd-content li.share-custom>a {
padding: 2px 3px 0 3px;
position: relative;
top: 4px;
}
body .sd-social-icon .sd-content li.share-custom a span,
body .sd-social-icon-text .sd-content li.share-custom a span,
body .sd-social-text .sd-content li.share-custom a span,
body .sd-social-official .sd-content li.share-custom a span,
body .sd-content ul li.share-custom a.share-icon span
{
background-size: 16px 16px;
background-repeat: no-repeat;
margin-left: 0;
padding: 0 0 0 19px;
display: inline-block;
height: 16px;
line-height: 16px;
}
body .sd-social-icon .sd-content li.share-custom a span {
width: 0;
}
body .sd-content li.share-custom a:hover span {
}
body .sd-social-icon .sd-content li.share-custom a span {
padding-left: 16px !important;
}
/* Overflow Sharing dialog */
.sharing-hidden .inner {
position: absolute;
z-index: 2;
border: 1px solid #ccc;
padding: 10px;
background: #fff;
box-shadow: 0px 5px 20px rgba(0,0,0,.2);
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
margin-top: 5px;
max-width: 400px;
}
.sharing-hidden .inner ul{
margin: 0 !important;
}
.sd-social-official .sd-content .sharing-hidden ul>li.share-end {
clear: both;
margin: 0;
height: 0;
}
.sharing-hidden .inner:before, .sharing-hidden .inner:after {
position: absolute;
z-index: 1;
top: -8px;
left: 20px;
width: 0;
height: 0;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 8px solid #ccc;
content: "";
display: block;
}
.sharing-hidden .inner:after {
z-index: 2;
top: -7px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 8px solid #fff;
}
.sharing-hidden ul {
margin: 0;
}
/**
* Special colorful look for "Icon Only" option
*/
.sd-social-icon .sd-content ul li[class*='share-'] a,
.sd-social-icon .sd-content ul li[class*='share-'] a:hover,
.sd-social-icon .sd-content ul li[class*='share-'] div.option a {
border-radius: 50%;
-webkit-border-radius: 50%;
border: 0;
box-shadow: none;
padding: 8px;
position: relative;
top: -2px;
line-height: 1;
width: auto;
height: auto;
margin-bottom: 0;
}
.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button>span,
.sd-social-icon .sd-content ul li[class*='share-'] div.option a span {
line-height: 1;
}
.sd-social-icon .sd-content ul li[class*='share-'] a:hover,
.sd-social-icon .sd-content ul li[class*='share-'] div.option a:hover {
border: none;
opacity: .6;
}
.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button:before {
top: 0;
}
.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button.share-custom {
padding: 8px 8px 6px 8px;
top: 5px;
}
.sd-social-icon .sd-content ul li a.sd-button.share-more {
margin-left: 10px;
}
.sd-social-icon .sd-content ul li:first-child a.sd-button.share-more {
margin-left: 0;
}
.sd-social-icon .sd-button span.share-count {
position: absolute;
bottom: 0;
right: 0;
border-radius: 0;
background: #555;
font-size: 9px;
}
/* Special look colors */
.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button {
background: #e9e9e9;
margin-top: 2px;
text-indent: 0;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-tumblr a.sd-button {
background: #2c4762;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-facebook a.sd-button {
background: #3b5998;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-twitter a.sd-button {
background: #00acee;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-pinterest a.sd-button {
background: #ca1f27;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-digg a.sd-button {
color: #555555 !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-press-this a.sd-button {
background: #1e8cbe;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-linkedin a.sd-button {
background: #0077b5;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-google-plus-1 a.sd-button {
background: #dd4b39;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-pocket a.sd-button {
background: #ee4056;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-skype a.sd-button {
background: #00AFF0;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-reddit a.sd-button {
background: #cee3f8;
color: #555555 !important;
}
/**
* Screen Reader Text for "Icon Only" option
*/
.sharing-screen-reader-text {
clip: rect(1px, 1px, 1px, 1px);
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
}
.sharing-screen-reader-text:hover,
.sharing-screen-reader-text:active,
.sharing-screen-reader-text:focus {
background-color: #f1f1f1;
border-radius: 3px;
box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
clip: auto !important;
color: #21759b;
display: block;
font-size: 14px;
font-weight: bold;
height: auto;
left: 5px;
line-height: normal;
padding: 15px 23px 14px;
text-decoration: none;
top: 5px;
width: auto;
z-index: 100000; /* Above WP toolbar */
}
/**
* Sharing Email Dialog
*/
#sharing_email {
width: 342px;
position: absolute;
z-index: 1001;
border: 1px solid #ccc;
padding: 15px;
background: #fff;
box-shadow: 0px 5px 20px rgba(0,0,0,.2);
text-align: left;
}
div.sharedaddy.sharedaddy-dark #sharing_email {
border-color: #fff;
}
#sharing_email .errors {
color: #fff;
background-color: #771a09;
font-size: 12px;
padding: 5px 8px;
line-height: 1;
margin: 10px 0 0 0;
}
#sharing_email label {
font-size: 12px;
color: #333;
font-weight: bold;
display: block;
padding: 0 0 4px 0;
text-align: left;
text-shadow: none;
}
#sharing_email form {
margin: 0;
}
#sharing_email input[type="text"], #sharing_email input[type="email"] {
width: 100%;
box-sizing: border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
border: 1px solid #ccc;
margin-bottom: 1em;
background: #fff;
font-size: 12px;
color: #333;
max-width: none;
padding: 1px 3px;
}
#jetpack-source_f_name {
display: none!important;
position: absolute !important;
left: -9000px;
}
#sharing_email .sharing_cancel {
padding: 0 0 0 1em;
font-size: 12px;
text-shadow: none;
}
#sharing_email .recaptcha {
width: 312px;
height: 123px;
margin: 0 0 1em 0;
}

View file

@ -0,0 +1,446 @@
/* global WPCOM_sharing_counts, grecaptcha */
/* jshint unused:false */
var sharing_js_options;
if ( sharing_js_options && sharing_js_options.counts ) {
var WPCOMSharing = {
done_urls : [],
get_counts : function() {
var url, requests, id, service, service_request;
if ( 'undefined' === typeof WPCOM_sharing_counts ) {
return;
}
for ( url in WPCOM_sharing_counts ) {
id = WPCOM_sharing_counts[ url ];
if ( 'undefined' !== typeof WPCOMSharing.done_urls[ id ] ) {
continue;
}
requests = {
// LinkedIn actually gets the share count for both the http and https version automatically -- so we don't need to do extra magic
linkedin: [
'https://www.linkedin.com/countserv/count/share?format=jsonp&callback=updateLinkedInCount&url=' +
encodeURIComponent( url )
],
// Pinterest, like LinkedIn, handles share counts for both http and https
pinterest: [
window.location.protocol +
'//api.pinterest.com/v1/urls/count.json?callback=WPCOMSharing.update_pinterest_count&url=' +
encodeURIComponent( url )
],
// Facebook protocol summing has been shown to falsely double counts, so we only request the current URL
facebook: [
window.location.protocol +
'//graph.facebook.com/?callback=WPCOMSharing.update_facebook_count&ids=' +
encodeURIComponent( url )
]
};
for ( service in requests ) {
if ( ! jQuery( 'a[data-shared=sharing-' + service + '-' + id + ']' ).length ) {
continue;
}
while ( ( service_request = requests[ service ].pop() ) ) {
jQuery.getScript( service_request );
}
WPCOMSharing.bump_sharing_count_stat( service );
}
WPCOMSharing.done_urls[ id ] = true;
}
},
// get the version of the url that was stored in the dom (sharing-$service-URL)
get_permalink: function( url ) {
if ( 'https:' === window.location.protocol ) {
url = url.replace( /^http:\/\//i, 'https://' );
} else {
url = url.replace( /^https:\/\//i, 'http://' );
}
return url;
},
update_facebook_count: function( data ) {
var url, permalink;
if ( ! data ) {
return;
}
for ( url in data ) {
if ( ! data.hasOwnProperty( url ) || ! data[ url ].shares ) {
continue;
}
permalink = WPCOMSharing.get_permalink( url );
if ( ! ( permalink in WPCOM_sharing_counts ) ) {
continue;
}
WPCOMSharing.inject_share_count( 'sharing-facebook-' + WPCOM_sharing_counts[ permalink ], data[ url ].shares );
}
},
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 );
}
},
update_pinterest_count : function( data ) {
if ( 'undefined' !== typeof data.count && ( data.count * 1 ) > 0 ) {
WPCOMSharing.inject_share_count( 'sharing-pinterest-' + WPCOM_sharing_counts[ data.url ], data.count );
}
},
inject_share_count : function( id, count ) {
var $share = jQuery( 'a[data-shared=' + id + '] > span');
$share.find( '.share-count' ).remove();
$share.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+';
},
bump_sharing_count_stat: function( service ) {
new Image().src = document.location.protocol + '//pixel.wp.com/g.gif?v=wpcom-no-pv&x_sharing-count-request=' + service + '&r=' + Math.random();
}
};
}
var updateLinkedInCount = function( data ) {
WPCOMSharing.update_linkedin_count( data );
};
(function($){
var $body, $sharing_email;
$.fn.extend( {
share_is_email: function() {
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() );
}
} );
$body = $( document.body ).on( 'post-load', WPCOMSharing_do );
$( document ).on( 'ready', function() {
$sharing_email = $( '#sharing_email' );
$body.append( $sharing_email );
WPCOMSharing_do();
} );
function WPCOMSharing_do() {
var $more_sharing_buttons;
if ( 'undefined' !== typeof WPCOMSharing ) {
WPCOMSharing.get_counts();
}
$more_sharing_buttons = $( '.sharedaddy a.sharing-anchor' );
$more_sharing_buttons.click( function() {
return false;
} );
$( '.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.
// Non-touchscreen device: use click if not already appearing due to a hover event
$more_sharing_buttons.on( 'click', function() {
var $more_sharing_button = $( this ),
$more_sharing_pane = $more_sharing_button.parents( 'div:first' ).find( '.inner' );
if ( $more_sharing_pane.is( ':animated' ) ) {
// 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'
} ).slideToggle( 200 );
} );
if ( document.ontouchstart === undefined ) {
// Non-touchscreen device: use hover/mouseout with delay
$more_sharing_buttons.hover( function() {
var $more_sharing_button = $( this ),
$more_sharing_pane = $more_sharing_button.parents( 'div:first' ).find( '.inner' ),
timer;
if ( ! $more_sharing_pane.is( ':animated' ) ) {
// Create a timer to make the area appear if the mouse hovers for a period
timer = setTimeout( function() {
var handler_item_leave, handler_item_enter, handler_original_leave, handler_original_enter, close_it;
$sharing_email.slideUp( 200 );
$more_sharing_pane.data( 'justSlid', true );
$more_sharing_pane.css( {
left: $more_sharing_button.position().left + 'px',
top: $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px'
} ).slideDown( 200, function() {
// Mark the item as have being appeared by the hover
$more_sharing_button.data( 'hasoriginal', true ).data( 'hasitem', false );
setTimeout( function() {
$more_sharing_pane.data( 'justSlid', false );
}, 300 );
if ( $more_sharing_pane.find( '.share-google-plus-1' ).size() ) {
// The pane needs to stay open for the Google+ Button
return;
}
$more_sharing_pane.mouseleave( handler_item_leave ).mouseenter( handler_item_enter );
$more_sharing_button.mouseleave( handler_original_leave ).mouseenter( handler_original_enter );
} );
// 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
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 );
}
};
handler_item_enter = function() {
$more_sharing_button.data( 'hasitem', true );
clearTimeout( $more_sharing_button.data( 'timer2' ) );
};
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 );
}
};
handler_original_enter = function() {
$more_sharing_button.data( 'hasoriginal', true );
clearTimeout( $more_sharing_button.data( 'timer2' ) );
};
close_it = function() {
$more_sharing_pane.data( 'justSlid', true );
$more_sharing_pane.slideUp( 200, function() {
setTimeout( function() {
$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 );
}
}, function() {
// Mouse out - remove any timer
$more_sharing_buttons.each( function() {
clearTimeout( $( this ).data( 'timer' ) );
} );
$more_sharing_buttons.data( 'timer', false );
} );
}
$( document ).click(function() {
// Click outside
// remove any timer
$more_sharing_buttons.each( function() {
clearTimeout( $( this ).data( 'timer' ) );
} );
$more_sharing_buttons.data( 'timer', false );
// slide down forcibly
$( '.sharedaddy .inner' ).slideUp();
});
// Add click functionality
$( '.sharedaddy ul' ).each( function() {
if ( 'yep' === $( this ).data( 'has-click-events' ) ) {
return;
}
$( this ).data( 'has-click-events', 'yep' );
var 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( 'a.share-print' ).click( function() {
var ref = $( this ).attr( 'href' ),
do_print = function() {
if ( ref.indexOf( '#print' ) === -1 ) {
var uid = new Date().getTime();
printUrl( uid , ref );
} else {
print();
}
};
// Is the button in a dropdown?
if ( $( this ).parents( '.sharing-hidden' ).length > 0 ) {
$( this ).parents( '.inner' ).slideUp( 0, function() {
do_print();
} );
} else {
do_print();
}
return false;
} );
// Press This button
$( this ).find( 'a.share-press-this' ).click( function() {
var s = '';
if ( window.getSelection ) {
s = window.getSelection();
} else if( document.getSelection ) {
s = document.getSelection();
} else if( document.selection ) {
s = document.selection.createRange().text;
}
if ( s ) {
$( this ).attr( 'href', $( this ).attr( 'href' ) + '&sel=' + encodeURI( s ) );
}
if ( !window.open( $( this ).attr( 'href' ), 't', 'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570' ) ) {
document.location.href = $( this ).attr( 'href' );
}
return false;
} );
// Email button
$( 'a.share-email', this ).on( 'click', function() {
var url = $( this ).attr( 'href' );
if ( $sharing_email.is( ':visible' ) ) {
$sharing_email.slideUp( 200 );
} else {
$( '.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();
// Reset reCATPCHA if exists.
if ( 'object' === typeof grecaptcha && 'function' === typeof grecaptcha.reset ) {
grecaptcha.reset();
}
// Show dialog
$sharing_email.css( {
left: $( this ).offset().left + 'px',
top: $( this ).offset().top + $( this ).height() + 'px'
} ).slideDown( 200 );
// Hook up other buttons
$( '#sharing_email a.sharing_cancel' ).unbind( 'click' ).click( function() {
$( '#sharing_email .errors' ).hide();
$sharing_email.slideUp( 200 );
$( '#sharing_background' ).fadeOut();
return false;
} );
// Submit validation
$( '#sharing_email input[type=submit]' ).unbind( 'click' ).click( function() {
var form = $( this ).parents( 'form' );
// Disable buttons + enable loading icon
$( this ).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() ) {
$( '#sharing_email input[name=source_email]' ).addClass( 'error' );
}
if ( ! $( '#sharing_email input[name=target_email]' ).share_is_email() ) {
$( '#sharing_email input[name=target_email]' ).addClass( 'error' );
}
if ( $( '#sharing_email .error' ).length === 0 ) {
// AJAX send the form
$.ajax( {
url: url,
type: 'POST',
data: form.serialize(),
success: function( response ) {
form.find( 'img.loading' ).hide();
if ( response === '1' || response === '2' || response === '3' ) {
$( '#sharing_email .errors-' + response ).show();
form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
form.find( 'a.sharing_cancel' ).show();
if ( 'object' === typeof grecaptcha && 'function' === typeof grecaptcha.reset ) {
grecaptcha.reset();
}
}
else {
$( '#sharing_email form' ).hide();
$sharing_email.append( response );
$( '#sharing_email a.sharing_cancel' ).click( function() {
$sharing_email.slideUp( 200 );
$( '#sharing_background' ).fadeOut();
return false;
} );
}
}
} );
return false;
}
form.find( 'img.loading' ).hide();
form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
form.find( 'a.sharing_cancel' ).show();
$( '#sharing_email .errors-1' ).show();
return false;
} );
}
return false;
} );
} );
$( 'li.share-email, li.share-custom a.sharing-anchor' ).addClass( 'share-service-visible' );
}
})( jQuery );

View file

@ -0,0 +1,496 @@
<?php
class Sharing_Admin {
public function __construct() {
if ( !defined( 'WP_SHARING_PLUGIN_URL' ) ) {
define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
require_once WP_SHARING_PLUGIN_DIR.'sharing-service.php';
add_action( 'admin_init', array( &$this, 'admin_init' ) );
add_action( 'admin_menu', array( &$this, 'subscription_menu' ) );
// 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' ) );
}
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' ), 2 );
wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL.'admin-sharing.css', false, JETPACK__VERSION );
wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL.'sharing.css', false, JETPACK__VERSION );
wp_enqueue_style( 'genericons' );
wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array( ), 4 );
add_thickbox();
}
public function admin_init() {
if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) )
$this->process_requests();
}
public function process_requests() {
if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
$sharer = new Sharing_Service();
$sharer->set_global_options( $_POST );
/**
* Fires when updating sharing settings.
*
* @module sharedaddy
*
* @since 1.1.0
*/
do_action( 'sharing_admin_update' );
wp_safe_redirect( admin_url( 'options-general.php?page=sharing&update=saved' ) );
die();
}
}
public function subscription_menu( $user ) {
if ( !defined( 'IS_WPCOM' ) || !IS_WPCOM ) {
$active = Jetpack::get_active_modules();
if ( !in_array( 'publicize', $active ) && !current_user_can( 'manage_options' ) )
return;
}
add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'publish_posts', 'sharing', array( &$this, 'management_page' ) );
}
public function ajax_save_services() {
if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) && isset( $_POST['hidden'] ) && isset( $_POST['visible'] ) ) {
$sharer = new Sharing_Service();
$sharer->set_blog_services( explode( ',', $_POST['visible'] ), explode( ',', $_POST['hidden'] ) );
die();
}
}
public function ajax_new_service() {
if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['sharing_name'] ) && isset( $_POST['sharing_url'] ) && isset( $_POST['sharing_icon'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-new_service' ) ) {
$sharer = new Sharing_Service();
if ( $service = $sharer->new_service( stripslashes( $_POST['sharing_name'] ), stripslashes( $_POST['sharing_url'] ), stripslashes( $_POST['sharing_icon'] ) ) ) {
$this->output_service( $service->get_id(), $service );
echo '<!--->';
$service->button_style = 'icon-text';
$this->output_preview( $service );
die();
}
}
// Fail
die( '1' );
}
public function ajax_delete_service() {
if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_'.$_POST['service'] ) ) {
$sharer = new Sharing_Service();
$sharer->delete_service( $_POST['service'] );
}
}
public function ajax_save_options() {
if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_'.$_POST['service'] ) ) {
$sharer = new Sharing_Service();
$service = $sharer->get_service( $_POST['service'] );
if ( $service && $service instanceof Sharing_Advanced_Source ) {
$service->update_options( $_POST );
$sharer->set_service( $_POST['service'], $service );
}
$this->output_service( $service->get_id(), $service, true );
echo '<!--->';
$service->button_style = 'icon-text';
$this->output_preview( $service );
die();
}
}
public function output_preview( $service ) {
$klasses = array( 'advanced', 'preview-item' );
if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
$klasses[] = 'preview-'.$service->get_class();
$klasses[] = 'share-'.$service->get_class();
if ( $service->get_class() != $service->get_id() )
$klasses[] = 'preview-'.$service->get_id();
}
echo '<li class="'.implode( ' ', $klasses ).'">';
$service->display_preview();
echo '</li>';
}
public function output_service( $id, $service, $show_dropdown = false ) {
?>
<li class="service advanced share-<?php echo $service->get_class(); ?>" id="<?php echo $service->get_id(); ?>" tabindex="0">
<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
}
public function management_page() {
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
$global = $sharer->get_global_options();
$shows = array_values( get_post_types( array( 'public' => true ) ) );
array_unshift( $shows, 'index' );
if ( false == function_exists( 'mb_stripos' ) ) {
echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
echo "<p>" . sprintf( __( 'This plugin will work without it, but multibyte support is used <a href="%s" target="_blank">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ), "http://www.php.net/manual/en/mbstring.installation.php" ) . '</p></div>';
}
if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' )
echo '<div class="updated"><p>'.__( 'Settings have been saved', 'jetpack' ).'</p></div>';
if( ! isset( $global['sharing_label'] ) ) {
$global['sharing_label'] = __( 'Share this:', 'jetpack' );
}
?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
<?php
/**
* Fires at the top of the admin sharing settings screen.
*
* @module sharedaddy
*
* @since 1.6.0
*/
do_action( 'pre_admin_screen_sharing' );
?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<div class="share_manage_options">
<h2><?php _e( 'Sharing Buttons', 'jetpack' ) ?></h2>
<p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ) ?></p>
<div id="services-config">
<table id="available-services">
<tr>
<td class="description">
<h3><?php _e( 'Available Services', 'jetpack' ); ?></h3>
<p><?php _e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
<p><a href="#TB_inline?height=395&amp;width=600&amp;inlineId=new-service" class="thickbox" id="add-a-new-service"><?php _e( 'Add a new service', 'jetpack' ); ?></a></p>
</td>
<td class="services">
<ul class="services-available" style="height: 100px;">
<?php foreach ( $sharer->get_all_services_blog() AS $id => $service ) : ?>
<?php
if ( !isset( $enabled['all'][$id] ) )
$this->output_service( $id, $service );
?>
<?php endforeach; ?>
</ul>
<?php
if ( -1 == get_option( 'blog_public' ) )
echo '<p><strong>'.__( 'Please note that your services have been restricted because your site is private.', 'jetpack' ).'</strong></p>';
?>
<br class="clearing" />
</td>
</tr>
</table>
<table id="enabled-services">
<tr>
<td class="description">
<h3>
<?php _e( 'Enabled Services', 'jetpack' ); ?>
<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</h3>
<p><?php _e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
</td>
<td class="services" id="share-drop-target">
<h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Drag and drop available services here.', 'jetpack' ); ?></h2>
<ul class="services-enabled">
<?php foreach ( $enabled['visible'] as $id => $service ) : ?>
<?php $this->output_service( $id, $service, true ); ?>
<?php endforeach; ?>
<li class="end-fix"></li>
</ul>
</td>
<td id="hidden-drop-target" class="services">
<p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
<ul class="services-hidden">
<?php foreach ( $enabled['hidden'] as $id => $service ) : ?>
<?php $this->output_service( $id, $service, true ); ?>
<?php endforeach; ?>
<li class="end-fix"></li>
</ul>
</td>
</tr>
</table>
<table id="live-preview">
<tr>
<td class="description">
<h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3>
</td>
<td class="services">
<h2<?php if ( count( $enabled['all'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
<div class="sharedaddy sd-sharing-enabled">
<?php if ( count( $enabled['all'] ) > 0 ) : ?>
<h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3>
<?php endif; ?>
<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; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>">
<?php if ( count( $enabled['hidden'] ) == 1 ) : ?>
<ul style="background-image:none;">
<?php else: ?>
<ul>
<?php endif; ?>
<?php foreach ( $enabled['hidden'] as $id => $service ) {
$this->output_preview( $service );
}?>
</ul>
</div>
</div>
<?php endif; ?>
<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];
$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>
</div>
<br class="clearing" />
</td>
</tr>
</table>
<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="save-enabled-shares">
<input type="hidden" name="action" value="sharing_save_services" />
<input type="hidden" name="visible" value="<?php echo implode( ',', array_keys( $enabled['visible'] ) ); ?>" />
<input type="hidden" name="hidden" value="<?php echo implode( ',', array_keys( $enabled['hidden'] ) ); ?>" />
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
</form>
</div>
<form method="post" action="">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th>
<td>
<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 esc_attr( $global['sharing_label'] ); ?>" />
</td>
</tr>
<?php
/**
* Filters the HTML at the beginning of the "Show button on" row.
*
* @module sharedaddy
*
* @since 2.1.0
*
* @param string $var Opening HTML tag at the beginning of the "Show button on" row.
*/
echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' );
?>
<th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
<td>
<?php
$br = false;
foreach ( $shows as $show ) :
if ( 'index' == $show ) {
$label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
} else {
$post_type_object = get_post_type_object( $show );
$label = $post_type_object->labels->name;
}
?>
<?php if ( $br ) echo '<br />'; ?><label><input type="checkbox"<?php checked( in_array( $show, $global['show'] ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
<?php $br = true; endforeach; ?>
</td>
<?php
/**
* Filters the HTML at the end of the "Show button on" row.
*
* @module sharedaddy
*
* @since 2.1.0
*
* @param string $var Closing HTML tag at the end of the "Show button on" row.
*/
echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' );
?>
<?php
/**
* Fires at the end of the sharing global options settings table.
*
* @module sharedaddy
*
* @since 1.1.0
*/
do_action( 'sharing_global_options' );
?>
</tbody>
</table>
<p class="submit">
<input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'jetpack' ); ?>" />
</p>
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
</form>
<div id="new-service" style="display: none">
<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-service-form">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_name" 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" 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_tags%</code></p>
</td>
</tr>
<tr valign="top">
<th scope="row" width="100"><label><?php _e( 'Icon URL', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_icon" 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-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>
<?php
/**
* Fires after the custom sharing service form
*
* @module sharedaddy
*
* @since 1.1.0
*/
do_action( 'sharing_new_service_form' );
?>
</tbody>
</table>
<?php
/**
* Fires at the bottom of the admin sharing settings screen.
*
* @module sharedaddy
*
* @since 1.6.0
*/
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>
<input type="hidden" name="action" value="sharing_new_service" />
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
</form>
</div>
</div>
<?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
}
}
function sharing_admin_init() {
global $sharing_admin;
$sharing_admin = new Sharing_Admin();
}
add_action( 'init', 'sharing_admin_init' );