Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Plugin Name: SunriseWeb.ca Sharing Buttons
- Description: Add Sharing buttons to content area of ElegantThemes.com themes, includes dependency on Get The Image plugin for Pinterest functionality and looks for default image in theme options
- Version: 0.01
- Author: Brad Trivers
- Author URI: http://sunriseweb.ca
- */
- /**
- * @author Brad Trivers <[email protected]>
- */
- if(!function_exists('sharingButtons_addThis') && !function_exists('getThumbnailSunriseWeb')) {
- add_filter( 'the_content', 'sharingButtons_addThis', 100 );
- // Put AddThis buttons at the bottom of every post page.
- function sharingButtons_addThis( $content ) {
- global $post;
- $thisImage = getThumbnailSunriseWeb( $post->ID );
- $pinterestURL = $thisImage['url'];
- $currentURL = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- $content .= ' <!-- AddThis Button BEGIN -->';
- $content .= ' <div class="addthis_toolbox addthis_default_style ">';
- $content .= ' <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>';
- if(!empty($pinterestURL)) {
- $content .= ' <a class="addthis_button_pinterest" pi:pinit:url="'. $currentURL .'" pi:pinit:media="'. $pinterestURL .'" pi:pinit:layout="horizontal"></a>';
- }
- $content .= ' <a class="addthis_button_tweet"></a>';
- $content .= ' <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>';
- $content .= ' <a class="addthis_counter addthis_pill_style"></a> ';
- $content .= ' </div>';
- $content .= ' <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=btrivers"></script>';
- $content .= ' <!-- AddThis Button END --> ';
- // Returns the content.
- return $content;
- }
- //Function to get the post thumbnail
- //relies on Get the image plugin and Default Featured Image theme option
- //returns array of image parameters - always contains URL
- function getThumbnailSunriseWeb( $postID ) {
- global $shortname;
- $defaultImage = get_option($shortname.'_defaultFeaturedImage');
- if($defaultImage == "") {
- $defaultImage = (get_option($shortname.'_logo') <> '') ? get_option($shortname.'_logo') : get_bloginfo('template_directory').'/images/logo.png';
- }
- // if($format != 'array') {
- // $format = 'img';
- // }
- if(trim($postID) != "" && !is_home()) {
- if ( function_exists( 'get_the_image' ) ) {
- $getTheImageOptions = array(
- 'meta_key' => array( 'Thumbnail', 'thumbnail' ),
- 'post_id' => $postID,
- 'attachment' => true,
- 'the_post_thumbnail' => true,
- 'size' => 'large',
- 'default_image' => $defaultImage,
- 'order_of_image' => 1,
- 'link_to_post' => true,
- 'image_class' => false,
- 'image_scan' => false,
- 'width' => false,
- 'height' => false,
- 'format' => 'array',
- 'meta_key_save' => false,
- 'callback' => null,
- 'cache' => true,
- 'echo' => false
- );
- $thisImage = get_the_image($getTheImageOptions);
- // $url = $thisImage['url'];
- } else {
- $thisImage['url'] = wp_get_attachment_url( get_post_thumbnail_id($postID) );
- if(!$thisImage['url']) {
- $thisImage['url'] = $defaultImage;
- }
- }
- } else {
- $thisImage['url'] = $defaultImage;
- }
- return $thisImage;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment