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.


Built from https://develop.svn.wordpress.org/trunk@48412


git-svn-id: http://core.svn.wordpress.org/trunk@48181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-07-09 23:29:08 +00:00
parent d322fb66de
commit 1158166d9c
5 changed files with 37 additions and 13 deletions

View File

@ -90,7 +90,6 @@ var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
isRtl = <?php echo (int) is_rtl(); ?>; isRtl = <?php echo (int) is_rtl(); ?>;
</script> </script>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<?php <?php
/** /**

View File

@ -132,10 +132,7 @@ $body_class = 'wp-core-ui wp-customizer js';
if ( wp_is_mobile() ) : if ( wp_is_mobile() ) :
$body_class .= ' mobile'; $body_class .= ' mobile';
add_filter( 'admin_viewport_meta', '_customizer_mobile_viewport_meta' );
?>
<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" />
<?php
endif; endif;
if ( $wp_customize->is_ios() ) { if ( $wp_customize->is_ios() ) {
@ -171,6 +168,13 @@ do_action( 'customize_controls_print_styles' );
* @since 3.4.0 * @since 3.4.0
*/ */
do_action( 'customize_controls_print_scripts' ); do_action( 'customize_controls_print_scripts' );
/**
* Fires when Customizer control scripts are printed.
*
* @since 5.5.0
*/
do_action( 'customize_controls_head' );
?> ?>
</head> </head>
<body class="<?php echo esc_attr( $body_class ); ?>"> <body class="<?php echo esc_attr( $body_class ); ?>">

View File

@ -44,7 +44,8 @@ add_action( 'login_init', 'wp_admin_headers' );
add_action( 'admin_head', 'wp_admin_canonical_url' ); add_action( 'admin_head', 'wp_admin_canonical_url' );
add_action( 'admin_head', 'wp_color_scheme_settings' ); add_action( 'admin_head', 'wp_color_scheme_settings' );
add_action( 'admin_head', 'wp_site_icon' ); add_action( 'admin_head', 'wp_site_icon' );
add_action( 'admin_head', '_ipad_meta' ); add_action( 'admin_head', 'wp_admin_viewport_meta' );
add_action( 'customize_controls_head', 'wp_admin_viewport_meta' );
// Prerendering. // Prerendering.
if ( ! is_customize_preview() ) { if ( ! is_customize_preview() ) {

View File

@ -1014,14 +1014,34 @@ function wp_color_scheme_settings() {
} }
/** /**
* @since 3.3.0 * Displays the viewport meta in the admin.
*
* @since 5.5.0
*/ */
function _ipad_meta() { function wp_admin_viewport_meta() {
if ( wp_is_mobile() ) { /**
?> * Filters the viewport meta in the admin.
<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1"> *
<?php * @since 5.5.0
*
* @param string $viewport_meta The viewport meta.
*/
$viewport_meta = apply_filters( 'admin_viewport_meta', 'width=device-width,initial-scale=1.0' );
if ( empty( $viewport_meta ) ) {
return;
} }
echo '<meta name="viewport" content="' . esc_attr( $viewport_meta ) . '">';
}
/**
* Viewport meta for mobile in customize.
*
* Hooked to the {@see 'admin_viewport_meta'} filter.
*
* @since 5.5.0
*/
function _customizer_mobile_viewport_meta( $content ) {
return trim( $content, ',' ) . ',minimum-scale=0.5,maximum-scale=1.2';
} }
/** /**

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-beta1-48411'; $wp_version = '5.5-beta1-48412';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.