forked from Joel-James/404-to-301
-
Notifications
You must be signed in to change notification settings - Fork 0
/
404-to-301.php
executable file
·105 lines (94 loc) · 3.11 KB
/
404-to-301.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Plugin Name: 404 to 301
* Plugin URI: https://duckdev.com/products/404-to-301/
* Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
* Version: 3.0.0
* Author: Joel James
* Author URI: https://duckdev.com/
* Donate link: https://paypal.me/JoelCJ
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: 404-to-301
* Domain Path: /languages
*
* 404 to 301 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* 404 to 301 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 404 to 301. If not, see <http://www.gnu.org/licenses/>.
*
* @category Core
* @package JJ4T33
* @author Joel James <[email protected]>
* @license http://www.gnu.org/licenses/ GNU General Public License
* @link https://duckdev.com/products/404-to-301/
*/
// If this file is called directly, abort.
defined( 'ABSPATH' ) or exit;
// Stay lazy if our class is already there.
if ( ! class_exists( 'JJ_404_to_301' ) ) :
/**
* File that contains main plugin class.
*/
require_once plugin_dir_path( __FILE__ ) . 'includes/class-jj-404-to-301.php';
/**
* Setup plugin constants.
*
* We need a few constants in our plugin.
* These values should be constant and con't
* be altered later.
*
* @since 2.0.0
* @access private
*
* @return void
*/
function jj4t3_set_constants() {
$constants = array(
'JJ4T3_NAME' => '404-to-301',
'JJ4T3_DOMAIN' => '404-to-301',
'JJ4T3_DIR' => plugin_dir_path( __FILE__ ),
'JJ4T3_URL' => plugin_dir_url( __FILE__ ),
'JJ4T3_BASE_FILE' => __FILE__,
'JJ4T3_VERSION' => '3.0.0',
'JJ4T3_DB_VERSION' => '11.0',
'JJ4T3_TABLE' => $GLOBALS['wpdb']->prefix . '404_to_301',
// Set who all can access plugin settings.
// You can change this if you want to give others access.
'JJ4T3_ACCESS' => 'manage_options',
);
foreach ( $constants as $constant => $value ) {
if ( ! defined( $constant ) ) {
define( $constant, $value );
}
}
}
/**
* The main function for that returns JJ_404_to_301
*
* The main function responsible for returning the one true JJ_404_to_301
* instance to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Example: <?php $jj4t3 = JJ_404_to_301(); ?>
*
* @since 3.0.0
*
* @return JJ_404_to_301|object
*/
function JJ_404_to_301() {
jj4t3_set_constants();
return JJ_404_to_301::instance();
}
JJ_404_to_301();
endif; // End if class_exists check.