[wp-trac] [WordPress Trac] #40924: Making font_size data for wp_generate_tag_cloud_data filter more flexible

WordPress Trac noreply at wordpress.org
Mon Jun 5 09:35:30 UTC 2017


#40924: Making font_size data for wp_generate_tag_cloud_data filter more flexible
-----------------------------+-----------------------------
 Reporter:  mhmdshv          |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Widgets          |    Version:  4.7.5
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Hi,

 The 'wp_generate_tag_cloud_data' filter currently supports font_size, but
 the flexibility is so little.

 This data only accepts a number, and automatically appends a pt to it,
 setting the font's size. So for example if i set the font size by using
 the following code:


 {{{
 add_filter( 'wp_generate_tag_cloud_data', function( $tag_data ) {
     return array_map (
         function ( $item ) {
             $item['font_size'] = '8';
             return $item;
         },
         (array) $tag_data
     );

 } );
 }}}


 The result would be font-size:8pt . But if i want to unset the font size
 or for example use em/px, i won't be able to, unless i use preg_replace:


 {{{
 add_filter('wp_generate_tag_cloud', 'filter_tag_cloud',10,1);
 function filter_tag_cloud($string){
    return preg_replace("/style='font-size:.+pt;'/", 'tyle='font-
 size:unset;', $string);
 }
 }}}


 This feature will come in handy in some theme's that have their own way of
 styling and handling the tag cloud widget. I for example, have problem
 with this in two of my theme that are being developed, since the font size
 is having a bad effect on my theme's appearance.

 Here is a post on WordPress Stackexchange that we discussed this matter a
 bit further:

 [https://wordpress.stackexchange.com/q/225693/94498]

 Would love to see this in future.

 Regards, Jack

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40924>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list