This commit is contained in:
emmymayo
2025-02-05 23:15:46 +01:00
commit 7269c99357
16995 changed files with 3389680 additions and 0 deletions
@@ -0,0 +1,479 @@
/**
* 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 #dcdcde;
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 {
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 {
color: #2C3338 !important;
display: inline-block;
font-family: "Open Sans", sans-serif;
font-size: 13px;
font-weight: 500;
line-height: 23px;
margin: 0 0 8px 8px;
padding: 3px 9px 4px 11px;
border-radius: 4px;
background: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.12);
}
#available-services .service .options-left, #enabled-services .service .options-left {
align-items: center;
display: flex;
}
#available-services .service:hover, #enabled-services .service:hover {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.22);
}
#available-services .service.share-deprecated,
#enabled-services .service.share-deprecated {
opacity: 0.5;
padding: 5px;
text-decoration: line-through;
}
#available-services .service.share-deprecated {
display: none;
}
/* Generic style icons */
li.service span:before {
-webkit-font-smoothing: antialiased;
font: normal 18px/1 "social-logos";
position: relative;
top: -1px;
margin-left: 6px;
width: 16px;
height: 16px;
}
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-pinterest span:before {
content: "\f209";
}
li.service.share-facebook span:before {
content: "\f203";
}
li.service.share-press-this span:before { /* Fixme: remove this button in favor of reblog */
content: "\f205";
}
li.service.share-telegram span:before {
content: "\f606";
}
li.service.share-threads span:before {
content: "\f10d";
}
li.service.share-jetpack-whatsapp span:before {
content: "\f608";
}
li.service.share-mastodon span:before {
content: "\f10a";
}
li.service.share-nextdoor span:before {
content: "\f10c";
}
li.service.share-x span:before {
content: "\f10e";
}
li.service.share-bluesky span:before {
content: "\f10f";
}
/**
* Preview section
*/
body.settings_page_sharing ul.preview {
display: flex;
flex-wrap: wrap;
float: right;
}
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(../../modules/sharedaddy/images/smart-digg.png) no-repeat top right;
background-size: 76px 17px;
width: 76px;
height: 17px;
margin-top: 2px;
}
.preview-facebook .option-smart-on {
background: url(../../modules/sharedaddy/images/smart-like.png) no-repeat top right;
background-size: 85px 20px;
width: 85px;
height: 20px;
margin-right: -4px;
}
.preview-twitter .option-smart-on,
.preview-x .option-smart-on {
background: url(../../modules/sharedaddy/images/smart-x.png) no-repeat top right;
background-size: 60px 20px;
width: 60px;
height: 20px;
}
.preview-linkedin .option-smart-on {
background: url(../../modules/sharedaddy/images/linkedin-smart.png) no-repeat top center;
background-size: 99px 18px;
width: 99px;
height: 20px;
}
.preview-tumblr .option-smart-on {
background: url(../../modules/sharedaddy/images/smart-tumblr.png) no-repeat top right;
background-size: 62px 20px;
width: 62px;
height: 20px;
}
.preview-pinterest .option-smart-on {
background: url(../../modules/sharedaddy/images/smart-pinterest.png) no-repeat top right;
background-size: 39px 20px;
width: 39px;
height: 20px;
}
.preview-pocket .option-smart-on {
background: url(../../modules/sharedaddy/images/smart-pocket.png) no-repeat top right;
background-size: 60px 20px;
width: 60px;
height: 20px;
}
.preview-item.share-deprecated {
opacity: 0.5;
}
.preview-item.share-deprecated a span {
text-decoration: line-through;
}
@media (min-resolution: 120dpi) {
.preview-digg .option-smart-on {
background-image: url(../../modules/sharedaddy/images/smart-digg@2x.png);
}
.preview-facebook .option-smart-on {
background-image: url(../../modules/sharedaddy/images/smart-like@2x.png);
}
.preview-twitter .option-smart-on,
.preview-x .option-smart-on {
background-image: url(../../modules/sharedaddy/images/smart-x@2x.png);
}
.preview-linkedin .option-smart-on {
background-image: url(../../modules/sharedaddy/images/linkedin-smart@2x.png);
}
.preview-tumblr .option-smart-on {
background-image: url(../../modules/sharedaddy/images/smart-tumblr@2x.png);
}
.preview-pinterest .option-smart-on {
background-image: url(../../modules/sharedaddy/images/smart-pinterest@2x.png);
}
.preview-pocket .option-smart-on {
background-image: url(../../modules/sharedaddy/images/smart-pocket@2x.png);
}
}
/**
* 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: #dcdcde;
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%;
}
.sharing-block-message__items-wrapper {
display: flex;
flex-wrap: wrap;
column-gap: 6rem;
}
.sharing-block-message__buttons-wrapper .button {
margin-left: 1rem;
}
.sharing-block-message__buttons-wrapper .button-primary:visited {
color: #fff;
}
.admin-sharing-settings__block-theme-description {
margin-top: 1rem;
font-style: italic;
}
a.dops-card__link {
cursor: pointer;
}
.settings-sharing__block-theme-description {
font-style: italic;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,476 @@
/**
* 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 #dcdcde;
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 {
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 {
color: #2C3338 !important;
display: inline-block;
font-family: "Open Sans", sans-serif;
font-size: 13px;
font-weight: 500;
line-height: 23px;
margin: 0 8px 8px 0;
padding: 3px 11px 4px 9px;
border-radius: 4px;
background: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.12);
}
#available-services .service .options-left, #enabled-services .service .options-left {
align-items: center;
display: flex;
}
#available-services .service:hover, #enabled-services .service:hover {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.22);
}
#available-services .service.share-deprecated,
#enabled-services .service.share-deprecated {
opacity: 0.5;
padding: 5px;
text-decoration: line-through;
}
#available-services .service.share-deprecated {
display: none;
}
/* Generic style icons */
li.service span:before {
-webkit-font-smoothing: antialiased;
font: normal 18px/1 'social-logos';
position: relative;
top: -1px;
margin-right: 6px;
width: 16px;
height: 16px;
}
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-pinterest span:before {
content: '\f209';
}
li.service.share-facebook span:before {
content: '\f203';
}
li.service.share-press-this span:before { /* Fixme: remove this button in favor of reblog */
content: '\f205';
}
li.service.share-telegram span:before {
content: '\f606';
}
li.service.share-threads span:before {
content: '\f10d';
}
li.service.share-jetpack-whatsapp span:before {
content: '\f608';
}
li.service.share-mastodon span:before {
content: '\f10a';
}
li.service.share-nextdoor span:before {
content: '\f10c';
}
li.service.share-x span:before {
content: '\f10e';
}
li.service.share-bluesky span:before {
content: '\f10f';
}
/**
* Preview section
*/
body.settings_page_sharing ul.preview {
display: flex;
flex-wrap: wrap;
float: left;
}
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-facebook .option-smart-on {
background: url(images/smart-like.png) no-repeat top left;
background-size: 85px 20px;
width:85px;
height:20px;
margin-left: -4px;
}
.preview-twitter .option-smart-on,
.preview-x .option-smart-on {
background: url(images/smart-x.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: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-item.share-deprecated {
opacity: 0.5;
}
.preview-item.share-deprecated a span {
text-decoration: line-through;
}
@media
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.preview-digg .option-smart-on {
background-image: url(images/smart-digg@2x.png);
}
.preview-facebook .option-smart-on {
background-image: url(images/smart-like@2x.png);
}
.preview-twitter .option-smart-on,
.preview-x .option-smart-on {
background-image: url(images/smart-x@2x.png?1);
}
.preview-linkedin .option-smart-on {
background-image: url(images/linkedin-smart@2x.png);
}
.preview-tumblr .option-smart-on {
background-image: url(images/smart-tumblr@2x.png);
}
.preview-pinterest .option-smart-on {
background-image: url(images/smart-pinterest@2x.png);
}
.preview-pocket .option-smart-on {
background-image: url(images/smart-pocket@2x.png);
}
}
/**
* 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: #dcdcde;
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%;
}
.sharing-block-message__items-wrapper {
display: flex;
flex-wrap: wrap;
column-gap: 6rem;
}
.sharing-block-message__buttons-wrapper .button {
margin-right:1rem;
}
.sharing-block-message__buttons-wrapper .button-primary:visited {
color: #fff;
}
.admin-sharing-settings__block-theme-description {
margin-top: 1rem;
font-style: italic;
}
a.dops-card__link {
cursor: pointer;
}
.settings-sharing__block-theme-description {
font-style: italic;
}
@@ -0,0 +1,519 @@
/* 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 timer2 = setTimeout( close_it, 800 );
$( original ).data( 'timer2', timer2 );
}
};
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 timer2 = setTimeout( close_it, 800 );
$( original ).data( 'timer2', timer2 );
}
};
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();
// Toggle .sd-social-official class
var sharedaddy = $( '.sharedaddy' );
var oficialClass = 'sd-social-official';
if ( 'official' === button_style ) {
sharedaddy.addClass( oficialClass );
} else {
sharedaddy.removeClass( oficialClass );
}
// 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-mastodon' ) &&
! $( this ).hasClass( 'preview-nextdoor' ) &&
! $( this ).hasClass( 'preview-bluesky' ) &&
! $( this ).hasClass( 'preview-print' ) &&
! $( this ).hasClass( 'preview-reddit' ) &&
! $( this ).hasClass( 'preview-telegram' ) &&
! $( this ).hasClass( 'preview-threads' ) &&
! $( this ).hasClass( 'preview-jetpack-whatsapp' ) &&
! $( this ).hasClass( 'share-custom' ) &&
! $( this ).hasClass( 'share-deprecated' )
) {
$( 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.reload();
}
},
} );
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
@@ -0,0 +1,128 @@
amp-social-share,
.amp-social-share {
border-radius: 50%;
color: #fff;
-webkit-border-radius: 50%;
position: relative;
line-height: 1;
width: 32px;
height: 32px;
margin: 0 5px 5px 0;
vertical-align: middle;
}
amp-social-share::before,
.amp-social-share::before {
display: inline-block;
font: normal 18px/1 'social-logos';
padding: 7px;
position: relative;
top: 1px;
vertical-align: top;
text-align: center;
}
.amp-social-share.print {
background: #e9e9e9;
font-size: 0;
cursor: pointer;
display: inline-block;
vertical-align: middle;
border: none;
padding: 0;
}
.amp-social-share.print::before {
content: '\f469';
color: #656565;
}
amp-social-share[type='email'] {
background: #e9e9e9;
color: #656565;
}
amp-social-share[type='email']::before {
content: '\f410';
}
amp-social-share[type='tumblr'] {
background: #2c4762;
}
amp-social-share[type='tumblr']::before {
content: '\f607';
}
amp-social-share[type='facebook'] {
background: #0866ff;
}
amp-social-share[type='facebook']::before {
content: '\f203';
}
amp-social-share[type='twitter'] {
background: #00acee;
}
amp-social-share[type='twitter']::before {
content: '\f202';
}
amp-social-share[type='pinterest'] {
background: #ca1f27;
}
amp-social-share[type='pinterest']::before {
content: '\f210';
}
amp-social-share[type='telegram'] {
background: #0088cc;
}
amp-social-share[type='telegram']::before {
content: '\f606';
}
amp-social-share[type='linkedin'] {
background: #0077b5;
}
amp-social-share[type='linkedin']::before {
content: '\f207';
}
amp-social-share[type='pocket'] {
background: #ee4056;
}
amp-social-share[type='pocket']::before {
content: '\f224';
}
amp-social-share[type='reddit'] {
background: #cee3f8;
color: #555;
}
amp-social-share[type='reddit']::before {
content: '\f222';
}
amp-social-share[type='skype'] {
background: #00AFF0;
}
amp-social-share[type='skype']::before {
content: '\f220';
}
amp-social-share[type='whatsapp'] {
background: #43d854;
}
amp-social-share[type='whatsapp']::before {
content: '\f608';
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 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: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,230 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Google reCAPTCHA utilities, for use in the sharing feature.
*
* @package automattic/jetpack
*/
/**
* Class that handles reCAPTCHA.
*
* @deprecated 11.0
*/
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' ),
'unexpected-hostname' => __( 'Unexpected hostname', 'jetpack' ),
);
}
/**
* Get default config for this reCAPTCHA instance.
*
* @return array Default config
*/
public function get_default_config() {
return array(
'language' => get_locale(),
'script_async' => false,
'script_defer' => true,
'script_lazy' => false,
'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 );
}
// Validate the hostname matches expected source
if ( isset( $resp_decoded['hostname'] ) ) {
$url = wp_parse_url( get_home_url() );
/**
* Allow other valid hostnames.
*
* This can be useful in cases where the token hostname is expected to be
* different from the get_home_url (ex. AMP recaptcha token contains a different hostname)
*
* @module sharedaddy
*
* @since 9.1.0
*
* @param array [ $url['host'] ] List of the valid hostnames to check against.
*/
$valid_hostnames = apply_filters( 'jetpack_recaptcha_valid_hostnames', array( $url['host'] ) );
if ( ! in_array( $resp_decoded['hostname'], $valid_hostnames, true ) ) {
return new WP_Error( 'unexpected-host', $this->error_codes['unexpected-hostname'] );
}
}
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() {
$url = sprintf(
'https://www.google.com/recaptcha/api.js?hl=%s',
rawurlencode( $this->config['language'] )
);
$html = sprintf(
'
<div
class="%s"
data-sitekey="%s"
data-theme="%s"
data-type="%s"
data-tabindex="%s"
data-lazy="%s"
data-url="%s"></div>
',
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'] ),
$this->config['script_lazy'] ? 'true' : 'false',
esc_attr( $url )
);
if ( ! $this->config['script_lazy'] ) {
$html = $html . sprintf(
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
'<script src="%s"%s%s></script>
',
$url,
$this->config['script_async'] && ! $this->config['script_defer'] ? ' async' : '',
$this->config['script_defer'] ? ' defer' : ''
);
}
return $html;
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,229 @@
<?php
/**
* Jetpack's Sharing feature, nee Sharedaddy.
* The most super duper sharing tool on the interwebs.
*
* @package automattic/jetpack
*/
// Set up Sharing in wp-admin.
require_once plugin_dir_path( __FILE__ ) . 'sharing.php';
/**
* Add a meta box to the post editing screen for sharing.
*
* @return void
*/
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, 'side', 'default', array( '__back_compat_meta_box' => true ) );
}
}
}
/**
* Content of the meta box.
*
* @param WP_Post $post The post to share.
*
* @return void
*/
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 esc_html_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 );
}
/**
* Save new sharing status in post meta in the meta box.
*
* @param int $post_id Post ID.
*
* @return int
*/
function sharing_meta_box_save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
if ( ! isset( $_POST['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
return $post_id;
}
$post_type_object = get_post_type_object( sanitize_key( $_POST['post_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
// Record sharing disable.
if (
$post_type_object->public
&& current_user_can( 'edit_post', $post_id )
&& isset( $_POST['sharing_status_hidden'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
) {
if ( ! isset( $_POST['enable_post_sharing'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
update_post_meta( $post_id, 'sharing_disabled', 1 );
} else {
delete_post_meta( $post_id, 'sharing_disabled' );
}
}
return $post_id;
}
/**
* If Sharing is disabled, disable the meta box.
*
* @param bool $protected Whether the key is considered protected.
* @param string $meta_key Metadata key.
*
* @return bool
*/
function sharing_meta_box_protected( $protected, $meta_key ) {
if ( 'sharing_disabled' === $meta_key ) {
$protected = true;
}
return $protected;
}
add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 2 );
/**
* Add link to sharing settings in the Plugins screen.
*
* @param array $links An array of plugin action links.
*
* @return array
*/
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;
}
/**
* Add links to settings and support in the plugin row.
*
* @param array $links An array of the plugin's metadata, including the version, author, author URI, and plugin URI.
* @param string $file Path to the plugin file relative to the plugins directory.
*
* @return array
*/
function sharing_add_plugin_settings( $links, $file ) {
if ( $file === basename( __DIR__ ) . '/' . basename( __FILE__ ) ) {
$links[] = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
$links[] = '<a href="https://support.wordpress.com/sharing/" rel="noopener noreferrer" target="_blank">' . __( 'Support', 'jetpack' ) . '</a>';
}
return $links;
}
/**
* Disable sharing on the frontend if disabled in the admin.
*
* @return void
*/
function sharing_init() {
if ( Jetpack_Options::get_option_and_ensure_autoload( 'sharedaddy_disable_resources', '0' ) ) {
add_filter( 'sharing_js', '__return_false' );
remove_action( 'wp_head', 'sharing_add_header', 1 );
}
}
/**
* Add settings to disable CSS and JS normally enqueued by our feature.
*
* @return void
*/
function sharing_global_resources() {
$disable = get_option( 'sharedaddy_disable_resources' );
?>
<tr valign="top">
<th scope="row"><label for="disable_css"><?php esc_html_e( 'Disable CSS and JS', 'jetpack' ); ?></label></th>
<td>
<?php
printf(
'<input id="disable_css" type="checkbox" name="disable_resources"%1$s /> <small><em>%2$s</em></small>',
( 1 == $disable ) ? ' checked="checked"' : '', // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
esc_html__( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' )
);
?>
</td>
</tr>
<?php
}
/**
* Save settings to disable CSS and JS normally enqueued by our feature.
*
* @return void
*/
function sharing_global_resources_save() {
update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling is handled for all elements at once.
}
add_action( 'init', 'sharing_init' );
add_action( 'add_meta_boxes', 'sharing_add_meta_box' );
add_action( 'save_post', 'sharing_meta_box_save' );
add_action( 'edit_attachment', 'sharing_meta_box_save' );
add_action( 'sharing_global_options', 'sharing_global_resources', 30 );
add_action( 'sharing_admin_update', 'sharing_global_resources_save' );
add_action( 'plugin_action_links_' . basename( __DIR__ ) . '/' . basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 );
add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 );
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,776 @@
/**
* 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;
}
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-sharing {
margin-bottom: 1em;
}
.sd-content ul {
padding: 0 !important;
margin: 0 !important;
list-style: none !important;
}
.sd-content ul li {
display: inline-block;
}
.sd-content ul li.share-deprecated {
opacity: 0.5;
}
.sd-content ul li.share-deprecated a span {
text-decoration: line-through;
}
.sd-block.sd-gplus {
margin: 0 0 .5em 0;
}
.sd-gplus .sd-content {
font-size: 12px;
}
/* Sharing email errors */
.sd-content .share-email-error .share-email-error-title {
margin: 0.5em 0;
}
.sd-content .share-email-error .share-email-error-text {
font-family: "Open Sans", sans-serif;
font-size: 12px;
margin: 0.5em 0;
}
/* 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;
font-size: 13px;
font-family: "Open Sans", sans-serif;
font-weight: 500;
border-radius: 4px;
color: #2C3338 !important;
background: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.12);
text-shadow: none;
line-height: 23px;
padding: 4px 11px 3px 9px;
}
.sd-social-official .sd-content ul li a.sd-button,
.sd-social-official .sd-content ul li.preview-item div.option.option-smart-off a {
align-items: center;
display: flex;
font-size: 12px;
line-height: 12px;
padding: 1px 6px 0px 5px;
min-height: 20px;
}
.sd-social-official .sd-content ul.preview li a.sd-button,
.sd-social-official .sd-content ul.preview li.preview-item div.option.option-smart-off a {
position: relative;
top: 2px;
}
.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;
margin-left: 6px;
}
/* Icon Only */
.sd-social-icon .sd-content ul li a.sd-button>span {
margin-left: 0;
}
/* Text Only */
.sd-social-text .sd-content ul li a.sd-button span {
margin-left: 3px;
}
.sd-social-official .sd-content ul li a.sd-button>span,
.sd-social-official .sd-content ul li.preview-item div.option.option-smart-off a span {
line-height: 12px;
margin-left: 3px;
}
.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;
}
.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 {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.22);
}
.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 18px/1 'social-logos';
vertical-align: top;
text-align: center;
}
/* text + icon styles should have relative and top position */
.sd-social-icon-text ul li a.sd-button:before {
position: relative;
top: 2px;
}
/* Make it look great in Chrome and Safari */
@media screen and (-webkit-min-device-pixel-ratio:0) {
.sd-content ul li a.sd-button:before {
position: relative;
top: 2px;
}
}
.sd-social-official ul li a.sd-button:before {
position: relative;
top: -2px;
}
/* Make it look great in Chrome and Safari */
@media screen and (-webkit-min-device-pixel-ratio:0) {
.sd-social-official ul li a.sd-button:before {
top: 0px;
}
}
.sd-content ul li {
margin: 0 8px 12px 0;
padding: 0;
}
/* Add more pading on touch devices */
.jp-sharing-input-touch .sd-content ul li { padding-left: 10px; }
.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: -4px;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
.sd-social-icon .sd-content ul li a.share-more {
top: 2px;
}
}
/* Firefox specific hack to make the share more button look better on Firefox. */
@-moz-document url-prefix() {
.sd-social-icon .sd-content ul li a.share-more {
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-x a:before,
.sd-social-text .sd-content ul li.share-x a:before,
.sd-content ul li.share-x div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-x a:before {
content: '\f10e';
}
.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,
.sd-social-official .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: '\f607';
}
.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-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: '\f210';
}
.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: '\f203';
}
.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 li.share-telegram a:before,
.sd-social-text .sd-content ul li.share-telegram a:before,
.sd-content ul li.share-telegram div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-telegram a:before,
.sd-social-official .sd-content li.share-telegram a:before {
content: '\f606';
}
.sd-social-official .sd-content li.share-telegram a:before {
color: #0088cc;
}
.sd-social-icon .sd-content ul li.share-threads a:before,
.sd-social-text .sd-content ul li.share-threads a:before,
.sd-content ul li.share-threads div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-threads a:before,
.sd-social-official .sd-content li.share-threads a:before {
content: '\f10d';
}
.sd-social-official .sd-content li.share-threads a:before {
color: #000;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-threads a.sd-button {
background: #000;
color: #fff !important;
}
.sd-social-icon .sd-content ul li.share-mastodon a:before,
.sd-social-text .sd-content ul li.share-mastodon a:before,
.sd-content ul li.share-mastodon div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-mastodon a:before,
.sd-social-official .sd-content li.share-mastodon a:before {
content: '\f10a';
}
.sd-social-official .sd-content li.share-mastodon a:before {
color: #563ACC;
}
.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;
}
.sd-social-icon .sd-content ul li.share-jetpack-whatsapp a:before,
.sd-social-text .sd-content ul li.share-jetpack-whatsapp a:before,
.sd-content ul li.share-jetpack-whatsapp div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-jetpack-whatsapp a:before,
.sd-social-official .sd-content li.share-jetpack-whatsapp a:before {
content: '\f608';
}
.sd-social-official .sd-content li.share-jetpack-whatsapp a:before {
color: #43d854;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-jetpack-whatsapp a.sd-button {
background: #43d854;
color: #fff !important;
}
.sd-social-icon .sd-content ul li.share-nextdoor a:before,
.sd-social-text .sd-content ul li.share-nextdoor a:before,
.sd-content ul li.share-nextdoor div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-nextdoor a:before,
.sd-social-official .sd-content li.share-nextdoor a:before {
content: '\f10c';
}
.sd-social-official .sd-content li.share-nextdoor a:before {
color: #8ED500;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-nextdoor a.sd-button {
background: #8ED500;
color: #fff !important;
}
.sd-social-icon .sd-content ul li.share-bluesky a:before,
.sd-social-text .sd-content ul li.share-bluesky a:before,
.sd-content ul li.share-bluesky div.option.option-smart-off a:before,
.sd-social-icon-text .sd-content li.share-bluesky a:before,
.sd-social-official .sd-content li.share-bluesky a:before {
content: '\f10f';
}
.sd-social-official .sd-content li.share-bluesky a:before {
color: #0085ff;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-bluesky a.sd-button {
background: #0085ff;
color: #fff !important;
}
.sd-social-icon .sd-content ul li.share-deprecated a:before,
.sd-social-icon-text .sd-content li.share-deprecated a:before,
.sd-social-official .sd-content li.share-deprecated a:before,
.sd-content ul li.share-deprecated div.option.option-smart-off a:before {
width: 1em;
height: 1em;
content: "\1F6AB";
}
/* 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;
}
.sd-social-official .sd-content>ul>li>a.sd-button span {
line-height: 1;
}
.sd-social-official .sd-content ul {
display: flex;
flex-wrap: wrap;
}
.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: flex;
max-height: 18px;
}
.sd-social-official .sd-content ul>li .option-smart-off {
margin-right: 8px;
}
.sd-social-official .fb-share-button > span {
vertical-align: top !important;
}
.sd-social-official .sd-content .pocket_button iframe {
width: 98px;
}
/* Individual official buttons */
.pocket_button iframe, .pinterest_button, .twitter_button, .linkedin_button>span {
margin: 0 !important;
}
.linkedin_button>span, .pinterest_button a {
display: block !important;
}
.sd-social-official .sd-content .share-tumblr iframe {
max-width: 53px;
width: unset;
}
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: 21px;
line-height: 16px;
}
body .sd-social-icon .sd-content li.share-custom a span {
width: 0;
}
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 !important;
height: 0 !important;
}
.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: 7px;
position: relative;
top: -2px;
line-height: 1;
width: auto;
height: auto;
margin-bottom: 0;
max-width: 32px;
}
.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: #0866ff;
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-x a.sd-button {
background: #000;
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: #4f94d4;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-telegram a.sd-button {
background: #0088cc;
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-pocket a.sd-button {
background: #ee4056;
color: #fff !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-reddit a.sd-button {
background: #cee3f8;
color: #555555 !important;
}
.sd-social-icon .sd-content ul li[class*='share-'].share-mastodon a.sd-button {
background: linear-gradient(to top, #563ACC 0%, #6364FF 100%);
color: #fff !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: #f0f0f1;
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 */
}
#jetpack-source_f_name {
display: none!important;
position: absolute !important;
left: -9000px;
}
.sd-content .share-customize-link {
margin-top: 8px;
line-height: 11px;
}
.sd-content .share-customize-link a {
font-size: 11px;
font-family: "Open Sans", sans-serif;
}
@media print {
.sharedaddy.sd-sharing-enabled {
display: none;
}
}
@@ -0,0 +1,614 @@
/* global WPCOM_sharing_counts */
// NOTE: This file intentionally does not make use of polyfills or libraries,
// including jQuery. Please keep all code as IE11-compatible vanilla ES5, and
// ensure everything is inside an IIFE to avoid global namespace pollution.
// Code follows WordPress browser support guidelines. For an up to date list,
// see https://make.wordpress.org/core/handbook/best-practices/browser-support/
( function () {
var currentScript = document.currentScript;
// -------------------------- UTILITY FUNCTIONS -------------------------- //
// Helper function to load an external script.
function loadScript( url ) {
var script = document.createElement( 'script' );
var prev = currentScript || document.getElementsByTagName( 'script' )[ 0 ];
script.setAttribute( 'async', true );
script.setAttribute( 'src', url );
prev.parentNode.insertBefore( script, prev );
}
// Helper matches function (not a polyfill), compatible with IE 11.
function matches( el, sel ) {
if ( Element.prototype.matches ) {
return el.matches( sel );
}
if ( Element.prototype.msMatchesSelector ) {
return el.msMatchesSelector( sel );
}
}
// Helper closest parent node function (not a polyfill) based on
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
function closest( el, sel ) {
if ( el.closest ) {
return el.closest( sel );
}
var current = el;
do {
if ( matches( current, sel ) ) {
return current;
}
current = current.parentElement || current.parentNode;
} while ( current !== null && current.nodeType === 1 );
return null;
}
// Helper function to iterate over a NodeList
// (since IE 11 doesn't have NodeList.prototype.forEach)
function forEachNode( list, fn ) {
for ( var i = 0; i < list.length; i++ ) {
var node = list[ i ];
fn( node, i, list );
}
}
// Helper function to remove a node from the DOM.
function removeNode( node ) {
if ( node && node.parentNode ) {
node.parentNode.removeChild( node );
}
}
// Helper functions to show/hide a node, and check its status.
function hideNode( node ) {
if ( node ) {
node.style.display = 'none';
}
}
function showNode( node ) {
if ( node ) {
node.style.removeProperty( 'display' );
}
}
function isNodeHidden( node ) {
return ! node || node.style.display === 'none';
}
// ------------------------------- CLASSES ------------------------------- //
var PANE_SELECTOR = '.sharing-hidden .inner';
var PANE_DATA_ATTR = 'data-sharing-more-button-id';
// Implements a MoreButton class, which controls the lifecycle and behavior
// of a "more" button and its dialog.
function MoreButton( buttonEl ) {
this.button = buttonEl;
this.pane = closest( buttonEl, 'div' ).querySelector( PANE_SELECTOR );
this.openedBy = null;
this.recentlyOpenedByHover = false;
MoreButton.instances.push( this );
this.pane.setAttribute( PANE_DATA_ATTR, MoreButton.instances.length - 1 );
this.attachHandlers();
}
// Keep a reference to each instance, so we can get back to it from the DOM.
MoreButton.instances = [];
// Delay time configs.
MoreButton.hoverOpenDelay = 200;
MoreButton.recentOpenDelay = 400;
MoreButton.hoverCloseDelay = 300;
// Use this to avoid creating new instances for buttons which already have one.
MoreButton.instantiateOrReuse = function ( buttonEl ) {
var pane = closest( buttonEl, 'div' ).querySelector( PANE_SELECTOR );
var paneId = pane && pane.getAttribute( PANE_DATA_ATTR );
var existingInstance = MoreButton.instances[ paneId ];
if ( existingInstance ) {
return existingInstance;
}
return new MoreButton( buttonEl );
};
// Retrieve a button instance from the pane DOM element.
MoreButton.getButtonInstanceFromPane = function ( paneEl ) {
var paneId = paneEl && paneEl.getAttribute( PANE_DATA_ATTR );
return MoreButton.instances[ paneId ];
};
// Close all open More Button dialogs.
MoreButton.closeAll = function () {
for ( var i = 0; i < MoreButton.instances.length; i++ ) {
MoreButton.instances[ i ].close();
}
};
MoreButton.prototype.open = function () {
var offset;
var offsetParent;
var parentOffset = [ 0, 0 ];
function getOffsets( el ) {
var rect = el.getBoundingClientRect();
return [
rect.left + ( window.scrollX || window.pageXOffset || 0 ),
rect.top + ( window.scrollY || window.pageYOffset || 0 ),
];
}
function getStyleValue( el, prop ) {
return parseInt( getComputedStyle( el ).getPropertyValue( prop ) || 0 );
}
offset = getOffsets( this.button );
offsetParent = this.button.offsetParent || document.documentElement;
while (
offsetParent &&
( offsetParent === document.body || offsetParent === document.documentElement ) &&
getComputedStyle( offsetParent ).getPropertyValue( 'position' ) === 'static'
) {
offsetParent = offsetParent.parentNode;
}
if ( offsetParent && offsetParent !== this.button && offsetParent.nodeType === 1 ) {
parentOffset = getOffsets( offsetParent );
parentOffset = [
parentOffset[ 0 ] + getStyleValue( offsetParent, 'border-left-width' ),
parentOffset[ 1 ] + getStyleValue( offsetParent, 'border-top-width' ),
];
}
var positionLeft =
offset[ 0 ] - parentOffset[ 0 ] - getStyleValue( this.button, 'margin-left' );
var positionTop = offset[ 1 ] - parentOffset[ 1 ] - getStyleValue( this.button, 'margin-top' );
this.pane.style.left = positionLeft + 'px';
this.pane.style.top = positionTop + this.button.offsetHeight + 3 + 'px';
showNode( this.pane );
};
MoreButton.prototype.close = function () {
hideNode( this.pane );
this.openedBy = null;
};
MoreButton.prototype.toggle = function () {
if ( isNodeHidden( this.pane ) ) {
this.open();
} else {
this.close();
}
};
MoreButton.prototype.nonHoverOpen = function () {
clearTimeout( this.openTimer );
clearTimeout( this.closeTimer );
if ( this.recentlyOpenedByHover ) {
this.recentlyOpenedByHover = false;
clearTimeout( this.hoverOpenTimer );
this.open();
} else {
this.toggle();
}
};
MoreButton.prototype.resetCloseTimer = function () {
clearTimeout( this.closeTimer );
this.closeTimer = setTimeout( this.close.bind( this ), MoreButton.hoverCloseDelay );
};
MoreButton.prototype.attachHandlers = function () {
this.buttonClick = function ( event ) {
event.preventDefault();
event.stopPropagation();
this.openedBy = 'click';
this.nonHoverOpen();
}.bind( this );
this.buttonKeydown = function ( event ) {
if ( event.keyCode === 13 || event.keyCode === 32 ) {
event.preventDefault();
event.stopPropagation();
this.openedBy = 'keydown';
this.nonHoverOpen();
}
}.bind( this );
this.buttonEnter = function () {
if ( ! this.openedBy ) {
this.openTimer = setTimeout(
function () {
this.open();
this.openedBy = 'hover';
this.recentlyOpenedByHover = true;
this.hoverOpenTimer = setTimeout(
function () {
this.recentlyOpenedByHover = false;
}.bind( this ),
MoreButton.recentOpenDelay
);
}.bind( this ),
MoreButton.hoverOpenDelay
);
}
clearTimeout( this.closeTimer );
}.bind( this );
this.buttonLeave = function () {
if ( this.openedBy === 'hover' ) {
this.resetCloseTimer();
}
clearTimeout( this.openTimer );
}.bind( this );
this.paneEnter = function () {
clearTimeout( this.closeTimer );
}.bind( this );
this.paneLeave = function () {
if ( this.openedBy === 'hover' ) {
this.resetCloseTimer();
}
}.bind( this );
this.documentClick = function () {
this.close();
}.bind( this );
this.button.addEventListener( 'click', this.buttonClick );
this.button.addEventListener( 'keydown', this.buttonKeydown );
document.addEventListener( 'click', this.documentClick );
if ( document.ontouchstart === undefined ) {
// Non-touchscreen device: use hover/mouseout with delay
this.button.addEventListener( 'mouseenter', this.buttonEnter );
this.button.addEventListener( 'mouseleave', this.buttonLeave );
this.pane.addEventListener( 'mouseenter', this.paneEnter );
this.pane.addEventListener( 'mouseleave', this.paneLeave );
}
};
// ---------------------------- SHARE COUNTS ---------------------------- //
if ( window.sharing_js_options && window.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 = {
// Pinterest 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 ),
],
};
for ( service in requests ) {
if ( ! document.querySelector( 'a[data-shared=sharing-' + service + '-' + id + ']' ) ) {
continue;
}
while ( ( service_request = requests[ service ].pop() ) ) {
loadScript( service_request );
}
if ( window.sharing_js_options.is_stats_active ) {
WPCOMSharing.bump_sharing_count_stat( service );
}
}
WPCOMSharing.done_urls[ id ] = true;
}
},
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 ) {
forEachNode(
document.querySelectorAll( 'a[data-shared=' + id + '] > span' ),
function ( span ) {
var countNode = span.querySelector( '.share-count' );
removeNode( countNode );
var newNode = document.createElement( 'span' );
newNode.className = 'share-count';
newNode.textContent = WPCOMSharing.format_count( count );
span.appendChild( newNode );
}
);
},
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();
},
};
window.WPCOMSharing = WPCOMSharing;
}
// ------------------------ BUTTON FUNCTIONALITY ------------------------ //
function isUrlForCurrentHost( url ) {
var currentDomain = window.location.protocol + '//' + window.location.hostname + '/';
return String( url ).indexOf( currentDomain ) === 0;
}
function getEncodedFormFieldForSubmit( name, value ) {
// Encode the key and value into a URI-compatible string.
var encoded = encodeURIComponent( name ) + '=' + encodeURIComponent( value );
// In x-www-form-urlencoded, spaces should be `+`, not `%20`.
return encoded.replace( /%20/g, '+' );
}
function trackButtonClick( button ) {
var clickCount = getClickCountForButton( button );
setClickCountForButton( button, clickCount + 1 );
}
function setClickCountForButton( button, clickCount ) {
button.setAttribute( 'jetpack-share-click-count', clickCount );
}
function getClickCountForButton( button ) {
var currentClickCount = button.getAttribute( 'jetpack-share-click-count' );
if ( currentClickCount === null ) {
return 0;
}
return parseInt( currentClickCount, 10 );
}
function showEmailShareError( emailShareButton, sdUlGroup ) {
var sdContent = sdUlGroup.parentElement;
if ( ! sdContent.classList.contains( 'sd-content' ) ) {
return;
}
forEachNode( sdContent.querySelectorAll( '.share-email-error' ), function ( shareEmailError ) {
shareEmailError.parentElement.removeChild( shareEmailError );
} );
var newShareEmailError = document.createElement( 'div' );
newShareEmailError.className = 'share-email-error';
var newShareEmailErrorTitle = document.createElement( 'h6' );
newShareEmailErrorTitle.className = 'share-email-error-title';
newShareEmailErrorTitle.innerText = emailShareButton.getAttribute(
'data-email-share-error-title'
);
newShareEmailError.appendChild( newShareEmailErrorTitle );
var newShareEmailErrorText = document.createElement( 'p' );
newShareEmailErrorText.className = 'share-email-error-text';
newShareEmailErrorText.innerText = emailShareButton.getAttribute(
'data-email-share-error-text'
);
newShareEmailError.appendChild( newShareEmailErrorText );
sdContent.appendChild( newShareEmailError );
}
function recordEmailShareClick( emailShareTrackerUrl, emailShareNonce ) {
var request = new XMLHttpRequest();
request.open( 'POST', emailShareTrackerUrl, true );
request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' );
request.setRequestHeader( 'x-requested-with', 'XMLHttpRequest' );
request.send( getEncodedFormFieldForSubmit( 'email-share-nonce', emailShareNonce ) );
}
// Sharing initialization.
// Will run immediately or on `DOMContentLoaded`, depending on current page status.
function init() {
WPCOMSharing_do();
}
if ( document.readyState !== 'loading' ) {
init();
} else {
document.addEventListener( 'DOMContentLoaded', init );
}
// Set up sharing again whenever a new post loads, to pick up any new buttons.
document.body.addEventListener( 'is.post-load', WPCOMSharing_do );
// Set up sharing, updating counts and adding all button functionality.
function WPCOMSharing_do() {
if ( window.WPCOMSharing ) {
window.WPCOMSharing.get_counts();
}
forEachNode( document.querySelectorAll( '.sharedaddy a' ), function ( anchor ) {
var href = anchor.getAttribute( 'href' );
if ( href && href.indexOf( 'share=' ) !== -1 && href.indexOf( '&nb=1' ) === -1 ) {
anchor.setAttribute( 'href', href + '&nb=1' );
}
} );
// Show hidden buttons
// Touchscreen device: use click.
// Non-touchscreen device: use click if not already appearing due to a hover event
forEachNode(
document.querySelectorAll( '.sharedaddy a.sharing-anchor' ),
function ( buttonEl ) {
MoreButton.instantiateOrReuse( buttonEl );
}
);
if ( document.ontouchstart !== undefined ) {
document.body.classList.add( 'jp-sharing-input-touch' );
}
// Add click functionality
forEachNode( document.querySelectorAll( '.sharedaddy ul' ), function ( group ) {
if ( group.getAttribute( 'data-sharing-events-added' ) === 'true' ) {
return;
}
group.setAttribute( 'data-sharing-events-added', 'true' );
var printUrl = function ( uniqueId, urlToPrint ) {
var iframe = document.createElement( 'iframe' );
iframe.setAttribute(
'style',
'position:fixed; top:100; left:100; height:1px; width:1px; border:none;'
);
iframe.setAttribute( 'id', 'printFrame-' + uniqueId );
iframe.setAttribute( 'name', iframe.getAttribute( 'id' ) );
iframe.setAttribute( 'src', urlToPrint );
iframe.setAttribute(
'onload',
'frames["printFrame-' +
uniqueId +
'"].focus();frames["printFrame-' +
uniqueId +
'"].print();'
);
document.body.appendChild( iframe );
};
// Print button
forEachNode( group.querySelectorAll( 'a.share-print' ), function ( printButton ) {
printButton.addEventListener( 'click', function ( event ) {
event.preventDefault();
event.stopPropagation();
var ref = printButton.getAttribute( 'href' ) || '';
var doPrint = function () {
if ( ref.indexOf( '#print' ) === -1 ) {
var uid = new Date().getTime();
printUrl( uid, ref );
} else {
window.print();
}
};
// Is the button in a dropdown?
var pane = closest( printButton, PANE_SELECTOR );
if ( pane ) {
var moreButton = MoreButton.getButtonInstanceFromPane( pane );
if ( moreButton ) {
moreButton.close();
doPrint();
}
} else {
doPrint();
}
} );
} );
// Press This button
forEachNode( group.querySelectorAll( 'a.share-press-this' ), function ( pressThisButton ) {
pressThisButton.addEventListener( 'click', function ( event ) {
event.preventDefault();
event.stopPropagation();
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 ) {
var href = pressThisButton.getAttribute( 'href' );
pressThisButton.setAttribute( 'href', href + '&sel=' + encodeURI( s ) );
}
if (
! window.open(
pressThisButton.getAttribute( 'href' ),
't',
'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'
)
) {
document.location.href = pressThisButton.getAttribute( 'href' );
}
} );
} );
// Email button
forEachNode( group.querySelectorAll( 'a.share-email' ), function ( emailButton ) {
setClickCountForButton( emailButton, 0 );
var emailShareNonce = emailButton.getAttribute( 'data-email-share-nonce' );
var emailShareTrackerUrl = emailButton.getAttribute( 'data-email-share-track-url' );
if (
emailShareNonce &&
emailShareTrackerUrl &&
isUrlForCurrentHost( emailShareTrackerUrl )
) {
emailButton.addEventListener( 'click', function () {
trackButtonClick( emailButton );
if ( getClickCountForButton( emailButton ) > 2 ) {
showEmailShareError( emailButton, group );
}
recordEmailShareClick( emailShareTrackerUrl, emailShareNonce );
} );
}
} );
} );
forEachNode(
document.querySelectorAll( 'li.share-email, li.share-custom a.sharing-anchor' ),
function ( node ) {
node.classList.add( 'share-service-visible' );
}
);
}
} )();
@@ -0,0 +1,887 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Set up Sharing functionality and management in wp-admin.
*
* @package automattic/jetpack
*/
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Status;
if ( ! defined( 'WP_SHARING_PLUGIN_URL' ) ) {
define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
/**
* Utilities to manage sharing settings from wp-admin.
*/
class Sharing_Admin {
/**
* Constructor.
* Hook into WordPress to add our functionality.
*/
public function __construct() {
require_once WP_SHARING_PLUGIN_DIR . 'sharing-service.php';
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nonces are handled in process_requests.
if ( isset( $_GET['page'] ) && ( $_GET['page'] === 'sharing.php' || $_GET['page'] === 'sharing' ) ) {
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' ) );
}
/**
* Enqueue scripts and styles on the sharing settings page.
*
* @return void
*/
public function sharing_head() {
wp_enqueue_script(
'sharing-js',
Assets::get_file_url_for_environment(
'_inc/build/sharedaddy/admin-sharing.min.js',
'modules/sharedaddy/admin-sharing.js'
),
array( 'jquery', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ),
JETPACK__VERSION,
false
);
/**
* Filters the switch that if set to true allows Jetpack to use minified assets. Defaults to true
* if the SCRIPT_DEBUG constant is not set or set to false. The filter overrides it.
*
* @since 6.2.0
*
* @param boolean $var should Jetpack use minified assets.
*/
$postfix = apply_filters( 'jetpack_should_use_minified_assets', true ) ? '.min' : '';
if ( is_rtl() ) {
wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL . 'admin-sharing-rtl' . $postfix . '.css', false, JETPACK__VERSION );
} else {
wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL . 'admin-sharing' . $postfix . '.css', false, JETPACK__VERSION );
}
wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL . 'sharing.css', false, JETPACK__VERSION );
wp_enqueue_style( 'social-logos' );
wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array(), 4, false );
add_thickbox();
// On Jetpack sites, make sure we include CSS to style the admin page.
if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
Jetpack_Admin_Page::load_wrapper_styles();
}
}
/**
* Load the process that handles saving changes on the sharing settings page.
*
* @return void
*/
public function admin_init() {
$this->process_requests();
}
/**
* Save changes to sharing settings.
*
* @return void
*/
public function process_requests() {
if (
isset( $_POST['_wpnonce'] )
&& wp_verify_nonce( sanitize_key( wp_unslash( $_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( 0 );
}
}
/**
* Register Sharing settings menu page in offline mode or when wp-admin interface is enabled.
*/
public function subscription_menu() {
$wpcom_is_wp_admin_interface = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
$is_user_connected = ( new Connection_Manager() )->is_user_connected();
if (
( new Status() )->is_offline_mode()
|| $wpcom_is_wp_admin_interface
|| ! $is_user_connected
) {
add_submenu_page(
'options-general.php',
__( 'Sharing Settings', 'jetpack' ),
__( 'Sharing', 'jetpack' ),
'manage_options',
'sharing',
array( $this, 'wrapper_admin_page' )
);
}
}
/**
* Save changes to sharing services via AJAX.
*
* @return void
*/
public function ajax_save_services() {
if (
isset( $_POST['_wpnonce'] )
&& wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'sharing-options' )
&& isset( $_POST['hidden'] )
&& isset( $_POST['visible'] )
) {
$sharer = new Sharing_Service();
$sharer->set_blog_services(
explode( ',', sanitize_text_field( wp_unslash( $_POST['visible'] ) ) ),
explode( ',', sanitize_text_field( wp_unslash( $_POST['hidden'] ) ) )
);
die( 0 );
}
}
/**
* Create a new custom sharing service via AJAX.
*
* @return never
*/
public function ajax_new_service() {
if (
isset( $_POST['_wpnonce'] )
&& isset( $_POST['sharing_name'] )
&& isset( $_POST['sharing_url'] )
&& isset( $_POST['sharing_icon'] )
&& wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'sharing-new_service' )
) {
$sharer = new Sharing_Service();
$service = $sharer->new_service(
sanitize_text_field( wp_unslash( $_POST['sharing_name'] ) ),
esc_url_raw( wp_unslash( $_POST['sharing_url'] ) ),
esc_url_raw( wp_unslash( $_POST['sharing_icon'] ) )
);
if ( $service ) {
$this->output_service( $service->get_id(), $service );
echo '<!--->';
$service->button_style = 'icon-text';
$this->output_preview( $service );
die( 0 );
}
}
// Fail
die( '1' );
}
/**
* Delete a sharing service via AJAX.
*
* @return void
*/
public function ajax_delete_service() {
if (
isset( $_POST['_wpnonce'] )
&& isset( $_POST['service'] )
&& wp_verify_nonce(
sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ),
'sharing-options_' . sanitize_text_field( wp_unslash( $_POST['service'] ) )
)
) {
$sharer = new Sharing_Service();
$sharer->delete_service( sanitize_text_field( wp_unslash( $_POST['service'] ) ) );
}
}
/**
* Save changes to sharing settings via AJAX.
*
* @return void
*/
public function ajax_save_options() {
if (
isset( $_POST['_wpnonce'] )
&& isset( $_POST['service'] )
&& wp_verify_nonce(
sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ),
'sharing-options_' . sanitize_text_field( wp_unslash( $_POST['service'] ) )
)
) {
$sharer = new Sharing_Service();
$service = $sharer->get_service( sanitize_text_field( wp_unslash( $_POST['service'] ) ) );
if ( $service && $service instanceof Sharing_Advanced_Source ) {
$service->update_options( $_POST );
$sharer->set_service( sanitize_text_field( wp_unslash( $_POST['service'] ) ), $service );
}
$this->output_service( $service->get_id(), $service, true );
echo '<!--->';
$service->button_style = 'icon-text';
$this->output_preview( $service );
die( 0 );
}
}
/**
* Display a preview of a sharing service.
*
* @param object $service Sharing service object.
*
* @return void
*/
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->is_deprecated() ) {
$klasses[] = 'share-deprecated';
}
if ( $service->get_class() !== $service->get_id() ) {
$klasses[] = 'preview-' . $service->get_id();
}
}
echo '<li class="' . esc_attr( implode( ' ', $klasses ) ) . '">';
$service->display_preview();
echo '</li>';
}
/**
* Display a specific sharing service.
*
* @param int $id Service unique ID.
* @param object $service Sharing service.
* @param bool $show_dropdown Display a dropdown. Not in use at the moment.
*
* @return void
*/
public function output_service( $id, $service, $show_dropdown = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$title = '';
$klasses = array( 'service', 'advanced', 'share-' . $service->get_class() );
$displayed_klasses = implode( ' ', $klasses );
if ( $service->is_deprecated() ) {
/* translators: %1$s is the name of a deprecated Sharing Service like "Google+" */
$title = sprintf( __( 'The %1$s sharing service has shut down or discontinued support for sharing buttons. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $service->get_name() );
$klasses[] = 'share-deprecated';
}
?>
<li class="<?php echo esc_attr( $displayed_klasses ); ?>" id="<?php echo esc_attr( $service->get_id() ); ?>" tabindex="0" title="<?php echo esc_attr( $title ); ?>">
<span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span>
<?php if ( str_starts_with( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?>
<span class="close"><a href="#" class="remove">&times;</a></span>
<form method="post" action="<?php echo esc_url( 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 esc_attr( wp_create_nonce( 'sharing-options_' . $id ) ); ?>" />
</form>
<?php endif; ?>
</li>
<?php
}
/**
* Display admin UI within a Jetpack header and footer.
*
* @return void
*/
public function wrapper_admin_page() {
Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ), array( 'is-wide' => true ) );
}
/**
* Sharing settings inner page structure.
*
* @return void
*/
public function management_page() {
if ( ! function_exists( 'mb_stripos' ) ) {
echo '<div id="message" class="updated fade"><h3>' . esc_html__( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
echo '<p>' . wp_kses(
sprintf(
/* Translators: placeholder is a link to a PHP support document. */
__( 'This plugin will work without it, but multibyte support is used <a href="%s" rel="noopener noreferrer" target="_blank">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ),
'https://www.php.net/manual/en/mbstring.installation.php'
),
array(
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
),
)
) . '</p></div>';
}
if ( isset( $_GET['update'] ) && 'saved' === $_GET['update'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only used to display a message.
echo '<div class="updated"><p>' . esc_html__( 'Settings have been saved', 'jetpack' ) . '</p></div>';
}
?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h1><?php esc_html_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
$block_availability = Jetpack_Gutenberg::get_cached_availability();
$is_block_available = (bool) isset( $block_availability['sharing-buttons'] ) && $block_availability['sharing-buttons']['available'];
$is_block_theme = wp_is_block_theme();
$show_block_message = $is_block_available && $is_block_theme;
// We either show old services config or the sharing block message.
if ( current_user_can( 'manage_options' ) ) :
$show_block_message ? $this->sharing_block_display() : $this->services_config_display();
endif;
?>
</div>
<script type="text/javascript">
var sharing_loading_icon = '<?php echo esc_js( admin_url( '/images/loading.gif' ) ); ?>';
<?php
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- we handle the nonce on the PHP side.
if (
isset( $_GET['create_new_service'] ) && isset( $_GET['name'] ) && isset( $_GET['url'] ) && isset( $_GET['icon'] )
&& 'true' == $_GET['create_new_service'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
) :
?>
jQuery(document).ready(function() {
// Prefill new service box and then open it
jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( sanitize_text_field( wp_unslash( $_GET['name'] ) ) ); ?>' );
jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( sanitize_text_field( wp_unslash( $_GET['url'] ) ) ); ?>' );
jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( sanitize_text_field( wp_unslash( $_GET['icon'] ) ) ); ?>' );
jQuery( '#add-a-new-service' ).click();
});
<?php endif; ?>
</script>
<?php
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}
/**
* Display services admin UI for settings.
*
* @return void
*/
public function services_config_display() {
$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 ( ! isset( $global['sharing_label'] ) ) {
$global['sharing_label'] = __( 'Share this:', 'jetpack' );
}
?>
<div class="share_manage_options">
<h2><?php esc_html_e( 'Sharing Buttons', 'jetpack' ); ?></h2>
<p><?php esc_html_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 esc_html_e( 'Available Services', 'jetpack' ); ?></h3>
<p><?php esc_html_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 esc_html_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 ( ( new Status() )->is_private_site() ) {
echo '<p><strong>' . esc_html__( '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 esc_html_e( 'Enabled Services', 'jetpack' ); ?>
<img src="<?php echo esc_url( admin_url( 'images/loading.gif' ) ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</h3>
<p><?php esc_html_e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
</td>
<td class="services" id="share-drop-target">
<h2 id="drag-instructions"
<?php
if ( is_countable( $enabled['visible'] ) && count( $enabled['visible'] ) > 0 ) {
echo ' style="display: none"';}
?>
><?php esc_html_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 esc_html_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 esc_html_e( 'Live Preview', 'jetpack' ); ?></h3>
</td>
<td class="services">
<h2 <?php echo ( is_countable( $enabled['all'] ) && count( $enabled['all'] ) > 0 ) ? ' style="display: none"' : ''; ?>><?php esc_html_e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
<div class="sharedaddy sd-sharing-enabled">
<?php if ( is_countable( $enabled['all'] ) && 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 ( is_countable( $enabled['hidden'] ) && count( $enabled['hidden'] ) > 0 ) : ?>
<li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php esc_html_e( 'More', 'jetpack' ); ?></span></a></li>
<?php endif; ?>
</ul>
<?php if ( is_countable( $enabled['hidden'] ) && 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 esc_html_e( 'More', 'jetpack' ); ?></span></a></li>
</ul>
</div>
</div>
<br class="clearing" />
</td>
</tr>
</table>
<form method="post" action="<?php echo esc_url( 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 esc_attr( implode( ',', array_keys( $enabled['visible'] ) ) ); ?>" />
<input type="hidden" name="hidden" value="<?php echo esc_attr( implode( ',', array_keys( $enabled['hidden'] ) ) ); ?>" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'sharing-options' ) ); ?>" />
</form>
</div>
<form method="post" action="">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><label><?php esc_html_e( 'Button style', 'jetpack' ); ?></label></th>
<td>
<select name="button_style" id="button_style">
<option<?php echo ( $global['button_style'] === 'icon-text' ) ? ' selected="selected"' : ''; ?> value="icon-text"><?php esc_html_e( 'Icon + text', 'jetpack' ); ?></option>
<option<?php echo ( $global['button_style'] === 'icon' ) ? ' selected="selected"' : ''; ?> value="icon"><?php esc_html_e( 'Icon only', 'jetpack' ); ?></option>
<option<?php echo ( $global['button_style'] === 'text' ) ? ' selected="selected"' : ''; ?> value="text"><?php esc_html_e( 'Text only', 'jetpack' ); ?></option>
<option<?php echo ( $global['button_style'] === 'official' ) ? ' selected="selected"' : ''; ?> value="official"><?php esc_html_e( 'Official buttons', 'jetpack' ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><label><?php esc_html_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">' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<th scope="row"><label><?php esc_html_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'], true ) ); ?> 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>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<?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 esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
</p>
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'sharing-options' ) ); ?>" />
</form>
<div id="new-service" style="display: none">
<form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" id="new-service-form">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" width="100"><label><?php esc_html_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 esc_html_e( 'Sharing URL', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_url" id="new_sharing_url" size="40" />
<p><?php esc_html_e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
<code>%post_id%</code>, <code>%post_title%</code>, <code>%post_slug%</code>, <code>%post_url%</code>, <code>%post_full_url%</code>, <code>%post_excerpt%</code>, <code>%post_tags%</code>, <code>%home_url%</code></p>
</td>
</tr>
<tr valign="top">
<th scope="row" width="100"><label><?php esc_html_e( 'Icon URL', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_icon" id="new_sharing_icon" size="40" />
<p><?php esc_html_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 esc_attr_e( 'Create Share Button', 'jetpack' ); ?>" />
<img src="<?php echo esc_url( 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 esc_html_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 esc_attr( wp_create_nonce( 'sharing-new_service' ) ); ?>" />
</form>
</div>
<?php
}
/**
* Display sharing block admin UI for settings.
*
* @return void
*/
public function sharing_block_display() {
$showcase_services = array(
new Share_Tumblr( 'tumblr', array() ),
new Share_Facebook( 'facebook', array() ),
new Share_Email( 'email', array() ),
new Share_Reddit( 'reddit', array() ),
);
global $submenu;
// Hide the link to Jetpack Sharing settings if no Jetpack Settings found in submenu list
$show_jetpack_admin_settings_link = array_reduce(
$submenu['jetpack'],
function ( $carry, $item ) {
return $carry || ( isset( $item[2] ) && $item[2] === 'jetpack#/settings' );
},
false
);
?>
<div class="share_manage_options">
<br class="clearing" />
<h2><?php esc_html_e( 'Sharing Buttons', 'jetpack' ); ?></h2>
<div class="sharing-block-message__items-wrapper">
<div>
<p><?php esc_html_e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ); ?></p>
<div class="sharing-block-message__buttons-wrapper">
<a href="<?php echo esc_url( admin_url( 'site-editor.php?path=%2Fwp_template' ) ); ?>" class="button button-primary">
<?php esc_html_e( 'Go to the site editor', 'jetpack' ); ?>
</a>
<a href="<?php echo esc_url( Redirect::get_url( 'jetpack-support-sharing-block' ) ); ?>" class="button" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'Learn how to add Sharing Buttons', 'jetpack' ); ?>
</a>
</div>
</div>
<div>
<p><?php esc_html_e( 'Sharing Buttons example:', 'jetpack' ); ?></p>
<div class="sharedaddy sd-sharing-enabled">
<div class="sd-content">
<ul class="preview">
<?php foreach ( $showcase_services as $service ) : ?>
<?php $this->output_preview( $service ); ?>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php if ( $show_jetpack_admin_settings_link ) : ?>
<p class="settings-sharing__block-theme-description">
<?php
printf(
wp_kses(
/* translators: Link to Jetpack sharing settings. */
__( 'You are using a block-based theme. You can <a class="dops-card__link" href="%s">disable Jetpacks legacy sharing buttons</a> and add a sharing block to your themes template instead.', 'jetpack' ),
array(
'a' => array( 'href' => array() ),
)
),
esc_url( admin_url( 'admin.php?page=jetpack#/sharing' ) )
);
?>
</p>
<?php endif; ?>
</div>
<br class="clearing" />
</div>
<?php
}
}
/**
* Callback to get the value for the jetpack_sharing_enabled field.
*
* When the sharing_disabled post_meta is unset, we follow the global setting in Sharing.
* When it is set to 1, we disable sharing on the post, regardless of the global setting.
* It is not possible to enable sharing on a post if it is disabled globally.
*
* @param array $post The post object.
*
* @return bool
*/
function jetpack_post_sharing_get_value( array $post ) {
if ( ! isset( $post['id'] ) ) {
return false;
}
// if sharing IS disabled on this post, enabled=false, so negate the meta
return (bool) ! get_post_meta( $post['id'], 'sharing_disabled', true );
}
/**
* Callback to set sharing_disabled post_meta when the
* jetpack_sharing_enabled field is updated.
*
* When the sharing_disabled post_meta is unset, we follow the global setting in Sharing.
* When it is set to 1, we disable sharing on the post, regardless of the global setting.
* It is not possible to enable sharing on a post if it is disabled globally.
*
* @param bool $enable_sharing Should sharing be enabled on this post.
* @param WP_Post $post_object The post object.
*
* @return int|bool
*/
function jetpack_post_sharing_update_value( $enable_sharing, $post_object ) {
if ( $enable_sharing ) {
// delete the override if we want to enable sharing
return delete_post_meta( $post_object->ID, 'sharing_disabled' );
} else {
return update_post_meta( $post_object->ID, 'sharing_disabled', true );
}
}
/**
* Add Sharing post_meta to the REST API Post response.
*
* @action rest_api_init
* @uses register_rest_field
* @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
*/
function jetpack_post_sharing_register_rest_field() {
$post_types = get_post_types( array( 'public' => true ) );
foreach ( $post_types as $post_type ) {
register_rest_field(
$post_type,
'jetpack_sharing_enabled',
array(
'get_callback' => 'jetpack_post_sharing_get_value',
'update_callback' => 'jetpack_post_sharing_update_value',
'schema' => array(
'description' => __( 'Are sharing buttons enabled?', 'jetpack' ),
'type' => 'boolean',
),
)
);
/**
* Ensures all public internal post-types support `sharing`
* This feature support flag is used by the REST API and Gutenberg.
*/
add_post_type_support( $post_type, 'jetpack-sharing-buttons' );
}
}
// Add Sharing post_meta to the REST API Post response.
add_action( 'rest_api_init', 'jetpack_post_sharing_register_rest_field' );
// Some CPTs (e.g. Jetpack portfolios and testimonials) get registered with
// restapi_theme_init because they depend on theme support, so let's also hook to that
add_action( 'restapi_theme_init', 'jetpack_post_likes_register_rest_field', 20 );
/**
* Initialize sharing settings in WP Admin.
*
* @return void
*/
function sharing_admin_init() {
global $sharing_admin;
$sharing_admin = new Sharing_Admin();
}
add_action( 'init', 'sharing_admin_init' );