Linux 软件免费装
Banner图

4WP Style Switcher

开发者 4wpdev
更新时间 2026年6月14日 22:34
PHP版本: 7.4 及以上
WordPress版本: 7.0
版权: GPLv2 or later
版权网址: 版权信息

标签

dark mode full-site-editing theme.json block-theme style variations

下载

1.0.1

详情介绍:

4WP Style Switcher reads style variations from the active block theme (theme.json and /styles/*.json). A plugin by 4wp.dev. 4WP is our project brand; the letters "WP" appear only as part of that brand name, not as a reference to WordPress. This plugin is not affiliated with, endorsed, or sponsored by WordPress. Source code and releases: github.com/4wpdev/4wp-style-switcher Development Human-readable PHP source is in the public GitHub repository above. The plugin ZIP includes src/ (PSR-4 autoload via src/Autoload.php when vendor/ is absent). No npm build step — front-end scripts ship as plain JS in assets/. Live demo (WordPress Playground): https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/4wpdev/4wp-style-switcher/v1.0.0/.wordpress-org/assets/blueprints/blueprint.json The demo site Style Switcher uses Twenty Twenty-Five: About, Morning, Afternoon, and Evening pages with per-page styles, A/B light vs dark, a bottom-right visitor switcher, and Light/Dark in the header and footer menus. Page style (editor) — pick a variation for a page; optionally lock it so visitors cannot override it. Frontend switcher — visitors choose from allowed variations; the choice is stored in localStorage and synced to a cookie for server-side rendering. Light / Dark (navigation block) — add the Light/Dark block inside Navigation; map two variations (sun/moon icons). A/B testing — split new visitors between two variations; daily aggregate stats monitor the traffic split. Privacy When the visitor switcher or A/B testing is enabled, the plugin may store the selected style variation in a browser cookie (forwp_ss_style) and in localStorage on the visitor device. No personal data is sent to third-party services. A/B stats are aggregated counts stored in your WordPress database.

安装:

  1. Upload and activate the plugin.
  2. Go to Settings → 4WP Style Switcher.
  3. On Variations, check which style variations visitors may use.
  4. Under General, set the default variation and optional Light/Dark mapping.
  5. Edit a page → Page style panel to assign or lock a variation.
  6. In the site editor, insert Light / Dark inside the Navigation block.

屏幕截图:

  • Settings — Variations tab (allowed style variations).
  • Frontend — floating style switcher and menu Light/Dark toggle on Twenty Twenty-Five.

升级注意事项:

1.0.1 Review T1: Plugin URI points to 4wp.dev; removed Playground URL constant from plugin PHP (demo link remains in readme only). 1.0.0 First WordPress.org release. Plugin Check fixes, readme trademark disclaimer, Playground blueprint v1.0.0. 0.2.5 Performance: request-level caching for style resolution and theme.json variation lookups. 0.2.4 Playground demo: per-page theme.json titles, Afternoon locked, Light/Dark disabled when locked. 0.2.3 0.2.1 Fixes style switching on WordPress Playground (HTTPS cookie + dynamic demo slugs). 0.2.0 First feature release: visitor switcher, Light/Dark navigation block, A/B stats, and Playground demo.

其他记录:

Hooks (developers)

常见问题:

Which themes are supported?

Block themes (FSE) that ship style variations under the theme’s /styles/ directory.

Where is the Playground demo configured?

In the GitHub repository: playground/setup.php and .wordpress-org/assets/blueprints/blueprint.json.

Does the floating switcher list every theme variation?

It lists variations allowed on the Variations settings tab. The menu Light/Dark block uses only the two variations mapped under General.

更新日志:

1.0.1 1.0.0 0.2.5 0.2.4 0.2.3 0.2.2 0.2.1 0.2.0 0.1.0