| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | 'base_id' => 'uwp_users', |
| 27 | 27 | 'name' => __('UWP > Users','userswp'), |
| 28 | 28 | 'widget_ops' => array( |
| 29 | 29 | 'classname' => 'uwp-users-class', |
| 30 | - 'description' => esc_html__('Displays users form.','userswp'), | |
| 30 | + 'description' => esc_html__('Displays users list.','userswp'), | |
| 31 | 31 | ), |
| 32 | 32 | 'arguments' => array( |
| 33 | 33 | 'title' => array( |
| 34 | 34 | 'title' => __( 'Widget title', 'userswp' ), |
| @@ -37,8 +37,18 @@ | ||
| 37 | 37 | 'desc_tip' => true, |
| 38 | 38 | 'default' => '', |
| 39 | 39 | 'advanced' => false |
| 40 | 40 | ), |
| 41 | + 'roles' => array( | |
| 42 | + 'title' => __('Roles:', 'userswp'), | |
| 43 | + 'desc' => __('Choose user roles to show in list. All users will display if no role selected.', 'userswp'), | |
| 44 | + 'type' => 'select', | |
| 45 | + 'options' => uwp_get_user_roles(), | |
| 46 | + 'desc_tip' => true, | |
| 47 | + 'default' => '', | |
| 48 | + 'advanced' => false, | |
| 49 | + 'multiple' => true | |
| 50 | + ) | |
| 41 | 51 | ) |
| 42 | 52 | |
| 43 | 53 | ); |
| 44 | 54 | |
| @@ -45,33 +55,46 @@ | ||
| 45 | 55 | |
| 46 | 56 | parent::__construct( $options ); |
| 47 | 57 | } |
| 48 | 58 | |
| 59 | + /** | |
| 60 | + * The Super block output function. | |
| 61 | + * | |
| 62 | + * @param array $args | |
| 63 | + * @param array $widget_args | |
| 64 | + * @param string $content | |
| 65 | + * | |
| 66 | + * @return string | |
| 67 | + */ | |
| 49 | 68 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 50 | 69 | |
| 51 | 70 | ob_start(); |
| 52 | 71 | |
| 53 | - echo '<div class="uwp_widgets uwp_widget_users">'; | |
| 72 | + if(isset($args['roles']) && !empty($args['roles'])){ | |
| 73 | + if(is_array($args['roles'])){ | |
| 74 | + $roles = implode(',', $args['roles']); | |
| 75 | + } else { | |
| 76 | + $roles = $args['roles']; | |
| 77 | + } | |
| 54 | 78 | |
| 55 | - $temp_obj = new UsersWP_Templates(); | |
| 79 | + $loop_shortcode = '[uwp_users_loop roles='.$roles.']'; | |
| 80 | + } else { | |
| 81 | + $loop_shortcode = '[uwp_users_loop]'; | |
| 82 | + } | |
| 56 | 83 | |
| 57 | - $template = $temp_obj->uwp_locate_template('users'); | |
| 84 | + $design_style = uwp_get_option("design_style",'bootstrap'); | |
| 58 | 85 | |
| 59 | 86 | echo '<div class="uwp_page">'; |
| 60 | 87 | |
| 61 | - if ($template) { | |
| 62 | - include($template); | |
| 88 | + if($design_style=='bootstrap'){ | |
| 89 | + echo do_shortcode("[uwp_users_loop_actions]\n".$loop_shortcode); | |
| 90 | + }else{ | |
| 91 | + echo do_shortcode("[uwp_users_search]\n[uwp_users_loop_actions]\n".$loop_shortcode); | |
| 63 | 92 | } |
| 64 | 93 | |
| 65 | 94 | echo '</div>'; |
| 66 | 95 | |
| 67 | - echo '</div>'; | |
| 68 | - | |
| 69 | - $output = ob_get_contents(); | |
| 70 | - | |
| 71 | - ob_end_clean(); | |
| 72 | - | |
| 73 | - return trim($output); | |
| 96 | + return ob_get_clean(); | |
| 74 | 97 | |
| 75 | 98 | } |
| 76 | 99 | |
| 77 | 100 | } |