Skip to content

Command Palette: Convert commands to sentence case #191

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions assets/src/js/commands/admin-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const registerAdminCommands = () => {
const commands = [
{
name: 'field-groups',
label: __( 'Field Groups', 'secure-custom-fields' ),
label: __( 'Field groups', 'secure-custom-fields' ),
url: 'edit.php',
urlArgs: { post_type: 'acf-field-group' },
icon: layout,
Expand All @@ -49,7 +49,7 @@ const registerAdminCommands = () => {
},
{
name: 'new-field-group',
label: __( 'Create New Field Group', 'secure-custom-fields' ),
label: __( 'Create new field group', 'secure-custom-fields' ),
url: 'post-new.php',
urlArgs: { post_type: 'acf-field-group' },
icon: plus,
Expand All @@ -67,7 +67,7 @@ const registerAdminCommands = () => {
},
{
name: 'post-types',
label: __( 'Post Types', 'secure-custom-fields' ),
label: __( 'Post types', 'secure-custom-fields' ),
url: 'edit.php',
urlArgs: { post_type: 'acf-post-type' },
icon: postList,
Expand All @@ -79,7 +79,7 @@ const registerAdminCommands = () => {
},
{
name: 'new-post-type',
label: __( 'Create New Post Type', 'secure-custom-fields' ),
label: __( 'Create new post type', 'secure-custom-fields' ),
url: 'post-new.php',
urlArgs: { post_type: 'acf-post-type' },
icon: plus,
Expand All @@ -103,7 +103,7 @@ const registerAdminCommands = () => {
},
{
name: 'new-taxonomy',
label: __( 'Create New Taxonomy', 'secure-custom-fields' ),
label: __( 'Create new taxonomy', 'secure-custom-fields' ),
url: 'post-new.php',
urlArgs: { post_type: 'acf-taxonomy' },
icon: plus,
Expand All @@ -122,7 +122,7 @@ const registerAdminCommands = () => {
},
{
name: 'options-pages',
label: __( 'Options Pages', 'secure-custom-fields' ),
label: __( 'Options pages', 'secure-custom-fields' ),
url: 'edit.php',
urlArgs: { post_type: 'acf-ui-options-page' },
icon: settings,
Expand All @@ -134,7 +134,7 @@ const registerAdminCommands = () => {
},
{
name: 'new-options-page',
label: __( 'Create New Options Page', 'secure-custom-fields' ),
label: __( 'Create new options page', 'secure-custom-fields' ),
url: 'post-new.php',
urlArgs: { post_type: 'acf-ui-options-page' },
icon: plus,
Expand All @@ -146,7 +146,7 @@ const registerAdminCommands = () => {
},
{
name: 'tools',
label: __( 'SCF Tools', 'secure-custom-fields' ),
label: __( 'SCF tools', 'secure-custom-fields' ),
url: 'admin.php',
urlArgs: { page: 'acf-tools' },
icon: tool,
Expand All @@ -158,7 +158,7 @@ const registerAdminCommands = () => {
},
{
name: 'import',
label: __( 'Import SCF Data', 'secure-custom-fields' ),
label: __( 'Import SCF data', 'secure-custom-fields' ),
url: 'admin.php',
urlArgs: { page: 'acf-tools', tool: 'import' },
icon: upload,
Expand All @@ -170,7 +170,7 @@ const registerAdminCommands = () => {
},
{
name: 'export',
label: __( 'Export SCF Data', 'secure-custom-fields' ),
label: __( 'Export SCF data', 'secure-custom-fields' ),
url: 'admin.php',
urlArgs: { page: 'acf-tools', tool: 'export' },
icon: download,
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/admin-commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function acf_commands_init() {
$custom_post_types[] = array(
'name' => $post_type['post_type'],
'all_items' => $labels->all_items,
'add_new_item' => $labels->add_new_item,
'add_new_item' => ucfirst( strtolower( $labels->add_new_item ) ),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, RTL languages don't have upper and lower case, so this shouldn't affect them, nor would they require different treatment; is that correct, @mcsf?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't do this 🙈 Operations like this tend to break when applied across different languages, as they make implicit assumptions that don't always apply to all languages.

In this particular change, it breaks for German, where nouns are always capitalized: "book" is "Buch", so "Neues buch hinzufügen" would be very wrong 😬

Basically, localized strings should be left alone (which is also the reason why $labels has so many seemingly redundant strings) -- our best course of action is to continue to use $labels->add_new_item, and to handle the case of the strings in the individual translations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Bernie, I suspected this could not play well in other languages 😅

In this case, the add_new_label in English capitalizes both words, as seen in the Add new X button, whereas core commands for adding new pages don't reuse strings and have their own post/page-specific strings.

My best guess here would be to add a completely new label to avoid breaking others, which aligns with the seemingly redundant strings you mentioned. Do you have any other recommendations?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My best guess here would be to add a completely new label to avoid breaking others, which aligns with the seemingly redundant strings you mentioned. Do you have any other recommendations?

Do you mean a new label which would be the same as add_new_label but with different casing expectations?

Copy link
Contributor Author

@priethor priethor Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally meant this, but that's before realizing core add_new_label values have been updated in 6.8 to remove the New part, so what we should do is change the default value for add_new_value to align with core when creating CPTs in SCF (see #193).

'icon' => $post_type['menu_icon'] ?? '',
'label' => $labels->name,
'id' => $post_type['ID'],
Expand Down
Loading