內容簡介
閱讀完整介紹: 在 Customizer 中預覽自適應設計主題。
此外掛擴充了在 4.5 版本新增的 Customizer 響應式裝置預覽功能(請見 #31195)。在核心功能中,當您變更所預覽的裝置時,僅會更改預覽的尺寸,允許您模擬主題在平板電腦或行動裝置屏幕上的外觀,但它並未觸發預覽重新載入,並以當前預覽的裝置偽裝 User-Agent。對於實現響應式設計的主題,這種核心行為很好用,因為改變 iframe 的尺寸將導致適當的媒體查詢適用。然而,如果您的主題採用了自適應設計,那麼您將無法看到它在不同設備上顯示的任何服務端組件。例如,在行動裝置上,主題可能會希望完全跳過輸出側邊欄以節省頻寬。
此外掛將確保當更改預覽裝置時,預覽被重新加載並更改預覽窗口大小。它會在正在預覽的 URL 中傳遞一個 customize_previewed_device 查詢參數,此參數將是 desktop、tablet 或 mobile 中的一個。此外掛將覆蓋 $_SERVER['HTTP_USER_AGENT'] 以成為所提供裝置類型的用戶代理,因此對 wp_is_mobile()、jetpack_is_mobile() 和 Jetpack_User_Agent_Info::is_tablet() 的呼叫都會根據當前預覽的裝置類型返回預期值。
此外掛的開發在 GitHub 上進行。歡迎提交拉取請求。請先查看報告的 問題,再前往 此外掛論壇。
外掛標籤
開發者團隊
② 後台搜尋「Customizer Responsive Server-Side Components Device Preview」→ 直接安裝(推薦)
原文外掛簡介
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. 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. 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(), and Jetpack_User_Agent_Info::is_tablet() will all return the expected values based on the current previewed device.
Development of this plugin is done on GitHub. Pull requests welcome. Please see issues reported there before going to the plugin forum.
