Make WordPress Core


Ignore:
Timestamp:
02/02/2010 05:37:03 PM (17 years ago)
Author:
ryan
Message:

Allow customizing capabilities for custom post types. Always check caps against those in the post type object instead of contructing them manually. see #9674

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r12923 r12927  
    701701 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
    702702 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
     703 * edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post).
     704 * edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts).
     705 * edit_others_cap - The capability that controls editing objects of this post type that are owned by other users. Defaults to "edit_others_ . $capability_type . s" (edit_others_posts).
     706 * edit_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts).
     707 * read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post).
     708 * delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post).
    703709 * hierarchical - Whether the post type is hierarchical. Defaults to false.
    704710 * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
     
    737743                $args->label = $post_type;
    738744
    739         if ( empty($args->capability_type) ) {
    740                 $args->edit_cap = '';
    741                 $args->read_cap = '';
    742                 $args->delete_cap = '';
    743         } else {
     745        if ( empty($args->capability_type) )
     746                $args->capability_type = 'post';
     747        if ( empty($args->edit_cap) )
    744748                $args->edit_cap = 'edit_' . $args->capability_type;
     749        if ( empty($args->edit_type_cap) )
     750                $args->edit_type_cap = 'edit_' . $args->capability_type . 's';
     751        if ( empty($args->edit_others_cap) )
     752                $args->edit_others_cap = 'edit_others_' . $args->capability_type . 's';
     753        if ( empty($args->publish_cap) )
     754                $args->publish_cap = 'publish_' . $args->capability_type . 's';
     755        if ( empty($args->read_cap) )
    745756                $args->read_cap = 'read_' . $args->capability_type;
     757        if ( empty($args->delete_cap) )
    746758                $args->delete_cap = 'delete_' . $args->capability_type;
    747         }
    748759
    749760        if ( !$args->_builtin && $args->public )
Note: See TracChangeset for help on using the changeset viewer.