function init () { global $redirection; $url = $_SERVER['REQUEST_URI']; // Make sure we don't try and redirect something essential if (!$this->protected_url ($url) && !$redirection->hasMatched ()) { do_action ('redirection_first', $url, $this); $redirects = Red_Item::get_for_url( $url, 'wp' ); if ( !empty( $redirects) ) { foreach ($redirects AS $key => $item) { if ( $item->matches( $url ) ) { global $redirection; $redirection->setMatched( true ); $this->matched = $item; break; } } } do_action ('redirection_last', $url, $this); } }
public function init() { $url = $_SERVER['REQUEST_URI']; // Make sure we don't try and redirect something essential if (!$this->protected_url($url) && $this->matched === false) { do_action('redirection_first', $url, $this); $redirects = Red_Item::get_for_url($url, 'wp'); foreach ((array) $redirects as $item) { if ($item->matches($url)) { $this->matched = $item; break; } } do_action('redirection_last', $url, $this); } }
function template_redirect() { global $redirection; if (is_404() && !$redirection->hasMatched()) { $url = $_SERVER['REQUEST_URI']; $redirects = Red_Item::get_for_url($url, '404'); if (!empty($redirects)) { foreach ($redirects as $key => $item) { if ($item->matches($url)) { $redirection->setMatched(true); $this->matched = $item; break; } } } if (empty($this->matched)) { $modules = Red_Module::get_by_type('404'); if (count($modules) > 0) { foreach ($modules as $module) { // Log 404 errors if ($module->log_404) { if (isset($_SERVER['REMOTE_ADDR'])) { $myip = $_SERVER['REMOTE_ADDR']; } else { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $myip = $_SERVER['HTTP_X_FORWARDED_FOR']; } } $options = $redirection->get_options(); if ($options['log_404s']) { $log = RE_Log::create($_SERVER['REQUEST_URI'], '', $_SERVER['HTTP_USER_AGENT'], $myip, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', 'NULL', $module->id); } } } } } } }