| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Redirection |
| 4 |
Plugin URI: https://redirection.me/ |
| 5 |
Description: Manage all your 301 redirects and monitor 404 errors |
| 6 |
Version: 5.6.0 |
| 7 |
Author: John Godley |
| 8 |
Text Domain: redirection |
| 9 |
Requires PHP: 7.2 |
| 10 |
Requires at least: 6.5 |
| 11 |
============================================================================================================ |
| 12 |
For full license details see license.txt |
| 13 |
============================================================================================================ |
| 14 |
*/ |
| 15 |
|
| 16 |
define( 'REDIRECTION_DB_VERSION', '4.2' ); // DB schema version. Only change if DB needs changing |
| 17 |
define( 'REDIRECTION_FILE', __FILE__ ); |
| 18 |
|
| 19 |
if ( ! defined( 'REDIRECTION_FLYING_SOLO' ) ) { |
| 20 |
define( 'REDIRECTION_FLYING_SOLO', apply_filters( 'redirection_flying_solo', true ) ); |
| 21 |
} |
| 22 |
|
| 23 |
// This file must support PHP < 7.2 so as not to crash |
| 24 |
if ( version_compare( phpversion(), '7.2' ) < 0 ) { |
| 25 |
add_filter( 'plugin_action_links_' . basename( dirname( REDIRECTION_FILE ) ) . '/' . basename( REDIRECTION_FILE ), 'red_deprecated_php' ); |
| 26 |
|
| 27 |
/** |
| 28 |
* @param array<string> $links |
| 29 |
* @return array<string> |
| 30 |
*/ |
| 31 |
function red_deprecated_php( array $links ): array { |
| 32 |
/* translators: 1: server PHP version. 2: required PHP version. */ |
| 33 |
array_unshift( $links, '<a href="https://redirection.me/support/problems/php-version/" style="color: red; text-decoration: underline">' . sprintf( __( 'Disabled! Detected PHP %1$s, need PHP %2$s+', 'redirection' ), phpversion(), '7.2' ) . '</a>' ); |
| 34 |
return $links; |
| 35 |
} |
| 36 |
|
| 37 |
return; |
| 38 |
} |
| 39 |
|
| 40 |
require_once __DIR__ . '/build/redirection-version.php'; |
| 41 |
require_once __DIR__ . '/redirection-settings.php'; |
| 42 |
require_once __DIR__ . '/models/options.php'; |
| 43 |
require_once __DIR__ . '/models/redirect/redirect.php'; |
| 44 |
require_once __DIR__ . '/models/url/url.php'; |
| 45 |
require_once __DIR__ . '/models/regex.php'; |
| 46 |
require_once __DIR__ . '/models/module.php'; |
| 47 |
require_once __DIR__ . '/models/log/log.php'; |
| 48 |
require_once __DIR__ . '/models/flusher.php'; |
| 49 |
require_once __DIR__ . '/models/match.php'; |
| 50 |
require_once __DIR__ . '/models/action.php'; |
| 51 |
require_once __DIR__ . '/models/request.php'; |
| 52 |
require_once __DIR__ . '/models/header.php'; |
| 53 |
require_once __DIR__ . '/models/group.php'; |
| 54 |
|
| 55 |
/** |
| 56 |
* @return bool |
| 57 |
*/ |
| 58 |
function red_is_wpcli() { |
| 59 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 60 |
return true; |
| 61 |
} |
| 62 |
|
| 63 |
return false; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* @return bool |
| 68 |
*/ |
| 69 |
function red_is_admin() { |
| 70 |
if ( is_admin() ) { |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* @return void |
| 79 |
*/ |
| 80 |
function red_start_rest() { |
| 81 |
require_once __DIR__ . '/redirection-admin.php'; |
| 82 |
require_once __DIR__ . '/api/api.php'; |
| 83 |
|
| 84 |
Redirection_Api::init(); |
| 85 |
Redirection_Admin::init(); |
| 86 |
|
| 87 |
remove_action( 'rest_api_init', 'red_start_rest' ); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* @return void |
| 92 |
*/ |
| 93 |
function redirection_locale() { |
| 94 |
load_plugin_textdomain( 'redirection', false, dirname( plugin_basename( REDIRECTION_FILE ) ) . '/locale/' ); |
| 95 |
} |
| 96 |
|
| 97 |
if ( red_is_admin() || red_is_wpcli() ) { |
| 98 |
require_once __DIR__ . '/redirection-admin.php'; |
| 99 |
require_once __DIR__ . '/api/api.php'; |
| 100 |
} else { |
| 101 |
require_once __DIR__ . '/redirection-front.php'; |
| 102 |
} |
| 103 |
|
| 104 |
if ( red_is_wpcli() ) { |
| 105 |
require_once __DIR__ . '/redirection-cli.php'; |
| 106 |
} |
| 107 |
|
| 108 |
add_action( 'rest_api_init', 'red_start_rest' ); |
| 109 |
add_action( 'init', 'redirection_locale' ); |
| 110 |
|