4WP Style Switcher

4WP Style Switcher

توسط

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.

Blocks

This plugin provides 1 block.

  • Light / Dark — menu toggle between two mapped theme style variations (sun/moon icons).Hooks (developers)

  • forwp_style_switcher_variations — filter theme variation list.

  • forwp_style_switcher_ab_assigned — after A/B cohort assignment.
  • forwp_style_switcher_analytics_track — analytics events.
  • forwp_style_switcher_ab_assignment_enabled — filter A/B assignment.
  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.

سوالات متداول

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.

تصویری برای این آیتم موجود نیست.
نظری برای این آیتم موجود نیست.
0 0 رای ها
امتیازدهی
اشتراک در
اطلاع از
0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
بازخورد (Feedback) های اینلاین
مشاهده همه دیدگاه ها
هیچ نسخه‌ای برای این آیتم موجود نیست.
بدون امتیاز

قیمت:

رایگان

نگارش

آخرین انتشار

21 خرداد 1405

آخرین بروزرسانی

7 روز پیش

نصب های فعال

-

نگارش وردپرس

وردپرس 6.4+

تست شده از نسخه

وردپرس 7.0

نگارش PHP

PHP 7.4+

نسخه ها

0 نسخه