WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 3 months ago

Last modified 2 months ago

#13949 closed enhancement (wontfix)

Add a sprintf style argument to wp_list_categories() for title tag.

Reported by: mfields Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: needs-testing needs-unit-tests has-patch
Focuses: Cc:

Description

By default, wp_list_categories() will use the value of $term->description for the title tag of every link that it generates. If the argument "use_desc_for_title" is set to false, it will produce a string like: "View all posts filed under $term->name". With the inclusion of custom post_types into core, it would be wonderful to have more control over this title. The best solution that I can think of is to add a sprintf style argument which will allow themes and plugins to provide a custom format. Something like:

'title_format' => 'View all tacos posted under %s.'

Attachments (4)

13949.diff (1.6 KB) - added by wonderboymusic 4 years ago.
16946.2.patch (1008 bytes) - added by Mte90 20 months ago.
refreshed patch for 4.6
13949.2.diff (1.1 KB) - added by Mte90 20 months ago.
sorry wrong patch, this is patch for wp 4.6
13949.3.diff (2.0 KB) - added by Mte90 20 months ago.
added docs

Download all attachments as: .zip

Change History (14)

#1 @nacin
7 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Seems fine to me.

@wonderboymusic
4 years ago

#2 @wonderboymusic
4 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Added a patch - not sure how important this one is. I'll let someone else decide if they need this in 3.7

#3 @nacin
4 years ago

13949.diff screws up the translation functions. Otherwise, good for commit.

#4 @chriscct7
2 years ago

  • Keywords needs-refresh added

@Mte90
20 months ago

refreshed patch for 4.6

@Mte90
20 months ago

sorry wrong patch, this is patch for wp 4.6

#5 @Mte90
20 months ago

  • Keywords needs-refresh removed

I updated the patch code without the title_format because now in the code is available title_li that have the same behaviour.
I have added only the feed_title that is missing in the actual version.

#6 @boonebgorges
20 months ago

  • Keywords needs-patch needs-unit-tests added; has-patch removed

Hi @Mte90 - Thanks for the patch. A few comments and requests:

  • We'll need documentation for the new parameter. See https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/
  • Why are we calling it feed_title when it's used for the alt attribute? Is there an example of this usage elsewhere in WP?
  • You mentioned that title_li does the same thing as the proposed title_format, but I don't think that's true. 13949.diff proposes a sprintf-friendly string that is used for the link title attribute. I don't have strong feelings about whether this feature is necessary.
  • Ideally, we'd have unit tests demonstrating the sprintf() behavior. See tests/phpunit/tests/category/wpListCategories.php

@Mte90
20 months ago

added docs

#7 @Mte90
20 months ago

Hi @boonebgorges thanks for the help,

#8 @jorbin
15 months ago

  • Keywords has-patch added; needs-patch removed

This still needs some unit tests.

#9 @Mte90
3 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

Looking better at the code this feature is not required because today the feed parameter enable to insert a custom text and my patch was only changing the text in case of that value is not customized.
So this feature is already covered by WordPress :-)

#10 @netweb
2 months ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.