Keep Calm & Carry On Coding

Poor Clio

20110926-033520 AM.jpg

Gutted.

Jack walking like a boss – 11 months old.

20110914-011214.jpg

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!

VanBook 2.0

Back in the days of 2008 when Vanilla Forums were newish on the scene and just taking off, someone by the name of dkodr in the Vanilla Community created a theme called VanBook losly based on the FaceBook Developers pages.

Recently I’ve been doing a lot of tinkering with Vanilla to get myself up to speed with Gardens APIs and such – I also decided to create my own theme, well… I decided to recreate probably the single best Vanilla 1 theme that was available, Vanbook.

So I’m working on VanBook 2.0, there has been no mention of this in the Vanilla Community – which as of about a year ago I myself have not been active on. I did ask OP if he minded me tinkering with his theme quite a while ago and he said he didn’t mind.

At the moment there are not really any amazing themes available for Vanilla and I’m hoping this rehash of a once popular theme gets some good reception.