Created
March 25, 2013 04:36
-
-
Save yoren/5234955 to your computer and use it in GitHub Desktop.
WordPress: Post type capabilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'labels' => array( | |
'name' => '服務中心', | |
'signular_name' => '服務中心' | |
), | |
'public' => true, | |
'hierarchical' => true, | |
'supports' => array( | |
'title', 'editor', 'page-attributes' | |
), | |
'has_archive' => true, | |
'query_var' => false, | |
'capability_type' => 'ofo', | |
'capabilities' => array( | |
'publish_posts' => 'publish_ofos', | |
'edit_posts' => 'edit_ofos', | |
'edit_others_posts' => 'edit_others_ofos', | |
'delete_posts' => 'delete_ofos', | |
'delete_others_posts' => 'delete_others_ofos', | |
'read_private_posts' => 'read_private_ofos', | |
'edit_post' => 'edit_ofo', | |
'delete_post' => 'delete_ofo', | |
'read_post' => 'read_ofo', | |
) | |
); | |
register_post_type( 'branch', $args ); | |
add_action( 'init', 'ofo_add_cap' ); | |
function ofo_add_cap() { | |
$role = get_role( 'administrator' ); | |
if ( !$role->has_cap( 'publish_ofos' ) ) | |
$role->add_cap( 'publish_ofos' ); | |
if ( !$role->has_cap( 'edit_ofos' ) ) | |
$role->add_cap( 'edit_ofos' ); | |
if ( !$role->has_cap( 'edit_others_ofos' ) ) | |
$role->add_cap( 'edit_others_ofos' ); | |
if ( !$role->has_cap( 'delete_ofos' ) ) | |
$role->add_cap( 'delete_ofos' ); | |
if ( !$role->has_cap( 'delete_others_ofos' ) ) | |
$role->add_cap( 'delete_others_ofos' ); | |
if ( !$role->has_cap( 'read_private_ofos' ) ) | |
$role->add_cap( 'read_private_ofos' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment