This commit is contained in:
zbatte committed 2026-07-02 15:54:39 -06:00
commit 9883323161
17470 files changed
+4470592

No files matched your search

@@ -0,0 +1,469 @@
/**
* Sharedaddy Admin Styles
*/
#services-config {
min-width: 700px;
width: 100%;
float: right;
}
#services-config h3 {
font-weight: 400;
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 #ccc;
}
#live-preview {
border-bottom: 1px solid #dcdcde;
padding-bottom: 60px;
}
#available-services h3,
#enabled-services h3,
#live-preview h3 {
padding: 0;
margin-top: 0;
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: 0 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: 400 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-x span::before,
li.service.share-twitter span::before {
content: "\f10e";
}
li.service.share-reddit span::before {
content: "\f222";
}
li.service.share-tumblr span::before {
content: "\f214";
}
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-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: 0;
font-weight: 400 !important;
color: #999;
}
body.settings_page_sharing #live-preview h2 {
font-size: 20px;
font-weight: 400 !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: 100% 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-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);
}
}
/**
* Overflow sharing dialog
*/
.services .sharing-hidden li {
background-color: transparent;
}
.sharing-hidden li.share-end {
clear: both;
height: 0;
padding: 0 !important;
margin: 0 !important;
width: 0;
visibility: hidden;
float: none;
}
.preview .sharing-label {
font-weight: 700;
border: 0;
padding: 4px 0 0 6px;
}
#services-config a.remove {
background: #dcdcde;
color: #fff;
padding: 0 4px 2px;
border-radius: 15px;
text-decoration: none;
font-weight: 700;
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;
}
@@ -0,0 +1 @@
#services-config{float:right;min-width:700px;width:100%}#services-config h3{color:#464646;font-size:15px;font-weight:400;margin:0;overflow:hidden;padding:8px 10px;white-space:nowrap}#available-services,#enabled-services,#live-preview{border-spacing:0;padding:20px 0 0;width:100%}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}:is(#available-services,#enabled-services,#live-preview) h3{margin-bottom:1em;margin-top:0;padding:0}body.settings_page_sharing .description{vertical-align:top;width:180px}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{cursor:move}body.settings_page_sharing .services ul li.divider{background:none;border:none;cursor:default;padding:0}body.settings_page_sharing ul.services-hidden{margin-bottom:0}:is(#available-services,#enabled-services) .service{background:#fff;border-radius:4px;box-shadow:0 1px 2px #0000001f,0 0 0 1px #0000001f;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}:is(#available-services,#enabled-services) .service .options-left{align-items:center;display:flex}:is(#available-services,#enabled-services) .service:hover{box-shadow:0 1px 2px #00000038,0 0 0 1px #00000038}:is(#available-services,#enabled-services) .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{-webkit-font-smoothing:antialiased;font:400 18px/1 social-logos;height:16px;margin-left:6px;position:relative;top:-1px;width: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"}:is(li.service.share-twitter,li.service.share-x) span:before{content:"\f10e"}li.service.share-reddit span:before{content:"\f222"}li.service.share-tumblr span:before{content:"\f214"}li.service.share-pinterest span:before{content:"\f209"}li.service.share-facebook span:before{content:"\f203"}li.service.share-press-this span:before{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-bluesky span:before{content:"\f10f"}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 .inner li.preview-item a span,div.sd-social-icon ul.preview 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;height:20px;margin:0;padding:0;visibility:hidden;width:0}#enabled-services h2{color:#999;font-size:20px;font-weight:400!important;padding-top:0}body.settings_page_sharing #live-preview h2{color:#e3e3e3;font-size:20px;font-weight:400!important}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{border-top:1px solid #e3e3e3;display:none;margin-right:-24px;margin-top:4px;padding:10px 10px 8px 14px}body.settings_page_sharing .utility{float:left;font-size:10px;padding-left:10px;padding-top:10px}body.settings_page_sharing .advanced input[type=submit]{float:right;margin-left:10px;margin-top:10px}.services li.dropzone{background:#e3e3e3;border:1px dashed #999;border-radius:3px;height:18px;margin-left:10px;padding:5px}.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;padding:10px;vertical-align:top;width:29%}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px}.preview li.preview-item{background-position:100% 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 100% 0;background-size:76px 17px;height:17px;margin-top:2px;width:76px}.preview-facebook .option-smart-on{background:url(../../modules/sharedaddy/images/smart-like.png) no-repeat 100% 0;background-size:85px 20px;height:20px;margin-right:-4px;width:85px}:is(.preview-twitter,.preview-x) .option-smart-on{backgrLine truncated
@@ -0,0 +1,484 @@
/**
* Sharedaddy Admin Styles
*/
#services-config {
min-width: 700px;
width: 100%;
float: left;
}
#services-config h3 {
font-weight: 400;
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 #ccc;
}
#live-preview {
border-bottom: 1px solid #dcdcde;
padding-bottom: 60px;
}
#available-services h3,
#enabled-services h3,
#live-preview h3 {
padding: 0;
margin-top: 0;
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: 0 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: 400 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-x span::before,
li.service.share-twitter span::before {
content: "\f10e";
}
li.service.share-reddit span::before {
content: "\f222";
}
li.service.share-tumblr span::before {
content: "\f214";
}
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-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: 0;
font-weight: 400 !important;
color: #999;
}
body.settings_page_sharing #live-preview h2 {
font-size: 20px;
font-weight: 400 !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: 0 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-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);
}
}
/**
* Overflow sharing dialog
*/
.services .sharing-hidden li {
background-color: transparent;
}
.sharing-hidden li.share-end {
clear: both;
height: 0;
padding: 0 !important;
margin: 0 !important;
width: 0;
visibility: hidden;
float: none;
}
.preview .sharing-label {
font-weight: 700;
border: 0;
padding: 4px 6px 0 0;
}
#services-config a.remove {
background: #dcdcde;
color: #fff;
padding: 0 4px 2px;
border-radius: 15px;
text-decoration: none;
font-weight: 700;
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 .spinner' ).addClass( 'is-active' );
// 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 .spinner' ).removeClass( 'is-active' );
} );
}
$( '#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 .spinner' ).addClass( 'is-active' );
$( '#new-service-form input[type="submit"]' ).prop( 'disabled', true );
},
success: function ( response ) {
$( '#new-service-form .spinner' ).removeClass( 'is-active' );
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 );
@@ -0,0 +1 @@
#services-config{float:left;min-width:700px;width:100%}#services-config h3{color:#464646;font-size:15px;font-weight:400;margin:0;overflow:hidden;padding:8px 10px;white-space:nowrap}#available-services,#enabled-services,#live-preview{border-spacing:0;padding:20px 0 0;width:100%}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}:is(#available-services,#enabled-services,#live-preview) h3{margin-bottom:1em;margin-top:0;padding:0}body.settings_page_sharing .description{vertical-align:top;width:180px}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{cursor:move}body.settings_page_sharing .services ul li.divider{background:none;border:none;cursor:default;padding:0}body.settings_page_sharing ul.services-hidden{margin-bottom:0}:is(#available-services,#enabled-services) .service{background:#fff;border-radius:4px;box-shadow:0 1px 2px #0000001f,0 0 0 1px #0000001f;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}:is(#available-services,#enabled-services) .service .options-left{align-items:center;display:flex}:is(#available-services,#enabled-services) .service:hover{box-shadow:0 1px 2px #00000038,0 0 0 1px #00000038}:is(#available-services,#enabled-services) .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{-webkit-font-smoothing:antialiased;font:400 18px/1 social-logos;height:16px;margin-right:6px;position:relative;top:-1px;width: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"}:is(li.service.share-twitter,li.service.share-x) span:before{content:"\f10e"}li.service.share-reddit span:before{content:"\f222"}li.service.share-tumblr span:before{content:"\f214"}li.service.share-pinterest span:before{content:"\f209"}li.service.share-facebook span:before{content:"\f203"}li.service.share-press-this span:before{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-bluesky span:before{content:"\f10f"}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 .inner li.preview-item a span,div.sd-social-icon ul.preview 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;height:20px;margin:0;padding:0;visibility:hidden;width:0}#enabled-services h2{color:#999;font-size:20px;font-weight:400!important;padding-top:0}body.settings_page_sharing #live-preview h2{color:#e3e3e3;font-size:20px;font-weight:400!important}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{border-top:1px solid #e3e3e3;display:none;margin-left:-24px;margin-top:4px;padding:10px 14px 8px 10px}body.settings_page_sharing .utility{float:right;font-size:10px;padding-right:10px;padding-top:10px}body.settings_page_sharing .advanced input[type=submit]{float:left;margin-right:10px;margin-top:10px}.services li.dropzone{background:#e3e3e3;border:1px dashed #999;border-radius:3px;height:18px;margin-right:10px;padding:5px}.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;padding:10px;vertical-align:top;width:29%}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px}.preview li.preview-item{background-position:0 5px;cursor:default}.preview .option-smart-on{margin:3px 5px 0 0}.preview-digg .option-smart-on{background:url(../../modules/sharedaddy/images/smart-digg.png) no-repeat 0 0;background-size:76px 17px;height:17px;margin-top:2px;width:76px}.preview-facebook .option-smart-on{background:url(../../modules/sharedaddy/images/smart-like.png) no-repeat 0 0;background-size:85px 20px;height:20px;margin-left:-4px;width:85px}:is(.preview-twitter,.preview-x) .option-smart-on{background:url(.Line truncated
@@ -0,0 +1,111 @@
amp-social-share,
.amp-social-share {
color: #fff;
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: 400 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: #000;
}
amp-social-share[type="twitter"]::before {
content: "\f10e";
}
amp-social-share[type="pinterest"] {
background: #ca1f27;
}
amp-social-share[type="pinterest"]::before {
content: "\f210";
}
amp-social-share[type="telegram"] {
background: #08c;
}
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="reddit"] {
background: #cee3f8;
color: #555;
}
amp-social-share[type="reddit"]::before {
content: "\f222";
}
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: 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: 69 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: 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,234 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Google reCAPTCHA utilities, for use in the sharing feature.
*
* @package automattic/jetpack
*/
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
/**
* 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 .= 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;
}
}
@@ -0,0 +1,196 @@
<?php
/**
* Display a Mastodon modal, where folks can enter a Mastodon instance.
*
* @package automattic/jetpack
*/
/**
* Class Mastodon_Modal
*/
class Jetpack_Mastodon_Modal {
/**
* Mastodon SVG icon.
*
* @var string
*/
private static $svg = '<svg width="261" height="66" viewBox="0 0 261 66" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path d="M60.7539 14.4034C59.8143 7.41942 53.7273 1.91557 46.5117 0.849066C45.2943 0.668854 40.6819 0.0130005 29.9973 0.0130005H29.9175C19.2299 0.0130005 16.937 0.668854 15.7196 0.849066C8.70488 1.88602 2.29885 6.83152 0.744617 13.8982C-0.00294988 17.3784 -0.0827298 21.2367 0.0561464 24.7759C0.254119 29.8514 0.292531 34.918 0.753482 39.9728C1.07215 43.3305 1.62806 46.6614 2.41704 49.9406C3.89445 55.9969 9.87499 61.0369 15.7344 63.0931C22.0077 65.2374 28.7542 65.5934 35.2184 64.1212C35.9295 63.9558 36.6318 63.7638 37.3252 63.5451C38.8971 63.0459 40.738 62.4875 42.0913 61.5067C42.1099 61.4929 42.1251 61.4751 42.1358 61.4547C42.1466 61.4342 42.1526 61.4116 42.1534 61.3885V56.4903C42.153 56.4687 42.1479 56.4475 42.1383 56.4281C42.1287 56.4088 42.1149 56.3918 42.0979 56.3785C42.0809 56.3652 42.0611 56.3559 42.04 56.3512C42.019 56.3465 41.9971 56.3466 41.9761 56.3514C37.8345 57.3406 33.5905 57.8364 29.3324 57.8286C22.0045 57.8286 20.0336 54.3514 19.4693 52.9038C19.0156 51.6527 18.7275 50.3476 18.6124 49.0218C18.6112 48.9996 18.6153 48.9773 18.6243 48.9569C18.6333 48.9366 18.647 48.9186 18.6643 48.9045C18.6816 48.8904 18.7019 48.8805 18.7237 48.8758C18.7455 48.871 18.7681 48.8715 18.7897 48.8771C22.8622 49.8595 27.037 50.3553 31.2265 50.3542C32.234 50.3542 33.2387 50.3542 34.2463 50.3276C38.4598 50.2094 42.9009 49.9938 47.0465 49.1843C47.1499 49.1636 47.2534 49.1459 47.342 49.1193C53.881 47.8637 60.1038 43.9227 60.7362 33.9431C60.7598 33.5502 60.8189 29.8278 60.8189 29.4201C60.8218 28.0345 61.2651 19.5911 60.7539 14.4034Z" fill="url(#paint0_linear_89_11)"></path>
<path d="M12.3442 18.3034C12.3442 16.2668 13.9777 14.6194 15.997 14.6194C18.0163 14.6194 19.6497 16.2668 19.6497 18.3034C19.6497 20.34 18.0163 21.9874 15.997 21.9874C13.9777 21.9874 12.3442 20.34 12.3442 18.3034Z" fill="currentColor"></path>
<path d="M66.1484 21.4685V38.3839H59.4988V21.9744C59.4988 18.5109 58.0583 16.7597 55.1643 16.7597C51.9746 16.7597 50.3668 18.8482 50.3668 22.9603V31.9499H43.7687V22.9603C43.7687 18.8352 42.1738 16.7597 38.9712 16.7597C36.0901 16.7597 34.6367 18.5109 34.6367 21.9744V38.3839H28V21.4685C28 18.018 28.8746 15.268 30.6238 13.2314C32.4374 11.1948 34.8039 10.157 37.7365 10.157C41.132 10.157 43.7172 11.4802 45.415 14.1135L47.0742 16.9154L48.7334 14.1135C50.4311 11.4802 53.0035 10.157 56.4119 10.157C59.3444 10.157 61.711 11.1948 63.5246 13.2314C65.2738 15.268 66.1484 18.005 66.1484 21.4685ZM89.0297 29.8743C90.4059 28.4085 91.0619 26.5795 91.0619 24.3613C91.0619 22.1431 90.4059 20.3011 89.0297 18.9001C87.7049 17.4343 86.0329 16.7338 84.0007 16.7338C81.9685 16.7338 80.2965 17.4343 78.9717 18.9001C77.6469 20.3011 76.991 22.1431 76.991 24.3613C76.991 26.5795 77.6469 28.4215 78.9717 29.8743C80.2965 31.2753 81.9685 31.9888 84.0007 31.9888C86.0329 31.9888 87.7049 31.2883 89.0297 29.8743ZM91.0619 10.8316H97.6086V37.891H91.0619V34.6999C89.0811 37.3462 86.3416 38.6563 82.7788 38.6563C79.2161 38.6563 76.4765 37.3073 74.0456 34.5442C71.6533 31.7812 70.4443 28.3696 70.4443 24.3743C70.4443 20.3789 71.6661 17.0192 74.0456 14.2561C76.4893 11.4931 79.3833 10.0922 82.7788 10.0922C86.1744 10.0922 89.0811 11.3894 91.0619 14.0356V10.8445V10.8316ZM119.654 23.8683C121.583 25.3342 122.548 27.3837 122.496 29.9781C122.496 32.7411 121.532 34.9075 119.551 36.4122C117.57 37.878 115.178 38.6304 112.284 38.6304C107.049 38.6304 103.499 36.4641 101.621 32.1963L107.306 28.7847C108.065 31.1067 109.737 32.3001 112.284 32.3001C114.625 32.3001 115.782 31.5477 115.782 29.9781C115.782 28.8366 114.265 27.8118 111.165 27.0075C109.995 26.6833 109.03 26.359 108.271 26.0865C107.204 25.6585 106.29 25.1655 105.532 24.5688C103.654 23.103 102.689 21.1572 102.689 18.6666C102.689 16.0203 103.602 13.9059 105.429 12.3882C107.306 10.8186 109.596 10.0662 112.335 10.0662C116.709 10.0662 119.898 11.9601 121.982 15.7998L116.4 19.0428C115.59 17.2008 114.213 16.2798 112.335 16.2798C110.355 16.2798 109.39 17.0321 109.39 18.498C109.39 19.6395 110.908 20.6643 114.008 21.4685C116.4 22.0134 118.278 22.8176 119.641 23.8554L119.654 23.8683ZM140.477 17.538H134.741V28.7977C134.741 30.1468 135.255 30.964 136.22 31.3402C136.927 31.6126 138.355 31.6645 140.49 31.5607V37.891C136.079 38.4358 132.876 37.9948 130.998 36.5419C129.12 35.1409 128.207 32.5336 128.207 28.8106V17.538H123.795V10.8316H128.207V5.37038L134.754 3.25595V10.8316H140.49V17.538H140.477ZM161.352 29.7187C162.677 28.3177 163.333 26.5276 163.333 24.3613C163.333 22.195 162.677 20.4178 161.352 19.0039C160.027 17.6029 158.407 16.8894 156.426 16.8894C154.445 16.8894 152.825 17.5899 151.5 19.0039C150.227 20.4697 149.571 22.2469 149.571 24.3613C149.571 26.4757 150.227 28.2529 151.5 29.7187C152.825 31.1196 154.445 31.8331 156.426 31.8331C158.407 31.8331 160.027 31.1326 161.352 29.7187ZM146.883 34.5313C144.297 31.7682 143.024 28.4215 143.024 24.3613C143.024 20.3011 144.297 17.0062 146.883 14.2432C149.468 11.4802 152.67 10.0792 156.426 10.0792C160.182 10.0792 163.384 11.4802 165.97 14.2432C168.555 17.0062 169.88 20.4178 169.88 24.3613C169.88 28.3047 168.555 31.7682 165.97 34.5313C163.384 37.2943 160.233 38.6434 156.426 38.6434C152.619 38.6434 149.468 37.2943 146.883 34.5313ZM191.771 29.8743C193.095 28.4085 193.751 26.5795 193.751 24.3613C193.751 22.1431 193.095 20.3011 191.771 18.9001C190.446 17.4343 188.774 16.7338 186.742 16.7338C184.709 16.7338 183.037 17.4343 181.661 18.9001C180.336 20.3011 179.68 22.1431 179.68 24.3613C179.68 26.5795 180.336 28.4215 181.661 29.8743C183.037 31.2753 184.761 31.9888 186.742 31.9888C188.722 31.9888 190.446 31.2883 191.771 29.8743ZM193.751 0H200.298V37.891H193.751V34.6999C191.822 37.3462 189.082 38.6563 185.52 38.6563C181.957 38.6563 179.179 37.3073 176.735 34.5442C174.343 31.7812 173.134 28.3696 173.134 24.3743C173.134 20.3789 174.356 17.0192 176.735 14.2561C179.166 11.4931 182.111 10.0922 185.52 10.0922C188.928 10.0922 191.822 11.3894 193.751 14.0356V0.0129719V0ZM223.308 29.7057C224.633 28.3047 225.289 26.5146 225.289 24.3483C225.289 22.182 224.633 20.4048 223.308 18.9909C221.983 17.5899 220.363 16.8765 218.382 16.8765C216.401 16.8765 214.78 17.577 213.456 18.9909C212.182 20.4567 211.526 22.2339 211.526 24.3483C211.526 26.4627 212.182 28.2399 213.456 29.7057C214.78 31.1067 216.401 31.8201 218.382 31.8201C220.363 31.8201 221.983 31.1196 223.308 29.7057ZM208.838 34.5183C206.253 31.7553 204.98 28.4085 204.98 24.3483C204.98 20.2881 206.253 16.9932 208.838 14.2302C211.424 11.4672 214.626 10.0662 218.382 10.0662C222.137 10.0662 225.34 11.4672 227.925 14.2302C230.511 16.9932 231.835 20.4048 231.835 24.3483C231.835 28.2918 230.511 31.7553 227.925 34.5183C225.34 37.2813 222.189 38.6304 218.382 38.6304C214.575 38.6304 211.424 37.2813 208.838 34.5183ZM260.17 21.261V37.878H253.623V22.1301C253.623 20.34 253.173 18.9909 252.247 17.9661C251.385 17.0451 250.164 16.5651 248.594 16.5651C244.89 16.5651 243.012 18.7833 Line truncated
<defs>
<linearGradient id="paint0_linear_89_11" x1="30.5" y1="0.0130005" x2="30.5" y2="65.013" gradientUnits="userSpaceOnUse">
<stop stop-color="#6364FF"></stop>
<stop offset="1" stop-color="#563ACC"></stop>
</linearGradient>
</defs>
</svg>';
/**
* Decide whether the modal should be displayed.
* We want to show it when the user clicks on the Mastodon share button,
* thus loading a page with ?share=mastodon&nb=1.
*
* @return bool
*/
public static function should_display_modal() {
if (
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Only used to display the modal.
isset( $_GET['share'] )
&& 'mastodon' === sanitize_text_field( wp_unslash( $_GET['share'] ) )
&& isset( $_GET['nb'] )
&& 1 === (int) $_GET['nb']
// phpcs:enable
) {
return true;
}
return false;
}
/**
* Hook the modal render into WordPress.
*/
public static function modal() {
if ( ! self::should_display_modal() ) {
return;
}
// Render the modal.
self::render_modal();
die( 0 );
}
/**
* Render the modal.
*/
public static function render_modal() {
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex,follow" />
<meta name="referrer" content="no-referrer">
<?php rel_canonical(); ?>
<title><?php esc_html_e( 'Share to Mastodon', 'jetpack' ); ?></title>
<style type="text/css">
.sd-mastodon-modal {
background-color: #282c37;
color: #ffffff;
display: flex;
flex-direction: column;
font-family: sans-serif;
margin-top: 1em;
}
.sd-mastodon-modal__inner {
margin: 0 auto;
width: 450px;
}
.sd-mastodon-modal__title,
.sd-mastodon-modal__logo {
display: flex;
font-size: 0;
justify-content: center;
align-items: center;
}
.sd-mastodon-modal__logo {
margin-top: 50px;
}
.sd-mastodon-modal__logo svg {
height: 42px;
}
.sd-mastodon-modal__inner form {
margin: 2em 0;
max-width: 400px;
padding: 0 1em;
}
.sd-mastodon-modal__inner label {
font-size: 14px;
font-weight: 500;
}
.sd-mastodon-modal__inner input {
box-sizing: border-box;
font-size: 16px;
color: #fff;
display: block;
width: 100%;
outline: 0;
font-family: inherit;
resize: vertical;
background: #131419;
border: 1px solid #0a0b0e;
border-radius: 4px;
margin: 15px 10px 10px 0;
padding: 10px;
}
.sd-mastodon-modal__inner input:focus {
border-color: #8c8dff;
background: #17191f;
}
.sd-mastodon-modal__submit button {
display: block;
width: 100%;
border: 0;
border-radius: 4px;
background: #595aff;
color: #fff;
font-size: 18px;
line-height: inherit;
height: auto;
margin: 15px 10px 10px 0;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
text-align: center;
box-sizing: border-box;
cursor: pointer;
font-weight: 500;
outline: 0;
}
.sd-mastodon-modal__submit button:hover {
background-color: #6364ff;
}
</style>
</head>
<body class="sd-mastodon-modal">
<div class="sd-mastodon-modal__inner">
<h2 class="sd-mastodon-modal__title"><?php esc_html_e( 'Share to Mastodon', 'jetpack' ); ?></h2>
<div class="sd-mastodon-modal__logo">
<?php echo self::$svg; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- SVG is safe. ?>
</div>
<form method="post">
<label for="jetpack-mastodon-instance" class="sd-mastodon-modal__label">
<?php esc_html_e( 'Enter the full URL of the Mastodon instance where you’d like to share this post.', 'jetpack' ); ?>
</label>
<input
required
aria-required="true"
type="url"
id="jetpack-mastodon-instance"
name="jetpack-mastodon-instance"
placeholder="<?php echo esc_url( 'https://mastodon.social' ); ?>"
/>
<div class="sd-mastodon-modal__submit">
<?php wp_nonce_field( 'jetpack_share_mastodon_instance', '_wpnonce', true, true ); ?>
<button id="mastodon-submit"><?php esc_html_e( 'Share', 'jetpack' ); ?></button>
</div>
</form>
</div>
</body>
</html>
<?php
}
}
@@ -0,0 +1,234 @@
<?php
/**
* Jetpack's Sharing feature, nee Sharedaddy.
* The most super duper sharing tool on the interwebs.
*
* @package automattic/jetpack
*/
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
// 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 instanceof \WP_Post_Type
&& $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,761 @@
/**
* Sharedaddy Base Styles
*
* Contains styles for modules, containers, buttons
*/
/* Master container */
#jp-post-flair {
padding-top: 0.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: 700;
}
body.highlander-light h3.sd-title::before {
border-top: 1px solid rgba(0, 0, 0, 0.2);
}
body.highlander-dark h3.sd-title::before {
border-top: 1px solid rgba(255, 255, 255, 0.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;
margin: 0 8px 12px 0;
padding: 0;
}
.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 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 0 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;
}
body .sd-social-icon .sd-content ul li[class*="share-"] a.sd-button.share-icon.no-text span:not(.custom-sharing-span) {
display: none;
}
/* 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, 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: 400 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: 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;
}
}
/* 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,
.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-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: #08c;
}
.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;
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;
}
/* Individual official buttons */
.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-content ul li.share-custom a span[hidden] {
display: none;
}
body .sd-social-icon .sd-content ul li[class*="share-"] a.sd-button.share-icon.no-text .custom-sharing-span {
color: transparent;
}
body .sd-social-icon .sd-content li.share-custom a span {
width: 0;
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: 0 5px 20px rgba(0, 0, 0, 0.2);
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%;
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: 0.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;
}
.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: #000;
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: #555 !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: #08c;
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-reddit a.sd-button {
background: #cee3f8;
color: #555 !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;
}
#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,926 @@
<?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\Redirect;
use Automattic\Jetpack\Status;
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
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 Settings > Sharing.
*/
public function subscription_menu() {
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
$is_simple_site = defined( 'IS_WPCOM' ) && IS_WPCOM;
$show_block_message = $this->should_use_site_editor() && ! $is_simple_site;
// 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 wp_json_encode( admin_url( '/images/loading.gif' ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>;
<?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 wp_json_encode( sanitize_text_field( wp_unslash( $_GET['name'] ) ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?> );
jQuery( '#new_sharing_url' ).val( <?php echo wp_json_encode( sanitize_text_field( wp_unslash( $_GET['url'] ) ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?> );
jQuery( '#new_sharing_icon' ).val( <?php echo wp_json_encode( sanitize_text_field( wp_unslash( $_GET['icon'] ) ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?> );
jQuery( '#add-a-new-service' ).click();
});
<?php endif; ?>
</script>
<?php
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}
/**
* Check if we should encourage to use the site editor instead of the legacy sharing settings.
*
* @return boolean
*/
public function should_use_site_editor() {
$block_availability = Jetpack_Gutenberg::get_cached_availability();
$is_block_available = isset( $block_availability['sharing-buttons'] ) && $block_availability['sharing-buttons']['available'];
$is_block_theme = wp_is_block_theme();
return $is_block_available && $is_block_theme;
}
/**
* 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>
<?php
$is_simple_site = defined( 'IS_WPCOM' ) && IS_WPCOM;
if ( $this->should_use_site_editor() && $is_simple_site ) :
$this->site_editor_prompt_display();
?>
<div class="notice notice-info inline">
<p>
<?php esc_html_e( 'You are using a block-based theme. We recommend that you disable the legacy sharing features below and add a sharing button block to your theme’s template instead.', 'jetpack' ); ?>
</p>
</div>
<?php
endif;
?>
<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' ); ?>
<span class="spinner" style="vertical-align: middle"></span>
</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' ); ?>" />
<span class="spinner" style="vertical-align: middle"></span>
</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>
<?php $this->site_editor_prompt_display(); ?>
</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 Jetpack’s legacy sharing buttons</a> and add a sharing block to your theme’s 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
}
/**
* Display the "Go to the site editor" prompt.
*
* @return void
*/
public function site_editor_prompt_display() {
$host = new Status\Host();
$wpcom_link = 'https://wordpress.com/support/wordpress-editor/blocks/sharing-buttons-block/';
if ( function_exists( 'localized_wpcom_url' ) ) {
$wpcom_link = localized_wpcom_url( $wpcom_link );
}
$link = $host->is_wpcom_platform() ? $wpcom_link : Redirect::get_url( 'jetpack-support-sharing-block' );
?>
<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 data-target="wpcom-help-center" href="<?php echo esc_url( $link ); ?>" class="button" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'Learn how to add Sharing Buttons', 'jetpack' ); ?>
</a>
</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 ! 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' );