Last active
November 6, 2020 12:14
-
-
Save marsch/35fe626859726498ee43c80965e881d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Show WP author dropdown list | |
* | |
* @return array | |
*/ | |
static function user_list() { | |
global $cv_admin_users_list; | |
if ( !empty( $cv_admin_users_list ) ) { | |
$result = $cv_admin_users_list; | |
} else { | |
$result = array(); | |
$show = 'display_name'; | |
$args = array( | |
'role__in' => [ 'author' ], | |
'fields' => array( 'ID', $show, 'user_login' ), | |
'orderby' => 'display_name', | |
'order' => 'ASC', | |
); | |
$users = get_users( apply_filters( PT_CV_PREFIX_ . 'user_list', $args ) ); | |
foreach ( (array) $users as $user ) { | |
$user->ID = (int) $user->ID; | |
$display = !empty( $user->$show ) ? $user->$show : '(' . $user->user_login . ')'; | |
$result[ $user->ID ] = esc_html( $display ); | |
} | |
$cv_admin_users_list = $result; | |
} | |
return $result; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
key is line 17
just adding this