The available check categories are currently only defined as a slug, via class constants on Check_Categories. While those slugs are the key to the functionality, the categories are also displayed to end users. Right now this is accomplished via ucfirst( str_replace( '_', ' ', $category ) ), which really isn't right. We need to use a proper i18n string for each category.
In other words, each available category should also have a label. Here's what I'd suggest:
Introduce a new method Check_Categories::get_category_labels().
The method should return an associative array of the category slugs and their respective labels.
The slugs should be the ones from the class constants, and the labels should be new i18n friendly strings.
The Admin_Page class should then call the new method to have both the category slugs and labels, and the admin-page.php template should be adjusted accordingly.
In case the PR #339 has already been merged, there's another reference to the categories in there that would need to be updated in the same way as well.
Another related observation is that the Check_Categories::get_categories() method is unnecessarily complex, using ReflectionClass to dynamically get the class constants. I think that's a bit "too smart" and more importantly inefficient, so I think it would be better to simply return a "hard-coded" array including the class constants in there. I think it would be worth making that change here too, while we're enhancing that class anyway.
The available check categories are currently only defined as a slug, via class constants on
Check_Categories
. While those slugs are the key to the functionality, the categories are also displayed to end users. Right now this is accomplished viaucfirst( str_replace( '_', ' ', $category ) )
, which really isn't right. We need to use a proper i18n string for each category.In other words, each available category should also have a label. Here's what I'd suggest:
Check_Categories::get_category_labels()
.Admin_Page
class should then call the new method to have both the category slugs and labels, and theadmin-page.php
template should be adjusted accordingly.Another related observation is that the
Check_Categories::get_categories()
method is unnecessarily complex, usingReflectionClass
to dynamically get the class constants. I think that's a bit "too smart" and more importantly inefficient, so I think it would be better to simply return a "hard-coded" array including the class constants in there. I think it would be worth making that change here too, while we're enhancing that class anyway.cc @mukeshpanchal27 @swissspidy @ernilambar