Changeset 42343 for trunk/src/wp-includes/widgets/class-wp-widget-links.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets/class-wp-widget-links.php
r41685 r42343 24 24 public function __construct() { 25 25 $widget_ops = array( 26 'description' => __( 'Your blogroll' ),26 'description' => __( 'Your blogroll' ), 27 27 'customize_selective_refresh' => true, 28 28 ); … … 40 40 */ 41 41 public function widget( $args, $instance ) { 42 $show_description = isset( $instance['description']) ? $instance['description'] : false;43 $show_name = isset($instance['name']) ? $instance['name'] : false;44 $show_rating = isset($instance['rating']) ? $instance['rating'] : false;45 $show_images = isset($instance['images']) ? $instance['images'] : true;46 $category = isset($instance['category']) ? $instance['category'] : false;47 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';48 $order = $orderby == 'rating' ? 'DESC' : 'ASC';49 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;42 $show_description = isset( $instance['description'] ) ? $instance['description'] : false; 43 $show_name = isset( $instance['name'] ) ? $instance['name'] : false; 44 $show_rating = isset( $instance['rating'] ) ? $instance['rating'] : false; 45 $show_images = isset( $instance['images'] ) ? $instance['images'] : true; 46 $category = isset( $instance['category'] ) ? $instance['category'] : false; 47 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 48 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; 49 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 50 50 51 51 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); … … 93 93 public function update( $new_instance, $old_instance ) { 94 94 $new_instance = (array) $new_instance; 95 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 95 $instance = array( 96 'images' => 0, 97 'name' => 0, 98 'description' => 0, 99 'rating' => 0, 100 ); 96 101 foreach ( $instance as $field => $val ) { 97 if ( isset($new_instance[$field]) ) 98 $instance[$field] = 1; 102 if ( isset( $new_instance[ $field ] ) ) { 103 $instance[ $field ] = 1; 104 } 99 105 } 100 106 101 107 $instance['orderby'] = 'name'; 102 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 108 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { 103 109 $instance['orderby'] = $new_instance['orderby']; 110 } 104 111 105 112 $instance['category'] = intval( $new_instance['category'] ); 106 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;113 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; 107 114 108 115 return $instance; … … 119 126 120 127 //Defaults 121 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); 128 $instance = wp_parse_args( 129 (array) $instance, array( 130 'images' => true, 131 'name' => true, 132 'description' => false, 133 'rating' => false, 134 'category' => false, 135 'orderby' => 'name', 136 'limit' => -1, 137 ) 138 ); 122 139 $link_cats = get_terms( 'link_category' ); 123 if ( ! $limit = intval( $instance['limit'] ) ) 140 if ( ! $limit = intval( $instance['limit'] ) ) { 124 141 $limit = -1; 142 } 125 143 ?> 126 144 <p> 127 <label for="<?php echo $this->get_field_id( 'category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>128 <select class="widefat" id="<?php echo $this->get_field_id( 'category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">129 <option value=""><?php _ex( 'All Links', 'links widget'); ?></option>145 <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Select Link Category:' ); ?></label> 146 <select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>"> 147 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> 130 148 <?php 131 149 foreach ( $link_cats as $link_cat ) { … … 136 154 ?> 137 155 </select> 138 <label for="<?php echo $this->get_field_id( 'orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>139 <select name="<?php echo $this->get_field_name( 'orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">156 <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:' ); ?></label> 157 <select name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>" class="widefat"> 140 158 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option> 141 159 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option> … … 145 163 </p> 146 164 <p> 147 <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'); ?>" />148 <label for="<?php echo $this->get_field_id( 'images'); ?>"><?php _e('Show Link Image'); ?></label><br />149 <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'); ?>" />150 <label for="<?php echo $this->get_field_id( 'name'); ?>"><?php _e('Show Link Name'); ?></label><br />151 <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'); ?>" />152 <label for="<?php echo $this->get_field_id( 'description'); ?>"><?php _e('Show Link Description'); ?></label><br />153 <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'); ?>" />154 <label for="<?php echo $this->get_field_id( 'rating'); ?>"><?php _e('Show Link Rating'); ?></label>165 <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' ); ?>" /> 166 <label for="<?php echo $this->get_field_id( 'images' ); ?>"><?php _e( 'Show Link Image' ); ?></label><br /> 167 <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' ); ?>" /> 168 <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e( 'Show Link Name' ); ?></label><br /> 169 <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' ); ?>" /> 170 <label for="<?php echo $this->get_field_id( 'description' ); ?>"><?php _e( 'Show Link Description' ); ?></label><br /> 171 <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' ); ?>" /> 172 <label for="<?php echo $this->get_field_id( 'rating' ); ?>"><?php _e( 'Show Link Rating' ); ?></label> 155 173 </p> 156 174 <p> 157 <label for="<?php echo $this->get_field_id( 'limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>158 <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" />175 <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label> 176 <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" /> 159 177 </p> 160 178 <?php
Note: See TracChangeset
for help on using the changeset viewer.