/** * Echo widget content = list of blog users. */ function widget($args, $instance) { require_once 'UserList.class.php'; // parse hidden users string if (!empty($instance['hiddenusers'])) { $hiddenusers = explode(',', $instance['hiddenusers']); $hiddenusers = array_map('trim', $hiddenusers); } else { $hiddenusers = array(); } $userlist = new UserList(); $userlist->roles = $instance['roles']; $userlist->blogs = $instance['blogs']; $userlist->group_by = $instance['group_by']; $userlist->hiddenusers = $hiddenusers; if (is_array($instance['display'])) { $userlist->show_name = in_array('show_name', $instance['display']); $userlist->show_postcount = in_array('show_postcount', $instance['display']); $userlist->show_bbpress_post_count = in_array('show_bbpress_post_count', $instance['display']); $userlist->show_biography = in_array('show_biography', $instance['display']); $userlist->user_link = $instance['display']['user_link']; $userlist->avatar_size = $instance['display']['avatar_size']; $userlist->limit = $instance['display']['limit']; $userlist->min_post_count = $instance['display']['min_post_count']; $userlist->order = $instance['display']['order']; $userlist->sort_direction = $instance['display']['sort_direction']; } // extract widget arguments extract($args, EXTR_SKIP); // add the standard title filter $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); // build the widget html echo $before_widget; echo $before_title . $title . $after_title; $userlist->output(); echo $after_widget; }
/** * Echo widget content = list of blog users. */ function widget($args, $instance) { require_once 'UserList.class.php'; // parse hidden users string if (!empty($instance['hiddenusers'])) { $hiddenusers = explode(',', $instance['hiddenusers']); $hiddenusers = array_map('trim', $hiddenusers); } else { $hiddenusers = array(); } $userlist = new UserList(); $userlist->roles = $instance['roles']; $userlist->blogs = $instance['blogs']; $userlist->group_by = $instance['group_by']; $userlist->hiddenusers = $hiddenusers; if (is_array($instance['display'])) { // $userlist->show_name = in_array( 'show_name', $instance['display'] ); // $userlist->show_email = in_array( 'show_email', $instance['display'] ); // $userlist->show_postcount = in_array( 'show_postcount', $instance['display'] ); // $userlist->show_bbpress_post_count = in_array( 'show_bbpress_post_count', $instance['display'] ); // $userlist->show_biography = in_array( 'show_biography', $instance['display'] ); // $userlist->show_last_post = in_array( 'show_last_post', $instance['display'] ); // todo: add array_kay_exsists $userlist->user_link = array_key_exists('user_link', $instance['display']) ? $instance['display']['user_link'] : false; unset($instance['display']['user_link']); $userlist->avatar_size = array_key_exists('avatar_size', $instance['display']) ? $instance['display']['avatar_size'] : false; unset($instance['display']['avatar_size']); $userlist->limit = array_key_exists('limit', $instance['display']) ? $instance['display']['limit'] : false; unset($instance['display']['limit']); $userlist->min_post_count = array_key_exists('min_post_count', $instance['display']) ? $instance['display']['min_post_count'] : false; unset($instance['display']['min_post_count']); $userlist->order = array_key_exists('order', $instance['display']) ? $instance['display']['order'] : false; unset($instance['display']['order']); $userlist->sort_direction = array_key_exists('sort_direction', $instance['display']) ? $instance['display']['sort_direction'] : false; unset($instance['display']['sort_direction']); $userlist->bio_length = array_key_exists('bio_length', $instance['display']) ? $instance['display']['bio_length'] : false; unset($instance['display']['bio_length']); } $display_config_values = array('user_link', 'avatar_size', 'limit', 'min_post_count', 'order', 'sort_direction'); if (is_array($instance['display'])) { $instance['display'] = apply_filters('aa_widget_display_list', $instance['display']); $display = array(); if (!empty($instance['display'])) { if (!is_array($instance['display'])) { $display = explode(',', $instance['display']); } else { $display = $instance['display']; } } $default_display_options = array('show_name', 'show_email', 'show_biography', 'show_postcount', 'show_last_post', 'show_bbpress_post_count'); // loop the old name=true settings and add them to the new array format foreach ($default_display_options as $default_display_option) { if (isset($instance['display'][$default_display_option]) && strlen($instance['display'][$default_display_option]) > 0) { if (true == $instance['display'][$default_display_option] && !in_array($default_display_option, $display)) { $display[] = $default_display_option; } } } // the defaults array and set the globals if found foreach ($default_display_options as $default_display_option) { if (in_array($default_display_option, $display)) { $userlist->{$default_display_option} = true; } else { $userlist->{$default_display_option} = false; } } $userlist->display_extra = array_diff($display, $default_display_options); } //var_dump($userlist->display_extra); // extract widget arguments extract($args, EXTR_SKIP); // add the standard title filter $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); // build the widget html echo $before_widget; echo $before_title . $title . $after_title; $userlist->output(); echo $after_widget; }