[wordpress插件] Customizer Responsive Server-Side Components Device PreviewCustomizer响应式服务器端组件设备预览

wordpress 插件 文章 2020-04-10 22:11 0 261 全屏看文

Read full writeup:


>Previewing Themes with Adaptive Designs in the Customizer.


This plugin extends the responsive device preview functionality in the customizer which was added in 4.5 (see #31195




In core when you change the previewed device it merely changes the dimensions of the preview, allowing you to simulate how the theme will appear on tablet or mobile screens.


What it does not do, however, is cause the preview to reload with the User-Agent overridden for the current device being previewed.

但是,它没有执行的操作是使预览重新加载,而 User-Agent 覆盖了当前正在预览的当前设备。

For themes that implement a responsive design this core behavior is just fine since changing the dimensions of the iframe will cause the appropriate media queries to apply.


However, if you have an adaptive design for your theme you won’t be able to see any server-side components that it may display when viewing a different device.


For example, on mobile devices a theme may want to skip outputting the sidebar altogether to save on bandwidth.


This plugin will ensure that the preview is refreshed when the previewed device is changed in addition to changing the preview window size.


It will pass a customize_previewed_device query parameter on the URL being previewed, and this parameter will be either desktop, tablet, or mobile<

它将在要预览的URL上传递 customize_previewed_device 查询参数,并且该参数将是 desktop tablet mobile <


/ code>。

The plugin will override the $_SERVER['HTTP_USER_AGENT'] to be a user agent representative of the supplied device type so that calls to wp_is_mobile(), jetpack_is_mobile(

插件将覆盖 $ _ SERVER ['HTTP_USER_AGENT'] 作为代表所提供设备类型的用户代理,以便调用 wp_is_mobile() jetpack_is_mobile(

), and Jetpack_User_Agent_Info::is_tablet() will all return the expected values based on the current previewed device.

Jetpack_User_Agent_Info :: is_tablet()都将基于当前预览的设备返回期望值。

Development of this plugin is done on GitHub.

此插件的开发在GitHub上 完成。

Pull requests welcome.


Please see issues reported there before going to the


"https://wordpress.org/support/plugin/customizer-responsive-device-preview">plugin forum.

“ https://wordpress.org/support/plugin/customizer-sensitive-device-preview“>插件论坛。