Toolbar Theme Switcher description pretty much fits in its name.
This plugin provides toolbar (previously known as admin bar) menu for users to quickly switch between available themes.
Theme choice is individual for user, saved in cookies and doesn't affect current theme of the site.
Plugin is multisite-aware — it will only list themes allowed for site and save choice for each site separately.
Toolbar Theme Switcher is a Composer package and can be installed in plugin directory via:
composer create-project rarst/toolbar-theme-switcher --no-dev
Clear the cookies. Don't do it again.
Filter tts_allowed_themes
and unset unwanted themes.
Example code (removes Twenty Ten theme from the list):
add_filter( 'tts_allowed_themes', 'hide_twenty_ten' );
function hide_twenty_ten( $themes ) {
unset( $themes['Twenty Ten'] );
return $themes;
}
Users with switch_themes
capability (administrators by default).
Filter tts_capability
(capability name) or tts_can_switch_themes
(boolean) to customize.
Filter tts_root_title
to control what it says.
Plugin needs to build full list of available themes, which isn't typically needed on each page load and can be relatively slow with a lot of disk access.
When using Object Cache, caching theme data in WordPress can be enabled via:
add_filter( 'wp_cache_themes_persistently', '__return_true' );
Since it doesn't handle invalidation (will need to wait or flush cache when themes are added/removed), plugin isn't enabling it and leaves choice up to the user.
- (enhancement) made plugin not interfere with Appearance admin page and real theme switching
- (internal) updated theme allowed check to use native method over enumeration, improves boot performance
- (internal) reworked to filter underlying options - more robust, should solve customizer issues and similar
- (localization) made translation-ready, added russian translation
- (compatibility) removed legacy checks, increased minimum required WordPress version to 3.4
- (bugfix) fixed crash in installations with multiple theme directories
- (docs) added example code for removing theme from list to readme
- (bugfix) improved cookie name to better work on secure sites
- (bugfix) changed order of function checks to prevent deprecated notices in admin
- (bugfix) fixed fatal error on deprecated function in WP 3.4 #blamenacin
- (internal) switched to older
add_menu()
method for now (pre-3.3 compatibility)
- (internal) code cleanup
- (enhancement) show current theme name in toolbar, props Leho Kraav
- (enhancement) added filter for root node title, props Leho Kraav
- Initial repository release.