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.



git-svn-id: https://develop.svn.wordpress.org/trunk@48412 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock 2020-07-09 23:27:28 +00:00
parent 9683101398
commit 0999a01956
4 changed files with 36 additions and 12 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'] ); ?>',
isRtl = <?php echo (int) is_rtl(); ?>;
</script>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<?php
/**

View File

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