• Please add this patch. It checks for is_admin()

    33   foreach($browsers as $browser) {
     34     if (preg_match("/".$browser."/i", $_SERVER['HTTP_USER_AGENT'])) {
     35       if (!isset($_COOKIE['wordpress_mobile_domain_plugin'])) {
     36         if ($_SERVER['SERVER_NAME'] == WPMD_DESKTOP) {
     37           $get = get_option('wpmd_db_options');
     38           if (!empty($get['domain'])) {
     39             if( ! is_admin() ) {
     40               header ('location:http://'.$get['domain'].''.$_SERVER['REQUEST_URI']);
     41               die();
     42             }
     43           }
     44         }
     45       }
     46     }
     47   }

    http://wordpress.org/extend/plugins/mobile-domain/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Yusuf

    (@byoozz)

    Thanks sterlo for the patch, but I already use this :

    $wp_admin = substr_count($_SERVER['REQUEST_URI'], '/wp-admin/');
    
    	$wp_login = substr_count($_SERVER['REQUEST_URI'], '/wp-login.php');
    
    	if ($wp_login > 0 || $wp_admin > 0) {
    
    		$get = get_option('wpmd_db_options');
    
    		if ($_SERVER['SERVER_NAME'] == $get['domain']) {
    
    			ywpmd_create_cookie();
    
    			header ('location:'.WPMD_SITEURL.'/wp-login.php');
    
    			die();
    
    		}
    
    	}

    maybe I’ll use your code in the next version.

    Thread Starter Sterling Hamilton

    (@sterlo)

    Hey byoozz:

    I submitted the patch because I broke an alpha site testing the plugin.

    I added “firefox” to the list of mobile clients – just to test the redirection. I told it to redirect me to google.com and from then on, even in the admin area, it did that.

    The patch I submitted, is basically intended to say “Do not perform redirections if in the administration area”.

    The function ywpmd_options currently causes the problem, which is what my patch addresses.

    It hooks here: add_action(‘init’, ‘ywpmd_options’);
    Which means that theres nothing stopping it from redirecting.

    I do see your code here (starting at line 61):

    $wp_admin = substr_count($_SERVER['REQUEST_URI'], '/wp-admin/');
    $wp_login = substr_count($_SERVER['REQUEST_URI'], '/wp-login.php');
    if ($wp_login > 0 || $wp_admin > 0) {
    	$get = get_option('wpmd_db_options');
    	if ($_SERVER['SERVER_NAME'] == $get['domain']) {
    		ywpmd_create_cookie();
    		header ('location:'.WPMD_SITEURL.'/wp-login.php');
    		die();
    	}
    }

    But that comes AFTER line 38…so the problem still exists.

    It’s an edgecase – but one I can tell could cause a user a very painful experience if not fixed.

    Thanks for the hard work!

    Plugin Author Yusuf

    (@byoozz)

    you were right sterlo, I fixed it.
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Mobile Domain] This should not redirect in the admin area.’ is closed to new replies.