Make WordPress Core

Ticket #9449: 9449.diff

File 9449.diff, 2.8 KB (added by Denis-de-Bernardy, 15 years ago)
  • Users/denis/Sites/sem-pro/wp-includes/default-widgets.php

     
    102102                $show_name = isset($instance['name']) ? $instance['name'] : false;
    103103                $show_rating = isset($instance['rating']) ? $instance['rating'] : false;
    104104                $show_images = isset($instance['images']) ? $instance['images'] : true;
    105 
     105                $category = isset($instance['category']) ? $instance['category'] : false;
     106               
     107                if ( is_admin() && !$category ) {
     108                        // Display All Links widget as such in the widgets screen
     109                        echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget;
     110                        return;
     111                }
     112               
    106113                $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
    107114                wp_list_bookmarks(apply_filters('widget_links_args', array(
    108115                        'title_before' => $before_title, 'title_after' => $after_title,
    109116                        'category_before' => $before_widget, 'category_after' => $after_widget,
    110117                        'show_images' => $show_images, 'show_description' => $show_description,
    111118                        'show_name' => $show_name, 'show_rating' => $show_rating,
    112                         'class' => 'linkcat widget'
     119                        'category' => $category, 'class' => 'linkcat widget'
    113120                )));
    114121        }
    115122
     
    120127                        if ( isset($new_instance[$field]) )
    121128                                $instance[$field] = 1;
    122129                }
     130                $instance['category'] = intval($new_instance['category']);
    123131
    124132                return $instance;
    125133        }
     
    127135        function form( $instance ) {
    128136
    129137                //Defaults
    130                 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false) );
     138                $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
     139                $link_cats = get_terms( 'link_category');
    131140?>
    132141                <p>
     142                <label for="<?php echo $this->get_field_id('category'); ?>">
     143                <select id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" style="width: 97%;" />
     144                <option value=""><?php _e('All Links'); ?></option>
     145                <?php
     146                foreach ( $link_cats as $link_cat ) {
     147                        echo '<option value="' . intval($link_cat->term_id) . '"'
     148                                . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
     149                                . '>' . $link_cat->name . "</option>\n";
     150                }
     151                ?>
     152                </select></label><br />
    133153                <label for="<?php echo $this->get_field_id('images'); ?>">
    134154                <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'); ?>" /> <?php _e('Show Link Image'); ?></label><br />
    135155                <label for="<?php echo $this->get_field_id('name'); ?>">