Changeset 51943
- Timestamp:
- 10/27/2021 06:42:13 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-posts-list-table.php
r51737 r51943 1661 1661 $users_opt = array( 1662 1662 'hide_if_only_one_author' => false, 1663 ' who' => 'authors',1663 ', 1664 1664 'name' => 'post_author', 1665 1665 'class' => 'authors', -
trunk/src/wp-admin/includes/meta-boxes.php
r51837 r51943 904 904 function post_author_meta_box( $post ) { 905 905 global $user_ID; 906 907 906 908 ?> 907 909 <label class="screen-reader-text" for="post_author_override"><?php _e( 'Author' ); ?></label> … … 909 911 wp_dropdown_users( 910 912 array( 911 ' who' => 'authors',913 ', 912 914 'name' => 'post_author_override', 913 915 'selected' => empty( $post->ID ) ? $user_ID : $post->post_author, -
trunk/src/wp-content/themes/twentyfourteen/functions.php
r51045 r51943 492 492 */ 493 493 function twentyfourteen_list_authors() { 494 $contributor_ids = get_users( 495 array( 496 'fields' => 'ID', 497 'orderby' => 'post_count', 498 'order' => 'DESC', 499 'who' => 'authors', 500 ) 501 ); 494 $args = array( 495 'fields' => 'ID', 496 'orderby' => 'post_count', 497 'order' => 'DESC', 498 'capability' => array( 'edit_posts' ), 499 ); 500 501 /** 502 * Filters query arguments for listing authors. 503 * 504 * @since 3.3 505 * 506 * @param array $args Query arguments. 507 */ 508 $args = apply_filters( 'twentyfourteen_list_authors_query_args', $args ); 509 510 $contributor_ids = get_users( $args ); 502 511 503 512 foreach ( $contributor_ids as $contributor_id ) : -
trunk/src/wp-includes/class-wp-user-query.php
r49946 r51943 94 94 'role__in' => array(), 95 95 'role__not_in' => array(), 96 97 98 96 99 'meta_key' => '', 97 100 'meta_value' => '', … … 134 137 * @since 4.7.0 Added 'nicename', 'nicename__in', 'nicename__not_in', 'login', 'login__in', 135 138 * and 'login__not_in' parameters. 139 136 140 * 137 141 * @global wpdb $wpdb WordPress database abstraction object. … … 149 153 * @type string[] $role__not_in An array of role names to exclude. Users matching one or more of these 150 154 * roles will not be included in results. Default empty array. 155 156 157 158 159 160 161 162 163 164 165 166 167 151 168 * @type string $meta_key User meta key. Default empty. 152 169 * @type string $meta_value User meta value. Default empty. … … 321 338 322 339 if ( isset( $qv['who'] ) && 'authors' === $qv['who'] && $blog_id ) { 340 341 342 343 344 345 346 347 348 349 350 323 351 $who_query = array( 324 352 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level', … … 344 372 } 345 373 374 346 375 $roles = array(); 347 376 if ( isset( $qv['role'] ) ) { … … 361 390 if ( isset( $qv['role__not_in'] ) ) { 362 391 $role__not_in = (array) $qv['role__not_in']; 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 363 497 } 364 498 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r51786 r51943 199 199 } 200 200 201 202 203 204 205 206 207 208 209 201 210 if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) { 202 211 return new WP_Error( … … 255 264 */ 256 265 $parameter_mappings = array( 257 'exclude' => 'exclude', 258 'include' => 'include', 259 'order' => 'order', 260 'per_page' => 'number', 261 'search' => 'search', 262 'roles' => 'role__in', 263 'slug' => 'nicename__in', 266 'exclude' => 'exclude', 267 'include' => 'include', 268 'order' => 'order', 269 'per_page' => 'number', 270 'search' => 'search', 271 'roles' => 'role__in', 272 'capabilities' => 'capability__in', 273 'slug' => 'nicename__in', 264 274 ); 265 275 … … 1555 1565 ); 1556 1566 1567 1568 1569 1570 1571 1572 1573 1574 1557 1575 $query_params['who'] = array( 1558 1576 'description' => __( 'Limit result set to users who are considered authors.' ), -
trunk/src/wp-includes/user.php
r51738 r51943 1321 1321 'role__in' => array(), 1322 1322 'role__not_in' => array(), 1323 1324 1325 1323 1326 ); 1324 1327 … … 1327 1330 $parsed_args = wp_parse_args( $args, $defaults ); 1328 1331 1329 $query_args = wp_array_slice_assoc( $parsed_args, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who', 'role', 'role__in', 'role__not_in' ) ); 1332 $query_args = wp_array_slice_assoc( 1333 $parsed_args, 1334 array( 1335 'blog_id', 1336 'include', 1337 'exclude', 1338 'orderby', 1339 'order', 1340 'who', 1341 'role', 1342 'role__in', 1343 'role__not_in', 1344 'capability', 1345 'capability__in', 1346 'capability__not_in', 1347 ) 1348 ); 1330 1349 1331 1350 $fields = array( 'ID', 'user_login' ); -
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r51568 r51943 16 16 protected static $draft_editor; 17 17 protected static $subscriber; 18 18 19 19 20 protected static $authors = array(); … … 54 55 'display_name' => 'subscriber', 55 56 'user_email' => 'subscriber@example.com', 57 58 59 60 61 62 63 56 64 ) 57 65 ); … … 108 116 109 117 // Set up users for pagination tests. 110 for ( $i = 0; $i < self::$total_users - 1 0; $i++ ) {118 for ( $i = 0; $i < self::$total_users - 1; $i++ ) { 111 119 self::$user_ids[] = $factory->user->create( 112 120 array( … … 122 130 self::delete_user( self::$editor ); 123 131 self::delete_user( self::$draft_editor ); 132 124 133 125 134 foreach ( self::$posts as $post ) { … … 184 193 $data = $response->get_data(); 185 194 $keys = array_keys( $data['endpoints'][0]['args'] ); 186 sort( $keys ); 187 $this->assertSame( 195 $this->assertEqualSets( 188 196 array( 189 197 'context', … … 196 204 'per_page', 197 205 'roles', 206 198 207 'search', 199 208 'slug', … … 796 805 wp_set_current_user( self::$user ); 797 806 798 $tango = $this->factory->user->create(799 array(800 'display_name' => 'tango',801 'role' => 'subscriber',802 )803 );804 $yolo = $this->factory->user->create(805 array(806 'display_name' => 'yolo',807 'role' => 'author',808 )809 );810 811 807 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 812 808 $request->set_param( 'roles', 'author,subscriber' ); 813 809 $response = rest_get_server()->dispatch( $request ); 814 810 $data = $response->get_data(); 815 $this->assertCount( 3, $data );816 $this->assertSame( $tango, $data[1]['id'] );817 $this->assertSame( $yolo, $data[2]['id'] );811 $this->assertCount( , $data ); 812 $this->assertSame( ]['id'] ); 813 $this->assertSame( ]['id'] ); 818 814 819 815 $request->set_param( 'roles', 'author' ); … … 821 817 $data = $response->get_data(); 822 818 $this->assertCount( 1, $data ); 823 $this->assertSame( $yolo, $data[0]['id'] );819 $this->assertSame( , $data[0]['id'] ); 824 820 825 821 wp_set_current_user( 0 ); … … 839 835 wp_set_current_user( self::$user ); 840 836 841 $lolz = $this->factory->user->create(842 array(843 'display_name' => 'lolz',844 'role' => 'author',845 )846 );847 848 837 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 849 838 $request->set_param( 'roles', 'ilovesteak,author' ); … … 851 840 $data = $response->get_data(); 852 841 $this->assertCount( 1, $data ); 853 $this->assertSame( $lolz, $data[0]['id'] );842 $this->assertSame( , $data[0]['id'] ); 854 843 855 844 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 857 846 $response = rest_get_server()->dispatch( $request ); 858 847 $data = $response->get_data(); 859 $this->assertCount( 0, $data ); 860 $this->assertSame( array(), $data ); 861 } 862 848 $this->assertIsArray( $data ); 849 $this->assertEmpty( $data ); 850 } 851 852 /** 853 * @ticket 16841 854 */ 855 public function test_get_items_capabilities() { 856 wp_set_current_user( self::$user ); 857 858 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 859 $request->set_param( 'capabilities', 'edit_posts' ); 860 $response = rest_get_server()->dispatch( $request ); 861 $data = $response->get_data(); 862 863 $this->assertNotEmpty( $data ); 864 foreach ( $data as $user ) { 865 $this->assertTrue( user_can( $user['id'], 'edit_posts' ) ); 866 } 867 } 868 869 /** 870 * @ticket 16841 871 */ 872 public function test_get_items_capabilities_no_permission_no_user() { 873 wp_set_current_user( 0 ); 874 875 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 876 $request->set_param( 'capabilities', 'edit_posts' ); 877 $response = rest_get_server()->dispatch( $request ); 878 $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 ); 879 } 880 881 /** 882 * @ticket 16841 883 */ 884 public function test_get_items_capabilities_no_permission_editor() { 885 wp_set_current_user( self::$editor ); 886 887 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 888 $request->set_param( 'capabilities', 'edit_posts' ); 889 $response = rest_get_server()->dispatch( $request ); 890 $this->assertErrorResponse( 'rest_user_cannot_view', $response, 403 ); 891 } 892 893 /** 894 * @ticket 16841 895 */ 896 public function test_get_items_invalid_capabilities() { 897 wp_set_current_user( self::$user ); 898 899 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 900 $request->set_param( 'roles', 'ilovesteak,author' ); 901 $response = rest_get_server()->dispatch( $request ); 902 $data = $response->get_data(); 903 $this->assertCount( 1, $data ); 904 $this->assertSame( self::$author, $data[0]['id'] ); 905 906 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 907 $request->set_param( 'capabilities', 'steakisgood' ); 908 $response = rest_get_server()->dispatch( $request ); 909 $data = $response->get_data(); 910 $this->assertIsArray( $data ); 911 $this->assertEmpty( $data ); 912 } 913 914 /** 915 * @expectedDeprecated WP_User_Query 916 */ 863 917 public function test_get_items_who_author_query() { 864 918 wp_set_current_user( self::$superadmin ); -
trunk/tests/phpunit/tests/user/query.php
r51462 r51943 731 731 * @ticket 32019 732 732 * @group ms-required 733 733 734 */ 734 735 public function test_who_authors() { … … 756 757 * @ticket 32019 757 758 * @group ms-required 759 758 760 */ 759 761 public function test_who_authors_should_work_alongside_meta_query() { … … 790 792 * @ticket 36724 791 793 * @group ms-required 794 792 795 */ 793 796 public function test_who_authors_should_work_alongside_meta_params() { … … 1726 1729 return array( 555 ); 1727 1730 } 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1728 1969 } -
trunk/tests/phpunit/tests/xmlrpc/wp/getUsers.php
r51367 r51943 55 55 } 56 56 57 58 59 57 60 function test_role_filter() { 58 61 $author_id = $this->make_user_by_role( 'author' ); -
trunk/tests/qunit/fixtures/wp-api-generated.js
r51463 r51943 5358 5358 "required": false 5359 5359 }, 5360 5361 5362 5363 5364 5365 5366 5367 5360 5368 "who": { 5361 5369 "description": "Limit result set to users who are considered authors.",
Note: See TracChangeset
for help on using the changeset viewer.