Changeset 13276 for trunk/wp-includes/default-widgets.php
- Timestamp:
- 02/21/2010 02:47:58 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/default-widgets.php
r13268 r13276 977 977 function widget( $args, $instance ) { 978 978 extract($args); 979 $title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title'], $instance, $this->id_base); 979 $current_taxonomy = $this->_get_current_taxonomy($instance); 980 if ( !empty($instance['title']) ) { 981 $title = $instance['title']; 982 } else { 983 if ( 'post_tag' == $current_taxonomy ) { 984 $title = __('Tags'); 985 } else { 986 $tax = get_taxonomy($current_taxonomy); 987 $title = $tax->label; 988 } 989 } 990 $title = apply_filters('widget_title', $title, $instance, $this->id_base); 980 991 981 992 echo $before_widget; … … 983 994 echo $before_title . $title . $after_title; 984 995 echo '<div>'; 985 wp_tag_cloud( apply_filters('widget_tag_cloud_args', array()));996 wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); 986 997 echo "</div>\n"; 987 998 echo $after_widget; … … 990 1001 function update( $new_instance, $old_instance ) { 991 1002 $instance['title'] = strip_tags(stripslashes($new_instance['title'])); 1003 $instance['taxonomy'] = stripslashes($new_instance['taxonomy']); 992 1004 return $instance; 993 1005 } 994 1006 995 1007 function form( $instance ) { 1008 $current_taxonomy = $this->_get_current_taxonomy($instance); 996 1009 ?> 997 1010 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label> 998 1011 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p> 999 <?php 1012 <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label> 1013 <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>"> 1014 <?php foreach ( get_object_taxonomies('post') as $taxonomy ) : 1015 $tax = get_taxonomy($taxonomy); 1016 if ( !$tax->show_tagcloud || empty($tax->label) ) 1017 continue; 1018 ?> 1019 <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->label ?></option> 1020 <?php endforeach; ?> 1021 </select></p><?php 1022 } 1023 1024 function _get_current_taxonomy($instance) { 1025 if ( !empty($instance['taxonomy']) && is_taxonomy($instance['taxonomy']) ) 1026 return $instance['taxonomy']; 1027 1028 return 'post_tag'; 1000 1029 } 1001 1030 }
Note: See TracChangeset
for help on using the changeset viewer.