PluginProbe
Redirection / 2.7
Redirection v2.7
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
← All changes | redirection.php +42 -61 4.22.7 View file →
@@ -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.2
6 +Version: 2.7
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,39 +20,46 @@
20 20 For full license details see license.txt
21 21 ============================================================================================================
22 22 */
23 23
24 -define( 'REDIRECTION_DB_VERSION', '4.1' ); // DB schema version. Only change if DB needs changing
24 +define( 'REDIRECTION_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' ) ) {
29 - define( 'REDIRECTION_FLYING_SOLO', apply_filters( 'redirection_flying_solo', true ) );
30 -}
28 +include dirname( __FILE__ ).'/models/redirect.php';
29 +include dirname( __FILE__ ).'/models/module.php';
30 +include dirname( __FILE__ ).'/models/log.php';
31 +include dirname( __FILE__ ).'/models/flusher.php';
32 +include dirname( __FILE__ ).'/models/match.php';
33 +include dirname( __FILE__ ).'/models/action.php';
34 +include dirname( __FILE__ ).'/models/request.php';
31 35
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 );
36 +function red_get_options() {
37 + $options = get_option( 'redirection_options' );
38 + if ( $options === false ) {
39 + $options = array();
40 + }
35 41
36 - function red_deprecated_php( $links ) {
37 - /* translators: 1: PHP version */
38 - 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>' );
39 - return $links;
42 + $defaults = apply_filters( 'red_default_options', array(
43 + 'support' => false,
44 + 'token' => md5( uniqid() ),
45 + 'monitor_post' => 0,
46 + 'auto_target' => '',
47 + 'expire_redirect' => 7,
48 + 'expire_404' => 7,
49 + 'modules' => array(),
50 + 'newsletter' => false,
51 + ) );
52 +
53 + foreach ( $defaults as $key => $value ) {
54 + if ( ! isset( $options[ $key ] ) ) {
55 + $options[ $key ] = $value;
56 + }
40 57 }
41 58
42 - return;
59 + return $options;
43 60 }
44 61
45 -include dirname( __FILE__ ) . '/redirection-version.php';
46 -include dirname( __FILE__ ) . '/redirection-settings.php';
47 -include dirname( __FILE__ ) . '/models/redirect.php';
48 -include dirname( __FILE__ ) . '/models/module.php';
49 -include dirname( __FILE__ ) . '/models/log.php';
50 -include dirname( __FILE__ ) . '/models/flusher.php';
51 -include dirname( __FILE__ ) . '/models/match.php';
52 -include dirname( __FILE__ ) . '/models/action.php';
53 -include dirname( __FILE__ ) . '/models/request.php';
54 -
55 62 function red_is_wpcli() {
56 63 if ( defined( 'WP_CLI' ) && WP_CLI ) {
57 64 return true;
58 65 }
@@ -60,8 +67,12 @@
60 67 return false;
61 68 }
62 69
63 70 function red_is_admin() {
71 + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
72 + return true;
73 + }
74 +
64 75 if ( is_admin() ) {
65 76 return true;
66 77 }
67 78
@@ -67,42 +78,12 @@
67 78
68 79 return false;
69 80 }
70 81
71 -function red_start_rest() {
72 - include_once dirname( __FILE__ ) . '/redirection-admin.php';
73 - include_once dirname( __FILE__ ) . '/redirection-api.php';
74 -
75 - Redirection_Api::init();
76 - Redirection_Admin::init();
77 -
78 - remove_action( 'rest_api_init', 'red_start_rest' );
79 -}
80 -
81 -function redirection_locale() {
82 - load_plugin_textdomain( 'redirection', false, dirname( plugin_basename( REDIRECTION_FILE ) ) . '/locale/' );
83 -}
84 -
85 -if ( red_is_admin() || red_is_wpcli() ) {
86 - include_once dirname( __FILE__ ) . '/redirection-admin.php';
87 - include_once dirname( __FILE__ ) . '/redirection-api.php';
82 +if ( red_is_wpcli() ) {
83 + include dirname( __FILE__ ).'/redirection-admin.php';
84 + include dirname( __FILE__ ).'/redirection-cli.php';
85 +} elseif ( red_is_admin() ) {
86 + include dirname( __FILE__ ).'/redirection-admin.php';
88 87 } else {
89 - include_once dirname( __FILE__ ) . '/redirection-front.php';
88 + include dirname( __FILE__ ).'/redirection-front.php';
90 89 }
91 -
92 -if ( red_is_wpcli() ) {
93 - include_once dirname( __FILE__ ) . '/redirection-cli.php';
94 -}
95 -
96 -add_action( 'rest_api_init', 'red_start_rest' );
97 -add_action( 'init', 'redirection_locale' );
98 -
99 -// This is causing a lot of problems with the REST API - disable qTranslate
100 -add_filter( 'qtranslate_language_detect_redirect', function( $lang, $url ) {
101 - $url = Redirection_Request::get_request_url();
102 -
103 - if ( strpos( $url, '/wp-json/' ) !== false || strpos( $url, 'index.php?rest_route' ) !== false ) {
104 - return false;
105 - }
106 -
107 - return $lang;
108 -}, 10, 2 );