Opened 10 years ago
Last modified 3 months ago
#39106 assigned enhancement
Make hierarchy level indicator text changeable [WP List]
| Reported by: | gk.loveweb | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | Future Release |
| Component: | Posts, Post Types | Version: | 4.6.1 |
| Severity: | minor | Keywords: | good-first-bug has-patch has-unit-tests |
| Cc: | Focuses: | ui, administration |
Description
In WP_Posts_List_Table class, dashes(—) used to indicate the hierarchy level of post item, which is not changeble by any filter, we can add a new filter to replace this string.
$pad = str_repeat( '— ', $this->current_level );
Source: http://wordpress.stackexchange.com/questions/248405/replace-dashes-before-title-in-page-list
Attachments (2)
Change History (11)
#2
@
6 years ago
- Keywords good-first-bug needs-patch added
- Milestone Awaiting Review → Future Release
- Owner set to
- Priority normal → low
- Severity normal → minor
- Status new → accepted
- Type defect (bug) → enhancement
#3
@
6 years ago
- Component Administration → Posts, Post Types
- Owner removed
- Status accepted → assigned
#5
@
6 years ago
I downloaded and tested this patch.
It worked as expected and I was easily able to change the separator used for the hierarchy post separator by adding the filter to my functions.php and trying out different combinations.
One code change I would suggest is to rename name the variable used from $pad to $separator - as I believe this would more closely match the name of the suggested filter naming.
#6
@
6 years ago
I completely agree with @seanchayes and changed $pad to $separator as it makes more sense and semantically correct. I also cross-checked for the conflicts and find zero conflicts.
#7
@
5 years ago
I would suggest an even simpler fix without the need of a filter: just add an element around the character so that it can be accessed by a CSS selector, and have the user add custom admin CSS to hide it (or whatever), like so:
$pad = str_repeat( '<span class="dash">— </span>', $this->current_level );
This ticket was mentioned in PR #11469 on WordPress/wordpress-develop by @iampi20.
3 months ago
#8
- Keywords has-unit-tests added
## Summary
WP_Posts_List_Table::column_title() built the hierarchical indent with a hardcoded em dash string repeated per level. This adds a filter — post_title_child_separator — so the per-level separator can be changed while preserving default output (— ) when the filter is not used.
Props rebasaurus, mayankmajeji, and seanchayes for earlier patches and discussion on the ticket.
## Testing
phpunit(filtered):post_title_child_separatorintests/phpunit/tests/admin/wpPostsListTable.php
Trac ticket: https://core.trac.wordpress.org/ticket/39106
## Use of AI Tools
AI assistance: Yes
Tool(s): Cursor (AI-assisted editor)
Used for: Implementation and PHPUnit coverage; I reviewed the result and ran tests locally before opening this PR.
This ticket was mentioned in PR #11481 on WordPress/wordpress-develop by @vijendrajat.
3 months ago
#9
Introduces the post_title_child_separator filter in WP_Posts_List_Table::column_title(), allowing the hardcoded em-dash hierarchy indicator to be replaced with a custom string. The separator string is passed through the filter once and then repeated per hierarchy level.
Renames the internal $pad variable to $separator for clarity.
Trac ticket: https://core.trac.wordpress.org/ticket/39106
## Use of AI Tools
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thanks for the ticket @gkloveweb. I believe it makes sense to allow this to be tweakable so I've marked it accordingly.
It also seems like an easy to do change, so I've marked it as
good-first-bugfor new contributors to tackle.