-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add filter for plugins list status text #8294
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
base: trunk
Are you sure you want to change the base?
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@Sukhendu2002 could you merge the latest trunk changes into this to see if that fixes the test issues? |
|
Test Report added to the Trac ticket: https://core.trac.wordpress.org/ticket/60495#comment:26 |
| * @param string $type The status slug being filtered. | ||
| */ | ||
| $text = apply_filters( 'plugins_list_status_text', '', $count, $type ); | ||
| if ( empty( $text ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ( empty( $text ) ) { | |
| if ( empty( $text ) || ! is_string( $text ) ) { |
| if ( empty( $text ) ) { | ||
| $text = $type; | ||
| } | ||
| $text .= ' ' . sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not strictly necessary but for sanity's sake:
| $text .= ' ' . sprintf( | |
| $text = esc_html( $text ) . ' ' . sprintf( |
| break; | ||
| default: | ||
| /** | ||
| * Filter the status text of default switch case in the Plugins list table. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be capitalized?
| * Filter the status text of default switch case in the Plugins list table. | |
| * Filters the status text of default switch case in the plugins list table. |
| * @param string $text Plugins list status text. Default empty string. | ||
| * @param int $count Count the Number of plugins. | ||
| * @param string $type The status slug being filtered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param string $text Plugins list status text. Default empty string. | |
| * @param int $count Count the Number of plugins. | |
| * @param string $type The status slug being filtered. | |
| * @param string $text Plugins list status text. Default empty string. | |
| * @param int $count Count of the number of plugins. | |
| * @param string $type The status slug being filtered. |
| * @param int $count Count the Number of plugins. | ||
| * @param string $type The status slug being filtered. | ||
| */ | ||
| $text = apply_filters( 'plugins_list_status_text', '', $count, $type ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking for a string as suggested below, should we force a string value from the filter?
| $text = apply_filters( 'plugins_list_status_text', '', $count, $type ); | |
| $text = (string) apply_filters( 'plugins_list_status_text', '', $count, $type ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could result in a PHP warning if the filter returns an array: https://3v4l.org/XAR5P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. My thought was that, since WP core does this kind of casting already in numerous places, it would be safe to do since a warning doesn't stop execution, and it provides clues about incorrect code that doesn't provide expected results, whereas without it we kinda hide the problem. But as your example shows, having a string that says "Array" isn't very helpful either. Happy to withdraw my suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about it. If someone uses this filter to return anything other than a string then they are doing it wrong anyway. There's probably a literal billion other places on WP where this kind of thing would also happen currently.
|
@Sukhendu2002 are you available to update your PR to address the review from Weston? |
|
Patch Refreshed in this PR #10133 |
Trac ticket: https://core.trac.wordpress.org/ticket/60495
Patch refresh for: #6637
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.