Widgets

Widgetifying the web; one widget at a time.

We turn PHP code into WordPress widgets.

Go ahead and get started!

Developers Info

Here are some samples of widget that you can create.

User Info Widget

I call this widget "User Info". It's pretty much the same as the standard "Meta" widget without the Wordpress links. It basically builds a list and will be styled based on your theme. It dynamically changes depending on your login status in the same way as the "Meta" widget does.

echo "<ul>";
  wp_register(); 
  echo "<li>";
  wp_loginout(); 
  echo "</li>";
echo "</ul>";


The User Info widget will look something like this.

You can see it in use on our blog.

User Info
Widget Source Code: This code was generated by Widgetifyr.com (V0.04) from the few lines of code above.
<?php
/*
Plugin Name: User Info
Plugin URI: http://www.widgetifyr.com
Description: Modified Meta Widget
Author: Glenn Bennett
Version: 0.1
Author URI: http://www.widgetifyr.com
*/


	// We're putting the plugin's functions inside the init function to ensure the
	// required Sidebar Widget functions are available.
	
	function widget_userInfo_init() 
	{
		/* Your custom code starts here */
		/* ---------------------------- */
		
		/* Your Function */
		function userInfo()
		{
			
			/* Your Code ----------------- */ 
			
			echo "<ul>";
			wp_register(); 
			echo "<li>";
			wp_loginout(); 
            echo "</li>";
			echo "</ul>";
			
			
			/* End of Your Code ---------- */
			
		}
		
		/* -------------------------- */
		/* Your custom code ends here */
		
		function widget_userInfo($args) 
		{
			
	  	  // Collect our widget's options, or define their defaults.
		  $options = get_option('widget_userInfo');
		  $title = empty($options['title']) ? __('User Info') : $options['title'];
			
		  extract($args);
		  echo $before_widget;
		  echo $before_title;
		  echo $title;
		  echo $after_title;
		  userInfo();
		  echo $after_widget;
	  }  
	  
	  // This is the function that outputs the form to let users edit
	  // the widget's title. It's an optional feature, but were're doing 
	  // it all for you so why not!
				
	  function widget_userInfo_control()
	  {
					
	    // Collect our widget options.
		$options = $newoptions = get_option('widget_userInfo');
					
		// This is for handing the control form submission.
		if ( $_POST['widget_userInfo-submit'] ) 
		{
		  // Clean up control form submission options
		  $newoptions['title'] = strip_tags(stripslashes($_POST['widget_userInfo-title']));
		}
							
		// If original widget options do not match control form
		// submission options, update them.
		if ( $options != $newoptions ) 
		{
		  $options = $newoptions;
		  update_option('widget_userInfo', $options);
		}
									
		$title = attribute_escape($options['title']);
									
		echo '<p><label for="userInfo-title">';
		echo 'Title: <input style="width: 250px;" id="widget_userInfo-title" name="widget_userInfo-title" type="text" value="';
		echo $title;
		echo '" />';
		echo '</label></p>';
		echo '<input type="hidden" id="widget_userInfo-submit" name="widget_userInfo-submit" value="1" />';
	  }
								
								
	  // This registers the widget.
	  register_sidebar_widget('User Info', 'widget_userInfo');
								
	  // This registers the (optional!) widget control form.
	  register_widget_control('User Info', 'widget_userInfo_control');
								
	}
							
	add_action('plugins_loaded', 'widget_userInfo_init');
							
?>