Twitter Updates
  • someone offered my something pretty cool. my brain now has big decisions to make 17 hours ago

Category Archives: WordPress

FaceBook Share

/*
Plugin Name: Very Simple FaceBook Share
Plugin URI: http://www.paulOr.net/facebook-share/
Description: A very simple shortcode plugin which will allow you to put a facebook sharecode on any page or post via [fbshare] - you can also style it any way with [fbshare style="color:#ffffff; text-decoration: underline;"]
Author: Paul Fraser
Version: 1
Author URI: http://www.paulOr.net
*/
function FBShare($params, $content = null) {
extract(shortcode_atts(array(
'style' => ''
), $params));
return '<a '.($style == '' ? '' : " style=\"$style\"").' name="fb_share"></a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>';
}
add_shortcode('fbshare','FBShare');

Very simple facebook share plugin which allows you to just add a shortcode to a page or post & style it via [fbshare style="blah: blah;"]

Download: FBShare.php

WordPress Tshirts

20111203-125405 PM.jpg

20111203-125417 PM.jpg

Add Product Images into Shopp Receipt

## ADD THIS INTO FUNCTIONS.PHP
add_filter('shopp_tag_purchase_item-image','purchased_image',10, 3);
function purchased_image($result, $options, $Purchase) {
   $item = current($Purchase->purchased);
   $product = new Product($id=$item->product);
   return $product->tag($property='coverimage');
}

## NOW YOU CAN SHOW THE IMAGES INSIDE THE PURCHASED ITEMS WHILE LOOP
shopp('purchase','item-image');

I’ve long said Shopp is a total bellend, they totally missed out putting the product image tags into half the hooks. The above, will allow you to show the product image in the receipt, after all – its always nice to show you what you have bought after you’ve paid good money.

Get a grip Shopp – I’m so moving to WooCommerce.

WordPress Dynamic Navigation

Sometimes in WordPress you don’t want to use the custom menus for some navigation parts, like sub navigations in sidebars or something. Sometimes custom menus are just over kill, especially if every page has a sub navigation made up of child pages.

Heres an easy way of generating the sub navigations of Parent / Child pages & also showing the Parent page title above it.

if($post->post_parent) {
	$post_ancestors = get_post_ancestors($post->ID);
	$post_root = count($post_ancestors)-1;
	$post_parent = $post_ancestors[$post_root];
	$title = get_the_title($post_ancestors[$post_root]);
} else {
	$post_parent = $post->ID;
	$title = get_the_title($post->ID);
}
$children = wp_list_pages("title_li=&child_of=".$post_parent."&echo=0&depth=1");
if($children) {
	echo '<div id="page_left">'."\n";
	echo '	<h3>'.$title.'</h3>'."\n";
	echo '	<ul id="subnav">'."\n";
	echo 	    $children."\n";
	echo '	</ul>'."\n";
	echo '</div>'."\n";
}

WordPress Plugin: Custom Class Text Widget

Every now and then at Inigo Media @Ben_Seven likes to come sit by me and pick through my work finding issues and generally tries to cause me the greatest amount of stress. Yesterday was no different, apart from he had quite a cool idea regarding WordPress widgets.

Currently there is no way to define multiple widgets with the same class – unless you do all or none. @Ben_Seven had the idea of somehow getting a custom class into the widget area while still maintaining the general look/feel & presentation on the front end.

I give to you; Custom Class Text Widget.

/*
Plugin Name: Custom Class on Text Widgets
Plugin URI: http://www.inigo.net
Description: A customized text widget to give custom classes on each widget area.
Author: Paul @ Inigo
Version: 1.0
Author URI: http://www.inigo.net
*/

	class customClassText extends WP_Widget {
		function customClassText() {
			parent::WP_Widget('customclasstext', $name = 'Custom Class Text Widget');
		}

		function widget($args, $instance) {
			extract($args);
			$title 			= apply_filters('widget_title', $instance['title']);
			$customClass 	= apply_filters('widget_title', $instance['customClass']);
			$text 			= $instance['text'];

			echo '<div class="'.$customClass.'">'."\n";
			echo 	$before_widget;
			echo 	$before_title.$title.$after_title;
			echo 	$text;
			echo 	$after_widget;
			echo '</div>'."\n";
		}

		function update($new_instance, $old_instance) {
			$instance = $old_instance;
			$instance['title'] 			= strip_tags($new_instance['title']);
			$instance['customClass'] 	= strip_tags($new_instance['customClass']);
			$instance['text'] 			= $new_instance['text'];
			return $instance;
		}

		function form($instance) {
			if($instance) {
				$title 			= esc_attr($instance['title']);
				$customClass 	= esc_attr($instance['customClass']);
				$text 			= esc_attr($instance['text']);
			} else {
				$title 			= __('', 'text_domain');
				$customClass 	= __('', 'text_domain');
				$text 			= __('', 'text_domain');
			}

			echo '<p><label for="'.$this->get_field_id('title').'">'._e('Title:').'</label>';
			echo '<input class="widefat" id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" type="text" value="'.$title.'" /></p>';
			echo '<p><label for="'.$this->get_field_id('customClass').'">'._e('Custom Class:'.'</label>';
			echo '<input class="widefat" id="'.$this->get_field_id('customClass').'" name="'.$this->get_field_name('customClass').'" type="text" value="'.$customClass;.'" /></p>';
			echo '<p><label for="'.$this->get_field_id('text').'">'._e('Text:').'</label>';
			echo '<textarea class="widefat" id="'.echo $this->get_field_id('text').'" name="'.$this->get_field_name('text').'" rows="20">'.$text.'</textarea></p>';

		}
	}

	add_action('widgets_init', create_function('', 'return register_widget("customClassText");'));

Its aso a multi-widget which means you can have as many instances as you like of it – something most WordPress developers miss out of there own widgets.

I made this on Inigo Media time, so Inigo ftw on this!