| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* UsersWP users widget. |
| 8 |
* |
| 9 |
* @since 1.0.22 |
| 10 |
*/ |
| 11 |
class UWP_Users_Widget extends WP_Super_Duper { |
| 12 |
|
| 13 |
/** |
| 14 |
* Register the users widget with WordPress. |
| 15 |
* |
| 16 |
*/ |
| 17 |
public function __construct() { |
| 18 |
|
| 19 |
|
| 20 |
$options = array( |
| 21 |
'textdomain' => 'userswp', |
| 22 |
'block-icon' => 'admin-site', |
| 23 |
'block-category'=> 'widgets', |
| 24 |
'block-keywords'=> "['userswp','users']", |
| 25 |
'class_name' => __CLASS__, |
| 26 |
'base_id' => 'uwp_users', |
| 27 |
'name' => __('UWP > Users','userswp'), |
| 28 |
'widget_ops' => array( |
| 29 |
'classname' => 'uwp-users-class', |
| 30 |
'description' => esc_html__('Displays users list.','userswp'), |
| 31 |
), |
| 32 |
'arguments' => array( |
| 33 |
'title' => array( |
| 34 |
'title' => __( 'Widget title', 'userswp' ), |
| 35 |
'desc' => __( 'Enter widget title.', 'userswp' ), |
| 36 |
'type' => 'text', |
| 37 |
'desc_tip' => true, |
| 38 |
'default' => '', |
| 39 |
'advanced' => false |
| 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 |
) |
| 51 |
) |
| 52 |
|
| 53 |
); |
| 54 |
|
| 55 |
|
| 56 |
parent::__construct( $options ); |
| 57 |
} |
| 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 |
*/ |
| 68 |
public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 69 |
|
| 70 |
ob_start(); |
| 71 |
|
| 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 |
} |
| 78 |
|
| 79 |
$loop_shortcode = '[uwp_users_loop roles='.$roles.']'; |
| 80 |
} else { |
| 81 |
$loop_shortcode = '[uwp_users_loop]'; |
| 82 |
} |
| 83 |
|
| 84 |
$design_style = uwp_get_option("design_style",'bootstrap'); |
| 85 |
|
| 86 |
echo '<div class="uwp_page">'; |
| 87 |
|
| 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); |
| 92 |
} |
| 93 |
|
| 94 |
echo '</div>'; |
| 95 |
|
| 96 |
return ob_get_clean(); |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
} |