Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter kiboost

    (@kiboost)

    I have updated your wp_user_stylesheet_switcher.php file and it now works.
    But next update will erase it I guess.
    Is there a way to make an add_filter in functions.php for this ?

    public function wp_user_stylesheet_switcher_addcss()
    {
    $stylesheet_choice = $settings['default'];
    if(isset($_COOKIE['MYCOOKIE'])) {
       $_SESSION['user_stylesheet_switcher'] = $_COOKIE['intranet_theme'];
    		}
    if (isset($_POST['user_stylesheet_switcher_choice']))
    {
       // User chose a stylesheet in the switcher
       $stylesheet_choice = $_POST['user_stylesheet_switcher_choice'];
       setcookie('MYCOOKIE', $stylesheet_choice, time()+1209600, '/', 'MYURL', false);
    
    ...
    }
    Thread Starter kiboost

    (@kiboost)

    For those interested:
    In my child theme, in header.php, just place this

    if(isset($_COOKIE['MYCOOKIE']))
     	{
    		$_SESSION['user_stylesheet_switcher'] = $_COOKIE['MYCOOKIE'];
    	}
    if (isset($_POST['user_stylesheet_switcher_choice']))
    	{
    		$stylesheet_choice = $_POST['user_stylesheet_switcher_choice'];
    		setcookie('MYCOOKIE', $stylesheet_choice, time()+1209600, '/', 'MYURL', false);
    		$_SESSION['user_stylesheet_switcher'] = $stylesheet_choice;
    	}

    So, nothing changed in plugin core !

    Plugin Author vgstef

    (@vgstef)

    Hi! I’m working on an update, so I’ll add a setcookie to my plugin.

    Thanks for the idea.

    Thread Starter kiboost

    (@kiboost)

    Nice ??

    Plugin Author vgstef

    (@vgstef)

    Hi kiboost,
    I just updated my plugin. I made many important changes, the main one is that the user choice is now saved in a cookie using javascript.
    Could you test the new version to see the user choice is preserved on your site too.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Choice not stored between sessions’ is closed to new replies.