function wppa_get_related_data() { global $wpdb; $pagid = wppa_get_the_id(); $data = $wpdb->get_var("SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `ID` = " . $pagid); wppa_dbg_q('Q-reld'); $data = str_replace(array(' ', ',', '.', "\t", "\r", "0", "x0B", "\n"), ';', $data); $data = strip_tags($data); $data = strip_shortcodes($data); $data = wppa_sanitize_tags($data, true); $data = trim($data, "; \t\n\r\v"); return $data; }
function wppa_get_share_html($id, $key = '', $js = true, $single = false) { global $wppa_locale; $p = wppa_get_the_id(); $p_void = explode(',', wppa_opt('sm_void_pages')); if (!empty($p_void) && in_array($p, $p_void)) { return ''; } $do_it = false; if (!wppa('is_slideonly') || $key == 'lightbox') { if (wppa_switch('share_on') && !wppa_in_widget()) { $do_it = true; } if (wppa_switch('share_on_widget') && wppa_in_widget()) { $do_it = true; } if (wppa_switch('share_on_lightbox')) { $do_it = true; } } if (!$do_it) { return ''; } // The share url if (wppa_in_widget()) { if (wppa_opt('widget_sm_linktype') == 'home') { $share_url = home_url(); } else { $share_url = get_permalink(wppa_get_the_landing_page('widget_sm_linkpage', __('Social media landing page', 'wp-photo-album-plus'))); $alb = wppa_get_photo_item($id, 'album'); $oc = wppa_opt('widget_sm_linkpage_oc'); $share_url .= '?wppa-album=' . $alb . '&wppa-photo=' . $id . '&wppa-cover=0&wppa-occur=' . $oc; if (wppa_switch('share_single_image') || $single) { $share_url .= '&wppa-single=1'; } } } else { $share_url = wppa_get_image_page_url_by_id($id, wppa_switch('share_single_image')); $share_url = str_replace('&', '&', $share_url); } $share_url = wppa_convert_to_pretty(wppa_encrypt_url($share_url), 'nonames'); // Protect url against making relative $share_url = wppa_protect_relative($share_url); // The share title $photo_name = wppa_get_photo_name($id); // The share description $photo_desc = wppa_html(wppa_get_photo_desc($id)); $photo_desc = strip_shortcodes(wppa_strip_tags($photo_desc, 'all')); // The default description $site = str_replace('&', __('and', 'wp-photo-album-plus'), get_bloginfo('name')); $see_on_site = sprintf(__('See this image on %s', 'wp-photo-album-plus'), $site); // The share image. Must be the fullsize image for facebook. // If you take the thumbnail, facebook takes a different image at random. $share_img = wppa_get_photo_url($id); // The icon size if (wppa_in_widget() && $key != 'lightbox' || $key == 'thumb') { $s = '16'; $br = '2'; } else { $s = wppa_opt('share_size'); $br = ceil($s / 8); } // qr code if (wppa_switch('share_qr') && $key != 'thumb') { $src = 'http://api.qrserver.com/v1/create-qr-code/' . '?data=' . urlencode($share_url) . '&size=80x80' . '&color=' . trim(wppa_opt('qr_color'), '#') . '&bgcolor=' . trim(wppa_opt('qr_bgcolor'), '#'); $qr = '<div style="float:left; padding:2px;" >' . '<img' . ' src="' . $src . '"' . ' title="' . esc_attr($share_url) . '"' . ' alt="' . __('QR code', 'wp-photo-album-plus') . '"' . ' />' . '</div>'; } else { $qr = ''; } // twitter share button if (wppa_switch('share_twitter')) { $tweet = urlencode($see_on_site) . ': '; $tweet_len = strlen($tweet) + '1'; $tweet .= urlencode($share_url); // find first '/' after 'http( s )://' rest doesnt count for twitter chars $url_len = strpos($share_url, '/', 8) + 1; $tweet_len += $url_len > 1 ? $url_len : strlen($share_url); $rest_len = 140 - $tweet_len; if (wppa_switch('show_full_name')) { if ($rest_len > strlen($photo_name)) { $tweet .= ' ' . urlencode($photo_name); $rest_len -= strlen($photo_name); $rest_len -= '2'; } else { $tweet .= ' ' . urlencode(substr($photo_name, 0, $rest_len)) . '...'; $rest_len -= strlen(substr($photo_name, 0, $rest_len)); $rest_len -= '5'; } } if ($photo_desc) { if ($rest_len > strlen($photo_desc)) { $tweet .= ': ' . urlencode($photo_desc); } elseif ($rest_len > 8) { $tweet .= ': ' . urlencode(substr($photo_desc, 0, $rest_len)) . '...'; } } $tweet = urlencode($share_url); $tw = '<div class="wppa-share-icon" style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Tweet %s on Twitter', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="https://twitter.com/intent/tweet?text=' . $tweet . '"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'twitter.png"' . ' style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Twitter', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>'; } else { $tw = ''; } // Google if (wppa_switch('share_google')) { $go = '<div class="wppa-share-icon" style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Share %s on Google+', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="https://plus.google.com/share?url=' . urlencode($share_url) . '"' . ' onclick="javascript:window.open( this.href, \\"\\", \\"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\\" );return false;"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'google.png"' . ' style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Google+', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>'; } else { $go = ''; } // Pinterest $desc = urlencode($see_on_site) . ': ' . urlencode($photo_desc); if (strlen($desc) > 500) { $desc = substr($desc, 0, 495) . '...'; } if (wppa_switch('share_pinterest')) { $pi = '<div class="wppa-share-icon" style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Share %s on Pinterest', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="http://pinterest.com/pin/create/button/?url=' . urlencode($share_url) . '&media=' . urlencode(str_replace('/thumbs/', '/', $share_img)) . '&description=' . $desc . '"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'pinterest.png"' . ' style="height:' . $s . 'px;vertical-align:top;border-radius:' . $br . 'px;"' . ' alt="' . esc_attr(__('Share on Pinterest', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>'; } else { $pi = ''; } // LinkedIn if (wppa_switch('share_linkedin') && $key != 'thumb' && $key != 'lightbox') { /* old style that does no longer work $li = '<script' . ' type="text/javascript"' . ' src="//platform.linkedin.com/in.js"' . ' >' . 'lang: ' . $wppa_locale . '</script>' . '<script' . ' type="IN/Share"' . ' data-url="' . urlencode( $share_url ) . '"' . ' data-counter="top"' . ' >' . '</script>'; if ( $js ) { $li = str_replace( '<', '[', $li ); } */ // New style under development $li = '<div class="wppa-share-icon" style="float:left; padding:0 2px;" >' . '<a' . ' href="https://www.linkedin.com/shareArticle?mini=true&url=' . urlencode($share_url) . '" >' . '<img src="' . wppa_get_imgdir() . 'linkedin.png" style="height:' . $s . 'px;vertical-align:top;" />' . '</a>' . '</div>'; } else { $li = ''; } // Facebook $fb = ''; $need_fb_init = false; $small = 'thumb' == $key; if ('lightbox' == $key) { if (wppa_switch('facebook_like') && wppa_switch('share_facebook')) { $lbs = 'max-width:62px; max-height:96px; overflow:show;'; } else { $lbs = 'max-width:62px; max-height:64px; overflow:show;'; } } else { $lbs = ''; } // Share if (wppa_switch('share_facebook') && !wppa_switch('facebook_like')) { if ($small) { $fb .= '<div' . ' class="fb-share-button"' . ' style="float:left; padding:0 2px;"' . ' data-href="' . $share_url . '"' . ' data-type="icon"' . ' >' . '</div>'; } else { $disp = wppa_opt('fb_display'); if ('standard' == $disp) { $disp = 'button'; } $fb .= '<div' . ' class="fb-share-button"' . ' style="float:left; padding:0 2px; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-type="' . $disp . '"' . ' >' . '</div>'; } $need_fb_init = true; } // Like if (wppa_switch('facebook_like') && !wppa_switch('share_facebook')) { if ($small) { $fb .= '<div' . ' class="fb-like"' . ' style="float:left; padding:0 2px; "' . ' data-href="' . $share_url . '"' . ' data-layout="button"' . ' >' . '</div>'; } else { $fb .= '<div' . ' class="fb-like"' . ' style="float:left; padding:0 2px; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-layout="' . wppa_opt('fb_display') . '"' . ' >' . '</div>'; } $need_fb_init = true; } // Like and share if (wppa_switch('facebook_like') && wppa_switch('share_facebook')) { if ($small) { $fb .= '<div' . ' class="fb-like"' . ' style="float:left; padding:0 2px; "' . ' data-href="' . $share_url . '"' . ' data-layout="button"' . ' data-action="like"' . ' data-show-faces="false"' . ' data-share="true"' . ' >' . '</div>'; } else { $fb .= '<div' . ' class="fb-like"' . ' style="float:left; padding:0 2px; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-layout="' . wppa_opt('fb_display') . '"' . ' data-action="like"' . ' data-show-faces="false"' . ' data-share="true"' . ' >' . '</div>'; } $need_fb_init = true; } // Comments if (wppa_switch('facebook_comments') && !wppa_in_widget() && $key != 'thumb' && $key != 'lightbox') { $width = wppa('auto_colwidth') ? '100%' : wppa_get_container_width(true); if (wppa_switch('facebook_comments')) { $fb .= '<div style="clear:both;" ></div>' . '<div class="wppa-fb-comments-title" style="color:blue;" >' . __('Comment on Facebook:', 'wp-photo-album-plus') . '</div>'; $fb .= '<div class="fb-comments" data-href="' . $share_url . '" data-width="' . $width . '"></div>'; $need_fb_init = true; } } // Need init? if ($need_fb_init) { if ($js && $key != 'thumb') { $fb .= '[script>wppaFbInit();[/script>'; } else { $fb .= '<script>wppaFbInit();</script>'; } } return $qr . $tw . $go . $pi . $li . $fb . '<div style="clear:both"></div>'; }