mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Allow 'role' parameters to be passed to wp_dropdown_users().
`wp_dropdown_users()` contains a whitelist of function params that are passed through to `get_users()`. `role`, `role__in`, and `role__not_in` have now been added to this whitelist. Props sillybean. Fixes #38135. git-svn-id: https://develop.svn.wordpress.org/trunk@38651 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -110,4 +110,55 @@ class Tests_User_WpDropdownUsers extends WP_UnitTestCase {
|
||||
$user1 = get_userdata( $users[1] );
|
||||
$this->assertContains( $user1->user_login, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38135
|
||||
*/
|
||||
public function test_role() {
|
||||
$u1 = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) );
|
||||
$u2 = self::factory()->user->create_and_get( array( 'role' => 'author' ) );
|
||||
|
||||
$found = wp_dropdown_users( array(
|
||||
'echo' => false,
|
||||
'role' => 'author',
|
||||
'show' => 'user_login',
|
||||
) );
|
||||
|
||||
$this->assertNotContains( $u1->user_login, $found );
|
||||
$this->assertContains( $u2->user_login, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38135
|
||||
*/
|
||||
public function test_role__in() {
|
||||
$u1 = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) );
|
||||
$u2 = self::factory()->user->create_and_get( array( 'role' => 'author' ) );
|
||||
|
||||
$found = wp_dropdown_users( array(
|
||||
'echo' => false,
|
||||
'role__in' => array( 'author', 'editor' ),
|
||||
'show' => 'user_login',
|
||||
) );
|
||||
|
||||
$this->assertNotContains( $u1->user_login, $found );
|
||||
$this->assertContains( $u2->user_login, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38135
|
||||
*/
|
||||
public function test_role__not_in() {
|
||||
$u1 = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) );
|
||||
$u2 = self::factory()->user->create_and_get( array( 'role' => 'author' ) );
|
||||
|
||||
$found = wp_dropdown_users( array(
|
||||
'echo' => false,
|
||||
'role__not_in' => array( 'subscriber', 'editor' ),
|
||||
'show' => 'user_login',
|
||||
) );
|
||||
|
||||
$this->assertNotContains( $u1->user_login, $found );
|
||||
$this->assertContains( $u2->user_login, $found );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user