Fix error for undefined
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 16 Sep 2016 15:42:31 +0000 (11:42 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 16 Sep 2016 15:42:31 +0000 (11:42 -0400)
Check with isset.

functions.php

index 7a5e16d..bec1c0e 100644 (file)
@@ -116,10 +116,10 @@ function glm_site_scripts()
 
 /* Woocommerce */
 
-function get_product_category_by_id($cat_id) 
+function get_product_category_by_id($cat_id)
 {
 $category = get_term_by('id', $cat_id, 'product_cat', 'OBJECT');
-return $category; 
+return $category;
 }
 add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
 
@@ -307,7 +307,7 @@ if ( ! function_exists( 'is_tree' ) ) {
 }
 add_action('thematic_searchloop', 'mytheme_search_loop');
 // End of the Contextual/Highlight Search functions
-// 
+//
 
 //function get_menu_parent_ID($menu_name){
 //    if(!isset($menu_name)){
@@ -362,17 +362,17 @@ if (!function_exists('is_in_tree')) {
 /**
  * Function Name:   front_end_login_fail.
  * Added for:       GLM Member DB front-end login failure custom redirection.
- * Description:     This redirects the failed login to the custom login page 
+ * Description:     This redirects the failed login to the custom login page
  *                  instead of default login page with a modified url
 **/
 add_action( 'wp_login_failed', 'front_end_login_fail' );
 function front_end_login_fail( $username ) {
     // Getting URL of the login page
-    $referrer = $_SERVER['HTTP_REFERER'];    
+    $referrer = $_SERVER['HTTP_REFERER'];
     // if there's a valid referrer, and it's not the default log-in screen
     if( !empty( $referrer ) && !strstr( $referrer,'wp-login' ) && !strstr( $referrer,'wp-admin' ) ) {
-        echo get_permalink( get_option('glm_members_database_option_members_only_id') ) . "?login=failed"; 
-        wp_redirect( get_permalink( get_option('glm_members_database_option_members_only_id') ) . "?login=failed" ); 
+        echo get_permalink( get_option('glm_members_database_option_members_only_id') ) . "?login=failed";
+        wp_redirect( get_permalink( get_option('glm_members_database_option_members_only_id') ) . "?login=failed" );
         exit;
     }
 }
@@ -380,16 +380,16 @@ function front_end_login_fail( $username ) {
 /**
  * Function Name:   front_end_blank_credentials.
  * Added for:       GLM Member DB front-end login failure custom redirection.
- * Description:     This redirects to the custom login page if user name or 
+ * Description:     This redirects to the custom login page if user name or
  *                  password is empty with a modified url
 **/
 add_action( 'authenticate', 'front_end_blank_credentials', 1, 3);
 function front_end_blank_credentials( $login, $username, $password ) {
 
     // Getting URL of the login page
-    $referrer = $_SERVER['HTTP_REFERER'];
+    $referrer = ( isset( $_SERVER['HTTP_REFERER'] ) && $_SERVER['HTTP_REFERER'] ) ? : '';
     // if there's a valid referrer, and it's not the default log-in screen
-    if( !empty( $referrer ) && !strstr( $referrer,'wp-login' ) && !strstr( $referrer,'wp-admin' ) ) { 
+    if( !empty( $referrer ) && !strstr( $referrer,'wp-login' ) && !strstr( $referrer,'wp-admin' ) ) {
         if( $username == "" || $password == "" ){
             wp_redirect( get_permalink( get_option('glm_members_database_option_members_only_id') ) . "?login=empty" );
             exit;