diff --git a/wp-content/plugins/current-ltw-projects/current-ltw-projects.php b/wp-content/plugins/current-ltw-projects/current-ltw-projects.php index a258dfa..fa7a2e4 100755 --- a/wp-content/plugins/current-ltw-projects/current-ltw-projects.php +++ b/wp-content/plugins/current-ltw-projects/current-ltw-projects.php @@ -17,6 +17,7 @@ '/taxonomies/project-status.php', '/taxonomies/project-org-type.php', '/taxonomies/project-category.php', + '/user-roles/user-roles.php' ); foreach ( $includes as $include ) { if ( 0 === validate_file( $include ) ) { diff --git a/wp-content/plugins/current-ltw-projects/post-types/projects.php b/wp-content/plugins/current-ltw-projects/post-types/projects.php index 237a92f..917e845 100755 --- a/wp-content/plugins/current-ltw-projects/post-types/projects.php +++ b/wp-content/plugins/current-ltw-projects/post-types/projects.php @@ -60,6 +60,8 @@ function projects_init() { // 'page-attributes', // 'post-formats', ), + 'capability_type' => array( 'project', 'projects' ), + 'map_meta_cap' => true, ) ); } diff --git a/wp-content/plugins/current-ltw-projects/taxonomies/project-category.php b/wp-content/plugins/current-ltw-projects/taxonomies/project-category.php index beb6a0d..c342a6c 100755 --- a/wp-content/plugins/current-ltw-projects/taxonomies/project-category.php +++ b/wp-content/plugins/current-ltw-projects/taxonomies/project-category.php @@ -14,10 +14,10 @@ function ltw_content_categories_init() { 'query_var' => true, 'rewrite' => true, 'capabilities' => array( - 'manage_terms' => 'edit_posts', - 'edit_terms' => 'edit_posts', - 'delete_terms' => 'edit_posts', - 'assign_terms' => 'edit_posts', + 'manage_terms' => 'edit_projects', + 'edit_terms' => 'edit_projects', + 'delete_terms' => 'edit_projects', + 'assign_terms' => 'edit_projects', ), 'labels' => array( 'name' => __( 'Content Categories', 'current-ltw-projects' ), diff --git a/wp-content/plugins/current-ltw-projects/taxonomies/project-org-type.php b/wp-content/plugins/current-ltw-projects/taxonomies/project-org-type.php index efa01eb..2e73af6 100755 --- a/wp-content/plugins/current-ltw-projects/taxonomies/project-org-type.php +++ b/wp-content/plugins/current-ltw-projects/taxonomies/project-org-type.php @@ -14,10 +14,10 @@ function project_org_type_init() { 'query_var' => true, 'rewrite' => true, 'capabilities' => array( - 'manage_terms' => 'edit_posts', - 'edit_terms' => 'edit_posts', - 'delete_terms' => 'edit_posts', - 'assign_terms' => 'edit_posts', + 'manage_terms' => 'edit_projects', + 'edit_terms' => 'edit_projects', + 'delete_terms' => 'edit_projects', + 'assign_terms' => 'edit_projects', ), 'labels' => array( 'name' => __( 'Organization Types', 'current-ltw-projects' ), diff --git a/wp-content/plugins/current-ltw-projects/taxonomies/project-status.php b/wp-content/plugins/current-ltw-projects/taxonomies/project-status.php index cf4352b..17fa434 100755 --- a/wp-content/plugins/current-ltw-projects/taxonomies/project-status.php +++ b/wp-content/plugins/current-ltw-projects/taxonomies/project-status.php @@ -14,10 +14,10 @@ function ltw_status_init() { 'query_var' => true, 'rewrite' => true, 'capabilities' => array( - 'manage_terms' => 'edit_posts', - 'edit_terms' => 'edit_posts', - 'delete_terms' => 'edit_posts', - 'assign_terms' => 'edit_posts', + 'manage_terms' => 'edit_projects', + 'edit_terms' => 'edit_projects', + 'delete_terms' => 'edit_projects', + 'assign_terms' => 'edit_projects', ), 'labels' => array( 'name' => __( 'Status', 'current-ltw-projects' ), diff --git a/wp-content/plugins/current-ltw-projects/user-roles/user-roles.php b/wp-content/plugins/current-ltw-projects/user-roles/user-roles.php new file mode 100644 index 0000000..c22f509 --- /dev/null +++ b/wp-content/plugins/current-ltw-projects/user-roles/user-roles.php @@ -0,0 +1,65 @@ + true, + 'edit_posts' => false, + 'delete_posts' => false, + 'publish_posts' => false, + 'upload_files' => true, + 'read_attachments' => true, + ) + ); +} +add_action( 'init', 'ltw_projects_user_roles_init' ); + +function ltw_projects_add_role_capabilities() { + + $roles = array( 'ltw_editor', 'editor', 'administrator' ); + + foreach($roles as $the_role) { + + $role = get_role($the_role); + + $role->add_cap( 'read' ); + $role->add_cap( 'read_project'); + $role->add_cap( 'read_private_projects' ); + $role->add_cap( 'edit_project' ); + $role->add_cap( 'edit_projects' ); + $role->add_cap( 'edit_others_projects' ); + $role->add_cap( 'edit_published_projects' ); + $role->add_cap( 'publish_projects' ); + $role->add_cap( 'delete_projects' ); + $role->add_cap( 'delete_others_projects' ); + $role->add_cap( 'delete_private_projects' ); + $role->add_cap( 'delete_published_projects' ); + + } + +} +add_action( 'admin_init', 'ltw_projects_add_role_capabilities', 999 ); + +/** + * Unregister LTW taxonomies from Largo CFTL landing page object type + * so that the new ltw_editor user role doesn't have access to series landing pages + * + * @see https://github.com/INN/largo/blob/c41d8519370b48a6e53ce36b3b516d3e54e39d66/inc/wp-taxonomy-landing/functions/cftl-admin.php#L77-L84 + * @see https://github.com/INN/umbrella-currentorg/pull/156#issuecomment-652672358 + */ +function ltw_projects_unregister_taxonomies_from_cftl_landing() { + + $ltw_projects_taxonomies = array( + 'project-category', + 'project-org-type', + 'project-status' + ); + + foreach( $ltw_projects_taxonomies as $taxonomy ) { + unregister_taxonomy_for_object_type( $taxonomy, 'cftl-tax-landing' ); + } + +} +add_action( 'init', 'ltw_projects_unregister_taxonomies_from_cftl_landing', 999999 ); \ No newline at end of file