Ticket #45098: 45098.7.diff
| File 45098.7.diff, 5.2 KB (added by , 7 years ago) |
|---|
-
src/wp-admin/includes/schema.php
diff --git src/wp-admin/includes/schema.php src/wp-admin/includes/schema.php index b93fad35b4..ef4158c4dc 100644
function populate_roles() { 608 608 populate_roles_270(); 609 609 populate_roles_280(); 610 610 populate_roles_300(); 611 populate_roles_500(); 611 612 } 612 613 613 614 /** … … function populate_roles_300() { 848 849 } 849 850 } 850 851 852 /** 853 * Create and modify WordPress roles for WordPress 5.0. 854 * 855 * Assigns capabilities for reading and editing reusable blocks. Runs 856 * directly on the option to avoid updating the roles option 30+ times. 857 * 858 * @since 5.0.0 859 */ 860 function populate_roles_500() { 861 global $wp_user_roles, $wpdb; 862 863 if ( ! empty( $wp_user_roles ) ) { 864 // Roles and caps are not stored in the database. 865 return; 866 } 867 868 $site_id = get_current_blog_id(); 869 $role_key = $wpdb->get_blog_prefix( $site_id ) . 'user_roles'; 870 $roles_and_caps = get_option( $role_key, array() ); 871 872 $editor_caps = array( 873 'edit_blocks', 874 'edit_others_blocks', 875 'publish_blocks', 876 'read_private_blocks', 877 'read_blocks', 878 'delete_blocks', 879 'delete_private_blocks', 880 'delete_published_blocks', 881 'delete_others_blocks', 882 'edit_private_blocks', 883 'edit_published_blocks', 884 'create_blocks', 885 ); 886 887 $caps_map = array( 888 'administrator' => $editor_caps, 889 'editor' => $editor_caps, 890 'author' => array( 891 'edit_blocks', 892 'publish_blocks', 893 'read_blocks', 894 'delete_blocks', 895 'delete_published_blocks', 896 'edit_published_blocks', 897 'create_blocks', 898 ), 899 'contributor' => array( 900 'read_blocks', 901 ), 902 ); 903 904 foreach ( $caps_map as $role_name => $caps ) { 905 if ( ! isset( $roles_and_caps[ $role_name ] ) ) { 906 continue; 907 } 908 $role = $roles_and_caps[ $role_name ]; 909 910 if ( empty( $role ) ) { 911 continue; 912 } 913 914 /* 915 * Due to roles being created in the block editor feature plugin, 916 * the presence needs to be checked before adding the role. 917 */ 918 foreach ( $caps as $cap ) { 919 if ( isset( $role['capabilities'][ $cap ] ) ) { 920 continue; 921 } 922 $roles_and_caps[ $role_name ]['capabilities'][ $cap ] = true; 923 } 924 } 925 926 update_option( $role_key, $roles_and_caps ); 927 } 928 851 929 if ( !function_exists( 'install_network' ) ) : 852 930 /** 853 931 * Install Network. -
src/wp-admin/includes/upgrade.php
diff --git src/wp-admin/includes/upgrade.php src/wp-admin/includes/upgrade.php index f36d2d0c02..13c075b4c6 100644
function upgrade_all() { 628 628 if ( $wp_current_db_version < 37965 ) 629 629 upgrade_460(); 630 630 631 if ( $wp_current_db_version < 43 764 )631 if ( $wp_current_db_version < 43824 ) 632 632 upgrade_500(); 633 633 634 634 maybe_disable_link_manager(); … … function upgrade_500() { 1815 1815 } 1816 1816 deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true ); 1817 1817 } 1818 1819 if ( $wp_current_db_version < 43824 ) { 1820 populate_roles_500(); 1821 } 1818 1822 } 1819 1823 1820 1824 /** -
src/wp-includes/capabilities.php
diff --git src/wp-includes/capabilities.php src/wp-includes/capabilities.php index 38bb4c6c6d..748d02907c 100644
function map_meta_cap( $cap, $user_id ) { 555 555 return call_user_func_array( 'map_meta_cap', $args ); 556 556 } 557 557 558 // Block capabilities map to their post equivalent.559 $block_caps = array(560 'edit_blocks',561 'edit_others_blocks',562 'publish_blocks',563 'read_private_blocks',564 'delete_blocks',565 'delete_private_blocks',566 'delete_published_blocks',567 'delete_others_blocks',568 'edit_private_blocks',569 'edit_published_blocks',570 );571 if ( in_array( $cap, $block_caps, true ) ) {572 $cap = str_replace( '_blocks', '_posts', $cap );573 }574 575 558 // If no meta caps match, return the original cap. 576 559 $caps[] = $cap; 577 560 } -
src/wp-includes/post.php
diff --git src/wp-includes/post.php src/wp-includes/post.php index c9d1edbe67..03189b89e1 100644
function create_initial_post_types() { 261 261 'rest_controller_class' => 'WP_REST_Blocks_Controller', 262 262 'capability_type' => 'block', 263 263 'capabilities' => array( 264 // You need to be able to edit posts, in order to read blocks in their raw form. 265 'read' => 'edit_posts', 266 // You need to be able to publish posts, in order to create blocks. 267 'create_posts' => 'publish_posts', 268 'edit_published_posts' => 'edit_published_posts', 269 'delete_published_posts' => 'delete_published_posts', 270 'edit_others_posts' => 'edit_others_posts', 271 'delete_others_posts' => 'delete_others_posts', 264 'read' => 'read_blocks', 265 'create_posts' => 'create_blocks', 272 266 ), 273 267 'map_meta_cap' => true, 274 268 'supports' => array( … … function create_initial_post_types() { 278 272 ) 279 273 ); 280 274 281 282 275 register_post_status( 'publish', array( 283 276 'label' => _x( 'Published', 'post status' ), 284 277 'public' => true, -
src/wp-includes/version.php
diff --git src/wp-includes/version.php src/wp-includes/version.php index ab321dd33a..cee49296ce 100644
$wp_version = '5.0-beta2-43845-src'; 11 11 * 12 12 * @global int $wp_db_version 13 13 */ 14 $wp_db_version = 43 764;14 $wp_db_version = 43824; 15 15 16 16 /** 17 17 * Holds the TinyMCE version