| 1030 | | $current_taxonomy = $this->_get_current_taxonomy($instance); |
| 1031 | | ?> |
| 1032 | | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label> |
| 1033 | | <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> |
| 1034 | | <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label> |
| 1035 | | <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>"> |
| 1036 | | <?php foreach ( get_object_taxonomies('post') as $taxonomy ) : |
| 1037 | | $tax = get_taxonomy($taxonomy); |
| 1038 | | if ( !$tax->show_tagcloud || empty($tax->labels->name) ) |
| 1039 | | continue; |
| 1040 | | ?> |
| 1041 | | <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option> |
| 1042 | | <?php endforeach; ?> |
| 1043 | | </select></p><?php |
| | 1034 | $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
| | 1035 | echo '<p><label for="' . $this->get_field_id( 'title' ) .'">' . __( 'Title:' ) . '</label> |
| | 1036 | <input type="text" class="widefat" id="' . $this->get_field_id( 'title' ) .'" name="' . $this->get_field_name( 'title' ) .'" value="' . $instance['title'] .'" /> |
| | 1037 | </p>'; |
| | 1038 | |
| | 1039 | $current_taxonomy = $this->_get_current_taxonomy( $instance ); |
| | 1040 | $taxonomies = get_taxonomies( array( 'show_tagcloud' => true ), 'object' ); |
| | 1041 | |
| | 1042 | switch ( count( $taxonomies ) ) { |
| | 1043 | |
| | 1044 | // No tag cloud supporting taxonomies found, display error message |
| | 1045 | case 0 : |
| | 1046 | echo '<p>' . __( 'The tag cloud would not be displayed since their are no taxonomies that support the tag cloud widget.' ) . '</p>'; |
| | 1047 | echo '<input type="hidden" id="' . $this->get_field_id( 'taxonomy' ) . '" name="' . $this->get_field_name( 'taxonomy' ) . '" value="" />'; |
| | 1048 | break; |
| | 1049 | |
| | 1050 | // Just a single tag cloud supporting taxonomy found, no need to display options |
| | 1051 | case 1 : |
| | 1052 | $taxonomy = array_pop( array_keys( $taxonomies ) ); |
| | 1053 | echo '<input type="hidden" id="' . $this->get_field_id( 'taxonomy' ) . '" name="' . $this->get_field_name( 'taxonomy' ) . '" value="' . esc_attr( $taxonomy ) . '" />'; |
| | 1054 | break; |
| | 1055 | |
| | 1056 | // More than one tag cloud supporting taxonomy found, display options |
| | 1057 | default : |
| | 1058 | echo '<p><label for="' . $this->get_field_id( 'taxonomy' ) . '">' . __( 'Taxonomy:' ) . '</label> |
| | 1059 | <select class="widefat" id="' . $this->get_field_id( 'taxonomy' ) . '" name="' . $this->get_field_name( 'taxonomy' ) .'">'; |
| | 1060 | |
| | 1061 | foreach ( $taxonomies as $taxonomy => $tax ) { |
| | 1062 | echo '<option value="' . esc_attr( $taxonomy ) . '"' . selected( $taxonomy, $current_taxonomy, false ) .'>' . $tax->labels->name .'</option>'; |
| | 1063 | } |
| | 1064 | |
| | 1065 | echo '</select></p>'; |
| | 1066 | } |
| | 1067 | |