public
Last active

latest deal redirect.

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
function latest_deal_redirect( $redirect = null ) {
$latest_deal_qv = get_query_var( 'todays-deal' );
$latest_deal = ( $latest_deal_qv != '' ) ? $latest_deal_qv : $_GET['todays-deal'] ;
// redirect from homepage if cookie is set or we are using the todays-deal link
if( 1 == $latest_deal || ( is_home() && isset( $_COOKIE[ 'your-selected-location' ] ) ) ) {
$redirect = get_gbs_latest_deal_link();
} elseif ( is_home() && is_user_logged_in() ) { // redirect for logged in users
$redirect = get_gbs_deals_link();
}
if ( $redirect != null ) { // if we have something to redirect to let's do it.
wp_redirect( apply_filters( 'latest_deal_redirect', $redirect ) );
exit();
}
return;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.