Make WordPress Core

Ticket #43632: 43632.4.diff

File 43632.4.diff, 1.3 KB (added by audrasjb, 7 years ago)

Screen reader text + lang attribute if needed

  • src/wp-content/plugins/hello.php

    diff --git a/src/wp-content/plugins/hello.php b/src/wp-content/plugins/hello.php
    index 34e3b68..d35fee7 100644
    a b Dolly'll never go away again"; 
    5252// This just echoes the chosen line, we'll position it later
    5353function hello_dolly() {
    5454        $chosen = hello_dolly_get_lyric();
    55         echo "<p id='dolly'>$chosen</p>";
     55        $lang = "";
     56        if ( false === strpos( get_user_locale(), 'en_' ) ) {
     57                $lang = "lang='en'";
     58        }
     59        echo "<p id='dolly' $lang><span class='screen-reader-text'>Quote from Hello Dolly song:</span>$chosen</p>";
    5660}
    5761
    5862// Now we set that function up to execute when the admin_notices action is called
    add_action( 'admin_notices', 'hello_dolly' ); 
    6064
    6165// We need some CSS to position the paragraph
    6266function dolly_css() {
    63         // This makes sure that the positioning is also good for right-to-left languages
    64         $x = is_rtl() ? 'left' : 'right';
    65 
    6667        echo "
    6768        <style type='text/css'>
    6869        #dolly {
    69                 float: $x;
    70                 padding-$x: 15px;
    71                 padding-top: 5px;               
     70                float: right;
     71                padding: 6px 10px 4px 0;
    7272                margin: 0;
     73                line-height: 1.7;
    7374                font-size: 11px;
    7475        }
     76        body.rtl #dolly {
     77                float: left;
     78                padding: 6px 0 4px 10px;
     79        }
     80        @media screen and (max-width: 782px) {
     81                #dolly {
     82                        float: none;
     83                }
     84        }
    7585        </style>
    7686        ";
    7787}
    7888
    7989add_action( 'admin_head', 'dolly_css' );
    80 
    81