Make WordPress Core


Ignore:
Timestamp:
07/10/2020 12:48:54 AM (4 years ago)
Author:
whyisjake
Message:

Sitemaps: Add better support for RTL sites.

While the URLs are intended to be machine readable, they should always be LTR, while other data would be RTL in the sitemap.

Fixes #50449.

Props joyously, SergeyBiryukov, pbiron. apedog, ramiy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php

    r48098 r48414  
    249249     */
    250250    public function get_stylesheet_css() {
    251         $css = '
    252             body {
    253                 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    254                 color: #444;
    255             }
    256 
    257             #sitemap__table {
    258                 border: solid 1px #ccc;
    259                 border-collapse: collapse;
    260             }
    261 
    262             #sitemap__table tr th {
    263                 text-align: left;
    264             }
    265 
    266             #sitemap__table tr td,
    267             #sitemap__table tr th {
    268                 padding: 10px;
    269             }
    270 
    271             #sitemap__table tr:nth-child(odd) td {
    272                 background-color: #eee;
    273             }
    274 
    275             a:hover {
    276                 text-decoration: none;
    277             }';
     251        $text_align = is_rtl() ? 'right' : 'left';
     252
     253        $css = <<<EOF
     254       
     255                    body {
     256                        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
     257                        color: #444;
     258                    }
     259                   
     260                    #sitemap__table {
     261                        border: solid 1px #ccc;
     262                        border-collapse: collapse;
     263                    }
     264                   
     265                    #sitemap__table tr td.loc {
     266                        /*
     267                         * URLs should always be LTR.
     268                         * see https://core.trac.wordpress.org/ticket/16834 and
     269                         * https://core.trac.wordpress.org/ticket/49949
     270                         */
     271                        direction: ltr;
     272                    }
     273                   
     274                    #sitemap__table tr th {
     275                        text-align: {$text_align};
     276                    }
     277                   
     278                    #sitemap__table tr td,
     279                    #sitemap__table tr th {
     280                        padding: 10px;
     281                    }
     282                   
     283                    #sitemap__table tr:nth-child(odd) td {
     284                        background-color: #eee;
     285                    }
     286                   
     287                    a:hover {
     288                        text-decoration: none;
     289                    }
     290EOF;
    278291
    279292        /**
Note: See TracChangeset for help on using the changeset viewer.