<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[53706] trunk/src/wp-admin: Permalinks: Label and describe permalink settings fields.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53706">53706</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/53706","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>joedolson</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-07-15 22:40:03 +0000 (Fri, 15 Jul 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Permalinks: Label and describe permalink settings fields.
Restructure the permalink settings fields so URL formats are communicated to screen readers through `aria-describedby` relationships, avoid the usage of implicitly labeled input fields, labeling the custom permalink format correctly, and clarifying values. Make settings `table` element presentational.
Props rishishah, sabernhardt, kebbet.
Fixes <a href="https://core.trac.wordpress.org/ticket/55498">#55498</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincssformscss">trunk/src/wp-admin/css/forms.css</a></li>
<li><a href="#trunksrcwpadminoptionspermalinkphp">trunk/src/wp-admin/options-permalink.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincssformscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/forms.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/forms.css 2022-07-15 16:00:25 UTC (rev 53705)
+++ trunk/src/wp-admin/css/forms.css 2022-07-15 22:40:03 UTC (rev 53706)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1070,11 +1070,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> vertical-align: middle;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.form-table.permalink-structure .available-structure-tags {
+ margin-top: 8px;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .form-table.permalink-structure .available-structure-tags li {
</span><span class="cx" style="display: block; padding: 0 10px"> float: left;
</span><span class="cx" style="display: block; padding: 0 10px"> margin-right: 5px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.form-table.permalink-structure .structure-selection .row {
+ margin-bottom: 16px;
+}
+
+.form-table.permalink-structure .structure-selection .row > div {
+ max-width: calc(100% - 24px);
+ margin-left: 4px;
+ display: inline-flex;
+ flex-direction: column;
+}
+
+.form-table.permalink-structure .structure-selection .row label {
+ font-weight: 600;
+}
+
+.form-table.permalink-structure .structure-selection .row p {
+ margin-top: 0;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*------------------------------------------------------------------------------
</span><span class="cx" style="display: block; padding: 0 10px"> 21.0 - Network Admin
</span><span class="cx" style="display: block; padding: 0 10px"> ------------------------------------------------------------------------------*/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1577,14 +1600,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .form-table.permalink-structure td code {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin-left: 32px;
</del><span class="cx" style="display: block; padding: 0 10px"> display: inline-block;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .form-table.permalink-structure .structure-selection {
+ margin-top: 8px;
+ }
+
+ .form-table.permalink-structure .structure-selection .row > div {
+ max-width: calc(100% - 36px);
+ width: 100%;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .form-table.permalink-structure td input[type="text"] {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin-left: 32px;
</del><span class="cx" style="display: block; padding: 0 10px"> margin-top: 4px;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- width: 96%;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .form-table input.regular-text {
</span></span></pre></div>
<a id="trunksrcwpadminoptionspermalinkphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/options-permalink.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/options-permalink.php 2022-07-15 16:00:25 UTC (rev 53705)
+++ trunk/src/wp-admin/options-permalink.php 2022-07-15 22:40:03 UTC (rev 53706)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -235,103 +235,130 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 3 => $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
</span><span class="cx" style="display: block; padding: 0 10px"> 4 => $prefix . '/%postname%/',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+$inputs = array(
+ 0 => array(
+ 'id' => 'plain',
+ 'label' => __( 'Plain' ),
+ 'example' => get_option( 'home' ) . '/?p=123',
+ 'value' => $structures[0],
+ ),
+ 1 => array(
+ 'id' => 'day-name',
+ 'label' => __( 'Day and name' ),
+ 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . gmdate( 'd' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
+ 'value' => $structures[1],
+ ),
+ 2 => array(
+ 'id' => 'month-name',
+ 'label' => __( 'Month and name' ),
+ 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
+ 'value' => $structures[2],
+ ),
+ 3 => array(
+ 'id' => 'day-numeric',
+ 'label' => __( 'Numeric' ),
+ 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/123',
+ 'value' => $structures[3],
+ ),
+ 4 => array(
+ 'id' => 'post-name',
+ 'label' => __( 'Post name' ),
+ 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
+ 'value' => $structures[4],
+ ),
+);
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <h2 class="title"><?php _e( 'Common Settings' ); ?></h2>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<table class="form-table permalink-structure">
- <tr>
- <th scope="row"><label><input name="selection" type="radio" value="" <?php checked( '', $permalink_structure ); ?> /> <?php _e( 'Plain' ); ?></label></th>
- <td><code><?php echo get_option( 'home' ); ?>/?p=123</code></td>
- </tr>
- <tr>
- <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[1] ); ?>" <?php checked( $structures[1], $permalink_structure ); ?> /> <?php _e( 'Day and name' ); ?></label></th>
- <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . gmdate( 'd' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
- </tr>
- <tr>
- <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[2] ); ?>" <?php checked( $structures[2], $permalink_structure ); ?> /> <?php _e( 'Month and name' ); ?></label></th>
- <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
- </tr>
- <tr>
- <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[3] ); ?>" <?php checked( $structures[3], $permalink_structure ); ?> /> <?php _e( 'Numeric' ); ?></label></th>
- <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/123'; ?></code></td>
- </tr>
- <tr>
- <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[4] ); ?>" <?php checked( $structures[4], $permalink_structure ); ?> /> <?php _e( 'Post name' ); ?></label></th>
- <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
- </tr>
- <tr>
- <th scope="row">
- <label><input name="selection" id="custom_selection" type="radio" value="custom" <?php checked( ! in_array( $permalink_structure, $structures, true ) ); ?> />
- <?php _e( 'Custom Structure' ); ?>
- </label>
- </th>
- <td>
- <code><?php echo get_option( 'home' ) . $blog_prefix; ?></code>
- <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr( $permalink_structure ); ?>" class="regular-text code" />
- <div class="available-structure-tags hide-if-no-js">
- <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
- <?php
- $available_tags = array(
- /* translators: %s: Permalink structure tag. */
- 'year' => __( '%s (The year of the post, four digits, for example 2004.)' ),
- /* translators: %s: Permalink structure tag. */
- 'monthnum' => __( '%s (Month of the year, for example 05.)' ),
- /* translators: %s: Permalink structure tag. */
- 'day' => __( '%s (Day of the month, for example 28.)' ),
- /* translators: %s: Permalink structure tag. */
- 'hour' => __( '%s (Hour of the day, for example 15.)' ),
- /* translators: %s: Permalink structure tag. */
- 'minute' => __( '%s (Minute of the hour, for example 43.)' ),
- /* translators: %s: Permalink structure tag. */
- 'second' => __( '%s (Second of the minute, for example 33.)' ),
- /* translators: %s: Permalink structure tag. */
- 'post_id' => __( '%s (The unique ID of the post, for example 423.)' ),
- /* translators: %s: Permalink structure tag. */
- 'postname' => __( '%s (The sanitized post title (slug).)' ),
- /* translators: %s: Permalink structure tag. */
- 'category' => __( '%s (Category slug. Nested sub-categories appear as nested directories in the URL.)' ),
- /* translators: %s: Permalink structure tag. */
- 'author' => __( '%s (A sanitized version of the author name.)' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<table class="form-table permalink-structure" role="presentation">
+ <tbody>
+ <tr>
+ <th scope="row"><?php _e( 'Permalink structure' ); ?></th>
+ <td>
+ <fieldset class="structure-selection">
+ <legend class="screen-reader-text"><?php _e( 'Permalink structure' ); ?></legend>
+ <?php
+ foreach ( $inputs as $structure_id => $structure_values ) {
+ $input_markup = '<div class="row">';
+ $input_markup .= '<input id="permalink-input-' . $structure_values['id'] . '" name="selection" aria-describedby="permalink-' . $structure_values['id'] . '" type="radio" value="' . $structure_values['value'] . '" ' . checked( $structure_values['value'], $permalink_structure, false ) . ' />';
+ $input_markup .= '<div><label for="permalink-input-' . $structure_values['id'] . '">' . $structure_values['label'] . '</label>';
+ $input_markup .= '<p><code id="permalink-' . $structure_values['id'] . '">' . $structure_values['example'] . '</code></p>';
+ $input_markup .= '</div>';
+ $input_markup .= '</div>';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Filters the list of available permalink structure tags on the Permalinks settings page.
- *
- * @since 4.9.0
- *
- * @param string[] $available_tags An array of key => value pairs of available permalink structure tags.
- */
- $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo $input_markup;
+ }
+ ?>
+ <div class="row">
+ <input id="custom_selection" name="selection" type="radio" value="custom" <?php checked( ! in_array( $permalink_structure, $structures, true ) ); ?> /><div><label for="custom_selection"><?php _e( 'Custom Structure' ); ?></label>
+ <p><label for="permalink_structure" class="screen-reader-text"><?php _e( 'Customize permalink structure by selecting available tags' ); ?></label><span class="code"><code id="permalink-custom"><?php echo get_option( 'home' ) . $blog_prefix; ?></code><input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr( $permalink_structure ); ?>" aria-describedby="permalink-custom" class="regular-text code" /></span></p>
+ <div class="available-structure-tags hide-if-no-js">
+ <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
+ <?php
+ $available_tags = array(
+ /* translators: %s: Permalink structure tag. */
+ 'year' => __( '%s (The year of the post, four digits, for example 2004.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'monthnum' => __( '%s (Month of the year, for example 05.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'day' => __( '%s (Day of the month, for example 28.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'hour' => __( '%s (Hour of the day, for example 15.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'minute' => __( '%s (Minute of the hour, for example 43.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'second' => __( '%s (Second of the minute, for example 33.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'post_id' => __( '%s (The unique ID of the post, for example 423.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'postname' => __( '%s (The sanitized post title (slug).)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'category' => __( '%s (Category slug. Nested sub-categories appear as nested directories in the URL.)' ),
+ /* translators: %s: Permalink structure tag. */
+ 'author' => __( '%s (A sanitized version of the author name.)' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* translators: %s: Permalink structure tag. */
- $structure_tag_added = __( '%s added to permalink structure' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters the list of available permalink structure tags on the Permalinks settings page.
+ *
+ * @since 4.9.0
+ *
+ * @param string[] $available_tags An array of key => value pairs of available permalink structure tags.
+ */
+ $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* translators: %s: Permalink structure tag. */
- $structure_tag_already_used = __( '%s (already used in permalink structure)' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* translators: %s: Permalink structure tag. */
+ $structure_tag_added = __( '%s added to permalink structure' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $available_tags ) ) :
- ?>
- <p><?php _e( 'Available tags:' ); ?></p>
- <ul role="list">
- <?php
- foreach ( $available_tags as $tag => $explanation ) {
- ?>
- <li>
- <button type="button"
- class="button button-secondary"
- aria-label="<?php echo esc_attr( sprintf( $explanation, $tag ) ); ?>"
- data-added="<?php echo esc_attr( sprintf( $structure_tag_added, $tag ) ); ?>"
- data-used="<?php echo esc_attr( sprintf( $structure_tag_already_used, $tag ) ); ?>">
- <?php echo '%' . $tag . '%'; ?>
- </button>
- </li>
- <?php
- }
- ?>
- </ul>
- <?php endif; ?>
- </div>
- </td>
- </tr>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* translators: %s: Permalink structure tag. */
+ $structure_tag_already_used = __( '%s (already used in permalink structure)' );
+
+ if ( ! empty( $available_tags ) ) :
+ ?>
+ <fieldset>
+ <legend><?php _e( 'Available tags:' ); ?></legend>
+ <ul role="list">
+ <?php foreach ( $available_tags as $tag => $explanation ) : ?>
+ <li>
+ <button type="button"
+ class="button button-secondary"
+ aria-label="<?php echo esc_attr( sprintf( $explanation, $tag ) ); ?>"
+ data-added="<?php echo esc_attr( sprintf( $structure_tag_added, $tag ) ); ?>"
+ data-used="<?php echo esc_attr( sprintf( $structure_tag_already_used, $tag ) ); ?>">
+ <?php echo '%' . $tag . '%'; ?>
+ </button>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+ </fieldset>
+ <?php endif; ?>
+ </div>
+ </div>
+ </div>
+ </fieldset>
+ </td>
+ </tr>
+ </tbody>
</ins><span class="cx" style="display: block; padding: 0 10px"> </table>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <h2 class="title"><?php _e( 'Optional' ); ?></h2>
</span></span></pre>
</div>
</div>
</body>
</html>