Changeset 14585 for trunk/wp-includes/post.php
- Timestamp:
- 05/12/2010 08:45:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r14584 r14585 775 775 * - inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 776 776 * - capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 777 * - edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 778 * - edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 779 * - 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). 780 * - publish_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 781 * - read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 782 * - delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 777 * - capabilities - Array of capabilities for this post type. You can see accepted values in {@link get_post_type_capabilities()}. By default the capability_type is used to construct capabilities. 783 778 * - hierarchical - Whether the post type is hierarchical. Defaults to false. 784 779 * - supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. … … 803 798 $defaults = array( 804 799 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 805 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', ' hierarchical' => false,800 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'capabilities' => array(), 'hierarchical' => false, 806 801 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 807 802 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, … … 828 823 if ( empty($args->capability_type) ) 829 824 $args->capability_type = 'post'; 830 if ( empty($args->edit_cap) ) 831 $args->edit_cap = 'edit_' . $args->capability_type; 832 if ( empty($args->edit_type_cap) ) 833 $args->edit_type_cap = 'edit_' . $args->capability_type . 's'; 834 if ( empty($args->edit_others_cap) ) 835 $args->edit_others_cap = 'edit_others_' . $args->capability_type . 's'; 836 if ( empty($args->publish_cap) ) 837 $args->publish_cap = 'publish_' . $args->capability_type . 's'; 838 if ( empty($args->read_cap) ) 839 $args->read_cap = 'read_' . $args->capability_type; 840 if ( empty($args->read_private_cap) ) 841 $args->read_private_cap = 'read_private_' . $args->capability_type . 's'; 842 if ( empty($args->delete_cap) ) 843 $args->delete_cap = 'delete_' . $args->capability_type; 825 826 $args->cap = get_post_type_capabilities( $args ); 844 827 845 828 if ( ! empty($args->supports) ) { … … 891 874 892 875 return $args; 876 } 877 878 /** 879 * Builds an object with all post type capabilities out of a post type object 880 * 881 * Accepted keys of the capabilities array in the post type object: 882 * - edit_post - The meta capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 883 * - edit_posts - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 884 * - edit_others_posts - 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). 885 * - publish_posts - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 886 * - read_post - The meta capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 887 * - read_private_posts - The capability that controls reading private posts. Defaults to "read_ . $capability_type . s" (read_private_posts). 888 * - delete_post - The meta capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 889 * 890 * @since 3.0.0 891 * @param object $args 892 * @return object object with all the capabilities as member variables 893 */ 894 function get_post_type_capabilities( $args ) { 895 $defaults = array( 896 'edit_post' => 'edit_' . $args->capabilities['capability_type'], 897 'edit_posts' => 'edit_' . $args->capabilities['capability_type'] . 's', 898 'edit_others_posts' => 'edit_others_' . $args->capabilities['capability_type'] . 's', 899 'publish_posts' => 'publish_' . $args->capabilities['capability_type'] . 's', 900 'read_post' => 'edit_' . $args->capabilities['capability_type'], 901 'read_private_posts' => 'read_private_' . $args->capabilities['capability_type'] . 's', 902 'delete_post' => 'delete_' . $args->capabilities['capability_type'], 903 ); 904 $labels = array_merge( $defaults, $args->capabilities ); 905 return (object) $labels; 893 906 } 894 907 … … 1526 1539 if ( 'readable' == $perm && is_user_logged_in() ) { 1527 1540 $post_type_object = get_post_type_object($type); 1528 if ( !current_user_can( $post_type_object-> read_private_cap) ) {1541 if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) { 1529 1542 $cache_key .= '_' . $perm . '_' . $user->ID; 1530 1543 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))";
Note: See TracChangeset
for help on using the changeset viewer.