$widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract($widget_args, EXTR_SKIP); $options = get_option('widget_authors'); # if (!isset($options[$number])) # return; $title = empty($options[$number]['title']) ? __('Authors','authors') : apply_filters('widget_title', $options[$number]['title']); $feedlink = $options[$number]['feedlink'] ? '1' : '0'; $count = $options[$number]['count'] ? '1' : '0'; $exclude_admin = $options[$number]['exclude_admin'] ? '1' : '0'; ?> $widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract($widget_args, EXTR_SKIP); $options = get_option('widget_authors'); if ( !is_array( $options ) ) $options = array(); if ( !$updated && !empty($_POST['sidebar']) ) { $sidebar = (string) $_POST['sidebar']; $sidebars_widgets = wp_get_sidebars_widgets(); if ( isset($sidebars_widgets[$sidebar]) ) $this_sidebar =& $sidebars_widgets[$sidebar]; else $this_sidebar = array(); foreach ( (array) $this_sidebar as $_widget_id ) { if ( 'widget_authors' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; if ( !in_array( "authors-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. unset($options[$widget_number]); } } foreach ( (array) $_POST['widget-authors'] as $widget_number => $widget_authors ) { if ( !isset($widget_authors['title']) && isset($options[$widget_number]) ) // user clicked cancel continue; $title = trim(strip_tags(stripslashes($widget_authors['title']))); $feedlink = isset($widget_authors['feedlink']); $count = isset($widget_authors['count']); $exclude_admin = isset($widget_authors['exclude_admin']); $options[$widget_number] = compact( 'title', 'feedlink', 'count', 'exclude_admin' ); } update_option('widget_authors', $options); $updated = true; } if ( -1 == $number ) { $title = ''; $feedlink = false; $count = false; $exclude_admin = 0; $number = '%i%'; } else { $title = attribute_escape( $options[$number]['title'] ); $feedlink = (bool) $options[$number]['feedlink']; $count = (bool) $options[$number]['count']; $exclude_admin = (bool) $options[$number]['exclude_admin']; } ?>

$options ); update_option( 'widget_authors', $newoptions ); $sidebars_widgets = get_option( 'sidebars_widgets' ); if ( is_array( $sidebars_widgets ) ) { foreach ( $sidebars_widgets as $sidebar => $widgets ) { if ( is_array( $widgets ) ) { foreach ( $widgets as $widget ) $new_widgets[$sidebar][] = ( $widget == 'authors' ) ? 'authors-1' : $widget; } else { $new_widgets[$sidebar] = $widgets; } } if ( $new_widgets != $sidebars_widgets ) update_option( 'sidebars_widgets', $new_widgets ); } return $newoptions; } if ( !$options = get_option( 'widget_authors' ) ) $options = array(); if ( isset($options['title']) ) $options = widget_authors_upgrade(); $widget_ops = array( 'classname' => 'widget_authors', 'description' => __( 'A list of the authors','authors' ) ); $name = __( 'Authors','authors' ); $id = false; foreach ( (array) array_keys($options) as $o ) { // Old widgets can have null values for some reason if ( !isset($options[$o]['title']) ) continue; $id = "authors-$o"; wp_register_sidebar_widget( $id, $name, 'widget_authors', $widget_ops, array( 'number' => $o ) ); wp_register_widget_control( $id, $name, 'widget_authors_control', array( 'id_base' => 'authors' ), array( 'number' => $o ) ); } // If there are none, we register the widget's existance with a generic template if ( !$id ) { wp_register_sidebar_widget( 'authors-1', $name, 'widget_authors', $widget_ops, array( 'number' => -1 ) ); wp_register_widget_control( 'authors-1', $name, 'widget_authors_control', array( 'id_base' => 'authors' ), array( 'number' => -1 ) ); } /* if ( is_active_widget('widget_authors') ) add_action('wp_head', 'widget_authors_style'); */ endif; } add_action('init', 'widget_authors_register'); ?>