From 77569c97f01c82f4fecc6b94157445f7a44f6f4f Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 31 Dec 2013 05:00:57 +1100 Subject: [PATCH] Config role permissions and installation file --- admin/post-types/column.php | 3 +- admin/post-types/outcome.php | 3 +- admin/post-types/result.php | 3 +- admin/post-types/statistic.php | 3 +- sportspress-defaults.php => install.php | 45 ++++++++++++++----------- sportspress.php | 4 +-- 6 files changed, 35 insertions(+), 26 deletions(-) rename sportspress-defaults.php => install.php (88%) diff --git a/admin/post-types/column.php b/admin/post-types/column.php index 9cc8fb34..16db69ed 100644 --- a/admin/post-types/column.php +++ b/admin/post-types/column.php @@ -8,10 +8,11 @@ function sp_column_cpt_init() { 'label' => $name, 'labels' => $labels, 'public' => false, + 'show_ui' => true, + 'show_in_menu' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), 'register_meta_box_cb' => 'sp_column_meta_init', - 'show_in_menu' => 'edit.php?post_type=sp_event', 'capability_type' => 'sp_config' ); register_post_type( 'sp_column', $args ); diff --git a/admin/post-types/outcome.php b/admin/post-types/outcome.php index 8dc10848..a4d7a136 100644 --- a/admin/post-types/outcome.php +++ b/admin/post-types/outcome.php @@ -8,9 +8,10 @@ function sp_outcome_cpt_init() { 'label' => $name, 'labels' => $labels, 'public' => false, + 'show_ui' => true, + 'show_in_menu' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), - 'show_in_menu' => 'edit.php?post_type=sp_event', 'capability_type' => 'sp_config' ); register_post_type( 'sp_outcome', $args ); diff --git a/admin/post-types/result.php b/admin/post-types/result.php index 9a53b061..6ca30668 100644 --- a/admin/post-types/result.php +++ b/admin/post-types/result.php @@ -8,9 +8,10 @@ function sp_result_cpt_init() { 'label' => $name, 'labels' => $labels, 'public' => false, + 'show_ui' => true, + 'show_in_menu' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), - 'show_in_menu' => 'edit.php?post_type=sp_event', 'capability_type' => 'sp_config' ); register_post_type( 'sp_result', $args ); diff --git a/admin/post-types/statistic.php b/admin/post-types/statistic.php index feb3edfd..73b0d573 100644 --- a/admin/post-types/statistic.php +++ b/admin/post-types/statistic.php @@ -8,10 +8,11 @@ function sp_statistic_cpt_init() { 'label' => $name, 'labels' => $labels, 'public' => false, + 'show_ui' => true, + 'show_in_menu' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), 'register_meta_box_cb' => 'sp_statistic_meta_init', - 'show_in_menu' => 'edit.php?post_type=sp_event', 'capability_type' => 'sp_config' ); register_post_type( 'sp_statistic', $args ); diff --git a/sportspress-defaults.php b/install.php similarity index 88% rename from sportspress-defaults.php rename to install.php index bee6a5cb..d6b0359e 100644 --- a/sportspress-defaults.php +++ b/install.php @@ -10,7 +10,7 @@ if ( !function_exists( 'sportspress_install' ) ) { $role->add_cap( 'edit_sp_event' ); $role->add_cap( 'edit_sp_events' ); $role->add_cap( 'edit_others_sp_events' ); - $role->add_cap( 'delete_sp_events' ); + $role->add_cap( 'delete_sp_event' ); $role->add_cap( 'publish_sp_events' ); $role->add_cap( 'read_sp_events' ); $role->add_cap( 'read_private_sp_events' ); @@ -19,7 +19,7 @@ if ( !function_exists( 'sportspress_install' ) ) { $role->add_cap( 'edit_sp_team' ); $role->add_cap( 'edit_sp_teams' ); $role->add_cap( 'edit_others_sp_teams' ); - $role->add_cap( 'delete_sp_teams' ); + $role->add_cap( 'delete_sp_team' ); $role->add_cap( 'publish_sp_teams' ); $role->add_cap( 'read_sp_teams' ); $role->add_cap( 'read_private_sp_teams' ); @@ -28,7 +28,7 @@ if ( !function_exists( 'sportspress_install' ) ) { $role->add_cap( 'edit_sp_table' ); $role->add_cap( 'edit_sp_tables' ); $role->add_cap( 'edit_others_sp_tables' ); - $role->add_cap( 'delete_sp_tables' ); + $role->add_cap( 'delete_sp_table' ); $role->add_cap( 'publish_sp_tables' ); $role->add_cap( 'read_sp_tables' ); $role->add_cap( 'read_private_sp_tables' ); @@ -37,7 +37,7 @@ if ( !function_exists( 'sportspress_install' ) ) { $role->add_cap( 'edit_sp_player' ); $role->add_cap( 'edit_sp_players' ); $role->add_cap( 'edit_others_sp_players' ); - $role->add_cap( 'delete_sp_players' ); + $role->add_cap( 'delete_sp_player' ); $role->add_cap( 'publish_sp_players' ); $role->add_cap( 'read_sp_players' ); $role->add_cap( 'read_private_sp_players' ); @@ -46,7 +46,7 @@ if ( !function_exists( 'sportspress_install' ) ) { $role->add_cap( 'edit_sp_list' ); $role->add_cap( 'edit_sp_lists' ); $role->add_cap( 'edit_others_sp_lists' ); - $role->add_cap( 'delete_sp_lists' ); + $role->add_cap( 'delete_sp_list' ); $role->add_cap( 'publish_sp_lists' ); $role->add_cap( 'read_sp_lists' ); $role->add_cap( 'read_private_sp_lists' ); @@ -55,19 +55,24 @@ if ( !function_exists( 'sportspress_install' ) ) { $role->add_cap( 'edit_sp_staff' ); $role->add_cap( 'edit_sp_staffs' ); $role->add_cap( 'edit_others_sp_staffs' ); - $role->add_cap( 'delete_sp_staffs' ); + $role->add_cap( 'delete_sp_staff' ); $role->add_cap( 'publish_sp_staffs' ); $role->add_cap( 'read_sp_staffs' ); $role->add_cap( 'read_private_sp_staffs' ); // Settings - $role->add_cap( 'edit_sp_config' ); - $role->add_cap( 'edit_sp_configs' ); - $role->add_cap( 'edit_others_sp_configs' ); - $role->add_cap( 'delete_sp_configs' ); - $role->add_cap( 'publish_sp_configs' ); $role->add_cap( 'read_sp_configs' ); $role->add_cap( 'read_private_sp_configs' ); + $role->add_cap( 'edit_sp_config' ); + $role->add_cap( 'edit_sp_configs' ); + $role->add_cap( 'edit_published_sp_configs' ); + $role->add_cap( 'edit_private_sp_configs' ); + $role->add_cap( 'edit_others_sp_configs' ); + $role->add_cap( 'delete_sp_config' ); + $role->add_cap( 'delete_published_sp_configs' ); + $role->add_cap( 'delete_private_sp_configs' ); + $role->add_cap( 'delete_others_sp_configs' ); + $role->add_cap( 'publish_sp_configs' ); // Team Manager remove_role( 'sp_team_manager' ); @@ -81,13 +86,13 @@ if ( !function_exists( 'sportspress_install' ) ) { 'read_sp_players' => true, 'edit_sp_players' => true, 'edit_others_sp_players' => true, - 'delete_sp_players' => true, + 'delete_sp_player' => true, 'publish_sp_players' => true, - 'read_sp_staff' => true, - 'edit_sp_staff' => true, - 'edit_others_sp_staff' => true, + 'read_sp_staffs' => true, + 'edit_sp_staffs' => true, + 'edit_others_sp_staffs' => true, 'delete_sp_staff' => true, - 'publish_sp_staff' => true + 'publish_sp_staffs' => true ) ); @@ -100,8 +105,8 @@ if ( !function_exists( 'sportspress_install' ) ) { 'read' => true, 'edit_posts' => true, 'delete_posts' => true, - 'read_sp_staff' => true, - 'edit_sp_staff' => true, + 'read_sp_staffs' => true, + 'edit_sp_staffs' => true, 'delete_sp_staff' => true ) ); @@ -117,7 +122,7 @@ if ( !function_exists( 'sportspress_install' ) ) { 'delete_posts' => true, 'read_sp_players' => true, 'edit_sp_players' => true, - 'delete_sp_players' => true + 'delete_sp_player' => true ) ); @@ -170,5 +175,5 @@ if ( !function_exists( 'sportspress_install' ) ) { } } -sportspress_install(); +add_action( 'admin_init', 'sportspress_install', 1 ); ?> \ No newline at end of file diff --git a/sportspress.php b/sportspress.php index f0d90cb8..30a73a13 100644 --- a/sportspress.php +++ b/sportspress.php @@ -50,8 +50,8 @@ require_once dirname( __FILE__ ) . '/admin/post-types/staff.php'; require_once dirname( __FILE__ ) . '/admin/terms/league.php'; require_once dirname( __FILE__ ) . '/admin/terms/position.php'; -// Defaults -include dirname( __FILE__ ) . '/sportspress-defaults.php'; +// Install +include dirname( __FILE__ ) . '/install.php'; // Hooks, Actions, and Filters require_once dirname( __FILE__ ) . '/sportspress-hooks.php';