Configure'; return $actions; } function admin_menu() { add_submenu_page( 'options-general.php', __( 'Advanced Mobile Redirect', 'mobile-redirect' ), __( 'Advanced Mobile Redirect', 'mobile-redirect' ), 'administrator', __FILE__, array( &$this, 'page' ) ); } function page() { global $geo_ip; //admin options page if ( isset( $_POST['iphone_redirect_url'] ) ) { // urls update_option( 'iphone_redirect_url', esc_url_raw( $_POST['iphone_redirect_url'] ) ); update_option( 'ipad_redirect_url', esc_url_raw( $_POST['ipad_redirect_url'] ) ); update_option( 'android_redirect_url', esc_url_raw( $_POST['android_redirect_url'] ) ); update_option( 'blackberry_redirect_url', esc_url_raw( $_POST['blackberry_redirect_url'] ) ); update_option( 'windowsm_redirect_url', esc_url_raw( $_POST['windowsm_redirect_url'] ) ); update_option( 'opera_redirect_url', esc_url_raw( $_POST['opera_redirect_url'] ) ); update_option( 'palm_redirect_url', esc_url_raw( $_POST['palm_redirect_url'] ) ); update_option( 'other_redirect_url', esc_url_raw( $_POST['other_redirect_url'] ) ); // countries update_option( 'iphone_redirect_country', esc_attr( $_POST['iphone_redirect_country'] ) ); update_option( 'ipad_redirect_country', esc_attr( $_POST['ipad_redirect_country'] ) ); update_option( 'android_redirect_country', esc_attr( $_POST['android_redirect_country'] ) ); update_option( 'blackberry_redirect_country', esc_attr( $_POST['blackberry_redirect_country'] ) ); update_option( 'windowsm_redirect_country', esc_attr( $_POST['windowsm_redirect_country'] ) ); update_option( 'opera_redirect_country', esc_attr( $_POST['opera_redirect_country'] ) ); update_option( 'palm_redirect_country', esc_attr( $_POST['palm_redirect_country'] ) ); update_option( 'other_redirect_country', esc_attr( $_POST['other_redirect_country'] ) ); // redirect modes update_option( 'iphone_redirect_mode', intval( $_POST['iphone_redirect_mode'] ) ); update_option( 'ipad_redirect_mode', intval( $_POST['ipad_redirect_mode'] ) ); update_option( 'android_redirect_mode', intval( $_POST['android_redirect_mode'] ) ); update_option( 'blackberry_redirect_mode', intval( $_POST['blackberry_redirect_mode'] ) ); update_option( 'windowsm_redirect_mode', intval( $_POST['windowsm_redirect_mode'] ) ); update_option( 'opera_redirect_mode', intval( $_POST['opera_redirect_mode'] ) ); update_option( 'palm_redirect_mode', intval( $_POST['palm_redirect_mode'] ) ); update_option( 'other_redirect_mode', intval( $_POST['other_redirect_mode'] ) ); // redirect home update_option( 'iphone_redirect_home', isset( $_POST['iphone_redirect_home'] ) ); update_option( 'ipad_redirect_home', isset( $_POST['ipad_redirect_home'] ) ); update_option( 'android_redirect_home', isset( $_POST['android_redirect_home'] ) ); update_option( 'blackberry_redirect_home', isset( $_POST['blackberry_redirect_home'] ) ); update_option( 'windowsm_redirect_home', isset( $_POST['windowsm_redirect_home'] ) ); update_option( 'opera_redirect_home', isset( $_POST['opera_redirect_home'] ) ); update_option( 'palm_redirect_home', isset( $_POST['palm_redirect_home'] ) ); update_option( 'other_redirect_home', isset( $_POST['other_redirect_home'] ) ); // toggles update_option( 'iphone_redirect_toggle', isset( $_POST['iphone_redirect_toggle'] ) ? true : false ); update_option( 'ipad_redirect_toggle', isset( $_POST['ipad_redirect_toggle'] ) ? true : false ); update_option( 'android_redirect_toggle', isset( $_POST['android_redirect_toggle'] ) ? true : false ); update_option( 'blackberry_redirect_toggle', isset( $_POST['blackberry_redirect_toggle'] ) ? true : false ); update_option( 'windowsm_redirect_toggle', isset( $_POST['windowsm_redirect_toggle'] ) ? true : false ); update_option( 'opera_redirect_toggle', isset( $_POST['opera_redirect_toggle'] ) ? true : false ); update_option( 'palm_redirect_toggle', isset( $_POST['palm_redirect_toggle'] ) ? true : false ); update_option( 'other_redirect_toggle', isset( $_POST['other_redirect_toggle'] ) ? true : false ); echo '

' . __( 'Updated', 'mobile-redirect' ) . '

'; } ?>

Select Device for Redirect
  Country Redirect URL Redirect Mode    
iPhone/iPod Touch: /> />
iPad /> />
Android /> />
Blackberry /> />
Windows Mobile /> />
Opera Mini /> />
Palm Os /> />
Other Mobile Device /> />
Back to full version website

Place this link in mobile website for Redirect back mobile visitor to main website


Converting Desktop and Mobile Traffic with Slimspots - CPA Network.
isMobile() || $detect->isTablet() && !isset($_SESSION['amr_main'])){ // check if any of the options is toogled if (amr_is_anything_toggled() == true){ $amr_redirect_options = Array('url'=>'', 'mode'=>'302', 'only_home'=>'0'); // check for iphone if (get_option( 'iphone_redirect_toggle' ) == '1' && $detect->isiPhone() ){ $amr_redirect_options = Array( 'url'=> get_option( 'iphone_redirect_url' ), 'country'=> get_option( 'iphone_redirect_country' ), 'mode'=>get_option( 'iphone_redirect_mode' ), 'only_home'=>get_option( 'iphone_redirect_home' ) ); } // check for ipad if (get_option( 'ipad_redirect_toggle' ) == '1' && $detect->isiPad() ){ $amr_redirect_options = Array( 'url'=> get_option( 'ipad_redirect_url' ), 'country'=> get_option( 'ipad_redirect_country' ), 'mode'=>get_option( 'ipad_redirect_mode' ), 'only_home'=>get_option( 'ipad_redirect_home' ) ); } // check for android if (get_option( 'android_redirect_toggle' ) == '1' && $detect->isAndroidOS() ){ $amr_redirect_options = Array( 'url'=> get_option( 'android_redirect_url' ), 'country'=> get_option( 'android_redirect_country' ), 'mode'=>get_option( 'android_redirect_mode' ), 'only_home'=>get_option( 'android_redirect_home' ) ); } // check for blackberry if (get_option( 'blackberry_redirect_toggle' ) == '1' && $detect->isBlackBerryOS() ){ $amr_redirect_options = Array( 'url'=> get_option( 'blackberry_redirect_url' ), 'country'=> get_option( 'blackberry_redirect_country' ), 'mode'=>get_option( 'blackberry_redirect_mode' ), 'only_home'=>get_option( 'blackberry_redirect_home' ) ); } // check for windows mobile if (get_option( 'windowsm_redirect_toggle' ) == '1' && $detect->isWindowsMobileOS() ){ $amr_redirect_options = Array( 'url'=> get_option( 'windowsm_redirect_url' ), 'country'=> get_option( 'windowsm_redirect_country' ), 'mode'=>get_option( 'windowsm_redirect_mode' ), 'only_home'=>get_option( 'windowsm_redirect_home' ) ); } // check for opera if (get_option( 'opera_redirect_toggle' ) == '1' && $detect->isOpera() ){ $amr_redirect_options = Array( 'url'=> get_option( 'opera_redirect_url' ), 'country'=> get_option( 'opera_redirect_country' ), 'mode'=>get_option( 'opera_redirect_mode' ), 'only_home'=>get_option( 'opera_redirect_home' ) ); } // check for palm if (get_option( 'palm_redirect_toggle' ) == '1' && $detect->isPalmOS() ){ $amr_redirect_options = Array( 'url'=> get_option( 'palm_redirect_url' ), 'country'=> get_option( 'palm_redirect_country' ), 'mode'=>get_option( 'palm_redirect_mode' ), 'only_home'=>get_option( 'palm_redirect_home' ) ); } // check for other type of mobile device if (get_option( 'other_redirect_toggle' ) == '1' && ($detect->isMobile() || $detect->isTablet()) ){ $amr_redirect_options = Array( 'url'=> get_option( 'other_redirect_url' ), 'country'=> get_option( 'other_redirect_country' ), 'mode'=>get_option( 'other_redirect_mode' ), 'only_home'=>get_option( 'other_redirect_home' ) ); } // if empty url then exit if ( empty( $amr_redirect_options['url'] ) ) return; // at this point an option is toogled and the url to redirect is not empty // check for the Only home option if( $amr_redirect_options['home'] == '1'){ if( ! is_front_page() ) return; } // FINAL STEP // make sure we don't redirect to ourself if ( $amr_redirect_options['url'] != $cur_url ) { $do_redirect_country = false; // check country code if (!empty($amr_redirect_options['country'])){ $gi = geoip_open(plugin_dir_path(__FILE__)."libs/GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); if ($country_code == $amr_redirect_options['country']){ $do_redirect_country = true; } geoip_close($gi); }else{ // if not sent then redirect ALL countries $do_redirect_country = true; } // if country do not match then do not redirect if (!$do_redirect_country) return; header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate"); wp_redirect( $amr_redirect_options['url'], $amr_redirect_options['mode'] ); exit; } } }else{ // die("SESSION DONE;".$_SESSION['amr_main']); } } } /** * Start session */ function amr_start_session(){ if(!session_id()) { session_start(); } if (isset($_REQUEST["main"])){ amr_session_set(); } } /** * End session */ function amr_end_session(){ session_destroy(); } /** * Set main site session */ function amr_session_set(){ if (!isset($_SESSION['amr_main'])) $_SESSION['amr_main'] = 1; } add_action('init', 'amr_start_session', 1); add_action('wp_logout', 'amr_end_session'); add_action('wp_login', 'amr_end_session'); // eof