Add filters to post states function#10000
Add filters to post states function#10000paulbonneau wants to merge 12 commits intoWordPress:trunkfrom
Conversation
|
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. |
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. |
|
Thanks @paulbonneau, Left some final bit of feedbacks. |
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
SirLouen
left a comment
There was a problem hiding this comment.
Remove the src/wp-includes/compat-utf8.php
done |
| $output = _post_states( $post, false ); | ||
|
|
||
| $this->assertStringContainsString( $text_to_append, $output ); | ||
| $this->assertStringContainsString( $original_output, $output ); |
There was a problem hiding this comment.
should we consider using $this->assertStringStartsWith and $this->assertStringEndsWith here instead of contains?
Update: not a blocker, but also something that seems fine to change while merging if it’s useful.
There was a problem hiding this comment.
Yeah, in dea8f00 I'm changing this to:
$this->assertSame( $original_output . $text_to_append, $output, 'Expected text to be appended to the original output.' );When there are no post states, then the $original_output is an empty string.
…into add-filters-to-_post_states-function
| * Default true. | ||
| * @return string Post states string. | ||
| */ | ||
| function _post_states( $post, $display = true ) { |
There was a problem hiding this comment.
The same changes seem like they should be done to _media_states().
… post states. Developed in #10000 Props paulbonneau, mukesh27, westonruter, SirLouen, dmsnell, brandbrilliance, shsajalchowdhury, aialvi, ugyensupport. Fixes #51403. git-svn-id: https://develop.svn.wordpress.org/trunk@60986 602fd350-edb4-49c9-b593-d223f7449a82
… post states. Developed in WordPress/wordpress-develop#10000 Props paulbonneau, mukesh27, westonruter, SirLouen, dmsnell, brandbrilliance, shsajalchowdhury, aialvi, ugyensupport. Fixes #51403. Built from https://develop.svn.wordpress.org/trunk@60986 git-svn-id: http://core.svn.wordpress.org/trunk@60322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
… post states. Developed in WordPress/wordpress-develop#10000 Props paulbonneau, mukesh27, westonruter, SirLouen, dmsnell, brandbrilliance, shsajalchowdhury, aialvi, ugyensupport. Fixes #51403. Built from https://develop.svn.wordpress.org/trunk@60986 git-svn-id: https://core.svn.wordpress.org/trunk@60322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
| * | ||
| * @param string $post_states_string The post states HTML string. | ||
| * @param string[] $post_states The post states. | ||
| * @param WP_Post $post The current post object. |
There was a problem hiding this comment.
can follow-up after merge, but it would be really handy to have some examples here so people know what to expect. I find the combination of _string and HTML string confusing, plus I don’t know what to expect for this or the following array. Which post states are these?
/**
* @param string $post_states_html All relevant post states combined into a an HTML string for display.
* E.g. ' — <span class="post-state">draft</span> — <span class="post-state">private</span>'
* @param string[] $post_states. All relevant posts states as an array of raw names.
* E.g. `array( "draft", "private" )`.There was a problem hiding this comment.
@dmsnell Should we rename the filter to be post_states_html then too?
There was a problem hiding this comment.
@westonruter originally started to share here, but moved it to #51403 because I feel like it applies to the design of the request rather the implementation.
Since this does provide the array of $post_states I think it does serve the questions I raised, but I do believe we could better communicate what’s going on with the naming.
This PR aim to implement a new filter in _post_states as asked in the ticket linked below
Trac ticket: https://core.trac.wordpress.org/ticket/51403