summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/sharedaddy')
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css453
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css1
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.css452
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.js532
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.min.css2
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.pngbin0 -> 1068 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/comments@2x.pngbin0 -> 763 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/contact-form@2x.pngbin0 -> 539 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/custom.pngbin0 -> 445 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/custom@2x.pngbin0 -> 1147 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/designfloat.pngbin0 -> 833 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/digg.pngbin0 -> 530 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/digg@2x.pngbin0 -> 872 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/divider.pngbin0 -> 94 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/divider@2x.pngbin0 -> 116 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/draggy.pngbin0 -> 107 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/draggy@2x.pngbin0 -> 109 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/email.pngbin0 -> 209 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/email@2x.pngbin0 -> 927 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/ember.pngbin0 -> 533 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.pngbin0 -> 757 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/facebook.pngbin0 -> 568 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/facebook@2x.pngbin0 -> 1036 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/feed.pngbin0 -> 761 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/icon-facebook-2x.pngbin0 -> 1027 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/icon-facebook.pngbin0 -> 581 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/icon-twitter-2x.pngbin0 -> 1414 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/icon-twitter.pngbin0 -> 523 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/icon-wordpress-2x.pngbin0 -> 592 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/icon-wordpress.pngbin0 -> 666 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/kindle.pngbin0 -> 750 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/kindle@2x.pngbin0 -> 1505 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.pngbin0 -> 2115 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.pngbin0 -> 2975 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.pngbin0 -> 1564 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.pngbin0 -> 1736 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-smart.pngbin0 -> 2115 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.pngbin0 -> 2975 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.pngbin0 -> 2274 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.pngbin0 -> 2653 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin.pngbin0 -> 360 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/linkedin@2x.pngbin0 -> 944 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/loading.gifbin0 -> 2530 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/more.pngbin0 -> 285 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/more@2x.pngbin0 -> 798 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/pinterest.pngbin0 -> 624 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/pinterest@2x.pngbin0 -> 1310 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/pocket.pngbin0 -> 367 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/pocket@2x.pngbin0 -> 504 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/print.pngbin0 -> 209 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/print@2x.pngbin0 -> 1052 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/reddit.pngbin0 -> 881 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/reddit@2x.pngbin0 -> 1500 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/rss.pngbin0 -> 870 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/rss@2x.pngbin0 -> 1775 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/share-bg.pngbin0 -> 82 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/sharing-hidden.pngbin0 -> 213 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.pngbin0 -> 106 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-digg.pngbin0 -> 793 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.pngbin0 -> 1147 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-facebook.pngbin0 -> 1427 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.pngbin0 -> 830 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-like.pngbin0 -> 1620 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-like@2x.pngbin0 -> 3800 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-pinterest.pngbin0 -> 1235 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.pngbin0 -> 2170 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-pocket.pngbin0 -> 641 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-pocket@2x.pngbin0 -> 1272 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-reddit.pngbin0 -> 1572 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.pngbin0 -> 2601 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-skype.pngbin0 -> 1688 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-skype@2x.pngbin0 -> 4019 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.pngbin0 -> 552 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.pngbin0 -> 2072 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-tumblr.pngbin0 -> 1531 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.pngbin0 -> 4179 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-twitter.pngbin0 -> 1952 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.pngbin0 -> 1691 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/tumblr.pngbin0 -> 742 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/tumblr@2x.pngbin0 -> 926 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/twitter.pngbin0 -> 523 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/twitter@2x.pngbin0 -> 1302 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/wordpress.pngbin0 -> 667 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/images/wordpress@2x.pngbin0 -> 1344 bytes
-rw-r--r--plugins/jetpack/modules/sharedaddy/recaptcha.php188
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharedaddy.php289
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-service.php955
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-sources.php1793
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.css755
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.js514
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.php638
91 files changed, 6572 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css
new file mode 100644
index 00000000..04d10acc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css
@@ -0,0 +1,453 @@
+/* Do not modify this file directly. It is concatenated from individual module CSS files. */
+/**
+ * Sharedaddy Admin Styles
+ */
+
+#services-config {
+ min-width: 700px;
+ width: 100%;
+ float: right;
+}
+
+#services-config h3 {
+ font-weight: normal;
+ font-size: 15px;
+ margin: 0;
+ padding: 8px 10px;
+ overflow: hidden;
+ white-space: nowrap;
+ color: #464646;
+}
+
+#available-services, #enabled-services, #live-preview {
+ padding: 0;
+ width: 100%;
+ padding-top: 20px;
+ border-spacing: 0;
+}
+
+#enabled-services .ui-sortable {
+ min-height: 50px;
+}
+
+#enabled-services {
+ padding-bottom: 20px;
+}
+
+#available-services, #enabled-services {
+ border-bottom: 2px solid #cccccc;
+}
+
+#live-preview {
+ border-bottom: 1px solid #dfdfdf;
+ padding-bottom: 60px;
+}
+
+#available-services h3, #enabled-services h3, #live-preview h3 {
+ padding: 0px;
+ margin-top: 0px;
+ margin-bottom: 1em;
+}
+
+body.settings_page_sharing .description {
+ width: 180px;
+ vertical-align: top;
+}
+
+body.settings_page_sharing .description p {
+ font-size: 13px;
+ font-style: italic;
+}
+
+body.settings_page_sharing .services {
+ padding: 0px 20px;
+ vertical-align: top;
+}
+
+body.settings_page_sharing .services ul li {
+ float: right;
+ cursor: move;
+}
+
+body.settings_page_sharing .services ul li.divider {
+ border: none;
+ padding: 0;
+ background: none;
+ cursor: default;
+}
+
+body.settings_page_sharing ul.services-hidden {
+ margin-bottom: 0;
+}
+
+/* Generic style */
+#available-services .service, #enabled-services .service {
+ margin-left: 10px;
+ padding: 5px 5px 5px 10px;
+ border-radius: 3px;
+ border: 1px solid #bbb;
+ background: #f8f8f8;
+ background-repeat: no-repeat;
+ background-position: center center;
+}
+
+#available-services .service:hover, #enabled-services .service:hover {
+ background: #fff;
+ border: 1px solid #bbb;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
+}
+
+#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 {
+ color: #555;
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 18px/1 'social-logos';
+ vertical-align: top;
+ position: relative;
+ top: 1px;
+ margin-left: 3px;
+ width: 16px;
+ height: 16px;
+ text-align: center;
+}
+li.service.share-print span:before {
+ content: '\f469';
+}
+li.service.share-digg span:before {
+ content: '\f221';
+}
+li.service.share-email span:before {
+ content: '\f410';
+}
+li.service.share-linkedin span:before {
+ content: '\f207';
+}
+li.service.share-twitter span:before {
+ content: '\f202';
+}
+li.service.share-reddit span:before {
+ content: '\f222';
+}
+li.service.share-tumblr span:before {
+ content: '\f214';
+}
+li.service.share-pocket span:before {
+ content: '\f224';
+}
+li.service.share-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-jetpack-whatsapp span:before {
+ content: '\f608';
+}
+li.service.share-skype span:before {
+ content: '\f220';
+}
+
+/**
+ * Preview section
+ */
+
+body.settings_page_sharing ul.preview {
+ float: right;
+ margin: 0px;
+}
+
+body.settings_page_sharing ul.preview li.preview-item, body.settings_page_sharing ul.preview li.preview-item a {
+ cursor: default;
+ text-decoration: none;
+}
+
+div.sd-social-icon ul.preview li.preview-item a span,
+div.sd-social-icon .inner li.preview-item a span {
+ display: none;
+}
+
+div.sd-social-icon ul.preview li.preview-item.preview-custom a span {
+ display: inline-block;
+
+}
+
+.services .preview li.share-custom a {
+ text-decoration: none;
+}
+
+.services ul li.end-fix {
+ clear:both;
+ float:none;
+ visibility:hidden;
+ padding:0;
+ margin:0;
+ height:20px;
+ width:0;
+}
+
+#enabled-services h2{
+ font-size:20px;
+ padding-top:0px;
+ font-weight: normal !important;
+ color: #999;
+}
+
+body.settings_page_sharing #live-preview h2 {
+ font-size:20px;
+ font-weight: normal !important;
+ color: #e3e3e3;
+}
+
+body.settings_page_sharing .clearing {
+ clear: both;
+}
+
+body.settings_page_sharing .options .options-left {
+ float: right;
+}
+
+body.settings_page_sharing .input label {
+ font-size: 11px;
+ line-height: 16px;
+}
+
+body.settings_page_sharing .advanced-form {
+ padding: 10px 10px 8px 14px;
+ margin-right: -24px;
+ display: none;
+ border-top: 1px #e3e3e3 solid;
+ margin-top:4px;
+}
+
+body.settings_page_sharing .utility {
+ float: left;
+ padding-top:10px;
+ padding-left: 10px;
+ font-size: 10px;
+}
+
+body.settings_page_sharing .advanced input[type=submit] {
+ float: right;
+ margin-top:10px;
+ margin-left: 10px;
+}
+
+.services li.dropzone {
+ border: 1px dashed #999;
+ border-radius: 3px;
+ background: #e3e3e3;
+ margin-left: 10px;
+ padding: 5px;
+ height: 18px;
+}
+
+.advanced-form .form-table th {
+ width: auto !important;
+}
+
+.advanced-form .button-secondary {
+ margin-top: 0 !important;
+}
+
+#hidden-drop-target {
+ background: #e1e1e1;
+ border: 1px solid #cdcdcd;
+ width: 29%;
+ padding: 10px;
+ vertical-align: top;
+}
+
+#hidden-drop-target p {
+ font-size: 13px;
+ font-style: italic;
+ margin: 0 0 10px 0;
+}
+
+
+/* Official button previews */
+.preview li.preview-item {
+ background-position: 0px 5px;
+ cursor: default;
+}
+
+.preview .option-smart-on {
+ margin: 3px 0 0 5px;
+}
+
+.preview-digg .option-smart-on {
+ background: url(images/smart-digg.png) no-repeat top left;
+ background-size: 76px 17px;
+ width:76px;
+ height:17px;
+ margin-top: 2px;
+}
+
+.preview-reddit .option-smart-on {
+ background: url(images/smart-reddit.png) no-repeat top left;
+ background-size: 104px 21px;
+ width:104px;
+ height:21px;
+}
+
+.preview-facebook .option-smart-on {
+ background: url(images/smart-like.png) no-repeat top left;
+ background-size: 85px 20px;
+ width:85px;
+ height:20px;
+}
+
+.preview-twitter .option-smart-on {
+ background: url(images/smart-twitter.png?1) no-repeat top left;
+ background-size: 60px 20px;
+ width:60px;
+ height:20px;
+}
+
+.preview-linkedin .option-smart-on {
+ background: url(images/linkedin-smart.png) no-repeat top center;
+ background-size: 99px 18px;
+ width:99px;
+ height:20px;
+}
+
+.preview-tumblr .option-smart-on {
+ background: url(images/smart-tumblr.png) no-repeat top left;
+ background-size: 62px 20px;
+ width: 62px;
+ height: 20px;
+}
+
+.preview-pinterest .option-smart-on {
+ background: url(images/smart-pinterest.png) no-repeat top left;
+ background-size: 39px 20px;
+ width: 39px;
+ height: 20px;
+}
+
+.preview-pocket .option-smart-on {
+ background: url(images/smart-pocket.png) no-repeat top left;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
+}
+
+.preview-skype .option-smart-on {
+ background: url(images/smart-skype.png) no-repeat top left;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
+}
+
+.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-reddit .option-smart-on {
+ background-image: url(images/smart-reddit@2x.png);
+ }
+
+ .preview-facebook .option-smart-on {
+ background-image: url(images/smart-like@2x.png);
+ }
+
+ .preview-twitter .option-smart-on {
+ background-image: url(images/smart-twitter@2x.png?1);
+ }
+
+ .preview-linkedin .option-smart-on {
+ background-image: url(images/linkedin-smart@2x.png);
+ }
+
+ .preview-tumblr .option-smart-on {
+ background-image: url(images/smart-tumblr@2x.png);
+ }
+
+ .preview-pinterest .option-smart-on {
+ background-image: url(images/smart-pinterest@2x.png);
+ }
+
+ .preview-pocket .option-smart-on {
+ background-image: url(images/smart-pocket@2x.png);
+ }
+
+ .preview-skype .option-smart-on {
+ background-image: url(images/smart-skype@2x.png);
+ }
+}
+
+/**
+ * Overflow sharing dialog
+ */
+
+.services .sharing-hidden li {
+ background-color: transparent;
+}
+
+.sharing-hidden li.share-end {
+ clear: both;
+ height: 0;
+ padding: 0px !important;
+ margin: 0px !important;
+ width: 0;
+ visibility: hidden;
+ float: none;
+}
+
+.preview .sharing-label {
+ font-weight: bold;
+ border: 0;
+ padding: 4px 0 0 6px;
+}
+
+#services-config a.remove {
+ background: #ddd;
+ color: #fff;
+ padding: 0px 4px 2px;
+ border-radius: 15px;
+ -moz-border-radius: 15px;
+ -webkit-border-radius: 15px;
+ text-decoration: none;
+ font-weight: bold;
+ font-size: 10px;
+}
+
+#services-config a.remove:hover {
+ background: #f00;
+}
+
+.sd-social-icon .inner a.sd-button span,
+.sd-social-icon .inner a.share-icon span {
+ display: inline-block;
+ overflow: hidden;
+ width: 0;
+ text-indent: 100%;
+}
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css
new file mode 100644
index 00000000..db5c3771
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css
@@ -0,0 +1 @@
+#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 #dfdfdf;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{float:right;cursor:move}body.settings_page_sharing .services ul li.divider{border:none;padding:0;background:0 0;cursor:default}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{margin-left:10px;padding:5px 5px 5px 10px;border-radius:3px;border:1px solid #bbb;background:#f8f8f8;background-repeat:no-repeat;background-position:center center}#available-services .service:hover,#enabled-services .service:hover{background:#fff;border:1px solid #bbb;box-shadow:0 1px 3px rgba(0,0,0,.2)}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{color:#555;display:inline-block;-webkit-font-smoothing:antialiased;font:normal 18px/1 social-logos;vertical-align:top;position:relative;top:1px;margin-left:3px;width:16px;height:16px;text-align:center}li.service.share-print span:before{content:'\f469'}li.service.share-digg span:before{content:'\f221'}li.service.share-email span:before{content:'\f410'}li.service.share-linkedin span:before{content:'\f207'}li.service.share-twitter span:before{content:'\f202'}li.service.share-reddit span:before{content:'\f222'}li.service.share-tumblr span:before{content:'\f214'}li.service.share-pocket span:before{content:'\f224'}li.service.share-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-jetpack-whatsapp span:before{content:'\f608'}li.service.share-skype span:before{content:'\f220'}body.settings_page_sharing ul.preview{float:right;margin:0}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;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}.preview li.preview-item{background-position:0 5px;cursor:default}.preview .option-smart-on{margin:3px 0 0 5px}.preview-digg .option-smart-on{background:url(images/smart-digg.png) no-repeat top left;background-size:76px 17px;width:76px;height:17px;margin-top:2px}.preview-reddit .option-smart-on{background:url(images/smart-reddit.png) no-repeat top left;background-size:104px 21px;width:104px;height:21px}.preview-facebook .option-smart-on{background:url(images/smart-like.png) no-repeat top left;background-size:85px 20px;width:85px;height:20px}.preview-twitter .option-smart-on{background:url(images/smart-twitter.png?1) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-linkedin .option-smart-on{background:url(images/linkedin-smart.png) no-repeat top center;background-size:99px 18px;width:99px;height:20px}.preview-tumblr .option-smart-on{background:url(images/smart-tumblr.png) no-repeat top left;background-size:62px 20px;width:62px;height:20px}.preview-pinterest .option-smart-on{background:url(images/smart-pinterest.png) no-repeat top left;background-size:39px 20px;width:39px;height:20px}.preview-pocket .option-smart-on{background:url(images/smart-pocket.png) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-skype .option-smart-on{background:url(images/smart-skype.png) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-item.share-deprecated{opacity:.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-reddit .option-smart-on{background-image:url(images/smart-reddit@2x.png)}.preview-facebook .option-smart-on{background-image:url(images/smart-like@2x.png)}.preview-twitter .option-smart-on{background-image:url(images/smart-twitter@2x.png?1)}.preview-linkedin .option-smart-on{background-image:url(images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(images/smart-pocket@2x.png)}.preview-skype .option-smart-on{background-image:url(images/smart-skype@2x.png)}}.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:#ddd;color:#fff;padding:0 4px 2px;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;text-decoration:none;font-weight:700;font-size:10px}#services-config a.remove:hover{background:red}.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%} \ No newline at end of file
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.css b/plugins/jetpack/modules/sharedaddy/admin-sharing.css
new file mode 100644
index 00000000..f7093186
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.css
@@ -0,0 +1,452 @@
+/**
+ * Sharedaddy Admin Styles
+ */
+
+#services-config {
+ min-width: 700px;
+ width: 100%;
+ float: left;
+}
+
+#services-config h3 {
+ font-weight: normal;
+ font-size: 15px;
+ margin: 0;
+ padding: 8px 10px;
+ overflow: hidden;
+ white-space: nowrap;
+ color: #464646;
+}
+
+#available-services, #enabled-services, #live-preview {
+ padding: 0;
+ width: 100%;
+ padding-top: 20px;
+ border-spacing: 0;
+}
+
+#enabled-services .ui-sortable {
+ min-height: 50px;
+}
+
+#enabled-services {
+ padding-bottom: 20px;
+}
+
+#available-services, #enabled-services {
+ border-bottom: 2px solid #cccccc;
+}
+
+#live-preview {
+ border-bottom: 1px solid #dfdfdf;
+ padding-bottom: 60px;
+}
+
+#available-services h3, #enabled-services h3, #live-preview h3 {
+ padding: 0px;
+ margin-top: 0px;
+ margin-bottom: 1em;
+}
+
+body.settings_page_sharing .description {
+ width: 180px;
+ vertical-align: top;
+}
+
+body.settings_page_sharing .description p {
+ font-size: 13px;
+ font-style: italic;
+}
+
+body.settings_page_sharing .services {
+ padding: 0px 20px;
+ vertical-align: top;
+}
+
+body.settings_page_sharing .services ul li {
+ float: left;
+ cursor: move;
+}
+
+body.settings_page_sharing .services ul li.divider {
+ border: none;
+ padding: 0;
+ background: none;
+ cursor: default;
+}
+
+body.settings_page_sharing ul.services-hidden {
+ margin-bottom: 0;
+}
+
+/* Generic style */
+#available-services .service, #enabled-services .service {
+ margin-right: 10px;
+ padding: 5px 10px 5px 5px;
+ border-radius: 3px;
+ border: 1px solid #bbb;
+ background: #f8f8f8;
+ background-repeat: no-repeat;
+ background-position: center center;
+}
+
+#available-services .service:hover, #enabled-services .service:hover {
+ background: #fff;
+ border: 1px solid #bbb;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
+}
+
+#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 {
+ color: #555;
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 18px/1 'social-logos';
+ vertical-align: top;
+ position: relative;
+ top: 1px;
+ margin-right: 3px;
+ width: 16px;
+ height: 16px;
+ text-align: center;
+}
+li.service.share-print span:before {
+ content: '\f469';
+}
+li.service.share-digg span:before {
+ content: '\f221';
+}
+li.service.share-email span:before {
+ content: '\f410';
+}
+li.service.share-linkedin span:before {
+ content: '\f207';
+}
+li.service.share-twitter span:before {
+ content: '\f202';
+}
+li.service.share-reddit span:before {
+ content: '\f222';
+}
+li.service.share-tumblr span:before {
+ content: '\f214';
+}
+li.service.share-pocket span:before {
+ content: '\f224';
+}
+li.service.share-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-jetpack-whatsapp span:before {
+ content: '\f608';
+}
+li.service.share-skype span:before {
+ content: '\f220';
+}
+
+/**
+ * Preview section
+ */
+
+body.settings_page_sharing ul.preview {
+ float: left;
+ margin: 0px;
+}
+
+body.settings_page_sharing ul.preview li.preview-item, body.settings_page_sharing ul.preview li.preview-item a {
+ cursor: default;
+ text-decoration: none;
+}
+
+div.sd-social-icon ul.preview li.preview-item a span,
+div.sd-social-icon .inner li.preview-item a span {
+ display: none;
+}
+
+div.sd-social-icon ul.preview li.preview-item.preview-custom a span {
+ display: inline-block;
+
+}
+
+.services .preview li.share-custom a {
+ text-decoration: none;
+}
+
+.services ul li.end-fix {
+ clear:both;
+ float:none;
+ visibility:hidden;
+ padding:0;
+ margin:0;
+ height:20px;
+ width:0;
+}
+
+#enabled-services h2{
+ font-size:20px;
+ padding-top:0px;
+ font-weight: normal !important;
+ color: #999;
+}
+
+body.settings_page_sharing #live-preview h2 {
+ font-size:20px;
+ font-weight: normal !important;
+ color: #e3e3e3;
+}
+
+body.settings_page_sharing .clearing {
+ clear: both;
+}
+
+body.settings_page_sharing .options .options-left {
+ float: left;
+}
+
+body.settings_page_sharing .input label {
+ font-size: 11px;
+ line-height: 16px;
+}
+
+body.settings_page_sharing .advanced-form {
+ padding: 10px 14px 8px 10px;
+ margin-left: -24px;
+ display: none;
+ border-top: 1px #e3e3e3 solid;
+ margin-top:4px;
+}
+
+body.settings_page_sharing .utility {
+ float: right;
+ padding-top:10px;
+ padding-right: 10px;
+ font-size: 10px;
+}
+
+body.settings_page_sharing .advanced input[type=submit] {
+ float: left;
+ margin-top:10px;
+ margin-right: 10px;
+}
+
+.services li.dropzone {
+ border: 1px dashed #999;
+ border-radius: 3px;
+ background: #e3e3e3;
+ margin-right: 10px;
+ padding: 5px;
+ height: 18px;
+}
+
+.advanced-form .form-table th {
+ width: auto !important;
+}
+
+.advanced-form .button-secondary {
+ margin-top: 0 !important;
+}
+
+#hidden-drop-target {
+ background: #e1e1e1;
+ border: 1px solid #cdcdcd;
+ width: 29%;
+ padding: 10px;
+ vertical-align: top;
+}
+
+#hidden-drop-target p {
+ font-size: 13px;
+ font-style: italic;
+ margin: 0 0 10px 0;
+}
+
+
+/* Official button previews */
+.preview li.preview-item {
+ background-position: 0px 5px;
+ cursor: default;
+}
+
+.preview .option-smart-on {
+ margin: 3px 5px 0 0;
+}
+
+.preview-digg .option-smart-on {
+ background: url(images/smart-digg.png) no-repeat top left;
+ background-size: 76px 17px;
+ width:76px;
+ height:17px;
+ margin-top: 2px;
+}
+
+.preview-reddit .option-smart-on {
+ background: url(images/smart-reddit.png) no-repeat top left;
+ background-size: 104px 21px;
+ width:104px;
+ height:21px;
+}
+
+.preview-facebook .option-smart-on {
+ background: url(images/smart-like.png) no-repeat top left;
+ background-size: 85px 20px;
+ width:85px;
+ height:20px;
+}
+
+.preview-twitter .option-smart-on {
+ background: url(images/smart-twitter.png?1) no-repeat top left;
+ background-size: 60px 20px;
+ width:60px;
+ height:20px;
+}
+
+.preview-linkedin .option-smart-on {
+ background: url(images/linkedin-smart.png) no-repeat top center;
+ background-size: 99px 18px;
+ width:99px;
+ height:20px;
+}
+
+.preview-tumblr .option-smart-on {
+ background: url(images/smart-tumblr.png) no-repeat top left;
+ background-size: 62px 20px;
+ width: 62px;
+ height: 20px;
+}
+
+.preview-pinterest .option-smart-on {
+ background: url(images/smart-pinterest.png) no-repeat top left;
+ background-size: 39px 20px;
+ width: 39px;
+ height: 20px;
+}
+
+.preview-pocket .option-smart-on {
+ background: url(images/smart-pocket.png) no-repeat top left;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
+}
+
+.preview-skype .option-smart-on {
+ background: url(images/smart-skype.png) no-repeat top left;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
+}
+
+.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-reddit .option-smart-on {
+ background-image: url(images/smart-reddit@2x.png);
+ }
+
+ .preview-facebook .option-smart-on {
+ background-image: url(images/smart-like@2x.png);
+ }
+
+ .preview-twitter .option-smart-on {
+ background-image: url(images/smart-twitter@2x.png?1);
+ }
+
+ .preview-linkedin .option-smart-on {
+ background-image: url(images/linkedin-smart@2x.png);
+ }
+
+ .preview-tumblr .option-smart-on {
+ background-image: url(images/smart-tumblr@2x.png);
+ }
+
+ .preview-pinterest .option-smart-on {
+ background-image: url(images/smart-pinterest@2x.png);
+ }
+
+ .preview-pocket .option-smart-on {
+ background-image: url(images/smart-pocket@2x.png);
+ }
+
+ .preview-skype .option-smart-on {
+ background-image: url(images/smart-skype@2x.png);
+ }
+}
+
+/**
+ * Overflow sharing dialog
+ */
+
+.services .sharing-hidden li {
+ background-color: transparent;
+}
+
+.sharing-hidden li.share-end {
+ clear: both;
+ height: 0;
+ padding: 0px !important;
+ margin: 0px !important;
+ width: 0;
+ visibility: hidden;
+ float: none;
+}
+
+.preview .sharing-label {
+ font-weight: bold;
+ border: 0;
+ padding: 4px 6px 0 0;
+}
+
+#services-config a.remove {
+ background: #ddd;
+ color: #fff;
+ padding: 0px 4px 2px;
+ border-radius: 15px;
+ -moz-border-radius: 15px;
+ -webkit-border-radius: 15px;
+ text-decoration: none;
+ font-weight: bold;
+ font-size: 10px;
+}
+
+#services-config a.remove:hover {
+ background: #f00;
+}
+
+.sd-social-icon .inner a.sd-button span,
+.sd-social-icon .inner a.share-icon span {
+ display: inline-block;
+ overflow: hidden;
+ width: 0;
+ text-indent: 100%;
+}
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.js b/plugins/jetpack/modules/sharedaddy/admin-sharing.js
new file mode 100644
index 00000000..741931d1
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.js
@@ -0,0 +1,532 @@
+/* jshint onevar: false, smarttabs: true */
+/* global sharing_loading_icon */
+
+( function( $ ) {
+ $( document ).ready( function() {
+ function enable_share_button() {
+ $( '.preview a.sharing-anchor' )
+ .unbind( 'mouseenter mouseenter' )
+ .hover(
+ function() {
+ if ( $( this ).data( 'hasappeared' ) !== true ) {
+ var item = $( '.sharing-hidden .inner' );
+ var original = $( this ).parents( 'li' );
+
+ // Create a timer to make the area appear if the mouse hovers for a period
+ var timer = setTimeout( function() {
+ $( item )
+ .css( {
+ left: $( original ).position().left + 'px',
+ top: $( original ).position().top + $( original ).height() + 3 + 'px',
+ } )
+ .slideDown( 200, function() {
+ // Mark the item as have being appeared by the hover
+ $( original )
+ .data( 'hasappeared', true )
+ .data( 'hasoriginal', true )
+ .data( 'hasitem', false );
+
+ // Remove all special handlers
+ $( item )
+ .mouseleave( handler_item_leave )
+ .mouseenter( handler_item_enter );
+ $( original )
+ .mouseleave( handler_original_leave )
+ .mouseenter( handler_original_enter );
+
+ // Add a special handler to quickly close the item
+ $( original ).click( close_it );
+ } );
+
+ // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area
+ var handler_item_leave = function() {
+ $( original ).data( 'hasitem', false );
+
+ if ( $( original ).data( 'hasoriginal' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $( original ).data( 'timer2', timer );
+ }
+ };
+
+ var handler_item_enter = function() {
+ $( original ).data( 'hasitem', true );
+ clearTimeout( $( original ).data( 'timer2' ) );
+ };
+
+ var handler_original_leave = function() {
+ $( original ).data( 'hasoriginal', false );
+
+ if ( $( original ).data( 'hasitem' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $( original ).data( 'timer2', timer );
+ }
+ };
+
+ var handler_original_enter = function() {
+ $( original ).data( 'hasoriginal', true );
+ clearTimeout( $( original ).data( 'timer2' ) );
+ };
+
+ var close_it = function() {
+ item.slideUp( 200 );
+
+ // Clear all hooks
+ $( original )
+ .unbind( 'mouseleave', handler_original_leave )
+ .unbind( 'mouseenter', handler_original_enter );
+ $( item )
+ .unbind( 'mouseleave', handler_item_leave )
+ .unbind( 'mouseenter', handler_item_leave );
+ $( original ).data( 'hasappeared', false );
+ $( original ).unbind( 'click', close_it );
+ return false;
+ };
+ }, 200 );
+
+ // Remember the timer so we can detect it on the mouseout
+ $( this ).data( 'timer', timer );
+ }
+ },
+ function() {
+ // Mouse out - remove any timer
+ clearTimeout( $( this ).data( 'timer' ) );
+ $( this ).data( 'timer', false );
+ }
+ );
+ }
+
+ function update_preview() {
+ var button_style = $( '#button_style' ).val();
+
+ // Clear the live preview
+ $( '#live-preview ul.preview li' ).remove();
+
+ // Add label
+ if (
+ $( '#save-enabled-shares input[name=visible]' ).val() ||
+ $( '#save-enabled-shares input[name=hidden]' ).val()
+ ) {
+ $( '#live-preview ul.preview' ).append(
+ $( '#live-preview ul.archive .sharing-label' ).clone()
+ );
+ }
+
+ // Re-insert all the enabled items
+ $( 'ul.services-enabled li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ var service = $( this ).attr( 'id' );
+ $( '#live-preview ul.preview' ).append(
+ $( '#live-preview ul.archive li.preview-' + service ).clone()
+ );
+ }
+ } );
+
+ // Add any hidden items
+ if ( $( '#save-enabled-shares input[name=hidden]' ).val() ) {
+ // Add share button
+ $( '#live-preview ul.preview' ).append(
+ $( '#live-preview ul.archive .share-more' )
+ .parent()
+ .clone()
+ );
+
+ $( '.sharing-hidden ul li' ).remove();
+
+ // Add hidden items into the inner panel
+ $( 'ul.services-hidden li' ).each( function(/*pos, item*/) {
+ if ( $( this ).hasClass( 'service' ) ) {
+ var service = $( this ).attr( 'id' );
+ $( '.sharing-hidden .inner ul' ).append(
+ $( '#live-preview ul.archive .preview-' + service ).clone()
+ );
+ }
+ } );
+
+ enable_share_button();
+ }
+
+ $( '#live-preview div.sharedaddy' ).removeClass( 'sd-social-icon' );
+ $( '#live-preview li.advanced' ).removeClass( 'no-icon' );
+
+ // Button style
+ if ( 'icon' === button_style ) {
+ $( '#live-preview ul.preview div span, .sharing-hidden .inner ul div span' )
+ .html( ' ' )
+ .parent()
+ .addClass( 'no-text' );
+ $( '#live-preview div.sharedaddy' ).addClass( 'sd-social-icon' );
+ } else if ( 'official' === button_style ) {
+ $( '#live-preview ul.preview .advanced, .sharing-hidden .inner ul .advanced' ).each(
+ function(/*i*/) {
+ if (
+ ! $( this ).hasClass( 'preview-press-this' ) &&
+ ! $( this ).hasClass( 'preview-email' ) &&
+ ! $( this ).hasClass( 'preview-print' ) &&
+ ! $( this ).hasClass( 'preview-telegram' ) &&
+ ! $( this ).hasClass( 'preview-jetpack-whatsapp' ) &&
+ ! $( this ).hasClass( 'share-custom' ) &&
+ ! $( this ).hasClass( 'share-deprecated' )
+ ) {
+ $( this )
+ .find( '.option a span' )
+ .html( '' )
+ .parent()
+ .removeClass( 'sd-button' )
+ .parent()
+ .attr( 'class', 'option option-smart-on' );
+ }
+ }
+ );
+ } else if ( 'text' === button_style ) {
+ $( '#live-preview li.advanced' ).addClass( 'no-icon' );
+ }
+ }
+
+ window.sharing_option_changed = function() {
+ var item = this;
+
+ // Loading icon
+ $( this )
+ .parents( 'li:first' )
+ .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
+
+ // Save
+ $( this )
+ .parents( 'form' )
+ .ajaxSubmit( function( response ) {
+ if ( response.indexOf( '<!---' ) >= 0 ) {
+ var button = response.substring( 0, response.indexOf( '<!--->' ) );
+ var preview = response.substring( response.indexOf( '<!--->' ) + 6 );
+
+ if ( $( item ).is( ':submit' ) === true ) {
+ // Update the DOM using a bit of cut/paste technology
+
+ $( item )
+ .parents( 'li:first' )
+ .replaceWith( button );
+ }
+
+ $(
+ '#live-preview ul.archive li.preview-' +
+ $( item )
+ .parents( 'form' )
+ .find( 'input[name=service]' )
+ .val()
+ ).replaceWith( preview );
+ }
+
+ // Update preview
+ update_preview();
+
+ // Restore the icon
+ $( item )
+ .parents( 'li:first' )
+ .removeAttr( 'style' );
+ } );
+
+ if ( $( item ).is( ':submit' ) === true ) {
+ return false;
+ }
+ return true;
+ };
+
+ function showExtraOptions( service ) {
+ jQuery( '.' + service + '-extra-options' )
+ .css( { backgroundColor: '#ffffcc' } )
+ .fadeIn();
+ }
+
+ function hideExtraOptions( service ) {
+ jQuery( '.' + service + '-extra-options' ).fadeOut( 'slow' );
+ }
+
+ function save_services() {
+ $( '#enabled-services h3 img' ).show();
+
+ // Toggle various dividers/help texts
+ if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) {
+ $( '#drag-instructions' ).hide();
+ } else {
+ $( '#drag-instructions' ).show();
+ }
+
+ if ( $( '#enabled-services li.service' ).length > 0 ) {
+ $( '#live-preview .services h2' ).hide();
+ } else {
+ $( '#live-preview .services h2' ).show();
+ }
+
+ // Gather the modules
+ var visible = [],
+ hidden = [];
+
+ $( 'ul.services-enabled li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ // Ready for saving
+ visible[ visible.length ] = $( this ).attr( 'id' );
+ showExtraOptions( $( this ).attr( 'id' ) );
+ }
+ } );
+
+ $( 'ul.services-available li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ hideExtraOptions( $( this ).attr( 'id' ) );
+ }
+ } );
+
+ $( 'ul.services-hidden li' ).each( function() {
+ if ( $( this ).hasClass( 'service' ) ) {
+ // Ready for saving
+ hidden[ hidden.length ] = $( this ).attr( 'id' );
+ showExtraOptions( $( this ).attr( 'id' ) );
+ }
+ } );
+
+ // Set the hidden element values
+ $( '#save-enabled-shares input[name=visible]' ).val( visible.join( ',' ) );
+ $( '#save-enabled-shares input[name=hidden]' ).val( hidden.join( ',' ) );
+
+ update_preview();
+
+ // Save it
+ $( '#save-enabled-shares' ).ajaxSubmit( function() {
+ $( '#enabled-services h3 img' ).hide();
+ } );
+ }
+
+ $( '#enabled-services .services ul' ).sortable( {
+ receive: function(/*event, ui*/) {
+ save_services();
+ },
+ stop: function() {
+ save_services();
+ $( 'li.service' ).enableSelection(); // Fixes a problem with Chrome
+ },
+ over: function(/*event, ui*/) {
+ $( this )
+ .find( 'ul' )
+ .addClass( 'dropping' );
+
+ // Ensure the 'end-fix' is at the end
+ $( '#enabled-services li.end-fix' ).remove();
+ $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
+ },
+ out: function(/*event, ui*/) {
+ $( this )
+ .find( 'ul' )
+ .removeClass( 'dropping' );
+
+ // Ensure the 'end-fix' is at the end
+ $( '#enabled-services li.end-fix' ).remove();
+ $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
+ },
+ helper: function( event, ui ) {
+ ui.find( '.advanced-form' ).hide();
+
+ return ui.clone();
+ },
+ start: function(/*event, ui*/) {
+ // Make sure that the advanced section is closed
+ $( '.advanced-form' ).hide();
+ $( 'li.service' ).disableSelection(); // Fixes a problem with Chrome
+ },
+ placeholder: 'dropzone',
+ opacity: 0.8,
+ delay: 150,
+ forcePlaceholderSize: true,
+ items: 'li',
+ connectWith: '#available-services ul, #enabled-services .services ul',
+ cancel: '.advanced-form',
+ } );
+
+ $( '#available-services ul' ).sortable( {
+ opacity: 0.8,
+ delay: 150,
+ cursor: 'move',
+ connectWith: '#enabled-services .services ul',
+ placeholder: 'dropzone',
+ forcePlaceholderSize: true,
+ start: function() {
+ $( '.advanced-form' ).hide();
+ },
+ } );
+
+ // Accessibility keyboard shortcurts
+ $( '.service' ).on( 'keydown', function( e ) {
+ // Reposition if one of the directional keys is pressed
+ switch ( e.keyCode ) {
+ case 13:
+ keyboardDragDrop( $( this ) );
+ break; // Enter
+ case 32:
+ keyboardDragDrop( $( this ) );
+ break; // Space
+ case 37:
+ keyboardChangeOrder( $( this ), 'left' );
+ break; // Left
+ case 39:
+ keyboardChangeOrder( $( this ), 'right' );
+ break; // Right
+ default:
+ return true; // Exit and bubble
+ }
+
+ e.preventDefault();
+ } );
+
+ function keyboardChangeOrder( $this, dir ) {
+ var thisParent = $this.parent(),
+ thisParentsChildren = thisParent.find( 'li' ),
+ thisPosition = thisParentsChildren.index( $this ) + 1,
+ totalChildren = thisParentsChildren.length - 1,
+ thisService;
+
+ // No need to be able to sort order for the "Available Services" section
+ if ( thisParent.hasClass( 'services-available' ) ) {
+ return;
+ }
+
+ if ( 'left' === dir ) {
+ if ( 1 === thisPosition ) {
+ return;
+ }
+
+ // Find service to left
+ var prevSibling = $this.prev();
+
+ // Detach this service from DOM
+ thisService = $this.detach();
+
+ // Move it to the appropriate area and add focus back to service
+ prevSibling.before( thisService );
+
+ // Add focus
+ prevSibling.prev().focus();
+ }
+
+ if ( 'right' === dir ) {
+ if ( thisPosition === totalChildren ) {
+ return;
+ }
+
+ // Find service to left
+ var nextSibling = $this.next();
+
+ // Detach this service from DOM
+ thisService = $this.detach();
+
+ // Move it to the appropriate area and add focus back to service
+ nextSibling.after( thisService );
+
+ // Add focus
+ nextSibling.next().focus();
+ }
+
+ //Save changes
+ save_services();
+ }
+
+ function keyboardDragDrop( $this ) {
+ var dropzone,
+ thisParent = $this.parent();
+
+ // Rotate through 3 available dropzones
+ if ( thisParent.hasClass( 'services-available' ) ) {
+ dropzone = 'services-enabled';
+ } else if ( thisParent.hasClass( 'services-enabled' ) ) {
+ dropzone = 'services-hidden';
+ } else {
+ dropzone = 'services-available';
+ }
+
+ // Detach this service from DOM
+ var thisService = $this.detach();
+
+ // Move it to the appropriate area and add focus back to service
+ $( '.' + dropzone )
+ .prepend( thisService )
+ .find( 'li:first-child' )
+ .focus();
+
+ //Save changes
+ save_services();
+ }
+
+ // Live preview 'hidden' button
+ $( '.preview-hidden a' ).click( function() {
+ $( this )
+ .parent()
+ .find( '.preview' )
+ .toggle();
+ return false;
+ } );
+
+ // Add service
+ $( '#new-service form' ).ajaxForm( {
+ beforeSubmit: function() {
+ $( '#new-service-form .error' ).hide();
+ $( '#new-service-form img' ).show();
+ $( '#new-service-form input[type=submit]' ).prop( 'disabled', true );
+ },
+ success: function( response ) {
+ $( '#new-service-form img' ).hide();
+
+ if ( '' + response === '1' ) {
+ $( '#new-service-form .inerror' )
+ .removeClass( 'inerror' )
+ .addClass( 'error' );
+ $( '#new-service-form .error' ).show();
+ $( '#new-service-form input[type=submit]' ).prop( 'disabled', false );
+ } else {
+ document.location.reload();
+ }
+ },
+ } );
+
+ function init_handlers() {
+ $( '#services-config a.remove' )
+ .unbind( 'click' )
+ .click( function() {
+ var form = $( this )
+ .parent()
+ .next();
+
+ // Loading icon
+ $( this )
+ .parents( 'li:first' )
+ .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
+
+ // Save
+ form.ajaxSubmit( function(/*response*/) {
+ // Remove the item
+ form.parents( 'li:first' ).fadeOut( function() {
+ $( this ).remove();
+
+ // Update preview
+ update_preview();
+ } );
+ } );
+
+ return false;
+ } );
+ }
+
+ $( '#button_style' )
+ .change( function() {
+ update_preview();
+ return true;
+ } )
+ .change();
+
+ $( 'input[name=sharing_label]' ).blur( function() {
+ $( '#live-preview h3.sd-title' ).text(
+ $( '<div/>' )
+ .text( $( this ).val() )
+ .html()
+ );
+ } );
+
+ init_handlers();
+ enable_share_button();
+ } );
+} )( jQuery );
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css b/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css
new file mode 100644
index 00000000..e572752d
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css
@@ -0,0 +1,2 @@
+/* Do not modify this file directly. It is concatenated from individual module CSS files. */
+#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 #dfdfdf;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{float:left;cursor:move}body.settings_page_sharing .services ul li.divider{border:none;padding:0;background:0 0;cursor:default}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{margin-right:10px;padding:5px 10px 5px 5px;border-radius:3px;border:1px solid #bbb;background:#f8f8f8;background-repeat:no-repeat;background-position:center center}#available-services .service:hover,#enabled-services .service:hover{background:#fff;border:1px solid #bbb;box-shadow:0 1px 3px rgba(0,0,0,.2)}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{color:#555;display:inline-block;-webkit-font-smoothing:antialiased;font:normal 18px/1 social-logos;vertical-align:top;position:relative;top:1px;margin-right:3px;width:16px;height:16px;text-align:center}li.service.share-print span:before{content:'\f469'}li.service.share-digg span:before{content:'\f221'}li.service.share-email span:before{content:'\f410'}li.service.share-linkedin span:before{content:'\f207'}li.service.share-twitter span:before{content:'\f202'}li.service.share-reddit span:before{content:'\f222'}li.service.share-tumblr span:before{content:'\f214'}li.service.share-pocket span:before{content:'\f224'}li.service.share-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-jetpack-whatsapp span:before{content:'\f608'}li.service.share-skype span:before{content:'\f220'}body.settings_page_sharing ul.preview{float:left;margin:0}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;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}.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-reddit .option-smart-on{background:url(images/smart-reddit.png) no-repeat top left;background-size:104px 21px;width:104px;height:21px}.preview-facebook .option-smart-on{background:url(images/smart-like.png) no-repeat top left;background-size:85px 20px;width:85px;height:20px}.preview-twitter .option-smart-on{background:url(images/smart-twitter.png?1) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-linkedin .option-smart-on{background:url(images/linkedin-smart.png) no-repeat top center;background-size:99px 18px;width:99px;height:20px}.preview-tumblr .option-smart-on{background:url(images/smart-tumblr.png) no-repeat top left;background-size:62px 20px;width:62px;height:20px}.preview-pinterest .option-smart-on{background:url(images/smart-pinterest.png) no-repeat top left;background-size:39px 20px;width:39px;height:20px}.preview-pocket .option-smart-on{background:url(images/smart-pocket.png) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-skype .option-smart-on{background:url(images/smart-skype.png) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-item.share-deprecated{opacity:.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-reddit .option-smart-on{background-image:url(images/smart-reddit@2x.png)}.preview-facebook .option-smart-on{background-image:url(images/smart-like@2x.png)}.preview-twitter .option-smart-on{background-image:url(images/smart-twitter@2x.png?1)}.preview-linkedin .option-smart-on{background-image:url(images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(images/smart-pocket@2x.png)}.preview-skype .option-smart-on{background-image:url(images/smart-skype@2x.png)}}.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:#ddd;color:#fff;padding:0 4px 2px;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;text-decoration:none;font-weight:700;font-size:10px}#services-config a.remove:hover{background:red}.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%} \ No newline at end of file
diff --git a/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png b/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png
new file mode 100644
index 00000000..d06bd260
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/comments@2x.png b/plugins/jetpack/modules/sharedaddy/images/comments@2x.png
new file mode 100644
index 00000000..f1c8fbf9
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/comments@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png b/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png
new file mode 100644
index 00000000..2c38752c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/custom.png b/plugins/jetpack/modules/sharedaddy/images/custom.png
new file mode 100644
index 00000000..46adefa4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/custom.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/custom@2x.png b/plugins/jetpack/modules/sharedaddy/images/custom@2x.png
new file mode 100644
index 00000000..9bbfcfb6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/custom@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/designfloat.png b/plugins/jetpack/modules/sharedaddy/images/designfloat.png
new file mode 100644
index 00000000..e2110bcc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/designfloat.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/digg.png b/plugins/jetpack/modules/sharedaddy/images/digg.png
new file mode 100644
index 00000000..dc98382c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/digg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/digg@2x.png b/plugins/jetpack/modules/sharedaddy/images/digg@2x.png
new file mode 100644
index 00000000..f9bd8a74
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/digg@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/divider.png b/plugins/jetpack/modules/sharedaddy/images/divider.png
new file mode 100644
index 00000000..00f427ad
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/divider.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/divider@2x.png b/plugins/jetpack/modules/sharedaddy/images/divider@2x.png
new file mode 100644
index 00000000..901cf653
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/divider@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/draggy.png b/plugins/jetpack/modules/sharedaddy/images/draggy.png
new file mode 100644
index 00000000..b4633d29
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/draggy.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png b/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png
new file mode 100644
index 00000000..133483ad
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/email.png b/plugins/jetpack/modules/sharedaddy/images/email.png
new file mode 100644
index 00000000..6753619a
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/email.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/email@2x.png b/plugins/jetpack/modules/sharedaddy/images/email@2x.png
new file mode 100644
index 00000000..6a6f70d2
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/email@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/ember.png b/plugins/jetpack/modules/sharedaddy/images/ember.png
new file mode 100644
index 00000000..47461ece
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/ember.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png b/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png
new file mode 100644
index 00000000..694dba27
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/facebook.png b/plugins/jetpack/modules/sharedaddy/images/facebook.png
new file mode 100644
index 00000000..91d3702f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/facebook.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png b/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png
new file mode 100644
index 00000000..10b36803
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/feed.png b/plugins/jetpack/modules/sharedaddy/images/feed.png
new file mode 100644
index 00000000..9eeeffd3
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/feed.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/icon-facebook-2x.png b/plugins/jetpack/modules/sharedaddy/images/icon-facebook-2x.png
new file mode 100644
index 00000000..3f2723fa
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/icon-facebook-2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/icon-facebook.png b/plugins/jetpack/modules/sharedaddy/images/icon-facebook.png
new file mode 100644
index 00000000..bb9edab4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/icon-facebook.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/icon-twitter-2x.png b/plugins/jetpack/modules/sharedaddy/images/icon-twitter-2x.png
new file mode 100644
index 00000000..a9a90141
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/icon-twitter-2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/icon-twitter.png b/plugins/jetpack/modules/sharedaddy/images/icon-twitter.png
new file mode 100644
index 00000000..ec41046e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/icon-twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/icon-wordpress-2x.png b/plugins/jetpack/modules/sharedaddy/images/icon-wordpress-2x.png
new file mode 100644
index 00000000..23439d93
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/icon-wordpress-2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/icon-wordpress.png b/plugins/jetpack/modules/sharedaddy/images/icon-wordpress.png
new file mode 100644
index 00000000..1ff384a0
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/icon-wordpress.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/kindle.png b/plugins/jetpack/modules/sharedaddy/images/kindle.png
new file mode 100644
index 00000000..a8b235c6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/kindle.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/kindle@2x.png b/plugins/jetpack/modules/sharedaddy/images/kindle@2x.png
new file mode 100644
index 00000000..dfbcbec3
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/kindle@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png
new file mode 100644
index 00000000..a55a3e60
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png
new file mode 100644
index 00000000..cd400275
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png
new file mode 100644
index 00000000..a5d4baeb
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png
new file mode 100644
index 00000000..ad599e67
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
new file mode 100644
index 00000000..a55a3e60
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png
new file mode 100644
index 00000000..cd400275
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png
new file mode 100644
index 00000000..24bc27d4
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png
new file mode 100644
index 00000000..3e6216e5
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin.png b/plugins/jetpack/modules/sharedaddy/images/linkedin.png
new file mode 100644
index 00000000..ee860f7f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png
new file mode 100644
index 00000000..7139d05f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/loading.gif b/plugins/jetpack/modules/sharedaddy/images/loading.gif
new file mode 100644
index 00000000..85b99d46
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/loading.gif
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/more.png b/plugins/jetpack/modules/sharedaddy/images/more.png
new file mode 100644
index 00000000..eb5bb625
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/more.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/more@2x.png b/plugins/jetpack/modules/sharedaddy/images/more@2x.png
new file mode 100644
index 00000000..931e9caf
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/more@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/pinterest.png b/plugins/jetpack/modules/sharedaddy/images/pinterest.png
new file mode 100644
index 00000000..d170d748
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/pinterest.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png b/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png
new file mode 100644
index 00000000..5229524f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/pocket.png b/plugins/jetpack/modules/sharedaddy/images/pocket.png
new file mode 100644
index 00000000..cba4e662
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/pocket.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/pocket@2x.png b/plugins/jetpack/modules/sharedaddy/images/pocket@2x.png
new file mode 100644
index 00000000..2512c887
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/pocket@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/print.png b/plugins/jetpack/modules/sharedaddy/images/print.png
new file mode 100644
index 00000000..71fa6bf6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/print.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/print@2x.png b/plugins/jetpack/modules/sharedaddy/images/print@2x.png
new file mode 100644
index 00000000..bb6b4027
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/print@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/reddit.png b/plugins/jetpack/modules/sharedaddy/images/reddit.png
new file mode 100644
index 00000000..d6644565
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/reddit.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png b/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png
new file mode 100644
index 00000000..11a3f2c3
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/rss.png b/plugins/jetpack/modules/sharedaddy/images/rss.png
new file mode 100644
index 00000000..7c92968f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/rss.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/rss@2x.png b/plugins/jetpack/modules/sharedaddy/images/rss@2x.png
new file mode 100644
index 00000000..f007bf2e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/rss@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/share-bg.png b/plugins/jetpack/modules/sharedaddy/images/share-bg.png
new file mode 100644
index 00000000..03c2d2bd
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/share-bg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png
new file mode 100644
index 00000000..3458c7bd
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png
new file mode 100644
index 00000000..5924c4af
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
new file mode 100644
index 00000000..6f564b7d
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png
new file mode 100644
index 00000000..6468a53e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-facebook.png b/plugins/jetpack/modules/sharedaddy/images/smart-facebook.png
new file mode 100644
index 00000000..799e0986
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-facebook.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png
new file mode 100644
index 00000000..bc277c2f
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like.png b/plugins/jetpack/modules/sharedaddy/images/smart-like.png
new file mode 100644
index 00000000..368a6c11
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-like.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png
new file mode 100644
index 00000000..7ad4d638
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png
new file mode 100644
index 00000000..ac78d5ad
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png
new file mode 100644
index 00000000..ea03b942
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pocket.png b/plugins/jetpack/modules/sharedaddy/images/smart-pocket.png
new file mode 100644
index 00000000..4a368a35
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-pocket.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pocket@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-pocket@2x.png
new file mode 100644
index 00000000..b84a0d90
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-pocket@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
new file mode 100644
index 00000000..5afa0aa6
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png
new file mode 100644
index 00000000..da4b569b
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-skype.png b/plugins/jetpack/modules/sharedaddy/images/smart-skype.png
new file mode 100644
index 00000000..b800d516
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-skype.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-skype@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-skype@2x.png
new file mode 100644
index 00000000..6828be4a
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-skype@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
new file mode 100644
index 00000000..922d84b9
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png
new file mode 100644
index 00000000..a807aef8
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png
new file mode 100644
index 00000000..147975e1
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png
new file mode 100644
index 00000000..b73b9a26
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
new file mode 100644
index 00000000..299c7d88
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png
new file mode 100644
index 00000000..0be96c46
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/tumblr.png b/plugins/jetpack/modules/sharedaddy/images/tumblr.png
new file mode 100644
index 00000000..d248cd09
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/tumblr.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png b/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png
new file mode 100644
index 00000000..f991236c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter.png b/plugins/jetpack/modules/sharedaddy/images/twitter.png
new file mode 100644
index 00000000..ec41046e
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/twitter.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png
new file mode 100644
index 00000000..aa666e66
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress.png b/plugins/jetpack/modules/sharedaddy/images/wordpress.png
new file mode 100644
index 00000000..94e92823
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/wordpress.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png b/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png
new file mode 100644
index 00000000..2da25ffc
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png
Binary files differ
diff --git a/plugins/jetpack/modules/sharedaddy/recaptcha.php b/plugins/jetpack/modules/sharedaddy/recaptcha.php
new file mode 100644
index 00000000..58ae6563
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/recaptcha.php
@@ -0,0 +1,188 @@
+<?php
+
+/**
+ * Class that handles reCAPTCHA.
+ */
+class Jetpack_ReCaptcha {
+
+ /**
+ * URL to which requests are POSTed.
+ *
+ * @const string
+ */
+ const VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
+
+ /**
+ * Site key to use in HTML code.
+ *
+ * @var string
+ */
+ private $site_key;
+
+ /**
+ * Shared secret for the site.
+ *
+ * @var string
+ */
+ private $secret_key;
+
+ /**
+ * Config for reCAPTCHA instance.
+ *
+ * @var array
+ */
+ private $config;
+
+ /**
+ * Error codes returned from reCAPTCHA API.
+ *
+ * @see https://developers.google.com/recaptcha/docs/verify
+ *
+ * @var array
+ */
+ private $error_codes;
+
+ /**
+ * Create a configured instance to use the reCAPTCHA service.
+ *
+ * @param string $site_key Site key to use in HTML code.
+ * @param string $secret_key Shared secret between site and reCAPTCHA server.
+ * @param array $config Config array to optionally configure reCAPTCHA instance.
+ */
+ public function __construct( $site_key, $secret_key, $config = array() ) {
+ $this->site_key = $site_key;
+ $this->secret_key = $secret_key;
+ $this->config = wp_parse_args( $config, $this->get_default_config() );
+
+ $this->error_codes = array(
+ 'missing-input-secret' => __( 'The secret parameter is missing', 'jetpack' ),
+ 'invalid-input-secret' => __( 'The secret parameter is invalid or malformed', 'jetpack' ),
+ 'missing-input-response' => __( 'The response parameter is missing', 'jetpack' ),
+ 'invalid-input-response' => __( 'The response parameter is invalid or malformed', 'jetpack' ),
+ 'invalid-json' => __( 'Invalid JSON', 'jetpack' ),
+ 'unexpected-response' => __( 'Unexpected response', 'jetpack' ),
+ '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' => true,
+ 'tag_class' => 'g-recaptcha',
+ 'tag_attributes' => array(
+ 'theme' => 'light',
+ 'type' => 'image',
+ 'tabindex' => 0,
+ ),
+ );
+ }
+
+ /**
+ * Calls the reCAPTCHA siteverify API to verify whether the user passes
+ * CAPTCHA test.
+ *
+ * @param string $response The value of 'g-recaptcha-response' in the submitted
+ * form.
+ * @param string $remote_ip The end user's IP address.
+ *
+ * @return bool|WP_Error Returns true if verified. Otherwise WP_Error is returned.
+ */
+ public function verify( $response, $remote_ip ) {
+ // No need make a request if response is empty.
+ if ( empty( $response ) ) {
+ return new WP_Error( 'missing-input-response', $this->error_codes['missing-input-response'], 400 );
+ }
+
+ $resp = wp_remote_post( self::VERIFY_URL, $this->get_verify_request_params( $response, $remote_ip ) );
+ if ( is_wp_error( $resp ) ) {
+ return $resp;
+ }
+
+ $resp_decoded = json_decode( wp_remote_retrieve_body( $resp ), true );
+ if ( ! $resp_decoded ) {
+ return new WP_Error( 'invalid-json', $this->error_codes['invalid-json'], 400 );
+ }
+
+ // Default error code and message.
+ $error_code = 'unexpected-response';
+ $error_message = $this->error_codes['unexpected-response'];
+
+ // Use the first error code if exists.
+ if ( isset( $resp_decoded['error-codes'] ) && is_array( $resp_decoded['error-codes'] ) ) {
+ if ( isset( $resp_decoded['error-codes'][0] ) && isset( $this->error_codes[ $resp_decoded['error-codes'][0] ] ) ) {
+ $error_message = $this->error_codes[ $resp_decoded['error-codes'][0] ];
+ $error_code = $resp_decoded['error-codes'][0];
+ }
+ }
+
+ if ( ! isset( $resp_decoded['success'] ) ) {
+ return new WP_Error( $error_code, $error_message );
+ }
+
+ if ( true !== $resp_decoded['success'] ) {
+ return new WP_Error( $error_code, $error_message );
+ }
+
+ // Validate the hostname matches expected source
+ if ( isset( $resp_decoded['hostname'] ) ) {
+ $url = wp_parse_url( get_home_url() );
+ if ( $url['host'] !== $resp_decoded['hostname'] ) {
+ 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() {
+ return sprintf(
+ '
+ <div
+ class="%s"
+ data-sitekey="%s"
+ data-theme="%s"
+ data-type="%s"
+ data-tabindex="%s"></div>
+ <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=%s"%s></script>
+ ',
+ esc_attr( $this->config['tag_class'] ),
+ esc_attr( $this->site_key ),
+ esc_attr( $this->config['tag_attributes']['theme'] ),
+ esc_attr( $this->config['tag_attributes']['type'] ),
+ esc_attr( $this->config['tag_attributes']['tabindex'] ),
+ rawurlencode( $this->config['language'] ),
+ $this->config['script_async'] ? ' async' : ''
+ );
+ }
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharedaddy.php b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
new file mode 100644
index 00000000..1e5de22c
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
@@ -0,0 +1,289 @@
+<?php
+/*
+Plugin Name: Sharedaddy
+Description: The most super duper sharing tool on the interwebs.
+Version: 0.3.1
+Author: Automattic, Inc.
+Author URI: http://automattic.com/
+Plugin URI: http://en.blog.wordpress.com/2010/08/24/more-ways-to-share/
+*/
+
+require_once plugin_dir_path( __FILE__ ).'sharing.php';
+
+function sharing_email_send_post( $data ) {
+
+ $content = sharing_email_send_post_content( $data );
+ // Borrowed from wp_mail();
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
+ if ( substr( $sitename, 0, 4 ) == 'www.' ) {
+ $sitename = substr( $sitename, 4 );
+ }
+
+ /** This filter is documented in core/src/wp-includes/pluggable.php */
+ $from_email = apply_filters( 'wp_mail_from', 'wordpress@' . $sitename );
+
+ if ( ! empty( $data['name'] ) ) {
+ $s_name = (string) $data['name'];
+ $name_needs_encoding_regex =
+ '/[' .
+ // SpamAssasin's list of characters which "need MIME" encoding
+ '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff' .
+ // Our list of "unsafe" characters
+ '<\r\n' .
+ ']/';
+
+ $needs_encoding =
+ // If it contains any blacklisted chars,
+ preg_match( $name_needs_encoding_regex, $s_name ) ||
+ // Or if we can't use `mb_convert_encoding`
+ ! function_exists( 'mb_convert_encoding' ) ||
+ // Or if it's not already ASCII
+ mb_convert_encoding( $data['name'], 'ASCII' ) !== $s_name;
+
+ if ( $needs_encoding ) {
+ $data['name'] = sprintf( '=?UTF-8?B?%s?=', base64_encode( $data['name'] ) );
+ }
+ }
+
+ $headers[] = sprintf( 'From: %1$s <%2$s>', $data['name'], $from_email );
+ $headers[] = sprintf( 'Reply-To: %1$s <%2$s>', $data['name'], $data['source'] );
+
+ // Make sure to pass the title through the normal sharing filters.
+ $title = $data['sharing_source']->get_share_title( $data['post']->ID );
+
+ /**
+ * Filter the Sharing Email Send Post Subject.
+ *
+ * @module sharedaddy
+ *
+ * @since 5.8.0
+ *
+ * @param string $var Sharing Email Send Post Subject. Default is "Shared Post".
+ */
+ $subject = apply_filters( 'wp_sharing_email_send_post_subject', '[' . __( 'Shared Post', 'jetpack' ) . '] ' . $title );
+
+ wp_mail( $data['target'], $subject, $content, $headers );
+}
+
+
+/* Checks for spam using akismet if available. */
+/* Return $data as it if email about to be send out is not spam. */
+function sharing_email_check_for_spam_via_akismet( $data ) {
+
+ if ( ! Jetpack::is_akismet_active() )
+ return $data;
+
+ // Prepare the body_request for akismet
+ $body_request = array(
+ 'blog' => get_option( 'home' ),
+ 'permalink' => $data['sharing_source']->get_share_url( $data['post']->ID ),
+ 'comment_type' => 'share',
+ 'comment_author' => $data['name'],
+ 'comment_author_email' => $data['source'],
+ 'comment_content' => sharing_email_send_post_content( $data ),
+ 'user_agent' => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null ),
+ );
+
+ if ( method_exists( 'Akismet', 'http_post' ) ) {
+ $body_request['user_ip'] = Akismet::get_ip_address();
+ $response = Akismet::http_post( build_query( $body_request ), 'comment-check' );
+ } else {
+ global $akismet_api_host, $akismet_api_port;
+ $body_request['user_ip'] = ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null );
+ $response = akismet_http_post( build_query( $body_request ), $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
+ }
+
+ // The Response is spam lets not send the email.
+ if ( ! empty( $response ) && isset( $response[1] ) && 'true' == trim( $response[1] ) ) { // 'true' is spam
+ return false; // don't send the email
+ }
+ return $data;
+}
+
+function sharing_email_send_post_content( $data ) {
+ /* translators: included in email when post is shared via email. First item is sender's name. Second is sender's email address. */
+ $content = sprintf( __( '%1$s (%2$s) thinks you may be interested in the following post:', 'jetpack' ), $data['name'], $data['source'] );
+ $content .= "\n\n";
+ // Make sure to pass the title and URL through the normal sharing filters.
+ $content .= $data['sharing_source']->get_share_title( $data['post']->ID ) . "\n";
+ $content .= $data['sharing_source']->get_share_url( $data['post']->ID ) . "\n";
+ return $content;
+}
+
+function sharing_add_meta_box() {
+ global $post;
+ if ( empty( $post ) ) { // If a current post is not defined, such as when editing a comment.
+ return;
+ }
+
+ /**
+ * Filter whether to display the Sharing Meta Box or not.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.8.0
+ *
+ * @param bool true Display Sharing Meta Box.
+ * @param $post Post.
+ */
+ if ( ! apply_filters( 'sharing_meta_box_show', true, $post ) ) {
+ return;
+ }
+
+ $post_types = get_post_types( array( 'public' => true ) );
+ /**
+ * Filter the Sharing Meta Box title.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.2.0
+ *
+ * @param string $var Sharing Meta Box title. Default is "Sharing".
+ */
+ $title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );
+ if ( $post->ID !== get_option( 'page_for_posts' ) ) {
+ foreach( $post_types as $post_type ) {
+ add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'side', 'default', array( '__back_compat_meta_box' => true ) );
+ }
+ }
+}
+
+
+function sharing_meta_box_content( $post ) {
+ /**
+ * Fires before the sharing meta box content.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.2.0
+ *
+ * @param WP_Post $post The post to share.
+ */
+ do_action( 'start_sharing_meta_box_content', $post );
+
+ $disabled = get_post_meta( $post->ID, 'sharing_disabled', true ); ?>
+
+ <p>
+ <label for="enable_post_sharing">
+ <input type="checkbox" name="enable_post_sharing" id="enable_post_sharing" value="1" <?php checked( !$disabled ); ?>>
+ <?php _e( 'Show sharing buttons.' , 'jetpack'); ?>
+ </label>
+ <input type="hidden" name="sharing_status_hidden" value="1" />
+ </p>
+
+ <?php
+ /**
+ * Fires after the sharing meta box content.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.2.0
+ *
+ * @param WP_Post $post The post to share.
+ */
+ do_action( 'end_sharing_meta_box_content', $post );
+}
+
+function sharing_meta_box_save( $post_id ) {
+ if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
+ return $post_id;
+
+ // Record sharing disable
+ if ( isset( $_POST['post_type'] ) && ( $post_type_object = get_post_type_object( $_POST['post_type'] ) ) && $post_type_object->public ) {
+ if ( current_user_can( 'edit_post', $post_id ) ) {
+ if ( isset( $_POST['sharing_status_hidden'] ) ) {
+ if ( !isset( $_POST['enable_post_sharing'] ) ) {
+ update_post_meta( $post_id, 'sharing_disabled', 1 );
+ } else {
+ delete_post_meta( $post_id, 'sharing_disabled' );
+ }
+ }
+ }
+ }
+
+ return $post_id;
+}
+
+function sharing_meta_box_protected( $protected, $meta_key, $meta_type ) {
+ if ( 'sharing_disabled' == $meta_key )
+ $protected = true;
+
+ return $protected;
+}
+
+add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 3 );
+
+function sharing_plugin_settings( $links ) {
+ $settings_link = '<a href="options-general.php?page=sharing.php">'.__( 'Settings', 'jetpack' ).'</a>';
+ array_unshift( $links, $settings_link );
+ return $links;
+}
+
+function sharing_add_plugin_settings($links, $file) {
+ if ( $file == basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ) ) {
+ $links[] = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
+ $links[] = '<a href="http://support.wordpress.com/sharing/" rel="noopener noreferrer" target="_blank">' . __( 'Support', 'jetpack' ) . '</a>';
+ }
+
+ return $links;
+}
+
+function sharing_init() {
+ if ( Jetpack_Options::get_option_and_ensure_autoload( 'sharedaddy_disable_resources', '0' ) ) {
+ add_filter( 'sharing_js', 'sharing_disable_js' );
+ remove_action( 'wp_head', 'sharing_add_header', 1 );
+ }
+}
+
+function sharing_disable_js() {
+ return false;
+}
+
+function sharing_global_resources() {
+ $disable = get_option( 'sharedaddy_disable_resources' );
+?>
+<tr valign="top">
+ <th scope="row"><label for="disable_css"><?php _e( 'Disable CSS and JS', 'jetpack' ); ?></label></th>
+ <td>
+ <input id="disable_css" type="checkbox" name="disable_resources" <?php if ( $disable == 1 ) echo ' checked="checked"'; ?>/> <small><em><?php _e( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' ); ?></em></small>
+ </td>
+</tr>
+<?php
+}
+
+function sharing_global_resources_save() {
+ update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 );
+}
+
+function sharing_email_dialog() {
+ require_once plugin_dir_path( __FILE__ ) . 'recaptcha.php';
+
+ $recaptcha = new Jetpack_ReCaptcha( RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY );
+ echo $recaptcha->get_recaptcha_html(); // xss ok
+}
+
+function sharing_email_check( $true, $post, $data ) {
+ require_once plugin_dir_path( __FILE__ ) . 'recaptcha.php';
+
+ $recaptcha = new Jetpack_ReCaptcha( RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY );
+ $response = ! empty( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
+ $result = $recaptcha->verify( $response, $_SERVER['REMOTE_ADDR'] );
+
+ return ( true === $result );
+}
+
+add_action( 'init', 'sharing_init' );
+add_action( 'add_meta_boxes', 'sharing_add_meta_box' );
+add_action( 'save_post', 'sharing_meta_box_save' );
+add_action( 'edit_attachment', 'sharing_meta_box_save' );
+add_action( 'sharing_email_send_post', 'sharing_email_send_post' );
+add_filter( 'sharing_email_can_send', 'sharing_email_check_for_spam_via_akismet' );
+add_action( 'sharing_global_options', 'sharing_global_resources', 30 );
+add_action( 'sharing_admin_update', 'sharing_global_resources_save' );
+add_action( 'plugin_action_links_'.basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 );
+add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 );
+
+if ( defined( 'RECAPTCHA_PUBLIC_KEY' ) && defined( 'RECAPTCHA_PRIVATE_KEY' ) ) {
+ add_action( 'sharing_email_dialog', 'sharing_email_dialog' );
+ add_filter( 'sharing_email_check', 'sharing_email_check', 10, 3 );
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php
new file mode 100644
index 00000000..7e453262
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php
@@ -0,0 +1,955 @@
+<?php
+
+include_once dirname( __FILE__ ) . '/sharing-sources.php';
+
+define( 'WP_SHARING_PLUGIN_VERSION', JETPACK__VERSION );
+
+class Sharing_Service {
+ private $global = false;
+ public $default_sharing_label = '';
+
+ public function __construct() {
+ $this->default_sharing_label = __( 'Share this:', 'jetpack' );
+ }
+
+ /**
+ * Gets a generic list of all services, without any config
+ */
+ public function get_all_services_blog() {
+ $options = get_option( 'sharing-options' );
+
+ $all = $this->get_all_services();
+ $services = array();
+
+ foreach ( $all as $id => $name ) {
+ if ( isset( $all[ $id ] ) ) {
+ $config = array();
+
+ // Pre-load custom modules otherwise they won't know who they are
+ if ( substr( $id, 0, 7 ) == 'custom-' && is_array( $options[ $id ] ) ) {
+ $config = $options[ $id ];
+ }
+
+ $services[ $id ] = new $all[ $id ]( $id, $config );
+ }
+ }
+
+ return $services;
+ }
+
+ /**
+ * Gets a list of all available service names and classes
+ */
+ public function get_all_services( $include_custom = true ) {
+ // Default services
+ // if you update this list, please update the REST API tests
+ // in bin/tests/api/suites/SharingTest.php
+ $services = array(
+ 'print' => 'Share_Print',
+ 'facebook' => 'Share_Facebook',
+ 'linkedin' => 'Share_LinkedIn',
+ 'reddit' => 'Share_Reddit',
+ 'twitter' => 'Share_Twitter',
+ 'tumblr' => 'Share_Tumblr',
+ 'pinterest' => 'Share_Pinterest',
+ 'pocket' => 'Share_Pocket',
+ 'telegram' => 'Share_Telegram',
+ 'jetpack-whatsapp' => 'Jetpack_Share_WhatsApp',
+ 'skype' => 'Share_Skype',
+ );
+
+ /**
+ * Filters if Email Sharing is enabled.
+ *
+ * E-Mail sharing is often problematic due to spam concerns, so this filter enables it to be quickly and simply toggled.
+ * @module sharedaddy
+ *
+ * @since 5.1.0
+ *
+ * @param bool $email Is e-mail sharing enabled? Default false if Akismet is not active or true if Akismet is active.
+ */
+ if ( apply_filters( 'sharing_services_email', Jetpack::is_akismet_active() ) ) {
+ $services['email'] = 'Share_Email';
+ }
+
+ if ( is_multisite() && is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
+ $services['press-this'] = 'Share_PressThis';
+ }
+
+ if ( $include_custom ) {
+ // Add any custom services in
+ $options = $this->get_global_options();
+ foreach ( (array) $options['custom'] as $custom_id ) {
+ $services[ $custom_id ] = 'Share_Custom';
+ }
+ }
+
+ /**
+ * Filters the list of available Sharing Services.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $services Array of all available Sharing Services.
+ */
+ return apply_filters( 'sharing_services', $services );
+ }
+
+ public function new_service( $label, $url, $icon ) {
+ // Validate
+ $label = trim( wp_html_excerpt( wp_kses( $label, array() ), 30 ) );
+ $url = trim( esc_url_raw( $url ) );
+ $icon = trim( esc_url_raw( $icon ) );
+
+ if ( $label && $url && $icon ) {
+ $options = get_option( 'sharing-options' );
+ if ( ! is_array( $options ) ) {
+ $options = array();
+ }
+
+ $service_id = 'custom-' . time();
+
+ // Add a new custom service
+ $options['global']['custom'][] = $service_id;
+ if ( false !== $this->global ) {
+ $this->global['custom'][] = $service_id;
+ }
+
+ update_option( 'sharing-options', $options );
+
+ // Create a custom service and set the options for it
+ $service = new Share_Custom(
+ $service_id, array(
+ 'name' => $label,
+ 'url' => $url,
+ 'icon' => $icon,
+ )
+ );
+ $this->set_service( $service_id, $service );
+
+ // Return the service
+ return $service;
+ }
+
+ return false;
+ }
+
+ public function delete_service( $service_id ) {
+ $options = get_option( 'sharing-options' );
+ if ( isset( $options[ $service_id ] ) ) {
+ unset( $options[ $service_id ] );
+ }
+
+ $key = array_search( $service_id, $options['global']['custom'] );
+ if ( $key !== false ) {
+ unset( $options['global']['custom'][ $key ] );
+ }
+
+ update_option( 'sharing-options', $options );
+ return true;
+ }
+
+ public function set_blog_services( array $visible, array $hidden ) {
+ $services = $this->get_all_services();
+ // Validate the services
+ $available = array_keys( $services );
+
+ // Only allow services that we have defined
+ $hidden = array_intersect( $hidden, $available );
+ $visible = array_intersect( $visible, $available );
+
+ // Ensure we don't have the same ones in hidden and visible
+ $hidden = array_diff( $hidden, $visible );
+
+ /**
+ * Control the state of the list of sharing services.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $args {
+ * Array of options describing the state of the sharing services.
+ *
+ * @type array $services List of all available service names and classes.
+ * @type array $available Validated list of all available service names and classes.
+ * @type array $hidden List of services hidden behind a "More" button.
+ * @type array $visible List of visible services.
+ * @type array $this->get_blog_services() Array of Sharing Services currently enabled.
+ * }
+ */
+ do_action(
+ 'sharing_get_services_state', array(
+ 'services' => $services,
+ 'available' => $available,
+ 'hidden' => $hidden,
+ 'visible' => $visible,
+ 'currently_enabled' => $this->get_blog_services(),
+ )
+ );
+
+ return update_option(
+ 'sharing-services', array(
+ 'visible' => $visible,
+ 'hidden' => $hidden,
+ )
+ );
+ }
+
+ public function get_blog_services() {
+ $options = get_option( 'sharing-options' );
+ $enabled = get_option( 'sharing-services' );
+ $services = $this->get_all_services();
+
+ /**
+ * Check if options exist and are well formatted.
+ * This avoids issues on sites with corrupted options.
+ * @see https://github.com/Automattic/jetpack/issues/6121
+ */
+ if ( ! is_array( $options ) || ! isset( $options['button_style'], $options['global'] ) ) {
+ $global_options = array( 'global' => $this->get_global_options() );
+ $options = is_array( $options )
+ ? array_merge( $options, $global_options )
+ : $global_options;
+ }
+
+ $global = $options['global'];
+
+ // Default services
+ if ( ! is_array( $enabled ) ) {
+ $enabled = array(
+ 'visible' => array(),
+ 'hidden' => array(),
+ );
+
+ /**
+ * Filters the list of default Sharing Services.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $enabled Array of default Sharing Services.
+ */
+ $enabled = apply_filters( 'sharing_default_services', $enabled );
+ }
+
+ // Cleanup after any filters that may have produced duplicate services
+ if ( is_array( $enabled['visible'] ) ) {
+ $enabled['visible'] = array_unique( $enabled['visible'] );
+ } else {
+ $enabled['visible'] = array();
+ }
+
+ if ( is_array( $enabled['hidden'] ) ) {
+ $enabled['hidden'] = array_unique( $enabled['hidden'] );
+ } else {
+ $enabled['hidden'] = array();
+ }
+
+ // Form the enabled services
+ $blog = array(
+ 'visible' => array(),
+ 'hidden' => array(),
+ );
+
+ foreach ( $blog as $area => $stuff ) {
+ foreach ( (array) $enabled[ $area ] as $service ) {
+ if ( isset( $services[ $service ] ) ) {
+ if ( ! isset( $options[ $service ] ) || ! is_array( $options[ $service ] ) ) {
+ $options[ $service ] = array();
+ }
+ $blog[ $area ][ $service ] = new $services[ $service ]( $service, array_merge( $global, $options[ $service ] ) );
+ }
+ }
+ }
+
+ /**
+ * Filters the list of enabled Sharing Services.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $blog Array of enabled Sharing Services.
+ */
+ $blog = apply_filters( 'sharing_services_enabled', $blog );
+
+ // Add CSS for NASCAR
+ if ( count( $blog['visible'] ) || count( $blog['hidden'] ) ) {
+ add_filter( 'post_flair_block_css', 'post_flair_service_enabled_sharing' );
+ }
+
+ // Convenience for checking if a service is present
+ $blog['all'] = array_flip( array_merge( array_keys( $blog['visible'] ), array_keys( $blog['hidden'] ) ) );
+ return $blog;
+ }
+
+ public function get_service( $service_name ) {
+ $services = $this->get_blog_services();
+
+ if ( isset( $services['visible'][ $service_name ] ) ) {
+ return $services['visible'][ $service_name ];
+ }
+
+ if ( isset( $services['hidden'][ $service_name ] ) ) {
+ return $services['hidden'][ $service_name ];
+ }
+
+ return false;
+ }
+
+ public function set_global_options( $data ) {
+ $options = get_option( 'sharing-options' );
+
+ // No options yet
+ if ( ! is_array( $options ) ) {
+ $options = array();
+ }
+
+ // Defaults
+ $options['global'] = array(
+ 'button_style' => 'icon-text',
+ 'sharing_label' => $this->default_sharing_label,
+ 'open_links' => 'same',
+ 'show' => array(),
+ 'custom' => isset( $options['global']['custom'] ) ? $options['global']['custom'] : array(),
+ );
+
+ /**
+ * Filters global sharing settings.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $options['global'] Array of global sharing settings.
+ */
+ $options['global'] = apply_filters( 'sharing_default_global', $options['global'] );
+
+ // Validate options and set from our data
+ if ( isset( $data['button_style'] ) && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text', 'official' ) ) ) {
+ $options['global']['button_style'] = $data['button_style'];
+ }
+
+ if ( isset( $data['sharing_label'] ) ) {
+ if ( $this->default_sharing_label === $data['sharing_label'] ) {
+ $options['global']['sharing_label'] = false;
+ } else {
+ $options['global']['sharing_label'] = trim( wp_kses( stripslashes( $data['sharing_label'] ), array() ) );
+ }
+ }
+
+ if ( isset( $data['open_links'] ) && in_array( $data['open_links'], array( 'new', 'same' ) ) ) {
+ $options['global']['open_links'] = $data['open_links'];
+ }
+
+ $shows = array_values( get_post_types( array( 'public' => true ) ) );
+ $shows[] = 'index';
+ if ( isset( $data['show'] ) ) {
+ if ( is_scalar( $data['show'] ) ) {
+ switch ( $data['show'] ) {
+ case 'posts':
+ $data['show'] = array( 'post', 'page' );
+ break;
+ case 'index':
+ $data['show'] = array( 'index' );
+ break;
+ case 'posts-index':
+ $data['show'] = array( 'post', 'page', 'index' );
+ break;
+ }
+ }
+
+ if ( $data['show'] = array_intersect( $data['show'], $shows ) ) {
+ $options['global']['show'] = $data['show'];
+ }
+ }
+
+ update_option( 'sharing-options', $options );
+ return $options['global'];
+ }
+
+ public function get_global_options() {
+ if ( $this->global === false ) {
+ $options = get_option( 'sharing-options' );
+
+ if ( is_array( $options ) && isset( $options['global'] ) && is_array( $options['global'] ) ) {
+ $this->global = $options['global'];
+ } else {
+ $this->global = $this->set_global_options( $options['global'] );
+ }
+ }
+
+ if ( ! isset( $this->global['show'] ) ) {
+ $this->global['show'] = array( 'post', 'page' );
+ } elseif ( is_scalar( $this->global['show'] ) ) {
+ switch ( $this->global['show'] ) {
+ case 'posts':
+ $this->global['show'] = array( 'post', 'page' );
+ break;
+ case 'index':
+ $this->global['show'] = array( 'index' );
+ break;
+ case 'posts-index':
+ $this->global['show'] = array( 'post', 'page', 'index' );
+ break;
+ }
+ }
+
+ if ( false === $this->global['sharing_label'] ) {
+ $this->global['sharing_label'] = $this->default_sharing_label;
+ }
+
+ return $this->global;
+ }
+
+ public function set_service( $id, Sharing_Source $service ) {
+ // Update the options for this service
+ $options = get_option( 'sharing-options' );
+
+ // No options yet
+ if ( ! is_array( $options ) ) {
+ $options = array();
+ }
+
+ /**
+ * Get the state of a sharing button.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $args {
+ * State of a sharing button.
+ *
+ * @type string $id Service ID.
+ * @type array $options Array of all sharing options.
+ * @type array $service Details about a service.
+ * }
+ */
+ do_action(
+ 'sharing_get_button_state', array(
+ 'id' => $id,
+ 'options' => $options,
+ 'service' => $service,
+ )
+ );
+
+ $options[ $id ] = $service->get_options();
+
+ update_option( 'sharing-options', array_filter( $options ) );
+ }
+
+ // Soon to come to a .org plugin near you!
+ public function get_total( $service_name = false, $post_id = false, $_blog_id = false ) {
+ global $wpdb, $blog_id;
+ if ( ! $_blog_id ) {
+ $_blog_id = $blog_id;
+ }
+ if ( $service_name == false ) {
+ if ( $post_id > 0 ) {
+ // total number of shares for this post
+ return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d', $_blog_id, $post_id ) );
+ } else {
+ // total number of shares for this blog
+ return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d', $_blog_id ) );
+ }
+ }
+
+ if ( $post_id > 0 ) {
+ return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s', $_blog_id, $post_id, $service_name ) );
+ } else {
+ return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s', $_blog_id, $service_name ) );
+ }
+ }
+
+ public function get_services_total( $post_id = false ) {
+ $totals = array();
+ $services = $this->get_blog_services();
+
+ if ( ! empty( $services ) && isset( $services['all'] ) ) {
+ foreach ( $services['all'] as $key => $value ) {
+ $totals[ $key ] = new Sharing_Service_Total( $key, $this->get_total( $key, $post_id ) );
+ }
+ }
+ usort( $totals, array( 'Sharing_Service_Total', 'cmp' ) );
+
+ return $totals;
+ }
+
+ public function get_posts_total() {
+ $totals = array();
+ global $wpdb, $blog_id;
+
+ $my_data = $wpdb->get_results( $wpdb->prepare( 'SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d GROUP BY post_id ORDER BY count DESC ', $blog_id ) );
+
+ if ( ! empty( $my_data ) ) {
+ foreach ( $my_data as $row ) {
+ $totals[] = new Sharing_Post_Total( $row->id, $row->total );
+ }
+ }
+
+ usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
+
+ return $totals;
+ }
+}
+
+class Sharing_Service_Total {
+ public $id = '';
+ public $name = '';
+ public $service = '';
+ public $total = 0;
+
+ public function __construct( $id, $total ) {
+ $services = new Sharing_Service();
+ $this->id = esc_html( $id );
+ $this->service = $services->get_service( $id );
+ $this->total = (int) $total;
+
+ $this->name = $this->service->get_name();
+ }
+
+ static function cmp( $a, $b ) {
+ if ( $a->total == $b->total ) {
+ return $a->name < $b->name;
+ }
+ return $a->total < $b->total;
+ }
+}
+
+class Sharing_Post_Total {
+ public $id = 0;
+ public $total = 0;
+ public $title = '';
+ public $url = '';
+
+ public function __construct( $id, $total ) {
+ $this->id = (int) $id;
+ $this->total = (int) $total;
+ $this->title = get_the_title( $this->id );
+ $this->url = get_permalink( $this->id );
+ }
+
+ static function cmp( $a, $b ) {
+ if ( $a->total == $b->total ) {
+ return $a->id < $b->id;
+ }
+ return $a->total < $b->total;
+ }
+}
+
+function sharing_register_post_for_share_counts( $post_id ) {
+ global $jetpack_sharing_counts;
+
+ if ( ! isset( $jetpack_sharing_counts ) || ! is_array( $jetpack_sharing_counts ) ) {
+ $jetpack_sharing_counts = array();
+ }
+
+ $jetpack_sharing_counts[ (int) $post_id ] = get_permalink( $post_id );
+}
+
+function sharing_maybe_enqueue_scripts() {
+ $sharer = new Sharing_Service();
+ $global_options = $sharer->get_global_options();
+
+ $enqueue = false;
+ if ( is_singular() && in_array( get_post_type(), $global_options['show'] ) ) {
+ $enqueue = true;
+ } elseif ( in_array( 'index', $global_options['show'] ) && ( is_home() || is_front_page() || is_archive() || is_search() || in_array( get_post_type(), $global_options['show'] ) ) ) {
+ $enqueue = true;
+ }
+
+ /**
+ * Filter to decide when sharing scripts should be enqueued.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.2.0
+ *
+ * @param bool $enqueue Decide if the sharing scripts should be enqueued.
+ */
+ return (bool) apply_filters( 'sharing_enqueue_scripts', $enqueue );
+}
+
+function sharing_add_footer() {
+ if (
+ class_exists( 'Jetpack_AMP_Support' )
+ && Jetpack_AMP_Support::is_amp_request()
+ ) {
+ return;
+ }
+
+ global $jetpack_sharing_counts;
+
+ /**
+ * Filter all JavaScript output by the sharing module.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param bool true Control whether the sharing module should add any JavaScript to the site. Default to true.
+ */
+ if ( apply_filters( 'sharing_js', true ) && sharing_maybe_enqueue_scripts() ) {
+
+ /**
+ * Filter the display of sharing counts next to the sharing buttons.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.2.0
+ *
+ * @param bool true Control the display of counters next to the sharing buttons. Default to true.
+ */
+ if ( apply_filters( 'jetpack_sharing_counts', true ) && is_array( $jetpack_sharing_counts ) && count( $jetpack_sharing_counts ) ) :
+ $sharing_post_urls = array_filter( $jetpack_sharing_counts );
+ if ( $sharing_post_urls ) :
+ ?>
+
+ <script type="text/javascript">
+ window.WPCOM_sharing_counts = <?php echo json_encode( array_flip( $sharing_post_urls ) ); ?>;
+ </script>
+ <?php
+ endif;
+ endif;
+
+ wp_enqueue_script( 'sharing-js' );
+ $sharing_js_options = array(
+ 'lang' => get_base_recaptcha_lang_code(),
+ /** This filter is documented in modules/sharedaddy/sharing-service.php */
+ 'counts' => apply_filters( 'jetpack_sharing_counts', true ),
+ 'is_stats_active' => Jetpack::is_module_active( 'stats' ),
+ );
+ wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options );
+ }
+ $sharer = new Sharing_Service();
+ $enabled = $sharer->get_blog_services();
+ foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) as $service ) {
+ $service->display_footer();
+ }
+}
+
+function sharing_add_header() {
+ $sharer = new Sharing_Service();
+ $enabled = $sharer->get_blog_services();
+
+ foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) as $service ) {
+ $service->display_header();
+ }
+
+ if ( count( $enabled['all'] ) > 0 && sharing_maybe_enqueue_scripts() ) {
+ wp_enqueue_style( 'sharedaddy', plugin_dir_url( __FILE__ ) . 'sharing.css', array(), JETPACK__VERSION );
+ wp_enqueue_style( 'social-logos' );
+ }
+
+}
+add_action( 'wp_head', 'sharing_add_header', 1 );
+
+function sharing_process_requests() {
+ global $post;
+
+ // Only process if: single post and share=X defined
+ if ( ( is_page() || is_single() ) && isset( $_GET['share'] ) ) {
+ $sharer = new Sharing_Service();
+
+ $service = $sharer->get_service( $_GET['share'] );
+ if ( $service ) {
+ $service->process_request( $post, $_POST );
+ }
+ }
+}
+add_action( 'template_redirect', 'sharing_process_requests', 9 );
+
+function sharing_display( $text = '', $echo = false ) {
+ global $post, $wp_current_filter;
+
+ require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
+ if ( Jetpack_Sync_Settings::is_syncing() ) {
+ return $text;
+ }
+
+ if ( empty( $post ) ) {
+ return $text;
+ }
+
+ if ( ( is_preview() || is_admin() ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
+ return $text;
+ }
+
+ // Don't output flair on excerpts
+ if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
+ return $text;
+ }
+
+ // Don't allow flair to be added to the_content more than once (prevent infinite loops)
+ $done = false;
+ foreach ( $wp_current_filter as $filter ) {
+ if ( 'the_content' == $filter ) {
+ if ( $done ) {
+ return $text;
+ } else {
+ $done = true;
+ }
+ }
+ }
+
+ // check whether we are viewing the front page and whether the front page option is checked
+ $options = get_option( 'sharing-options' );
+ $display_options = $options['global']['show'];
+
+ if ( is_front_page() && ( is_array( $display_options ) && ! in_array( 'index', $display_options ) ) ) {
+ return $text;
+ }
+
+ if ( is_attachment() && in_array( 'the_excerpt', (array) $wp_current_filter ) ) {
+ // Many themes run the_excerpt() conditionally on an attachment page, then run the_content().
+ // We only want to output the sharing buttons once. Let's stick with the_content().
+ return $text;
+ }
+
+ $sharer = new Sharing_Service();
+ $global = $sharer->get_global_options();
+
+ $show = false;
+ if ( ! is_feed() ) {
+ if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {
+ $show = true;
+ } elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_front_page() || is_archive() || is_search() || in_array( get_post_type(), $global['show'] ) ) ) {
+ $show = true;
+ }
+ }
+
+ /**
+ * Filter to decide if sharing buttons should be displayed.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param bool $show Should the sharing buttons be displayed.
+ * @param WP_Post $post The post to share.
+ */
+ $show = apply_filters( 'sharing_show', $show, $post );
+
+ // Disabled for this post?
+ $switched_status = get_post_meta( $post->ID, 'sharing_disabled', false );
+
+ if ( ! empty( $switched_status ) ) {
+ $show = false;
+ }
+
+ // Private post?
+ $post_status = get_post_status( $post->ID );
+
+ if ( 'private' === $post_status ) {
+ $show = false;
+ }
+
+ /**
+ * Filter the Sharing buttons' Ajax action name Jetpack checks for.
+ * This allows the use of the buttons with your own Ajax implementation.
+ *
+ * @module sharedaddy
+ *
+ * @since 7.3.0
+ *
+ * @param string $sharing_ajax_action_name Name of the Sharing buttons' Ajax action.
+ */
+ $ajax_action = apply_filters( 'sharing_ajax_action', 'get_latest_posts' );
+
+ // Allow to be used in ajax requests for latest posts.
+ if (
+ defined( 'DOING_AJAX' )
+ && DOING_AJAX
+ && isset( $_REQUEST['action'] )
+ && $ajax_action === $_REQUEST['action']
+ ) {
+ $show = true;
+ }
+
+ $sharing_content = '';
+ $enabled = false;
+
+ if ( $show ) {
+ /**
+ * Filters the list of enabled Sharing Services.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.2.3
+ *
+ * @param array $sharer->get_blog_services() Array of Sharing Services currently enabled.
+ */
+ $enabled = apply_filters( 'sharing_enabled', $sharer->get_blog_services() );
+
+ if ( count( $enabled['all'] ) > 0 ) {
+ global $post;
+
+ $dir = get_option( 'text_direction' );
+
+ // Wrapper
+ $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';
+ if ( $global['sharing_label'] != '' ) {
+ $sharing_content .= sprintf(
+ /**
+ * Filter the sharing buttons' headline structure.
+ *
+ * @module sharedaddy
+ *
+ * @since 4.4.0
+ *
+ * @param string $sharing_headline Sharing headline structure.
+ * @param string $global['sharing_label'] Sharing title.
+ * @param string $sharing Module name.
+ */
+ apply_filters( 'jetpack_sharing_headline_html', '<h3 class="sd-title">%s</h3>', $global['sharing_label'], 'sharing' ),
+ esc_html( $global['sharing_label'] )
+ );
+ }
+ $sharing_content .= '<div class="sd-content"><ul>';
+
+ // Visible items
+ $visible = '';
+ foreach ( $enabled['visible'] as $id => $service ) {
+ $klasses = array( 'share-' . $service->get_class() );
+ if ( $service->is_deprecated() ) {
+ if ( ! current_user_can( 'manage_options' ) ) {
+ continue;
+ }
+ $klasses[] = 'share-deprecated';
+ }
+ // Individual HTML for sharing service
+ $visible .= '<li class="' . implode( ' ', $klasses ) . '">' . $service->get_display( $post ) . '</li>';
+ }
+
+ $parts = array();
+ $parts[] = $visible;
+ if ( count( $enabled['hidden'] ) > 0 ) {
+ if ( count( $enabled['visible'] ) > 0 ) {
+ $expand = __( 'More', 'jetpack' );
+ } else {
+ $expand = __( 'Share', 'jetpack' );
+ }
+ $parts[] = '<li><a href="#" class="sharing-anchor sd-button share-more"><span>' . $expand . '</span></a></li>';
+ }
+
+ if ( $dir == 'rtl' ) {
+ $parts = array_reverse( $parts );
+ }
+
+ $sharing_content .= implode( '', $parts );
+ $sharing_content .= '<li class="share-end"></li></ul>';
+
+ if ( count( $enabled['hidden'] ) > 0 ) {
+ $sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;';
+
+ if ( count( $enabled['hidden'] ) == 1 ) {
+ $sharing_content .= 'width:150px;';
+ }
+
+ $sharing_content .= '">';
+
+ if ( count( $enabled['hidden'] ) == 1 ) {
+ $sharing_content .= '<ul style="background-image:none;">';
+ } else {
+ $sharing_content .= '<ul>';
+ }
+
+ $count = 1;
+ foreach ( $enabled['hidden'] as $id => $service ) {
+ // Individual HTML for sharing service
+ $klasses = array( 'share-' . $service->get_class() );
+ if ( $service->is_deprecated() ) {
+ if ( ! current_user_can( 'manage_options' ) ) {
+ continue;
+ }
+ $klasses[] = 'share-deprecated';
+ }
+ $sharing_content .= '<li class="' . implode( ' ', $klasses ) . '">';
+ $sharing_content .= $service->get_display( $post );
+ $sharing_content .= '</li>';
+
+ if ( ( $count % 2 ) == 0 ) {
+ $sharing_content .= '<li class="share-end"></li>';
+ }
+
+ $count ++;
+ }
+
+ // End of wrapper
+ $sharing_content .= '<li class="share-end"></li></ul></div></div>';
+ }
+
+ $sharing_content .= '</div></div></div>';
+
+ // Register our JS
+ if ( defined( 'JETPACK__VERSION' ) ) {
+ $ver = JETPACK__VERSION;
+ } else {
+ $ver = '20141212';
+ }
+ wp_register_script(
+ 'sharing-js',
+ Jetpack::get_file_url_for_environment(
+ '_inc/build/sharedaddy/sharing.min.js',
+ 'modules/sharedaddy/sharing.js'
+ ),
+ array( 'jquery' ),
+ $ver
+ );
+
+ // Enqueue scripts for the footer
+ add_action( 'wp_footer', 'sharing_add_footer' );
+ }
+ }
+
+ /**
+ * Filters the content markup of the Jetpack sharing links
+ *
+ * @module sharedaddy
+ *
+ * @since 3.8.0
+ * @since 6.2.0 Started sending $enabled as a second parameter.
+ *
+ * @param string $sharing_content Content markup of the Jetpack sharing links
+ * @param array $enabled Array of Sharing Services currently enabled.
+ */
+ $sharing_markup = apply_filters( 'jetpack_sharing_display_markup', $sharing_content, $enabled );
+
+ if ( $echo ) {
+ echo $text . $sharing_markup;
+ } else {
+ return $text . $sharing_markup;
+ }
+}
+
+add_filter( 'the_content', 'sharing_display', 19 );
+add_filter( 'the_excerpt', 'sharing_display', 19 );
+function get_base_recaptcha_lang_code() {
+
+ $base_recaptcha_lang_code_mapping = array(
+ 'en' => 'en',
+ 'nl' => 'nl',
+ 'fr' => 'fr',
+ 'fr-be' => 'fr',
+ 'fr-ca' => 'fr',
+ 'fr-ch' => 'fr',
+ 'de' => 'de',
+ 'pt' => 'pt',
+ 'pt-br' => 'pt',
+ 'ru' => 'ru',
+ 'es' => 'es',
+ 'tr' => 'tr',
+ );
+
+ $blog_lang_code = function_exists( 'get_blog_lang_code' ) ? get_blog_lang_code() : get_bloginfo( 'language' );
+ if ( isset( $base_recaptcha_lang_code_mapping[ $blog_lang_code ] ) ) {
+ return $base_recaptcha_lang_code_mapping[ $blog_lang_code ];
+ }
+
+ // if no base mapping is found return default 'en'
+ return 'en';
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
new file mode 100644
index 00000000..0cc0ec59
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
@@ -0,0 +1,1793 @@
+<?php
+
+abstract class Sharing_Source {
+ public $button_style;
+ public $smart;
+ protected $open_link_in_new;
+ protected $id;
+
+ public function __construct( $id, array $settings ) {
+ $this->id = $id;
+ /**
+ * Filter the way sharing links open.
+ *
+ * By default, sharing links open in a new window.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.4.0
+ *
+ * @param bool true Should Sharing links open in a new window. Default to true.
+ */
+ $this->open_link_in_new = apply_filters( 'jetpack_open_sharing_in_new_window', true );
+
+ if ( isset( $settings['button_style'] ) ) {
+ $this->button_style = $settings['button_style'];
+ }
+
+ if ( isset( $settings['smart'] ) ) {
+ $this->smart = $settings['smart'];
+ }
+ }
+
+ public function is_deprecated() {
+ return false;
+ }
+
+ public function http() {
+ return is_ssl() ? 'https' : 'http';
+ }
+
+ public function get_id() {
+ return $this->id;
+ }
+
+ public function get_class() {
+ return $this->id;
+ }
+
+ public function get_share_url( $post_id ) {
+ /**
+ * Filter the sharing permalink.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.2.0
+ *
+ * @param string get_permalink( $post_id ) Post Permalink.
+ * @param int $post_id Post ID.
+ * @param int $this->id Sharing ID.
+ */
+ return apply_filters( 'sharing_permalink', get_permalink( $post_id ), $post_id, $this->id );
+ }
+
+ public function get_share_title( $post_id ) {
+ $post = get_post( $post_id );
+ /**
+ * Filter the sharing title.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.8.0
+ *
+ * @param string $post->post_title Post Title.
+ * @param int $post_id Post ID.
+ * @param int $this->id Sharing ID.
+ */
+ $title = apply_filters( 'sharing_title', $post->post_title, $post_id, $this->id );
+
+ return html_entity_decode( wp_kses( $title, null ) );
+ }
+
+ public function has_custom_button_style() {
+ return false;
+ }
+
+ public function get_link( $url, $text, $title, $query = '', $id = false ) {
+ $args = func_get_args();
+ $klasses = array( 'share-' . $this->get_class(), 'sd-button' );
+
+ if ( 'icon' == $this->button_style || 'icon-text' == $this->button_style ) {
+ $klasses[] = 'share-icon';
+ }
+
+ if ( 'icon' == $this->button_style ) {
+ $text = $title;
+ $klasses[] = 'no-text';
+
+ if ( true == $this->open_link_in_new ) {
+ $text .= __( ' (Opens in new window)', 'jetpack' );
+ }
+ }
+
+ /**
+ * Filter the sharing display ID.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.4.0
+ *
+ * @param int|false $id Sharing ID.
+ * @param object $this Sharing service properties.
+ * @param array $args Array of sharing service options.
+ */
+ $id = apply_filters( 'jetpack_sharing_display_id', $id, $this, $args );
+ /**
+ * Filter the sharing display link.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.8.0
+ *
+ * @param string $url Post URL.
+ * @param object $this Sharing service properties.
+ * @param int|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $url = apply_filters( 'sharing_display_link', $url, $this, $id, $args ); // backwards compatibility
+ /**
+ * Filter the sharing display link.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.8.0
+ *
+ * @param string $url Post URL.
+ * @param object $this Sharing service properties.
+ * @param int|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $url = apply_filters( 'jetpack_sharing_display_link', $url, $this, $id, $args );
+ /**
+ * Filter the sharing display query.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.8.0
+ *
+ * @param string $query Sharing service URL parameter.
+ * @param object $this Sharing service properties.
+ * @param int|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $query = apply_filters( 'jetpack_sharing_display_query', $query, $this, $id, $args );
+
+ if ( ! empty( $query ) ) {
+ if ( false === stripos( $url, '?' ) ) {
+ $url .= '?' . $query;
+ } else {
+ $url .= '&amp;' . $query;
+ }
+ }
+
+ if ( 'text' == $this->button_style ) {
+ $klasses[] = 'no-icon';
+ }
+
+ /**
+ * Filter the sharing display classes.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.4.0
+ *
+ * @param array $klasses Sharing service classes.
+ * @param object $this Sharing service properties.
+ * @param int|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $klasses = apply_filters( 'jetpack_sharing_display_classes', $klasses, $this, $id, $args );
+ /**
+ * Filter the sharing display title.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.4.0
+ *
+ * @param string $title Sharing service title.
+ * @param object $this Sharing service properties.
+ * @param int|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $title = apply_filters( 'jetpack_sharing_display_title', $title, $this, $id, $args );
+ /**
+ * Filter the sharing display text.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.4.0
+ *
+ * @param string $text Sharing service text.
+ * @param object $this Sharing service properties.
+ * @param int|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $text = apply_filters( 'jetpack_sharing_display_text', $text, $this, $id, $args );
+
+ return sprintf(
+ '<a rel="nofollow%s" data-shared="%s" class="%s" href="%s"%s title="%s"><span%s>%s</span></a>',
+ ( true == $this->open_link_in_new ) ? ' noopener noreferrer' : '',
+ ( $id ? esc_attr( $id ) : '' ),
+ implode( ' ', $klasses ),
+ $url,
+ ( true == $this->open_link_in_new ) ? ' target="_blank"' : '',
+ $title,
+ ( 'icon' == $this->button_style ) ? '></span><span class="sharing-screen-reader-text"' : '',
+ $text
+ );
+ }
+
+ /**
+ * Get an unfiltered post permalink to use when generating a sharing URL with get_link.
+ * Use instead of get_share_url for non-official styles as get_permalink ensures that process_request
+ * will be executed more reliably, in the case that the filtered URL uses a service that strips query parameters.
+ *
+ * @since 3.7.0
+ * @param int $post_id Post ID.
+ * @uses get_permalink
+ * @return string get_permalink( $post_id ) Post permalink.
+ */
+ public function get_process_request_url( $post_id ) {
+ return get_permalink( $post_id );
+ }
+
+ abstract public function get_name();
+ abstract public function get_display( $post );
+
+ public function display_header() {
+ }
+
+ public function display_footer() {
+ }
+
+ public function has_advanced_options() {
+ return false;
+ }
+
+ public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
+ $text = '&nbsp;';
+ $button_style = ( ! empty( $button_style ) ) ? $button_style : $this->button_style;
+ if ( ! $this->smart && ! $force_smart ) {
+ if ( $button_style != 'icon' ) {
+ $text = $this->get_name();
+ }
+ }
+
+ $klasses = array( 'share-' . $this->get_class(), 'sd-button' );
+
+ if ( $button_style == 'icon' || $button_style == 'icon-text' ) {
+ $klasses[] = 'share-icon';
+ }
+
+ if ( $button_style == 'icon' ) {
+ $klasses[] = 'no-text';
+ }
+
+ if ( $button_style == 'text' ) {
+ $klasses[] = 'no-icon';
+ }
+
+ $is_deprecated = $this->is_deprecated();
+
+ $link = sprintf(
+ '<a rel="nofollow" class="%s" href="javascript:void(0)" title="%s"><span>%s</span></a>',
+ implode( ' ', $klasses ),
+ esc_attr(
+ $is_deprecated
+ ? sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $this->get_name() )
+ : $this->get_name()
+ ),
+ esc_html(
+ $is_deprecated
+ ? sprintf( __( '%1$s has shut down', 'jetpack' ), $this->get_name() )
+ : $text
+ )
+ );
+
+ $smart = ( $this->smart || $force_smart ) ? 'on' : 'off';
+ $return = "<div class='option option-smart-$smart'>$link</div>";
+ if ( $echo ) {
+ echo $return;
+ }
+
+ return $return;
+ }
+
+ public function get_total( $post = false ) {
+ global $wpdb, $blog_id;
+
+ $name = strtolower( $this->get_id() );
+
+ if ( $post == false ) {
+ // get total number of shares for service
+ return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s', $blog_id, $name ) );
+ }
+
+ // get total shares for a post
+ return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s', $blog_id, $post->ID, $name ) );
+ }
+
+ public function get_posts_total() {
+ global $wpdb, $blog_id;
+
+ $totals = array();
+ $name = strtolower( $this->get_id() );
+
+ $my_data = $wpdb->get_results( $wpdb->prepare( 'SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d AND share_service = %s GROUP BY post_id ORDER BY count DESC ', $blog_id, $name ) );
+
+ if ( ! empty( $my_data ) ) {
+ foreach ( $my_data as $row ) {
+ $totals[] = new Sharing_Post_Total( $row->id, $row->total );
+ }
+ }
+
+ usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
+
+ return $totals;
+ }
+
+ public function process_request( $post, array $post_data ) {
+ /**
+ * Fires when a post is shared via one of the sharing buttons.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $args Aray of information about the sharing service.
+ */
+ do_action( 'sharing_bump_stats', array( 'service' => $this, 'post' => $post ) );
+ }
+
+ public function js_dialog( $name, $params = array() ) {
+ if ( true !== $this->open_link_in_new ) {
+ return;
+ }
+
+ $defaults = array(
+ 'menubar' => 1,
+ 'resizable' => 1,
+ 'width' => 600,
+ 'height' => 400,
+ );
+ $params = array_merge( $defaults, $params );
+ $opts = array();
+ foreach ( $params as $key => $val ) {
+ $opts[] = "$key=$val";
+ }
+ $opts = implode( ',', $opts );
+
+ // Add JS after sharing-js has been enqueued.
+ wp_add_inline_script( 'sharing-js',
+ "var windowOpen;
+ jQuery( document.body ).on( 'click', 'a.share-$name', function() {
+ // If there's another sharing window open, close it.
+ if ( 'undefined' !== typeof windowOpen ) {
+ windowOpen.close();
+ }
+ windowOpen = window.open( jQuery( this ).attr( 'href' ), 'wpcom$name', '$opts' );
+ return false;
+ });"
+ );
+ }
+}
+
+abstract class Deprecated_Sharing_Source extends Sharing_Source {
+ public $button_style = 'text';
+ public $smart = false;
+ protected $open_link_in_new = false;
+ protected $id;
+ protected $deprecated = true;
+
+ final public function __construct( $id, array $settings ) {
+ $this->id = $id;
+
+ if ( isset( $settings['button_style'] ) ) {
+ $this->button_style = $settings['button_style'];
+ }
+ }
+
+ final public function is_deprecated() {
+ return true;
+ }
+
+ final public function get_share_url( $post_id ) {
+ return get_permalink( $post_id );
+ }
+
+ final public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
+ return parent::display_preview( $echo, false, $button_style );
+ }
+
+ final public function get_total( $post = false ) {
+ return 0;
+ }
+
+ final public function get_posts_total() {
+ return 0;
+ }
+
+ final public function process_request( $post, array $post_data ) {
+ parent::process_request( $post, $post_data );
+ }
+
+ final public function get_display( $post ) {
+ if ( current_user_can( 'manage_options' ) ) {
+ return $this->display_deprecated( $post );
+ }
+
+ return '';
+ }
+
+ public function display_deprecated( $post ) {
+ return $this->get_link(
+ $this->get_share_url( $post->ID ),
+ sprintf( __( '%1$s has shut down', 'jetpack' ), $this->get_name() ),
+ sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $this->get_name() )
+ );
+ }
+}
+
+abstract class Sharing_Advanced_Source extends Sharing_Source {
+ public function has_advanced_options() {
+ return true;
+ }
+
+ abstract public function display_options();
+ abstract public function update_options( array $data );
+ abstract public function get_options();
+}
+
+class Share_Email extends Sharing_Source {
+ public $shortname = 'email';
+ public $icon = '\f410';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return _x( 'Email', 'as sharing source', 'jetpack' );
+ }
+
+ // Default does nothing
+ public function process_request( $post, array $post_data ) {
+ $ajax = false;
+ if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
+ $ajax = true;
+ }
+
+ $source_email = $target_email = $source_name = false;
+
+ if ( isset( $post_data['source_email'] ) && is_email( $post_data['source_email'] ) ) {
+ $source_email = $post_data['source_email'];
+ }
+
+ if ( isset( $post_data['target_email'] ) && is_email( $post_data['target_email'] ) ) {
+ $target_email = $post_data['target_email'];
+ }
+
+ if ( isset( $post_data['source_name'] ) && strlen( $post_data['source_name'] ) < 200 ) {
+ $source_name = $post_data['source_name'];
+ } elseif ( isset( $post_data['source_name'] ) ) {
+ $source_name = substr( $post_data['source_name'], 0, 200 );
+ } else {
+ $source_name = '';
+ }
+
+ // Test email
+ $error = 1; // Failure in data
+ if ( empty( $post_data['source_f_name'] ) && $source_email && $target_email && $source_name ) {
+ /**
+ * Allow plugins to stop the email sharing button from running the shared message through Akismet.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param bool true Should we check if the message isn't spam?
+ * @param object $post Post information.
+ * @param array $post_data Information about the shared message.
+ */
+ if ( apply_filters( 'sharing_email_check', true, $post, $post_data ) ) {
+ $data = array(
+ 'post' => $post,
+ 'source' => $source_email,
+ 'target' => $target_email,
+ 'name' => $source_name,
+ 'sharing_source' => $this,
+ );
+ // todo: implement an error message when email doesn't get sent.
+ /**
+ * Filter whether an email can be sent from the Email sharing button.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $data Array of information about the shared message.
+ */
+ if ( ( $data = apply_filters( 'sharing_email_can_send', $data ) ) !== false ) {
+ // Record stats
+ parent::process_request( $data['post'], $post_data );
+
+ /**
+ * Fires when an email is sent via the Email sharing button.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param array $data Array of information about the shared message.
+ */
+ do_action( 'sharing_email_send_post', $data );
+ }
+
+ // Return a positive regardless of whether the user is subscribed or not
+ if ( $ajax ) {
+?>
+<div class="response">
+ <div class="response-title"><?php _e( 'This post has been shared!', 'jetpack' ); ?></div>
+ <div class="response-sub"><?php printf( __( 'You have shared this post with %s', 'jetpack' ), esc_html( $target_email ) ); ?></div>
+ <div class="response-close"><a href="#" class="sharing_cancel"><?php _e( 'Close', 'jetpack' ); ?></a></div>
+</div>
+<?php
+ } else {
+ wp_safe_redirect( get_permalink( $post->ID ) . '?shared=email' );
+ }
+
+ die();
+ } else {
+ $error = 2; // Email check failed
+ }
+ }
+
+ if ( $ajax ) {
+ echo $error;
+ } else {
+ wp_safe_redirect( get_permalink( $post->ID ) . '?shared=email&msg=fail' );
+ }
+
+ die();
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Email', 'share to', 'jetpack' ), __( 'Click to email this to a friend', 'jetpack' ), 'share=email' );
+ }
+
+ /**
+ * Outputs the hidden email dialog
+ */
+ public function display_footer() {
+ global $current_user;
+
+ $visible = $status = false;
+?>
+ <div id="sharing_email" style="display: none;">
+ <form action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" method="post">
+ <label for="target_email"><?php _e( 'Send to Email Address', 'jetpack' ) ?></label>
+ <input type="email" name="target_email" id="target_email" value="" />
+
+ <?php if ( is_user_logged_in() ) : ?>
+ <input type="hidden" name="source_name" value="<?php echo esc_attr( $current_user->display_name ); ?>" />
+ <input type="hidden" name="source_email" value="<?php echo esc_attr( $current_user->user_email ); ?>" />
+ <?php else : ?>
+
+ <label for="source_name"><?php _e( 'Your Name', 'jetpack' ) ?></label>
+ <input type="text" name="source_name" id="source_name" value="" />
+
+ <label for="source_email"><?php _e( 'Your Email Address', 'jetpack' ) ?></label>
+ <input type="email" name="source_email" id="source_email" value="" />
+
+ <?php endif; ?>
+ <input type="text" id="jetpack-source_f_name" name="source_f_name" class="input" value="" size="25" autocomplete="off" title="<?php esc_attr_e( 'This field is for validation and should not be changed', 'jetpack' ); ?>" />
+ <?php
+ /**
+ * Fires when the Email sharing dialog is loaded.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ *
+ * @param string jetpack Eail sharing source.
+ */
+ do_action( 'sharing_email_dialog', 'jetpack' );
+ ?>
+
+ <img style="float: right; display: none" class="loading" src="<?php
+ /** This filter is documented in modules/stats.php */
+ echo apply_filters( 'jetpack_static_url', plugin_dir_url( __FILE__ ) . 'images/loading.gif' ); ?>" alt="loading" width="16" height="16" />
+ <input type="submit" value="<?php esc_attr_e( 'Send Email', 'jetpack' ); ?>" class="sharing_send" />
+ <a rel="nofollow" href="#cancel" class="sharing_cancel" role="button"><?php _e( 'Cancel', 'jetpack' ); ?></a>
+
+ <div class="errors errors-1" style="display: none;">
+ <?php _e( 'Post was not sent - check your email addresses!', 'jetpack' ); ?>
+ </div>
+
+ <div class="errors errors-2" style="display: none;">
+ <?php _e( 'Email check failed, please try again', 'jetpack' ); ?>
+ </div>
+
+ <div class="errors errors-3" style="display: none;">
+ <?php _e( 'Sorry, your blog cannot share posts by email.', 'jetpack' ); ?>
+ </div>
+ </form>
+ </div>
+<?php
+ }
+}
+
+class Share_Twitter extends Sharing_Source {
+ public $shortname = 'twitter';
+ public $icon = '\f202';
+ // 'https://dev.twitter.com/rest/reference/get/help/configuration' ( 2015/02/06 ) short_url_length is 22, short_url_length_https is 23
+ public $short_url_length = 24;
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Twitter', 'jetpack' );
+ }
+
+ /**
+ * Determine the Twitter 'via' value for a post.
+ *
+ * @param WP_Post|int $post Post object or post ID.
+ * @return string Twitter handle without the preceding @.
+ **/
+ public static function sharing_twitter_via( $post ) {
+ $post = get_post( $post );
+ /**
+ * Allow third-party plugins to customize the Twitter username used as "twitter:site" Twitter Card Meta Tag.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.0.0
+ *
+ * @param string $string Twitter Username.
+ * @param array $args Array of Open Graph Meta Tags and Twitter Cards tags.
+ */
+ $twitter_site_tag_value = apply_filters(
+ 'jetpack_twitter_cards_site_tag',
+ '',
+ /** This action is documented in modules/sharedaddy/sharing-sources.php */
+ array( 'twitter:creator' => apply_filters( 'jetpack_sharing_twitter_via', '', $post->ID ) )
+ );
+
+ /*
+ * Hack to remove the unwanted behavior of adding 'via @jetpack' which
+ * was introduced with the adding of the Twitter cards.
+ * This should be a temporary solution until a better method is setup.
+ */
+ if ( 'jetpack' == $twitter_site_tag_value ) {
+ $twitter_site_tag_value = '';
+ }
+
+ /**
+ * Filters the Twitter username used as "via" in the Twitter sharing button.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.7.0
+ *
+ * @param string $twitter_site_tag_value Twitter Username.
+ * @param int $post->ID Post ID.
+ */
+ $twitter_site_tag_value = apply_filters( 'jetpack_sharing_twitter_via', $twitter_site_tag_value, $post->ID );
+
+ // Strip out anything other than a letter, number, or underscore.
+ // This will prevent the inadvertent inclusion of an extra @, as well as normalizing the handle.
+ return preg_replace( '/[^\da-z_]+/i', '', $twitter_site_tag_value );
+ }
+
+ /**
+ * Determine the 'related' Twitter accounts for a post.
+ *
+ * @param WP_Post|int $post Post object or post ID.
+ * @return string Comma-separated list of Twitter handles.
+ **/
+ public static function get_related_accounts( $post ) {
+ $post = get_post( $post );
+ /**
+ * Filter the list of related Twitter accounts added to the Twitter sharing button.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.7.0
+ *
+ * @param array $args Array of Twitter usernames. Format is 'username' => 'Optional description'
+ * @param int $post->ID Post ID.
+ */
+ $related_accounts = apply_filters( 'jetpack_sharing_twitter_related', array(), $post->ID );
+
+ // Example related string: account1,account2:Account 2 description,account3
+ $related = array();
+
+ foreach ( $related_accounts as $related_account_username => $related_account_description ) {
+ // Join the description onto the end of the username
+ if ( $related_account_description ) {
+ $related_account_username .= ':' . $related_account_description;
+ }
+
+ $related[] = $related_account_username;
+ }
+
+ return implode( ',', $related );
+ }
+
+ public function get_display( $post ) {
+ $via = $this->sharing_twitter_via( $post );
+
+ if ( $via ) {
+ $via = 'data-via="' . esc_attr( $via ) . '"';
+ } else {
+ $via = '';
+ }
+
+ $related = $this->get_related_accounts( $post );
+ if ( ! empty( $related ) && $related !== $via ) {
+ $related = 'data-related="' . esc_attr( $related ) . '"';
+ } else {
+ $related = '';
+ }
+
+ if ( $this->smart ) {
+ $share_url = $this->get_share_url( $post->ID );
+ $post_title = $this->get_share_title( $post->ID );
+ return sprintf(
+ '<a href="https://twitter.com/share" class="twitter-share-button" data-url="%1$s" data-text="%2$s" %3$s %4$s>Tweet</a>',
+ esc_url( $share_url ),
+ esc_attr( $post_title ),
+ $via,
+ $related
+ );
+ } else {
+ if (
+ /**
+ * Allow plugins to disable sharing counts for specific sharing services.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.0.0
+ *
+ * @param bool true Should sharing counts be enabled for this specific service. Default to true.
+ * @param int $post->ID Post ID.
+ * @param string $str Sharing service name.
+ */
+ apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'twitter' )
+ ) {
+ sharing_register_post_for_share_counts( $post->ID );
+ }
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Twitter', 'share to', 'jetpack' ), __( 'Click to share on Twitter', 'jetpack' ), 'share=twitter', 'sharing-twitter-' . $post->ID );
+ }
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $post_title = $this->get_share_title( $post->ID );
+ $post_link = $this->get_share_url( $post->ID );
+
+ if ( function_exists( 'mb_stripos' ) ) {
+ $strlen = 'mb_strlen';
+ $substr = 'mb_substr';
+ } else {
+ $strlen = 'strlen';
+ $substr = 'substr';
+ }
+
+ $via = $this->sharing_twitter_via( $post );
+ $related = $this->get_related_accounts( $post );
+ if ( $via ) {
+ $sig = " via @$via";
+ if ( $related === $via ) {
+ $related = false;
+ }
+ } else {
+ $via = false;
+ $sig = '';
+ }
+
+ $suffix_length = $this->short_url_length + $strlen( $sig );
+ // $sig is handled by twitter in their 'via' argument.
+ // $post_link is handled by twitter in their 'url' argument.
+ if ( 280 < $strlen( $post_title ) + $suffix_length ) {
+ // The -1 is for "\xE2\x80\xA6", a UTF-8 ellipsis.
+ $text = $substr( $post_title, 0, 280 - $suffix_length - 1 ) . "\xE2\x80\xA6";
+ } else {
+ $text = $post_title;
+ }
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ $url = $post_link;
+ $twitter_url = add_query_arg(
+ rawurlencode_deep( array_filter( compact( 'via', 'related', 'text', 'url' ) ) ),
+ 'https://twitter.com/intent/tweet'
+ );
+
+ // Redirect to Twitter
+ wp_redirect( $twitter_url );
+ die();
+ }
+
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function display_footer() {
+ if ( $this->smart ) {
+ ?>
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
+ <?php
+ } else {
+ $this->js_dialog( $this->shortname, array( 'height' => 350 ) );
+ }
+ }
+}
+
+
+class Share_Reddit extends Sharing_Source {
+ public $shortname = 'reddit';
+ public $icon = '\f222';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Reddit', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart ) {
+ return '<div class="reddit_button"><iframe src="' . $this->http() . '://www.reddit.com/static/button/button1.html?newwindow=true&width=120&amp;url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&amp;title=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '" height="22" width="120" scrolling="no" frameborder="0"></iframe></div>';
+ } else {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Reddit', 'share to', 'jetpack' ), __( 'Click to share on Reddit', 'jetpack' ), 'share=reddit' );
+ }
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $reddit_url = $this->http() . '://reddit.com/submit?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Reddit
+ wp_redirect( $reddit_url );
+ die();
+ }
+}
+
+class Share_LinkedIn extends Sharing_Source {
+ public $shortname = 'linkedin';
+ public $icon = '\f207';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'LinkedIn', 'jetpack' );
+ }
+
+ public function has_custom_button_style() {
+ return $this->smart;
+ }
+
+ public function get_display( $post ) {
+ $display = '';
+
+ if ( $this->smart ) {
+ $share_url = $this->get_share_url( $post->ID );
+ $display .= sprintf( '<div class="linkedin_button"><script type="in/share" data-url="%s" data-counter="right"></script></div>', esc_url( $share_url ) );
+ } else {
+ $display = $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'LinkedIn', 'share to', 'jetpack' ), __( 'Click to share on LinkedIn', 'jetpack' ), 'share=linkedin', 'sharing-linkedin-' . $post->ID );
+ }
+
+ /** This filter is already documented in modules/sharedaddy/sharing-sources.php */
+ if ( apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'linkedin' ) ) {
+ sharing_register_post_for_share_counts( $post->ID );
+ }
+
+ return $display;
+ }
+
+ public function process_request( $post, array $post_data ) {
+
+ $post_link = $this->get_share_url( $post->ID );
+
+ // Using the same URL as the official button, which is *not* LinkedIn's documented sharing link
+ // https://www.linkedin.com/cws/share?url={url}&token=&isFramed=false
+ $linkedin_url = add_query_arg( array(
+ 'url' => rawurlencode( $post_link ),
+ ), 'https://www.linkedin.com/cws/share?token=&isFramed=false' );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to LinkedIn
+ wp_redirect( $linkedin_url );
+ die();
+ }
+
+ public function display_footer() {
+ if ( ! $this->smart ) {
+ $this->js_dialog( $this->shortname, array( 'width' => 580, 'height' => 450 ) );
+ } else {
+ ?><script type="text/javascript">
+ jQuery( document ).ready( function() {
+ jQuery.getScript( 'https://platform.linkedin.com/in.js?async=true', function success() {
+ IN.init();
+ });
+ });
+ jQuery( document.body ).on( 'post-load', function() {
+ if ( typeof IN != 'undefined' )
+ IN.parse();
+ });
+ </script><?php
+ }
+ }
+}
+
+class Share_Facebook extends Sharing_Source {
+ public $shortname = 'facebook';
+ public $icon = '\f204';
+ private $share_type = 'default';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['share_type'] ) ) {
+ $this->share_type = $settings['share_type'];
+ }
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Facebook', 'jetpack' );
+ }
+
+ public function display_header() {
+ }
+
+ function guess_locale_from_lang( $lang ) {
+ if ( 'en' == $lang || 'en_US' == $lang || ! $lang ) {
+ return 'en_US';
+ }
+
+ if ( ! class_exists( 'GP_Locales' ) ) {
+ if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
+ return false;
+ }
+
+ require JETPACK__GLOTPRESS_LOCALES_PATH;
+ }
+
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ // WP.com: get_locale() returns 'it'
+ $locale = GP_Locales::by_slug( $lang );
+ } else {
+ // Jetpack: get_locale() returns 'it_IT';
+ $locale = GP_Locales::by_field( 'wp_locale', $lang );
+ }
+
+ if ( ! $locale ) {
+ return false;
+ }
+
+ if ( empty( $locale->facebook_locale ) ) {
+ if ( empty( $locale->wp_locale ) ) {
+ return false;
+ } else {
+ // Facebook SDK is smart enough to fall back to en_US if a
+ // locale isn't supported. Since supported Facebook locales
+ // can fall out of sync, we'll attempt to use the known
+ // wp_locale value and rely on said fallback.
+ return $locale->wp_locale;
+ }
+ }
+
+ return $locale->facebook_locale;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart ) {
+ $share_url = $this->get_share_url( $post->ID );
+ $fb_share_html = '<div class="fb-share-button" data-href="' . esc_attr( $share_url ) . '" data-layout="button_count"></div>';
+ /**
+ * Filter the output of the Facebook Sharing button.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.6.0
+ *
+ * @param string $fb_share_html Facebook Sharing button HTML.
+ * @param string $share_url URL of the post to share.
+ */
+ return apply_filters( 'jetpack_sharing_facebook_official_button_output', $fb_share_html, $share_url );
+ }
+
+ /** This filter is already documented in modules/sharedaddy/sharing-sources.php */
+ if ( apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'facebook' ) ) {
+ sharing_register_post_for_share_counts( $post->ID );
+ }
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Facebook', 'share to', 'jetpack' ), __( 'Click to share on Facebook', 'jetpack' ), 'share=facebook', 'sharing-facebook-' . $post->ID );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $fb_url = $this->http() . '://www.facebook.com/sharer.php?u=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&t=' . rawurlencode( $this->get_share_title( $post->ID ) );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Facebook
+ wp_redirect( $fb_url );
+ die();
+ }
+
+ public function display_footer() {
+ $this->js_dialog( $this->shortname );
+ if ( $this->smart ) {
+ $locale = $this->guess_locale_from_lang( get_locale() );
+ if ( ! $locale ) {
+ $locale = 'en_US';
+ }
+ /**
+ * Filter the App ID used in the official Facebook Share button.
+ *
+ * @since 3.8.0
+ *
+ * @param int $fb_app_id Facebook App ID. Default to 249643311490 (WordPress.com's App ID).
+ */
+ $fb_app_id = apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' );
+ if ( is_numeric( $fb_app_id ) ) {
+ $fb_app_id = '&appId=' . $fb_app_id;
+ } else {
+ $fb_app_id = '';
+ }
+ ?><div id="fb-root"></div>
+ <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = 'https://connect.facebook.net/<?php echo $locale; ?>/sdk.js#xfbml=1<?php echo $fb_app_id; ?>&version=v2.3'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
+ <script>
+ jQuery( document.body ).on( 'post-load', function() {
+ if ( 'undefined' !== typeof FB ) {
+ FB.XFBML.parse();
+ }
+ } );
+ </script>
+ <?php
+ }
+ }
+}
+
+class Share_Print extends Sharing_Source {
+ public $shortname = 'print';
+ public $icon = '\f469';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Print', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( $this->get_process_request_url( $post->ID ) . ( ( is_single() || is_page() ) ? '#print': '' ), _x( 'Print', 'share to', 'jetpack' ), __( 'Click to print', 'jetpack' ) );
+ }
+}
+
+class Share_PressThis extends Sharing_Source {
+ public $shortname = 'pressthis';
+ public $icon = '\f205';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Press This', 'jetpack' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ global $current_user;
+
+ $primary_blog = (int) get_user_meta( $current_user->ID, 'primary_blog', true );
+ if ( $primary_blog ) {
+ $primary_blog_details = get_blog_details( $primary_blog );
+ } else {
+ $primary_blog_details = false;
+ }
+
+ if ( $primary_blog_details ) {
+ $blogs = array( $primary_blog_details );
+ } elseif ( function_exists( 'get_active_blogs_for_user' ) ) {
+ $blogs = get_active_blogs_for_user();
+ if ( empty( $blogs ) ) {
+ $blogs = get_blogs_of_user( $current_user->ID );
+ }
+ } else {
+ $blogs = get_blogs_of_user( $current_user->ID );
+ }
+
+ if ( empty( $blogs ) ) {
+ wp_safe_redirect( get_permalink( $post->ID ) );
+ die();
+ }
+
+ $blog = current( $blogs );
+
+ $args = array(
+ 'u' => rawurlencode( $this->get_share_url( $post->ID ) ),
+ );
+
+ $args[ 'url-scan-submit' ] = 'Scan';
+ $args[ '_wpnonce' ] = wp_create_nonce( 'scan-site' );
+
+ $url = $blog->siteurl . '/wp-admin/press-this.php';
+ $url = add_query_arg( $args, $url );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Press This
+ wp_redirect( $url );
+ die();
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Press This', 'share to', 'jetpack' ), __( 'Click to Press This!', 'jetpack' ), 'share=press-this' );
+ }
+}
+
+class Share_Custom extends Sharing_Advanced_Source {
+ private $name;
+ private $icon;
+ private $url;
+ public $smart = true;
+ public $shortname;
+
+ public function get_class() {
+ return 'custom share-custom-' . sanitize_html_class( strtolower( $this->name ) );
+ }
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ $opts = $this->get_options();
+
+ if ( isset( $settings['name'] ) ) {
+ $this->name = $settings['name'];
+ $this->shortname = preg_replace( '/[^a-z0-9]*/', '', $settings['name'] );
+ }
+
+ if ( isset( $settings['icon'] ) ) {
+ $this->icon = $settings['icon'];
+
+ $new_icon = esc_url_raw( wp_specialchars_decode( $this->icon, ENT_QUOTES ) );
+ $i = 0;
+ while ( $new_icon != $this->icon ) {
+ if ( $i > 5 ) {
+ $this->icon = false;
+ break;
+ } else {
+ $this->icon = $new_icon;
+ $new_icon = esc_url_raw( wp_specialchars_decode( $this->icon, ENT_QUOTES ) );
+ }
+ $i++;
+ }
+ }
+
+ if ( isset( $settings['url'] ) ) {
+ $this->url = $settings['url'];
+ }
+ }
+
+ public function get_name() {
+ return $this->name;
+ }
+
+ public function get_display( $post ) {
+ $str = $this->get_link( $this->get_process_request_url( $post->ID ), esc_html( $this->name ), sprintf( __( 'Click to share on %s', 'jetpack' ), esc_attr( $this->name ) ), 'share=' . $this->id );
+ return str_replace( '<span>', '<span style="' . esc_attr( 'background-image:url("' . addcslashes( esc_url_raw( $this->icon ), '"' ) . '");' ) . '">', $str );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $url = str_replace( '&amp;', '&', $this->url );
+ $url = str_replace( '%post_id%', rawurlencode( $post->ID ), $url );
+ $url = str_replace( '%post_url%', rawurlencode( $this->get_share_url( $post->ID ) ), $url );
+ $url = str_replace( '%post_full_url%', rawurlencode( get_permalink( $post->ID ) ), $url );
+ $url = str_replace( '%post_title%', rawurlencode( $this->get_share_title( $post->ID ) ), $url );
+ $url = str_replace( '%home_url%', rawurlencode( home_url() ), $url );
+ $url = str_replace( '%post_slug%', rawurlencode( $post->post_name ), $url );
+
+ if ( strpos( $url, '%post_tags%' ) !== false ) {
+ $tags = get_the_tags( $post->ID );
+ $tagged = '';
+
+ if ( $tags ) {
+ $tagged_raw = array();
+ foreach ( $tags as $tag ) {
+ $tagged_raw[] = rawurlencode( $tag->name );
+ }
+
+ $tagged = implode( ',', $tagged_raw );
+ }
+
+ $url = str_replace( '%post_tags%', $tagged, $url );
+ }
+
+ if ( strpos( $url, '%post_excerpt%' ) !== false ) {
+ $url_excerpt = $post->post_excerpt;
+ if ( empty( $url_excerpt ) ) {
+ $url_excerpt = $post->post_content;
+ }
+
+ $url_excerpt = strip_tags( strip_shortcodes( $url_excerpt ) );
+ $url_excerpt = wp_html_excerpt( $url_excerpt, 100 );
+ $url_excerpt = rtrim( preg_replace( '/[^ .]*$/', '', $url_excerpt ) );
+ $url = str_replace( '%post_excerpt%', rawurlencode( $url_excerpt ), $url );
+ }
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect
+ wp_redirect( $url );
+ die();
+ }
+
+ public function display_options() {
+?>
+<div class="input">
+ <table class="form-table">
+ <tbody>
+ <tr>
+ <th scope="row"><?php _e( 'Label', 'jetpack' ); ?></th>
+ <td><input type="text" name="name" value="<?php echo esc_attr( $this->name ); ?>" /></td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e( 'URL', 'jetpack' ); ?></th>
+ <td><input type="text" name="url" value="<?php echo esc_attr( $this->url ); ?>" /></td>
+ </tr>
+
+ <tr>
+ <th scope="row"><?php _e( 'Icon', 'jetpack' ); ?></th>
+ <td><input type="text" name="icon" value="<?php echo esc_attr( $this->icon ); ?>" /></td>
+ </tr>
+
+ <tr>
+ <th scope="row"></th>
+ <td>
+ <input class="button-secondary" type="submit" value="<?php esc_attr_e( 'Save', 'jetpack' ); ?>" />
+ <a href="#" class="remove"><small><?php _e( 'Remove Service', 'jetpack' ); ?></small></a>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<?php
+ }
+
+ public function update_options( array $data ) {
+ $name = trim( wp_html_excerpt( wp_kses( stripslashes( $data['name'] ), array() ), 30 ) );
+ $url = trim( esc_url_raw( $data['url'] ) );
+ $icon = trim( esc_url_raw( $data['icon'] ) );
+
+ if ( $name ) {
+ $this->name = $name;
+ }
+
+ if ( $url ) {
+ $this->url = $url;
+ }
+
+ if ( $icon ) {
+ $this->icon = $icon;
+ }
+ }
+
+ public function get_options() {
+ return array(
+ 'name' => $this->name,
+ 'icon' => $this->icon,
+ 'url' => $this->url,
+ );
+ }
+
+ public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
+ $opts = $this->get_options();
+
+ $text = '&nbsp;';
+ if ( ! $this->smart ) {
+ if ( $this->button_style != 'icon' ) {
+ $text = $this->get_name();
+ }
+ }
+
+ $klasses = array( 'share-' . $this->shortname );
+
+ if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' ) {
+ $klasses[] = 'share-icon';
+ }
+
+ if ( $this->button_style == 'icon' ) {
+ $text = '';
+ $klasses[] = 'no-text';
+ }
+
+ if ( $this->button_style == 'text' ) {
+ $klasses[] = 'no-icon';
+ }
+
+ $link = sprintf(
+ '<a rel="nofollow" class="%s" href="javascript:void(0)" title="%s"><span style="background-image:url(&quot;%s&quot;) !important;background-position:left center;background-repeat:no-repeat;">%s</span></a>',
+ implode( ' ', $klasses ),
+ $this->get_name(),
+ addcslashes( esc_url_raw( $opts['icon'] ), '"' ),
+ $text
+ );
+ ?>
+ <div class="option option-smart-off">
+ <?php echo $link ; ?>
+ </div><?php
+ }
+}
+
+class Share_Tumblr extends Sharing_Source {
+ public $shortname = 'tumblr';
+ public $icon = '\f214';
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Tumblr', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart ) {
+ $target = '';
+ if ( true == $this->open_link_in_new ) {
+ $target = '_blank';
+ }
+
+ /**
+ * If we are looking at a single post, let Tumblr figure out the post type (text, photo, link, quote, chat, or video)
+ * based on the content available on the page.
+ * If we are not looking at a single post, content from other posts can appear on the page and Tumblr will pick that up.
+ * In this case, we want Tumblr to focus on our current post, so we will limit the post type to link, where we can give Tumblr a link to our post.
+ */
+ if ( ! is_single() ) {
+ $posttype = 'data-posttype="link"';
+ } else {
+ $posttype = '';
+ }
+
+ // Documentation: https://www.tumblr.com/docs/en/share_button
+ return sprintf(
+ '<a class="tumblr-share-button" target="%1$s" href="%2$s" data-title="%3$s" data-content="%4$s" title="%5$s"%6$s>%5$s</a>',
+ $target,
+ 'https://www.tumblr.com/share',
+ $this->get_share_title( $post->ID ),
+ $this->get_share_url( $post->ID ),
+ __( 'Share on Tumblr', 'jetpack' ),
+ $posttype
+ );
+ } else {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' );
+ }
+ }
+
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Tumblr's sharing endpoint (a la their bookmarklet)
+ $url = 'https://www.tumblr.com/share?v=3&u=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&t=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '&s=';
+ wp_redirect( $url );
+ die();
+ }
+
+ public function display_footer() {
+ if ( $this->smart ) {
+ ?><script id="tumblr-js" type="text/javascript" src="https://assets.tumblr.com/share-button.js"></script><?php
+ } else {
+ $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ }
+ }
+}
+
+class Share_Pinterest extends Sharing_Source {
+ public $shortname = 'pinterest';
+ public $icon = '\f209';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Pinterest', 'jetpack' );
+ }
+
+ public function get_image( $post ) {
+ if ( class_exists( 'Jetpack_PostImages' ) ) {
+ $image = Jetpack_PostImages::get_image( $post->ID, array( 'fallback_to_avatars' => true ) );
+ if ( ! empty( $image ) ) {
+ return $image['src'];
+ }
+ }
+
+ /**
+ * Filters the default image used by the Pinterest Pin It share button.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.6.0
+ *
+ * @param string $url Default image URL.
+ */
+ return apply_filters( 'jetpack_sharing_pinterest_default_image', 'https://s0.wp.com/i/blank.jpg' );
+ }
+
+ public function get_external_url( $post ) {
+ $url = 'https://www.pinterest.com/pin/create/button/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&media=' . rawurlencode( $this->get_image( $post ) ) . '&description=' . rawurlencode( $post->post_title );
+
+ /**
+ * Filters the Pinterest share URL used in sharing button output.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.6.0
+ *
+ * @param string $url Pinterest share URL.
+ */
+ return apply_filters( 'jetpack_sharing_pinterest_share_url', $url );
+ }
+
+ public function get_widget_type() {
+ /**
+ * Filters the Pinterest widget type.
+ *
+ * @see https://business.pinterest.com/en/widget-builder
+ *
+ * @module sharedaddy
+ *
+ * @since 3.6.0
+ *
+ * @param string $type Pinterest widget type. Default of 'buttonPin' for single-image selection. 'buttonBookmark' for multi-image modal.
+ */
+ return apply_filters( 'jetpack_sharing_pinterest_widget_type', 'buttonPin' );
+ }
+
+ public function get_display( $post ) {
+ $display = '';
+
+ if ( $this->smart ) {
+ $display = sprintf(
+ '<div class="pinterest_button"><a href="%s" data-pin-do="%s" data-pin-config="beside"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a></div>',
+ esc_url( $this->get_external_url( $post ) ),
+ esc_attr( $this->get_widget_type() )
+ );
+ } else {
+ $display = $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Pinterest', 'share to', 'jetpack' ), __( 'Click to share on Pinterest', 'jetpack' ), 'share=pinterest', 'sharing-pinterest-' . $post->ID );
+ }
+
+ /** This filter is already documented in modules/sharedaddy/sharing-sources.php */
+ if ( apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'linkedin' ) ) {
+ sharing_register_post_for_share_counts( $post->ID );
+ }
+
+ return $display;
+ }
+
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+ // If we're triggering the multi-select panel, then we don't need to redirect to Pinterest
+ if ( ! isset( $_GET['js_only'] ) ) {
+ $pinterest_url = esc_url_raw( $this->get_external_url( $post ) );
+ wp_redirect( $pinterest_url );
+ } else {
+ echo '// share count bumped';
+ }
+ die();
+ }
+
+ public function display_footer() {
+ /**
+ * Filter the Pin it button appearing when hovering over images when using the official button style.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.6.0
+ *
+ * @param bool $jetpack_pinit_over True by default, displays the Pin it button when hovering over images.
+ */
+ $jetpack_pinit_over = apply_filters( 'jetpack_pinit_over_button', true );
+ ?>
+ <?php if ( $this->smart ) : ?>
+ <script type="text/javascript">
+ // Pinterest shared resources
+ var s = document.createElement("script");
+ s.type = "text/javascript";
+ s.async = true;
+ <?php if ( $jetpack_pinit_over ) {
+ echo "s.setAttribute('data-pin-hover', true);";
+ } ?>
+ s.src = window.location.protocol + "//assets.pinterest.com/js/pinit.js";
+ var x = document.getElementsByTagName("script")[0];
+ x.parentNode.insertBefore(s, x);
+ // if 'Pin it' button has 'counts' make container wider
+ jQuery(window).load( function(){ jQuery( 'li.share-pinterest a span:visible' ).closest( '.share-pinterest' ).width( '80px' ); } );
+ </script>
+ <?php elseif ( 'buttonPin' != $this->get_widget_type() ) : ?>
+ <script type="text/javascript">
+ jQuery(document).ready( function(){
+ jQuery('body').on('click', 'a.share-pinterest', function(e){
+ e.preventDefault();
+ // Load Pinterest Bookmarklet code
+ var s = document.createElement("script");
+ s.type = "text/javascript";
+ s.src = window.location.protocol + "//assets.pinterest.com/js/pinmarklet.js?r=" + ( Math.random() * 99999999 );
+ var x = document.getElementsByTagName("script")[0];
+ x.parentNode.insertBefore(s, x);
+ // Trigger Stats
+ var s = document.createElement("script");
+ s.type = "text/javascript";
+ s.src = this + ( this.toString().indexOf( '?' ) ? '&' : '?' ) + 'js_only=1';
+ var x = document.getElementsByTagName("script")[0];
+ x.parentNode.insertBefore(s, x);
+ });
+ });
+ </script>
+ <?php endif;
+ }
+}
+
+class Share_Pocket extends Sharing_Source {
+ public $shortname = 'pocket';
+ public $icon = '\f224';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+ }
+
+ public function get_name() {
+ return __( 'Pocket', 'jetpack' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ $pocket_url = esc_url_raw( 'https://getpocket.com/save/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) ) );
+ wp_redirect( $pocket_url );
+ exit;
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart ) {
+ $post_count = 'horizontal';
+
+ $button = '';
+ $button .= '<div class="pocket_button">';
+ $button .= sprintf( '<a href="https://getpocket.com/save" class="pocket-btn" data-lang="%s" data-save-url="%s" data-pocket-count="%s" >%s</a>', 'en', esc_attr( $this->get_share_url( $post->ID ) ), $post_count, esc_attr__( 'Pocket', 'jetpack' ) );
+ $button .= '</div>';
+
+ return $button;
+ } else {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Pocket', 'share to', 'jetpack' ), __( 'Click to share on Pocket', 'jetpack' ), 'share=pocket' );
+ }
+
+ }
+
+ function display_footer() {
+ if ( $this->smart ) :
+ ?>
+ <script>
+ // Don't use Pocket's default JS as it we need to force init new Pocket share buttons loaded via JS.
+ function jetpack_sharing_pocket_init() {
+ jQuery.getScript( 'https://widgets.getpocket.com/v1/j/btn.js?v=1' );
+ }
+ jQuery( document ).ready( jetpack_sharing_pocket_init );
+ jQuery( document.body ).on( 'post-load', jetpack_sharing_pocket_init );
+ </script>
+ <?php
+ else :
+ $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ endif;
+
+ }
+
+}
+
+class Share_Telegram extends Sharing_Source {
+ public $shortname = 'telegram';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+ }
+
+ public function get_name() {
+ return __( 'Telegram', 'jetpack' );
+ }
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+ $telegram_url = esc_url_raw( 'https://telegram.me/share/url?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&text=' . rawurlencode( $this->get_share_title( $post->ID ) ) );
+ wp_redirect( $telegram_url );
+ exit;
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Telegram', 'share to', 'jetpack' ), __( 'Click to share on Telegram', 'jetpack' ), 'share=telegram' );
+ }
+
+ function display_footer() {
+ $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ }
+}
+
+class Jetpack_Share_WhatsApp extends Sharing_Source {
+ public $shortname = 'jetpack-whatsapp';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+ }
+
+ public function get_name() {
+ return __( 'WhatsApp', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ), 'share=jetpack-whatsapp' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+ $url = 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) . ' ' . $this->get_share_url( $post->ID ) );
+ wp_redirect( $url );
+ exit;
+ }
+}
+
+class Share_Skype extends Sharing_Source {
+ public $shortname = 'skype';
+ public $icon = '\f220';
+ private $share_type = 'default';
+
+ public function __construct( $id, array $settings ) {
+ parent::__construct( $id, $settings );
+
+ if ( isset( $settings['share_type'] ) ) {
+ $this->share_type = $settings['share_type'];
+ }
+
+ if ( 'official' == $this->button_style ) {
+ $this->smart = true;
+ } else {
+ $this->smart = false;
+ }
+
+ }
+
+ public function get_name() {
+ return __( 'Skype', 'jetpack' );
+ }
+
+ public function get_display( $post ) {
+ if ( $this->smart ) {
+ $skype_share_html = sprintf(
+ '<div class="skype-share" data-href="%1$s" data-lang="%2$s" data-style="small" data-source="jetpack" ></div>',
+ esc_attr( $this->get_share_url( $post->ID ) ),
+ 'en-US'
+ );
+ return $skype_share_html;
+ }
+
+ /** This filter is already documented in modules/sharedaddy/sharing-sources.php */
+ if ( apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'skype' ) ) {
+ sharing_register_post_for_share_counts( $post->ID );
+ }
+ return $this->get_link(
+ $this->get_process_request_url( $post->ID ), _x( 'Skype', 'share to', 'jetpack' ), __( 'Click to share on Skype', 'jetpack' ), 'share=skype', 'sharing-skype-' . $post->ID );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ $skype_url = sprintf(
+ 'https://web.skype.com/share?url=%1$s&lang=%2$s=&source=jetpack',
+ rawurlencode( $this->get_share_url( $post->ID ) ),
+ 'en-US'
+ );
+
+ // Record stats
+ parent::process_request( $post, $post_data );
+
+ // Redirect to Skype
+ wp_redirect( $skype_url );
+ die();
+ }
+
+ public function display_footer() {
+ if ( $this->smart ) :
+ ?>
+ <script>
+ (function(r, d, s) {
+ r.loadSkypeWebSdkAsync = r.loadSkypeWebSdkAsync || function(p) {
+ var js, sjs = d.getElementsByTagName(s)[0];
+ if (d.getElementById(p.id)) { return; }
+ js = d.createElement(s);
+ js.id = p.id;
+ js.src = p.scriptToLoad;
+ js.onload = p.callback
+ sjs.parentNode.insertBefore(js, sjs);
+ };
+ var p = {
+ scriptToLoad: 'https://swx.cdn.skype.com/shared/v/latest/skypewebsdk.js',
+ id: 'skype_web_sdk'
+ };
+ r.loadSkypeWebSdkAsync(p);
+ })(window, document, 'script');
+ </script>
+ <?php
+ else :
+ $this->js_dialog( $this->shortname, array( 'width' => 305, 'height' => 665 ) );
+ endif;
+ }
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.css b/plugins/jetpack/modules/sharedaddy/sharing.css
new file mode 100644
index 00000000..7481f416
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing.css
@@ -0,0 +1,755 @@
+/**
+ * Sharedaddy Base Styles
+ *
+ * Contains styles for modules, containers, buttons
+ */
+
+
+/* Master container */
+#jp-post-flair {
+ padding-top: .5em;
+}
+
+
+/* Overall Sharedaddy block title */
+div.sharedaddy,
+#content div.sharedaddy,
+#main div.sharedaddy {
+ clear: both;
+}
+
+div.sharedaddy h3.sd-title {
+ margin: 0 0 1em 0;
+ display: inline-block;
+ line-height: 1.2;
+ font-size: 9pt;
+ font-weight: bold;
+}
+
+div.sharedaddy h3.sd-title:before {
+ content: "";
+ display: block;
+ width: 100%;
+ min-width: 30px;
+ border-top: 1px solid #ddd;
+ margin-bottom: 1em;
+}
+
+body.highlander-light h3.sd-title:before {
+ border-top: 1px solid rgba(0,0,0,.2);
+}
+
+body.highlander-dark h3.sd-title:before {
+ border-top: 1px solid rgba(255,255,255,.4);
+}
+
+
+/* Sharing services list */
+.sd-content ul {
+ padding: 0 !important;
+ margin: 0 0 .7em 0 !important;
+ list-style: none !important;
+}
+
+.sd-content ul li {
+ display: inline-block;
+}
+
+.sd-content ul li.share-deprecated {
+ opacity: 0.5;
+}
+
+.sd-content ul li.share-deprecated a span {
+ text-decoration: line-through;
+}
+
+.sd-block.sd-gplus {
+ margin: 0 0 .5em 0;
+}
+
+.sd-gplus .sd-content {
+ font-size: 12px;
+}
+
+
+/* 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: 12px;
+ font-family: "Open Sans", sans-serif;
+ font-weight: normal;
+ border-radius: 3px;
+ color: #545454 !important;
+ background: #f8f8f8;
+ border: 1px solid #cccccc;
+ box-shadow: 0 1px 0 rgba(0,0,0,.08);
+ text-shadow: none;
+ line-height: 23px;
+ padding: 1px 8px 0px 5px;
+}
+
+.sd-social-text .sd-content ul li a.sd-button span,
+.sd-content ul li a.sd-button>span,
+.sd-content ul li .option a.share-ustom span, /* Ugh. */
+.sd-content ul li.preview-item div.option.option-smart-off a span,
+.sd-content ul li.advanced a.share-more span,
+.sd-social-icon-text .sd-content ul li a.sd-button>span,
+.sd-social-official .sd-content>ul>li>a.sd-button span,
+.sd-social-official .sd-content>ul>li .digg_button >a span { /* official Digg button no longer works, needs cleaning */
+ line-height: 23px;
+}
+
+
+
+/* Our gray buttons should be smaller when seen with the official ones */
+.sd-social-official .sd-content>ul>li>a.sd-button,
+.sd-social-official .sd-content .sharing-hidden .inner>ul>li>a.sd-button,
+.sd-social-official .sd-content>ul>li .digg_button>a,
+.sd-social-official .sd-content .sharing-hidden .inner>ul>li .digg_button>a {
+ line-height: 17px;
+ box-shadow: none; /* No shadow on gray buttons between the official ones */
+ vertical-align: top;
+}
+
+.sd-social-official .sd-content ul li a.sd-button>span {
+ line-height: 17px;
+}
+.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 {
+ color: #555;
+ background: #fafafa;
+ border: 1px solid #999999;
+}
+
+.sd-social-icon .sd-content ul li a.sd-button:active,
+.sd-social-text .sd-content ul li a.sd-button:active,
+.sd-social-icon-text .sd-content ul li a.sd-button:active,
+.sd-social-official .sd-content>ul>li>a.sd-button:active,
+.sd-social-official .sd-content>ul>li .digg_button>a:active {
+ box-shadow: inset 0 1px 0 rgba(0,0,0,.16);
+}
+
+/* All icons */
+.sd-content ul li a.sd-button:before {
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ font: normal 18px/1 'social-logos';
+ vertical-align: top;
+ text-align: center;
+}
+/* text + icon styles should have relative and top position */
+.sd-social-icon-text ul li a.sd-button:before {
+ position: relative;
+ top: 2px;
+}
+
+/* Make it look great in Chrome and Safari */
+@media screen and (-webkit-min-device-pixel-ratio:0) {
+ .sd-content ul li a.sd-button:before {
+ position: relative;
+ top: 2px;
+ }
+}
+
+.sd-social-official ul li a.sd-button:before {
+ position: relative;
+ top: -2px;
+}
+/* Make it look great in Chrome and Safari */
+@media screen and (-webkit-min-device-pixel-ratio:0) {
+ .sd-social-official ul li a.sd-button:before {
+ top: 0px;
+ }
+}
+
+.sd-content ul li {
+ margin: 0 5px 5px 0;
+ padding: 0;
+}
+/* Add more pading on touch devices */
+.jp-sharing-input-touch .sd-content ul li { padding-left: 10px; }
+
+/* Text + icon & Official */
+.sd-social-icon-text .sd-content ul li a span,
+.sd-social-official .sd-content ul li a.sd-button span,
+.sd-content ul li.preview-item a.sd-button span {
+ margin-left: 3px;
+}
+.sd-content ul li.preview-item.no-icon a.sd-button span {
+ margin-left: 0;
+}
+
+/* Text only */
+.sd-social-text .sd-content ul li a:before,
+.sd-content ul li.no-icon a:before {
+ display: none;
+}
+body .sd-social-text .sd-content ul li.share-custom a span,
+body .sd-content ul li.share-custom.no-icon a span {
+ background-image: none;
+ background-position: -500px -500px !important; /* hack to work around !important inline style */
+ background-repeat: no-repeat !important;
+ padding-left: 0;
+ height: 0;
+ line-height: inherit;
+}
+
+.sd-social-icon .sd-content ul li a.share-more {
+ position: relative;
+ top: -4px;
+}
+@media screen and (-webkit-min-device-pixel-ratio:0) {
+ .sd-social-icon .sd-content ul li a.share-more {
+ top: 2px;
+ }
+}
+/* Firefox specific hack to make the share more button look better on Firefox. */
+@-moz-document url-prefix() {
+ .sd-social-icon .sd-content ul li a.share-more {
+ top: 2px;
+ }
+}
+
+.sd-social-icon .sd-content ul li a.share-more span {
+ margin-left: 3px;
+}
+
+
+/* Individual icons */
+.sd-social-icon .sd-content ul li.share-print a:before,
+.sd-social-text .sd-content ul li.share-print a:before,
+.sd-content ul li.share-print div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-print a:before,
+.sd-social-official .sd-content li.share-print a:before {
+ content: '\f469';
+}
+
+.sd-social-icon .sd-content ul li.share-email a:before,
+.sd-social-text .sd-content ul li.share-email a:before,
+.sd-content ul li.share-email div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-email a:before,
+.sd-social-official .sd-content li.share-email a:before {
+ content: '\f410';
+}
+.sd-social-icon .sd-content ul li.share-linkedin a:before,
+.sd-social-text .sd-content ul li.share-linkedin a:before,
+.sd-content ul li.share-linkedin div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-linkedin a:before {
+ content: '\f207';
+}
+.sd-social-icon .sd-content ul li.share-twitter a:before,
+.sd-social-text .sd-content ul li.share-twitter a:before,
+.sd-content ul li.share-twitter div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-twitter a:before {
+ content: '\f202';
+}
+.sd-social-icon .sd-content ul li.share-reddit a:before,
+.sd-social-text .sd-content ul li.share-reddit a:before,
+.sd-content ul li.share-reddit div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-reddit a:before {
+ content: '\f222';
+}
+.sd-social-icon .sd-content ul li.share-tumblr a:before,
+.sd-social-text .sd-content ul li.share-tumblr a:before,
+.sd-content ul li.share-tumblr div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-tumblr a:before {
+ content: '\f607';
+}
+
+.sd-social-icon .sd-content ul li.share-pocket a:before,
+.sd-social-text .sd-content ul li.share-pocket a:before,
+.sd-content ul li.share-pocket div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-pocket a:before {
+ content: '\f224';
+}
+.sd-social-icon .sd-content ul li.share-pinterest a:before,
+.sd-social-text .sd-content ul li.share-pinterest a:before,
+.sd-content ul li.share-pinterest div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-pinterest a:before {
+ content: '\f210';
+}
+.sd-social-icon .sd-content ul li.share-facebook a:before,
+.sd-social-text .sd-content ul li.share-facebook a:before,
+.sd-content ul li.share-facebook div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-facebook a:before {
+ content: '\f203';
+}
+.sd-social-icon .sd-content ul li.share-press-this a:before,
+.sd-social-text .sd-content ul li.share-press-this a:before,
+.sd-content ul li.share-press-this div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-press-this a:before,
+.sd-social-official .sd-content li.share-press-this a:before {
+ content: '\f205';
+}
+.sd-social-official .sd-content li.share-press-this a:before {
+ color: #2ba1cb;
+}
+.sd-social-icon .sd-content ul li.share-telegram a:before,
+.sd-social-text .sd-content ul li.share-telegram a:before,
+.sd-content ul li.share-telegram div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-telegram a:before,
+.sd-social-official .sd-content li.share-telegram a:before {
+ content: '\f606';
+}
+.sd-social-official .sd-content li.share-telegram a:before {
+ color: #0088cc;
+}
+.sd-social-icon .sd-content ul li.share-skype a:before,
+.sd-social-text .sd-content ul li.share-skype a:before,
+.sd-content ul li.share-skype div.option.option-smart-off a:before,
+.sd-social-icon-text .sd-content li.share-skype a:before {
+ content: '\f220';
+}
+.sd-social-icon .sd-content ul 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-deprecated a:before,
+.sd-social-icon-text .sd-content li.share-deprecated a:before,
+.sd-social-official .sd-content li.share-deprecated a:before,
+.sd-content ul li.share-deprecated div.option.option-smart-off a:before {
+ width: 1em;
+ height: 1em;
+ content: "\1F6AB";
+}
+
+/* Share count */
+.sd-social .sd-button .share-count {
+ background: #2ea2cc;
+ color: #fff;
+ -moz-border-radius: 10px;
+ border-radius: 10px;
+ display: inline-block;
+ text-align: center;
+ font-size: 10px;
+ padding: 1px 3px;
+ line-height: 1;
+}
+
+
+/* Official buttons */
+.sd-social-official .sd-content ul, .sd-social-official .sd-content ul li {
+ line-height: 25px !important;
+}
+
+.sd-social-official .sd-content>ul>li>a.sd-button span {
+ line-height: 1;
+}
+
+.sd-social-official .sd-content ul:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+}
+
+.sd-social-official .sd-content li.share-press-this a {
+ margin: 0 0 5px 0;
+}
+
+.sd-social-official .sd-content ul>li {
+ display: block;
+ float: left;
+ margin: 0 10px 5px 0 !important;
+ height: 25px;
+}
+
+.sd-social-official .fb-share-button > span {
+ vertical-align: top !important;
+}
+
+.sd-social-official .sd-content .pocket_button iframe {
+ width: 98px;
+}
+
+
+/* Individual official buttons */
+.reddit_button iframe {
+ margin-top: 1px;
+}
+
+.pocket_button iframe, .pinterest_button, .twitter_button, .linkedin_button>span {
+ margin: 0 !important;
+}
+
+.linkedin_button>span, .pinterest_button a {
+ display: block !important;
+}
+
+.sd-social-official .sd-content .share-skype {
+ width: 55px;
+}
+
+body .sd-social-official li.share-print ,
+body .sd-social-official li.share-email a,
+body .sd-social-official li.share-custom a,
+body .sd-social-official li a.share-more,
+body .sd-social-official li.share-digg a,
+body .sd-social-official li.share-press-this a
+{
+ position: relative;
+ top: 0;
+}
+
+
+/* Custom icons */
+body .sd-social-icon .sd-content li.share-custom>a {
+ padding: 2px 3px 0 3px;
+ position: relative;
+ top: 4px;
+}
+
+body .sd-social-icon .sd-content li.share-custom a span,
+body .sd-social-icon-text .sd-content li.share-custom a span,
+body .sd-social-text .sd-content li.share-custom a span,
+body .sd-social-official .sd-content li.share-custom a span,
+body .sd-content ul li.share-custom a.share-icon span
+{
+ background-size: 16px 16px;
+ background-repeat: no-repeat;
+ margin-left: 0;
+ padding: 0 0 0 19px;
+ display: inline-block;
+ height: 21px;
+ line-height: 16px;
+}
+
+body .sd-social-icon .sd-content li.share-custom a span {
+ width: 0;
+}
+
+body .sd-social-icon .sd-content li.share-custom a span {
+ padding-left: 16px !important;
+}
+
+
+/* Overflow Sharing dialog */
+.sharing-hidden .inner {
+ position: absolute;
+ z-index: 2;
+ border: 1px solid #ccc;
+ padding: 10px;
+ background: #fff;
+ box-shadow: 0px 5px 20px rgba(0,0,0,.2);
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+ margin-top: 5px;
+ max-width: 400px;
+}
+
+.sharing-hidden .inner ul{
+ margin: 0 !important;
+}
+
+.sd-social-official .sd-content .sharing-hidden ul>li.share-end {
+ clear: both;
+ margin: 0 !important;
+ height: 0 !important;
+}
+
+.sharing-hidden .inner:before, .sharing-hidden .inner:after {
+ position: absolute;
+ z-index: 1;
+ top: -8px;
+ left: 20px;
+ width: 0;
+ height: 0;
+ border-left: 6px solid transparent;
+ border-right: 6px solid transparent;
+ border-bottom: 8px solid #ccc;
+ content: "";
+ display: block;
+}
+
+.sharing-hidden .inner:after {
+ z-index: 2;
+ top: -7px;
+ border-left: 6px solid transparent;
+ border-right: 6px solid transparent;
+ border-bottom: 8px solid #fff;
+}
+
+.sharing-hidden ul {
+ margin: 0;
+}
+
+
+/**
+ * Special colorful look for "Icon Only" option
+ */
+
+.sd-social-icon .sd-content ul li[class*='share-'] a,
+.sd-social-icon .sd-content ul li[class*='share-'] a:hover,
+.sd-social-icon .sd-content ul li[class*='share-'] div.option a {
+ border-radius: 50%;
+ -webkit-border-radius: 50%;
+ border: 0;
+ box-shadow: none;
+ padding: 7px;
+ position: relative;
+ top: -2px;
+ line-height: 1;
+ width: auto;
+ height: auto;
+ margin-bottom: 0;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button>span,
+.sd-social-icon .sd-content ul li[class*='share-'] div.option a span {
+ line-height: 1;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'] a:hover,
+.sd-social-icon .sd-content ul li[class*='share-'] div.option a:hover {
+ border: none;
+ opacity: .6;
+}
+
+
+
+.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button:before {
+ top: 1px;
+ top: 0px\9; /* IE8 and below */
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button.share-custom {
+ padding: 8px 8px 6px 8px;
+ top: 5px;
+}
+
+.sd-social-icon .sd-content ul li a.sd-button.share-more {
+ margin-left: 10px;
+}
+
+.sd-social-icon .sd-content ul li:first-child a.sd-button.share-more {
+ margin-left: 0;
+}
+
+
+.sd-social-icon .sd-button span.share-count {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ border-radius: 0;
+ background: #555;
+ font-size: 9px;
+}
+
+/* Special look colors */
+.sd-social-icon .sd-content ul li[class*='share-'] a.sd-button {
+ background: #e9e9e9;
+ margin-top: 2px;
+ text-indent: 0;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-tumblr a.sd-button {
+ background: #2c4762;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-facebook a.sd-button {
+ background: #3b5998;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-twitter a.sd-button {
+ background: #00acee;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-pinterest a.sd-button {
+ background: #ca1f27;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-digg a.sd-button {
+ color: #555555 !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-press-this a.sd-button {
+ background: #1e8cbe;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-telegram a.sd-button {
+ background: #0088cc;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-linkedin a.sd-button {
+ background: #0077b5;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-pocket a.sd-button {
+ background: #ee4056;
+ color: #fff !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-reddit a.sd-button {
+ background: #cee3f8;
+ color: #555555 !important;
+}
+
+.sd-social-icon .sd-content ul li[class*='share-'].share-skype a.sd-button {
+ background: #00AFF0;
+ color: #fff !important;
+}
+
+/**
+ * Screen Reader Text for "Icon Only" option
+ */
+
+.sharing-screen-reader-text {
+ clip: rect(1px, 1px, 1px, 1px);
+ position: absolute !important;
+ height: 1px;
+ width: 1px;
+ overflow: hidden;
+}
+
+.sharing-screen-reader-text:hover,
+.sharing-screen-reader-text:active,
+.sharing-screen-reader-text:focus {
+ background-color: #f1f1f1;
+ border-radius: 3px;
+ box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
+ clip: auto !important;
+ color: #21759b;
+ display: block;
+ font-size: 14px;
+ font-weight: bold;
+ height: auto;
+ left: 5px;
+ line-height: normal;
+ padding: 15px 23px 14px;
+ text-decoration: none;
+ top: 5px;
+ width: auto;
+ z-index: 100000; /* Above WP toolbar */
+}
+
+
+/**
+ * Sharing Email Dialog
+ */
+
+#sharing_email {
+ width: 342px;
+ position: absolute;
+ z-index: 1001;
+ border: 1px solid #ccc;
+ padding: 15px;
+ background: #fff;
+ box-shadow: 0px 5px 20px rgba(0,0,0,.2);
+ text-align: left;
+}
+
+div.sharedaddy.sharedaddy-dark #sharing_email {
+ border-color: #fff;
+}
+
+#sharing_email .errors {
+ color: #fff;
+ background-color: #771a09;
+ font-size: 12px;
+ padding: 5px 8px;
+ line-height: 1;
+ margin: 10px 0 0 0;
+}
+
+#sharing_email label {
+ font-size: 12px;
+ color: #333;
+ font-weight: bold;
+ display: block;
+ padding: 0 0 4px 0;
+ text-align: left;
+ text-shadow: none;
+}
+
+#sharing_email form {
+ margin: 0;
+}
+
+#sharing_email input[type="text"], #sharing_email input[type="email"] {
+ width: 100%;
+ box-sizing: border-box;
+ -moz-box-sizing:border-box;
+ -webkit-box-sizing:border-box;
+ border: 1px solid #ccc;
+ margin-bottom: 1em;
+ background: #fff;
+ font-size: 12px;
+ color: #333;
+ max-width: none;
+ padding: 1px 3px;
+}
+#jetpack-source_f_name {
+ display: none!important;
+ position: absolute !important;
+ left: -9000px;
+}
+
+#sharing_email .sharing_cancel {
+ padding: 0 0 0 1em;
+ font-size: 12px;
+ text-shadow: none;
+}
+
+#sharing_email .recaptcha {
+ width: 312px;
+ height: 123px;
+ margin: 0 0 1em 0;
+}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js
new file mode 100644
index 00000000..dcaf0f11
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing.js
@@ -0,0 +1,514 @@
+/* global WPCOM_sharing_counts, grecaptcha */
+/* jshint unused:false */
+var sharing_js_options;
+if ( sharing_js_options && sharing_js_options.counts ) {
+ var WPCOMSharing = {
+ done_urls: [],
+ get_counts: function() {
+ var url, requests, id, service, service_request;
+
+ if ( 'undefined' === typeof WPCOM_sharing_counts ) {
+ return;
+ }
+
+ for ( url in WPCOM_sharing_counts ) {
+ id = WPCOM_sharing_counts[ url ];
+
+ if ( 'undefined' !== typeof WPCOMSharing.done_urls[ id ] ) {
+ continue;
+ }
+
+ requests = {
+ // 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 ),
+ ],
+ // Facebook protocol summing has been shown to falsely double counts, so we only request the current URL
+ facebook: [
+ window.location.protocol +
+ '//graph.facebook.com/?callback=WPCOMSharing.update_facebook_count&ids=' +
+ encodeURIComponent( url ),
+ ],
+ };
+
+ for ( service in requests ) {
+ if ( ! jQuery( 'a[data-shared=sharing-' + service + '-' + id + ']' ).length ) {
+ continue;
+ }
+
+ while ( ( service_request = requests[ service ].pop() ) ) {
+ jQuery.getScript( service_request );
+ }
+
+ if ( sharing_js_options.is_stats_active ) {
+ WPCOMSharing.bump_sharing_count_stat( service );
+ }
+ }
+
+ WPCOMSharing.done_urls[ id ] = true;
+ }
+ },
+
+ // get the version of the url that was stored in the dom (sharing-$service-URL)
+ get_permalink: function( url ) {
+ if ( 'https:' === window.location.protocol ) {
+ url = url.replace( /^http:\/\//i, 'https://' );
+ } else {
+ url = url.replace( /^https:\/\//i, 'http://' );
+ }
+
+ return url;
+ },
+ update_facebook_count: function( data ) {
+ var url, permalink;
+
+ if ( ! data ) {
+ return;
+ }
+
+ for ( url in data ) {
+ if (
+ ! data.hasOwnProperty( url ) ||
+ ! data[ url ].share ||
+ ! data[ url ].share.share_count
+ ) {
+ continue;
+ }
+
+ permalink = WPCOMSharing.get_permalink( url );
+
+ if ( ! ( permalink in WPCOM_sharing_counts ) ) {
+ continue;
+ }
+
+ WPCOMSharing.inject_share_count(
+ 'sharing-facebook-' + WPCOM_sharing_counts[ permalink ],
+ data[ url ].share.share_count
+ );
+ }
+ },
+ update_pinterest_count: function( data ) {
+ if ( 'undefined' !== typeof data.count && data.count * 1 > 0 ) {
+ WPCOMSharing.inject_share_count(
+ 'sharing-pinterest-' + WPCOM_sharing_counts[ data.url ],
+ data.count
+ );
+ }
+ },
+ inject_share_count: function( id, count ) {
+ var $share = jQuery( 'a[data-shared=' + id + '] > span' );
+ $share.find( '.share-count' ).remove();
+ $share.append(
+ '<span class="share-count">' + WPCOMSharing.format_count( count ) + '</span>'
+ );
+ },
+ format_count: function( count ) {
+ if ( count < 1000 ) {
+ return count;
+ }
+ if ( count >= 1000 && count < 10000 ) {
+ return String( count ).substring( 0, 1 ) + 'K+';
+ }
+ return '10K+';
+ },
+ bump_sharing_count_stat: function( service ) {
+ new Image().src =
+ document.location.protocol +
+ '//pixel.wp.com/g.gif?v=wpcom-no-pv&x_sharing-count-request=' +
+ service +
+ '&r=' +
+ Math.random();
+ },
+ };
+}
+
+( function( $ ) {
+ var $body, $sharing_email;
+
+ $.fn.extend( {
+ share_is_email: function() {
+ return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(
+ this.val()
+ );
+ },
+ } );
+
+ $body = $( document.body ).on( 'post-load', WPCOMSharing_do );
+ $( document ).ready( function() {
+ $sharing_email = $( '#sharing_email' );
+ $body.append( $sharing_email );
+ WPCOMSharing_do();
+ } );
+
+ function WPCOMSharing_do() {
+ var $more_sharing_buttons;
+ if ( 'undefined' !== typeof WPCOMSharing ) {
+ WPCOMSharing.get_counts();
+ }
+ $more_sharing_buttons = $( '.sharedaddy a.sharing-anchor' );
+
+ $more_sharing_buttons.click( function() {
+ return false;
+ } );
+
+ $( '.sharedaddy a' ).each( function() {
+ if (
+ $( this ).attr( 'href' ) &&
+ $( this )
+ .attr( 'href' )
+ .indexOf( 'share=' ) !== -1
+ ) {
+ $( this ).attr( 'href', $( this ).attr( 'href' ) + '&nb=1' );
+ }
+ } );
+
+ // Show hidden buttons
+
+ // Touchscreen device: use click.
+ // Non-touchscreen device: use click if not already appearing due to a hover event
+ $more_sharing_buttons.on( 'click', function() {
+ var $more_sharing_button = $( this ),
+ $more_sharing_pane = $more_sharing_button.parents( 'div:first' ).find( '.inner' );
+
+ if ( $more_sharing_pane.is( ':animated' ) ) {
+ // We're in the middle of some other event's animation
+ return;
+ }
+
+ if ( true === $more_sharing_pane.data( 'justSlid' ) ) {
+ // We just finished some other event's animation - don't process click event so that slow-to-react-clickers don't get confused
+ return;
+ }
+
+ $sharing_email.slideUp( 200 );
+
+ $more_sharing_pane
+ .css( {
+ left: $more_sharing_button.position().left + 'px',
+ top: $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px',
+ } )
+ .slideToggle( 200 );
+ } );
+
+ if ( document.ontouchstart === undefined ) {
+ // Non-touchscreen device: use hover/mouseout with delay
+ $more_sharing_buttons.hover(
+ function() {
+ var $more_sharing_button = $( this ),
+ $more_sharing_pane = $more_sharing_button.parents( 'div:first' ).find( '.inner' ),
+ timer;
+
+ if ( ! $more_sharing_pane.is( ':animated' ) ) {
+ // Create a timer to make the area appear if the mouse hovers for a period
+ timer = setTimeout( function() {
+ var handler_item_leave,
+ handler_item_enter,
+ handler_original_leave,
+ handler_original_enter,
+ close_it;
+
+ $sharing_email.slideUp( 200 );
+
+ $more_sharing_pane.data( 'justSlid', true );
+ $more_sharing_pane
+ .css( {
+ left: $more_sharing_button.position().left + 'px',
+ top:
+ $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px',
+ } )
+ .slideDown( 200, function() {
+ // Mark the item as have being appeared by the hover
+ $more_sharing_button.data( 'hasoriginal', true ).data( 'hasitem', false );
+
+ setTimeout( function() {
+ $more_sharing_pane.data( 'justSlid', false );
+ }, 300 );
+
+ $more_sharing_pane
+ .mouseleave( handler_item_leave )
+ .mouseenter( handler_item_enter );
+ $more_sharing_button
+ .mouseleave( handler_original_leave )
+ .mouseenter( handler_original_enter );
+ } );
+
+ // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area
+ handler_item_leave = function() {
+ $more_sharing_button.data( 'hasitem', false );
+
+ if ( $more_sharing_button.data( 'hasoriginal' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $more_sharing_button.data( 'timer2', timer );
+ }
+ };
+
+ handler_item_enter = function() {
+ $more_sharing_button.data( 'hasitem', true );
+ clearTimeout( $more_sharing_button.data( 'timer2' ) );
+ };
+
+ handler_original_leave = function() {
+ $more_sharing_button.data( 'hasoriginal', false );
+
+ if ( $more_sharing_button.data( 'hasitem' ) === false ) {
+ var timer = setTimeout( close_it, 800 );
+ $more_sharing_button.data( 'timer2', timer );
+ }
+ };
+
+ handler_original_enter = function() {
+ $more_sharing_button.data( 'hasoriginal', true );
+ clearTimeout( $more_sharing_button.data( 'timer2' ) );
+ };
+
+ close_it = function() {
+ $more_sharing_pane.data( 'justSlid', true );
+ $more_sharing_pane.slideUp( 200, function() {
+ setTimeout( function() {
+ $more_sharing_pane.data( 'justSlid', false );
+ }, 300 );
+ } );
+
+ // Clear all hooks
+ $more_sharing_button
+ .unbind( 'mouseleave', handler_original_leave )
+ .unbind( 'mouseenter', handler_original_enter );
+ $more_sharing_pane
+ .unbind( 'mouseleave', handler_item_leave )
+ .unbind( 'mouseenter', handler_item_leave );
+ return false;
+ };
+ }, 200 );
+
+ // Remember the timer so we can detect it on the mouseout
+ $more_sharing_button.data( 'timer', timer );
+ }
+ },
+ function() {
+ // Mouse out - remove any timer
+ $more_sharing_buttons.each( function() {
+ clearTimeout( $( this ).data( 'timer' ) );
+ } );
+ $more_sharing_buttons.data( 'timer', false );
+ }
+ );
+ } else {
+ $( document.body ).addClass( 'jp-sharing-input-touch' );
+ }
+
+ $( document ).click( function() {
+ // Click outside
+ // remove any timer
+ $more_sharing_buttons.each( function() {
+ clearTimeout( $( this ).data( 'timer' ) );
+ } );
+ $more_sharing_buttons.data( 'timer', false );
+
+ // slide down forcibly
+ $( '.sharedaddy .inner' ).slideUp();
+ } );
+
+ // Add click functionality
+ $( '.sharedaddy ul' ).each( function() {
+ if ( 'yep' === $( this ).data( 'has-click-events' ) ) {
+ return;
+ }
+ $( this ).data( 'has-click-events', 'yep' );
+
+ var printUrl = function( uniqueId, urlToPrint ) {
+ $( 'body:first' ).append(
+ '<iframe style="position:fixed;top:100;left:100;height:1px;width:1px;border:none;" id="printFrame-' +
+ uniqueId +
+ '" name="printFrame-' +
+ uniqueId +
+ '" src="' +
+ urlToPrint +
+ '" onload="frames[\'printFrame-' +
+ uniqueId +
+ "'].focus();frames['printFrame-" +
+ uniqueId +
+ '\'].print();"></iframe>'
+ );
+ };
+
+ // Print button
+ $( this )
+ .find( 'a.share-print' )
+ .click( function() {
+ var ref = $( this ).attr( 'href' ),
+ do_print = function() {
+ if ( ref.indexOf( '#print' ) === -1 ) {
+ var uid = new Date().getTime();
+ printUrl( uid, ref );
+ } else {
+ print();
+ }
+ };
+
+ // Is the button in a dropdown?
+ if ( $( this ).parents( '.sharing-hidden' ).length > 0 ) {
+ $( this )
+ .parents( '.inner' )
+ .slideUp( 0, function() {
+ do_print();
+ } );
+ } else {
+ do_print();
+ }
+
+ return false;
+ } );
+
+ // Press This button
+ $( this )
+ .find( 'a.share-press-this' )
+ .click( function() {
+ var s = '';
+
+ if ( window.getSelection ) {
+ s = window.getSelection();
+ } else if ( document.getSelection ) {
+ s = document.getSelection();
+ } else if ( document.selection ) {
+ s = document.selection.createRange().text;
+ }
+
+ if ( s ) {
+ $( this ).attr( 'href', $( this ).attr( 'href' ) + '&sel=' + encodeURI( s ) );
+ }
+
+ if (
+ ! window.open(
+ $( this ).attr( 'href' ),
+ 't',
+ 'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'
+ )
+ ) {
+ document.location.href = $( this ).attr( 'href' );
+ }
+
+ return false;
+ } );
+
+ // Email button
+ $( 'a.share-email', this ).on( 'click', function() {
+ var url = $( this ).attr( 'href' );
+ var currentDomain = window.location.protocol + '//' + window.location.hostname + '/';
+ if ( url.indexOf( currentDomain ) !== 0 ) {
+ return true;
+ }
+
+ if ( $sharing_email.is( ':visible' ) ) {
+ $sharing_email.slideUp( 200 );
+ } else {
+ $( '.sharedaddy .inner' ).slideUp();
+
+ $( '#sharing_email .response' ).remove();
+ $( '#sharing_email form' ).show();
+ $( '#sharing_email form input[type=submit]' ).removeAttr( 'disabled' );
+ $( '#sharing_email form a.sharing_cancel' ).show();
+
+ // Reset reCATPCHA if exists.
+ if (
+ 'object' === typeof grecaptcha &&
+ 'function' === typeof grecaptcha.reset &&
+ window.___grecaptcha_cfg.count
+ ) {
+ grecaptcha.reset();
+ }
+
+ // Show dialog
+ $sharing_email
+ .css( {
+ left: $( this ).offset().left + 'px',
+ top: $( this ).offset().top + $( this ).height() + 'px',
+ } )
+ .slideDown( 200 );
+
+ // Hook up other buttons
+ $( '#sharing_email a.sharing_cancel' )
+ .unbind( 'click' )
+ .click( function() {
+ $( '#sharing_email .errors' ).hide();
+ $sharing_email.slideUp( 200 );
+ $( '#sharing_background' ).fadeOut();
+ return false;
+ } );
+
+ // Submit validation
+ $( '#sharing_email input[type=submit]' )
+ .unbind( 'click' )
+ .click( function() {
+ var form = $( this ).parents( 'form' );
+ var source_email_input = form.find( 'input[name=source_email]' );
+ var target_email_input = form.find( 'input[name=target_email]' );
+
+ // Disable buttons + enable loading icon
+ $( this ).prop( 'disabled', true );
+ form.find( 'a.sharing_cancel' ).hide();
+ form.find( 'img.loading' ).show();
+
+ $( '#sharing_email .errors' ).hide();
+ $( '#sharing_email .error' ).removeClass( 'error' );
+
+ if ( ! source_email_input.share_is_email() ) {
+ source_email_input.addClass( 'error' );
+ }
+
+ if ( ! target_email_input.share_is_email() ) {
+ target_email_input.addClass( 'error' );
+ }
+
+ if ( $( '#sharing_email .error' ).length === 0 ) {
+ // AJAX send the form
+ $.ajax( {
+ url: url,
+ type: 'POST',
+ data: form.serialize(),
+ success: function( response ) {
+ form.find( 'img.loading' ).hide();
+
+ if ( response === '1' || response === '2' || response === '3' ) {
+ $( '#sharing_email .errors-' + response ).show();
+ form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
+ form.find( 'a.sharing_cancel' ).show();
+
+ if (
+ 'object' === typeof grecaptcha &&
+ 'function' === typeof grecaptcha.reset
+ ) {
+ grecaptcha.reset();
+ }
+ } else {
+ $( '#sharing_email form' ).hide();
+ $sharing_email.append( response );
+ $( '#sharing_email a.sharing_cancel' ).click( function() {
+ $sharing_email.slideUp( 200 );
+ $( '#sharing_background' ).fadeOut();
+ return false;
+ } );
+ }
+ },
+ } );
+
+ return false;
+ }
+
+ form.find( 'img.loading' ).hide();
+ form.find( 'input[type=submit]' ).removeAttr( 'disabled' );
+ form.find( 'a.sharing_cancel' ).show();
+ $( '#sharing_email .errors-1' ).show();
+
+ return false;
+ } );
+ }
+
+ return false;
+ } );
+ } );
+
+ $( 'li.share-email, li.share-custom a.sharing-anchor' ).addClass( 'share-service-visible' );
+ }
+} )( jQuery );
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.php b/plugins/jetpack/modules/sharedaddy/sharing.php
new file mode 100644
index 00000000..49df892b
--- /dev/null
+++ b/plugins/jetpack/modules/sharedaddy/sharing.php
@@ -0,0 +1,638 @@
+<?php
+if ( ! defined( 'WP_SHARING_PLUGIN_URL' ) ) {
+ define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
+ define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
+}
+
+class Sharing_Admin {
+ public function __construct() {
+ require_once WP_SHARING_PLUGIN_DIR . 'sharing-service.php';
+
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
+ add_action( 'admin_menu', array( &$this, 'subscription_menu' ) );
+
+ // Insert our CSS and JS
+ add_action( 'load-settings_page_sharing', array( &$this, 'sharing_head' ) );
+
+ // Catch AJAX
+ add_action( 'wp_ajax_sharing_save_services', array( &$this, 'ajax_save_services' ) );
+ add_action( 'wp_ajax_sharing_save_options', array( &$this, 'ajax_save_options' ) );
+ add_action( 'wp_ajax_sharing_new_service', array( &$this, 'ajax_new_service' ) );
+ add_action( 'wp_ajax_sharing_delete_service', array( &$this, 'ajax_delete_service' ) );
+ }
+
+ public function sharing_head() {
+ wp_enqueue_script(
+ 'sharing-js',
+ Jetpack::get_file_url_for_environment(
+ '_inc/build/sharedaddy/admin-sharing.min.js',
+ 'modules/sharedaddy/admin-sharing.js'
+ ),
+ array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ),
+ 2
+ );
+
+ /**
+ * 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 );
+ 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();
+ }
+ }
+
+ public function admin_init() {
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) ) {
+ $this->process_requests();
+ }
+ }
+
+ public function process_requests() {
+ if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
+ $sharer = new Sharing_Service();
+ $sharer->set_global_options( $_POST );
+ /**
+ * Fires when updating sharing settings.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ */
+ do_action( 'sharing_admin_update' );
+
+ wp_safe_redirect( admin_url( 'options-general.php?page=sharing&update=saved' ) );
+ die();
+ }
+ }
+
+ public function subscription_menu( $user ) {
+ if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
+ $active = Jetpack::get_active_modules();
+ if ( ! in_array( 'publicize', $active ) && ! current_user_can( 'manage_options' ) ) {
+ return;
+ }
+ }
+
+ add_submenu_page(
+ 'options-general.php',
+ __( 'Sharing Settings', 'jetpack' ),
+ __( 'Sharing', 'jetpack' ),
+ 'publish_posts',
+ 'sharing',
+ array( &$this, 'wrapper_admin_page' )
+ );
+ }
+
+ public function ajax_save_services() {
+ if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) && isset( $_POST['hidden'] ) && isset( $_POST['visible'] ) ) {
+ $sharer = new Sharing_Service();
+
+ $sharer->set_blog_services( explode( ',', $_POST['visible'] ), explode( ',', $_POST['hidden'] ) );
+ die();
+ }
+ }
+
+ public function ajax_new_service() {
+ if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['sharing_name'] ) && isset( $_POST['sharing_url'] ) && isset( $_POST['sharing_icon'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-new_service' ) ) {
+ $sharer = new Sharing_Service();
+ if ( $service = $sharer->new_service( stripslashes( $_POST['sharing_name'] ), stripslashes( $_POST['sharing_url'] ), stripslashes( $_POST['sharing_icon'] ) ) ) {
+ $this->output_service( $service->get_id(), $service );
+ echo '<!--->';
+ $service->button_style = 'icon-text';
+ $this->output_preview( $service );
+
+ die();
+ }
+ }
+
+ // Fail
+ die( '1' );
+ }
+
+ public function ajax_delete_service() {
+ if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_' . $_POST['service'] ) ) {
+ $sharer = new Sharing_Service();
+ $sharer->delete_service( $_POST['service'] );
+ }
+ }
+
+ public function ajax_save_options() {
+ if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_' . $_POST['service'] ) ) {
+ $sharer = new Sharing_Service();
+ $service = $sharer->get_service( $_POST['service'] );
+
+ if ( $service && $service instanceof Sharing_Advanced_Source ) {
+ $service->update_options( $_POST );
+
+ $sharer->set_service( $_POST['service'], $service );
+ }
+
+ $this->output_service( $service->get_id(), $service, true );
+ echo '<!--->';
+ $service->button_style = 'icon-text';
+ $this->output_preview( $service );
+ die();
+ }
+ }
+
+ public function output_preview( $service ) {
+
+ $klasses = array( 'advanced', 'preview-item' );
+
+ if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
+ $klasses[] = 'preview-' . $service->get_class();
+ $klasses[] = 'share-' . $service->get_class();
+ if ( $service->is_deprecated() ) {
+ $klasses[] = 'share-deprecated';
+ }
+
+ if ( $service->get_class() != $service->get_id() ) {
+ $klasses[] = 'preview-' . $service->get_id();
+ }
+ }
+
+ echo '<li class="' . implode( ' ', $klasses ) . '">';
+ $service->display_preview();
+ echo '</li>';
+ }
+
+ public function output_service( $id, $service, $show_dropdown = false ) {
+ $title = '';
+ $klasses = array( 'service', 'advanced', 'share-' . $service->get_class() );
+ if ( $service->is_deprecated() ) {
+ $title = sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $service->get_name() );
+ $klasses[] = 'share-deprecated';
+ }
+
+?>
+ <li class="<?php echo implode( ' ', $klasses ); ?>" id="<?php echo $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 ( 0 === strpos( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?>
+ <span class="close"><a href="#" class="remove">&times;</a></span>
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
+ <input type="hidden" name="action" value="sharing_delete_service" />
+ <input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_' . $id );?>" />
+ </form>
+ <?php endif; ?>
+ </li>
+<?php
+ }
+
+ public function wrapper_admin_page() {
+ Jetpack_Admin_Page::wrap_ui( array( &$this, 'management_page' ), array( 'is-wide' =>true ) );
+ }
+
+ public function management_page() {
+ $sharer = new Sharing_Service();
+ $enabled = $sharer->get_blog_services();
+ $global = $sharer->get_global_options();
+
+ $shows = array_values( get_post_types( array( 'public' => true ) ) );
+ array_unshift( $shows, 'index' );
+
+ if ( false == function_exists( 'mb_stripos' ) ) {
+ echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
+ echo '<p>' . sprintf( __( 'This plugin will work without it, but multibyte support is used <a href="%s" rel="noopener noreferrer" target="_blank">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ), 'http://www.php.net/manual/en/mbstring.installation.php' ) . '</p></div>';
+ }
+
+ if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' ) {
+ echo '<div class="updated"><p>' . __( 'Settings have been saved', 'jetpack' ) . '</p></div>';
+ }
+
+ if ( ! isset( $global['sharing_label'] ) ) {
+ $global['sharing_label'] = __( 'Share this:', 'jetpack' );
+ }
+?>
+
+ <div class="wrap">
+ <div class="icon32" id="icon-options-general"><br /></div>
+ <h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
+
+ <?php
+ /**
+ * Fires at the top of the admin sharing settings screen.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.6.0
+ */
+ do_action( 'pre_admin_screen_sharing' );
+ ?>
+
+ <?php if ( current_user_can( 'manage_options' ) ) : ?>
+
+ <div class="share_manage_options">
+ <h2><?php _e( 'Sharing Buttons', 'jetpack' ) ?></h2>
+ <p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ) ?></p>
+
+ <div id="services-config">
+ <table id="available-services">
+ <tr>
+ <td class="description">
+ <h3><?php _e( 'Available Services', 'jetpack' ); ?></h3>
+ <p><?php _e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
+ <p><a href="#TB_inline?height=395&amp;width=600&amp;inlineId=new-service" class="thickbox" id="add-a-new-service"><?php _e( 'Add a new service', 'jetpack' ); ?></a></p>
+ </td>
+ <td class="services">
+ <ul class="services-available" style="height: 100px;">
+ <?php foreach ( $sharer->get_all_services_blog() as $id => $service ) : ?>
+ <?php
+ if ( ! isset( $enabled['all'][ $id ] ) ) {
+ $this->output_service( $id, $service );
+ }
+ ?>
+ <?php endforeach; ?>
+ </ul>
+ <?php
+ if ( -1 == get_option( 'blog_public' ) ) {
+ echo '<p><strong>' . __( 'Please note that your services have been restricted because your site is private.', 'jetpack' ) . '</strong></p>';
+ }
+ ?>
+ <br class="clearing" />
+ </td>
+ </tr>
+ </table>
+
+ <table id="enabled-services">
+ <tr>
+ <td class="description">
+ <h3>
+ <?php _e( 'Enabled Services', 'jetpack' ); ?>
+ <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
+ </h3>
+ <p><?php _e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
+ </td>
+ <td class="services" id="share-drop-target">
+ <h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) { echo ' style="display: none"';} ?>><?php _e( 'Drag and drop available services here.', 'jetpack' ); ?></h2>
+
+ <ul class="services-enabled">
+ <?php foreach ( $enabled['visible'] as $id => $service ) : ?>
+ <?php $this->output_service( $id, $service, true ); ?>
+ <?php endforeach; ?>
+
+ <li class="end-fix"></li>
+ </ul>
+ </td>
+ <td id="hidden-drop-target" class="services">
+ <p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
+
+ <ul class="services-hidden">
+ <?php foreach ( $enabled['hidden'] as $id => $service ) : ?>
+ <?php $this->output_service( $id, $service, true ); ?>
+ <?php endforeach; ?>
+ <li class="end-fix"></li>
+ </ul>
+ </td>
+ </tr>
+ </table>
+
+ <table id="live-preview">
+ <tr>
+ <td class="description">
+ <h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3>
+ </td>
+ <td class="services">
+ <h2 <?php echo ( count( $enabled['all'] ) > 0 ) ? ' style="display: none"' : ''; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
+ <div class="sharedaddy sd-sharing-enabled">
+ <?php if ( count( $enabled['all'] ) > 0 ) : ?>
+ <h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3>
+ <?php endif; ?>
+ <div class="sd-content">
+ <ul class="preview">
+ <?php foreach ( $enabled['visible'] as $id => $service ) : ?>
+ <?php $this->output_preview( $service ); ?>
+ <?php endforeach; ?>
+
+ <?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
+ <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
+ <?php endif; ?>
+ </ul>
+
+ <?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
+ <div class="sharing-hidden">
+ <div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>">
+ <?php if ( count( $enabled['hidden'] ) == 1 ) : ?>
+ <ul style="background-image:none;">
+ <?php else : ?>
+ <ul>
+ <?php endif; ?>
+
+ <?php
+ foreach ( $enabled['hidden'] as $id => $service ) {
+ $this->output_preview( $service );
+ }
+ ?>
+ </ul>
+ </div>
+ </div>
+ <?php endif; ?>
+
+ <ul class="archive" style="display:none;">
+ <?php
+ foreach ( $sharer->get_all_services_blog() as $id => $service ) :
+ if ( isset( $enabled['visible'][ $id ] ) ) {
+ $service = $enabled['visible'][ $id ];
+ } elseif ( isset( $enabled['hidden'][ $id ] ) ) {
+ $service = $enabled['hidden'][ $id ];
+ }
+
+ $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later
+ $service->smart = false;
+ $this->output_preview( $service );
+ endforeach; ?>
+ <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
+ </ul>
+ </div>
+ </div>
+ <br class="clearing" />
+ </td>
+ </tr>
+ </table>
+
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="save-enabled-shares">
+ <input type="hidden" name="action" value="sharing_save_services" />
+ <input type="hidden" name="visible" value="<?php echo implode( ',', array_keys( $enabled['visible'] ) ); ?>" />
+ <input type="hidden" name="hidden" value="<?php echo implode( ',', array_keys( $enabled['hidden'] ) ); ?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
+ </form>
+ </div>
+
+ <form method="post" action="">
+ <table class="form-table">
+ <tbody>
+ <tr valign="top">
+ <th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th>
+ <td>
+ <select name="button_style" id="button_style">
+ <option<?php echo ( $global['button_style'] == 'icon-text' ) ? ' selected="selected"' : ''; ?> value="icon-text"><?php _e( 'Icon + text', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] == 'icon' ) ? ' selected="selected"' : ''; ?> value="icon"><?php _e( 'Icon only', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] == 'text' ) ? ' selected="selected"' : ''; ?> value="text"><?php _e( 'Text only', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] == 'official' ) ? ' selected="selected"' : ''; ?> value="official"><?php _e( 'Official buttons', 'jetpack' ); ?></option>
+ </select>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><label><?php _e( 'Sharing label', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" />
+ </td>
+ </tr>
+ <?php
+ /**
+ * Filters the HTML at the beginning of the "Show button on" row.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.1.0
+ *
+ * @param string $var Opening HTML tag at the beginning of the "Show button on" row.
+ */
+ echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' );
+ ?>
+ <th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
+ <td>
+ <?php
+ $br = false;
+ foreach ( $shows as $show ) :
+ if ( 'index' == $show ) {
+ $label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
+ } else {
+ $post_type_object = get_post_type_object( $show );
+ $label = $post_type_object->labels->name;
+ }
+ ?>
+ <?php
+ if ( $br ) {
+ echo '<br />';
+ }
+ ?>
+ <label><input type="checkbox"<?php checked( in_array( $show, $global['show'] ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
+ <?php
+ $br = true;
+ endforeach;
+ ?>
+ </td>
+ <?php
+ /**
+ * Filters the HTML at the end of the "Show button on" row.
+ *
+ * @module sharedaddy
+ *
+ * @since 2.1.0
+ *
+ * @param string $var Closing HTML tag at the end of the "Show button on" row.
+ */
+ echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' );
+ ?>
+
+ <?php
+ /**
+ * Fires at the end of the sharing global options settings table.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ */
+ do_action( 'sharing_global_options' );
+ ?>
+ </tbody>
+ </table>
+
+ <p class="submit">
+ <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
+ </p>
+
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
+ </form>
+
+ <div id="new-service" style="display: none">
+ <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-service-form">
+ <table class="form-table">
+ <tbody>
+ <tr valign="top">
+ <th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_name" id="new_sharing_name" size="40" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row" width="100"><label><?php _e( 'Sharing URL', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_url" id="new_sharing_url" size="40" />
+
+ <p><?php _e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
+ <code>%post_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 _e( 'Icon URL', 'jetpack' ); ?></label></th>
+ <td>
+ <input type="text" name="sharing_icon" id="new_sharing_icon" size="40" />
+ <p><?php _e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p>
+ </td>
+ </tr>
+ <tr valign="top" width="100">
+ <th scope="row"></th>
+ <td>
+ <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Create Share Button', 'jetpack' ); ?>" />
+ <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
+ </td>
+ </tr>
+
+ <?php
+ /**
+ * Fires after the custom sharing service form
+ *
+ * @module sharedaddy
+ *
+ * @since 1.1.0
+ */
+ do_action( 'sharing_new_service_form' );
+ ?>
+ </tbody>
+ </table>
+
+ <?php
+ /**
+ * Fires at the bottom of the admin sharing settings screen.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.6.0
+ */
+ do_action( 'post_admin_screen_sharing' );
+ ?>
+
+ <div class="inerror" style="display: none; margin-top: 15px">
+ <p><?php _e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p>
+ </div>
+
+ <input type="hidden" name="action" value="sharing_new_service" />
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
+ </form>
+ </div>
+ </div>
+
+ <?php endif; ?>
+
+
+ </div>
+
+ <script type="text/javascript">
+ var sharing_loading_icon = '<?php echo esc_js( admin_url( '/images/loading.gif' ) ); ?>';
+ <?php if ( isset( $_GET['create_new_service'] ) && 'true' == $_GET['create_new_service'] ) : ?>
+ jQuery(document).ready(function() {
+ // Prefill new service box and then open it
+ jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( $_GET['name'] ); ?>' );
+ jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( $_GET['url'] ); ?>' );
+ jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( $_GET['icon'] ); ?>' );
+ jQuery( '#add-a-new-service' ).click();
+ });
+ <?php endif; ?>
+ </script>
+<?php
+ }
+}
+
+/**
+ * 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.
+ */
+function jetpack_post_sharing_get_value( array $post ) {
+ // if sharing IS disabled on this post, enabled=false, so negate the meta
+ return (bool) ! get_post_meta( $post['id'], 'sharing_disabled', true );
+}
+
+/**
+ * Callback to set sharing_disabled post_meta when the
+ * jetpack_sharing_enabled field is updated.
+ *
+ * When the sharing_disabled post_meta is unset, we follow the global setting in Sharing.
+ * When it is set to 1, we disable sharing on the post, regardless of the global setting.
+ * It is not possible to enable sharing on a post if it is disabled globally.
+ *
+ */
+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 );
+
+function sharing_admin_init() {
+ global $sharing_admin;
+
+ $sharing_admin = new Sharing_Admin();
+}
+
+/**
+ * Set the Likes and Sharing Gutenberg extension as available
+ */
+function jetpack_sharing_set_extension_availability() {
+ Jetpack_Gutenberg::set_extension_available( 'sharing' );
+}
+
+add_action( 'jetpack_register_gutenberg_extensions', 'jetpack_sharing_set_extension_availability' );
+
+add_action( 'init', 'sharing_admin_init' );