# Slim Mobile Theme Switcher
Serve a lightweight mobile theme to phones while keeping desktops on your primary theme. Includes dedicated tablet routing.

* **Contributors:** sethsm
* **Tags:** mobile, theme switcher, device theme, responsive, mobile theme
* **Requires at least:** 5.8
* **Tested up to:** 7.0
* **Stable tag:** 1.1.0
* **Requires PHP:** 7.4
* **License:** GPLv2 or later
* **License URI:** http://www.gnu.org/licenses/gpl-2.0.html
* **Donate link:** https://www.paypal.com/donate/?hosted_button_id=M3B2Q94PGVVWL
* **Plugin URI:**  https://www.sethcreates.com/plugins-for-wordpress/slim-mobile-theme-switcher/
* **Author URI:**  https://www.sethcreates.com/plugins-for-wordpress/

## Description

Ever wanted to serve a dedicated theme to visitors on handheld devices instead of a theme that is fine-tuned for big screen traffic? 

Slim Mobile Theme Switcher is a highly optimized, lightweight plugin designed for websites that need to serve a different theme to mobile devices while preserving the primary desktop experience. 

Instead of relying on clunky, resource-heavy device detection libraries, this plugin uses streamlined, modern user-agent detection to instantly route users to the correct theme before the page even loads.

## Key Features
* **Three-way Theme Routing:** Serve up to three different themes simultaneously. Set one theme for Mobile Phones, one for Desktops, and optionally enable a dedicated theme specifically for Tablets (iPads/Android tablets).
* **True Mobile Detection:** Uses refined regex to separate small-screen phones from tablets (iPads/Android tablets).
* **Zero-Friction Setup:** Select your themes from a simple dropdown menu. No coding required.
* **Manual Overrides:** Allow users to manually switch between views using `?theme=handheld` or `?theme=active` or `?theme=tablet`.
* **Persistent Choice:** Activating the 'Remember Visitor’s Choice' option ensures that when a user has manually selected a different theme, this preference is saved for 30 days via cookies.
* **No Bloat:** Zero front-end CSS or JS added by the plugin itself.
* **Developer Friendly:** Built by a developer for developers.

## Installation

1. Upload the `slim-mobile-theme-switcher` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Go to **Settings > Slim Mobile Theme Switcher** to select your mobile and desktop themes.

## Frequently Asked Questions

### How do I manually force a specific theme?
You can append query strings to your URLs to allow users to switch themes manually.
* Mobile Theme: `yoursite.com/?theme=handheld`
* Tablet Theme: `yoursite.com/?theme=tablet`
* Desktop Theme: `yoursite.com/?theme=active`

### How do I add a "View Full Site" link?
You can add a link to your mobile theme's footer: `<a href="?theme=active">View Full Site</a>`

### How do I link to the mobile version manually?
Simply add `?theme=handheld` to any URL on your site. To go back to the default/desktop view, use `?theme=active`.

### What should I configure in my caching plugin?
For best results, exclude the `theme` query parameter from your cache. If your host supports it, enable "Vary by User-Agent" or "Mobile Caching".

### Why isn't my theme switching?
The most common cause is **Page Caching**. If your host (like WP Engine or Kinsta) or a plugin (like WP Rocket) caches the desktop version of a page, it may serve that cached HTML to mobile users regardless of this plugin. Please ensure "Mobile Caching" or "User-Agent Vary" is enabled in your caching setup.

### What should I configure in my caching plugin?
For best results, exclude the `theme` query parameter from your cache. If your host supports it, enable "Vary by User-Agent" or "Mobile Caching".


## Screenshots

1. The settings page where you can choose your mobile and desktop themes.

## Changelog 
### 1.1.0
* **Feature:** Added dedicated Tablet Theme routing. You can now serve unique themes to Mobile, Tablet, and Desktop users independently.
* **Feature:** Added a persistent cookie (30 days) to remember a visitor's manual theme override choice.
* **Tweak:** Completely overhauled the mobile detection logic for better accuracy across modern devices.
* **DEV:** Tested Up To WordPress 7.0.
  
### 1.0.0
* Initial release.

## Upgrade Notice 

### 1.0.0
* Initial release.
