1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373:
<?php
$plugin_is_filter = 9 | THEME_PLUGIN;
$plugin_description = gettext('A Zenphoto plugin that provides scriptless and privacy friendly sharing buttons for Facebook, Twitter, Google+, Pinterest, Linkedin, Xing, Reddit, Stumbleupon, Tumblr, WhatsApp (iOS only) and e-mail. (Note: No share counts because of that!).');
$plugin_author = 'Malte Müller (acrylian)';
$plugin_category = gettext('Misc');
$option_interface = 'scriptlessSocialsharingOptions';
if (getOption('scriptless_socialsharing_iconfont')) {
zp_register_filter('theme_head', 'scriptlessSocialsharing::CSS');
}
class scriptlessSocialsharingOptions {
function __construct() {
purgeOption('scriptless_socialsharing_gplus');
}
function getOptionsSupported() {
$options = array(
gettext('Social networks') => array(
'key' => 'scriptless_socialsharing_socialnetworks',
'type' => OPTION_TYPE_CHECKBOX_UL,
'order' => 0,
'checkboxes' => array(
'Facebook' => 'scriptless_socialsharing_facebook',
'Twitter' => 'scriptless_socialsharing_twitter',
'Pinterest' => 'scriptless_socialsharing_pinterest',
'Linkedin' => 'scriptless_socialsharing_linkedin',
'Xing' => 'scriptless_socialsharing_xing',
'Reddit' => 'scriptless_socialsharing_reddit',
'StumbleUpon' => 'scriptless_socialsharing_stumbleupon',
'Tumblr' => 'scriptless_socialsharing_tumblr',
'Whatsapp' => 'scriptless_socialsharing_whatsapp',
'Digg' => 'scriptless_socialsharing_digg',
'Livejournal' => 'scriptless_socialsharing_livejournal',
'Buffer' => 'scriptless_socialsharing_buffer',
'Delicious' => 'scriptless_socialsharing_delicious',
'Evernote' => 'scriptless_socialsharing_evernote',
'WordPress' => 'scriptless_socialsharing_wordpress',
'Pocket' => 'scriptless_socialsharing_pocket',
gettext('E-mail') => 'scriptless_socialsharing_email',
),
'desc' => gettext('Select the social networks you wish buttons to appear for. Note: WhatsApp iOS only.')),
gettext('Icon font and default CSS') => array(
'key' => 'scriptless_socialsharing_iconfont',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 1,
'desc' => gettext("Uncheck to disable loading the included font and CSS and use your own theme based icon font and CSS.")),
gettext('Icons only') => array(
'key' => 'scriptless_socialsharing_iconsonly',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 1,
'desc' => gettext("Check to hide the service name and only show icon buttons.")),
gettext('Twitter user name') => array(
'key' => 'scriptless_socialsharing_twittername',
'type' => OPTION_TYPE_TEXTBOX,
'order' => 1,
'desc' => gettext("Enter your Twitter name without @ here if you like to have it appended to tweets made."))
);
return $options;
}
}
class scriptlessSocialsharing {
static function CSS() {
?>
<link rel="stylesheet" href="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?>/scriptless-socialsharing/style.min.css" type="text/css">
<?php
}
static function getButtons($beforetext = '', $customtext = null) {
global $_zp_gallery_page, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category;
$title = '';
$desc = '';
$url = '';
$buttons = array();
$gallerytitle = html_encode(getBareGallerytitle());
$imgsource = '';
switch ($_zp_gallery_page) {
case 'index.php':
case 'gallery.php':
$url = getGalleryIndexURL();
$title = (empty($customtext)) ? getBareGalleryTitle() : $customtext;
break;
case 'album.php':
$url = $_zp_current_album->getLink();
$title = (empty($customtext)) ? $_zp_current_album->getTitle() : $customtext;
break;
case 'image.php':
$url = $_zp_current_image->getLink();
$title = (empty($customtext)) ? $_zp_current_image->getTitle() : $customtext;
break;
case 'news.php':
if (function_exists("is_NewsArticle")) {
if (is_NewsArticle()) {
$url = $_zp_current_zenpage_news->getLink();
$title = (empty($customtext)) ? $_zp_current_zenpage_news->getTitle() : $customtext;
} else if (is_NewsCategory()) {
$url = $_zp_current_category->getLink();
$title = (empty($customtext)) ? $_zp_current_category->getTitle() : $customtext;
} else {
$url = getNewsIndexURL();
$title = (empty($customtext)) ? getBareGalleryTitle() . ' - ' . gettext('News') : $customtext;
}
}
break;
case 'pages.php':
if (function_exists("is_Pages")) {
$url = $_zp_current_zenpage_page->getLink();
$title = (empty($customtext)) ? $_zp_current_zenpage_page->getTitle() : $customtext;
}
break;
default:
$url = getCustomPageURL(stripSuffix($_zp_gallery_page));
if (empty($customtext)) {
switch ($_zp_gallery_page) {
case 'contact.php':
$title = gettext('Contact');
break;
case 'archive.php':
$title = gettext('Archive');
break;
case 'register.php':
$title = gettext('Register');
break;
case 'search.php':
$title = gettext('Search');
break;
default:
$title = strtoupper(stripSuffix($_zp_gallery_page));
break;
}
} else {
$title = $customtext;
}
break;
}
if (empty($customtext)) {
$title .= ' - ' . getBareGalleryTitle();
}
$title = urlencode($title);
$url = urlencode(SERVER_HTTP_HOST . html_encode($url));
if ($beforetext) {
echo $beforetext;
}
if (getOption('scriptless_socialsharing_facebook')) {
$buttons[] = array(
'class' => 'sharingicon-facebook-f',
'title' => 'facebook',
'url' => 'https://www.facebook.com/sharer/sharer.php?u=' . $url . '&quote=' . $title
);
}
if (getOption('scriptless_socialsharing_twitter')) {
$via = '';
if (getOption('scriptless_socialsharing_twittername')) {
$via = '&via=' . html_encode(getOption('scriptless_socialsharing_twittername'));
}
$buttons[] = array(
'class' => 'sharingicon-twitter',
'title' => 'Twitter',
'url' => 'https://twitter.com/intent/tweet?text=' . $title . $via . '&url=' . $url
);
}
if (getOption('scriptless_socialsharing_pinterest')) {
$buttons[] = array(
'class' => 'sharingicon-pinterest-p',
'title' => 'Pinterest',
'url' => 'https://pinterest.com/pin/create/button/?url=' . $url . '&description=' . $title . '&media=' . $url
);
}
if (getOption('scriptless_socialsharing_linkedin')) {
$buttons[] = array(
'class' => 'sharingicon-linkedin',
'title' => 'Linkedin',
'url' => 'https://www.linkedin.com/shareArticle?mini=true&url=' . $url . '>&title=' . $title . '&source=' . $url
);
}
if (getOption('scriptless_socialsharing_xing')) {
$buttons[] = array(
'class' => 'sharingicon-xing',
'title' => 'Xing',
'url' => 'https://www.xing-share.com/app/user?op=share;sc_p=xing-share;url=' . $url
);
}
if (getOption('scriptless_socialsharing_reddit')) {
$buttons[] = array(
'class' => 'sharingicon-reddit-alien',
'title' => 'Reddit',
'url' => 'https://reddit.com/submit?url=' . $url . '/?socialshare&title=' . $title
);
}
if (getOption('scriptless_socialsharing_stumbleupon')) {
$buttons[] = array(
'class' => 'sharingicon-stumbleupon',
'title' => 'StumbleUpon',
'url' => 'https://www.stumbleupon.com/submit?url=' . $url . '&title=' . $title
);
}
if (getOption('scriptless_socialsharing_tumblr')) {
$buttons[] = array(
'class' => 'sharingicon-tumblr',
'title' => 'Tumblr',
'url' => 'https://www.tumblr.com/share/link?url=' . $url . '&name=' . $title
);
}
if (getOption('scriptless_socialsharing_whatsapp')) {
$buttons[] = array(
'class' => 'sharingicon-whatsapp',
'title' => 'Whatsapp',
'url' => 'WhatsApp://send?text=' . $url
);
}
if (getOption('scriptless_socialsharing_digg')) {
$buttons[] = array(
'class' => 'sharingicon-digg',
'title' => 'Digg',
'url' => 'http://digg.com/submit?url=' . $url . '&title=' . $title
);
}
if (getOption('scriptless_socialsharing_livejournal')) {
$buttons[] = array(
'class' => 'sharingicon-pencil',
'title' => 'Livejournal',
'url' => 'https://www.livejournal.com/update.bml?url=' . $url . '&subject=' . $title
);
}
if (getOption('scriptless_socialsharing_buffer')) {
$buttons[] = array(
'class' => 'sharingicon-stack',
'title' => 'Buffer',
'url' => 'https://buffer.com/add?text=' . $url . '&url=' . $url
);
}
if (getOption('scriptless_socialsharing_delicious')) {
$buttons[] = array(
'class' => 'sharingicon-delicious',
'title' => 'Delicious',
'url' => 'https://delicious.com/save?v=5&provider=' . $gallerytitle . '&noui&jump=close&url=' . $url . '&title=' . $title
);
}
if (getOption('scriptless_socialsharing_evernote')) {
$buttons[] = array(
'class' => 'sharingicon-evernote',
'title' => 'Evernote',
'url' => 'https://www.evernote.com/clip.action?url=' . $url . '&title=' . $title
);
}
if (getOption('scriptless_socialsharing_wordpress')) {
$buttons[] = array(
'class' => 'sharingicon-wordpress',
'title' => 'WordPress',
'url' => 'https://wordpress.com/press-this.php?u=' . $url . '&t=' . $title
);
}
if (getOption('scriptless_socialsharing_pocket')) {
$buttons[] = array(
'class' => 'sharingicon-get-pocket',
'title' => 'Pocket',
'url' => 'https://getpocket.com/save?url=' . $url . '&title=' . $title
);
}
if (getOption('scriptless_socialsharing_email')) {
$buttons[] = array(
'class' => 'sharingicon-envelope-o',
'title' => gettext('e-mail'),
'url' => 'mailto:?subject=' . $title . '&body=' . $url
);
}
return $buttons;
}
static function printButtons($text = '', $customtext = null, $iconsonly = null) {
$buttons = self::getButtons($text, '', $customtext);
if (is_null($iconsonly)) {
$iconsonly = getOption('scriptless_socialsharing_iconsonly');
}
?>
<ul class="scriptless_socialsharing">
<?php
foreach ($buttons as $button) {
$li_class = '';
if ($button['class'] == 'sharingicon-whatsapp') {
$li_class = ' class="whatsappLink hidden"';
}
?>
<li<?php echo $li_class; ?>>
<a class="<?php echo $button['class']; ?>" href="<?php echo $button['url']; ?>" title="<?php echo $button['title']; ?>" target="_blank">
<?php
if (!$iconsonly) {
echo $button['title'];
}
?>
</a>
</li>
<?php
if ($button['class'] == 'sharingicon-whatsapp') { ?>
<script>
(navigator.userAgent.match(/(iPhone)/g)) ? $('.whatsappLink').removeClass('hidden') : null;
</script>
<?php
}
} ?>
</ul>
<?php
}
}