Ok so, many of you who visit my page are probably thinking “What the heck is this design change?”

Well to be honest it was unexpected that it would need to be changed.  It would seem that the theme (Arras) I had been using had a vulnerability I was unaware of which allowed for some file uploading, and as you can imagine, ended up with my site having a directory full of web shell scripts.  Luckily my host is a super awesome elite system administrator and the individuals who uploaded the malicious scripts didn’t get any further than that.

Shout out and thanks to my host and pal Werner for the dedication to his craft and keeping my web spaces safe for all these years.  You deserve more thank you’s I could ever possibly muster to write.

, , ,

I recently installed the WordPress plugin Jetpack, which puts together some fabulous WP plugins into a bundle. The problem I was having was that Sharedaddy, one of the available bundled plugins, was not being shown in my posts. So I started looking around in the WP plugin forums, and really didn’t find a solution. I almost felt like I had to contact ‘support’ in order to get this working because a lot of the threads posted had such replies.

Anyways, after a little fiddling around and a tip in a thread about a function, I decided to go ahead and code it into my themes functions.php file.

If this breaks your WordPress – don’t blame me, I will attempt to be as clear as possible.

First open up your themes functions.php file, and open up the file at jetpack/modules/sharedaddy/sharing-service.php

If you’re familiar with the functions.php file, you know that this file has functions and miscellaneous stuff related specifically to your theme. The sharing-service.php file has PHP classes which set up the Sharedaddy services for use.

In your functions.php file create a new function for use within the theme. You can name the function anything you want. Go ahead and use this code.

 
function show_sharing($text = '') {
 
	include(ABSPATH . 'wp-content/plugins/jetpack/modules/sharedaddy/sharing-service.php');
 
	static $shared_with_posts = array();
	global $post;
 
	$server = new Sharing_Service;
	$global = $server->get_global_options();
 
	if ( !is_feed() ) {
		if ( $global['show'] == 'posts' && ( is_single() || is_page() ) )
			$show = true;
		elseif ( $global['show'] == 'index' && ( is_home() || is_archive() || is_search() ) )
			$show = true;
		elseif ( $global['show'] == 'posts-index' && ( is_single() || is_page() || is_home() || is_search() || is_archive() ) )
			$show = true;
	}
 
	$switched_status = get_post_meta( $post->ID, 'sharing_disabled', false );
 
	if ( !empty( $switched_status ) )
	{
		$show = false;
	}
 
	// Only show once
	if ( isset( $shared_with_posts[$post->ID] ) )
		$show = false;
 
	$shared_with_posts[$post->ID] = true;
	$sharing_content = '';
 
	if($show)
	{
		$enabled = $server->get_blog_services();
 
		if ( count( $enabled['all'] ) > 0 ) {
			global $post;
 
			$dir = get_option( 'text_direction' );
 
			// Wrapper
			$sharing_content .= '<div class="snap_nopreview sharing robots-nocontent">';
			$sharing_content .= '<ul>';
 
			// Visible items
			$visible = '';
			foreach ( $enabled['visible'] AS $id => $service ) {
				// Individual HTML for sharing service
				$visible .= '<li class="share-'.$service->get_class().' share-regular">';
				$visible .= $service->get_display( $post );
				$visible .= '</li>';
			}
 
			$parts = array();
			if ( $global['sharing_label'] != '' )
				$parts[] = '<li class="sharing_label">'.$global['sharing_label'].'</li>';
 
			$parts[] = $visible;
			if ( count( $enabled['hidden'] ) > 0 )
				$parts[] = '<li class="share-custom"><a href="#" class="sharing-anchor">'._x( 'Share', 'dropdown button', 'jetpack' ).'</a></li>';
 
			if ( $dir == 'rtl' )
				$parts = array_reverse( $parts );
 
			$sharing_content .= implode( '', $parts );			
			$sharing_content .= '<li class="share-end"></li></ul>';
 
			if ( count( $enabled['hidden'] ) > 0 ) {
				$sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;';
 
				if ( count( $enabled['hidden'] ) == 1 )
					$sharing_content .= 'width:150px;';
 
				$sharing_content .= '">';
 
				if ( count( $enabled['hidden'] ) == 1 )
					$sharing_content .= '<ul style="background-image:none;">';
				else
					$sharing_content .= '<ul>';
 
				$count = 1;
				foreach ( $enabled['hidden'] AS $id => $service ) {
					// Individual HTML for sharing service
					$sharing_content .= '<li class="share-'.$service->get_class().'">';
					$sharing_content .= $service->get_display( $post );
					$sharing_content .= '</li>';
 
					if ( ( $count % 2 ) == 0 )
						$sharing_content .= '<li class="share-end"></li>';
 
					$count ++;
				}
 
				// End of wrapper
				$sharing_content .= '<li class="share-end"></li></ul></div></div>';
			}
 
			$sharing_content .= '<div class="sharing-clear"></div></div>';
		}
 
	}
 
	echo $sharing_content;
}

Ok. Basically this function recreates another function found in the sharing-service.php file called sharing_display(), except that it is trimmed up for our purposes…I repeat – dirty hacks. :p

Now that you have a new function in your theme that rebuilds the Sharedaddy services bar, you can add it to any part of your theme with

echo show_sharing();

Celebrate by sharing this link with others

, , , , , , , ,