Skip to content

Commit 4f10f17

Browse files
Bundled Themes: Change tag cloud format to a list (<ul>) for better semantics and accessibility.
List markup allows screen reader users to know in advance how many tags are within the list. Props xkon, davidakennedy. Fixes #40138. git-svn-id: https://develop.svn.wordpress.org/trunk@41756 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5c2609b commit 4f10f17

20 files changed

Lines changed: 204 additions & 14 deletions

File tree

src/wp-content/themes/twentyeleven/functions.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,22 @@ function twentyeleven_get_gallery_images() {
743743

744744
return $images;
745745
}
746+
747+
/**
748+
* Modifies tag cloud widget arguments to display all tags in the same font size
749+
* and use list format for better accessibility.
750+
*
751+
* @since Twenty Eleven 2.7
752+
*
753+
* @param array $args Arguments for tag cloud widget.
754+
* @return array The filtered arguments for tag cloud widget.
755+
*/
756+
function twentyeleven_widget_tag_cloud_args( $args ) {
757+
$args['largest'] = 22;
758+
$args['smallest'] = 8;
759+
$args['unit'] = 'pt';
760+
$args['format'] = 'list';
761+
762+
return $args;
763+
}
764+
add_filter( 'widget_tag_cloud_args', 'twentyeleven_widget_tag_cloud_args' );

src/wp-content/themes/twentyeleven/style.css

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,6 @@ section.ephemera .entry-title a span {
19221922
}
19231923

19241924
/* Calendar Widget */
1925-
19261925
.widget_calendar #wp-calendar {
19271926
color: #555;
19281927
width: 95%;
@@ -1952,7 +1951,6 @@ section.ephemera .entry-title a span {
19521951
}
19531952

19541953
/* Text Widget */
1955-
19561954
.widget_text ul,
19571955
.widget_text ol {
19581956
margin: 0 0 1.625em 2.5em;
@@ -1964,6 +1962,15 @@ section.ephemera .entry-title a span {
19641962
margin-bottom: 0;
19651963
}
19661964

1965+
/* Tag Cloud Widget */
1966+
.tagcloud ul {
1967+
list-style-type: none;
1968+
}
1969+
1970+
.tagcloud ul li {
1971+
display: inline-block;
1972+
}
1973+
19671974
/* =Comments
19681975
----------------------------------------------- */
19691976

@@ -2332,7 +2339,6 @@ p.comment-form-comment {
23322339
font-weight: bold;
23332340
}
23342341

2335-
23362342
/* =Responsive Structure
23372343
----------------------------------------------- */
23382344

src/wp-content/themes/twentyfifteen/functions.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,26 @@ function twentyfifteen_search_form_modify( $html ) {
385385
}
386386
add_filter( 'get_search_form', 'twentyfifteen_search_form_modify' );
387387

388+
/**
389+
* Modifies tag cloud widget arguments to display all tags in the same font size
390+
* and use list format for better accessibility.
391+
*
392+
* @since Twenty Fifteen 1.9
393+
*
394+
* @param array $args Arguments for tag cloud widget.
395+
* @return array The filtered arguments for tag cloud widget.
396+
*/
397+
function twentyfifteen_widget_tag_cloud_args( $args ) {
398+
$args['largest'] = 22;
399+
$args['smallest'] = 8;
400+
$args['unit'] = 'pt';
401+
$args['format'] = 'list';
402+
403+
return $args;
404+
}
405+
add_filter( 'widget_tag_cloud_args', 'twentyfifteen_widget_tag_cloud_args' );
406+
407+
388408
/**
389409
* Implement the Custom Header feature.
390410
*

src/wp-content/themes/twentyfifteen/inc/template-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function twentyfifteen_entry_meta() {
9797
}
9898

9999
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
100-
if ( $tags_list ) {
100+
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
101101
printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
102102
_x( 'Tags', 'Used before tag names.', 'twentyfifteen' ),
103103
$tags_list

src/wp-content/themes/twentyfifteen/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,13 @@ img.aligncenter {
15591559
margin-left: 1.6em;
15601560
}
15611561

1562+
.tagcloud ul {
1563+
list-style-type: none;
1564+
}
1565+
1566+
.tagcloud ul li {
1567+
display: inline-block;
1568+
}
15621569

15631570
/**
15641571
* 12.0 Content

src/wp-content/themes/twentyfourteen/functions.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,27 @@ function twentyfourteen_wp_title( $title, $sep ) {
527527
}
528528
add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );
529529

530+
531+
/**
532+
* Modifies tag cloud widget arguments to display all tags in the same font size
533+
* and use list format for better accessibility.
534+
*
535+
* @since Twenty Fourteen 2.1
536+
*
537+
* @param array $args Arguments for tag cloud widget.
538+
* @return array The filtered arguments for tag cloud widget.
539+
*/
540+
function twentyfourteen_widget_tag_cloud_args( $args ) {
541+
$args['largest'] = 22;
542+
$args['smallest'] = 8;
543+
$args['unit'] = 'pt';
544+
$args['format'] = 'list';
545+
546+
return $args;
547+
}
548+
add_filter( 'widget_tag_cloud_args', 'twentyfourteen_widget_tag_cloud_args' );
549+
550+
530551
// Implement Custom Header features.
531552
require get_template_directory() . '/inc/custom-header.php';
532553

src/wp-content/themes/twentyfourteen/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,14 @@ a.post-thumbnail:hover {
25832583
padding-bottom: 0;
25842584
}
25852585

2586+
.tagcloud ul {
2587+
list-style-type: none;
2588+
}
2589+
2590+
.tagcloud ul li {
2591+
display: inline-block;
2592+
}
2593+
25862594
/* Recent Posts Widget */
25872595

25882596
.widget_recent_entries .post-date {

src/wp-content/themes/twentyseventeen/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ function twentyseventeen_front_page_template( $template ) {
542542
add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' );
543543

544544
/**
545-
* Modify tag cloud widget arguments to display all tags in the same font size
545+
* Modifies tag cloud widget arguments to display all tags in the same font size
546546
* and use list format for better accessibility.
547547
*
548548
* @since Twenty Seventeen 1.4
@@ -555,6 +555,7 @@ function twentyseventeen_widget_tag_cloud_args( $args ) {
555555
$args['smallest'] = 1;
556556
$args['unit'] = 'em';
557557
$args['format'] = 'list';
558+
558559
return $args;
559560
}
560561
add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' );

src/wp-content/themes/twentyseventeen/inc/template-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function twentyseventeen_entry_footer() {
8484
echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
8585
}
8686

87-
if ( $tags_list ) {
87+
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
8888
echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
8989
}
9090

src/wp-content/themes/twentysixteen/functions.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,20 @@ function twentysixteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
415415
add_filter( 'wp_get_attachment_image_attributes', 'twentysixteen_post_thumbnail_sizes_attr', 10 , 3 );
416416

417417
/**
418-
* Modifies tag cloud widget arguments to have all tags in the widget same font size.
418+
* Modifies tag cloud widget arguments to display all tags in the same font size
419+
* and use list format for better accessibility.
419420
*
420421
* @since Twenty Sixteen 1.1
421422
*
422423
* @param array $args Arguments for tag cloud widget.
423-
* @return array A new modified arguments.
424+
* @return array The filtered arguments for tag cloud widget.
424425
*/
425426
function twentysixteen_widget_tag_cloud_args( $args ) {
426-
$args['largest'] = 1;
427+
$args['largest'] = 1;
427428
$args['smallest'] = 1;
428-
$args['unit'] = 'em';
429+
$args['unit'] = 'em';
430+
$args['format'] = 'list';
431+
429432
return $args;
430433
}
431434
add_filter( 'widget_tag_cloud_args', 'twentysixteen_widget_tag_cloud_args' );

0 commit comments

Comments
 (0)