Skip to content

Commit

Permalink
Add specific capabilities to the taxonomies
Browse files Browse the repository at this point in the history
  • Loading branch information
renatho committed Jun 6, 2024
1 parent 05dc462 commit 5860830
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions includes/class-sensei-data-cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class Sensei_Data_Cleaner {
'manage_lesson_categories',
'manage_course_categories',
'manage_question_categories',
'manage_modules',
'publish_quizzes',
'edit_quizzes',
'edit_published_quizzes',
Expand Down
6 changes: 6 additions & 0 deletions includes/class-sensei-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -2179,6 +2179,12 @@ public function setup_modules_taxonomy() {
'public' => true,
'hierarchical' => true,
'show_admin_column' => false,
'capabilities' => array(
'manage_terms' => 'manage_modules',
'edit_terms' => 'manage_modules',
'delete_terms' => 'manage_modules',
'assign_terms' => 'edit_courses',
),
'show_in_nav_menus' => false,
'show_in_quick_edit' => false,
'show_ui' => true,
Expand Down
14 changes: 10 additions & 4 deletions includes/class-sensei-posttypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,9 @@ public function setup_course_category_taxonomy() {
'query_var' => true,
'show_in_nav_menus' => true,
'capabilities' => array(
'manage_terms' => 'manage_categories',
'manage_terms' => 'manage_course_categories',
'edit_terms' => 'manage_course_categories',
'delete_terms' => 'manage_categories',
'delete_terms' => 'manage_course_categories',
'assign_terms' => 'edit_courses',
),
'rewrite' => array(
Expand Down Expand Up @@ -839,9 +839,9 @@ public function setup_question_category_taxonomy() {
'show_admin_column' => true,
'show_in_rest' => true,
'capabilities' => array(
'manage_terms' => 'manage_categories',
'manage_terms' => 'manage_question_categories',
'edit_terms' => 'manage_question_categories',
'delete_terms' => 'manage_categories',
'delete_terms' => 'manage_question_categories',
'assign_terms' => 'edit_questions',
),
'rewrite' => array(
Expand Down Expand Up @@ -891,6 +891,12 @@ public function setup_lesson_tag_taxonomy() {
'show_ui' => true,
'query_var' => true,
'show_in_nav_menus' => true,
'capabilities' => array(
'manage_terms' => 'manage_lesson_categories',
'edit_terms' => 'manage_lesson_categories',
'delete_terms' => 'manage_lesson_categories',
'assign_terms' => 'edit_lessons',
),
'rewrite' => array(
/**
* Filter the rewrite slug for the lesson tag taxonomy.
Expand Down
3 changes: 3 additions & 0 deletions includes/class-sensei-teacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ protected function add_capabilities() {
'read_private_courses' => true,
'delete_published_courses' => true,

// Modules
'manage_modules' => true,

// Quiz
'publish_quizzes' => true,
'edit_quizzes' => true,
Expand Down
2 changes: 2 additions & 0 deletions includes/class-sensei.php
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@ public function add_editor_caps() {
$role->add_cap( 'manage_lesson_categories' );
$role->add_cap( 'manage_course_categories' );
$role->add_cap( 'manage_question_categories' );
$role->add_cap( 'manage_modules' );
}

return true;
Expand All @@ -1868,6 +1869,7 @@ public function add_sensei_admin_caps() {
$role->add_cap( 'manage_lesson_categories' );
$role->add_cap( 'manage_course_categories' );
$role->add_cap( 'manage_question_categories' );
$role->add_cap( 'manage_modules' );
}

return true;
Expand Down

0 comments on commit 5860830

Please sign in to comment.