diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index d269d351c8..2f3ba008b0 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -609,20 +609,20 @@ function wp_widget_text_register() { add_action('sidebar_admin_page', 'wp_widget_text_page'); } -function wp_widget_categories($args) { +function wp_widget_categories($args, $number = 1) { extract($args); $options = get_option('widget_categories'); - $c = $options['count'] ? '1' : '0'; - $h = $options['hierarchical'] ? '1' : '0'; - $d = $options['dropdown'] ? '1' : '0'; - $title = empty($options['title']) ? __('Categories') : $options['title']; + $c = $options[$number]['count'] ? '1' : '0'; + $h = $options[$number]['hierarchical'] ? '1' : '0'; + $d = $options[$number]['dropdown'] ? '1' : '0'; + $title = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title']; echo $before_widget; echo $before_title . $title . $after_title; $cat_args = "orderby=name&show_count={$c}&hierarchical={$h}"; - if($d) { + if ( $d ) { wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category')); ?> @@ -648,22 +648,29 @@ function wp_widget_categories($args) { echo $after_widget; } -function wp_widget_categories_control() { +function wp_widget_categories_control( $number ) { $options = $newoptions = get_option('widget_categories'); - if ( $_POST['categories-submit'] ) { - $newoptions['count'] = isset($_POST['categories-count']); - $newoptions['hierarchical'] = isset($_POST['categories-hierarchical']); - $newoptions['dropdown'] = isset($_POST['categories-dropdown']); - $newoptions['title'] = strip_tags(stripslashes($_POST['categories-title'])); + + if ( !is_array( $options ) ) { + $options = $newoptions = get_option( 'widget_categories' ); } + + if ( $_POST['categories-submit-' . $number] ) { + $newoptions[$number]['count'] = isset($_POST['categories-count-' . $number]); + $newoptions[$number]['hierarchical'] = isset($_POST['categories-hierarchical-' . $number]); + $newoptions[$number]['dropdown'] = isset($_POST['categories-dropdown-' . $number]); + $newoptions[$number]['title'] = strip_tags(stripslashes($_POST['categories-title-' . $number])); + } + if ( $options != $newoptions ) { $options = $newoptions; update_option('widget_categories', $options); } - $count = $options['count'] ? 'checked="checked"' : ''; - $hierarchical = $options['hierarchical'] ? 'checked="checked"' : ''; - $dropdown = $options['dropdown'] ? 'checked="checked"' : ''; - $title = attribute_escape($options['title']); + + $count = $options[$number]['count'] ? 'checked="checked"' : ''; + $hierarchical = $options[$number]['hierarchical'] ? 'checked="checked"' : ''; + $dropdown = $options[$number]['dropdown'] ? 'checked="checked"' : ''; + $title = attribute_escape($options[$number]['title']); ?>
@@ -673,6 +680,79 @@ function wp_widget_categories_control() { 9 ) { + $number = 9; + } elseif ( $number < 1 ) { + $number = 1; + } + + $newoptions['number'] = $number; + } + + if ( $newoptions != $options ) { + $options = $newoptions; + update_option( 'widget_categories', $options ); + wp_widget_categories_register( $options['number'] ); + } +} + +function wp_widget_categories_page() { + $options = get_option( 'widget_categories' ); +?> +