Changeset 38651
- Timestamp:
- 09/25/2016 05:44:24 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r38457 r38651 965 965 * @since 2.3.0 966 966 * @since 4.5.0 Added the 'display_name_with_login' value for 'show'. 967 * @since 4.7.0 Added the `$role`, `$role__in`, and `$role__not_in` parameters. 967 968 * 968 969 * @param array|string $args { … … 1005 1006 * @type string $who Which type of users to query. Accepts only an empty string or 1006 1007 * 'authors'. Default empty. 1008 * @type string|array $role An array or a comma-separated list of role names that users must 1009 * match to be included in results. Note that this is an inclusive 1010 * list: users must match *each* role. Default empty. 1011 * @type array $role__in An array of role names. Matched users must have at least one of 1012 * these roles. Default empty array. 1013 * @type array $role__not_in An array of role names to exclude. Users matching one or more of 1014 * these roles will not be included in results. Default empty array. 1007 1015 * } 1008 1016 * @return string String of HTML content. … … 1016 1024 'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '', 1017 1025 'blog_id' => get_current_blog_id(), 'who' => '', 'include_selected' => false, 1018 'option_none_value' => -1 1026 'option_none_value' => -1, 1027 'role' => '', 1028 'role__in' => array(), 1029 'role__not_in' => array(), 1019 1030 ); 1020 1031 … … 1023 1034 $r = wp_parse_args( $args, $defaults ); 1024 1035 1025 $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );1036 $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who', 'role', 'role__in', 'role__not_in' ) ); 1026 1037 1027 1038 $fields = array( 'ID', 'user_login' ); -
trunk/tests/phpunit/tests/user/wpDropdownUsers.php
r35790 r38651 111 111 $this->assertContains( $user1->user_login, $found ); 112 112 } 113 114 /** 115 * @ticket 38135 116 */ 117 public function test_role() { 118 $u1 = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ); 119 $u2 = self::factory()->user->create_and_get( array( 'role' => 'author' ) ); 120 121 $found = wp_dropdown_users( array( 122 'echo' => false, 123 'role' => 'author', 124 'show' => 'user_login', 125 ) ); 126 127 $this->assertNotContains( $u1->user_login, $found ); 128 $this->assertContains( $u2->user_login, $found ); 129 } 130 131 /** 132 * @ticket 38135 133 */ 134 public function test_role__in() { 135 $u1 = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ); 136 $u2 = self::factory()->user->create_and_get( array( 'role' => 'author' ) ); 137 138 $found = wp_dropdown_users( array( 139 'echo' => false, 140 'role__in' => array( 'author', 'editor' ), 141 'show' => 'user_login', 142 ) ); 143 144 $this->assertNotContains( $u1->user_login, $found ); 145 $this->assertContains( $u2->user_login, $found ); 146 } 147 148 /** 149 * @ticket 38135 150 */ 151 public function test_role__not_in() { 152 $u1 = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ); 153 $u2 = self::factory()->user->create_and_get( array( 'role' => 'author' ) ); 154 155 $found = wp_dropdown_users( array( 156 'echo' => false, 157 'role__not_in' => array( 'subscriber', 'editor' ), 158 'show' => 'user_login', 159 ) ); 160 161 $this->assertNotContains( $u1->user_login, $found ); 162 $this->assertContains( $u2->user_login, $found ); 163 } 113 164 }
Note: See TracChangeset
for help on using the changeset viewer.