77 | | $title = isset( $instance['title'] ) ? $instance['title'] : ''; |
78 | | ?> |
79 | | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label> |
80 | | <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $title ); ?>" /></p> |
81 | | <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label> |
82 | | <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>"> |
83 | | <?php foreach ( get_taxonomies() as $taxonomy ) : |
84 | | $tax = get_taxonomy($taxonomy); |
85 | | if ( !$tax->show_tagcloud || empty($tax->labels->name) ) |
86 | | continue; |
87 | | ?> |
88 | | <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo esc_attr( $tax->labels->name ); ?></option> |
89 | | <?php endforeach; ?> |
90 | | </select></p><?php |
| 77 | $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
| 78 | echo '<p><label for="' . $this->get_field_id( 'title' ) .'">' . __( 'Title:' ) . '</label> |
| 79 | <input type="text" class="widefat" id="' . $this->get_field_id( 'title' ) .'" name="' . $this->get_field_name( 'title' ) .'" value="' . $instance['title'] .'" /> |
| 80 | </p>'; |
| 81 | |
| 82 | $taxonomies = get_taxonomies( array( 'show_tagcloud' => true ), 'object' ); |
| 83 | |
| 84 | switch ( count( $taxonomies ) ) { |
| 85 | |
| 86 | // No tag cloud supporting taxonomies found, display error message |
| 87 | case 0: |
| 88 | echo '<p>' . __( 'The tag cloud would not be displayed since their are no taxonomies that support the tag cloud widget.' ) . '</p>'; |
| 89 | echo '<input type="hidden" id="' . $this->get_field_id( 'taxonomy' ) . '" name="' . $this->get_field_name( 'taxonomy' ) . '" value="" />'; |
| 90 | break; |
| 91 | |
| 92 | // Just a single tag cloud supporting taxonomy found, no need to display options |
| 93 | case 1: |
| 94 | $taxonomy = array_pop( array_keys( $taxonomies ) ); |
| 95 | echo '<input type="hidden" id="' . $this->get_field_id( 'taxonomy' ) . '" name="' . $this->get_field_name( 'taxonomy' ) . '" value="' . esc_attr( $taxonomy ) . '" />'; |
| 96 | break; |
| 97 | |
| 98 | // More than one tag cloud supporting taxonomy found, display options |
| 99 | default: |
| 100 | echo '<p><label for="' . $this->get_field_id( 'taxonomy' ) . '">' . __( 'Taxonomy:' ) . '</label> |
| 101 | <select class="widefat" id="' . $this->get_field_id( 'taxonomy' ) . '" name="' . $this->get_field_name( 'taxonomy' ) .'">'; |
| 102 | |
| 103 | foreach ( $taxonomies as $taxonomy => $tax ) { |
| 104 | echo '<option value="' . esc_attr( $taxonomy ) . '"' . selected( $taxonomy, $current_taxonomy, false ) .'>' . $tax->labels->name .'</option>'; |
| 105 | } |
| 106 | |
| 107 | echo '</select></p>'; |
| 108 | } |