WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 3 months ago

#5172 accepted enhancement

Adding classes to wp_generate_tag_cloud

Reported by: chmac Owned by: westi
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: needs-patch reporter-feedback dev-feedback
Focuses: template Cc:

Description

The attached patch changes 2 things on the wp_generate_tag_cloud function.

1) The current code uses single quotes instead of double quotes, I believe the standard is to use double quotes. I've converted single quotes to double quotes.

2) I've rounded the tag size to a whole number (no decimal places).

3) I've added a class "tag-cloud-item-X" where X is the number in the list and a second class "tag-cloud-size-X" where X is the size of the tag. . This will allow theme designers to apply different styles to tags. For example changing the colour from cold to hot depending on order or size.

Attachments (1)

category-template.php.diff (1.0 KB) - added by chmac 7 years ago.

Download all attachments as: .zip

Change History (12)

chmac7 years ago

comment:1 foolswisdom7 years ago

  • Keywords has-patch added

comment:2 markjaquith7 years ago

There is no standard for quotes style in XHTML. We tend to use doublequotes by default, but we'll use singlequotes if we want to concat in some variables.

e.g.

echo "<a href='$url'>$title</a>";

rather than:

echo '<a href="'. $url . '">' . $title . '</a>';

comment:3 westi7 years ago

  • Owner changed from anonymous to westi
  • Status changed from new to assigned

+1 Good plan to add more classes for styling.

Relates to #5131 and #5171 all tag cloud changes.

I will get these all in soon.

comment:4 AaronCampbell6 years ago

+1 for adding some classes

I think we should actually remove the inline styles (font-size) and use classes instead.
Also, while we're adding classes, I think we should add a current_tag class if you're viewing a tag page.

comment:5 ffemtcj6 years ago

  • Milestone changed from 2.5 to 2.6

comment:6 Denis-de-Bernardy5 years ago

see #5031 (with a broken patch)

comment:7 hakre5 years ago

see #8903 with some general suggestion on how to solve.

comment:8 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 2.9 to Future Release

comment:9 hakre5 years ago

I take my comment over from #8903 for further reference:

  • add new function wp_generate_tag_cloud_array() that takes care of data only
  • that data should handle the absolute weight (min-max) as well as relative (1-5)
  • use the new function on your own will
  • update wp_genereate_tag_cloud() to use the new function as well.

going that route will seperate the concerns and refactor wp_generate_tag_cloud() a bit.

comment:10 hakre3 years ago

  • Keywords reporter-feedback dev-feedback added; wp_generate_tag_cloudk wp_tag_cloud removed

Are patches (or updates to the existing one) welcome for this issue?

comment:11 nacin3 months ago

  • Component changed from Template to Taxonomy
  • Focuses template added
Note: See TracTickets for help on using tickets.