| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! class_exists( 'WP_Customize_Control' ) ) { |
| 4 |
return null; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Multiselect option for WP Customizer |
| 9 |
* |
| 10 |
* @param $wp_customize |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* Multiple select customize control class. |
| 15 |
*/ |
| 16 |
class Customize_Control_Multiple_Select extends WP_Customize_Control { |
| 17 |
|
| 18 |
/** |
| 19 |
* The type of customize control being rendered. |
| 20 |
*/ |
| 21 |
public $type = 'multiple-select'; |
| 22 |
|
| 23 |
/** |
| 24 |
* Displays the multiple select on the customize screen. |
| 25 |
*/ |
| 26 |
public function render_content() { |
| 27 |
|
| 28 |
if ( empty( $this->choices ) ) { |
| 29 |
return; |
| 30 |
} |
| 31 |
?> |
| 32 |
|
| 33 |
<label> |
| 34 |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
| 35 |
<span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> |
| 36 |
<select <?php $this->link(); ?> class="wp-bottom-menu-select2" multiple="multiple" style="width: 100%"> |
| 37 |
<?php |
| 38 |
foreach ( $this->choices as $value => $label ) { |
| 39 |
$selected = ( in_array( $this->value(), $this->choices ) ) ? selected( 1, 1, false ) : ''; |
| 40 |
echo '<option value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>'; |
| 41 |
} |
| 42 |
?> |
| 43 |
</select> |
| 44 |
</label> |
| 45 |
<?php |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
function wpbm_get_user_roles() { |
| 52 |
|
| 53 |
global $wp_roles; |
| 54 |
$roles = [ 'all' => esc_html__( 'All Visitors', 'wp-bottom-menu' ) ]; |
| 55 |
|
| 56 |
// check roles |
| 57 |
if ( ! isset( $wp_roles ) ){ |
| 58 |
$wp_roles = new WP_Roles(); |
| 59 |
} |
| 60 |
|
| 61 |
// add roles in array |
| 62 |
foreach( $wp_roles->get_names() as $key => $role ){ |
| 63 |
$roles[$key] = $role; |
| 64 |
} |
| 65 |
|
| 66 |
// return roles |
| 67 |
return $roles; |
| 68 |
|
| 69 |
} |