Make WordPress Core

Changeset 48412


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.

Location:
trunk/src/wp-admin
Files:
4 edited

Legend:

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

    r48083 r48412  
    9191    isRtl = <?php echo (int) is_rtl(); ?>;
    9292</script>
    93 <meta name="viewport" content="width=device-width,initial-scale=1.0">
    9493<?php
    9594
  • trunk/src/wp-admin/customize.php

    r48111 r48412  
    133133if ( wp_is_mobile() ) :
    134134    $body_class .= ' mobile';
    135 
    136     ?>
    137     <meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" />
    138     <?php
     135    add_filter( 'admin_viewport_meta', '_customizer_mobile_viewport_meta' );
    139136endif;
    140137
     
    172169 */
    173170do_action( 'customize_controls_print_scripts' );
     171
     172/**
     173 * Fires when Customizer control scripts are printed.
     174 *
     175 * @since 5.5.0
     176 */
     177do_action( 'customize_controls_head' );
    174178?>
    175179</head>
  • trunk/src/wp-admin/includes/admin-filters.php

    r48288 r48412  
    4545add_action( 'admin_head', 'wp_color_scheme_settings' );
    4646add_action( 'admin_head', 'wp_site_icon' );
    47 add_action( 'admin_head', '_ipad_meta' );
     47add_action( 'admin_head', 'wp_admin_viewport_meta' );
     48add_action( 'customize_controls_head', 'wp_admin_viewport_meta' );
    4849
    4950// Prerendering.
  • 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.