| 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 |
| | 85 | $title_id = $this->get_field_id( 'title' ); |
| | 86 | $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
| | 87 | |
| | 88 | echo '<p><label for="' . $title_id .'">' . __( 'Title:' ) . '</label> |
| | 89 | <input type="text" class="widefat" id="' . $title_id .'" name="' . $this->get_field_name( 'title' ) .'" value="' . $instance['title'] .'" /> |
| | 90 | </p>'; |
| | 91 | |
| | 92 | $taxonomies = get_taxonomies( array( 'show_tagcloud' => true ), 'object' ); |
| | 93 | $id = $this->get_field_id( 'taxonomy' ); |
| | 94 | $name = $this->get_field_name( 'taxonomy' ); |
| | 95 | $input = '<input type="hidden" id="' . $id . '" name="' . $name . '" value="%s" />'; |
| | 96 | |
| | 97 | switch ( count( $taxonomies ) ) { |
| | 98 | |
| | 99 | // No tag cloud supporting taxonomies found, display error message |
| | 100 | case 0: |
| | 101 | echo '<p>' . __( 'The tag cloud will not be displayed since their are no taxonomies that support the tag cloud widget.' ) . '</p>'; |
| | 102 | printf( $input, '' ); |
| | 103 | break; |
| | 104 | |
| | 105 | // Just a single tag cloud supporting taxonomy found, no need to display options |
| | 106 | case 1: |
| | 107 | $keys = array_keys( $taxonomies ); |
| | 108 | $taxonomy = reset( $keys ); |
| | 109 | printf( $input, esc_attr( $taxonomy ) ); |
| | 110 | break; |
| | 111 | |
| | 112 | // More than one tag cloud supporting taxonomy found, display options |
| | 113 | default: |
| | 114 | printf( |
| | 115 | '<p><label for="%1$s">%2$s</label>' . |
| | 116 | '<select class="widefat" id="%1$s" name="%3$s">', |
| | 117 | $id, |
| | 118 | __( 'Taxonomy:' ), |
| | 119 | $name |
| | 120 | ); |
| | 121 | |
| | 122 | foreach ( $taxonomies as $taxonomy => $tax ) { |
| | 123 | printf( |
| | 124 | '<option value="%s"%s>%s</option>', |
| | 125 | esc_attr( $taxonomy ), |
| | 126 | selected( $taxonomy, $current_taxonomy, false ), |
| | 127 | $tax->labels->name |
| | 128 | ); |
| | 129 | } |
| | 130 | |
| | 131 | echo '</select></p>'; |
| | 132 | } |