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:
parent
9683101398
commit
0999a01956
@ -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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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 ); ?>">
|
||||||
|
@ -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() ) {
|
||||||
|
@ -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';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user