Last active
December 13, 2020 08:03
-
-
Save raazon/b4136fbdee1ebb203a800bd7dd0e7d06 to your computer and use it in GitHub Desktop.
Revisions
-
raazon revised this gist
Dec 13, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ function ic_icredirection() { if (!is_user_logged_in()) { $regex = '/^(?:(?!\/(?:hello-world|hello-regex)(?:\/|$)).)*$/m'; $str = home_url($_SERVER['REQUEST_URI']); if (preg_match_all($regex, $str, $matches, PREG_SET_ORDER, 0)) { wp_redirect(home_url()); @@ -22,7 +22,7 @@ function ic_icredirection() function ic_icredirection() { if (!is_user_logged_in()) { $regex = '/(http(s)?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w- ;,.\/?%&=]*)?(hello-world|hello-regex)/m'; $str = home_url($_SERVER['REQUEST_URI']); if (preg_match_all($regex, $str, $matches, PREG_SET_ORDER, 0)) { wp_redirect(home_url()); -
raazon created this gist
Dec 13, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <?php /* * Redirect if specific slug "hello-world OR hello-regex" not found in URL */ add_action('template_redirect', 'ic_icredirection'); function ic_icredirection() { if (!is_user_logged_in()) { $regex = '/^(?:(?!\/(?:hello-world|hello-regex)(?:\/|$)).)*$/gm'; $str = home_url($_SERVER['REQUEST_URI']); if (preg_match_all($regex, $str, $matches, PREG_SET_ORDER, 0)) { wp_redirect(home_url()); } } } /* * Redirect if specific slug "hello-world OR hello-regex" found in URL */ add_action('template_redirect', 'ic_icredirection'); function ic_icredirection() { if (!is_user_logged_in()) { $regex = '/(http(s)?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w- ;,.\/?%&=]*)?(hello-world|hello-regex)/gm'; $str = home_url($_SERVER['REQUEST_URI']); if (preg_match_all($regex, $str, $matches, PREG_SET_ORDER, 0)) { wp_redirect(home_url()); } } }