X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/bf5c68485ef07868ad0a91168ecd0092af7661ae..8f374b7233bc2815ccc387e448d208c5434eb961:/wp-includes/default-widgets.php?ds=sidebyside diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index df7ef39a..e4856dac 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -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,11 +139,13 @@ 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'); ?>" />

+

+ + +

  • RSS'); ?>
  • RSS'); ?>
  • -
  • WordPress.org
  • +
  • $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()) : ?> @@ -646,7 +668,7 @@ class WP_Widget_Recent_Comments extends WP_Widget { if ( empty( $instance['number'] ) || ! $number = absint( $instance['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; @@ -869,8 +891,6 @@ function wp_widget_rss_output( $rss, $args = array() ) { unset($rss); } - - /** * Display RSS widget options form. * @@ -1033,7 +1053,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget {