WordPress.org

Ready to get started?Download WordPress

Forums

Mobile Domain
[resolved] This should not redirect in the admin area. (4 posts)

  1. Sterling Hamilton
    Member
    Posted 2 years ago #

    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/

  2. Yusuf
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. Sterling Hamilton
    Member
    Posted 2 years ago #

    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!

  4. Yusuf
    Member
    Plugin Author

    Posted 2 years ago #

    you were right sterlo, I fixed it.
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic