Make WordPress Core

Opened 12 months ago

Last modified 8 months ago

#58134 new defect (bug)

Use correct plural of status

Reported by: presskopp's profile Presskopp Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: needs-patch
Focuses: Cc:

Description

Core uses a variable named $stati (10 times to be found, in 3 files), but that's not the correct plural form of 'status', neither in english, nor in latin or elsewhere. So I plead to change it to $statuses. While there seems to be no decent rule for variable names, so technically the variable could be named $stsii or whatever, still we are called to not

"abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting."

see https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/

Also, as we all know, "Code is Poetry", isn't it? Now you could argue poetry has some freedoms, but I strongly believe it should use correct grammar, at least in this case.

So I may have convinced you finally of that one, but there's one more issue:

There's also a function

get_post_stati()

see https://developer.wordpress.org/reference/functions/get_post_stati/

c'mon, let's rename it to get_post_statuses, while we're on it.

You may think this is petty, but it gave me some confusion and after all it's just wrong. Let's get rid of an usage of a plural form which doesn't exist.

Change History (8)

#1 @sabernhardt
12 months ago

  • Component changed from Text Changes to General

#2 @sabernhardt
12 months ago

Searching _stati also found $post_stati and a global $avail_post_stati variable (with $avail_post_stati_backup in the related unit test).

#3 @sabernhardt
12 months ago

  • Keywords needs-patch added

I think it's worth replacing the $stati and $post_stati variables, but I'm not sure about the function or the global variable.

Outside core, directory searches found the get_post_stati() function in 534 plugins and the Storefront theme.

If the function gets a new name (alias), get_post_status_list() might be appropriate.

#4 in reply to: ↑ description ; follow-up: @SergeyBiryukov
8 months ago

Replying to Presskopp:

There's also a function

get_post_stati()

see https://developer.wordpress.org/reference/functions/get_post_stati/

c'mon, let's rename it to get_post_statuses, while we're on it.

Just noting that get_post_statuses() already exists for a slightly different purpose, so get_post_status_list() as suggested above might be another option.

#5 @SergeyBiryukov
8 months ago

  • Component changed from General to Posts, Post Types

#6 in reply to: ↑ 4 @SergeyBiryukov
8 months ago

Replying to SergeyBiryukov:

Just noting that get_post_statuses() already exists for a slightly different purpose, so get_post_status_list() as suggested above might be another option.

There is also get_available_post_statuses() for another slightly different purpose.

#7 @Presskopp
8 months ago

For clarity let me sum it up:

The following are existing functions:

get_available_post_statuses() ("Returns all the possible statuses for a post type.")

get_post_statuses() ("Retrieves all of the WordPress supported post statuses.")

get_post_stati() ("Gets a list of post statuses.")

That makes it impossible to rename get_post_stati() to get_post_statuses(), so get_post_status_list() could be helpful here.

#8 @manfcarlo
8 months ago

Why would it be impossible? What about preserving the existing behaviour of get_post_statuses when no arguments are provided, but enhancing it with the same parameters of get_post_stati and then turning get_post_stati into a wrapper function? Noting that the output of get_post_stati when no arguments are provided is not the same as the output of get_post_statuses, the default arguments could be slightly tweaked for get_post_statuses to preserve the old output (e.g. the default value of $args could specify only built-in statuses.) Would that work?

Note: See TracTickets for help on using tickets.