Make WordPress Core

Opened 16 years ago

Closed 8 years ago

#5172 closed enhancement (fixed)

Adding classes to wp_generate_tag_cloud

Reported by: chmac's profile chmac Owned by: boonebgorges's profile boonebgorges
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch reporter-feedback dev-feedback
Focuses: template Cc:


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 (3)

category-template.php.diff (1.0 KB) - added by chmac 16 years ago.
5172.patch (790 bytes) - added by Mte90 9 years ago.
New patch updated
5172.2.patch (1010 bytes) - added by Mte90 8 years ago.
refreshed and changed name of the class to tag-link-position-

Download all attachments as: .zip

Change History (23)

#1 @foolswisdom
16 years ago

  • Keywords has-patch added

#2 @markjaquith
16 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.


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

rather than:

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

#3 @westi
16 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.

#4 @AaronCampbell
16 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.

#5 @ffemtcj
16 years ago

  • Milestone changed from 2.5 to 2.6

#6 @Denis-de-Bernardy
15 years ago

see #5031 (with a broken patch)

#7 @hakre
15 years ago

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

#8 @Denis-de-Bernardy
14 years ago

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

#9 @hakre
14 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.

#10 @hakre
13 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?

#11 @nacin
10 years ago

  • Component changed from Template to Taxonomy
  • Focuses template added

9 years ago

New patch updated

#12 @Mte90
9 years ago

  • Keywords has-patch added; needs-patch removed

Attached a new patch with code updated for last version of WordPress.

This ticket was mentioned in Slack in #core by mte90. View the logs.

9 years ago

#14 @samuelsidler
8 years ago

  • Owner westi deleted
  • Status changed from accepted to assigned

#15 @Mte90
8 years ago

any news for that patch?

#16 @samuelsidler
8 years ago

@boonebgorges: Want to take a look at this? :)

#17 @boonebgorges
8 years ago

  • Keywords needs-refresh added; reporter-feedback dev-feedback has-patch removed

The idea behind classes suggested in the patch looks good to me, but the patch needs a refresh after [32996].

'tag-cloud-item-' . count( $a ) feels like a weird class name. The integer doesn't describe the item, it describes the cardinal position (1, 2, 3...) of the tag in the cloud. How about 'tag-cloud-item-position-'?

8 years ago

refreshed and changed name of the class to tag-link-position-

#18 @Mte90
8 years ago

  • Keywords has-patch reporter-feedback dev-feedback added; needs-refresh removed

I've refreshed the patch and changed the class name to tag-link-position- to be similar to the class used in the tag cloud.

#19 @boonebgorges
8 years ago

  • Milestone changed from Future Release to 4.5

#20 @boonebgorges
8 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from assigned to closed

In 35984:

Introduce 'tag-link-position-x' class to tag cloud links.

The new class describes the cardinal position of a link in the cloud, allowing
more fine-grained CSS and JS targeting.

Props Mte90, chmac.
Fixes #5172.

Note: See TracTickets for help on using tickets.