WordPress.org

Make WordPress Core

Changeset 47223


Ignore:
Timestamp:
02/09/2020 08:42:26 PM (10 months ago)
Author:
jorbin
Message:

General: Fix HTML for get_calendar()

The <tfoot> element was allowed to precede the <tbody> element in HTML 5. However, that was changed in HTML 5.1 and <tfoot> must now follow <tbody>.

This removes the tfooot and instead uses a nav element for navigation between months.

Fixes: #39763
Props: isabel_brison, Harry Milatz, audrasjb, abhijitrakas, SergeyBiryukov

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r47221 r47223  
    21682168    </tr>
    21692169    </thead>
    2170 
    2171     <tfoot>
    2172     <tr>';
    2173 
    2174     if ( $previous ) {
    2175         $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
    2176             $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
    2177         '</a></td>';
    2178     } else {
    2179         $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    2180     }
    2181 
    2182     $calendar_output .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
    2183 
    2184     if ( $next ) {
    2185         $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
    2186             $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
    2187         ' &raquo;</a></td>';
    2188     } else {
    2189         $calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
    2190     }
    2191 
    2192     $calendar_output .= '
    2193     </tr>
    2194     </tfoot>
    2195 
    21962170    <tbody>
    21972171    <tr>';
     
    22612235        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
    22622236    }
    2263     $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
     2237    $calendar_output .= "\n\t</tr>\n\t</tbody>";
     2238
     2239    $calendar_output .= "\n\t</table>";
     2240
     2241    $calendar_output .= '<nav aria-label="' . __( 'Previous and next months' ) . '">';
     2242
     2243    if ( $previous ) {
     2244        $calendar_output .= "\n\t\t" . '<span id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
     2245            $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
     2246        '</a></span>';
     2247    } else {
     2248        $calendar_output .= "\n\t\t" . '<span id="prev">&nbsp;</span>';
     2249    }
     2250
     2251    $calendar_output .= "\n\t\t" . '<span class="pad">&nbsp;</span>';
     2252
     2253    if ( $next ) {
     2254        $calendar_output .= "\n\t\t" . '<span id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
     2255            $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
     2256        ' &raquo;</a></span>';
     2257    } else {
     2258        $calendar_output .= "\n\t\t" . '<span id="next" class="pad">&nbsp;</span>';
     2259    }
     2260
     2261    $calendar_output .= '
     2262    </nav>';
    22642263
    22652264    $cache[ $key ] = $calendar_output;
Note: See TracChangeset for help on using the changeset viewer.