Hi Meta Box Team,
Hope you're doing well!
I'm opening this ticket to report a string sanitization bug in the MB Custom Post Types & Taxonomies extension when generating custom capabilities for non-English languages.
The Issue:
When creating a new CPT, if the Singular or Plural name contains accented characters (very common in Portuguese, Spanish, French, etc.), and we set the "Capability Type" to "Custom" in the Advanced tab, the auto-generated capabilities are completely broken.
Example/Steps to Reproduce:
- Create a CPT with the Plural Name:
Lotes de Importação
- Go to the Advanced tab and set Capability Type to
Custom.
- Instead of transliterating the accents (converting "ç" to "c" and "ã" to "a"), the sanitization function just deletes the characters entirely.
- The generated capabilities become
edit_lotesdeimportao instead of the expected edit_lotes_de_importacao or edit_lotesdeimportacao.
-
The Workaround:
To fix the capability names in our system, we had to artificially remove the accents from the CPT labels in the General tab (typing "Lotes de Importacao" instead), which leaves the WordPress UI grammatically incorrect for our users.
Suggested Fix:
It looks like the script generating the capability suffixes is using a strict regex that strips non-ASCII characters. Passing the CPT name through WordPress's native remove_accents() or sanitize_title_with_dashes() before generating the capability array would easily solve this issue for all international users.
Let me know if you need any more details to patch this!
Best regards,
Jayron Castro
CEO, Kstros.com