Make WordPress Core


Ignore:
Timestamp:
07/09/2020 11:27:28 PM (4 years ago)
Author:
whyisjake
Message:

Administration: Remove multiple viewport meta tags from mobile pages.

In addition, add the wp_admin_viewport_meta() function, paired to the admin_viewport_meta filter to control attributes of the meta tag.

Fixes #47369.
Props BettyJJ, mukesh27, SergeyBiryukov, ajayghaghretiya1, msaggiorato, talldanwp, davidbaumwald, donmhico, audrasjb.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r48345 r48412  
    10151015
    10161016/**
    1017  * @since 3.3.0
    1018  */
    1019 function _ipad_meta() {
    1020     if ( wp_is_mobile() ) {
    1021         ?>
    1022         <meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1">
    1023         <?php
    1024     }
     1017 * Displays the viewport meta in the admin.
     1018 *
     1019 * @since 5.5.0
     1020 */
     1021function wp_admin_viewport_meta() {
     1022    /**
     1023     * Filters the viewport meta in the admin.
     1024     *
     1025     * @since 5.5.0
     1026     *
     1027     * @param string $viewport_meta The viewport meta.
     1028     */
     1029    $viewport_meta = apply_filters( 'admin_viewport_meta', 'width=device-width,initial-scale=1.0' );
     1030    if ( empty( $viewport_meta ) ) {
     1031        return;
     1032    }
     1033    echo '<meta name="viewport" content="' . esc_attr( $viewport_meta ) . '">';
     1034}
     1035
     1036/**
     1037 * Viewport meta for mobile in customize.
     1038 *
     1039 * Hooked to the {@see 'admin_viewport_meta'} filter.
     1040 *
     1041 * @since 5.5.0
     1042 */
     1043function _customizer_mobile_viewport_meta( $content ) {
     1044    return trim( $content, ',' ) . ',minimum-scale=0.5,maximum-scale=1.2';
    10251045}
    10261046
Note: See TracChangeset for help on using the changeset viewer.