Content Classification: Dynamicize taxonomy error messages - #916
Content Classification: Dynamicize taxonomy error messages#916Infinite-Null wants to merge 2 commits into
Conversation
…abel helper method
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #916 +/- ##
==========================================
Coverage 80.43% 80.44%
- Complexity 2565 2573 +8
==========================================
Files 110 110
Lines 10448 10462 +14
==========================================
+ Hits 8404 8416 +12
- Misses 2044 2046 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| $taxonomy = sanitize_key( $taxonomy ); | ||
|
|
||
| if ( '' === $taxonomy || ! taxonomy_exists( $taxonomy ) ) { | ||
| return 'taxonomy'; |
There was a problem hiding this comment.
Not sure if this fallback is ever hit but if it is, this string isn't passed through translation now
| ? $tax_object->labels->singular_name | ||
| : ( ! empty( $tax_object->labels->name ) ? $tax_object->labels->name : $taxonomy ); | ||
|
|
||
| return strtolower( trim( wp_strip_all_tags( (string) $label ) ) ); |
There was a problem hiding this comment.
Do we need strtolower here? I think in some languages the taxonomy name is likely better left capitalized so I'd remove that here to avoid that
| * | ||
| * @since x.x.x | ||
| */ | ||
| public function test_get_taxonomy_label_returns_correct_labels(): void { |
There was a problem hiding this comment.
This test is fine but I think we can add some better/additional tests. For instance, we can add a test that actually invokes the callbacks via reflection to ensure the messages are accurate, like:
$result = $method->invoke( $this->ability, array( 'taxonomy' => 'category' ) );
$this->assertStringContainsString( 'category suggestions', $result->get_error_message() );We also don't have tests for the no_results error code with a non-default taxonomy, a situation where a missing or non-string taxonomy is passed to permission_callback (which is new behavior in this PR that defaults to post_tag), or a custom taxonomy that has a multi-word label
What?
This PR updates the error and notice messages in the
Content_Classificationability to dynamically display the specific taxonomy label (e.g., "category" or "tag") rather than generic hardcoded "taxonomy" terminology.Why?
When users interacted with specific taxonomy panels (such as "Suggest Categories" under the Categories sidebar panel), error notices displayed generic phrasing like "No taxonomy suggestions were generated." or "You do not have permission to generate taxonomy suggestions." This caused confusion as users were explicitly generating suggestions for categories.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 4.6
Used for: Validating bug, suggesting a fix.
Testing Instructions
"Content is required to generate category suggestions."or"No category suggestions were generated."(instead of generic"No taxonomy suggestions were generated.").Screenshots or screencast
Before
Screen.Recording.2026-08-05.at.1.30.25.PM.mov
After
Screen.Recording.2026-08-05.at.1.29.48.PM.mov
Changelog Entry