X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/5aa86a9053fb0fa15846bb60aac2fb8fdfff524a..e08b42e8ad054ec67522d7ac1aaae5dc68cb3d01:/wp-includes/default-widgets.php diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index df7ef39a..6c6e321f 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -14,7 +14,7 @@ class WP_Widget_Pages extends WP_Widget { function __construct() { - $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your site’s WordPress Pages') ); + $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'A list of your site’s Pages.') ); parent::__construct('pages', __('Pages'), $widget_ops); } @@ -102,12 +102,9 @@ class WP_Widget_Links extends WP_Widget { $show_rating = isset($instance['rating']) ? $instance['rating'] : false; $show_images = isset($instance['images']) ? $instance['images'] : true; $category = isset($instance['category']) ? $instance['category'] : false; - - if ( is_admin() && !$category ) { - // Display All Links widget as such in the widgets screen - echo $before_widget . $before_title . _x('All Links', 'links widget') . $after_title . $after_widget; - return; - } + $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; + $order = $orderby == 'rating' ? 'DESC' : 'ASC'; + $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget); wp_list_bookmarks(apply_filters('widget_links_args', array( @@ -115,18 +112,26 @@ class WP_Widget_Links extends WP_Widget { 'category_before' => $before_widget, 'category_after' => $after_widget, 'show_images' => $show_images, 'show_description' => $show_description, 'show_name' => $show_name, 'show_rating' => $show_rating, - 'category' => $category, 'class' => 'linkcat widget' + 'category' => $category, 'class' => 'linkcat widget', + 'orderby' => $orderby, 'order' => $order, + 'limit' => $limit, ))); } function update( $new_instance, $old_instance ) { $new_instance = (array) $new_instance; - $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0); + $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); foreach ( $instance as $field => $val ) { if ( isset($new_instance[$field]) ) $instance[$field] = 1; } - $instance['category'] = intval($new_instance['category']); + + $instance['orderby'] = 'name'; + if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) + $instance['orderby'] = $new_instance['orderby']; + + $instance['category'] = intval( $new_instance['category'] ); + $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; return $instance; } @@ -134,21 +139,31 @@ class WP_Widget_Links extends WP_Widget { function form( $instance ) { //Defaults - $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) ); - $link_cats = get_terms( 'link_category'); + $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); + $link_cats = get_terms( 'link_category' ); + if ( ! $limit = intval( $instance['limit'] ) ) + $limit = -1; ?>

- +

+ + + +

id="get_field_id('images'); ?>" name="get_field_name('images'); ?>" />
@@ -159,6 +174,10 @@ class WP_Widget_Links extends WP_Widget { id="get_field_id('rating'); ?>" name="get_field_name('rating'); ?>" />

+

+ + +

'widget_search', 'description' => __( "A search form for your site") ); + $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site.") ); parent::__construct('search', __('Search'), $widget_ops); } @@ -214,7 +233,7 @@ class WP_Widget_Search extends WP_Widget { class WP_Widget_Archives extends WP_Widget { function __construct() { - $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s posts') ); + $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') ); parent::__construct('archives', __('Archives'), $widget_ops); } @@ -279,7 +298,7 @@ class WP_Widget_Archives extends WP_Widget { class WP_Widget_Meta extends WP_Widget { function __construct() { - $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") ); + $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") ); parent::__construct('meta', __('Meta'), $widget_ops); } @@ -296,7 +315,11 @@ class WP_Widget_Meta extends WP_Widget {
  • RSS'); ?>
  • RSS'); ?>
  • -
  • WordPress.org
  • + %s', + esc_url( __( 'http://wordpress.org/' ) ), + esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ), + _x( 'WordPress.org', 'meta widget link text' ) + ) ); ?> 'widget_calendar', 'description' => __( 'A calendar of your site’s posts') ); + $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.') ); parent::__construct('calendar', __('Calendar'), $widget_ops); } function widget( $args, $instance ) { extract($args); - $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base); + $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; @@ -368,7 +391,7 @@ class WP_Widget_Calendar extends WP_Widget { class WP_Widget_Text extends WP_Widget { function __construct() { - $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); + $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.')); $control_ops = array('width' => 400, 'height' => 350); parent::__construct('text', __('Text'), $widget_ops, $control_ops); } @@ -418,7 +441,7 @@ class WP_Widget_Text extends WP_Widget { class WP_Widget_Categories extends WP_Widget { function __construct() { - $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); + $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) ); parent::__construct('categories', __('Categories'), $widget_ops); } @@ -510,13 +533,13 @@ class WP_Widget_Categories extends WP_Widget { class WP_Widget_Recent_Posts extends WP_Widget { function __construct() { - $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") ); + $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site’s most recent Posts.") ); parent::__construct('recent-posts', __('Recent Posts'), $widget_ops); $this->alt_option_name = 'widget_recent_entries'; - add_action( 'save_post', array(&$this, 'flush_widget_cache') ); - add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); - add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); + add_action( 'save_post', array($this, 'flush_widget_cache') ); + add_action( 'deleted_post', array($this, 'flush_widget_cache') ); + add_action( 'switch_theme', array($this, 'flush_widget_cache') ); } function widget($args, $instance) { @@ -536,18 +559,26 @@ class WP_Widget_Recent_Posts extends WP_Widget { ob_start(); extract($args); - $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); - if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) + $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); + $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); + $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 10; + if ( ! $number ) $number = 10; + $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; - $r = new WP_Query(array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); + $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($r->have_posts()) : ?> @@ -565,6 +596,7 @@ class WP_Widget_Recent_Posts extends WP_Widget { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['number'] = (int) $new_instance['number']; + $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); @@ -579,14 +611,18 @@ class WP_Widget_Recent_Posts extends WP_Widget { } function form( $instance ) { - $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; - $number = isset($instance['number']) ? absint($instance['number']) : 5; + $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; + $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; ?> -

    -

    +

    +

    -

    -

    +

    +

    + +

    id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>" /> +

    'widget_recent_comments', 'description' => __( 'The most recent comments' ) ); + $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site’s most recent comments.' ) ); parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); $this->alt_option_name = 'widget_recent_comments'; if ( is_active_widget(false, false, $this->id_base) ) - add_action( 'wp_head', array(&$this, 'recent_comments_style') ); + add_action( 'wp_head', array($this, 'recent_comments_style') ); - add_action( 'comment_post', array(&$this, 'flush_widget_cache') ); - add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') ); + add_action( 'comment_post', array($this, 'flush_widget_cache') ); + add_action( 'edit_comment', array($this, 'flush_widget_cache') ); + add_action( 'transition_comment_status', array($this, 'flush_widget_cache') ); } function recent_comments_style() { @@ -641,18 +678,24 @@ class WP_Widget_Recent_Comments extends WP_Widget { extract($args, EXTR_SKIP); $output = ''; - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base ); - if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) + $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); + $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); + $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; + if ( ! $number ) $number = 5; - $comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ); + $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $output .= '