Changeset 15890 for trunk/wp-includes/post.php
- Timestamp:
- 10/21/2010 02:40:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r15852 r15890 21 21 '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 22 22 'capability_type' => 'post', 23 'map_meta_cap' => true, 23 24 'hierarchical' => false, 24 25 'rewrite' => false, … … 32 33 '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 33 34 'capability_type' => 'page', 35 'map_meta_cap' => true, 34 36 'hierarchical' => true, 35 37 'rewrite' => false, … … 837 839 * - menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon. 838 840 * - capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 839 * - 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. 841 * - 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 as a base to construct capabilities. 842 * - map_meta_cap - Whether to use the internal default meta capability handling. Defaults to false. 840 843 * - hierarchical - Whether the post type is hierarchical. Defaults to false. 841 844 * - supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. … … 867 870 $defaults = array( 868 871 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 869 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'capabilities' => array(), 'hierarchical' => false, 872 'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => false, 873 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 870 874 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 871 875 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, … … 979 983 * - delete_post - The meta capability that controls deleting a particular object of this post type. Defaults to "delete_ . $capability_type" (delete_post). 980 984 * 985 * @see map_meta_cap() 981 986 * @since 3.0.0 987 * 982 988 * @param object $args 983 989 * @return object object with all the capabilities as member variables 984 990 */ 985 991 function get_post_type_capabilities( $args ) { 986 $defaults = array( 992 global $_post_type_meta_capabilities; 993 994 $default_capabilities = array( 995 // Meta capabilities are generally mapped to primitive capabilities depending on the context 996 // (which would be the post being edited/deleted/read), instead of granted to users or roles: 987 997 'edit_post' => 'edit_' . $args->capability_type, 998 'read_post' => 'read_' . $args->capability_type, 999 'delete_post' => 'delete_' . $args->capability_type, 1000 // Primitive capabilities that are used outside of map_meta_cap(): 988 1001 'edit_posts' => 'edit_' . $args->capability_type . 's', 989 1002 'edit_others_posts' => 'edit_others_' . $args->capability_type . 's', 990 1003 'publish_posts' => 'publish_' . $args->capability_type . 's', 991 'read_post' => 'read_' . $args->capability_type,992 1004 'read_private_posts' => 'read_private_' . $args->capability_type . 's', 993 'delete_post' => 'delete_' . $args->capability_type,994 1005 ); 995 $labels = array_merge( $defaults, $args->capabilities ); 996 return (object) $labels; 1006 // Primitive capabilities that are used within map_meta_cap(): 1007 if ( $args->map_meta_cap ) { 1008 $default_capabilities_for_mapping = array( 1009 'read' => 'read', 1010 'delete_posts' => 'delete_' . $args->capability_type . 's', 1011 'delete_private_posts' => 'delete_private_' . $args->capability_type . 's', 1012 'delete_published_posts' => 'delete_published_' . $args->capability_type . 's', 1013 'delete_others_posts' => 'delete_others_' . $args->capability_type . 's', 1014 'edit_private_posts' => 'edit_private_' . $args->capability_type . 's', 1015 'edit_published_posts' => 'edit_published_' . $args->capability_type . 's', 1016 ); 1017 $default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping ); 1018 } 1019 $capabilities = array_merge( $default_capabilities, $args->capabilities ); 1020 if ( $args->map_meta_cap ) 1021 _post_type_meta_capabilities( $capabilities ); 1022 return (object) $capabilities; 1023 } 1024 1025 /** 1026 * Stores or returns a list of post type meta caps for map_meta_cap(). 1027 * 1028 * @since 3.1.0 1029 * @access private 1030 */ 1031 function _post_type_meta_capabilities( $capabilities = null ) { 1032 static $meta_caps = array(); 1033 if ( null === $capabilities ) 1034 return $meta_caps; 1035 foreach ( $capabilities as $core => $custom ) { 1036 if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) ) 1037 $meta_caps[ $custom ] = $core; 1038 } 997 1039 } 998 1040
Note: See TracChangeset
for help on using the changeset viewer.