CARVIEW |
Opened 5 years ago
Last modified 8 days ago
#51403 reviewing enhancement
Add filter for _post_states as it outputs raw HTML
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | good-first-bug has-test-info has-patch has-unit-tests |
Focuses: | template | Cc: |
Description
Currently this function can't be overridden with a filter, so it outputs raw HTML separators and such directly into the post title in the edit screen. However it should be suggested to make it possible to display the post states in your own custom function, e.g. remove the separators and the divider with the title, which are currently hard-coded at the moment in the function as raw HTML?
Change History (16)
#1
@SirLouen
4 weeks ago
- Focuses coding-standards removed
- Keywords needs-patch good-first-bug has-test-info added
- Milestone changed from Awaiting Review to Future Release
- Version 5.5.1 deleted
This ticket was mentioned in PR #10000 on WordPress/wordpress-develop by @paulbonneau.
2 weeks ago
#2
- Keywords has-patch added; needs-patch removed
This PR aim to implement a new filter in _post_states as asked in the ticket linked below
#3
@paulbonneau
2 weeks ago
Hello @SirLouen @brandbrilliance,
I created a PR with an implementation attempt of what you described @SirLouen.
The new filter can be tested by adding the code below to a test theme functions.php or test plugin :
<?php add_filter('post_states_string', function($post_states_string, $post){ return $post_states_string .= '<span class="post-state">, Sample state</span>'; }, 10, 2);
Nevertheless I'm not sure that a filter in _post_states function (/wp-admin/includes/template.php
l.2248) is necessary.
_post_states seems to be a formatting function specifically designed to display post states in the WordPress admin post list view.
The use case described by @brandbrilliance seems already covered. One can totally use the get_post_states function to gather post state and format them as you want on another screen sans passer par la fonction _post_states.
#4
@paulbonneau
2 weeks ago
- Keywords has-unit-tests added
Added test and a doc block above the new filter as suggested by @mukeshpanchal27 in the Github PR https://github.com/WordPress/wordpress-develop/pull/10000
#5
follow-ups:
↓ 7
↓ 8
@mukesh27
13 days ago
- Milestone changed from Future Release to 6.9
Move into milestone for visibility.
@mukesh27 commented on PR #10000:
13 days ago
#6
Thanks @paulbonneau, Left some final bit of feedbacks.
#8
in reply to:
↑ 5
@SirLouen
10 days ago
- Owner set to SirLouen
- Status changed from new to reviewing
Replying to mukesh27:
Move into milestone for visibility.
@paulbonneau we also have here the compact-utf8.php
fixes. This fix is plaguing all PR.
@paulbonneau commented on PR #10000:
10 days ago
#9
Remove the
src/wp-includes/compat-utf8.php
done
This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.
9 days ago
This ticket was mentioned in PR #10077 on WordPress/wordpress-develop by @shsajalchowdhury.
9 days ago
#11
Trac ticket: [Add filter for _post_states as it outputs raw HTML
#12
@aialvi
9 days ago
Test Report
Description
This report validates whether the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/10000
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.4
- Database: mysqli (Server: 8.4.4 / Client: mysqlnd 8.2.28)
- Browser: Chrome 140.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Actual Results
- ✅ Issue resolved with patch.
Additional Notes
- None
#13
@shsajalchowdhury
9 days ago
Test Report
Description
This report validates whether the indicated patch works as expected.
Testing Instructions
I have followed the instructions and applied them in my environment, and it seems to be working as instructed.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/10000
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 140.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Actual Results
- ✅ Issue resolved with patch.
Additional Notes
- None
#15
@SirLouen
9 days ago
Ok, this has been fully reviewed, tested, and everything, so it's pretty much ready to be shipped.
#16
@ugyensupport
8 days ago
Add filter for _post_states as it outputs raw HTML
Description
Currently this function can't be overridden with a filter, so it outputs raw HTML separators and such directly into the post title in the edit screen. However it should be suggested to make it possible to display the post states in your own custom function, e.g. remove the separators and the divider with the title, which are currently hard-coded at the moment in the function as raw HTML?
Patch tested: https://github.com/WordPress/wordpress-develop/pull/10000
Environment
- WordPress: 6.8.3-alpha-60773
- PHP: 8.4.1
- Server: nginx/1.21.4
- Database: mysqli (Server: 5.7.44-log / Client: mysqlnd 8.4.1)
- Browser: Chrome 140.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
- Gutenberg 21.7.0
- Test Reports 1.2.0
- WordPress Beta Tester 3.6.4
Expected Results
- ✅ Issue resolved with patch.
Looks good to me. A filter to
post_states_string
can be applied here definitely.Testing Instructions after the patch
Test info is pretty straight forward. These states are the ones that appear near the list of posts for example (The list that can say something like "Front Page, Draft", for example.
So testing is simply adding the filter, and checking if it appears there the modified content as expected. Like this: