-
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
Conversation
Test the previous changes of this PR with WordPress Playground. |
ec1b70e
to
3e0bbe0
Compare
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
@@ -1844,6 +1844,10 @@ 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 comment
The 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.
@@ -204,6 +204,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 comment
The 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.
* | ||
* @since 4.24.1 | ||
*/ | ||
private function v4_24_1_update_capabilities() { |
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.
Since we changed capabilities, we need a migration to apply the changes. It only happens on the plugin activation.
5860830
to
e116930
Compare
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
@@ -2180,9 +2180,9 @@ public function setup_modules_taxonomy() { | |||
'hierarchical' => true, | |||
'show_admin_column' => false, | |||
'capabilities' => array( |
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 the manage_categories
for edit_terms
.
But since teachers don't have the capability manage_categories
, it was hiding the buttons to add the categories through the editor sidebar.
e116930
to
64dd35f
Compare
Test the previous changes of this PR with WordPress Playground. |
I started it without a changelog entry because users probably won't notice that, but thinking more I decided to add an entry (bbc71c7), in case someone has special customizations with roles and capabilities. |
Test the previous changes of this PR with WordPress Playground. |
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.
Looks good and works well 👍
I had three observations during the tests.
1. It is related to the test instructions.
It looks like I cannot follow the instruction not to assign the tag:
2. Course Outline in the lesson preview for teacher
I previewed the draft lesson as a teacher and found the course outline was empty. Checked in Safari and Chrome in case it was an issue with styles: same result.
And then tested with an admin account: everything is in its place.
3. Assign module in the lesson for a legacy course
I found that when I first open the lesson in the editor I can't assign the module. It says set the course first, even though it the course is set. But it works fine after saving the draft and refreshing.
Thank you for the review, @merkushin!
Do you mean you couldn't reproduce the known issue and after the refresh, the lesson tag persisted for you?
I think it's an expected behavior because of this:
But I agree that it could be better, offering the same behavior to teachers. Do you think it's worth an enhancement issue for it?
I believe it was aways the behavior. Since it's for the legacy way to do it, I think it's not worth an issue. WDYT? |
Proposed Changes
/wp-admin/term.php?taxonomy=module&tag_ID=ID&post_type=course
) directly through the edit URL, but not being able to save it.module
,course-category
,lesson-tag
, andquestion-category
.manage_categories
capability by default are admin and editor.. So adding the new roles to administrator, editor, and teacher looks a good solution to me.Alternative approach
See #7613 (comment)
Context
The previous changes for the module taxonomy happened in this PR: #459
The first commit has the following description (the best context I could extract from the history):
Known issues
Testing Instructions
SENSEI_LMS_VERSION
, so the new capabilities are properly created.Now let's make sure everything continues working properly:
Pre-Merge Checklist