WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/26/2016 05:58:34 PM (3 years ago)
Author:
afercia
Message:

Administration: Better accessibility for the "Post locked" indicator.

  • hides the locked icon from assistive technologies
  • adds hidden text to indicate the post is locked
  • moves the info about who's currently editing to the top of the title table cell

Props mariovalney.
Fixes #38185.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r38951 r38965  
    836836            ?></label>
    837837            <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
    838             <div class="locked-indicator"></div>
     838            <div class="locked-indicator">
     839                <span class="locked-indicator-icon" aria-hidden="true"></span>
     840                <span class="screen-reader-text"><?php
     841                printf(
     842                    /* translators: %s: post title */
     843                    __( '&#8220;%s&#8221; is locked' ),
     844                    _draft_or_post_title()
     845                );
     846                ?></span>
     847            </div>
    839848        <?php endif;
    840849    }
     
    891900        }
    892901
     902        $can_edit_post = current_user_can( 'edit_post', $post->ID );
     903
     904        if ( $can_edit_post && $post->post_status != 'trash' ) {
     905            $lock_holder = wp_check_post_lock( $post->ID );
     906
     907            if ( $lock_holder ) {
     908                $lock_holder = get_userdata( $lock_holder );
     909                $locked_avatar = get_avatar( $lock_holder->ID, 18 );
     910                $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
     911            } else {
     912                $locked_avatar = $locked_text = '';
     913            }
     914
     915            echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
     916        }
     917
    893918        $pad = str_repeat( '&#8212; ', $this->current_level );
    894919        echo "<strong>";
     
    908933        }
    909934
    910         $can_edit_post = current_user_can( 'edit_post', $post->ID );
    911935        $title = _draft_or_post_title();
    912936
     
    930954        }
    931955        echo "</strong>\n";
    932 
    933         if ( $can_edit_post && $post->post_status != 'trash' ) {
    934             $lock_holder = wp_check_post_lock( $post->ID );
    935 
    936             if ( $lock_holder ) {
    937                 $lock_holder = get_userdata( $lock_holder );
    938                 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
    939                 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
    940             } else {
    941                 $locked_avatar = $locked_text = '';
    942             }
    943 
    944             echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
    945         }
    946956
    947957        if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) {
Note: See TracChangeset for help on using the changeset viewer.