43 $show_name = isset( $instance['name'] ) ? $instance['name'] : false; |
43 $show_name = isset( $instance['name'] ) ? $instance['name'] : false; |
44 $show_rating = isset( $instance['rating'] ) ? $instance['rating'] : false; |
44 $show_rating = isset( $instance['rating'] ) ? $instance['rating'] : false; |
45 $show_images = isset( $instance['images'] ) ? $instance['images'] : true; |
45 $show_images = isset( $instance['images'] ) ? $instance['images'] : true; |
46 $category = isset( $instance['category'] ) ? $instance['category'] : false; |
46 $category = isset( $instance['category'] ) ? $instance['category'] : false; |
47 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; |
47 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; |
48 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; |
48 $order = 'rating' === $orderby ? 'DESC' : 'ASC'; |
49 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; |
49 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; |
50 |
50 |
51 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); |
51 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); |
52 |
52 |
53 $widget_links_args = array( |
53 $widget_links_args = array( |
103 $instance[ $field ] = 1; |
103 $instance[ $field ] = 1; |
104 } |
104 } |
105 } |
105 } |
106 |
106 |
107 $instance['orderby'] = 'name'; |
107 $instance['orderby'] = 'name'; |
108 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { |
108 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ), true ) ) { |
109 $instance['orderby'] = $new_instance['orderby']; |
109 $instance['orderby'] = $new_instance['orderby']; |
110 } |
110 } |
111 |
111 |
112 $instance['category'] = intval( $new_instance['category'] ); |
112 $instance['category'] = intval( $new_instance['category'] ); |
113 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; |
113 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; |
135 'category' => false, |
135 'category' => false, |
136 'orderby' => 'name', |
136 'orderby' => 'name', |
137 'limit' => -1, |
137 'limit' => -1, |
138 ) |
138 ) |
139 ); |
139 ); |
140 $link_cats = get_terms( 'link_category' ); |
140 $link_cats = get_terms( array( 'taxonomy' => 'link_category' ) ); |
141 if ( ! $limit = intval( $instance['limit'] ) ) { |
141 $limit = intval( $instance['limit'] ); |
|
142 if ( ! $limit ) { |
142 $limit = -1; |
143 $limit = -1; |
143 } |
144 } |
144 ?> |
145 ?> |
145 <p> |
146 <p> |
146 <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Select Link Category:' ); ?></label> |
147 <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Select Link Category:' ); ?></label> |
147 <select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>"> |
148 <select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>"> |
148 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> |
149 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> |
149 <?php |
150 <?php foreach ( $link_cats as $link_cat ) : ?> |
150 foreach ( $link_cats as $link_cat ) { |
151 <option value="<?php echo intval( $link_cat->term_id ); ?>" <?php selected( $instance['category'], $link_cat->term_id ); ?>> |
151 echo '<option value="' . intval( $link_cat->term_id ) . '"' |
152 <?php echo esc_html( $link_cat->name ); ?> |
152 . selected( $instance['category'], $link_cat->term_id, false ) |
153 </option> |
153 . '>' . $link_cat->name . "</option>\n"; |
154 <?php endforeach; ?> |
154 } |
155 </select> |
155 ?> |
156 <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:' ); ?></label> |
156 </select> |
157 <select name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>" class="widefat"> |
157 <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:' ); ?></label> |
158 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option> |
158 <select name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>" class="widefat"> |
159 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option> |
159 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option> |
160 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option> |
160 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option> |
161 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option> |
161 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option> |
162 </select> |
162 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option> |
|
163 </select> |
|
164 </p> |
163 </p> |
|
164 |
165 <p> |
165 <p> |
166 <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 <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' ); ?>" /> |
167 <label for="<?php echo $this->get_field_id( 'images' ); ?>"><?php _e( 'Show Link Image' ); ?></label><br /> |
167 <label for="<?php echo $this->get_field_id( 'images' ); ?>"><?php _e( 'Show Link Image' ); ?></label> |
168 <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 <br /> |
169 <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e( 'Show Link Name' ); ?></label><br /> |
169 |
170 <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 <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' ); ?>" /> |
171 <label for="<?php echo $this->get_field_id( 'description' ); ?>"><?php _e( 'Show Link Description' ); ?></label><br /> |
171 <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e( 'Show Link Name' ); ?></label> |
172 <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 <br /> |
173 <label for="<?php echo $this->get_field_id( 'rating' ); ?>"><?php _e( 'Show Link Rating' ); ?></label> |
173 |
|
174 <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' ); ?>" /> |
|
175 <label for="<?php echo $this->get_field_id( 'description' ); ?>"><?php _e( 'Show Link Description' ); ?></label> |
|
176 <br /> |
|
177 |
|
178 <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' ); ?>" /> |
|
179 <label for="<?php echo $this->get_field_id( 'rating' ); ?>"><?php _e( 'Show Link Rating' ); ?></label> |
174 </p> |
180 </p> |
|
181 |
175 <p> |
182 <p> |
176 <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label> |
183 <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label> |
177 <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" /> |
184 <input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="text" value="<?php echo ( -1 !== $limit ) ? intval( $limit ) : ''; ?>" size="3" /> |
178 </p> |
185 </p> |
179 <?php |
186 <?php |
180 } |
187 } |
181 } |
188 } |