WordPress.org

Ready to get started?Download WordPress

Forums

Any Mobile Theme Switcher
Remember user choice (6 posts)

  1. richtelford
    Member
    Posted 1 year ago #

    If a user clicks "Switch to Desktop Version" it takes the user to the site homepage using the desktop theme which I guess is correct. But then when the user clicks another link it reverts back to the mobile theme. Is it possible to remember the chosen theme so the user can navigate around on the desktop site on a mobile device???

    http://wordpress.org/extend/plugins/any-mobile-theme-switcher/

  2. abelito
    Member
    Posted 1 year ago #

    Having same issue.

    this used to work until i upgraded to 1.2

    Looking to revert back to v1.1

  3. richtelford
    Member
    Posted 1 year ago #

    I made a few modifications to my local version of the plugin. The main change I made was to use $_COOKIE instead of $_SESSION to store user choice. It works very well.

  4. abelito
    Member
    Posted 1 year ago #

    Reverted back to v1.1 and all works fine now, but using $_COOKIE instead of $_SESSION makes far more sense to me too.

    Could you paste what changes you made and will apply myself.

    Presume majority of changes are after line 91 of any-mobile-theme-switcher.php??

    thanks

  5. richtelford
    Member
    Posted 1 year ago #

    Yes that's correct. I replaced that section from 91 down with:

    //Force Theme Display request from visitor.
    if (@$_GET['am_force_theme_layout']){
    	//$_COOKIE['am_force_theme_layout'] 	=	$_GET['am_force_theme_layout'];
    	setcookie("am_force_theme_layout", $_GET['am_force_theme_layout']);
    	header("Location: /");
    	exit;
    }
    
    if (isset($_COOKIE['am_force_theme_layout'])){ //IF USER FORCE FOR THE THEME
    	if ($_COOKIE['am_force_theme_layout'] == 'mobile'){ // IF FORCED THEME IS MOBILE
    		$mobile_browser = get_option('iphone_theme');
    		add_filter('stylesheet', 'loadMobileStyle');
    		add_filter('template', 'loadMobileTheme');
    		$shown_theme = 'mobile';
    	}
    } else { // NORMAL THEME [PLUGIN DEFAULT]
    	if (!empty($mobile_browser)){
    		add_filter('stylesheet', 'loadMobileStyle');
    		add_filter('template', 'loadMobileTheme');
    		$shown_theme = 'mobile';
    	}
    }
  6. abelito
    Member
    Posted 1 year ago #

    As simple as that. Yes, looking at it, that is that is required really.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.