[wp-trac] [WordPress Trac] #42768: the_archive_title clutter

WordPress Trac noreply at wordpress.org
Mon Jan 21 14:01:50 UTC 2019


#42768: the_archive_title clutter
------------------------------------+------------------------------
 Reporter:  beerwin                 |       Owner:  (none)
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  General                 |     Version:  4.9.1
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  ui, template
------------------------------------+------------------------------
Changes (by Confridin):

 * keywords:  needs-patch => has-patch dev-feedback


Comment:

 Hello everyone.

 I tried to create a patch to fix this issue. It would also solve #31237
 and #38545.

 I've split $title in 2 variables: $prefix and $title. I'v created a new
 filter "get_the_archive_title_prefix" in order to be able to change the
 prefix, without changing the whole text.

 Developers would be able to:
 - remove the prefix
 {{{#!php
 <?php
 add_filter( 'get_the_archive_title_prefix', __return_empty_string() );
 }}}

 - add for exemple a <span> or a <strong> tag for the prefix
 {{{#!php
 <?php
 add_filter( 'get_the_archive_title_prefix', sx_archive_prefix );
 function sx_archive_prefix( $prefix ){
 return '<strong>' . $prefix . '</strong>';
 }
 }}}


 This patch should not break backward compatibily : the
 get_the_archive_title() filter still exists and will still filters all
 get_the_archive_title() data. Developers would not need to change directly
 the get_the_archive_title() function in their themes and plugins.


 Am I doing it right ?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42768#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list