web/wp-includes/default-widgets.php
branchwordpress
changeset 109 03b0d1493584
child 132 4d4862461b8d
equal deleted inserted replaced
-1:000000000000 109:03b0d1493584
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * Default Widgets
       
     5  *
       
     6  * @package WordPress
       
     7  * @subpackage Widgets
       
     8  */
       
     9 
       
    10 /**
       
    11  * Pages widget class
       
    12  *
       
    13  * @since 2.8.0
       
    14  */
       
    15 class WP_Widget_Pages extends WP_Widget {
       
    16 
       
    17 	function WP_Widget_Pages() {
       
    18 		$widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your blog&#8217;s WordPress Pages') );
       
    19 		$this->WP_Widget('pages', __('Pages'), $widget_ops);
       
    20 	}
       
    21 
       
    22 	function widget( $args, $instance ) {
       
    23 		extract( $args );
       
    24 
       
    25 		$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title']);
       
    26 		$sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
       
    27 		$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
       
    28 
       
    29 		if ( $sortby == 'menu_order' )
       
    30 			$sortby = 'menu_order, post_title';
       
    31 
       
    32 		$out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) );
       
    33 
       
    34 		if ( !empty( $out ) ) {
       
    35 			echo $before_widget;
       
    36 			if ( $title)
       
    37 				echo $before_title . $title . $after_title;
       
    38 		?>
       
    39 		<ul>
       
    40 			<?php echo $out; ?>
       
    41 		</ul>
       
    42 		<?php
       
    43 			echo $after_widget;
       
    44 		}
       
    45 	}
       
    46 
       
    47 	function update( $new_instance, $old_instance ) {
       
    48 		$instance = $old_instance;
       
    49 		$instance['title'] = strip_tags($new_instance['title']);
       
    50 		if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
       
    51 			$instance['sortby'] = $new_instance['sortby'];
       
    52 		} else {
       
    53 			$instance['sortby'] = 'menu_order';
       
    54 		}
       
    55 
       
    56 		$instance['exclude'] = strip_tags( $new_instance['exclude'] );
       
    57 
       
    58 		return $instance;
       
    59 	}
       
    60 
       
    61 	function form( $instance ) {
       
    62 		//Defaults
       
    63 		$instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
       
    64 		$title = esc_attr( $instance['title'] );
       
    65 		$exclude = esc_attr( $instance['exclude'] );
       
    66 	?>
       
    67 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
       
    68 		<p>
       
    69 			<label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?></label>
       
    70 			<select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">
       
    71 				<option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
       
    72 				<option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
       
    73 				<option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
       
    74 			</select>
       
    75 		</p>
       
    76 		<p>
       
    77 			<label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
       
    78 			<br />
       
    79 			<small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
       
    80 		</p>
       
    81 <?php
       
    82 	}
       
    83 
       
    84 }
       
    85 
       
    86 /**
       
    87  * Links widget class
       
    88  *
       
    89  * @since 2.8.0
       
    90  */
       
    91 class WP_Widget_Links extends WP_Widget {
       
    92 
       
    93 	function WP_Widget_Links() {
       
    94 		$widget_ops = array('description' => __( "Your blogroll" ) );
       
    95 		$this->WP_Widget('links', __('Links'), $widget_ops);
       
    96 	}
       
    97 
       
    98 	function widget( $args, $instance ) {
       
    99 		extract($args, EXTR_SKIP);
       
   100 
       
   101 		$show_description = isset($instance['description']) ? $instance['description'] : false;
       
   102 		$show_name = isset($instance['name']) ? $instance['name'] : false;
       
   103 		$show_rating = isset($instance['rating']) ? $instance['rating'] : false;
       
   104 		$show_images = isset($instance['images']) ? $instance['images'] : true;
       
   105 		$category = isset($instance['category']) ? $instance['category'] : false;
       
   106 
       
   107 		if ( is_admin() && !$category ) {
       
   108 			// Display All Links widget as such in the widgets screen
       
   109 			echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget;
       
   110 			return;
       
   111 		}
       
   112 
       
   113 		$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
       
   114 		wp_list_bookmarks(apply_filters('widget_links_args', array(
       
   115 			'title_before' => $before_title, 'title_after' => $after_title,
       
   116 			'category_before' => $before_widget, 'category_after' => $after_widget,
       
   117 			'show_images' => $show_images, 'show_description' => $show_description,
       
   118 			'show_name' => $show_name, 'show_rating' => $show_rating,
       
   119 			'category' => $category, 'class' => 'linkcat widget'
       
   120 		)));
       
   121 	}
       
   122 
       
   123 	function update( $new_instance, $old_instance ) {
       
   124 		$new_instance = (array) $new_instance;
       
   125 		$instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0);
       
   126 		foreach ( $instance as $field => $val ) {
       
   127 			if ( isset($new_instance[$field]) )
       
   128 				$instance[$field] = 1;
       
   129 		}
       
   130 		$instance['category'] = intval($new_instance['category']);
       
   131 
       
   132 		return $instance;
       
   133 	}
       
   134 
       
   135 	function form( $instance ) {
       
   136 
       
   137 		//Defaults
       
   138 		$instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
       
   139 		$link_cats = get_terms( 'link_category');
       
   140 ?>
       
   141 		<p>
       
   142 		<label for="<?php echo $this->get_field_id('category'); ?>" class="screen-reader-text"><?php _e('Select Link Category'); ?></label>
       
   143 		<select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
       
   144 		<option value=""><?php _e('All Links'); ?></option>
       
   145 		<?php
       
   146 		foreach ( $link_cats as $link_cat ) {
       
   147 			echo '<option value="' . intval($link_cat->term_id) . '"'
       
   148 				. ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
       
   149 				. '>' . $link_cat->name . "</option>\n";
       
   150 		}
       
   151 		?>
       
   152 		</select></p>
       
   153 		<p>
       
   154 		<input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />
       
   155 		<label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
       
   156 		<input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />
       
   157 		<label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
       
   158 		<input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />
       
   159 		<label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
       
   160 		<input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />
       
   161 		<label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
       
   162 		</p>
       
   163 <?php
       
   164 	}
       
   165 }
       
   166 
       
   167 /**
       
   168  * Search widget class
       
   169  *
       
   170  * @since 2.8.0
       
   171  */
       
   172 class WP_Widget_Search extends WP_Widget {
       
   173 
       
   174 	function WP_Widget_Search() {
       
   175 		$widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your blog") );
       
   176 		$this->WP_Widget('search', __('Search'), $widget_ops);
       
   177 	}
       
   178 
       
   179 	function widget( $args, $instance ) {
       
   180 		extract($args);
       
   181 		$title = apply_filters('widget_title', $instance['title']);
       
   182 
       
   183 		echo $before_widget;
       
   184 		if ( $title )
       
   185 			echo $before_title . $title . $after_title;
       
   186 
       
   187 		// Use current theme search form if it exists
       
   188 		get_search_form();
       
   189 
       
   190 		echo $after_widget;
       
   191 	}
       
   192 
       
   193 	function form( $instance ) {
       
   194 		$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
       
   195 		$title = $instance['title'];
       
   196 ?>
       
   197 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
       
   198 <?php
       
   199 	}
       
   200 
       
   201 	function update( $new_instance, $old_instance ) {
       
   202 		$instance = $old_instance;
       
   203 		$new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
       
   204 		$instance['title'] = strip_tags($new_instance['title']);
       
   205 		return $instance;
       
   206 	}
       
   207 
       
   208 }
       
   209 
       
   210 /**
       
   211  * Archives widget class
       
   212  *
       
   213  * @since 2.8.0
       
   214  */
       
   215 class WP_Widget_Archives extends WP_Widget {
       
   216 
       
   217 	function WP_Widget_Archives() {
       
   218 		$widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your blog&#8217;s posts') );
       
   219 		$this->WP_Widget('archives', __('Archives'), $widget_ops);
       
   220 	}
       
   221 
       
   222 	function widget( $args, $instance ) {
       
   223 		extract($args);
       
   224 		$c = $instance['count'] ? '1' : '0';
       
   225 		$d = $instance['dropdown'] ? '1' : '0';
       
   226 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title']);
       
   227 
       
   228 		echo $before_widget;
       
   229 		if ( $title )
       
   230 			echo $before_title . $title . $after_title;
       
   231 
       
   232 		if ( $d ) {
       
   233 ?>
       
   234 		<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo esc_attr(__('Select Month')); ?></option> <?php wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c))); ?> </select>
       
   235 <?php
       
   236 		} else {
       
   237 ?>
       
   238 		<ul>
       
   239 		<?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?>
       
   240 		</ul>
       
   241 <?php
       
   242 		}
       
   243 
       
   244 		echo $after_widget;
       
   245 	}
       
   246 
       
   247 	function update( $new_instance, $old_instance ) {
       
   248 		$instance = $old_instance;
       
   249 		$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
       
   250 		$instance['title'] = strip_tags($new_instance['title']);
       
   251 		$instance['count'] = $new_instance['count'] ? 1 : 0;
       
   252 		$instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
       
   253 
       
   254 		return $instance;
       
   255 	}
       
   256 
       
   257 	function form( $instance ) {
       
   258 		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
       
   259 		$title = strip_tags($instance['title']);
       
   260 		$count = $instance['count'] ? 'checked="checked"' : '';
       
   261 		$dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
       
   262 ?>
       
   263 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
       
   264 		<p>
       
   265 			<input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label>
       
   266 			<br />
       
   267 			<input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as a drop down'); ?></label>
       
   268 		</p>
       
   269 <?php
       
   270 	}
       
   271 }
       
   272 
       
   273 /**
       
   274  * Meta widget class
       
   275  *
       
   276  * Displays log in/out, RSS feed links, etc.
       
   277  *
       
   278  * @since 2.8.0
       
   279  */
       
   280 class WP_Widget_Meta extends WP_Widget {
       
   281 
       
   282 	function WP_Widget_Meta() {
       
   283 		$widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") );
       
   284 		$this->WP_Widget('meta', __('Meta'), $widget_ops);
       
   285 	}
       
   286 
       
   287 	function widget( $args, $instance ) {
       
   288 		extract($args);
       
   289 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title']);
       
   290 
       
   291 		echo $before_widget;
       
   292 		if ( $title )
       
   293 			echo $before_title . $title . $after_title;
       
   294 ?>
       
   295 			<ul>
       
   296 			<?php wp_register(); ?>
       
   297 			<li><?php wp_loginout(); ?></li>
       
   298 			<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
       
   299 			<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
       
   300 			<li><a href="http://wordpress.org/" title="<?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li>
       
   301 			<?php wp_meta(); ?>
       
   302 			</ul>
       
   303 <?php
       
   304 		echo $after_widget;
       
   305 	}
       
   306 
       
   307 	function update( $new_instance, $old_instance ) {
       
   308 		$instance = $old_instance;
       
   309 		$instance['title'] = strip_tags($new_instance['title']);
       
   310 
       
   311 		return $instance;
       
   312 	}
       
   313 
       
   314 	function form( $instance ) {
       
   315 		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
       
   316 		$title = strip_tags($instance['title']);
       
   317 ?>
       
   318 			<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
       
   319 <?php
       
   320 	}
       
   321 }
       
   322 
       
   323 /**
       
   324  * Calendar widget class
       
   325  *
       
   326  * @since 2.8.0
       
   327  */
       
   328 class WP_Widget_Calendar extends WP_Widget {
       
   329 
       
   330 	function WP_Widget_Calendar() {
       
   331 		$widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your blog&#8217;s posts') );
       
   332 		$this->WP_Widget('calendar', __('Calendar'), $widget_ops);
       
   333 	}
       
   334 
       
   335 	function widget( $args, $instance ) {
       
   336 		extract($args);
       
   337 		$title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title']);
       
   338 		echo $before_widget;
       
   339 		if ( $title )
       
   340 			echo $before_title . $title . $after_title;
       
   341 		echo '<div id="calendar_wrap">';
       
   342 		get_calendar();
       
   343 		echo '</div>';
       
   344 		echo $after_widget;
       
   345 	}
       
   346 
       
   347 	function update( $new_instance, $old_instance ) {
       
   348 		$instance = $old_instance;
       
   349 		$instance['title'] = strip_tags($new_instance['title']);
       
   350 
       
   351 		return $instance;
       
   352 	}
       
   353 
       
   354 	function form( $instance ) {
       
   355 		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
       
   356 		$title = strip_tags($instance['title']);
       
   357 ?>
       
   358 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
       
   359 		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
       
   360 <?php
       
   361 	}
       
   362 }
       
   363 
       
   364 /**
       
   365  * Text widget class
       
   366  *
       
   367  * @since 2.8.0
       
   368  */
       
   369 class WP_Widget_Text extends WP_Widget {
       
   370 
       
   371 	function WP_Widget_Text() {
       
   372 		$widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML'));
       
   373 		$control_ops = array('width' => 400, 'height' => 350);
       
   374 		$this->WP_Widget('text', __('Text'), $widget_ops, $control_ops);
       
   375 	}
       
   376 
       
   377 	function widget( $args, $instance ) {
       
   378 		extract($args);
       
   379 		$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
       
   380 		$text = apply_filters( 'widget_text', $instance['text'] );
       
   381 		echo $before_widget;
       
   382 		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
       
   383 			<div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
       
   384 		<?php
       
   385 		echo $after_widget;
       
   386 	}
       
   387 
       
   388 	function update( $new_instance, $old_instance ) {
       
   389 		$instance = $old_instance;
       
   390 		$instance['title'] = strip_tags($new_instance['title']);
       
   391 		if ( current_user_can('unfiltered_html') )
       
   392 			$instance['text'] =  $new_instance['text'];
       
   393 		else
       
   394 			$instance['text'] = wp_filter_post_kses( $new_instance['text'] );
       
   395 		$instance['filter'] = isset($new_instance['filter']);
       
   396 		return $instance;
       
   397 	}
       
   398 
       
   399 	function form( $instance ) {
       
   400 		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
       
   401 		$title = strip_tags($instance['title']);
       
   402 		$text = format_to_edit($instance['text']);
       
   403 ?>
       
   404 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
       
   405 		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
       
   406 
       
   407 		<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
       
   408 
       
   409 		<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked($instance['filter']); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p>
       
   410 <?php
       
   411 	}
       
   412 }
       
   413 
       
   414 /**
       
   415  * Categories widget class
       
   416  *
       
   417  * @since 2.8.0
       
   418  */
       
   419 class WP_Widget_Categories extends WP_Widget {
       
   420 
       
   421 	function WP_Widget_Categories() {
       
   422 		$widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) );
       
   423 		$this->WP_Widget('categories', __('Categories'), $widget_ops);
       
   424 	}
       
   425 
       
   426 	function widget( $args, $instance ) {
       
   427 		extract( $args );
       
   428 
       
   429 		$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title']);
       
   430 		$c = $instance['count'] ? '1' : '0';
       
   431 		$h = $instance['hierarchical'] ? '1' : '0';
       
   432 		$d = $instance['dropdown'] ? '1' : '0';
       
   433 
       
   434 		echo $before_widget;
       
   435 		if ( $title )
       
   436 			echo $before_title . $title . $after_title;
       
   437 
       
   438 		$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
       
   439 
       
   440 		if ( $d ) {
       
   441 			$cat_args['show_option_none'] = __('Select Category');
       
   442 			wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
       
   443 ?>
       
   444 
       
   445 <script type='text/javascript'>
       
   446 /* <![CDATA[ */
       
   447 	var dropdown = document.getElementById("cat");
       
   448 	function onCatChange() {
       
   449 		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
       
   450 			location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
       
   451 		}
       
   452 	}
       
   453 	dropdown.onchange = onCatChange;
       
   454 /* ]]> */
       
   455 </script>
       
   456 
       
   457 <?php
       
   458 		} else {
       
   459 ?>
       
   460 		<ul>
       
   461 <?php
       
   462 		$cat_args['title_li'] = '';
       
   463 		wp_list_categories(apply_filters('widget_categories_args', $cat_args));
       
   464 ?>
       
   465 		</ul>
       
   466 <?php
       
   467 		}
       
   468 
       
   469 		echo $after_widget;
       
   470 	}
       
   471 
       
   472 	function update( $new_instance, $old_instance ) {
       
   473 		$instance = $old_instance;
       
   474 		$instance['title'] = strip_tags($new_instance['title']);
       
   475 		$instance['count'] = $new_instance['count'] ? 1 : 0;
       
   476 		$instance['hierarchical'] = $new_instance['hierarchical'] ? 1 : 0;
       
   477 		$instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
       
   478 
       
   479 		return $instance;
       
   480 	}
       
   481 
       
   482 	function form( $instance ) {
       
   483 		//Defaults
       
   484 		$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
       
   485 		$title = esc_attr( $instance['title'] );
       
   486 		$count = (bool) $instance['count'];
       
   487 		$hierarchical = (bool) $instance['hierarchical'];
       
   488 		$dropdown = (bool) $instance['dropdown'];
       
   489 ?>
       
   490 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
       
   491 		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
       
   492 
       
   493 		<p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
       
   494 		<label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Show as dropdown' ); ?></label><br />
       
   495 
       
   496 		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
       
   497 		<label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
       
   498 
       
   499 		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
       
   500 		<label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
       
   501 <?php
       
   502 	}
       
   503 
       
   504 }
       
   505 
       
   506 /**
       
   507  * Recent_Posts widget class
       
   508  *
       
   509  * @since 2.8.0
       
   510  */
       
   511 class WP_Widget_Recent_Posts extends WP_Widget {
       
   512 
       
   513 	function WP_Widget_Recent_Posts() {
       
   514 		$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your blog") );
       
   515 		$this->WP_Widget('recent-posts', __('Recent Posts'), $widget_ops);
       
   516 		$this->alt_option_name = 'widget_recent_entries';
       
   517 
       
   518 		add_action( 'save_post', array(&$this, 'flush_widget_cache') );
       
   519 		add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
       
   520 		add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
       
   521 	}
       
   522 
       
   523 	function widget($args, $instance) {
       
   524 		$cache = wp_cache_get('widget_recent_posts', 'widget');
       
   525 
       
   526 		if ( !is_array($cache) )
       
   527 			$cache = array();
       
   528 
       
   529 		if ( isset($cache[$args['widget_id']]) ) {
       
   530 			echo $cache[$args['widget_id']];
       
   531 			return;
       
   532 		}
       
   533 
       
   534 		ob_start();
       
   535 		extract($args);
       
   536 
       
   537 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']);
       
   538 		if ( !$number = (int) $instance['number'] )
       
   539 			$number = 10;
       
   540 		else if ( $number < 1 )
       
   541 			$number = 1;
       
   542 		else if ( $number > 15 )
       
   543 			$number = 15;
       
   544 
       
   545 		$r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1));
       
   546 		if ($r->have_posts()) :
       
   547 ?>
       
   548 		<?php echo $before_widget; ?>
       
   549 		<?php if ( $title ) echo $before_title . $title . $after_title; ?>
       
   550 		<ul>
       
   551 		<?php  while ($r->have_posts()) : $r->the_post(); ?>
       
   552 		<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li>
       
   553 		<?php endwhile; ?>
       
   554 		</ul>
       
   555 		<?php echo $after_widget; ?>
       
   556 <?php
       
   557 			wp_reset_query();  // Restore global post data stomped by the_post().
       
   558 		endif;
       
   559 
       
   560 		$cache[$args['widget_id']] = ob_get_flush();
       
   561 		wp_cache_add('widget_recent_posts', $cache, 'widget');
       
   562 	}
       
   563 
       
   564 	function update( $new_instance, $old_instance ) {
       
   565 		$instance = $old_instance;
       
   566 		$instance['title'] = strip_tags($new_instance['title']);
       
   567 		$instance['number'] = (int) $new_instance['number'];
       
   568 		$this->flush_widget_cache();
       
   569 
       
   570 		$alloptions = wp_cache_get( 'alloptions', 'options' );
       
   571 		if ( isset($alloptions['widget_recent_entries']) )
       
   572 			delete_option('widget_recent_entries');
       
   573 
       
   574 		return $instance;
       
   575 	}
       
   576 
       
   577 	function flush_widget_cache() {
       
   578 		wp_cache_delete('widget_recent_posts', 'widget');
       
   579 	}
       
   580 
       
   581 	function form( $instance ) {
       
   582 		$title = esc_attr($instance['title']);
       
   583 		if ( !$number = (int) $instance['number'] )
       
   584 			$number = 5;
       
   585 ?>
       
   586 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
       
   587 		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
       
   588 
       
   589 		<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
       
   590 		<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /><br />
       
   591 		<small><?php _e('(at most 15)'); ?></small></p>
       
   592 <?php
       
   593 	}
       
   594 }
       
   595 
       
   596 /**
       
   597  * Recent_Comments widget class
       
   598  *
       
   599  * @since 2.8.0
       
   600  */
       
   601 class WP_Widget_Recent_Comments extends WP_Widget {
       
   602 
       
   603 	function WP_Widget_Recent_Comments() {
       
   604 		$widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'The most recent comments' ) );
       
   605 		$this->WP_Widget('recent-comments', __('Recent Comments'), $widget_ops);
       
   606 		$this->alt_option_name = 'widget_recent_comments';
       
   607 
       
   608 		if ( is_active_widget(false, false, $this->id_base) )
       
   609 			add_action( 'wp_head', array(&$this, 'recent_comments_style') );
       
   610 
       
   611 		add_action( 'comment_post', array(&$this, 'flush_widget_cache') );
       
   612 		add_action( 'wp_set_comment_status', array(&$this, 'flush_widget_cache') );
       
   613 	}
       
   614 
       
   615 	function recent_comments_style() { ?>
       
   616 	<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
       
   617 <?php
       
   618 	}
       
   619 
       
   620 	function flush_widget_cache() {
       
   621 		wp_cache_delete('recent_comments', 'widget');
       
   622 	}
       
   623 
       
   624 	function widget( $args, $instance ) {
       
   625 		global $wpdb, $comments, $comment;
       
   626 
       
   627 		extract($args, EXTR_SKIP);
       
   628 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
       
   629 		if ( !$number = (int) $instance['number'] )
       
   630 			$number = 5;
       
   631 		else if ( $number < 1 )
       
   632 			$number = 1;
       
   633 		else if ( $number > 15 )
       
   634 			$number = 15;
       
   635 
       
   636 		if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
       
   637 			$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15");
       
   638 			wp_cache_add( 'recent_comments', $comments, 'widget' );
       
   639 		}
       
   640 
       
   641 		$comments = array_slice( (array) $comments, 0, $number );
       
   642 ?>
       
   643 		<?php echo $before_widget; ?>
       
   644 			<?php if ( $title ) echo $before_title . $title . $after_title; ?>
       
   645 			<ul id="recentcomments"><?php
       
   646 			if ( $comments ) : foreach ( (array) $comments as $comment) :
       
   647 			echo  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
       
   648 			endforeach; endif;?></ul>
       
   649 		<?php echo $after_widget; ?>
       
   650 <?php
       
   651 	}
       
   652 
       
   653 	function update( $new_instance, $old_instance ) {
       
   654 		$instance = $old_instance;
       
   655 		$instance['title'] = strip_tags($new_instance['title']);
       
   656 		$instance['number'] = (int) $new_instance['number'];
       
   657 		$this->flush_widget_cache();
       
   658 
       
   659 		$alloptions = wp_cache_get( 'alloptions', 'options' );
       
   660 		if ( isset($alloptions['widget_recent_comments']) )
       
   661 			delete_option('widget_recent_comments');
       
   662 
       
   663 		return $instance;
       
   664 	}
       
   665 
       
   666 	function form( $instance ) {
       
   667 		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
       
   668 		$number = isset($instance['number']) ? absint($instance['number']) : 5;
       
   669 ?>
       
   670 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
       
   671 		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
       
   672 
       
   673 		<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label>
       
   674 		<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /><br />
       
   675 		<small><?php _e('(at most 15)'); ?></small></p>
       
   676 <?php
       
   677 	}
       
   678 }
       
   679 
       
   680 /**
       
   681  * RSS widget class
       
   682  *
       
   683  * @since 2.8.0
       
   684  */
       
   685 class WP_Widget_RSS_Sam extends WP_Widget {
       
   686 
       
   687 	function WP_Widget_RSS_Sam() {
       
   688 		$widget_ops = array( 'description' => __('Entries from any RSS Custom / SAM') );
       
   689 		$control_ops = array( 'width' => 400, 'height' => 200 );
       
   690 		$this->WP_Widget( 'rss', __('RSS'), $widget_ops, $control_ops );
       
   691 	}
       
   692 
       
   693 	function widget($args, $instance) {
       
   694 
       
   695 		if ( isset($instance['error']) && $instance['error'] )
       
   696 			return;
       
   697 
       
   698 		extract($args, EXTR_SKIP);
       
   699 
       
   700 		$url = $instance['url'];
       
   701 		while ( stristr($url, 'http') != $url )
       
   702 			$url = substr($url, 1);
       
   703 
       
   704 		if ( empty($url) )
       
   705 			return;
       
   706 
       
   707 		$rss = fetch_feed($url);
       
   708 		$title = $instance['title'];
       
   709 		$desc = '';
       
   710 		$link = '';
       
   711 
       
   712 		if ( ! is_wp_error($rss) ) {
       
   713 			$desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
       
   714 			if ( empty($title) )
       
   715 				$title = esc_html(strip_tags($rss->get_title()));
       
   716 			$link = esc_url(strip_tags($rss->get_permalink()));
       
   717 			while ( stristr($link, 'http') != $link )
       
   718 				$link = substr($link, 1);
       
   719 		}
       
   720 
       
   721 		if ( empty($title) )
       
   722 			$title = empty($desc) ? __('Unknown Feed') : $desc;
       
   723 
       
   724 		$title = apply_filters('widget_title', $title );
       
   725 		$url = esc_url(strip_tags($url));
       
   726 		$icon = includes_url('images/rss.png');
       
   727 		if ( $title )
       
   728 			$title = "$title";
       
   729 
       
   730 		echo $before_widget;
       
   731 		if ( $title )
       
   732 			echo $before_title . $title . $after_title;
       
   733 		wp_widget_rss_output( $rss, $instance );
       
   734 		echo $after_widget;
       
   735 	}
       
   736 
       
   737 	function update($new_instance, $old_instance) {
       
   738 		$testurl = $new_instance['url'] != $old_instance['url'];
       
   739 		return wp_widget_rss_process( $new_instance, $testurl );
       
   740 	}
       
   741 
       
   742 	function form($instance) {
       
   743 
       
   744 		if ( empty($instance) )
       
   745 			$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
       
   746 		$instance['number'] = $this->number;
       
   747 
       
   748 		wp_widget_rss_form( $instance );
       
   749 	}
       
   750 }
       
   751 
       
   752 
       
   753 /**
       
   754  * RSS widget class
       
   755  *
       
   756  * @since 2.8.0
       
   757  */
       
   758 class WP_Widget_RSS extends WP_Widget {
       
   759 
       
   760 	function WP_Widget_RSS() {
       
   761 		$widget_ops = array( 'description' => __('Entries from any RSS or Atom feed') );
       
   762 		$control_ops = array( 'width' => 400, 'height' => 200 );
       
   763 		$this->WP_Widget( 'rss', __('RSS'), $widget_ops, $control_ops );
       
   764 	}
       
   765 
       
   766 	function widget($args, $instance) {
       
   767 
       
   768 		if ( isset($instance['error']) && $instance['error'] )
       
   769 			return;
       
   770 
       
   771 		extract($args, EXTR_SKIP);
       
   772 
       
   773 		$url = $instance['url'];
       
   774 		while ( stristr($url, 'http') != $url )
       
   775 			$url = substr($url, 1);
       
   776 
       
   777 		if ( empty($url) )
       
   778 			return;
       
   779 
       
   780 		$rss = fetch_feed($url);
       
   781 		$title = $instance['title'];
       
   782 		$desc = '';
       
   783 		$link = '';
       
   784 
       
   785 		if ( ! is_wp_error($rss) ) {
       
   786 			$desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
       
   787 			if ( empty($title) )
       
   788 				$title = esc_html(strip_tags($rss->get_title()));
       
   789 			$link = esc_url(strip_tags($rss->get_permalink()));
       
   790 			while ( stristr($link, 'http') != $link )
       
   791 				$link = substr($link, 1);
       
   792 		}
       
   793 
       
   794 		if ( empty($title) )
       
   795 			$title = empty($desc) ? __('Unknown Feed') : $desc;
       
   796 
       
   797 		$title = apply_filters('widget_title', $title );
       
   798 		$url = esc_url(strip_tags($url));
       
   799 		$icon = includes_url('images/rss.png');
       
   800 		if ( $title )
       
   801 			$title = "<a class='rsswidget' href='$url' title='" . esc_attr(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
       
   802 
       
   803 		echo $before_widget;
       
   804 		if ( $title )
       
   805 			echo $before_title . $title . $after_title;
       
   806 		wp_widget_rss_output( $rss, $instance );
       
   807 		echo $after_widget;
       
   808 	}
       
   809 
       
   810 	function update($new_instance, $old_instance) {
       
   811 		$testurl = $new_instance['url'] != $old_instance['url'];
       
   812 		return wp_widget_rss_process( $new_instance, $testurl );
       
   813 	}
       
   814 
       
   815 	function form($instance) {
       
   816 
       
   817 		if ( empty($instance) )
       
   818 			$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
       
   819 		$instance['number'] = $this->number;
       
   820 
       
   821 		wp_widget_rss_form( $instance );
       
   822 	}
       
   823 }
       
   824 
       
   825 /**
       
   826  * Display the RSS entries in a list.
       
   827  *
       
   828  * @since 2.5.0
       
   829  *
       
   830  * @param string|array|object $rss RSS url.
       
   831  * @param array $args Widget arguments.
       
   832  */
       
   833 function wp_widget_rss_output( $rss, $args = array() ) {
       
   834 	if ( is_string( $rss ) ) {
       
   835 		$rss = fetch_feed($rss);
       
   836 	} elseif ( is_array($rss) && isset($rss['url']) ) {
       
   837 		$args = $rss;
       
   838 		$rss = fetch_feed($rss['url']);
       
   839 	} elseif ( !is_object($rss) ) {
       
   840 		return;
       
   841 	}
       
   842 
       
   843 	if ( is_wp_error($rss) ) {
       
   844 		if ( is_admin() || current_user_can('manage_options') )
       
   845 			echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
       
   846 
       
   847 		return;
       
   848 	}
       
   849 
       
   850 	$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 );
       
   851 	$args = wp_parse_args( $args, $default_args );
       
   852 	extract( $args, EXTR_SKIP );
       
   853 
       
   854 	$items = (int) $items;
       
   855 	if ( $items < 1 || 20 < $items )
       
   856 		$items = 10;
       
   857 	$show_summary  = (int) $show_summary;
       
   858 	$show_author   = (int) $show_author;
       
   859 	$show_date     = (int) $show_date;
       
   860 
       
   861 	if ( !$rss->get_item_quantity() ) {
       
   862 		echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
       
   863 		return;
       
   864 	}
       
   865 
       
   866 	echo '<ul>';
       
   867 	foreach ( $rss->get_items(0, $items) as $item ) {
       
   868 		$link = $item->get_link();
       
   869 		while ( stristr($link, 'http') != $link )
       
   870 			$link = substr($link, 1);
       
   871 		$link = esc_url(strip_tags($link));
       
   872 		$title = esc_attr(strip_tags($item->get_title()));
       
   873 		if ( empty($title) )
       
   874 			$title = __('Untitled');
       
   875 
       
   876 		$desc = str_replace(array("\n", "\r"), ' ', esc_attr(strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset')))));
       
   877 		$desc = wp_html_excerpt( $desc, 360 ) . ' [&hellip;]';
       
   878 		$desc = esc_html( $desc );
       
   879 
       
   880 		if ( $show_summary ) {
       
   881 			$summary = "<div class='rssSummary'>$desc</div>";
       
   882 		} else {
       
   883 			$summary = '';
       
   884 		}
       
   885 
       
   886 		$date = '';
       
   887 		if ( $show_date ) {
       
   888 			$date = $item->get_date();
       
   889 
       
   890 			if ( $date ) {
       
   891 				if ( $date_stamp = strtotime( $date ) )
       
   892 					$date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
       
   893 				else
       
   894 					$date = '';
       
   895 			}
       
   896 		}
       
   897 
       
   898 		$author = '';
       
   899 		if ( $show_author ) {
       
   900 			$author = $item->get_author();
       
   901 			if ( is_object($author) ) {
       
   902 				$author = $author->get_name();
       
   903 				$author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
       
   904 			}
       
   905 		}
       
   906 
       
   907 		if ( $link == '' ) {
       
   908 			echo "<li>$title{$date}{$summary}{$author}</li>";
       
   909 		} else {
       
   910 			echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
       
   911 		}
       
   912 	}
       
   913 	echo '</ul>';
       
   914 }
       
   915 
       
   916 
       
   917 
       
   918 /**
       
   919  * Display RSS widget options form.
       
   920  *
       
   921  * The options for what fields are displayed for the RSS form are all booleans
       
   922  * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
       
   923  * 'show_date'.
       
   924  *
       
   925  * @since 2.5.0
       
   926  *
       
   927  * @param array|string $args Values for input fields.
       
   928  * @param array $inputs Override default display options.
       
   929  */
       
   930 function wp_widget_rss_form( $args, $inputs = null ) {
       
   931 
       
   932 	$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
       
   933 	$inputs = wp_parse_args( $inputs, $default_inputs );
       
   934 	extract( $args );
       
   935 	extract( $inputs, EXTR_SKIP);
       
   936 
       
   937 	$number = esc_attr( $number );
       
   938 	$title  = esc_attr( $title );
       
   939 	$url    = esc_url( $url );
       
   940 	$items  = (int) $items;
       
   941 	if ( $items < 1 || 20 < $items )
       
   942 		$items  = 10;
       
   943 	$show_summary   = (int) $show_summary;
       
   944 	$show_author    = (int) $show_author;
       
   945 	$show_date      = (int) $show_date;
       
   946 
       
   947 	if ( !empty($error) )
       
   948 		echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>';
       
   949 
       
   950 	if ( $inputs['url'] ) :
       
   951 ?>
       
   952 	<p><label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?></label>
       
   953 	<input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" /></p>
       
   954 <?php endif; if ( $inputs['title'] ) : ?>
       
   955 	<p><label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?></label>
       
   956 	<input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /></p>
       
   957 <?php endif; if ( $inputs['items'] ) : ?>
       
   958 	<p><label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?></label>
       
   959 	<select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
       
   960 <?php
       
   961 		for ( $i = 1; $i <= 20; ++$i )
       
   962 			echo "<option value='$i' " . ( $items == $i ? "selected='selected'" : '' ) . ">$i</option>";
       
   963 ?>
       
   964 	</select></p>
       
   965 <?php endif; if ( $inputs['show_summary'] ) : ?>
       
   966 	<p><input id="rss-show-summary-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_summary]" type="checkbox" value="1" <?php if ( $show_summary ) echo 'checked="checked"'; ?>/>
       
   967 	<label for="rss-show-summary-<?php echo $number; ?>"><?php _e('Display item content?'); ?></label></p>
       
   968 <?php endif; if ( $inputs['show_author'] ) : ?>
       
   969 	<p><input id="rss-show-author-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_author]" type="checkbox" value="1" <?php if ( $show_author ) echo 'checked="checked"'; ?>/>
       
   970 	<label for="rss-show-author-<?php echo $number; ?>"><?php _e('Display item author if available?'); ?></label></p>
       
   971 <?php endif; if ( $inputs['show_date'] ) : ?>
       
   972 	<p><input id="rss-show-date-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_date]" type="checkbox" value="1" <?php if ( $show_date ) echo 'checked="checked"'; ?>/>
       
   973 	<label for="rss-show-date-<?php echo $number; ?>"><?php _e('Display item date?'); ?></label></p>
       
   974 <?php
       
   975 	endif;
       
   976 	foreach ( array_keys($default_inputs) as $input ) :
       
   977 		if ( 'hidden' === $inputs[$input] ) :
       
   978 			$id = str_replace( '_', '-', $input );
       
   979 ?>
       
   980 	<input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][<?php echo $input; ?>]" value="<?php echo $$input; ?>" />
       
   981 <?php
       
   982 		endif;
       
   983 	endforeach;
       
   984 }
       
   985 
       
   986 /**
       
   987  * Process RSS feed widget data and optionally retrieve feed items.
       
   988  *
       
   989  * The feed widget can not have more than 20 items or it will reset back to the
       
   990  * default, which is 10.
       
   991  *
       
   992  * The resulting array has the feed title, feed url, feed link (from channel),
       
   993  * feed items, error (if any), and whether to show summary, author, and date.
       
   994  * All respectively in the order of the array elements.
       
   995  *
       
   996  * @since 2.5.0
       
   997  *
       
   998  * @param array $widget_rss RSS widget feed data. Expects unescaped data.
       
   999  * @param bool $check_feed Optional, default is true. Whether to check feed for errors.
       
  1000  * @return array
       
  1001  */
       
  1002 function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
       
  1003 	$items = (int) $widget_rss['items'];
       
  1004 	if ( $items < 1 || 20 < $items )
       
  1005 		$items = 10;
       
  1006 	$url           = esc_url_raw(strip_tags( $widget_rss['url'] ));
       
  1007 	$title         = trim(strip_tags( $widget_rss['title'] ));
       
  1008 	$show_summary  = (int) $widget_rss['show_summary'];
       
  1009 	$show_author   = (int) $widget_rss['show_author'];
       
  1010 	$show_date     = (int) $widget_rss['show_date'];
       
  1011 
       
  1012 	if ( $check_feed ) {
       
  1013 		$rss = fetch_feed($url);
       
  1014 		$error = false;
       
  1015 		$link = '';
       
  1016 		if ( is_wp_error($rss) ) {
       
  1017 			$error = $rss->get_error_message();
       
  1018 		} else {
       
  1019 			$link = esc_url(strip_tags($rss->get_permalink()));
       
  1020 			while ( stristr($link, 'http') != $link )
       
  1021 				$link = substr($link, 1);
       
  1022 		}
       
  1023 	}
       
  1024 
       
  1025 	return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
       
  1026 }
       
  1027 
       
  1028 /**
       
  1029  * Tag cloud widget class
       
  1030  *
       
  1031  * @since 2.8.0
       
  1032  */
       
  1033 class WP_Widget_Tag_Cloud extends WP_Widget {
       
  1034 
       
  1035 	function WP_Widget_Tag_Cloud() {
       
  1036 		$widget_ops = array( 'description' => __( "Your most used tags in cloud format") );
       
  1037 		$this->WP_Widget('tag_cloud', __('Tag Cloud'), $widget_ops);
       
  1038 	}
       
  1039 
       
  1040 	function widget( $args, $instance ) {
       
  1041 		extract($args);
       
  1042 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title']);
       
  1043 
       
  1044 		echo $before_widget;
       
  1045 		if ( $title )
       
  1046 			echo $before_title . $title . $after_title;
       
  1047 		echo '<div>';
       
  1048 		wp_tag_cloud(apply_filters('widget_tag_cloud_args', array()));
       
  1049 		echo "</div>\n";
       
  1050 		echo $after_widget;
       
  1051 	}
       
  1052 
       
  1053 	function update( $new_instance, $old_instance ) {
       
  1054 		$instance['title'] = strip_tags(stripslashes($new_instance['title']));
       
  1055 		return $instance;
       
  1056 	}
       
  1057 
       
  1058 	function form( $instance ) {
       
  1059 ?>
       
  1060 	<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
       
  1061 	<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>
       
  1062 <?php
       
  1063 	}
       
  1064 }
       
  1065 
       
  1066 /**
       
  1067  * Register all of the default WordPress widgets on startup.
       
  1068  *
       
  1069  * Calls 'widgets_init' action after all of the WordPress widgets have been
       
  1070  * registered.
       
  1071  *
       
  1072  * @since 2.2.0
       
  1073  */
       
  1074 function wp_widgets_init() {
       
  1075 	if ( !is_blog_installed() )
       
  1076 		return;
       
  1077 
       
  1078 	register_widget('WP_Widget_Pages');
       
  1079 
       
  1080 	register_widget('WP_Widget_Calendar');
       
  1081 
       
  1082 	register_widget('WP_Widget_Archives');
       
  1083 
       
  1084 	register_widget('WP_Widget_Links');
       
  1085 
       
  1086 	register_widget('WP_Widget_Meta');
       
  1087 
       
  1088 	register_widget('WP_Widget_Search');
       
  1089 
       
  1090 	register_widget('WP_Widget_Text');
       
  1091 
       
  1092 	register_widget('WP_Widget_Categories');
       
  1093 
       
  1094 	register_widget('WP_Widget_Recent_Posts');
       
  1095 
       
  1096 	register_widget('WP_Widget_Recent_Comments');
       
  1097 
       
  1098 	register_widget('WP_Widget_RSS');
       
  1099 	
       
  1100 	register_widget('WP_Widget_RSS_Sam');
       
  1101 	
       
  1102 	register_widget('WP_Widget_Tag_Cloud');
       
  1103 
       
  1104 	do_action('widgets_init');
       
  1105 }
       
  1106 
       
  1107 add_action('init', 'wp_widgets_init', 1);