Basic tag cloud widget. Props Stargazer. fixes #4130

git-svn-id: http://svn.automattic.com/wordpress/trunk@6040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-09-05 21:50:52 +00:00
parent 98a92950a3
commit c5d33cbebd
1 changed files with 36 additions and 0 deletions

View File

@ -1074,6 +1074,38 @@ function wp_widget_rss_register() {
add_action('sidebar_admin_page', 'wp_widget_rss_page');
}
function wp_widget_tag_cloud($args) {
extract($args);
$options = get_option('widget_tag_cloud');
$title = empty($options['title']) ? __('Tags') : $options['title'];
echo $before_widget;
echo $before_title . $title . $after_title;
wp_tag_cloud();
echo $after_widget;
}
function wp_widget_tag_cloud_control() {
$options = $newoptions = get_option('widget_tag_cloud');
if ( $_POST['tag-cloud-submit'] ) {
$newoptions['title'] = strip_tags(stripslashes($_POST['tag-cloud-title']));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_tag_cloud', $options);
}
$title = attribute_escape( $options['title'] );
?>
<p><label for="tag-cloud-title">
<?php _e('Title:') ?> <input type="text" style="width:300px" id="tag-cloud-title" name="tag-cloud-title" value="<?php echo $title ?>" /></label>
</p>
<input type="hidden" name="tag-cloud-submit" id="tag-cloud-submit" value="1" />
<?php
}
function wp_widgets_init() {
if ( !is_blog_installed() )
return;
@ -1110,6 +1142,10 @@ function wp_widgets_init() {
wp_register_sidebar_widget('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries', $class);
wp_register_widget_control('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries_control', $dims90);
$class['classname'] = 'widget_tag_cloud';
wp_register_sidebar_widget('tag_cloud', __('Tag Cloud'), 'wp_widget_tag_cloud', $class);
wp_register_widget_control('tag_cloud', __('Tag Cloud'), 'wp_widget_tag_cloud_control', 'width=300&height=160');
wp_widget_categories_register();
wp_widget_text_register();
wp_widget_rss_register();