diff --git src/wp-admin/includes/schema.php src/wp-admin/includes/schema.php
index b93fad35b4..3f7cf91bd8 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. |
| | 856 | * |
| | 857 | * @since 5.0.0 |
| | 858 | */ |
| | 859 | function populate_roles_500() { |
| | 860 | $editor_caps = array( |
| | 861 | 'edit_blocks', |
| | 862 | 'edit_others_blocks', |
| | 863 | 'publish_blocks', |
| | 864 | 'read_private_blocks', |
| | 865 | 'read_blocks', |
| | 866 | 'delete_blocks', |
| | 867 | 'delete_private_blocks', |
| | 868 | 'delete_published_blocks', |
| | 869 | 'delete_others_blocks', |
| | 870 | 'edit_private_blocks', |
| | 871 | 'edit_published_blocks', |
| | 872 | 'create_blocks', |
| | 873 | ); |
| | 874 | |
| | 875 | $caps_map = array( |
| | 876 | 'administrator' => $editor_caps, |
| | 877 | 'editor' => $editor_caps, |
| | 878 | 'author' => array( |
| | 879 | 'edit_blocks', |
| | 880 | 'publish_blocks', |
| | 881 | 'read_blocks', |
| | 882 | 'delete_blocks', |
| | 883 | 'delete_published_blocks', |
| | 884 | 'edit_published_blocks', |
| | 885 | 'create_blocks', |
| | 886 | ), |
| | 887 | 'contributor' => array( |
| | 888 | 'read_blocks', |
| | 889 | ), |
| | 890 | ); |
| | 891 | |
| | 892 | foreach ( $caps_map as $role_name => $caps ) { |
| | 893 | $role = get_role( $role_name ); |
| | 894 | |
| | 895 | if ( empty( $role ) ) { |
| | 896 | continue; |
| | 897 | } |
| | 898 | |
| | 899 | /* |
| | 900 | * Due to roles being created in the block editor feature plugin, |
| | 901 | * `$role->has_cap( $cap )` needs to run before adding the role. |
| | 902 | */ |
| | 903 | foreach ( $caps as $cap ) { |
| | 904 | if ( ! $role->has_cap( $cap ) ) { |
| | 905 | $role->add_cap( $cap ); |
| | 906 | } |
| | 907 | } |
| | 908 | } |
| | 909 | } |
| | 910 | |
| 851 | 911 | if ( !function_exists( 'install_network' ) ) : |
| 852 | 912 | /** |
| 853 | 913 | * Install Network. |
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 < 43764 ) |
| | 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 | /** |
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 | } |
diff --git src/wp-includes/post.php src/wp-includes/post.php
index 89b76184c3..86c58a4d83 100644
|
|
|
function create_initial_post_types() { |
| 243 | 243 | 'rest_controller_class' => 'WP_REST_Blocks_Controller', |
| 244 | 244 | 'capability_type' => 'block', |
| 245 | 245 | 'capabilities' => array( |
| 246 | | // You need to be able to edit posts, in order to read blocks in their raw form. |
| 247 | | 'read' => 'edit_posts', |
| 248 | | // You need to be able to publish posts, in order to create blocks. |
| 249 | | 'create_posts' => 'publish_posts', |
| 250 | | 'edit_published_posts' => 'edit_published_posts', |
| 251 | | 'delete_published_posts' => 'delete_published_posts', |
| 252 | | 'edit_others_posts' => 'edit_others_posts', |
| 253 | | 'delete_others_posts' => 'delete_others_posts', |
| | 246 | 'read' => 'read_blocks', |
| | 247 | 'create_posts' => 'create_blocks', |
| 254 | 248 | ), |
| 255 | 249 | 'map_meta_cap' => true, |
| 256 | 250 | 'supports' => array( |
| … |
… |
function create_initial_post_types() { |
| 260 | 254 | ) |
| 261 | 255 | ); |
| 262 | 256 | |
| 263 | | |
| 264 | 257 | register_post_status( 'publish', array( |
| 265 | 258 | 'label' => _x( 'Published', 'post status' ), |
| 266 | 259 | 'public' => true, |
diff --git src/wp-includes/version.php src/wp-includes/version.php
index 2bab60503f..f60251e436 100644
|
|
|
$wp_version = '5.0-beta1-43823-src'; |
| 11 | 11 | * |
| 12 | 12 | * @global int $wp_db_version |
| 13 | 13 | */ |
| 14 | | $wp_db_version = 43764; |
| | 14 | $wp_db_version = 43824; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Holds the TinyMCE version |