zwalker
Forum Replies Created
-
Thank you for adding the filter @specialk. This is perfect.
You’ll want to test this on your side but I added a check for this condition in the function and works across the board for my use case.
function theme_switcha_active_theme() { global $theme_switcha_options; $get_theme = wp_get_theme(); $options = $theme_switcha_options; $active_theme = $get_theme->get('Name'); $pass_overload = ($options['allowed_users'] == "passkey" && !isset($_COOKIE['theme_switcha_passkey_'. COOKIEHASH]) && !is_admin())? FALSE: TRUE; if (isset($_COOKIE['theme_switcha_theme_'. COOKIEHASH]) && $pass_overload) { $active_theme = $_COOKIE['theme_switcha_theme_'. COOKIEHASH]; } return $active_theme; }
Awesome, thank you! I’ll see what I can do in the mean time.
Best,
ZachI am using the theme_switcha_active_theme() function from your plugin core file to see what the current switched too theme is and include anything relavant to that theme in my functions.php.
Right now, when logged out, this function is returning the switched too theme even if theme options / permissions don’t align.
Is there another function here that I can use to check the options?
if(function_exists(‘theme_switcha_active_theme’) && (theme_switcha_active_theme() == ‘my-switched-to-theme’)) {
// DO important stuff
} else {
Do stuff for active theme
}- This reply was modified 3 years ago by zwalker.
Ahh I see… it’s theme_switcha_active_theme() is returning the theme switched theme on log out when passcode cookie is not set. I’m using this in my functions.php.
Theme settings are passcode view only while logged out.
1) Log in
2) Theme Switch to anther theme which is not current one used on the site (this will set theme_switcha_theme_ cookie)
3) Log Out
4) See error. (Due to no pass cookie being set)Happy to do a Loom if you’re unable to reproduce.
You can fix by adding a extra condition when it looks at what theme cookies are set. Have it default to current theme if no pass cookie is set and settings are passcode view only.
You’re aware of this error related to the use of the plugin though? It’s something that would make the most sense to fix from the plugin’s code base in the next update.
Something along these lines, maybe:
<?php
function theme_switcha_clear_cookies_on_logout() {
unset($_COOKIE[‘theme_switcha_theme_’]);
unset($_COOKIE[‘theme_switcha_pass_’]);
}
add_action( ‘wp_logout’, ‘theme_switcha_clear_cookies_on_logout’ );
?>Hi Jeff,
There was nothing of value in the debug / error logs and I couldn’t find a resolution so I ended up disabling WP Rocket and doing all the Caching / Optimisations programmatically instead.
I do get a critical error on the site if I use the top bar to switch themes and then log out. Can you hook the log out routine and clear your plugin cookies?
- This reply was modified 3 years ago by zwalker.
Hi Jeff,
I figured it out. It’s a compatibility thing with the newest version of WP Rocket.
I disabled this plugin specifically and everything worked. Do you have any insight into why this might be happening?
I can exclude the theme-switcher cookies from the cache etc.
Best,
Zach