prefix = framework_get_prefix(); /* Set up the widget options. */ $widget_options = array( 'classname' => 'authors', 'description' => esc_html__( 'A list of your site\'s authors.', 'wordsmith' ) ); /* Set up the widget control options. */ $control_options = array( 'width' => 200, 'height' => 350 ); /* Create the widget. */ $this->WP_Widget( "{$this->prefix}-authors", __( 'Authors', 'wordsmith' ), $widget_options, $control_options ); } /* Outputs the widget based on the arguments input through the widget controls. */ function widget( $args, $instance ) { extract( $args ); /* Set the $args for wp_list_authors() to the $instance array. */ $args = $instance; /* Overwrite the $echo argument and set it to false. */ $args['echo'] = false; /* Output the theme's $before_widget wrapper. */ echo $before_widget; /* If a title was input by the user, display it. */ if ( !empty( $instance['title'] ) ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; /* Get the authors list. */ $authors = str_replace( array( '\r', '\n', '\t' ), '', wp_list_authors( $args ) ); $authors = str_replace( '(', '', $authors ); $authors = str_replace( ')', '', $authors ); echo '
'; /* Close the theme's widget wrapper. */ echo $after_widget; } /* Updates the widget control options for the particular instance of the widget. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance = $new_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['order'] = strip_tags( $new_instance['order'] ); $instance['orderby'] = strip_tags( $new_instance['orderby'] ); $instance['number'] = strip_tags( $new_instance['number'] ); $instance['html'] = ( isset( $new_instance['html'] ) ? 1 : 0 ); $instance['optioncount'] = ( isset( $new_instance['optioncount'] ) ? 1 : 0 ); $instance['show_fullname'] = ( isset( $new_instance['show_fullname'] ) ? 1 : 0 ); $instance['hide_empty'] = ( isset( $new_instance['hide_empty'] ) ? 1 : 0 ); return $instance; } /* Displays the widget control options in the Widgets admin screen. */ function form( $instance ) { /* Set up the default form values. */ $defaults = array( 'title' => esc_attr__( 'Authors', 'wordsmith' ), 'hide_empty' => true, 'html' => true, 'number' => '', 'optioncount' => true, 'order' => 'ASC', 'orderby' => 'display_name', 'show_fullname' => true ); /* Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args( (array) $instance, $defaults ); $order = array( 'ASC' => esc_attr__( 'Ascending', 'wordsmith' ), 'DESC' => esc_attr__( 'Descending', 'wordsmith' ) ); $orderby = array( 'display_name' => esc_attr__( 'Display Name', 'wordsmith' ), 'email' => esc_attr__( 'Email', 'wordsmith' ), 'ID' => esc_attr__( 'ID', 'wordsmith' ), 'nicename' => esc_attr__( 'Nice Name', 'wordsmith' ), 'post_count' => esc_attr__( 'Post Count', 'wordsmith' ), 'registered' => esc_attr__( 'Registered', 'wordsmith' ), 'url' => esc_attr__( 'URL', 'wordsmith' ), 'user_login' => esc_attr__( 'Login', 'wordsmith' ) ); ?>