Created
August 21, 2012 18:14
-
-
Save AmeliaBriscoe/3418030 to your computer and use it in GitHub Desktop.
Thesis Feature Box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This file adds a feature box of social share icons to the Thesis Theme. | |
* The code compliments my personal Facebook Open Graph Tags Plugin | |
* The Google+ and pinterest javascript needs to be inserted into the Thesis Design Options prior | |
*/ | |
function get_featured_social_share() { | |
//choose which pages the social share buttons will feature on | |
if (!is_front_page() && !is_page(array('contact','about')) && !is_404()){ | |
global $post; | |
if(is_single()){ | |
//if it is a single post | |
$title = get_post_meta($post->ID, 'diva_title', true) ? get_post_meta($post->ID, 'diva_title', true); : 'Share This Tutorial'; | |
$url = get_permalink(); | |
$pinterest_url = get_post_meta($post->ID, 'diva_youtube', true); | |
$video = 'is_video=true&'; | |
if (!$pinterest_url) { | |
$pinterest_url = get_permalink(); | |
$video=''; | |
} | |
$image = get_post_meta($post->ID, 'diva_youtube_image', true) ? get_post_meta($post->ID, 'diva_youtube_image', true) : $image = 'http://ten0nine.com/gintonic/wp-content/themes/1009theme/custom/images/Logo_small.png'; | |
$description = get_post_meta($post->ID, "thesis_description", true); | |
if(!$description){ | |
$text = $post->post_excerpt ? $post->post_excerpt : $text = $post->post_content; | |
$text = str_replace(array("r\n", "\r", "\n"), " ", $text); | |
$text = str_replace(array("\""), "", $text); | |
$text = trim(strip_tags($text)); | |
$more = '.....'; | |
$description = wp_trim_words( $text, 45, $more ); | |
} | |
}else if (is_category()){ | |
//if it is a category page | |
$title = 'Share This Resource'; | |
foreach(get_the_category() as $category){ | |
$catId = $category->cat_ID; | |
$catDescription = $category->description; | |
} | |
$url = get_category_link( $catId ); | |
$pinterest_url = get_category_link( $catId ); | |
$description = $catDescription; | |
$image = 'http://ten0nine.com/gintonic/wp-content/themes/1009theme/custom/images/Logo_small.png'; | |
}else if (is_page()){ | |
//if it is a page | |
$title = get_post_meta($post->ID, 'diva_title', true); | |
if (!$title) { $title = 'Share This';} | |
$url = get_post_meta($post->ID, 'custom_url', true) ? get_post_meta($post->ID, 'custom_url', true) : get_permalink(); | |
if(is_page('confirmation')){ | |
$pinterest_url = $url; | |
}else{ | |
$pinterest_url = get_post_meta($post->ID, 'diva_youtube', true); | |
} | |
$description = get_post_meta($post->ID, "thesis_description", true); | |
if(!$description){ | |
$text = $post->post_excerpt ? $post->post_excerpt : $text = $post->post_content; | |
$text = str_replace(array("r\n", "\r", "\n"), " ", $text); | |
$text = str_replace(array("\""), "", $text); | |
$text = trim(strip_tags($text)); | |
$more = '.....'; | |
$description = wp_trim_words( $text, 45, $more ); | |
} | |
$image = get_post_meta($post->ID, 'diva_youtube_image', true) ? get_post_meta($post->ID, 'diva_youtube_image', true) : $image = 'http://ten0nine.com/gintonic/wp-content/themes/1009theme/custom/images/Logo_small.png'; | |
} | |
?> | |
<div id="feature-box-share"> | |
<div id="social-share"> | |
<div id="shareTitle"> | |
<h4><?php echo $title; ?></h4> | |
</div> | |
<ul> | |
<li class="sidefb"> | |
<fb:like href="<?php echo $url; ?>" ref="bottom_post" send="true" width="320" show_faces="false" font="arial"></fb:like> | |
</li> | |
<li class="sideg"> | |
<g:plusone size="standard" annotation="inline" href="<?php echo $url; ?>"></g:plusone> | |
</li> | |
<li class="sidepin"> | |
<?php | |
echo '<div class="pinterest-posts"><a href="http://pinterest.com/pin/create/button/?url='.urlencode($pinterest_url).'&media='.urlencode($image).'&description='.urlencode($description).'&'.$video.'" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a></div>'; | |
?> | |
</li> | |
<li class="sidetw"> | |
<?php | |
global $post; | |
?> | |
<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php if(is_page('confirmation')){echo $url; }else{ echo wp_get_shortlink();} ?>" data-text="<?php echo $description; ?>" data-count="horizontal">Tweet</a> | |
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> | |
</li> | |
</ul> | |
</div> | |
</div> | |
<?php } | |
} | |
add_action('thesis_hook_feature_box','get_featured_social_share'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment