function x_shortcode_share($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'title' => '', 'facebook' => '', 'twitter' => '', 'google_plus' => '', 'linkedin' => '', 'pinterest' => '', 'reddit' => '', 'email' => ''), $atts, 'x_share')); $share_url = urlencode(get_permalink()); $share_title = urlencode(get_the_title()); $share_source = urlencode(get_bloginfo('name')); $share_image_info = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $share_image = function_exists('x_get_featured_image_with_fallback_url') ? urlencode(x_get_featured_image_with_fallback_url()) : urlencode($share_image_info[0]); if ($linkedin == 'true') { $share_content = urlencode(cs_get_raw_excerpt()); } $tooltip_attr = cs_generate_data_attributes_extra('tooltip', 'hover', 'bottom'); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-entry-share ' . esc_attr($class) : 'x-entry-share'; $style = $style != '' ? 'style="' . $style . '"' : ''; $title = $title != '' ? $title : __('Share this Post', csl18n()); $facebook = $facebook == 'true' ? "<a href=\"#share\" {$tooltip_attr} class=\"x-share\" title=\"" . __('Share on Facebook', csl18n()) . "\" onclick=\"window.open('http://www.facebook.com/sharer.php?u={$share_url}&t={$share_title}', 'popupFacebook', 'width=650, height=270, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i></a>" : ''; $twitter = $twitter == 'true' ? "<a href=\"#share\" {$tooltip_attr} class=\"x-share\" title=\"" . __('Share on Twitter', csl18n()) . "\" onclick=\"window.open('https://twitter.com/intent/tweet?text={$share_title}&url={$share_url}', 'popupTwitter', 'width=500, height=370, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i></a>" : ''; $google_plus = $google_plus == 'true' ? "<a href=\"#share\" {$tooltip_attr} class=\"x-share\" title=\"" . __('Share on Google+', csl18n()) . "\" onclick=\"window.open('https://plus.google.com/share?url={$share_url}', 'popupGooglePlus', 'width=650, height=226, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i></a>" : ''; $linkedin = $linkedin == 'true' ? "<a href=\"#share\" {$tooltip_attr} class=\"x-share\" title=\"" . __('Share on LinkedIn', csl18n()) . "\" onclick=\"window.open('http://www.linkedin.com/shareArticle?mini=true&url={$share_url}&title={$share_title}&summary={$share_content}&source={$share_source}', 'popupLinkedIn', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-linkedin-square\" data-x-icon=\"\"></i></a>" : ''; $pinterest = $pinterest == 'true' ? "<a href=\"#share\" {$tooltip_attr} class=\"x-share\" title=\"" . __('Share on Pinterest', csl18n()) . "\" onclick=\"window.open('http://pinterest.com/pin/create/button/?url={$share_url}&media={$share_image}&description={$share_title}', 'popupPinterest', 'width=750, height=265, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-pinterest-square\" data-x-icon=\"\"></i></a>" : ''; $reddit = $reddit == 'true' ? "<a href=\"#share\" {$tooltip_attr} class=\"x-share\" title=\"" . __('Share on Reddit', csl18n()) . "\" onclick=\"window.open('http://www.reddit.com/submit?url={$share_url}', 'popupReddit', 'width=875, height=450, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-reddit-square\" data-x-icon=\"\"></i></a>" : ''; $email = $email == 'true' ? "<a href=\"mailto:?subject=" . get_the_title() . "&body=" . __('Hey, thought you might enjoy this! Check it out when you have a chance:', csl18n()) . " " . get_permalink() . "\" {$tooltip_attr} class=\"x-share email\" title=\"" . __('Share via Email', csl18n()) . "\"><span><i class=\"x-icon-envelope-square\" data-x-icon=\"\"></i></span></a>" : ''; $output = "<div {$id} class=\"{$class}\" {$style}>" . '<p>' . $title . '</p>' . '<div class="x-share-options">' . $facebook . $twitter . $google_plus . $linkedin . $pinterest . $reddit . $email . '</div>' . '</div>'; return $output; }
function x_social_meta() { $url = get_permalink(); $type = is_singular() ? 'article' : 'website'; $image = x_get_featured_image_with_fallback_url(); $title = the_title_attribute(array('echo' => false)); $site_name = get_bloginfo('name'); $description = is_singular() ? trim(wp_trim_words(strip_shortcodes(strip_tags(get_post()->post_content)), 35, ''), '.!?,;:-') . '…' : get_bloginfo('description'); if ($description == '…') { $description = get_bloginfo('description'); } echo '<meta property="og:site_name" content="' . $site_name . '">'; echo '<meta property="og:title" content="' . $title . '">'; echo '<meta property="og:description" content="' . $description . '">'; echo '<meta property="og:image" content="' . $image . '">'; echo '<meta property="og:url" content="' . $url . '">'; echo '<meta property="og:type" content="' . $type . '">'; }
function x_portfolio_item_social() { $share_project_title = x_get_option('x_portfolio_share_project_title', __('Share this Project', '__x__')); $enable_facebook = x_get_option('x_portfolio_enable_facebook_sharing', '1'); $enable_twitter = x_get_option('x_portfolio_enable_twitter_sharing', '1'); $enable_google_plus = x_get_option('x_portfolio_enable_google_plus_sharing', ''); $enable_linkedin = x_get_option('x_portfolio_enable_linkedin_sharing', ''); $enable_pinterest = x_get_option('x_portfolio_enable_pinterest_sharing', ''); $enable_reddit = x_get_option('x_portfolio_enable_reddit_sharing', ''); $enable_email = x_get_option('x_portfolio_enable_email_sharing', ''); $share_url = urlencode(get_permalink()); $share_title = urlencode(get_the_title()); $share_source = urlencode(get_bloginfo('name')); $share_content = urlencode(get_the_excerpt()); $share_image = urlencode(x_get_featured_image_with_fallback_url()); $facebook = $enable_facebook == '1' ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __('Share on Facebook', '__x__') . "\" onclick=\"window.open('http://www.facebook.com/sharer.php?u={$share_url}&t={$share_title}', 'popupFacebook', 'width=650, height=270, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i></a>" : ''; $twitter = $enable_twitter == '1' ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __('Share on Twitter', '__x__') . "\" onclick=\"window.open('https://twitter.com/intent/tweet?text={$share_title}&url={$share_url}', 'popupTwitter', 'width=500, height=370, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i></a>" : ''; $google_plus = $enable_google_plus == '1' ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __('Share on Google+', '__x__') . "\" onclick=\"window.open('https://plus.google.com/share?url={$share_url}', 'popupGooglePlus', 'width=650, height=226, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i></a>" : ''; $linkedin = $enable_linkedin == '1' ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __('Share on LinkedIn', '__x__') . "\" onclick=\"window.open('http://www.linkedin.com/shareArticle?mini=true&url={$share_url}&title={$share_title}&summary={$share_content}&source={$share_source}', 'popupLinkedIn', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-linkedin-square\" data-x-icon=\"\"></i></a>" : ''; $pinterest = $enable_pinterest == '1' ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __('Share on Pinterest', '__x__') . "\" onclick=\"window.open('http://pinterest.com/pin/create/button/?url={$share_url}&media={$share_image}&description={$share_title}', 'popupPinterest', 'width=750, height=265, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-pinterest-square\" data-x-icon=\"\"></i></a>" : ''; $reddit = $enable_reddit == '1' ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __('Share on Reddit', '__x__') . "\" onclick=\"window.open('http://www.reddit.com/submit?url={$share_url}', 'popupReddit', 'width=875, height=450, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-reddit-square\" data-x-icon=\"\"></i></a>" : ''; $email = $enable_email == '1' ? "<a href=\"mailto:?subject=" . get_the_title() . "&body=" . __('Hey, thought you might enjoy this! Check it out when you have a chance:', '__x__') . " " . get_permalink() . "\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share email\" title=\"" . __('Share via Email', '__x__') . "\"><span><i class=\"x-icon-envelope-square\" data-x-icon=\"\"></i></span></a>" : ''; if ($enable_facebook == '1' || $enable_twitter == '1' || $enable_google_plus == '1' || $enable_linkedin == '1' || $enable_pinterest == '1' || $enable_reddit == '1' || $enable_email == '1') { ?> <div class="x-entry-share man"> <div class="x-share-options"> <p><?php echo $share_project_title; ?> </p> <?php echo $facebook . $twitter . $google_plus . $linkedin . $pinterest . $reddit . $email; ?> </div> </div> <?php } }