Make WordPress Core

Ticket #29872: 29872.4.patch

File 29872.4.patch, 4.2 KB (added by joedolson, 9 years ago)

Add ARIA announcement

  • wp-admin/css/forms.css

     
    925925        vertical-align: middle;
    926926}
    927927
     928.form-table.permalink-structure .available-shortcode-tags li {
     929        float: left;
     930        margin-right: 5px;
     931}
     932
     933.form-table.permalink-structure .available-shortcode-tags button {
     934        background: none;
     935        border: 1px solid transparent;
     936        padding: 0;
     937        outline: none;
     938}
     939
     940.form-table.permalink-structure .available-shortcode-tags button:focus {
     941        border-color: #5b9dd9;
     942        -webkit-box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 );
     943        box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 );
     944}
     945
     946.form-table.permalink-structure .available-shortcode-tags code {
     947        margin: 0;
     948        cursor: pointer;
     949}
     950
    928951/*------------------------------------------------------------------------------
    929952  21.0 - Network Admin
    930953------------------------------------------------------------------------------*/
  • wp-admin/js/common.js

     
    175175        panel.addClass('active').show();
    176176});
    177177
     178/**
     179 * Custom permalink structures.
     180 */
     181$( '.form-table.permalink-structure .available-shortcode-tags button' ).on( 'click', function() {
     182        var $permalinkStructure = $( '#permalink_structure' ),
     183            textToAppend        = $( this ).find( 'code' ).text() + '/';
     184
     185        $( '#custom_selection' ).prop( 'checked', true );
     186
     187        if ( '/' !== $permalinkStructure.val().substr( -1 ) ) {
     188                textToAppend = '/' + textToAppend;
     189        }
     190        $permalinkStructure.val( $( '#permalink_structure' ).val() + textToAppend );
     191       
     192        var textToAnnounce = $( this ).attr( 'data-added' );
     193        $( '#custom_selection_updated' ).text( textToAnnounce );
     194} )
     195
    178196$document.ready( function() {
    179197        var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
    180198                lastClicked = false,
  • wp-admin/options-permalink.php

     
    206206                <td>
    207207                        <code><?php echo get_option('home') . $blog_prefix; ?></code>
    208208                        <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
     209                        <div class="available-shortcode-tags hide-if-no-js">
     210                                <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
     211                                <?php
     212                                $available_tags = array(
     213                                        '%year%'     => __( 'The year of the post, four digits, for example 2004' ),
     214                                        '%monthnum%' => __( 'Month of the year, for example 05' ),
     215                                        '%day%'      => __( 'Day of the month, for example 28' ),
     216                                        '%hour%'     => __( 'Hour of the day, for example 15' ),
     217                                        '%minute%'   => __( 'Minute of the hour, for example 43' ),
     218                                        '%second%'   => __( 'Second of the minute, for example 33' ),
     219                                        '%post_id%'  => __( 'The unique ID of the post, for example 423' ),
     220                                        '%postname%' => __( 'The sanitized post title (slug)' ),
     221                                        '%category%' => __( 'Category slug. Nested sub-categories appear as nested directories in the URI.' ),
     222                                        '%author%'   => __( 'A sanitized version of the author name.' ),
     223                                );
     224
     225                                /**
     226                                 * Filters the list of available permalink structure tags on the Permalinks settings page.
     227                                 *
     228                                 * @since 4.7.0
     229                                 *
     230                                 * @param array $available_tags A key => value pair of available permalink structure tags.
     231                                 */
     232                                $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
     233
     234                                if ( ! empty( $available_tags ) ) {
     235                                        echo '<p>';
     236                                        _e( 'Available tags:' );
     237                                        echo '</p>';
     238                                        echo '<ul>';
     239                                        foreach ( $available_tags as $tag => $explanation ) {
     240                                                $notification = esc_attr( sprintf( __( '%s added to permalink structure' ), $tag ) );
     241                                                printf( '<li><button type="button" data-added="%3$s"><code>%1$s</code><span class="screen-reader-text">%2$s</span></button></li>', $tag, $explanation, $notification );
     242                                        }
     243                                        echo '</ul>';
     244                                }
     245                                ?>
     246                        </div>
    209247                </td>
    210248        </tr>
    211249</table>