setArgs( array( 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_widget' => '

    ' ) ); // insert any of the default widget types using the associated addX function. // the $new_args variable allows you to optionally use a "one-of" $args array $my_variable->addArchives( $title, $display_count, $dropdown, $new_args ); List of Functions: addArchives(); addCalendar(); addCategories(); addLinks(); addMeta(); addPages(); addRecentComments(); addRecentPosts(); addRSS(); addSearch(); addTagCloud(); addText(); */ if( !class_exists( 'bitacreWidgets', false ) ) { class bitacreWidgets { var $version = '1.2.0'; // library version var $uid = ''; // unique menu id // default widget $args var $args = array( 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ' ); // constructor function bitacreWidgets() { $this->uid = uniqid(); } // set the_widget $args function setArgs( $new_args ) { if( !is_array( $new_args ) ) return false; foreach( $args as $key => $value ) if( isset( $new_args[$key] ) ) $args[$key] = $new_args[$key]; return true; } // generic "add widget" function function theWidget( $class, $instance='', $new_args='' ) { // check new args foreach( $this->args as $key => $value ) if( !array_key_exists( $key, $new_args ) ) $new_args[$key] = $value; // sprintf css $widget_class = substr( strtolower( $class ), 3 ); $widget_id = substr( str_replace( '_', '-', $widget_class ), 7 ) . '-' . $this->uid; $new_args['before_widget'] = sprintf( $new_args['before_widget'], $widget_id, $widget_class ); // add widget the_widget( $class, $instance, $new_args ); } /* Archives Widget $title == Widget display title $display_count == show post counts/totals? $dropdown == display as a dropdown menu (true) or unordered list (false) */ function addArchives( $title='Archives', $display_count=0, $dropdown=0, $new_args='' ) { $this->theWidget( 'WP_Widget_Archives', array( 'title' => $title, 'count' => $display_count, 'dropdown' => $dropdown ), $new_args ); } /* Calendar Widget $title == Widget display title */ function addCalendar( $title='', $new_args='' ) { $this->theWidget( 'WP_Widget_Calendar', array( 'title' => $title ), $new_args ); } /* Categories Widget $title == Widget display title $display_count == show post counts/totals? $dropdown == display as a dropdown menu (true) or unordered list (false) $hierarchical == show nested parent-child relationships (true) or flat list (false)? */ function addCategories( $title='Categories', $display_count=0, $dropdown=0, $hierarchical=0, $new_args='' ) { $this->theWidget( 'WP_Widget_Categories', array( 'title' => $title, 'count' => $display_count, 'dropdown' => $dropdown, 'hierarchical' => $hierarchical ), $new_args ); } /* Links Widget $title == Widget display title $category == show links from specific categories (comma separated IDs), or all categories (false) $description == include descripitons of links $rating == display link's rating $images == display link's associated image $show_name = if displaying link image, show link name as alt tag? */ function addLinks( $title='Links', $category=false, $description=0, $rating=0, $images=0, $show_name=1, $new_args='' ) { $this->theWidget( 'WP_Widget_Links', array( 'title' => $title, 'category' => $category, 'description' => $description, 'rating' => $rating, 'images' => $images, 'name' => $show_name ), $new_args ); } /* Meta Widget $title == Widget display title */ function addMeta( $title='Meta', $new_args='' ) { $this->theWidget( 'WP_Widget_Meta', array( 'title' => $title ), $new_args ); } /* Pages Widget $title == Widget display title $sortby == post_title | menu_order | post_date | post_modified | ID | post_author | post_name $exclude == page IDs to exclude from listing or show all pages (null) */ function addPages( $title='Meta', $sortby='menu_order', $exclude='', $new_args='' ) { $this->theWidget( 'WP_Widget_Pages', array( 'title' => $title, 'sortby' => $sortby, 'exclude' => $exclude ), $new_args ); } /* Recent Comments Widget $title == Widget display title $number == How many recent comments to show (MAX==15) */ function addRecentComments( $title='Recent Comments', $number=5, $new_args='' ) { $this->theWidget( 'WP_Widget_Recent_Comments', array( 'title' => $title, 'number' => $number ), $new_args ); } /* Recent Posts Widget $title == Widget display title $number == How many recent comments to show (MAX==15) */ function addRecentPosts( $title='Recent Posts', $number=5, $new_args='' ) { $this->theWidget( 'WP_Widget_Recent_Posts', array( 'title' => $title, 'number' => $number ), $new_args ); } /* RSS Widget $title == Widget display title (inherited from list if null $url == RSS or Atom feed URL to include $items == the number of items to show $show_summary == show RSS item summary $show_author == show RSS item author $show_date == show RSS item date */ function addRSS( $title='', $url='', $items=5, $show_summary=0, $show_author=0, $show_date=0, $new_args='' ) { $this->theWidget( 'WP_Widget_RSS', array( 'title' => $title, 'url' => $url, 'items' => $items, 'show_summary' => $show_summary, 'show_author' => $show_author, 'show_date' => $show_date ), $new_args ); } /* Search Widget $title == Widget display title */ function addSearch( $title='', $new_args='' ) { $this->theWidget( 'WP_Widget_Search', array( 'title' => $title ), $new_args ); } /* Tag Cloud Widget $title == Widget display title */ function addTagCloud( $title='Tags', $new_args='' ) { $this->theWidget( 'WP_Widget_Tag_Cloud', array( 'title' => $title ), $new_args ); } /* Text Widget $title == Widget display title */ function addText( $title='', $text='', $filter='widget_text', $new_args='' ) { $this->theWidget( 'WP_Widget_Text', array( 'title' => $title, 'text' => $text, 'filter' => $filter ), $new_args ); } } // end class } // end if( !class_exists ) ?>