| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Redirection |
| 4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/ |
| 5 |
Description: Manage all your 301 redirects and monitor 404 errors |
| 6 |
Version: 2.7.2 |
| 7 |
Author: John Godley |
| 8 |
Author URI: http://urbangiraffe.com |
| 9 |
Text Domain: redirection |
| 10 |
Domain Path: /locale |
| 11 |
============================================================================================================ |
| 12 |
This software is provided "as is" and any express or implied warranties, including, but not limited to, the |
| 13 |
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall |
| 14 |
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or |
| 15 |
consequential damages(including, but not limited to, procurement of substitute goods or services; loss of |
| 16 |
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in |
| 17 |
contract, strict liability, or tort(including negligence or otherwise) arising in any way out of the use of |
| 18 |
this software, even if advised of the possibility of such damage. |
| 19 |
|
| 20 |
For full license details see license.txt |
| 21 |
============================================================================================================ |
| 22 |
*/ |
| 23 |
|
| 24 |
define( 'REDIRECTION_DB_VERSION', '2.3.3' ); // DB schema version. Only change if DB needs changing |
| 25 |
define( 'REDIRECTION_FILE', __FILE__ ); |
| 26 |
define( 'REDIRECTION_DEV_MODE', false ); |
| 27 |
|
| 28 |
if ( !defined( 'REDIRECTION_FLYING_SOLO' ) ) { |
| 29 |
define( 'REDIRECTION_FLYING_SOLO', apply_filters( 'redirection_flying_solo', true ) ); |
| 30 |
} |
| 31 |
|
| 32 |
include dirname( __FILE__ ).'/redirection-version.php'; |
| 33 |
include dirname( __FILE__ ).'/models/redirect.php'; |
| 34 |
include dirname( __FILE__ ).'/models/module.php'; |
| 35 |
include dirname( __FILE__ ).'/models/log.php'; |
| 36 |
include dirname( __FILE__ ).'/models/flusher.php'; |
| 37 |
include dirname( __FILE__ ).'/models/match.php'; |
| 38 |
include dirname( __FILE__ ).'/models/action.php'; |
| 39 |
include dirname( __FILE__ ).'/models/request.php'; |
| 40 |
|
| 41 |
function red_get_options() { |
| 42 |
$options = get_option( 'redirection_options' ); |
| 43 |
if ( $options === false ) { |
| 44 |
$options = array(); |
| 45 |
} |
| 46 |
|
| 47 |
$defaults = apply_filters( 'red_default_options', array( |
| 48 |
'support' => false, |
| 49 |
'token' => md5( uniqid() ), |
| 50 |
'monitor_post' => 0, |
| 51 |
'auto_target' => '', |
| 52 |
'expire_redirect' => 7, |
| 53 |
'expire_404' => 7, |
| 54 |
'modules' => array(), |
| 55 |
'newsletter' => false, |
| 56 |
) ); |
| 57 |
|
| 58 |
foreach ( $defaults as $key => $value ) { |
| 59 |
if ( ! isset( $options[ $key ] ) ) { |
| 60 |
$options[ $key ] = $value; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
return $options; |
| 65 |
} |
| 66 |
|
| 67 |
function red_is_wpcli() { |
| 68 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 69 |
return true; |
| 70 |
} |
| 71 |
|
| 72 |
return false; |
| 73 |
} |
| 74 |
|
| 75 |
function red_is_admin() { |
| 76 |
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { |
| 77 |
return true; |
| 78 |
} |
| 79 |
|
| 80 |
if ( is_admin() ) { |
| 81 |
return true; |
| 82 |
} |
| 83 |
|
| 84 |
return false; |
| 85 |
} |
| 86 |
|
| 87 |
if ( red_is_wpcli() ) { |
| 88 |
include dirname( __FILE__ ).'/redirection-admin.php'; |
| 89 |
include dirname( __FILE__ ).'/redirection-cli.php'; |
| 90 |
} elseif ( red_is_admin() ) { |
| 91 |
include dirname( __FILE__ ).'/redirection-admin.php'; |
| 92 |
} else { |
| 93 |
include dirname( __FILE__ ).'/redirection-front.php'; |
| 94 |
} |
| 95 |
|