Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 2.04 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /**
  3.  * @Author      Jonathon byrd
  4.  * @link http://www.jonathonbyrd.com
  5.  * @Package Wordpress
  6.  * @SubPackage Widgets
  7.  * @copyright Proprietary Software, Copyright Byrd Incorporated. All Rights Reserved
  8.  * @Since 1.0.0
  9.  *
  10.  * Plugin Name: Document Widget
  11.  * Plugin URI: http://www.redrokk.com
  12.  * Description: <a href="http://redrokk.com" target="_blank">redrokk</a> Designs and develops software for WordPress, Drupal, Joomla, Cakephp, SugarCRM, Symfony and more!
  13.  * Version: 1.0.0
  14.  * Author: redrokk
  15.  * Author URI: http://www.redrokk.com
  16.  *
  17.  *
  18.  */
  19.  
  20. defined('ABSPATH') or die("Cannot access pages directly.");
  21.  
  22. /**
  23.  * Initializing
  24.  *
  25.  * The directory separator is different between linux and microsoft servers.
  26.  * Thankfully php sets the DIRECTORY_SEPARATOR constant so that we know what
  27.  * to use.
  28.  */
  29. defined("DS") or define("DS", DIRECTORY_SEPARATOR);
  30.  
  31. /**
  32.  * Actions and Filters
  33.  *
  34.  * Register any and all actions here. Nothing should actually be called
  35.  * directly, the entire system will be based on these actions and hooks.
  36.  */
  37. add_action( 'widgets_init', create_function( '', 'register_widget("Document_Widget");' ) );
  38.  
  39.  
  40. /**
  41.  *
  42.  * @author byrd
  43.  * Document Widget
  44.  */
  45. class Document_Widget extends WP_Widget
  46. {
  47.         /**
  48.          * Constructor
  49.          *
  50.          * Registers the widget details with the parent class
  51.          */
  52.         function Document_Widget()
  53.         {
  54.                 // widget actual processes
  55.                 parent::WP_Widget( $id = 'foo_widget', $name = get_class($this), $options = array( 'description' => 'A Foo Widget' ) );
  56.         }
  57.  
  58.         function form($instance)
  59.         {
  60.                 // outputs the options form on admin
  61.                 ?>
  62.                
  63.                 Form goes here
  64.                
  65.                 <?php
  66.         }
  67.  
  68.         function update($new_instance, $old_instance)
  69.         {
  70.                 // processes widget options to be saved
  71.                 $instance = wp_parse_args($old_instance, $new_instance);
  72.                 return $instance;
  73.         }
  74.  
  75.         function widget($args, $instance)
  76.         {
  77.                 // outputs the content of the widget
  78.                 extract( $args );
  79.                 $title = apply_filters( 'widget_title', $instance['title'] );
  80.                
  81.                 echo $before_widget;
  82.                 if ( $title )
  83.                         echo $before_title . $title . $after_title;
  84.                 ?>
  85.                
  86.                 Widget view to users goes here
  87.                
  88.                 <?php
  89.         }
  90.  
  91. }