Add roles and capabilities
This commit is contained in:
@@ -13,7 +13,8 @@ function sp_column_cpt_init() {
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'page-attributes' ),
|
||||
'register_meta_box_cb' => 'sp_column_meta_init',
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event'
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'capability_type' => 'sp_config'
|
||||
);
|
||||
register_post_type( 'sp_column', $args );
|
||||
}
|
||||
|
||||
@@ -11,10 +11,9 @@ function sp_event_cpt_init() {
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'author', 'comments' ),
|
||||
'register_meta_box_cb' => 'sp_event_meta_init',
|
||||
'rewrite' => array( 'slug' => 'event' ),
|
||||
'menu_position' => 42
|
||||
'rewrite' => array( 'slug' => get_option( 'sp_event_slug', 'event' ) ),
|
||||
'capability_type' => 'sp_event'
|
||||
);
|
||||
$args['labels']['menu_name'] = __( 'SportsPress', 'sportspress' );
|
||||
register_post_type( 'sp_event', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_event_cpt_init' );
|
||||
|
||||
@@ -12,7 +12,8 @@ function sp_list_cpt_init() {
|
||||
'supports' => array( 'title', 'author' ),
|
||||
'register_meta_box_cb' => 'sp_list_meta_init',
|
||||
'rewrite' => array( 'slug' => 'list' ),
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player'
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||
'capability_type' => 'sp_list'
|
||||
);
|
||||
register_post_type( 'sp_list', $args );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ function sp_outcome_cpt_init() {
|
||||
'show_in_nav_menus' => false,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'page-attributes' ),
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event'
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'capability_type' => 'sp_config'
|
||||
);
|
||||
register_post_type( 'sp_outcome', $args );
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ function sp_player_cpt_init() {
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'author', 'thumbnail' ),
|
||||
'register_meta_box_cb' => 'sp_player_meta_init',
|
||||
'rewrite' => array( 'slug' => 'player' ),
|
||||
'menu_position' => 44
|
||||
'rewrite' => array( 'slug' => get_option( 'sp_player_slug', 'player' ) ),
|
||||
'capability_type' => 'sp_player'
|
||||
);
|
||||
register_post_type( 'sp_player', $args );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ function sp_result_cpt_init() {
|
||||
'show_in_nav_menus' => false,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'page-attributes' ),
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event'
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'capability_type' => 'sp_config'
|
||||
);
|
||||
register_post_type( 'sp_result', $args );
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ function sp_staff_cpt_init() {
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'author', 'thumbnail' ),
|
||||
'register_meta_box_cb' => 'sp_staff_meta_init',
|
||||
'rewrite' => array( 'slug' => 'staff' ),
|
||||
'menu_position' => 45
|
||||
'rewrite' => array( 'slug' => get_option( 'sp_staff_slug', 'staff' ) ),
|
||||
'capability_type' => array( 'sp_staff', 'sp_staff' )
|
||||
);
|
||||
register_post_type( 'sp_staff', $args );
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ function sp_statistic_cpt_init() {
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'page-attributes' ),
|
||||
'register_meta_box_cb' => 'sp_statistic_meta_init',
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event'
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'capability_type' => 'sp_config'
|
||||
);
|
||||
register_post_type( 'sp_statistic', $args );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ function sp_table_cpt_init() {
|
||||
'supports' => array( 'title', 'author', 'excerpt' ),
|
||||
'register_meta_box_cb' => 'sp_table_meta_init',
|
||||
'rewrite' => array( 'slug' => 'table' ),
|
||||
'show_in_menu' => 'edit.php?post_type=sp_team'
|
||||
'show_in_menu' => 'edit.php?post_type=sp_team',
|
||||
'capability_type' => 'sp_table'
|
||||
);
|
||||
register_post_type( 'sp_table', $args );
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ function sp_team_cpt_init() {
|
||||
'hierarchical' => true,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'register_meta_box_cb' => 'sp_team_meta_init',
|
||||
'rewrite' => array( 'slug' => 'team' ),
|
||||
'menu_position' => 43
|
||||
'rewrite' => array( 'slug' => get_option( 'sp_team_slug', 'team' ) ),
|
||||
'capability_type' => 'sp_team'
|
||||
);
|
||||
register_post_type( 'sp_team', $args );
|
||||
}
|
||||
|
||||
@@ -15,13 +15,7 @@ function sp_admin_menu() {
|
||||
return;
|
||||
|
||||
global $menu, $submenu;
|
||||
|
||||
// Add separator
|
||||
$menu[41] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||
|
||||
// Remove "Add Event" link under Events
|
||||
unset( $submenu['edit.php?post_type=sp_event'][10] );
|
||||
|
||||
|
||||
// Remove "Leagues" link under Events
|
||||
unset( $submenu['edit.php?post_type=sp_event'][15] );
|
||||
|
||||
|
||||
@@ -1,9 +1,119 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sp_install_defaults' ) ) {
|
||||
function sp_install_defaults() {
|
||||
if ( !function_exists( 'sportspress_install' ) ) {
|
||||
function sportspress_install() {
|
||||
$installed = get_option( 'sportspress_installed', false );
|
||||
if ( ! $installed ):
|
||||
|
||||
$role = get_role( 'administrator' );
|
||||
|
||||
// Events
|
||||
$role->add_cap( 'edit_sp_events' );
|
||||
$role->add_cap( 'edit_others_sp_events' );
|
||||
$role->add_cap( 'delete_sp_events' );
|
||||
$role->add_cap( 'publish_sp_events' );
|
||||
$role->add_cap( 'read_sp_events' );
|
||||
$role->add_cap( 'read_private_sp_events' );
|
||||
|
||||
// Teams
|
||||
$role->add_cap( 'edit_sp_staff' );
|
||||
$role->add_cap( 'edit_others_sp_staff' );
|
||||
$role->add_cap( 'delete_sp_staff' );
|
||||
$role->add_cap( 'publish_sp_staff' );
|
||||
$role->add_cap( 'read_sp_staff' );
|
||||
$role->add_cap( 'read_private_sp_staff' );
|
||||
|
||||
// League Tables
|
||||
$role->add_cap( 'edit_sp_tables' );
|
||||
$role->add_cap( 'edit_others_sp_tables' );
|
||||
$role->add_cap( 'delete_sp_tables' );
|
||||
$role->add_cap( 'publish_sp_tables' );
|
||||
$role->add_cap( 'read_sp_tables' );
|
||||
$role->add_cap( 'read_private_sp_tables' );
|
||||
|
||||
// Players
|
||||
$role->add_cap( 'edit_sp_players' );
|
||||
$role->add_cap( 'edit_others_sp_players' );
|
||||
$role->add_cap( 'delete_sp_players' );
|
||||
$role->add_cap( 'publish_sp_players' );
|
||||
$role->add_cap( 'read_sp_players' );
|
||||
$role->add_cap( 'read_private_sp_players' );
|
||||
|
||||
// Player Lists
|
||||
$role->add_cap( 'edit_sp_lists' );
|
||||
$role->add_cap( 'edit_others_sp_lists' );
|
||||
$role->add_cap( 'delete_sp_lists' );
|
||||
$role->add_cap( 'publish_sp_lists' );
|
||||
$role->add_cap( 'read_sp_lists' );
|
||||
$role->add_cap( 'read_private_sp_lists' );
|
||||
|
||||
// Staff
|
||||
$role->add_cap( 'edit_sp_staff' );
|
||||
$role->add_cap( 'edit_others_sp_staff' );
|
||||
$role->add_cap( 'delete_sp_staff' );
|
||||
$role->add_cap( 'publish_sp_staff' );
|
||||
$role->add_cap( 'read_sp_staff' );
|
||||
$role->add_cap( 'read_private_sp_staff' );
|
||||
|
||||
// Settings
|
||||
$role->add_cap( 'edit_sp_settings' );
|
||||
$role->add_cap( 'edit_others_sp_settings' );
|
||||
$role->add_cap( 'delete_sp_settings' );
|
||||
$role->add_cap( 'publish_sp_settings' );
|
||||
$role->add_cap( 'read_sp_settings' );
|
||||
$role->add_cap( 'read_private_sp_settings' );
|
||||
|
||||
// Team Manager
|
||||
remove_role( 'sp_team_manager' );
|
||||
add_role(
|
||||
'sp_team_manager',
|
||||
__( 'Team Manager', 'sportspress' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => true,
|
||||
'delete_posts' => true,
|
||||
'read_sp_players' => true,
|
||||
'edit_sp_players' => true,
|
||||
'edit_others_sp_players' => true,
|
||||
'delete_sp_players' => true,
|
||||
'publish_sp_players' => true,
|
||||
'read_sp_staff' => true,
|
||||
'edit_sp_staff' => true,
|
||||
'edit_others_sp_staff' => true,
|
||||
'delete_sp_staff' => true,
|
||||
'publish_sp_staff' => true
|
||||
)
|
||||
);
|
||||
|
||||
// Staff
|
||||
remove_role( 'sp_staff' );
|
||||
add_role(
|
||||
'sp_staff',
|
||||
__( 'Staff', 'sportspress' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => true,
|
||||
'delete_posts' => true,
|
||||
'read_sp_staff' => true,
|
||||
'edit_sp_staff' => true,
|
||||
'delete_sp_staff' => true
|
||||
)
|
||||
);
|
||||
|
||||
// Player
|
||||
remove_role( 'sp_player' );
|
||||
add_role(
|
||||
'sp_player',
|
||||
__( 'Player', 'sportspress' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => true,
|
||||
'delete_posts' => true,
|
||||
'read_sp_players' => true,
|
||||
'edit_sp_players' => true,
|
||||
'delete_sp_players' => true
|
||||
)
|
||||
);
|
||||
|
||||
$pages = array(
|
||||
|
||||
// Results
|
||||
@@ -50,7 +160,8 @@ if ( !function_exists( 'sp_install_defaults' ) ) {
|
||||
|
||||
update_option( 'sportspress_installed', 1 );
|
||||
endif;
|
||||
|
||||
}
|
||||
}
|
||||
sp_install_defaults();
|
||||
sportspress_install();
|
||||
?>
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
function sportspress_admin_menu() {
|
||||
|
||||
add_submenu_page(
|
||||
'edit.php?post_type=sp_event',
|
||||
add_options_page(
|
||||
__( 'SportsPress Settings', 'sportspress' ),
|
||||
__( 'Settings', 'sportspress' ),
|
||||
__( 'SportsPress', 'sportspress' ),
|
||||
'manage_options',
|
||||
'sportspress',
|
||||
'sportspress_settings'
|
||||
|
||||
Reference in New Issue
Block a user