Ticket #40922: 40922.7.diff
File 40922.7.diff, 3.8 KB (added by , 7 years ago) |
---|
-
src/wp-includes/capabilities.php
440 440 else 441 441 $caps[] = 'do_not_allow'; 442 442 break; 443 case 'customize' :444 $caps[] = 'edit_theme_options';445 break;446 443 case 'delete_site': 447 444 if ( is_multisite() ) { 448 445 $caps[] = 'manage_options'; … … 862 859 863 860 return $allcaps; 864 861 } 862 863 /** 864 * Filters the user capabilities to grant the 'customize' capability as necessary. 865 * 866 * A user must have the 'edit_theme_options' capability for it to be granted. 867 * 868 * @since 4.9.0 869 * 870 * @param array $allcaps An array of all the user's capabilities. 871 * @return array Filtered array of the user's capabilities. 872 */ 873 function wp_maybe_grant_customize_cap( $allcaps ) { 874 if ( ! empty( $allcaps['edit_theme_options'] ) ) { 875 $allcaps['customize'] = true; 876 } 877 878 return $allcaps; 879 } 880 881 /** 882 * Filters the user capabilities to grant customize changeset capabilities as necessary. 883 * 884 * The capabilities are granted based on whether the user can 'customize'. 885 * 886 * @since 4.9.0 887 * 888 * @param array $allcaps An array of all the user's capabilities. 889 * @return array Filtered array of the user's capabilities. 890 */ 891 function wp_maybe_grant_customize_changesets_caps( $allcaps ) { 892 if ( ! empty( $allcaps['customize'] ) ) { 893 $post_type = get_post_type_object( 'customize_changeset' ); 894 foreach ( get_object_vars( $post_type->cap ) as $post_cap => $changeset_cap ) { 895 if ( '_posts' === substr( $post_cap, -6 ) ) { 896 $allcaps[ $changeset_cap ] = true; 897 } 898 } 899 } 900 901 return $allcaps; 902 } -
src/wp-includes/default-filters.php
514 514 515 515 // Capabilities 516 516 add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 ); 517 add_filter( 'user_has_cap', 'wp_maybe_grant_customize_cap', 1 ); 518 add_filter( 'user_has_cap', 'wp_maybe_grant_customize_changesets_caps', 10 ); 517 519 518 520 unset( $filter, $action ); -
src/wp-includes/post.php
176 176 'delete_with_user' => false, 177 177 'supports' => array( 'title', 'author' ), 178 178 'capability_type' => 'customize_changeset', 179 'capabilities' => array(180 'create_posts' => 'customize',181 'delete_others_posts' => 'customize',182 'delete_post' => 'customize',183 'delete_posts' => 'customize',184 'delete_private_posts' => 'customize',185 'delete_published_posts' => 'customize',186 'edit_others_posts' => 'customize',187 'edit_post' => 'customize',188 'edit_posts' => 'customize',189 'edit_private_posts' => 'customize',190 'edit_published_posts' => 'do_not_allow',191 'publish_posts' => 'customize',192 'read' => 'read',193 'read_post' => 'customize',194 'read_private_posts' => 'customize',195 ),196 179 ) ); 197 180 198 181 register_post_status( 'publish', array( … … 2964 2947 * @type string $guid Global Unique ID for referencing the post. Default empty. 2965 2948 * @type array $post_category Array of category names, slugs, or IDs. 2966 2949 * Defaults to value of the 'default_category' option. 2967 * @type array $tags_input Array of tag names, slugs, or IDs. Default empty. 2950 * @type array $tags_input Array of tag names, slugs, or IDs. Default empty. 2968 2951 * @type array $tax_input Array of taxonomy terms keyed by their taxonomy name. Default empty. 2969 2952 * @type array $meta_input Array of post meta values keyed by their post meta key. Default empty. 2970 2953 * }