| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: Redirection |
| 4 | -Plugin URI: https://redirection.me/ | |
| 4 | +Plugin URI: http://urbangiraffe.com/plugins/redirection/ | |
| 5 | 5 | Description: Manage all your 301 redirects and monitor 404 errors |
| 6 | -Version: 4.0 | |
| 6 | +Version: 2.9 | |
| 7 | 7 | Author: John Godley |
| 8 | -Author URI: https://johngodley.com | |
| 8 | +Author URI: http://urbangiraffe.com | |
| 9 | 9 | Text Domain: redirection |
| 10 | 10 | Domain Path: /locale |
| 11 | 11 | ============================================================================================================ |
| 12 | 12 | This software is provided "as is" and any express or implied warranties, including, but not limited to, the |
| @@ -20,38 +20,26 @@ | ||
| 20 | 20 | For full license details see license.txt |
| 21 | 21 | ============================================================================================================ |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -define( 'REDIRECTION_DB_VERSION', '4.0' ); // DB schema version. Only change if DB needs changing | |
| 24 | +define( 'REDIRECTION_DB_VERSION', '2.3.3' ); // DB schema version. Only change if DB needs changing | |
| 25 | 25 | define( 'REDIRECTION_FILE', __FILE__ ); |
| 26 | 26 | define( 'REDIRECTION_DEV_MODE', false ); |
| 27 | 27 | |
| 28 | -if ( ! defined( 'REDIRECTION_FLYING_SOLO' ) ) { | |
| 28 | +if ( !defined( 'REDIRECTION_FLYING_SOLO' ) ) { | |
| 29 | 29 | define( 'REDIRECTION_FLYING_SOLO', apply_filters( 'redirection_flying_solo', true ) ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -// This file must support PHP < 5.4 so as not to crash | |
| 33 | -if ( version_compare( phpversion(), '5.4' ) < 0 ) { | |
| 34 | - add_action( 'plugin_action_links_' . basename( dirname( REDIRECTION_FILE ) ) . '/' . basename( REDIRECTION_FILE ), 'red_deprecated_php', 10, 4 ); | |
| 32 | +include dirname( __FILE__ ).'/redirection-version.php'; | |
| 33 | +include dirname( __FILE__ ).'/redirection-settings.php'; | |
| 34 | +include dirname( __FILE__ ).'/models/redirect.php'; | |
| 35 | +include dirname( __FILE__ ).'/models/module.php'; | |
| 36 | +include dirname( __FILE__ ).'/models/log.php'; | |
| 37 | +include dirname( __FILE__ ).'/models/flusher.php'; | |
| 38 | +include dirname( __FILE__ ).'/models/match.php'; | |
| 39 | +include dirname( __FILE__ ).'/models/action.php'; | |
| 40 | +include dirname( __FILE__ ).'/models/request.php'; | |
| 35 | 41 | |
| 36 | - function red_deprecated_php( $links ) { | |
| 37 | - array_unshift( $links, '<a href="https://redirection.me/support/problems/php-version/" style="color: red; text-decoration: underline">' . sprintf( __( 'Disabled! Detected PHP %s, need PHP 5.4+', 'redirection' ), phpversion() ) . '</a>' ); | |
| 38 | - return $links; | |
| 39 | - } | |
| 40 | - | |
| 41 | - return; | |
| 42 | -} | |
| 43 | - | |
| 44 | -include dirname( __FILE__ ) . '/redirection-version.php'; | |
| 45 | -include dirname( __FILE__ ) . '/redirection-settings.php'; | |
| 46 | -include dirname( __FILE__ ) . '/models/redirect.php'; | |
| 47 | -include dirname( __FILE__ ) . '/models/module.php'; | |
| 48 | -include dirname( __FILE__ ) . '/models/log.php'; | |
| 49 | -include dirname( __FILE__ ) . '/models/flusher.php'; | |
| 50 | -include dirname( __FILE__ ) . '/models/match.php'; | |
| 51 | -include dirname( __FILE__ ) . '/models/action.php'; | |
| 52 | -include dirname( __FILE__ ) . '/models/request.php'; | |
| 53 | - | |
| 54 | 42 | function red_is_wpcli() { |
| 55 | 43 | if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 56 | 44 | return true; |
| 57 | 45 | } |
| @@ -59,8 +47,12 @@ | ||
| 59 | 47 | return false; |
| 60 | 48 | } |
| 61 | 49 | |
| 62 | 50 | function red_is_admin() { |
| 51 | + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { | |
| 52 | + return true; | |
| 53 | + } | |
| 54 | + | |
| 63 | 55 | if ( is_admin() ) { |
| 64 | 56 | return true; |
| 65 | 57 | } |
| 66 | 58 | |
| @@ -66,31 +58,12 @@ | ||
| 66 | 58 | |
| 67 | 59 | return false; |
| 68 | 60 | } |
| 69 | 61 | |
| 70 | -function red_start_rest() { | |
| 71 | - include_once dirname( __FILE__ ) . '/redirection-admin.php'; | |
| 72 | - include_once dirname( __FILE__ ) . '/redirection-api.php'; | |
| 73 | - | |
| 74 | - Redirection_Api::init(); | |
| 75 | - Redirection_Admin::init(); | |
| 76 | - | |
| 77 | - remove_action( 'rest_api_init', 'red_start_rest' ); | |
| 78 | -} | |
| 79 | - | |
| 80 | -function redirection_locale() { | |
| 81 | - load_plugin_textdomain( 'redirection', false, dirname( plugin_basename( REDIRECTION_FILE ) ) . '/locale/' ); | |
| 82 | -} | |
| 83 | - | |
| 84 | -if ( red_is_admin() || red_is_wpcli() ) { | |
| 85 | - include_once dirname( __FILE__ ) . '/redirection-admin.php'; | |
| 86 | - include_once dirname( __FILE__ ) . '/redirection-api.php'; | |
| 62 | +if ( red_is_wpcli() ) { | |
| 63 | + include dirname( __FILE__ ).'/redirection-admin.php'; | |
| 64 | + include dirname( __FILE__ ).'/redirection-cli.php'; | |
| 65 | +} elseif ( red_is_admin() ) { | |
| 66 | + include dirname( __FILE__ ).'/redirection-admin.php'; | |
| 87 | 67 | } else { |
| 88 | - include_once dirname( __FILE__ ) . '/redirection-front.php'; | |
| 68 | + include dirname( __FILE__ ).'/redirection-front.php'; | |
| 89 | 69 | } |
| 90 | - | |
| 91 | -if ( red_is_wpcli() ) { | |
| 92 | - include_once dirname( __FILE__ ) . '/redirection-cli.php'; | |
| 93 | -} | |
| 94 | - | |
| 95 | -add_action( 'rest_api_init', 'red_start_rest' ); | |
| 96 | -add_action( 'init', 'redirection_locale' ); | |