Make WordPress Core

Ticket #40922: 40922.6.diff

File 40922.6.diff, 3.1 KB (added by flixos90, 7 years ago)
  • src/wp-includes/capabilities.php

     
    862862
    863863        return $allcaps;
    864864}
     865
     866/**
     867 * Filters the user capabilities to grant customize changeset capabilities as necessary.
     868 *
     869 * The capabilities are granted based on whether the user can 'edit_theme_options'.
     870 *
     871 * @since 4.9.0
     872 *
     873 * @param array $allcaps An array of all the user's capabilities.
     874 * @return array Filtered array of the user's capabilities.
     875 */
     876function wp_maybe_grant_customize_changesets_capabilities( $allcaps ) {
     877        if ( ! empty( $allcaps['edit_theme_options'] ) ) {
     878                $post_type = get_post_type_object( 'customize_changeset' );
     879                foreach ( get_object_vars( $post_type->cap ) as $post_cap => $changeset_cap ) {
     880                        if ( '_posts' === substr( $post_cap, -6 ) ) {
     881                                $allcaps[ $changeset_cap ] = true;
     882                        }
     883                }
     884        }
     885
     886        return $allcaps;
     887}
  • src/wp-includes/default-filters.php

     
    514514
    515515// Capabilities
    516516add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 );
     517add_filter( 'user_has_cap', 'wp_maybe_grant_customize_changesets_capabilities', 1 );
    517518
    518519unset( $filter, $action );
  • src/wp-includes/post.php

     
    176176                'delete_with_user' => false,
    177177                'supports' => array( 'title', 'author' ),
    178178                '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                 ),
    196179        ) );
    197180
    198181        register_post_status( 'publish', array(
     
    29642947 *     @type string $guid                  Global Unique ID for referencing the post. Default empty.
    29652948 *     @type array  $post_category         Array of category names, slugs, or IDs.
    29662949 *                                         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.
    29682951 *     @type array  $tax_input             Array of taxonomy terms keyed by their taxonomy name. Default empty.
    29692952 *     @type array  $meta_input            Array of post meta values keyed by their post meta key. Default empty.
    29702953 * }