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.
Built from https://develop.svn.wordpress.org/trunk@41756


git-svn-id: http://core.svn.wordpress.org/trunk@41590 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2017-10-04 23:53:47 +00:00
parent 37aa531cd4
commit 203b275658
21 changed files with 205 additions and 15 deletions

View File

@ -743,3 +743,22 @@ function twentyeleven_get_gallery_images() {
return $images;
}
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Eleven 2.7
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentyeleven_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyeleven_widget_tag_cloud_args' );

View File

@ -1922,7 +1922,6 @@ section.ephemera .entry-title a span {
}
/* Calendar Widget */
.widget_calendar #wp-calendar {
color: #555;
width: 95%;
@ -1952,7 +1951,6 @@ section.ephemera .entry-title a span {
}
/* Text Widget */
.widget_text ul,
.widget_text ol {
margin: 0 0 1.625em 2.5em;
@ -1964,6 +1962,15 @@ section.ephemera .entry-title a span {
margin-bottom: 0;
}
/* Tag Cloud Widget */
.tagcloud ul {
list-style-type: none;
}
.tagcloud ul li {
display: inline-block;
}
/* =Comments
----------------------------------------------- */
@ -2332,7 +2339,6 @@ p.comment-form-comment {
font-weight: bold;
}
/* =Responsive Structure
----------------------------------------------- */

View File

@ -385,6 +385,26 @@ function twentyfifteen_search_form_modify( $html ) {
}
add_filter( 'get_search_form', 'twentyfifteen_search_form_modify' );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Fifteen 1.9
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentyfifteen_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyfifteen_widget_tag_cloud_args' );
/**
* Implement the Custom Header feature.
*

View File

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

View File

@ -1559,6 +1559,13 @@ img.aligncenter {
margin-left: 1.6em;
}
.tagcloud ul {
list-style-type: none;
}
.tagcloud ul li {
display: inline-block;
}
/**
* 12.0 Content

View File

@ -527,6 +527,27 @@ function twentyfourteen_wp_title( $title, $sep ) {
}
add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Fourteen 2.1
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentyfourteen_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyfourteen_widget_tag_cloud_args' );
// Implement Custom Header features.
require get_template_directory() . '/inc/custom-header.php';

View File

@ -2583,6 +2583,14 @@ a.post-thumbnail:hover {
padding-bottom: 0;
}
.tagcloud ul {
list-style-type: none;
}
.tagcloud ul li {
display: inline-block;
}
/* Recent Posts Widget */
.widget_recent_entries .post-date {

View File

@ -542,7 +542,7 @@ function twentyseventeen_front_page_template( $template ) {
add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' );
/**
* Modify tag cloud widget arguments to display all tags in the same font size
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Seventeen 1.4
@ -555,6 +555,7 @@ function twentyseventeen_widget_tag_cloud_args( $args ) {
$args['smallest'] = 1;
$args['unit'] = 'em';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' );

View File

@ -84,7 +84,7 @@ function twentyseventeen_entry_footer() {
echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
}
if ( $tags_list ) {
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
}

View File

@ -415,17 +415,20 @@ function twentysixteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
add_filter( 'wp_get_attachment_image_attributes', 'twentysixteen_post_thumbnail_sizes_attr', 10 , 3 );
/**
* Modifies tag cloud widget arguments to have all tags in the widget same font size.
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Sixteen 1.1
*
* @param array $args Arguments for tag cloud widget.
* @return array A new modified arguments.
* @return array The filtered arguments for tag cloud widget.
*/
function twentysixteen_widget_tag_cloud_args( $args ) {
$args['largest'] = 1;
$args['largest'] = 1;
$args['smallest'] = 1;
$args['unit'] = 'em';
$args['unit'] = 'em';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentysixteen_widget_tag_cloud_args' );

View File

@ -101,7 +101,7 @@ function twentysixteen_entry_taxonomies() {
}
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
if ( $tags_list ) {
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Tags', 'Used before tag names.', 'twentysixteen' ),
$tags_list

View File

@ -315,6 +315,10 @@ input[type="search"].search-field {
margin-left: 0.1875em;
}
.tagcloud ul {
margin-right: 0;
}
/**
* 8.0 - Content

View File

@ -1514,6 +1514,15 @@ blockquote:after,
padding: 0.5625em 0.4375em 0.5em;
}
.tagcloud ul {
list-style-type: none;
margin-left: 0;
}
.tagcloud ul li {
display: inline-block;
}
.tagcloud a:hover,
.tagcloud a:focus {
border-color: #007acc;

View File

@ -536,7 +536,7 @@ if ( ! function_exists( 'twentyten_posted_in' ) ) :
function twentyten_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
if ( $tag_list && ! is_wp_error( $tag_list ) ) {
$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
@ -593,3 +593,22 @@ function twentyten_get_gallery_images() {
return $images;
}
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Ten 2.4
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentyten_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyten_widget_tag_cloud_args' );

View File

@ -270,6 +270,11 @@ div.menu li{
margin-right: 1.3em;
}
#main .widget-area .tagcloud ul,
.widget-area .tagcloud ul {
margin-right: 0;
}
/* =Footer
-------------------------------------------------------------- */
#site-generator {

View File

@ -1238,6 +1238,13 @@ h3#reply-title {
.widget_media_video video {
max-width: 100%;
}
.tagcloud ul {
list-style-type: none;
margin-left: 0 !important;
}
.tagcloud ul li {
display: inline-block;
}
/* Main sidebars */
#main .widget-area ul {

View File

@ -615,3 +615,22 @@ function twentythirteen_customize_preview_js() {
wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true );
}
add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Thirteen 2.3
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentythirteen_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentythirteen_widget_tag_cloud_args' );

View File

@ -2562,7 +2562,6 @@ footer.entry-meta {
}
/* Text widget */
.widget_text ul,
.widget_text ol {
padding-left: 20px;
@ -2586,6 +2585,16 @@ footer.entry-meta {
list-style: decimal;
}
/* Tag Cloud widget */
.tagcloud ul {
list-style-type: none;
}
.tagcloud ul li {
display: inline-block;
padding: 0;
}
/**
* 7.0 Footer
* ----------------------------------------------------------------------------

View File

@ -559,3 +559,23 @@ function twentytwelve_customize_preview_js() {
wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true );
}
add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Twelve 2.4
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentytwelve_widget_tag_cloud_args( $args ) {
$args['largest'] = 22;
$args['smallest'] = 8;
$args['unit'] = 'pt';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentytwelve_widget_tag_cloud_args' );

View File

@ -1450,6 +1450,20 @@ a.comment-edit-link:hover {
display: block;
text-align: right;
}
.tagcloud ul {
list-style-type: none;
}
.tagcloud ul li {
display: inline-block;
}
.widget-area .widget.widget_tag_cloud li {
line-height: 1;
}
.template-front-page .widget-area .widget.widget_tag_cloud li {
margin: 0;
}
/* =Plugins
----------------------------------------------- */
@ -1460,7 +1474,6 @@ img#wpstats {
margin: 0 auto 1.714285714rem;
}
/* =Media queries
-------------------------------------------------------------- */

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41755';
$wp_version = '4.9-alpha-41756';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.