-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix taxonomy capabilities #7613
Changes from all commits
3e0bbe0
936e5ad
1db8c30
05dc462
64dd35f
bbc71c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fixed | ||
|
||
Change some taxonomy capabilities to fix some behaviors |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -204,6 +207,7 @@ protected function add_capabilities() { | |
|
||
// Questions | ||
'publish_questions' => true, | ||
'manage_question_categories' => true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were already adding it for courses and lessons, but not for questions. |
||
'edit_questions' => true, | ||
'edit_published_questions' => true, | ||
'edit_private_questions' => true, | ||
|
@@ -227,7 +231,7 @@ protected function add_capabilities() { | |
|
||
foreach ( $caps as $cap => $grant ) { | ||
|
||
// load the capability on to the teacher role | ||
// load the capability on to the teacher role. | ||
$this->teacher_role->add_cap( $cap, $grant ); | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,11 +88,26 @@ public function run_updates() { | |
$this->v4_10_update_install_time(); | ||
$this->v4_12_create_default_emails(); | ||
$this->v4_19_2_update_legacy_quiz_data(); | ||
$this->v4_24_1_update_capabilities(); | ||
|
||
// Flush rewrite cache. | ||
Sensei()->initiate_rewrite_rules_flush(); | ||
} | ||
|
||
/** | ||
* Update capabilities. | ||
* | ||
* @since 4.24.1 | ||
*/ | ||
private function v4_24_1_update_capabilities() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we changed capabilities, we need a migration to apply the changes. It only happens on the plugin activation. |
||
// Add new `manage_question_categories` capabilitiy to teacher. | ||
Sensei()->teacher->create_role(); | ||
|
||
// Update the other roles capabilities. | ||
Sensei()->add_sensei_admin_caps(); | ||
Sensei()->add_editor_caps(); | ||
} | ||
|
||
/** | ||
* Enqueue job to update the legacy quiz data. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1844,6 +1844,11 @@ public function add_editor_caps() { | |
|
||
if ( ! is_null( $role ) ) { | ||
$role->add_cap( 'manage_sensei_grades' ); | ||
|
||
$role->add_cap( 'manage_lesson_categories' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Admin and editor weren't receiving these capabilities previously. I think we didn't notice it before because we weren't explicitly using it, so it didn't cause any issue. |
||
$role->add_cap( 'manage_course_categories' ); | ||
$role->add_cap( 'manage_question_categories' ); | ||
$role->add_cap( 'manage_modules' ); | ||
} | ||
|
||
return true; | ||
|
@@ -1860,6 +1865,11 @@ public function add_sensei_admin_caps() { | |
if ( ! is_null( $role ) ) { | ||
$role->add_cap( 'manage_sensei' ); | ||
$role->add_cap( 'manage_sensei_grades' ); | ||
|
||
$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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first try was to just remove the
capabilities
to use the default ones. It would use just use themanage_categories
foredit_terms
.But since teachers don't have the capability
manage_categories
, it was hiding the buttons to add the categories through the editor sidebar.