Make WordPress Core

Changeset 6040


Ignore:
Timestamp:
09/05/2007 09:50:52 PM (19 years ago)
Author:
ryan
Message:

Basic tag cloud widget. Props Stargazer. fixes #4130

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/widgets.php

    r6026 r6040  
    10751075}
    10761076
     1077function wp_widget_tag_cloud($args) {
     1078        extract($args);
     1079        $options = get_option('widget_tag_cloud');
     1080        $title = empty($options['title']) ? __('Tags') : $options['title'];
     1081
     1082        echo $before_widget;
     1083        echo $before_title . $title . $after_title;
     1084        wp_tag_cloud();
     1085        echo $after_widget;
     1086}
     1087
     1088function wp_widget_tag_cloud_control() {
     1089        $options = $newoptions = get_option('widget_tag_cloud');
     1090
     1091        if ( $_POST['tag-cloud-submit'] ) {
     1092                $newoptions['title'] = strip_tags(stripslashes($_POST['tag-cloud-title']));
     1093        }
     1094
     1095        if ( $options != $newoptions ) {
     1096                $options = $newoptions;
     1097                update_option('widget_tag_cloud', $options);
     1098        }
     1099
     1100        $title = attribute_escape( $options['title'] );
     1101?>
     1102        <p><label for="tag-cloud-title">
     1103        <?php _e('Title:') ?> <input type="text" style="width:300px" id="tag-cloud-title" name="tag-cloud-title" value="<?php echo $title ?>" /></label>
     1104        </p>
     1105        <input type="hidden" name="tag-cloud-submit" id="tag-cloud-submit" value="1" />
     1106<?php
     1107}
     1108
    10771109function wp_widgets_init() {
    10781110        if ( !is_blog_installed() )
    … …  
    11101142        wp_register_sidebar_widget('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries', $class);
    11111143        wp_register_widget_control('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries_control', $dims90);
     1144
     1145        $class['classname'] = 'widget_tag_cloud';
     1146        wp_register_sidebar_widget('tag_cloud', __('Tag Cloud'), 'wp_widget_tag_cloud', $class);
     1147        wp_register_widget_control('tag_cloud', __('Tag Cloud'), 'wp_widget_tag_cloud_control', 'width=300&height=160');
    11121148
    11131149        wp_widget_categories_register();
Note: See TracChangeset for help on using the changeset viewer.