diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 4d269f1dad..876743635e 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -102,6 +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; + $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; + $order = $orderby == 'rating' ? 'DESC' : 'ASC'; + $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; if ( is_admin() && !$category ) { // Display All Links widget as such in the widgets screen @@ -115,18 +118,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,8 +145,10 @@ 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; ?>
@@ -148,7 +161,15 @@ class WP_Widget_Links extends WP_Widget { . '>' . $link_cat->name . "\n"; } ?> -
+ + + +
id="get_field_id('images'); ?>" name="get_field_name('images'); ?>" />
@@ -159,6 +180,10 @@ class WP_Widget_Links extends WP_Widget {
id="get_field_id('rating'); ?>" name="get_field_name('rating'); ?>" />
+ + +