Version Description
Added support for custom plugin directories.
Download this release
Release Info
Developer | shawn@eggplantstudios.ca |
Plugin | Eggplant 301 Redirects |
Version | 2.2.6 |
Comparing to | |
See all releases |
Code changes from version 2.2.5 to 2.2.6
- css/eps_redirect.css +15 -0
- eps-301-redirects.php +20 -73
- libs/eps-plugin-options.php +55 -7
- libs/eps-plugin.php +12 -12
- plugin.php +24 -12
- readme.txt +16 -1
- templates/admin-tab-404s.php +26 -14
- templates/admin-tab-error.php +32 -0
- templates/admin-tab-import-export.php +0 -1
- templates/admin-tab-redirects.php +2 -2
- templates/template.404-entry.php +0 -26
css/eps_redirect.css
CHANGED
@@ -261,6 +261,21 @@ select.eps-small-select { display: inline-block; }
|
|
261 |
|
262 |
.padding { padding: 16px; }
|
263 |
.padding-lots { padding: 32px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
/*----------------------------------------------------------*/
|
265 |
/*-------------------- media queries ---------------------*/
|
266 |
/*----------------------------------------------------------*/
|
261 |
|
262 |
.padding { padding: 16px; }
|
263 |
.padding-lots { padding: 32px; }
|
264 |
+
|
265 |
+
|
266 |
+
.eps-notice {
|
267 |
+
padding: 16px;
|
268 |
+
margin: 6px auto;
|
269 |
+
background: white;
|
270 |
+
box-shadow: 1px 1px 4px #dddddd;
|
271 |
+
border-left: 3px solid #888888;
|
272 |
+
font-weight: bold;
|
273 |
+
font-size: 14px;
|
274 |
+
}
|
275 |
+
.eps-notice.eps-warning {
|
276 |
+
border-left: 3px solid #940000;
|
277 |
+
color: #940000;
|
278 |
+
}
|
279 |
/*----------------------------------------------------------*/
|
280 |
/*-------------------- media queries ---------------------*/
|
281 |
/*----------------------------------------------------------*/
|
eps-301-redirects.php
CHANGED
@@ -13,19 +13,19 @@
|
|
13 |
* PHP version 5
|
14 |
*
|
15 |
*
|
16 |
-
* @package EPS 301 Redirects
|
17 |
* @author Shawn Wernig ( shawn@eggplantstudios.ca )
|
18 |
-
* @version 2.2.
|
19 |
*/
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
/*
|
25 |
-
Plugin Name: Eggplant 301 Redirects
|
26 |
Plugin URI: http://www.eggplantstudios.ca
|
27 |
Description: Create your own 301 redirects using this powerful plugin.
|
28 |
-
Version: 2.2.
|
29 |
Author: Shawn Wernig http://www.eggplantstudios.ca
|
30 |
License: GPLv2 or later
|
31 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -34,21 +34,20 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
34 |
if( ! defined( 'EPS_REDIRECT_PRO' ) )
|
35 |
{
|
36 |
|
37 |
-
|
38 |
define ( 'EPS_REDIRECT_PATH', plugin_dir_path(__FILE__) );
|
39 |
-
define ( 'EPS_REDIRECT_URL',
|
40 |
-
define ( 'EPS_REDIRECT_VERSION', '2.2.
|
41 |
-
define ( 'EPS_REDIRECT_PRO',
|
42 |
|
43 |
-
include(EPS_REDIRECT_PATH.'eps-form-elements.php');
|
44 |
-
include(EPS_REDIRECT_PATH.'class.drop-down-pages.php');
|
45 |
-
include(EPS_REDIRECT_PATH.'libs/eps-plugin.php');
|
46 |
-
include(EPS_REDIRECT_PATH.'libs/eps-plugin-options.php');
|
47 |
-
include(EPS_REDIRECT_PATH.'plugin.php');
|
48 |
|
49 |
|
50 |
|
51 |
-
class
|
52 |
|
53 |
/**
|
54 |
*
|
@@ -151,6 +150,10 @@ class EPS_Redirects_Pro {
|
|
151 |
*
|
152 |
*/
|
153 |
private function format_from_url( $string ) {
|
|
|
|
|
|
|
|
|
154 |
$complete = home_url() . '/' . $string;
|
155 |
list($uprotocol,$uempty,$uhost,$from) = explode( '/', $complete, 4);
|
156 |
$from = '/' . $from;
|
@@ -521,67 +524,11 @@ class EPS_Redirects_Pro {
|
|
521 |
file_put_contents(EPS_REDIRECT_PATH. '/error_activation.html', ob_get_contents());
|
522 |
}
|
523 |
|
524 |
-
|
525 |
-
/**
|
526 |
-
*
|
527 |
-
* 404 Stuff!
|
528 |
-
*
|
529 |
-
* This function will output a variable containing the admin ajax url for use in javascript.
|
530 |
-
*
|
531 |
-
* @author epstudios
|
532 |
-
*
|
533 |
-
*/
|
534 |
-
|
535 |
-
public static function get_404s() {
|
536 |
-
global $wpdb;
|
537 |
-
$table_name = $wpdb->prefix . "redirects";
|
538 |
-
|
539 |
-
$results = $wpdb->get_results(
|
540 |
-
"SELECT * FROM $table_name WHERE status = 404 ORDER BY id DESC"
|
541 |
-
);
|
542 |
-
|
543 |
-
return $results;
|
544 |
-
}
|
545 |
public static function check_404()
|
546 |
{
|
547 |
-
global $wp_query;
|
548 |
|
549 |
-
if ( $wp_query->is_404() )
|
550 |
-
{
|
551 |
-
$entries = array(
|
552 |
-
array(
|
553 |
-
'url_from' => ltrim( self::get_url(), '/' ),
|
554 |
-
'url_to' => '',
|
555 |
-
'type' => '',
|
556 |
-
'status' => 404,
|
557 |
-
'count' => 1
|
558 |
-
)
|
559 |
-
);
|
560 |
-
|
561 |
-
if( $entry = self::redirect_exists( $entries[0] ) )
|
562 |
-
{
|
563 |
-
self::increment_field($entry->id, 'count');
|
564 |
-
}
|
565 |
-
else
|
566 |
-
{
|
567 |
-
self::_save_redirects( $entries );
|
568 |
-
}
|
569 |
-
}
|
570 |
}
|
571 |
-
public static function list_404s(){
|
572 |
-
$redirects = self::get_404s( );
|
573 |
-
$html = '';
|
574 |
-
if (empty($redirects)) return false;
|
575 |
-
ob_start();
|
576 |
-
foreach ($redirects as $redirect ) {
|
577 |
-
$dfrom = urldecode($redirect->url_from);
|
578 |
-
include( EPS_REDIRECT_PATH . 'templates/template.404-entry.php');
|
579 |
-
}
|
580 |
-
$html = ob_get_contents();
|
581 |
-
ob_end_clean();
|
582 |
-
return $html;
|
583 |
-
}
|
584 |
-
|
585 |
|
586 |
}
|
587 |
|
@@ -614,12 +561,12 @@ function eps_view( $object ) {
|
|
614 |
|
615 |
|
616 |
// Run the plugin.
|
617 |
-
$EPS_Redirects = new
|
618 |
|
619 |
}
|
620 |
else
|
621 |
{
|
622 |
-
if( EPS_REDIRECT_PRO ===
|
623 |
{
|
624 |
add_action( 'admin_notices', 'eps_redirects_pro_conflict' );
|
625 |
function eps_redirects_pro_conflict()
|
13 |
* PHP version 5
|
14 |
*
|
15 |
*
|
16 |
+
* @package EPS 301 Redirects
|
17 |
* @author Shawn Wernig ( shawn@eggplantstudios.ca )
|
18 |
+
* @version 2.2.6
|
19 |
*/
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
/*
|
25 |
+
Plugin Name: Eggplant 301 Redirects
|
26 |
Plugin URI: http://www.eggplantstudios.ca
|
27 |
Description: Create your own 301 redirects using this powerful plugin.
|
28 |
+
Version: 2.2.6
|
29 |
Author: Shawn Wernig http://www.eggplantstudios.ca
|
30 |
License: GPLv2 or later
|
31 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
34 |
if( ! defined( 'EPS_REDIRECT_PRO' ) )
|
35 |
{
|
36 |
|
|
|
37 |
define ( 'EPS_REDIRECT_PATH', plugin_dir_path(__FILE__) );
|
38 |
+
define ( 'EPS_REDIRECT_URL', plugins_url() . '/eps-301-redirects/');
|
39 |
+
define ( 'EPS_REDIRECT_VERSION', '2.2.6');
|
40 |
+
define ( 'EPS_REDIRECT_PRO', false);
|
41 |
|
42 |
+
include( EPS_REDIRECT_PATH.'eps-form-elements.php');
|
43 |
+
include( EPS_REDIRECT_PATH.'class.drop-down-pages.php');
|
44 |
+
include( EPS_REDIRECT_PATH.'libs/eps-plugin.php');
|
45 |
+
include( EPS_REDIRECT_PATH.'libs/eps-plugin-options.php');
|
46 |
+
include( EPS_REDIRECT_PATH.'plugin.php');
|
47 |
|
48 |
|
49 |
|
50 |
+
class EPS_Redirects {
|
51 |
|
52 |
/**
|
53 |
*
|
150 |
*
|
151 |
*/
|
152 |
private function format_from_url( $string ) {
|
153 |
+
//$from = home_url() . '/' . $string;
|
154 |
+
//return strtolower( rtrim( $from,'/') );
|
155 |
+
|
156 |
+
|
157 |
$complete = home_url() . '/' . $string;
|
158 |
list($uprotocol,$uempty,$uhost,$from) = explode( '/', $complete, 4);
|
159 |
$from = '/' . $from;
|
524 |
file_put_contents(EPS_REDIRECT_PATH. '/error_activation.html', ob_get_contents());
|
525 |
}
|
526 |
|
527 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
public static function check_404()
|
529 |
{
|
|
|
530 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
|
533 |
}
|
534 |
|
561 |
|
562 |
|
563 |
// Run the plugin.
|
564 |
+
$EPS_Redirects = new EPS_Redirects();
|
565 |
|
566 |
}
|
567 |
else
|
568 |
{
|
569 |
+
if( EPS_REDIRECT_PRO === true )
|
570 |
{
|
571 |
add_action( 'admin_notices', 'eps_redirects_pro_conflict' );
|
572 |
function eps_redirects_pro_conflict()
|
libs/eps-plugin-options.php
CHANGED
@@ -51,16 +51,63 @@ class EPS_Plugin_Options {
|
|
51 |
*
|
52 |
*/
|
53 |
private function build_settings() {
|
54 |
-
$this->settings = $this->
|
55 |
}
|
56 |
|
57 |
-
private function
|
58 |
{
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
return $data;
|
62 |
}
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
/**
|
65 |
*
|
66 |
* Build the setting slug based on section.
|
@@ -147,6 +194,8 @@ class EPS_Plugin_Options {
|
|
147 |
|
148 |
}
|
149 |
|
|
|
|
|
150 |
/**
|
151 |
*
|
152 |
* Outputs the Sections intro HTML. A callback.
|
@@ -156,7 +205,7 @@ class EPS_Plugin_Options {
|
|
156 |
* @param $args
|
157 |
*
|
158 |
*/
|
159 |
-
function section_callback( $args ) {
|
160 |
if( isset( $_GET['tab'] ) )
|
161 |
{
|
162 |
$tab = $_GET['tab'];
|
@@ -166,7 +215,6 @@ class EPS_Plugin_Options {
|
|
166 |
$sections = array_keys( $this->settings );
|
167 |
$tab = $sections[0];
|
168 |
}
|
169 |
-
|
170 |
echo $this->settings[$tab]['description'];
|
171 |
}
|
172 |
|
@@ -271,7 +319,7 @@ class EPS_Plugin_Options {
|
|
271 |
if ( $this->tab_exists( $tab ) ) {
|
272 |
|
273 |
|
274 |
-
if(has_action( $tab.'_admin_tab'))
|
275 |
{
|
276 |
do_action( $tab.'_admin_tab', $this->settings[$tab] );
|
277 |
}
|
51 |
*
|
52 |
*/
|
53 |
private function build_settings() {
|
54 |
+
$this->settings = $this->read_settings( EPS_REDIRECT_PATH . 'options.json' );
|
55 |
}
|
56 |
|
57 |
+
private function read_settings( $uri )
|
58 |
{
|
59 |
+
if( file_exists( $uri ) )
|
60 |
+
{
|
61 |
+
if ( is_readable( $uri ) )
|
62 |
+
{
|
63 |
+
$data = $this->read_json_from_file($uri);
|
64 |
+
}
|
65 |
+
else
|
66 |
+
{
|
67 |
+
chmod($uri, 0644);
|
68 |
+
$data = $this->read_json_from_file($uri);
|
69 |
+
if( $data )
|
70 |
+
{
|
71 |
+
$data = array(
|
72 |
+
'error' => array(
|
73 |
+
"title" => "Oops!",
|
74 |
+
"description" => "An essential file (options.json) could not be read. Please check your folder permissions.",
|
75 |
+
"callback" => "error",
|
76 |
+
"fields" => ''
|
77 |
+
)
|
78 |
+
);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
else
|
83 |
+
{
|
84 |
+
$data = array(
|
85 |
+
'error' => array(
|
86 |
+
"title" => "Oops!",
|
87 |
+
"description" => "An essential file (options.json) could not be found. Please re-install the plugin.",
|
88 |
+
"callback" => "error",
|
89 |
+
"fields" => ''
|
90 |
+
)
|
91 |
+
);
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
return $data;
|
96 |
}
|
97 |
|
98 |
+
private function read_json_from_file($uri)
|
99 |
+
{
|
100 |
+
try
|
101 |
+
{
|
102 |
+
$json = file_get_contents( $uri );
|
103 |
+
return json_decode($json,true);
|
104 |
+
}
|
105 |
+
catch( Exception $e )
|
106 |
+
{
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
/**
|
112 |
*
|
113 |
* Build the setting slug based on section.
|
194 |
|
195 |
}
|
196 |
|
197 |
+
|
198 |
+
|
199 |
/**
|
200 |
*
|
201 |
* Outputs the Sections intro HTML. A callback.
|
205 |
* @param $args
|
206 |
*
|
207 |
*/
|
208 |
+
function section_callback( $args ) {
|
209 |
if( isset( $_GET['tab'] ) )
|
210 |
{
|
211 |
$tab = $_GET['tab'];
|
215 |
$sections = array_keys( $this->settings );
|
216 |
$tab = $sections[0];
|
217 |
}
|
|
|
218 |
echo $this->settings[$tab]['description'];
|
219 |
}
|
220 |
|
319 |
if ( $this->tab_exists( $tab ) ) {
|
320 |
|
321 |
|
322 |
+
if( has_action( $tab.'_admin_tab'))
|
323 |
{
|
324 |
do_action( $tab.'_admin_tab', $this->settings[$tab] );
|
325 |
}
|
libs/eps-plugin.php
CHANGED
@@ -8,8 +8,6 @@
|
|
8 |
* @package EPS Boilerplate
|
9 |
*/
|
10 |
|
11 |
-
require_once('eps-plugin-options.php');
|
12 |
-
|
13 |
if( ! class_exists('EPS_Plugin') )
|
14 |
{
|
15 |
class EPS_Plugin {
|
@@ -51,11 +49,13 @@ if( ! class_exists('EPS_Plugin') )
|
|
51 |
*/
|
52 |
public function __construct(){
|
53 |
$this->config['url'] = plugins_url() . $this->config['directory'] . '/';
|
54 |
-
$this->config['path'] =
|
55 |
-
|
|
|
|
|
56 |
|
57 |
-
register_activation_hook( __FILE__, array($this
|
58 |
-
register_deactivation_hook( __FILE__, array($this
|
59 |
if ( !self::is_current_version() ) self::update_self();
|
60 |
add_action('init', array($this, 'plugin_resources'));
|
61 |
}
|
@@ -109,17 +109,17 @@ if( ! class_exists('EPS_Plugin') )
|
|
109 |
|
110 |
public function _deactivation() {}
|
111 |
|
112 |
-
public function is_current_version()
|
113 |
{
|
114 |
-
return version_compare(
|
115 |
}
|
116 |
-
public function current_version()
|
117 |
{
|
118 |
-
return get_option(
|
119 |
}
|
120 |
-
public function set_current_version( $version )
|
121 |
{
|
122 |
-
update_option(
|
123 |
}
|
124 |
/**
|
125 |
*
|
8 |
* @package EPS Boilerplate
|
9 |
*/
|
10 |
|
|
|
|
|
11 |
if( ! class_exists('EPS_Plugin') )
|
12 |
{
|
13 |
class EPS_Plugin {
|
49 |
*/
|
50 |
public function __construct(){
|
51 |
$this->config['url'] = plugins_url() . $this->config['directory'] . '/';
|
52 |
+
$this->config['path'] = EPS_REDIRECT_PATH . $this->config['directory'] . '/';
|
53 |
+
|
54 |
+
if( class_exists('EPS_Plugin_Options') )
|
55 |
+
$this->settings = new EPS_Plugin_Options( $this );
|
56 |
|
57 |
+
register_activation_hook( __FILE__, array($this, '_activation'));
|
58 |
+
register_deactivation_hook( __FILE__, array($this, '_deactivation'));
|
59 |
if ( !self::is_current_version() ) self::update_self();
|
60 |
add_action('init', array($this, 'plugin_resources'));
|
61 |
}
|
109 |
|
110 |
public function _deactivation() {}
|
111 |
|
112 |
+
public static function is_current_version()
|
113 |
{
|
114 |
+
return version_compare( self::current_version(), EPS_REDIRECT_VERSION, '=') ? true : false; // TODO decouple
|
115 |
}
|
116 |
+
public static function current_version()
|
117 |
{
|
118 |
+
return get_option( 'eps_redirects_version' ); // TODO decouple
|
119 |
}
|
120 |
+
public static function set_current_version( $version )
|
121 |
{
|
122 |
+
update_option( 'eps_redirects_version', $version );
|
123 |
}
|
124 |
/**
|
125 |
*
|
plugin.php
CHANGED
@@ -7,6 +7,8 @@
|
|
7 |
*
|
8 |
*/
|
9 |
|
|
|
|
|
10 |
|
11 |
class EPS_Redirects_Plugin extends EPS_Plugin {
|
12 |
|
@@ -33,16 +35,22 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
33 |
// Template Hooks
|
34 |
add_action( 'redirects_admin_tab', array($this, 'admin_tab_redirects'), 10, 1 );
|
35 |
add_action( '404s_admin_tab', array($this, 'admin_tab_404s'), 10, 1 );
|
|
|
36 |
add_action( 'import-export_admin_tab', array($this, 'admin_tab_import_export'), 10, 1 );
|
37 |
add_action( 'eps_redirects_panels_left', array($this, 'admin_panel_cache'));
|
38 |
add_action( 'eps_redirects_panels_right', array($this, 'admin_panel_donate'));
|
39 |
-
add_action('eps_redirects_admin_head', array($this, 'admin_header_notices'));
|
40 |
|
41 |
// Actions
|
42 |
-
add_action('admin_init', array($this, 'check_plugin_actions'));
|
43 |
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
46 |
/**
|
47 |
*
|
48 |
* update_self
|
@@ -55,9 +63,7 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
55 |
*/
|
56 |
public function update_self()
|
57 |
{
|
58 |
-
|
59 |
$version = get_option( 'eps_redirects_version' );
|
60 |
-
$this->_create_tables(); // Maybe create the tables
|
61 |
|
62 |
if( version_compare($version, '2.0.0', '<')) {
|
63 |
// migrate old format to new format.
|
@@ -94,7 +100,7 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
94 |
);
|
95 |
}
|
96 |
|
97 |
-
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -107,7 +113,7 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
107 |
* @author epstudios
|
108 |
*
|
109 |
*/
|
110 |
-
public function
|
111 |
{
|
112 |
global $wpdb;
|
113 |
|
@@ -146,6 +152,8 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
146 |
global $EPS_Redirects_Plugin;
|
147 |
if( is_admin() && isset($_GET['page']) && $_GET['page'] == $EPS_Redirects_Plugin->config('page_slug') ) {
|
148 |
wp_enqueue_script('jquery');
|
|
|
|
|
149 |
wp_enqueue_script('eps_redirect_script', EPS_REDIRECT_URL .'js/scripts.js');
|
150 |
wp_enqueue_style('eps_redirect_styles', EPS_REDIRECT_URL .'css/eps_redirect.css');
|
151 |
}
|
@@ -185,7 +193,7 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
185 |
|
186 |
// Save Redirects
|
187 |
if ( isset( $_POST['eps_redirect_submit'] ) && wp_verify_nonce( $_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce') ) {
|
188 |
-
self::_save_redirects(
|
189 |
}
|
190 |
}
|
191 |
}
|
@@ -201,7 +209,7 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
201 |
*/
|
202 |
public static function export_csv()
|
203 |
{
|
204 |
-
$entries =
|
205 |
$filename = sprintf("%s-redirects.csv",
|
206 |
date('Y-m-d')
|
207 |
);
|
@@ -310,19 +318,19 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
310 |
switch( strtolower( $_POST['eps_redirect_upload_method'] ) )
|
311 |
{
|
312 |
case 'skip':
|
313 |
-
if( !
|
314 |
{
|
315 |
$save_redirects[] = $redirect;
|
316 |
}
|
317 |
break;
|
318 |
case 'update':
|
319 |
-
if( $entry =
|
320 |
{
|
321 |
$redirect['id'] = $entry->id;
|
322 |
}
|
323 |
$save_redirects[] = $redirect;
|
324 |
break;
|
325 |
-
|
326 |
$save_redirects[] = $redirect;
|
327 |
break;
|
328 |
}
|
@@ -330,7 +338,7 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
330 |
|
331 |
if( ! empty( $save_redirects ) )
|
332 |
{
|
333 |
-
|
334 |
add_action( 'admin_notices', array($this, 'admin_notice_upload_success') );
|
335 |
}
|
336 |
else
|
@@ -376,6 +384,10 @@ class EPS_Redirects_Plugin extends EPS_Plugin {
|
|
376 |
{
|
377 |
include ( EPS_REDIRECT_PATH . 'templates/admin-tab-import-export.php' );
|
378 |
}
|
|
|
|
|
|
|
|
|
379 |
|
380 |
public static function admin_header_notices()
|
381 |
{
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
+
register_activation_hook( __FILE__, array('EPS_Redirects_Plugin', '_activation'));
|
11 |
+
register_deactivation_hook( __FILE__, array('EPS_Redirects_Plugin', '_deactivation'));
|
12 |
|
13 |
class EPS_Redirects_Plugin extends EPS_Plugin {
|
14 |
|
35 |
// Template Hooks
|
36 |
add_action( 'redirects_admin_tab', array($this, 'admin_tab_redirects'), 10, 1 );
|
37 |
add_action( '404s_admin_tab', array($this, 'admin_tab_404s'), 10, 1 );
|
38 |
+
add_action( 'error_admin_tab', array($this, 'admin_tab_error'), 10, 1 );
|
39 |
add_action( 'import-export_admin_tab', array($this, 'admin_tab_import_export'), 10, 1 );
|
40 |
add_action( 'eps_redirects_panels_left', array($this, 'admin_panel_cache'));
|
41 |
add_action( 'eps_redirects_panels_right', array($this, 'admin_panel_donate'));
|
42 |
+
add_action( 'eps_redirects_admin_head', array($this, 'admin_header_notices'));
|
43 |
|
44 |
// Actions
|
45 |
+
add_action( 'admin_init', array($this, 'check_plugin_actions'));
|
46 |
|
47 |
}
|
48 |
|
49 |
+
public function _activation()
|
50 |
+
{
|
51 |
+
self::_create_redirect_table(); // Maybe create the tables
|
52 |
+
if ( !self::is_current_version() ) self::update_self();
|
53 |
+
}
|
54 |
/**
|
55 |
*
|
56 |
* update_self
|
63 |
*/
|
64 |
public function update_self()
|
65 |
{
|
|
|
66 |
$version = get_option( 'eps_redirects_version' );
|
|
|
67 |
|
68 |
if( version_compare($version, '2.0.0', '<')) {
|
69 |
// migrate old format to new format.
|
100 |
);
|
101 |
}
|
102 |
|
103 |
+
EPS_Redirects::_save_redirects( $new_redirects );
|
104 |
}
|
105 |
|
106 |
/**
|
113 |
* @author epstudios
|
114 |
*
|
115 |
*/
|
116 |
+
public static function _create_redirect_table()
|
117 |
{
|
118 |
global $wpdb;
|
119 |
|
152 |
global $EPS_Redirects_Plugin;
|
153 |
if( is_admin() && isset($_GET['page']) && $_GET['page'] == $EPS_Redirects_Plugin->config('page_slug') ) {
|
154 |
wp_enqueue_script('jquery');
|
155 |
+
|
156 |
+
|
157 |
wp_enqueue_script('eps_redirect_script', EPS_REDIRECT_URL .'js/scripts.js');
|
158 |
wp_enqueue_style('eps_redirect_styles', EPS_REDIRECT_URL .'css/eps_redirect.css');
|
159 |
}
|
193 |
|
194 |
// Save Redirects
|
195 |
if ( isset( $_POST['eps_redirect_submit'] ) && wp_verify_nonce( $_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce') ) {
|
196 |
+
self::_save_redirects( EPS_Redirects::_parse_serial_array($_POST['redirect']) );
|
197 |
}
|
198 |
}
|
199 |
}
|
209 |
*/
|
210 |
public static function export_csv()
|
211 |
{
|
212 |
+
$entries = EPS_Redirects::get_all();
|
213 |
$filename = sprintf("%s-redirects.csv",
|
214 |
date('Y-m-d')
|
215 |
);
|
318 |
switch( strtolower( $_POST['eps_redirect_upload_method'] ) )
|
319 |
{
|
320 |
case 'skip':
|
321 |
+
if( ! EPS_Redirects::redirect_exists( $redirect ) )
|
322 |
{
|
323 |
$save_redirects[] = $redirect;
|
324 |
}
|
325 |
break;
|
326 |
case 'update':
|
327 |
+
if( $entry = EPS_Redirects::redirect_exists( $redirect ) )
|
328 |
{
|
329 |
$redirect['id'] = $entry->id;
|
330 |
}
|
331 |
$save_redirects[] = $redirect;
|
332 |
break;
|
333 |
+
default:
|
334 |
$save_redirects[] = $redirect;
|
335 |
break;
|
336 |
}
|
338 |
|
339 |
if( ! empty( $save_redirects ) )
|
340 |
{
|
341 |
+
EPS_Redirects::_save_redirects( $save_redirects );
|
342 |
add_action( 'admin_notices', array($this, 'admin_notice_upload_success') );
|
343 |
}
|
344 |
else
|
384 |
{
|
385 |
include ( EPS_REDIRECT_PATH . 'templates/admin-tab-import-export.php' );
|
386 |
}
|
387 |
+
public static function admin_tab_error( $options )
|
388 |
+
{
|
389 |
+
include ( EPS_REDIRECT_PATH . 'templates/admin-tab-error.php' );
|
390 |
+
}
|
391 |
|
392 |
public static function admin_header_notices()
|
393 |
{
|
readme.txt
CHANGED
@@ -10,7 +10,7 @@ Requires at least: 3.0.1
|
|
10 |
|
11 |
Tested up to: 4.2.1
|
12 |
|
13 |
-
Stable tag: 2.2.
|
14 |
|
15 |
License: GPLv2 or later
|
16 |
|
@@ -116,6 +116,15 @@ By default, any URL with a query string is considered unique, and will redirect
|
|
116 |
|
117 |
== Changelog ==
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
= 2.2.0 =
|
120 |
Minor bug fixes. Greatly improved import feature. Redirects include query strings. Export feature added. Http/Https agnostic. Pro version added with 404 management.
|
121 |
|
@@ -164,6 +173,12 @@ Overhauled the entire plugin. Redirects are stored in their own table. Gracefull
|
|
164 |
|
165 |
== Upgrade Notice ==
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
= 2.2.0 =
|
168 |
Minor bug fixes. Greatly improved import feature, added Export feature plus many other updates. A Pro Version is now available with 404 Management!
|
169 |
|
10 |
|
11 |
Tested up to: 4.2.1
|
12 |
|
13 |
+
Stable tag: 2.2.6
|
14 |
|
15 |
License: GPLv2 or later
|
16 |
|
116 |
|
117 |
== Changelog ==
|
118 |
|
119 |
+
= 2.2.6 =
|
120 |
+
Added support for custom plugin directories.
|
121 |
+
|
122 |
+
= 2.2.4 =
|
123 |
+
Support for older versions of PHP.
|
124 |
+
|
125 |
+
= 2.2.3 =
|
126 |
+
Fixed an issue where the redirect database tables were not being created, causing 'Invalid Destination URL' errors.
|
127 |
+
|
128 |
= 2.2.0 =
|
129 |
Minor bug fixes. Greatly improved import feature. Redirects include query strings. Export feature added. Http/Https agnostic. Pro version added with 404 management.
|
130 |
|
173 |
|
174 |
== Upgrade Notice ==
|
175 |
|
176 |
+
= 2.2.6 =
|
177 |
+
Added support for custom plugin directories.
|
178 |
+
|
179 |
+
= 2.2.4 =
|
180 |
+
Support for older versions of PHP.
|
181 |
+
|
182 |
= 2.2.0 =
|
183 |
Minor bug fixes. Greatly improved import feature, added Export feature plus many other updates. A Pro Version is now available with 404 Management!
|
184 |
|
templates/admin-tab-404s.php
CHANGED
@@ -13,16 +13,28 @@
|
|
13 |
<div class="wrap">
|
14 |
<?php do_action('eps_redirects_admin_head'); ?>
|
15 |
|
16 |
-
<
|
17 |
-
<
|
18 |
-
<
|
19 |
-
<
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
|
28 |
<div class="right">
|
@@ -32,7 +44,7 @@
|
|
32 |
<?php do_action('eps_redirects_panels_left'); ?>
|
33 |
</div>
|
34 |
</div>
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
13 |
<div class="wrap">
|
14 |
<?php do_action('eps_redirects_admin_head'); ?>
|
15 |
|
16 |
+
<div class="eps-panel eps-margin-top group">
|
17 |
+
<div class="eps-redirects-50 group">
|
18 |
+
<h1>Take your redirects to the next level!</h1>
|
19 |
+
<p class="eps-redirects-lead">The <a href="http://www.eggplantstudios.ca/cart/?add_to_cart=2974" target="_blank">Pro Version of EPS 301 Redirects</a> will add a new 404 tracking feature. Every 404 error will be logged, and you will have the power and flexibility to redirect them wherever you want them to go.</p>
|
20 |
+
|
21 |
+
<ul id="eps-redirects-checklist">
|
22 |
+
<li><span>See which Request URLs are causing 404 errors on your site.</span></li>
|
23 |
+
<li><span>Discover which 404 errors are receiving the most traffic.</span></li>
|
24 |
+
<li><span>Improve SEO by lowering your total number of 404 errors.</span></li>
|
25 |
+
<li><span>Easily fix the 404 errors by turning them into redirects.</span></li>
|
26 |
+
</ul>
|
27 |
+
</div>
|
28 |
+
<div class="eps-redirects-50 group">
|
29 |
+
<div class="padding-lots">
|
30 |
+
<a href="http://www.eggplantstudios.ca/cart/?add_to_cart=2974" target="_blank">
|
31 |
+
<img class="eps-redirects-fit" src="<?php echo EPS_REDIRECT_URL; ?>/images/icon-eps-redirects.jpg" title="Upgrade EPS 301 Redirects">
|
32 |
+
</a>
|
33 |
+
<a class="eps-redirects-big-button" href="http://www.eggplantstudios.ca/cart/?add_to_cart=2974" target="_blank">BUY NOW • ONLY $15.00</a>
|
34 |
+
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
|
39 |
|
40 |
<div class="right">
|
44 |
<?php do_action('eps_redirects_panels_left'); ?>
|
45 |
</div>
|
46 |
</div>
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
|
templates/admin-tab-error.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The Redirects Tab.
|
5 |
+
*
|
6 |
+
* The main admin area for the redirects tab.
|
7 |
+
*
|
8 |
+
* @package EPS 301 Redirects
|
9 |
+
* @author Shawn Wernig ( shawn@eggplantstudios.ca )
|
10 |
+
*/
|
11 |
+
?>
|
12 |
+
|
13 |
+
|
14 |
+
<div class="wrap">
|
15 |
+
<?php do_action('eps_redirects_admin_head'); ?>
|
16 |
+
|
17 |
+
<div class="eps-notice eps-warning">
|
18 |
+
<?php echo $options['description']; ?>
|
19 |
+
</div>
|
20 |
+
|
21 |
+
|
22 |
+
<div class="right">
|
23 |
+
<?php do_action('eps_redirects_panels_right'); ?>
|
24 |
+
</div>
|
25 |
+
<div class="left">
|
26 |
+
<?php do_action('eps_redirects_panels_left'); ?>
|
27 |
+
</div>
|
28 |
+
</div>
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
templates/admin-tab-import-export.php
CHANGED
@@ -23,7 +23,6 @@
|
|
23 |
<p>
|
24 |
<input type="radio" name="eps_redirect_upload_method" value="skip" checked="checked"> Skip Duplicates
|
25 |
<input type="radio" name="eps_redirect_upload_method" value="update"> Update Duplicates
|
26 |
-
<input type="radio" name="eps_redirect_upload_method" value="ignore"> Ignore Duplicates
|
27 |
</p>
|
28 |
|
29 |
<br><small class="eps-grey-text">Supply Columns: <strong>Status</strong> (301,302,inactive), <strong>Request URL</strong>, <strong>Redirect To</strong> (ID or URL). <a href="<?php echo EPS_REDIRECT_URL . 'example.csv'?>" target="_blank">Download Example CSV</a></small>
|
23 |
<p>
|
24 |
<input type="radio" name="eps_redirect_upload_method" value="skip" checked="checked"> Skip Duplicates
|
25 |
<input type="radio" name="eps_redirect_upload_method" value="update"> Update Duplicates
|
|
|
26 |
</p>
|
27 |
|
28 |
<br><small class="eps-grey-text">Supply Columns: <strong>Status</strong> (301,302,inactive), <strong>Request URL</strong>, <strong>Redirect To</strong> (ID or URL). <a href="<?php echo EPS_REDIRECT_URL . 'example.csv'?>" target="_blank">Download Example CSV</a></small>
|
templates/admin-tab-redirects.php
CHANGED
@@ -25,8 +25,8 @@
|
|
25 |
<tr id="eps-redirect-add" style="display:none"><td colspan="4"><a href="#" id="eps-redirect-new"><span>+</span></a></td></tr>
|
26 |
|
27 |
<?php
|
28 |
-
echo
|
29 |
-
echo
|
30 |
?>
|
31 |
</table>
|
32 |
|
25 |
<tr id="eps-redirect-add" style="display:none"><td colspan="4"><a href="#" id="eps-redirect-new"><span>+</span></a></td></tr>
|
26 |
|
27 |
<?php
|
28 |
+
echo EPS_Redirects::get_inline_edit_entry();
|
29 |
+
echo EPS_Redirects::list_redirects();
|
30 |
?>
|
31 |
</table>
|
32 |
|
templates/template.404-entry.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* The 404 List Entry Template.
|
5 |
-
*
|
6 |
-
*
|
7 |
-
* @package EPS 301 Redirects
|
8 |
-
* @author Shawn Wernig ( shawn@eggplantstudios.ca )
|
9 |
-
*/
|
10 |
-
|
11 |
-
global $EPS_Redirects_Plugin;
|
12 |
-
$query_args = array( 'page' => $EPS_Redirects_Plugin->config('page_slug'), 'delete_redirect' => esc_attr( $redirect->id ) );
|
13 |
-
|
14 |
-
?>
|
15 |
-
<tr class="redirect-entry <?php echo esc_attr( $redirect->status ); ?> id-<?php echo esc_attr( $redirect->id ); ?>" data-id="<?php echo esc_attr( $redirect->id ); ?>" data-status="<?php echo esc_attr( $redirect->status ); ?>">
|
16 |
-
<td colspan="2">
|
17 |
-
<a target="_blank" class="eps-url" href="<?php bloginfo('url'); ?>/<?php echo esc_attr($dfrom); ?>" title="<?php bloginfo('url'); ?>/<?php echo esc_attr($dfrom); ?>">
|
18 |
-
<span class="eps-url-root eps-url-startcap"><?php echo ($redirect->status == 'inactive' ) ? 'OFF': esc_attr($redirect->status); ?></span><span class="eps-url-root"><?php bloginfo('url'); ?>/</span><span class="eps-url-fragment eps-url-endcap"><?php echo esc_attr($dfrom); ?></span>
|
19 |
-
</a>
|
20 |
-
</td>
|
21 |
-
<td class="redirect-hits"><strong><?php echo esc_attr( $redirect->count ); ?></strong></td>
|
22 |
-
<td class="redirect-actions">
|
23 |
-
<a class="button eps-redirect-edit" href="#eps-redirect-edit" data-id="<?php echo esc_attr( $redirect->id ); ?>">Redirect</a>
|
24 |
-
<a class="button eps-redirect-remove" href="<?php echo add_query_arg( $query_args, admin_url( '/options-general.php' ) ); ?>" data-id="<?php echo esc_attr( $redirect->id ); ?>">×</a>
|
25 |
-
</td>
|
26 |
-
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|