title: Specific URL If statement in PHP
body: <p>I'm trying to add an if statement that only executes the mobile redirect in this wordpress plugin if the url equals a certain location. I assume it would be placed in the location that determines whether or not the browser is mobile or not.  I've tried a few different pieces of code with no success.  Any help would be much appreciated.</p>
  
  <pre><code>    &lt;?php
  /*
  Plugin Name: Mobile Redirect
  Description: Select a URL to point mobile users to
  Author: Ozette Plugins
  Version: 1.4.1
  Author URI: http://ozette.com/
  */
  
  /*  Copyright 2013 Ozette Plugins (email : plugins@ozette.com)
  
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License, version 2, as
      published by the Free Software Foundation.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
      Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  
  */
  
  $ios_mobile_redirect = new IOS_Mobile_Redirect();
  
  register_uninstall_hook( __FILE__, 'uninstall_mobile_redirect' );
  function uninstall_mobile_redirect() {
      delete_option( 'mobileredirecturl' );
      delete_option( 'mobileredirecttoggle' );
      delete_option( 'mobileredirectmode' );
      delete_option( 'mobileredirecttablet' );
  }
  
  class IOS_Mobile_Redirect{
  
      function __construct() { //init function
          add_action( 'admin_init', array( &amp;$this, 'admin_init' ) );
          add_action( 'admin_menu', array( &amp;$this, 'admin_menu' ) );
          add_action( 'template_redirect', array( &amp;$this, 'template_redirect' ) );
          // upgrade option from 1.1 to 1.2
          if ( get_option( 'mobileredirecttoggle' ) == 'true' )
              update_option( 'mobileredirecttoggle', true );
      }
  
      function admin_init() {
          add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( &amp;$this, 'plugin_action_links' ), 10, 4 );
      }
  
      function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
          if ( is_plugin_active( $plugin_file ) )
              $actions[] = '&lt;a href="' . admin_url('options-general.php?page=simple-mobile-url-redirect/mobile-redirect.php') . '"&gt;Configure&lt;/a&gt;';
          return $actions;
      }
  
      function admin_menu() {
          add_submenu_page( 'options-general.php', __( 'Mobile Redirect', 'mobile-redirect' ), __( 'Mobile Redirect', 'mobile-redirect' ), 'administrator', __FILE__, array( &amp;$this, 'page' ) );
      }
  
      function page() { //admin options page
  
          //do stuff if form is submitted
          if ( isset( $_POST['mobileurl'] ) ) {
              update_option( 'mobileredirecturl', esc_url_raw( $_POST['mobileurl'] ) );
              update_option( 'mobileredirecttoggle', isset( $_POST['mobiletoggle'] ) ? true : false );
  
              update_option( 'mobileredirectmode', intval( $_POST['mobilemode'] ) );
              update_option( 'mobileredirecttablet', isset( $_POST['mobileredirecttablet'] ) );
  
              update_option( 'mobileredirectonce', isset( $_POST['mobileredirectonce'] ) ? true : false );
              update_option( 'mobileredirectoncedays', intval( $_POST['mobileredirectoncedays'] ) );
  
              echo '&lt;div class="updated"&gt;&lt;p&gt;' . __( 'Updated', 'mobile-redirect' ) . '&lt;/p&gt;&lt;/div&gt;';
          }
  
          ?&gt;
          &lt;div class="wrap"&gt;&lt;h2&gt;&lt;?php _e( 'Mobile Redirect', 'mobile-redirect' ); ?&gt;&lt;/h2&gt;
          &lt;p&gt;
              &lt;?php _e( 'If the checkbox is checked, and a valid URL is inputted, this site will redirect to the specified URL when visited by a mobile device.', 'mobile-redirect' ); ?&gt;
              &lt;?php // _e( 'This does not include the iPad, but will include most other mobile devices.', 'mobile-redirect' ); ?&gt;
          &lt;/p&gt;
  
          &lt;form method="post"&gt;
          &lt;p&gt;
              &lt;label for="mobiletoggle"&gt;&lt;?php _e( 'Enable Redirect:', 'mobile-redirect' ); ?&gt;
              &lt;input type="checkbox" value="1" name="mobiletoggle" id="mobiletoggle" &lt;?php checked( get_option('mobileredirecttoggle', ''), 1 ); ?&gt; /&gt;&lt;/label&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;label for="mobileurl"&gt;&lt;?php _e( 'Redirect URL:', 'mobile-redirect' ); ?&gt;
              &lt;input type="text" name="mobileurl" id="mobileurl" value="&lt;?php echo esc_url( get_option('mobileredirecturl', '') ); ?&gt;" /&gt;&lt;/label&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;label for="mobilemode"&gt;&lt;?php _e( 'Redirect Mode:', 'mobile-redirect' ); ?&gt;
              &lt;select id="mobilemode" name="mobilemode"&gt;
                  &lt;option value="301" &lt;?php selected( get_option('mobileredirectmode', 301 ), 301 ); ?&gt;&gt;301&lt;/option&gt;
                  &lt;option value="302" &lt;?php selected( get_option('mobileredirectmode'), 302 ); ?&gt;&gt;302&lt;/option&gt;
              &lt;/select&gt;
              &lt;/label&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;label for="mobileredirecttablet"&gt;&lt;?php _e( 'Redirect Tablets:', 'mobile-redirect' ); ?&gt;
              &lt;input type="checkbox" value="1" name="mobileredirecttablet" id="mobileredirecttablet" &lt;?php checked( get_option('mobileredirecttablet', ''), 1 ); ?&gt; /&gt;&lt;/label&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;label for="mobileredirectonce"&gt;&lt;?php _e( 'Redirect Once:', 'mobile-redirect' ); ?&gt;
              &lt;input type="checkbox" value="1" name="mobileredirectonce" id="mobileredirectonce" &lt;?php checked( get_option('mobileredirectonce', ''), 1 ); ?&gt; /&gt;&lt;/label&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;label for="mobileredirectoncedays"&gt;&lt;?php _e( 'Redirect Once Cookie Expiry:', 'mobile-redirect' ); ?&gt;
              &lt;input type="text" name="mobileredirectoncedays" id="mobileredirectoncedays" value="&lt;?php echo esc_attr( get_option('mobileredirectoncedays', 7 ) ); ?&gt;" /&gt; days.&lt;/label&gt;
              &lt;span class="description"&gt;If &lt;em&gt;Redirect Once&lt;/em&gt; is checked, a cookie will be set for the user to prevent them from being continually redirected to the same page. This cookie will expire by default after 7 days. Setting to zero or less is effectively the same as unchecking Redirect Once&lt;/span&gt;
          &lt;/p&gt;
              &lt;?php submit_button(); ?&gt;
          &lt;/form&gt;
          &lt;/div&gt;
  
          &lt;div class="copyFooter"&gt;Plugin written by &lt;a href="http://ozette.com"&gt;Ozette Plugins&lt;/a&gt;.&lt;/div&gt;
          &lt;?php
      }
  
      function is_mobile() {
          $mobile_browser = '0';
          if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
              $mobile_browser++;
          }
          if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')&gt;0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
              $mobile_browser++;
          }    
          $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
          $mobile_agents = array(
              'w3c ','acs-','alav','alca','amoi','audi','avan','andr','benq','bird','blac',
              'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
              'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
              'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
              'newt','noki','palm','pana','pant','phil','play','port','prox',
              'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
              'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
              'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
              'wapr','webc','winw','winw','xda','xda-');
          if(in_array($mobile_ua,$mobile_agents)) {
              $mobile_browser++;
          }
          if (isset($_SERVER['ALL_HTTP']) &amp;&amp; strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')&gt;0) {
              $mobile_browser++;
          }   
          if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'mobile safari')&gt;0) {
              $mobile_browser++;
          }
          if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')&gt;0) {
              $mobile_browser=0;
          }
          if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'android')&gt;0) {
              //if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'gecko')&gt;0) {
                  $mobile_browser++;
              //}
          }
  
          if($mobile_browser&gt;0) { return true; }
          else { return false; }
      }
  
      function template_redirect() {
          //check if tablet box is checked
          if( get_option('mobileredirecttablet') == 0){
              //redirect non-tablets
              if(!self::is_mobile() )
                  return;
          } else {
              // not mobile
              if ( ! wp_is_mobile() )
                  return;
          }
  
          // not enabled
          if ( ! get_option('mobileredirecttoggle') )
              return;
  
          $mr_url = esc_url( get_option('mobileredirecturl', '') );
          // empty url
          if ( empty( $mr_url ) )
              return;
  
          $cur_url = esc_url("http://". $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] );
          $cookiedays = intval( get_option( 'mobileredirectoncedays', 7 ) );
          // cookie can be expired by setting to a negative number
          // but it's better just to uncheck the redirect once option
          if ( $cookiedays &lt;= 0 || ! get_option( 'mobileredirectonce' ) ) {
              setcookie( 'mobile_single_redirect', true, time()-(60*60), '/' );
              unset($_COOKIE['mobile_single_redirect']);
          }
  
          // make sure we don't redirect to ourself
          if ( $mr_url != $cur_url ) {
              if ( isset( $_COOKIE['mobile_single_redirect'] ) ) return;
  
              if ( get_option( 'mobileredirectonce', '' ) )
                  setcookie( 'mobile_single_redirect', true, time()+(60*60*24*$cookiedays ), '/' );
  
              wp_redirect( $mr_url, get_option('mobileredirectmode', '301' ) );
              exit;
          }
  
      }
  
  }
  // eof
  </code></pre>