wp/wp-includes/default-widgets.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Default Widgets
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Widgets
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * Pages widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
class WP_Widget_Pages extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
		$widget_ops = array('classname' => 'widget_pages', 'description' => __( 'A list of your site&#8217;s Pages.') );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
		parent::__construct('pages', __('Pages'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
	public function widget( $args, $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
		 * Filter the widget title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
		 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
		 * @param string $title    The widget title. Default 'Pages'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
		 * @param array  $instance An array of the widget's settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
		 * @param mixed  $id_base  The widget ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
		$sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
		$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
		if ( $sortby == 'menu_order' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
			$sortby = 'menu_order, post_title';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
		 * Filter the arguments for the Pages widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
		 * @see wp_list_pages()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
		 * @param array $args An array of arguments to retrieve the pages list.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    48
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    49
		$out = wp_list_pages( apply_filters( 'widget_pages_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    50
			'title_li'    => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
			'echo'        => 0,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    52
			'sort_column' => $sortby,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
			'exclude'     => $exclude
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
		) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
		if ( ! empty( $out ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
			echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
			if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
				echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			<?php echo $out; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
		<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
			echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
			$instance['sortby'] = $new_instance['sortby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
			$instance['sortby'] = 'menu_order';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		$instance['exclude'] = strip_tags( $new_instance['exclude'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    84
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		//Defaults
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		$instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		$title = esc_attr( $instance['title'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
		$exclude = esc_attr( $instance['exclude'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
			<label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
			<select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
				<option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
				<option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
				<option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			<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" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
			<br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			<small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
 * Links widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
class WP_Widget_Links extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   116
	public function __construct() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
		$widget_ops = array('description' => __( "Your blogroll" ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
		parent::__construct('links', __('Links'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
	public function widget( $args, $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
		$show_description = isset($instance['description']) ? $instance['description'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
		$show_name = isset($instance['name']) ? $instance['name'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		$show_rating = isset($instance['rating']) ? $instance['rating'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		$show_images = isset($instance['images']) ? $instance['images'] : true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		$category = isset($instance['category']) ? $instance['category'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
		$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
		$order = $orderby == 'rating' ? 'DESC' : 'ASC';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
		$limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
		$before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
		 * Filter the arguments for the Links widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
		 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
		 * @see wp_list_bookmarks()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   140
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   141
		 * @param array $args An array of arguments to retrieve the links list.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   142
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   143
		wp_list_bookmarks( apply_filters( 'widget_links_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   144
			'title_before' => $args['before_title'], 'title_after' => $args['after_title'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   145
			'category_before' => $before_widget, 'category_after' => $args['after_widget'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
			'show_images' => $show_images, 'show_description' => $show_description,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
			'show_name' => $show_name, 'show_rating' => $show_rating,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
			'category' => $category, 'class' => 'linkcat widget',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
			'orderby' => $orderby, 'order' => $order,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
			'limit' => $limit,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
		) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
		$new_instance = (array) $new_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
		$instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		foreach ( $instance as $field => $val ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
			if ( isset($new_instance[$field]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
				$instance[$field] = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
		$instance['orderby'] = 'name';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
			$instance['orderby'] = $new_instance['orderby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		$instance['category'] = intval( $new_instance['category'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		$instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   172
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		//Defaults
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
		$instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
		$link_cats = get_terms( 'link_category' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		if ( ! $limit = intval( $instance['limit'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
			$limit = -1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		<label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
		<select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		<option value=""><?php _ex('All Links', 'links widget'); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
		foreach ( $link_cats as $link_cat ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
			echo '<option value="' . intval( $link_cat->term_id ) . '"'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
				. selected( $instance['category'], $link_cat->term_id, false )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
				. '>' . $link_cat->name . "</option>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
		<label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
		<select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
			<option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
			<option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
			<option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
			<option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
		</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
		<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'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
		<label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		<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'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		<label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
		<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'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
		<label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		<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'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		<label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		<label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		<input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
 * Search widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
class WP_Widget_Search extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
		$widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site.") );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
		parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
	public function widget( $args, $instance ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   231
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   232
		/** This filter is documented in wp-includes/default-widgets.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   235
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   236
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   237
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   238
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		// Use current theme search form if it exists
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
		get_search_form();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   243
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   246
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
		$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
		$title = $instance['title'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
		$new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
 * Archives widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
class WP_Widget_Archives extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
		$widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site&#8217;s Posts.') );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
		parent::__construct('archives', __('Archives'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   275
	public function widget( $args, $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		$c = ! empty( $instance['count'] ) ? '1' : '0';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
		$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   278
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   279
		/** This filter is documented in wp-includes/default-widgets.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   280
		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   282
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   283
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   285
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
		if ( $d ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
			$dropdown_id = "{$this->id_base}-dropdown-{$this->number}";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   290
		<label class="screen-reader-text" for="<?php echo esc_attr( $dropdown_id ); ?>"><?php echo $title; ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   291
		<select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   292
			<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   293
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   294
			 * Filter the arguments for the Archives widget drop-down.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   296
			 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   298
			 * @see wp_get_archives()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
			 * @param array $args An array of Archives widget drop-down arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
			$dropdown_args = apply_filters( 'widget_archives_dropdown_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
				'type'            => 'monthly',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
				'format'          => 'option',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
				'show_post_count' => $c
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
			) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   308
			switch ( $dropdown_args['type'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   309
				case 'yearly':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   310
					$label = __( 'Select Year' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
					break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
				case 'monthly':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
					$label = __( 'Select Month' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
					break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
				case 'daily':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
					$label = __( 'Select Day' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
					break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   318
				case 'weekly':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
					$label = __( 'Select Week' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
					break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
				default:
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
					$label = __( 'Select Post' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   323
					break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   324
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   325
			?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   326
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   327
			<option value=""><?php echo esc_attr( $label ); ?></option>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   328
			<?php wp_get_archives( $dropdown_args ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   329
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   330
		</select>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
		<ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   335
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   336
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   337
		 * Filter the arguments for the Archives widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   338
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   340
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   341
		 * @see wp_get_archives()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   342
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   343
		 * @param array $args An array of Archives option arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
		wp_get_archives( apply_filters( 'widget_archives_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
			'type'            => 'monthly',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
			'show_post_count' => $c
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
		) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
		</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
		$instance['count'] = $new_instance['count'] ? 1 : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
		$instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   367
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		$title = strip_tags($instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
		$count = $instance['count'] ? 'checked="checked"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
		$dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
			<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 dropdown'); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
			<br/>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
			<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
 * Meta widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
 * Displays log in/out, RSS feed links, etc.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
class WP_Widget_Meta extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
		$widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, &amp; WordPress.org links.") );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
		parent::__construct('meta', __('Meta'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
	public function widget( $args, $instance ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   398
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   399
		/** This filter is documented in wp-includes/default-widgets.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
		$title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   402
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   403
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   404
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   405
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
			<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
			<?php wp_register(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
			<li><?php wp_loginout(); ?></li>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
			<li><a href="<?php bloginfo('rss2_url'); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   411
			<li><a href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   414
			 * Filter the "Powered by WordPress" text in the Meta widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
			 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   417
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   418
			 * @param string $title_text Default title text for the WordPress.org link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   419
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   420
			echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   421
				esc_url( __( 'https://wordpress.org/' ) ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
				esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
				_x( 'WordPress.org', 'meta widget link text' )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
			) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   426
			wp_meta();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   427
?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
			</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   430
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   433
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   440
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
		$title = strip_tags($instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
			<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
 * Calendar widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
class WP_Widget_Calendar extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   456
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   457
		$widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site&#8217;s Posts.') );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
		parent::__construct('calendar', __('Calendar'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   461
	public function widget( $args, $instance ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   462
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   463
		/** This filter is documented in wp-includes/default-widgets.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   464
		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   465
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   466
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   467
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   468
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   469
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
		echo '<div id="calendar_wrap">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
		get_calendar();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
		echo '</div>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   473
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   476
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   483
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
		$title = strip_tags($instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
 * Text widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
class WP_Widget_Text extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   500
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
		$widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.'));
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
		$control_ops = array('width' => 400, 'height' => 350);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
		parent::__construct('text', __('Text'), $widget_ops, $control_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   506
	public function widget( $args, $instance ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   507
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   508
		/** This filter is documented in wp-includes/default-widgets.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   510
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   511
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   512
		 * Filter the content of the Text widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   513
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   514
		 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   515
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   516
		 * @param string    $widget_text The widget content.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   517
		 * @param WP_Widget $instance    WP_Widget instance.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   518
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
		$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   520
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   521
		if ( ! empty( $title ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   522
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   523
		} ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
			<div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
		<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   526
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   529
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
		if ( current_user_can('unfiltered_html') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
			$instance['text'] =  $new_instance['text'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
			$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   536
		$instance['filter'] = ! empty( $new_instance['filter'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
		$title = strip_tags($instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
		$text = esc_textarea($instance['text']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
		<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
 * Categories widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
class WP_Widget_Categories extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   562
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   563
		$widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
		parent::__construct('categories', __('Categories'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   567
	public function widget( $args, $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   569
		/** This filter is documented in wp-includes/default-widgets.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   570
		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   571
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
		$c = ! empty( $instance['count'] ) ? '1' : '0';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
		$h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
		$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   576
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   577
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   578
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   579
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   581
		$cat_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   582
			'orderby'      => 'name',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   583
			'show_count'   => $c,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
			'hierarchical' => $h
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   585
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
		if ( $d ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
			static $first_dropdown = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
			$dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
			$first_dropdown = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   593
			echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
			$cat_args['show_option_none'] = __( 'Select Category' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
			$cat_args['id'] = $dropdown_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
			 * Filter the arguments for the Categories widget drop-down.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
			 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
			 * @see wp_dropdown_categories()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   605
			 * @param array $cat_args An array of Categories widget drop-down arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
			wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
<script type='text/javascript'>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
/* <![CDATA[ */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   612
(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
	var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
	function onCatChange() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   615
		if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
			location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
	dropdown.onchange = onCatChange;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   620
})();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
/* ]]> */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
		<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
		$cat_args['title_li'] = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   630
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   631
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   632
		 * Filter the arguments for the Categories widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   634
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
		 * @param array $cat_args An array of Categories widget options.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
		wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
		</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   644
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   647
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
		$instance['count'] = !empty($new_instance['count']) ? 1 : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
		$instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
		$instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   657
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
		//Defaults
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
		$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
		$title = esc_attr( $instance['title'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
		$count = isset($instance['count']) ? (bool) $instance['count'] :false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
		$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
		$dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
		<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 ); ?> />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
		<label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
		<label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
		<label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
 * Recent_Posts widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
class WP_Widget_Recent_Posts extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   688
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   689
		$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site&#8217;s most recent Posts.") );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
		parent::__construct('recent-posts', __('Recent Posts'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
		$this->alt_option_name = 'widget_recent_entries';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
		add_action( 'save_post', array($this, 'flush_widget_cache') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
		add_action( 'deleted_post', array($this, 'flush_widget_cache') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
		add_action( 'switch_theme', array($this, 'flush_widget_cache') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   698
	public function widget($args, $instance) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   699
		$cache = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   700
		if ( ! $this->is_preview() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   701
			$cache = wp_cache_get( 'widget_recent_posts', 'widget' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   702
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   704
		if ( ! is_array( $cache ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
			$cache = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   706
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   708
		if ( ! isset( $args['widget_id'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
			$args['widget_id'] = $this->id;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   710
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
		if ( isset( $cache[ $args['widget_id'] ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
			echo $cache[ $args['widget_id'] ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
		ob_start();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
		$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   720
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   721
		/** This filter is documented in wp-includes/default-widgets.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   723
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   724
		$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
		if ( ! $number )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   726
			$number = 5;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
		$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   729
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   730
		 * Filter the arguments for the Recent Posts widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   734
		 * @see WP_Query::get_posts()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   736
		 * @param array $args An array of arguments used to retrieve the recent posts.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   738
		$r = new WP_Query( apply_filters( 'widget_posts_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   739
			'posts_per_page'      => $number,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   740
			'no_found_rows'       => true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   741
			'post_status'         => 'publish',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   742
			'ignore_sticky_posts' => true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   743
		) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   744
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
		if ($r->have_posts()) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   747
		<?php echo $args['before_widget']; ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   748
		<?php if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   749
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   750
		} ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
		<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
		<?php while ( $r->have_posts() ) : $r->the_post(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
			<li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
				<a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
			<?php if ( $show_date ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
				<span class="post-date"><?php echo get_the_date(); ?></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
			<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
			</li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
		<?php endwhile; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
		</ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   761
		<?php echo $args['after_widget']; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
		// Reset the global $the_post as this query will have stomped on it
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
		wp_reset_postdata();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
		endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   768
		if ( ! $this->is_preview() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   769
			$cache[ $args['widget_id'] ] = ob_get_flush();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   770
			wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   771
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   772
			ob_end_flush();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   773
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   776
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
		$instance['number'] = (int) $new_instance['number'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
		$instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
		$this->flush_widget_cache();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
		$alloptions = wp_cache_get( 'alloptions', 'options' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
		if ( isset($alloptions['widget_recent_entries']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
			delete_option('widget_recent_entries');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   790
	public function flush_widget_cache() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
		wp_cache_delete('widget_recent_posts', 'widget');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   794
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
		$title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
		$number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
		$show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
		<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
		<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
		<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" /></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
		<p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
		<label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
 * Recent_Comments widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
class WP_Widget_Recent_Comments extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   818
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   819
		$widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site&#8217;s most recent comments.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
		parent::__construct('recent-comments', __('Recent Comments'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
		$this->alt_option_name = 'widget_recent_comments';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
		if ( is_active_widget(false, false, $this->id_base) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
			add_action( 'wp_head', array($this, 'recent_comments_style') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
		add_action( 'comment_post', array($this, 'flush_widget_cache') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
		add_action( 'edit_comment', array($this, 'flush_widget_cache') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
		add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   830
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   831
	public function recent_comments_style() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   832
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   833
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   834
		 * Filter the Recent Comments default widget styles.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   835
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   836
		 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   837
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   838
		 * @param bool   $active  Whether the widget is active. Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   839
		 * @param string $id_base The widget ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   840
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
		if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
			|| ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
	<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   849
	public function flush_widget_cache() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
		wp_cache_delete('widget_recent_comments', 'widget');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   853
	public function widget( $args, $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
		global $comments, $comment;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   856
		$cache = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   857
		if ( ! $this->is_preview() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   858
			$cache = wp_cache_get('widget_recent_comments', 'widget');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   859
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
		if ( ! is_array( $cache ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
			$cache = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   862
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
		if ( ! isset( $args['widget_id'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
			$args['widget_id'] = $this->id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
		if ( isset( $cache[ $args['widget_id'] ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
			echo $cache[ $args['widget_id'] ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   872
		$output = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
		$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   876
		/** This filter is documented in wp-includes/default-widgets.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   878
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
		$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
		if ( ! $number )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   881
			$number = 5;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   883
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   884
		 * Filter the arguments for the Recent Comments widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   885
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   886
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   887
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
		 * @see WP_Comment_Query::query() for information on accepted arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   889
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   890
		 * @param array $comment_args An array of arguments used to retrieve the recent comments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   892
		$comments = get_comments( apply_filters( 'widget_comments_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
			'number'      => $number,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
			'status'      => 'approve',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
			'post_status' => 'publish'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
		) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   897
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   898
		$output .= $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   899
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   900
			$output .= $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   901
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
		$output .= '<ul id="recentcomments">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
		if ( $comments ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
			// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
			$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
			_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
			foreach ( (array) $comments as $comment) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   910
				$output .= '<li class="recentcomments">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   911
				/* translators: comments widget: 1: comment author, 2: post link */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   912
				$output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   913
					'<span class="comment-author-link">' . get_comment_author_link() . '</span>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   914
					'<a href="' . esc_url( get_comment_link( $comment->comment_ID ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   915
				);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   916
				$output .= '</li>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   918
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
		$output .= '</ul>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   920
		$output .= $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
		echo $output;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   923
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   924
		if ( ! $this->is_preview() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   925
			$cache[ $args['widget_id'] ] = $output;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   926
			wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   927
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   930
	public function update( $new_instance, $old_instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
		$instance = $old_instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
		$instance['title'] = strip_tags($new_instance['title']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
		$instance['number'] = absint( $new_instance['number'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
		$this->flush_widget_cache();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
		$alloptions = wp_cache_get( 'alloptions', 'options' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
		if ( isset($alloptions['widget_recent_comments']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
			delete_option('widget_recent_comments');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   943
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
		$title  = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
		$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
		<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
		<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
		<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" /></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
 * RSS widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
class WP_Widget_RSS extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   963
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   964
		$widget_ops = array( 'description' => __('Entries from any RSS or Atom feed.') );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
		$control_ops = array( 'width' => 400, 'height' => 200 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
		parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   969
	public function widget($args, $instance) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
		if ( isset($instance['error']) && $instance['error'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
		$url = ! empty( $instance['url'] ) ? $instance['url'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
		while ( stristr($url, 'http') != $url )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
			$url = substr($url, 1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   977
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
		if ( empty($url) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
		// self-url destruction sequence
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
		if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
		$rss = fetch_feed($url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
		$title = $instance['title'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
		$desc = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
		$link = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
		if ( ! is_wp_error($rss) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
			$desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
			if ( empty($title) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
				$title = esc_html(strip_tags($rss->get_title()));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
			$link = esc_url(strip_tags($rss->get_permalink()));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
			while ( stristr($link, 'http') != $link )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
				$link = substr($link, 1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
		if ( empty($title) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
			$title = empty($desc) ? __('Unknown Feed') : $desc;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1002
		/** This filter is documented in wp-includes/default-widgets.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1004
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
		$url = esc_url(strip_tags($url));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
		$icon = includes_url('images/rss.png');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
		if ( $title )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1008
			$title = "<a class='rsswidget' href='$url'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link'>$title</a>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1010
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1011
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1012
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1013
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
		wp_widget_rss_output( $rss, $instance );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1015
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
		if ( ! is_wp_error($rss) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
			$rss->__destruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
		unset($rss);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1022
	public function update($new_instance, $old_instance) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
		$testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
		return wp_widget_rss_process( $new_instance, $testurl );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1027
	public function form($instance) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
		if ( empty($instance) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
			$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
		$instance['number'] = $this->number;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
		wp_widget_rss_form( $instance );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
 * Display the RSS entries in a list.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
 * @param string|array|object $rss RSS url.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
 * @param array $args Widget arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
function wp_widget_rss_output( $rss, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
	if ( is_string( $rss ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
		$rss = fetch_feed($rss);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
	} elseif ( is_array($rss) && isset($rss['url']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
		$args = $rss;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
		$rss = fetch_feed($rss['url']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
	} elseif ( !is_object($rss) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
	if ( is_wp_error($rss) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
		if ( is_admin() || current_user_can('manage_options') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
			echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1058
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1061
	$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
	$args = wp_parse_args( $args, $default_args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1064
	$items = (int) $args['items'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
	if ( $items < 1 || 20 < $items )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
		$items = 10;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1067
	$show_summary  = (int) $args['show_summary'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1068
	$show_author   = (int) $args['show_author'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1069
	$show_date     = (int) $args['show_date'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
	if ( !$rss->get_item_quantity() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
		echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
		$rss->__destruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
		unset($rss);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
	echo '<ul>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1079
	foreach ( $rss->get_items( 0, $items ) as $item ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
		$link = $item->get_link();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1081
		while ( stristr( $link, 'http' ) != $link ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1082
			$link = substr( $link, 1 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1083
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1084
		$link = esc_url( strip_tags( $link ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1086
		$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1087
		if ( empty( $title ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1088
			$title = __( 'Untitled' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1089
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1091
		$desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1092
		$desc = esc_attr( wp_trim_words( $desc, 55, ' [&hellip;]' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1093
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1094
		$summary = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1095
		if ( $show_summary ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1096
			$summary = $desc;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1098
			// Change existing [...] to [&hellip;].
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1099
			if ( '[...]' == substr( $summary, -5 ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1100
				$summary = substr( $summary, 0, -5 ) . '[&hellip;]';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1101
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1103
			$summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
		$date = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
		if ( $show_date ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
			$date = $item->get_date( 'U' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
			if ( $date ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
				$date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
		$author = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
		if ( $show_author ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
			$author = $item->get_author();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
			if ( is_object($author) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
				$author = $author->get_name();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
				$author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
		if ( $link == '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
			echo "<li>$title{$date}{$summary}{$author}</li>";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1126
		} elseif ( $show_summary ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1127
			echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
		} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1129
			echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$author}</li>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1132
	echo '</ul>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
	$rss->__destruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
	unset($rss);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1136
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1137
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
 * Display RSS widget options form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
 * The options for what fields are displayed for the RSS form are all booleans
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
 * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
 * 'show_date'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1143
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
 * @param array|string $args Values for input fields.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
 * @param array $inputs Override default display options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
function wp_widget_rss_form( $args, $inputs = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
	$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
	$inputs = wp_parse_args( $inputs, $default_inputs );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1152
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1153
	$args['number'] = esc_attr( $args['number'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1154
	$args['title'] = isset( $args['title'] ) ? esc_attr( $args['title'] ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1155
	$args['url'] = isset( $args['url'] ) ? esc_url( $args['url'] ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1156
	$args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1158
	if ( $args['items'] < 1 || 20 < $args['items'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1159
		$args['items'] = 10;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1160
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1162
	$args['show_summary']   = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1163
	$args['show_author']    = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1164
	$args['show_date']      = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1165
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1166
	if ( ! empty( $args['error'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1167
		echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), $args['error'] ) . '</strong></p>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1168
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
	if ( $inputs['url'] ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1172
	<p><label for="rss-url-<?php echo $args['number']; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1173
	<input class="widefat" id="rss-url-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][url]" type="text" value="<?php echo $args['url']; ?>" /></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
<?php endif; if ( $inputs['title'] ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1175
	<p><label for="rss-title-<?php echo $args['number']; ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1176
	<input class="widefat" id="rss-title-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][title]" type="text" value="<?php echo $args['title']; ?>" /></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
<?php endif; if ( $inputs['items'] ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1178
	<p><label for="rss-items-<?php echo $args['number']; ?>"><?php _e( 'How many items would you like to display?' ); ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1179
	<select id="rss-items-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][items]">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1181
		for ( $i = 1; $i <= 20; ++$i ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1182
			echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1183
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
	</select></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1186
<?php endif; if ( $inputs['show_summary'] ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1187
	<p><input id="rss-show-summary-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> />
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1188
	<label for="rss-show-summary-<?php echo $args['number']; ?>"><?php _e( 'Display item content?' ); ?></label></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
<?php endif; if ( $inputs['show_author'] ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1190
	<p><input id="rss-show-author-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> />
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1191
	<label for="rss-show-author-<?php echo $args['number']; ?>"><?php _e( 'Display item author if available?' ); ?></label></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
<?php endif; if ( $inputs['show_date'] ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1193
	<p><input id="rss-show-date-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1194
	<label for="rss-show-date-<?php echo $args['number']; ?>"><?php _e( 'Display item date?' ); ?></label></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1195
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
	foreach ( array_keys($default_inputs) as $input ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
		if ( 'hidden' === $inputs[$input] ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1199
			$id = str_replace( '_', '-', $input );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1201
	<input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][<?php echo $input; ?>]" value="<?php echo $args[ $input ]; ?>" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1203
		endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
	endforeach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1208
 * Process RSS feed widget data and optionally retrieve feed items.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1209
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1210
 * The feed widget can not have more than 20 items or it will reset back to the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
 * default, which is 10.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
 * The resulting array has the feed title, feed url, feed link (from channel),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
 * feed items, error (if any), and whether to show summary, author, and date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
 * All respectively in the order of the array elements.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1219
 * @param array $widget_rss RSS widget feed data. Expects unescaped data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
 * @param bool $check_feed Optional, default is true. Whether to check feed for errors.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
 * @return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1222
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1223
function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1224
	$items = (int) $widget_rss['items'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1225
	if ( $items < 1 || 20 < $items )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1226
		$items = 10;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1227
	$url           = esc_url_raw( strip_tags( $widget_rss['url'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1228
	$title         = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
	$show_summary  = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1230
	$show_author   = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] :0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1231
	$show_date     = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1232
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1233
	if ( $check_feed ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1234
		$rss = fetch_feed($url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
		$error = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
		$link = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
		if ( is_wp_error($rss) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
			$error = $rss->get_error_message();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
			$link = esc_url(strip_tags($rss->get_permalink()));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1241
			while ( stristr($link, 'http') != $link )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1242
				$link = substr($link, 1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1244
			$rss->__destruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1245
			unset($rss);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1247
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
	return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
 * Tag cloud widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
class WP_Widget_Tag_Cloud extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1259
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1260
		$widget_ops = array( 'description' => __( "A cloud of your most used tags.") );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
		parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1264
	public function widget( $args, $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
		$current_taxonomy = $this->_get_current_taxonomy($instance);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1266
		if ( !empty($instance['title']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
			$title = $instance['title'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1269
			if ( 'post_tag' == $current_taxonomy ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
				$title = __('Tags');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1271
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1272
				$tax = get_taxonomy($current_taxonomy);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
				$title = $tax->labels->name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1276
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1277
		/** This filter is documented in wp-includes/default-widgets.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1278
		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1279
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1280
		echo $args['before_widget'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1281
		if ( $title ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1282
			echo $args['before_title'] . $title . $args['after_title'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1283
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1284
		echo '<div class="tagcloud">';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1286
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1287
		 * Filter the taxonomy used in the Tag Cloud widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1288
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1289
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1290
		 * @since 3.0.0 Added taxonomy drop-down.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1291
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1292
		 * @see wp_tag_cloud()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1293
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1294
		 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1295
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1296
		wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1297
			'taxonomy' => $current_taxonomy
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1298
		) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1299
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1300
		echo "</div>\n";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1301
		echo $args['after_widget'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1304
	public function update( $new_instance, $old_instance ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1305
		$instance = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
		$instance['title'] = strip_tags(stripslashes($new_instance['title']));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
		$instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1311
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1312
		$current_taxonomy = $this->_get_current_taxonomy($instance);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
	<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
	<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1316
	<p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
	<select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1318
	<?php foreach ( get_taxonomies() as $taxonomy ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1319
				$tax = get_taxonomy($taxonomy);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1320
				if ( !$tax->show_tagcloud || empty($tax->labels->name) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1321
					continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1322
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
		<option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1324
	<?php endforeach; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
	</select></p><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1328
	public function _get_current_taxonomy($instance) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
		if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
			return $instance['taxonomy'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1331
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1332
		return 'post_tag';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1335
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
 * Navigation Menu widget class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1341
 class WP_Nav_Menu_Widget extends WP_Widget {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1343
	public function __construct() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1344
		$widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1345
		parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1348
	public function widget($args, $instance) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1349
		// Get menu
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
		$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1351
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1352
		if ( !$nav_menu )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1353
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1355
		/** This filter is documented in wp-includes/default-widgets.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1356
		$instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1357
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
		echo $args['before_widget'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1359
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
		if ( !empty($instance['title']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
			echo $args['before_title'] . $instance['title'] . $args['after_title'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1363
		$nav_menu_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1364
			'fallback_cb' => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1365
			'menu'        => $nav_menu
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1366
		);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1367
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1368
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1369
		 * Filter the arguments for the Custom Menu widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1370
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1371
		 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1372
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1373
		 * @param array    $nav_menu_args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1374
		 *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1375
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1376
		 *     @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1377
		 *     @type mixed         $menu        Menu ID, slug, or name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1378
		 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1379
		 * @param stdClass $nav_menu      Nav menu object for the current menu.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1380
		 * @param array    $args          Display arguments for the current widget.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1381
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1382
		wp_nav_menu( apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1384
		echo $args['after_widget'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1385
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1386
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1387
	public function update( $new_instance, $old_instance ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1388
		$instance = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1389
		if ( ! empty( $new_instance['title'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1390
			$instance['title'] = strip_tags( stripslashes($new_instance['title']) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1391
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1392
		if ( ! empty( $new_instance['nav_menu'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1393
			$instance['nav_menu'] = (int) $new_instance['nav_menu'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1394
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1395
		return $instance;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1396
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1397
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1398
	public function form( $instance ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
		$title = isset( $instance['title'] ) ? $instance['title'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1400
		$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1401
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1402
		// Get menus
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1403
		$menus = wp_get_nav_menus();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1404
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1405
		// If no menus exists, direct the user to go and create some.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1406
		if ( !$menus ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1407
			echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1408
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1409
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1410
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1413
			<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1414
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1415
		<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1416
			<label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
			<select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1418
				<option value="0"><?php _e( '&mdash; Select &mdash;' ) ?></option>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1419
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1420
			foreach ( $menus as $menu ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1421
				echo '<option value="' . $menu->term_id . '"'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
					. selected( $nav_menu, $menu->term_id, false )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1423
					. '>'. esc_html( $menu->name ) . '</option>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1424
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1425
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1426
			</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1427
		</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1428
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1430
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1433
 * Register all of the default WordPress widgets on startup.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
 * Calls 'widgets_init' action after all of the WordPress widgets have been
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
 * registered.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1437
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1438
 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
function wp_widgets_init() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
	if ( !is_blog_installed() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1442
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1443
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1444
	register_widget('WP_Widget_Pages');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1445
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1446
	register_widget('WP_Widget_Calendar');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
	register_widget('WP_Widget_Archives');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1449
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
	if ( get_option( 'link_manager_enabled' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
		register_widget('WP_Widget_Links');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
	register_widget('WP_Widget_Meta');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
	register_widget('WP_Widget_Search');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
	register_widget('WP_Widget_Text');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
	register_widget('WP_Widget_Categories');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
	register_widget('WP_Widget_Recent_Posts');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
	register_widget('WP_Widget_Recent_Comments');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
	register_widget('WP_Widget_RSS');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1466
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
	register_widget('WP_Widget_Tag_Cloud');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1469
	register_widget('WP_Nav_Menu_Widget');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1471
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1472
	 * Fires after all default WordPress widgets have been registered.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1473
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1474
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1475
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1476
	do_action( 'widgets_init' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
add_action('init', 'wp_widgets_init', 1);