Eggplant 301 Redirects - Version 2.0.1

Version Description

Fixed an issue where the Automatic Update would not call the import process for pre 2.0 versions.

Download this release

Release Info

Developer shawn@eggplantstudios.ca
Plugin Icon 128x128 Eggplant 301 Redirects
Version 2.0.1
Comparing to
See all releases

Code changes from version 1.4.0 to 2.0.1

class.drop-down-pages.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Drop Down Pages
4
+ *
5
+ * Will return a heirarchical list of pages in a key->value pair.
6
+ *
7
+ * @since 2.1.0
8
+ *
9
+ * @param array|string $args Optional. Override default arguments.
10
+ * @return string HTML content, if not displaying.
11
+ */
12
+ if( !function_exists('eps_dropdown_pages')) {
13
+ function eps_dropdown_pages($args = '') {
14
+ $defaults = array(
15
+ 'posts_per_page' => -1,
16
+ 'offset' => 0,
17
+ 'category' => '',
18
+ 'orderby' => 'post_title',
19
+ 'order' => 'DESC',
20
+ 'include' => '',
21
+ 'exclude' => '',
22
+ 'meta_key' => '',
23
+ 'meta_value' => '',
24
+ 'post_type' => 'post',
25
+ 'post_mime_type' => '',
26
+ 'post_parent' => '',
27
+ 'post_status' => 'publish',
28
+ 'suppress_filters' => true,
29
+ 'depth' => 5
30
+ );
31
+
32
+
33
+
34
+ $r = wp_parse_args( $args, $defaults );
35
+ extract( $r, EXTR_SKIP );
36
+
37
+ $pages = get_posts( $r );
38
+
39
+ if ( empty($pages) ) return array();
40
+
41
+ return array_flip( eps_walk_page_dropdown_tree($pages, $depth, $r) );
42
+ }
43
+
44
+ /**
45
+ * Retrieve HTML dropdown (select) content for page list.
46
+ *
47
+ * @uses Walker_PageDropdown to create HTML dropdown content.
48
+ * @since 2.1.0
49
+ * @see Walker_PageDropdown::walk() for parameters and return description.
50
+ */
51
+ function eps_walk_page_dropdown_tree() {
52
+ $args = func_get_args();
53
+ $walker = ( empty($args[2]['walker']) ) ? new EPS_Walker_PageDropdown : $args[2]['walker'];
54
+ return call_user_func_array(array($walker, 'walk'), $args);
55
+ }
56
+
57
+ /**
58
+ * Create an array of pages.
59
+ *
60
+ * @package WordPress
61
+ * @since 2.1.0
62
+ * @uses Walker
63
+ */
64
+ class EPS_Walker_PageDropdown extends Walker {
65
+ var $tree_type = 'page';
66
+ var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
67
+
68
+ function start_el(&$output, $page, $depth, $args, $id = 0) {
69
+ $pad = str_repeat('&nbsp;', $depth * 3);
70
+ $output[$page->ID] = $pad . esc_html( apply_filters( 'list_pages', $page->post_title, $page ) );
71
+ }
72
+ }
73
+ }
74
+ ?>
css/eps_redirect.css CHANGED
@@ -1,33 +1,70 @@
1
  /*----------------------------------------------------------*/
2
- /*------------------------ Headings ------------------------*/
3
  /*----------------------------------------------------------*/
4
 
5
 
6
- h2.eps-title {
7
- color: #68214d !important;
8
- font-size: 32px !important;
9
- padding-top: 24px;
10
- }
 
 
11
 
12
- #icon-eggplant {
13
- background: url('../icons/eggplant-64.png') center center no-repeat;
14
- width: 64px; height: 64px; float: left; margin-right: 12px; margin-top: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
 
 
17
 
18
- /*#eps-redirect-entries { margin-top: 32px; padding: 12px; border: 1px solid #d6d6d6; box-shadow: 1px 1px 6px #f4f4f4; min-width: 810px; }*/
19
- #eps-redirect-entries h3 { margin: 8px; font-size: 20px; font-weight: 100; border-bottom: 1px solid #eeeeee; padding-bottom: 12px; }
20
 
21
- tr.redirect-entry td, tr.redirect-entry th { padding: 6px 8px; }
22
- .eps-request-url { }
23
- .eps-redirect-url { width: 20em; }
 
 
 
 
 
 
 
 
24
 
25
  /*----------------------------------------------------------*/
26
  /*---------------------- notifications ---------------------*/
27
  /*----------------------------------------------------------*/
28
 
29
-
30
-
31
  .eps-notification-area {
32
  -webkit-border-radius: 4px;
33
  -moz-border-radius: 4px;
@@ -50,27 +87,27 @@ tr.redirect-entry td, tr.redirect-entry th { padding: 6px 8px; }
50
  /*----------------------------------------------------------*/
51
 
52
  a.eps-text-link, a.eps-text-link:visited, a.eps-text-link:link {
53
- display: inline-block;
54
- zoom: 1;
55
- padding: 4px 8px;
56
- text-decoration: none;
57
- background: #fefefe; /* Old browsers */
58
- background: -moz-linear-gradient(top, #fefefe 0%, #eeeeee 10%, #f4f4f4 100%); /* FF3.6+ */
59
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fefefe), color-stop(10%,#eeeeee), color-stop(100%,#f4f4f4)); /* Chrome,Safari4+ */
60
- background: -webkit-linear-gradient(top, #fefefe 0%,#eeeeee 10%,#f4f4f4 100%); /* Chrome10+,Safari5.1+ */
61
- background: -o-linear-gradient(top, #fefefe 0%,#eeeeee 10%,#f4f4f4 100%); /* Opera 11.10+ */
62
- background: -ms-linear-gradient(top, #fefefe 0%,#eeeeee 10%,#f4f4f4 100%); /* IE10+ */
63
- background: linear-gradient(to bottom, #fefefe 0%,#eeeeee 10%,#f4f4f4 100%); /* W3C */
64
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fefefe', endColorstr='#f4f4f4',GradientType=0 ); /* IE6-9 */
65
-
66
- border: 1px solid #dddddd;
67
- margin: 0px 4px;
68
- text-shadow: 1px 1px 1px white;
69
-
70
- -webkit-border-radius: 4px;
71
- -moz-border-radius: 4px;
72
- border-radius: 4px;
73
  }
 
 
 
74
  a.eps-text-link:hover { background: #fafafa; }
75
 
76
  a.eps-text-link.remove {
@@ -79,17 +116,17 @@ a.eps-text-link.remove {
79
  -moz-border-radius: 12px;
80
  border-radius: 12px;
81
  }
82
- a.eps-text-link.remove:hover { color: #fafafa; background: #aa0000;}
83
-
84
  a.eps-text-link.new {
85
- padding: 8px;
86
  margin-top: 32px;
87
  }
88
 
89
  /*----------------------------------------------------------*/
90
  /*--------------------------- tabs -------------------------*/
91
  /*----------------------------------------------------------*/
92
- #eps-tabs { padding: 12px 32px; border: 1px solid #d6d6d6; box-shadow: 1px 1px 6px #f4f4f4; }
 
93
 
94
  #eps-tab-nav { margin-top: 32px; }
95
  #eps-tab-nav a, #eps-tab-nav a:link, #eps-tab-nav a:visited {
@@ -119,6 +156,65 @@ a.eps-text-link.new {
119
  /*-------------------------- misc ------------------------*/
120
  /*----------------------------------------------------------*/
121
 
122
- hr.eps-divider { border: none; margin: 16px 0px; }
123
- .padding { padding: 12px; }
124
- .eps-grey-text { font-style: italic; color: #888888; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /*----------------------------------------------------------*/
2
+ /*--------------------- Entries Table ----------------------*/
3
  /*----------------------------------------------------------*/
4
 
5
 
6
+ #eps-redirect-entries {
7
+ margin-top: 32px;
8
+ width: 100%;
9
+ table-layout:fixed;
10
+ }
11
+
12
+ #eps-redirect-entries h3 { margin: 8px; font-size: 20px; font-weight: 100; border-bottom: 1px solid #eeeeee; padding-bottom: 12px; }
13
 
14
+ #eps-redirect-entries tr.redirect-entry td,
15
+ #eps-redirect-entries tr.redirect-entry th { padding: 10px; text-align: left; overflow: hidden; }
16
+
17
+ #eps-redirect-entries tr.redirect-entry td.text-center,
18
+ #eps-redirect-entries tr.redirect-entry th.text-center { text-align: center; }
19
+
20
+
21
+ #eps-redirect-entries tr.redirect-entry th {
22
+ padding: 6px 10px;
23
+ -webkit-box-shadow:rgba(120, 200, 230, 0.498039) 0 1px 0 inset;
24
+ background-color:#21759B;
25
+ background-image:linear-gradient(#2A95C5, #21759B);
26
+ border-color:#21759B #21759B #1E6A8D;
27
+ box-shadow:rgba(120, 200, 230, 0.498039) 0 1px 0 inset;
28
+ color:#FFFFFF;
29
+ }
30
+ #eps-redirect-entries tr.redirect-entry th:nth-child(1) {
31
+ width: 60px !important;
32
+ }
33
+ #eps-redirect-entries tr.redirect-entry th:nth-child(4) {
34
+ width: 20px !important;
35
+ }
36
+ #eps-redirect-entries tr.redirect-entry th:nth-child(5) {
37
+ width: 80px !important;
38
+ }
39
+
40
+ #eps-redirect-entries tr.redirect-entry {
41
+ background: #fafafa;
42
+ }
43
+ #eps-redirect-entries tr.redirect-entry:nth-child(even) {
44
+ background: #fcfcfc;
45
  }
46
 
47
+ #eps-redirect-entries td.redirect-actions { min-width: 90px; }
48
 
49
+ #eps-redirect-entries .eps-request-url { width: 18em; }
50
+ #eps-redirect-entries .eps-redirect-url { width: 18em; }
51
 
52
+ #eps-redirect-entries tr.redirect-entry select,
53
+ #eps-redirect-entries tr.redirect-entry input {
54
+ font-size:13px;
55
+ display:inline-block; zoom: 1; *display: inline;
56
+ max-width: 100%;
57
+ }
58
+
59
+
60
+ #eps-redirect-entries tr.redirect-entry select {
61
+ margin-right: 3px;
62
+ }
63
 
64
  /*----------------------------------------------------------*/
65
  /*---------------------- notifications ---------------------*/
66
  /*----------------------------------------------------------*/
67
 
 
 
68
  .eps-notification-area {
69
  -webkit-border-radius: 4px;
70
  -moz-border-radius: 4px;
87
  /*----------------------------------------------------------*/
88
 
89
  a.eps-text-link, a.eps-text-link:visited, a.eps-text-link:link {
90
+ text-decoration: none;
91
+ height: 28px; line-height: 26px;
92
+ padding: 0 10px 1px;
93
+ display:inline-block; zoom: 1; *display: inline;
94
+ border: 1px solid #cccccc;
95
+ background: #f7f7f7;
96
+ color: #555555;
97
+ margin: 0;
98
+ -webkit-box-shadow: #FFFFFF 0 1px 0 inset, rgba(0, 0, 0, 0.0784314) 0 1px 0;
99
+ -moz-box-shadow: #FFFFFF 0 1px 0 inset, rgba(0, 0, 0, 0.0784314) 0 1px 0;
100
+ box-shadow:#FFFFFF 0 1px 0 inset, rgba(0, 0, 0, 0.0784314) 0 1px 0;
101
+ -webkit-box-sizing:border-box;
102
+ -moz-box-sizing:border-box;
103
+ box-sizing:border-box;
104
+ -webkit-border-radius: 3px;
105
+ -moz-border-radius: 3px;
106
+ border-radius: 3px;
 
 
 
107
  }
108
+
109
+
110
+
111
  a.eps-text-link:hover { background: #fafafa; }
112
 
113
  a.eps-text-link.remove {
116
  -moz-border-radius: 12px;
117
  border-radius: 12px;
118
  }
119
+ a.eps-text-link.remove:hover { color: #fafafa; background: #aa0000; }
120
+ a.eps-text-link.inactive { color: #aaaaaa !important; cursor: default; }
121
  a.eps-text-link.new {
 
122
  margin-top: 32px;
123
  }
124
 
125
  /*----------------------------------------------------------*/
126
  /*--------------------------- tabs -------------------------*/
127
  /*----------------------------------------------------------*/
128
+
129
+ #eps-tabs { padding: 12px 32px; border: 1px solid #d6d6d6; background: white; box-shadow: 1px 1px 6px #f4f4f4; }
130
 
131
  #eps-tab-nav { margin-top: 32px; }
132
  #eps-tab-nav a, #eps-tab-nav a:link, #eps-tab-nav a:visited {
156
  /*-------------------------- misc ------------------------*/
157
  /*----------------------------------------------------------*/
158
 
159
+ .eps-padding { padding: 12px; }
160
+ .eps-grey-text { font-style: italic; color: #999999; }
161
+
162
+ /*----------------------------------------------------------*/
163
+ /*------------------------ donate ------------------------*/
164
+ /*----------------------------------------------------------*/
165
+
166
+ #donate-box {
167
+ border: 1px solid #d6d6d6; background: white; box-shadow: 1px 1px 6px #f4f4f4;
168
+ width: 250px;
169
+ margin-top: 12px;
170
+ float: right;
171
+ text-align: center;
172
+ }
173
+ #donate-box p { margin-bottom: 12px; }
174
+ #donate-box h3 { margin-bottom: 12px; font-size: 1.2em; }
175
+
176
+ /*----------------------------------------------------------*/
177
+ /*-------------------- media queries ---------------------*/
178
+ /*----------------------------------------------------------*/
179
+
180
+ @media only screen and (max-width : 600px) {
181
+ #eps-redirect-entries tr.redirect-entry th:nth-child(1),
182
+ #eps-redirect-entries tr.redirect-entry th:nth-child(4),
183
+ #eps-redirect-entries tr.redirect-entry th:nth-child(5),
184
+ #eps-redirect-entries tr.redirect-entry td:nth-child(1),
185
+ #eps-redirect-entries tr.redirect-entry td:nth-child(4),
186
+ #eps-redirect-entries tr.redirect-entry td:nth-child(5) {
187
+ width: 0px !important;
188
+ background: red;
189
+ }
190
+ #eps-tabs { padding: 12px 12px; }
191
+ #eps-redirect-entries tr.redirect-entry select,
192
+ #eps-redirect-entries tr.redirect-entry input {
193
+ display: block;
194
+ width: 100%;
195
+ margin-bottom: 2px;
196
+ }
197
+ #donate-box { width: 100% !important; }
198
+ .button { display: block !important; width: 100%; }
199
+ #eps-redirect-entries tr.redirect-entry td,
200
+ #eps-redirect-entries tr.redirect-entry th { padding: 5px; }
201
+ }
202
+
203
+
204
+ @media only screen and (max-width : 768px) and (min-width : 600px) {
205
+ #eps-redirect-entries tr.redirect-entry select,
206
+ #eps-redirect-entries tr.redirect-entry input {
207
+ display: block;
208
+ width: 100%;
209
+ margin-bottom: 2px;
210
+ }
211
+ #donate-box { width: 100% !important; }
212
+ }
213
+ @media only screen and (max-width : 1024px) and (min-width : 768px) {
214
+ #eps-redirect-entries tr.redirect-entry select,
215
+ #eps-redirect-entries tr.redirect-entry input {
216
+ display: block;
217
+ width: 100%;
218
+ margin-bottom: 2px;
219
+ }
220
+ }
eps-301-redirects.php CHANGED
@@ -15,15 +15,17 @@
15
  *
16
  * @package EPS 301 Redirects
17
  * @author Shawn Wernig ( shawn@eggplantstudios.ca )
18
- * @version 1.4.0
19
  */
20
 
 
 
21
 
22
  /*
23
  Plugin Name: Eggplant 301 Redirects
24
  Plugin URI: http://www.eggplantstudios.ca
25
  Description: Create your own 301 redirects using this powerful plugin.
26
- Version: 1.4.0
27
  Author: Shawn Wernig http://www.eggplantstudios.ca
28
  License: GPLv2 or later
29
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -31,11 +33,13 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
31
 
32
  define ( 'EPS_REDIRECT_PATH', plugin_dir_path(__FILE__) );
33
  define ( 'EPS_REDIRECT_URL', plugin_dir_url( __FILE__ ) );
34
- define ( 'EPS_REDIRECT_VERSION', '1.4.0');
35
 
36
  register_activation_hook(__FILE__, array('EPS_Redirects', 'eps_redirect_activation'));
37
  register_deactivation_hook(__FILE__, array('EPS_Redirects', 'eps_redirect_deactivation'));
38
 
 
 
39
 
40
  class EPS_Redirects {
41
 
@@ -45,63 +49,137 @@ class EPS_Redirects {
45
  static $page_title = '301 Redirects';
46
 
47
 
 
 
 
 
 
 
 
 
48
  public function __construct(){
49
  if(is_admin()){
 
50
  add_action('admin_menu', array($this, 'add_plugin_page'));
51
  add_action('admin_init', array($this, '_save'));
52
- add_action('wp_ajax_eps_redirect_get_new_entry', array($this, 'ajax_get_blank_entry') );
53
  add_action('init', array($this, 'enqueue_resources'));
54
  add_action('admin_footer_text', array($this, 'set_ajax_url'));
 
 
 
 
 
 
 
 
 
 
55
  }
56
- add_action('wp_footer', array($this, 'set_ajax_url'));
57
- add_action('init', array($this,'do_redirect'), 1); // Priority 1 for redirects.
 
58
  }
59
 
 
 
 
 
 
 
 
 
60
  public static function eps_redirect_activation() {
61
- self::check_version();
62
  }
63
  public static function eps_redirect_deactivation() {
64
- //update_option( self::$option_slug, null );
65
- //update_option( 'eps_redirects_version', null );
66
  }
67
 
68
-
 
 
 
 
69
  /**
70
  *
71
  * CHECK VERSION
72
  *
73
  * This function will check the current version and do any fixes required
74
  *
75
- * @return html string
76
  * @author epstudios
77
  *
78
  */
79
- public function check_version() {
80
  $version = get_option( 'eps_redirects_version' );
81
-
82
- if ( !isset($version) || empty( $version ) ) {
83
- // no version is set. versions started being stored at 1.3.1
84
- // because in 1.3.1 we did a big database storage change, we need to fix old versions storage
85
-
86
- $redirects = get_option( self::$option_slug );
87
- if (empty($redirects)) return false; // no redirects anyways, so dont do anything.
88
 
89
- foreach ($redirects as $to => $from ) {
90
- $new_redirects[$from] = $to;
91
- }
92
- update_option( self::$option_slug, $new_redirects );
93
- }
94
 
95
- switch( $version ) {
96
- case '1.3.2':
97
- // do stuff
98
- default:
99
- break;
100
- }
101
  update_option( 'eps_redirects_version', EPS_REDIRECT_VERSION );
102
  return EPS_REDIRECT_VERSION;
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  /**
107
  *
@@ -115,7 +193,7 @@ class EPS_Redirects {
115
  */
116
  public function enqueue_resources(){
117
  wp_enqueue_script('jquery');
118
- wp_enqueue_script('eps_redirect_script', EPS_REDIRECT_URL .'/js/scripts.js');
119
  wp_enqueue_style('eps_redirect_styles', EPS_REDIRECT_URL .'css/eps_redirect.css');
120
  }
121
 
@@ -143,36 +221,49 @@ class EPS_Redirects {
143
  *
144
  */
145
  public function do_redirect() {
146
- $redirects = get_option( self::$option_slug );
147
- if (empty($redirects)) return false;
148
-
 
149
  // Get current url
150
  $url_request = self::get_url();
151
 
152
- foreach ($redirects as $from => $to ) {
153
- $from = urldecode($from);
154
- $to = urldecode($to);
155
-
156
- if( rtrim($url_request,'/') == self::format_from_url($from) ) {
157
- // Match, this needs to be redirected
158
- header ('HTTP/1.1 301 Moved Permanently');
159
- header ('Location: ' . $to, true, 301);
160
- exit();
161
- }
 
 
 
 
 
 
 
 
162
  }
163
  }
164
- private function rawurlencode_parts( $uri ) {
165
- $parts = explode('/', $uri);
166
- for ($i = 0; $i < count($parts); $i++) {
167
- $parts[$i] = rawurlencode($parts[$i]);
168
- }
169
- return implode('/', $parts);
170
- }
171
-
 
 
 
172
  private function format_from_url( $string ) {
173
- $from = get_option('home') . '/' . $string;
174
- return rtrim($from,'/');
175
  }
 
176
  /**
177
  *
178
  * GET_URL
@@ -185,7 +276,7 @@ class EPS_Redirects {
185
  */
186
  function get_url() {
187
  $protocol = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https' : 'http';
188
- return urldecode( $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
189
  }
190
 
191
 
@@ -206,7 +297,7 @@ class EPS_Redirects {
206
  *
207
  * _SAVE
208
  *
209
- * This function will list out all the current entries.
210
  *
211
  * @return html string
212
  * @author epstudios
@@ -214,366 +305,224 @@ class EPS_Redirects {
214
  */
215
  public function _save(){
216
 
217
- if ( isset( $_POST['eps_redirect_submit'] ) && wp_verify_nonce( $_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce') )
218
- $this->_save_redirects();
219
-
220
- if ( isset( $_POST['eps_redirect_settings_submit'] ) && wp_verify_nonce( $_POST['eps_redirect_setting_nonce_submit'], 'eps_redirect_setting_nonce') )
221
- $this->_save_settings();
222
- }
223
-
224
- private function _save_settings() {
225
- update_option( 'eps_redirect_settings', $_POST['eps_redirect_settings'] );
226
- }
227
- private function _save_redirects() {
228
- $total_redirects = count( $_POST[self::$option_slug]['to'] );
229
- $redirects = array();
230
-
231
- for($i = 0; $i < $total_redirects; $i ++) {
232
- $to = trim( $_POST[self::$option_slug]['to'][$i] );
233
- $to = self::rawurlencode_parts( $to );
234
- $to = filter_var( $to, FILTER_SANITIZE_URL);
235
-
236
- $from = trim( $_POST[self::$option_slug]['from'][$i] );
237
- $from = self::rawurlencode_parts( $from );
238
- $from = filter_var( $from, FILTER_SANITIZE_URL);
239
- $from = ltrim($from, '/');
240
-
241
- if( empty($to) ) $to = home_url() . '/'; // default
242
-
243
- // If this is a valid entry, add it to the save array.
244
- if ( !empty($from)) $redirects[$from] = $to;
245
  }
246
- // If we then have a valid array - save
247
- update_option( self::$option_slug, $redirects );
 
 
 
248
  }
249
 
250
  /**
251
  *
252
- * DO_INPUTS
253
  *
254
- * This function will list out all the current entries.
255
  *
256
- * @return html string
257
  * @author epstudios
258
- *
259
  */
260
- public function do_inputs(){
261
- $redirects = get_option( self::$option_slug );
 
262
 
263
- if (empty($redirects)) return false;
264
-
265
- foreach ($redirects as $from => $to ) {
266
- $dfrom = urldecode($from);
267
- $dto = urldecode($to);
268
 
269
-
270
-
271
- $html .= '
272
- <tr class="redirect-entry">
273
- <td><span class="eps-grey-text">'.get_bloginfo('home').'/&nbsp;</span><input class="eps-request-url" type="text" name="'.self::$option_slug.'[from][]" value="'. $dfrom .'" > &rarr;</td>
274
- <td>
275
- <input type="text" class="eps-redirect-url" name="'.self::$option_slug.'[to][]" value="'.$dto.'" >';
276
-
277
- $html .= $this->get_testing_results($from, $dto);
278
-
279
- $html .='<a class="eps-text-link" href="'.self::format_from_url( $from ).'" target="_blank">Test</a>
280
- <a class="eps-text-link remove" href="#" class="eps-redirect-remove">&times;</a>
281
- </td>
282
- </tr>';
283
  }
284
- return $html;
285
  }
286
-
287
 
288
- private static function url_esc_spaces( $url ) {
289
- return str_replace(' ', '%20', $url);
290
- }
291
  /**
292
  *
293
- * GET_BLANK_ENTRY
294
- * AJAX_GET_BLANK_ENTRY
295
  *
296
- * This function will return a blank row ready for user input.
297
  *
298
- * @return html string
299
- * @author epstudios
300
- *
301
- */
302
- public static function get_blank_entry() {
303
- return '<tr class="redirect-entry">
304
- <td><span class="eps-grey-text">'.get_bloginfo('home').'/&nbsp;</span><input class="eps-request-url" type="text" name="'.self::$option_slug.'[from][]" value="" > &rarr;</td>
305
- <td>'.self::get_type_select().'</td>
306
- </tr>';
307
- }
308
- public static function ajax_get_blank_entry() {
309
- echo self::get_blank_entry(); exit();
310
- }
311
-
312
-
313
- /**
314
  *
315
- * GET_TYPE_SELECT
316
- *
317
- * This function will initialze a series of html form elements so a user can narrow down their redirect destination.
318
- *
319
- * @return html string
320
  * @author epstudios
321
- *
322
  */
323
- private function get_type_select(){
324
-
325
- // Get a list of primary destinations.
326
- $post_types = get_post_types(array('public'=>true),'objects');
327
- $html = '<select class="type-select">';
328
- $html .= '<option value="eps-redirect-url" selected default>Custom</option>';
329
- foreach ($post_types as $post_type ) {
330
- $html .= '<option value="'.$post_type->name.'">'. $post_type->labels->singular_name. '</option>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
332
- $html .= '<option value="term">Term Archive</option>';
333
- $html .= '</select>';
334
-
335
- // The default input, javascript will populate this input with the final URL for submission.
336
- $html .= '<input class="eps-redirect-url" type="text" name="'.self::$option_slug.'[to][]" value="" placeholder="'.get_bloginfo('home').'"/>';
337
-
338
- // Get all the post type select boxes.
339
- foreach ($post_types as $post_type )
340
- $html .= self::get_post_type_select($post_type->name);
341
 
342
- // Get the term select box.
343
- $html .= self::get_term_archive_select();
344
- return $html;
345
  }
346
-
347
-
348
-
349
- /**
350
- *
351
- * GET_PARENT_INDEX
352
  *
353
- * Scans a custom array of posts to find a parent's position in the array. Used in GET_POST_TYPE_SELECT
354
  *
355
- * @return html string
356
- * @param $post_type = the post type slug.
357
  * @author epstudios
358
- *
359
  */
360
- function find_parent_index( $id, $entries ){
361
- foreach($entries as $k => $entry ) {
362
- if ( $entry->ID == $id ) return( $k );
363
- }
364
- return false;
 
 
365
  }
 
366
  /**
367
  *
368
- * GET_PARENT_INDEX
369
  *
370
- * Scans a custom array of posts to find a parent's position in the array. Used in GET_POST_TYPE_SELECT
371
  *
372
- * @return html string
373
- * @param $post_type = the post type slug.
374
  * @author epstudios
375
- *
376
  */
377
- function get_post_depth( $id ){
378
  global $wpdb;
379
- $depth = 0;
380
- $parent_id = $id;
381
- while ($parent_id > 0) {
382
- $parent_id = $wpdb->get_var( "SELECT post_parent FROM $wpdb->posts WHERE ID = $parent_id" );
383
- $depth ++;
384
- }
385
- return $depth;
386
  }
387
 
388
  /**
389
  *
390
- * GET_POST_TYPE_SELECT
391
  *
392
- * This function will output a select box with all the posts in a given post_type.
393
- * Post types with archives will have an All Posts link.
394
  *
395
  * @return html string
396
- * @param $post_type = the post type slug.
397
  * @author epstudios
398
  *
399
  */
400
- private function get_post_type_select( $post_type ){
401
- global $wpdb;
402
- $entries = $wpdb->get_results("SELECT ID, post_title, post_parent
403
- FROM $wpdb->posts
404
- WHERE post_status = 'publish'
405
- AND post_type = '$post_type'
406
- ORDER BY post_title ASC");
407
-
408
-
409
- if (!$entries) return false;
410
-
411
- // create heirarchy
412
-
413
- // get depths
414
- $max_depth = 0;
415
- foreach($entries as $k => $entry ) {
416
- $entry->depth = self::get_post_depth( $entry->post_parent );
417
- if($entry->depth > $max_depth) $max_depth = $entry->depth;
418
- }
419
-
420
- // Nest arrays as parent >> children
421
- for( $i = $max_depth; $i >= 0; $i -- ) {
422
- foreach( $entries as $k => $entry ) {
423
- if ( $entry->depth == $i ) {
424
- if ( $entry->post_parent > 0 ) {
425
- $entry->post_title = '&nbsp;' . str_repeat("-", $depth). ' ' . $entry->post_title;
426
- $parent_index = self::find_parent_index( $entry->post_parent, $entries );
427
-
428
- $entries[$parent_index]->children[] = $entry;
429
- unset($entries[$k]);
430
- }
431
- }
432
- }
433
- }
434
-
435
- // Start the select.
436
- $html = '<select class="'.$post_type.' url-selector" style="display:none;">';
437
- $html .= '<option value="" selected default>...</option>';
438
-
439
- // Get the correct archive link
440
- switch( $post_type ) {
441
- case 'post': break; // no archive
442
- case 'page': break; // no archive
443
- case 'attachment': break; // no archive
444
- default:
445
- $html .= '<option value="'.get_post_type_archive_link($post_type).'">All '.eps_prettify($post_type).'s</option>';
446
- }
447
-
448
-
449
- // Get all entries and insert them as options.
450
- foreach ($entries as $entry ) {
451
- $html .= self::do_post_heirarchy_selects( $entry );
452
  }
453
- $html .= '</select>';
454
- return $html;
455
- }
456
-
457
- function do_post_heirarchy_selects( $entry ) {
458
- $html .= '<option value="'.get_permalink($entry->ID).'">'. str_repeat("-", $entry->depth) . $entry->post_title . '</option>';
459
-
460
- if( isset( $entry->children ) && !empty( $entry->children ) ) {
461
- foreach ($entry->children as $child ) {
462
- $html .= self::do_post_heirarchy_selects($child);
463
- }
464
- }
465
  return $html;
466
  }
 
467
 
468
  /**
469
  *
470
- * GET_TERM_ARCHIVE_SELECT
471
  *
472
- * This function will output a select box with all the taxonomies and terms.
473
  *
474
- * @return html string
475
  * @author epstudios
476
  *
477
  */
478
- private function get_term_archive_select(){
479
- $taxonomies = get_taxonomies( '', 'objects' );
480
-
481
- if (!$taxonomies) return false;
482
 
483
- // Start the select.
484
- $html = '<select class="term url-selector" style="display:none;">';
485
- $html .= '<option value="" selected default>...</option>';
486
-
487
- // Loop through all taxonomies.
488
- foreach ($taxonomies as $tax ) {
489
- $terms = get_terms( $tax->name, array('hide_empty' => false) ); // show empty terms.
490
- $html .= '<option value="'.get_permalink($entry->ID).'" disabled>'. $tax->labels->singular_name. '</option>';
491
-
492
- // Loop through all terms in this taxonomy and insert them as options.
493
- foreach($terms as $term)
494
- $html .= '<option value="'.get_term_link($term).'">&nbsp;&nbsp;- '. $term->name. '</option>';
495
-
496
- }
497
- $html .= '</select>';
498
- return $html;
499
  }
500
 
501
  /**
502
  *
503
- * SET_AJAX_URL
 
504
  *
505
- * This function will output a variable containing the admin ajax url for use in javascript.
506
  *
 
507
  * @author epstudios
508
  *
509
  */
510
- public static function set_ajax_url() {
511
- echo '<script>var eps_redirect_ajax_url = "'. admin_url( 'admin-ajax.php' ) . '"</script>';
 
 
 
 
512
  }
513
 
 
 
 
514
 
515
- public static function filter_from( $string ) {
516
- $string = esc_attr($string);
517
- // If string does not start with a slash, add it
518
- if( substr($string, 0, 1) != '/') $string = '/' . $string;
519
-
520
- return $string;
521
  }
522
 
523
 
524
  /**
525
  *
 
526
  *
 
527
  *
528
- * Get the testing results for this redirect.
529
- *
530
  */
531
- private function get_testing_results($from, $to) {
532
- $settings = get_option( 'eps_redirect_settings' );
533
- $test_urls = $settings['test_urls'];
534
- if( isset($test_urls) && $test_urls == 'on' ) {
535
-
536
- $redirect_response_code = self::get_response( self::format_from_url( $from ) );
537
- $redirect_class = ( $redirect_response_code == 301 ) ? 'valid' : 'invalid';
538
-
539
- $destination_response_code = self::get_response( self::url_esc_spaces( $to ) );
540
- $destination_class = ( $destination_response_code == 200 ) ? 'valid' : 'invalid';
541
-
542
- return '<span class="eps-text-link eps-notification-area '.$redirect_class.'">'.eps_prettify($redirect_response_code).'</span> &rarr;
543
- <span class="eps-text-link eps-notification-area '.$destination_class.'">'.eps_prettify($destination_response_code).'</span>';
544
- }
545
  }
546
- /**
547
- *
548
- *
549
- * Gets the status code for this url.
550
- *
551
- */
552
- private static function get_response( $url ) {
553
- // returns int responsecode, or false (if url does not exist or connection timeout occurs)
554
- // NOTE: could potentially take up to 0-30 seconds , blocking further code execution (more or less depending on connection, target site, and local timeout settings))
555
-
556
- if( !$url || !is_string($url)) return false;
557
-
558
- $ch = @curl_init($url);
559
-
560
- if($ch === false) return false;
561
-
562
- @curl_setopt($ch, CURLOPT_HEADER ,true); // we want headers
563
- @curl_setopt($ch, CURLOPT_NOBODY ,true); // dont need body
564
- @curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true); // catch output (do NOT print!)
565
- @curl_exec($ch);
566
-
567
- if( @curl_errno($ch) ) { // should be 0
568
- @curl_close($ch);
569
- return false;
570
- } else {
571
- $code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
572
- @curl_close($ch);
573
- return $code;
574
- }
575
-
576
  }
 
 
577
  }
578
 
579
 
@@ -585,9 +534,19 @@ class EPS_Redirects {
585
  * @param $string = the object to prettify; Typically a string.
586
  * @author epstudios
587
  */
 
588
  function eps_prettify( $string ) {
589
  return ucwords( str_replace("_"," ",$string) );
590
  }
 
 
 
 
 
 
 
 
 
591
 
592
 
593
 
15
  *
16
  * @package EPS 301 Redirects
17
  * @author Shawn Wernig ( shawn@eggplantstudios.ca )
18
+ * @version 2.0.1
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.0.1
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
33
 
34
  define ( 'EPS_REDIRECT_PATH', plugin_dir_path(__FILE__) );
35
  define ( 'EPS_REDIRECT_URL', plugin_dir_url( __FILE__ ) );
36
+ define ( 'EPS_REDIRECT_VERSION', '2.0.1');
37
 
38
  register_activation_hook(__FILE__, array('EPS_Redirects', 'eps_redirect_activation'));
39
  register_deactivation_hook(__FILE__, array('EPS_Redirects', 'eps_redirect_deactivation'));
40
 
41
+ include(EPS_REDIRECT_PATH.'eps-form-elements.php');
42
+ include(EPS_REDIRECT_PATH.'class.drop-down-pages.php');
43
 
44
  class EPS_Redirects {
45
 
49
  static $page_title = '301 Redirects';
50
 
51
 
52
+
53
+ /**
54
+ *
55
+ * Constructor
56
+ *
57
+ * Add some actions.
58
+ *
59
+ */
60
  public function __construct(){
61
  if(is_admin()){
62
+ add_action('activated_plugin', array($this,'activation_error'));
63
  add_action('admin_menu', array($this, 'add_plugin_page'));
64
  add_action('admin_init', array($this, '_save'));
 
65
  add_action('init', array($this, 'enqueue_resources'));
66
  add_action('admin_footer_text', array($this, 'set_ajax_url'));
67
+
68
+ // Ajax funcs
69
+ add_action('wp_ajax_eps_redirect_get_new_entry', array($this, 'ajax_get_blank_entry') );
70
+ add_action('wp_ajax_eps_redirect_delete_entry', array($this, 'ajax_eps_delete_entry') );
71
+
72
+ if( isset($_GET['page']) && $_GET['page'] == self::$page_slug) {
73
+ add_action('admin_init', array($this, 'clear_cache'));
74
+ }
75
+ } else {
76
+ add_action('init', array($this,'do_redirect'), 1); // Priority 1 for redirects.
77
  }
78
+
79
+ if ( !self::is_current_version() ) self::update_self();
80
+
81
  }
82
 
83
+ /**
84
+ *
85
+ *
86
+ * Activation and Deactivation Handlers.
87
+ *
88
+ * @return nothing
89
+ * @author epstudios
90
+ */
91
  public static function eps_redirect_activation() {
92
+ self::update_self();
93
  }
94
  public static function eps_redirect_deactivation() {
 
 
95
  }
96
 
97
+ function is_current_version(){
98
+ $version = get_option( 'eps_redirects_version' );
99
+ return version_compare($version, EPS_REDIRECT_VERSION, '=') ? true : false;
100
+ }
101
+
102
  /**
103
  *
104
  * CHECK VERSION
105
  *
106
  * This function will check the current version and do any fixes required
107
  *
108
+ * @return string - version number.
109
  * @author epstudios
110
  *
111
  */
112
+ public function update_self() {
113
  $version = get_option( 'eps_redirects_version' );
114
+ self::_create_tables(); // Maybe create the tables
 
 
 
 
 
 
115
 
116
+ if( version_compare($version, '2.0.0', '<')) {
117
+ // migrate old format to new format.
118
+ self::_migrate_to_v2();
119
+ }
 
120
 
 
 
 
 
 
 
121
  update_option( 'eps_redirects_version', EPS_REDIRECT_VERSION );
122
  return EPS_REDIRECT_VERSION;
123
  }
124
 
125
+ /**
126
+ *
127
+ *
128
+ * MIGRATE TO V2
129
+ *
130
+ * Will migrate the old storage method to the new tables.
131
+ *
132
+ */
133
+ public function _migrate_to_v2() {
134
+ $redirects = get_option( self::$option_slug );
135
+ if (empty($redirects)) return false; // No redirects to migrate.
136
+
137
+ $new_redirects = array();
138
+
139
+ foreach ($redirects as $from => $to ) {
140
+ $new_redirects[] = array(
141
+ 'id' => false,
142
+ 'url_to' => urldecode($to),
143
+ 'url_from' => $from,
144
+ 'type' => 'url',
145
+ 'status' => '301'
146
+ );
147
+ }
148
+
149
+ self::_save_redirects( $new_redirects );
150
+
151
+ //update_option( self::$option_slug, null );
152
+ }
153
+
154
+ /**
155
+ *
156
+ * CREATE TABLES
157
+ *
158
+ * Creates the new database architecture
159
+ *
160
+ * @return nothing
161
+ * @author epstudios
162
+ *
163
+ */
164
+ private function _create_tables() {
165
+ global $wpdb;
166
+
167
+ $table_name = $wpdb->prefix . "redirects";
168
+
169
+ $sql = "CREATE TABLE $table_name (
170
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
171
+ url_from VARCHAR(256) DEFAULT '' NOT NULL,
172
+ url_to VARCHAR(256) DEFAULT '' NOT NULL,
173
+ status VARCHAR(12) DEFAULT '301' NOT NULL,
174
+ type VARCHAR(12) DEFAULT 'url' NOT NULL,
175
+ count mediumint(9) DEFAULT 0 NOT NULL,
176
+ UNIQUE KEY id (id)
177
+ );";
178
+
179
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
180
+ dbDelta( $sql );
181
+ }
182
+
183
 
184
  /**
185
  *
193
  */
194
  public function enqueue_resources(){
195
  wp_enqueue_script('jquery');
196
+ wp_enqueue_script('eps_redirect_script', EPS_REDIRECT_URL .'js/scripts.js');
197
  wp_enqueue_style('eps_redirect_styles', EPS_REDIRECT_URL .'css/eps_redirect.css');
198
  }
199
 
221
  *
222
  */
223
  public function do_redirect() {
224
+
225
+ $redirects = self::get_redirects( true ); // True for only active redirects.
226
+ if (empty($redirects)) return false; // No redirects.
227
+
228
  // Get current url
229
  $url_request = self::get_url();
230
 
231
+ foreach ($redirects as $redirect ) {
232
+ $from = urldecode( $redirect->url_from );
233
+ $to = ($redirect->type == "url" && !is_numeric( $redirect->url_to )) ? urldecode($redirect->url_to) : get_permalink( $redirect->url_to );
234
+
235
+ if( $redirect->status != 'inactive' && rtrim( trim($url_request),'/') === self::format_from_url( trim($from) ) ) {
236
+ // Match, this needs to be redirected
237
+ //increment this hit counter.
238
+ self::increment_field($redirect->id, 'count');
239
+
240
+ if( $redirect->status == '301' ) {
241
+ header ('HTTP/1.1 301 Moved Permanently');
242
+ } elseif ( $redirect->status == '302' ) {
243
+ header ('HTTP/1.1 301 Moved Temporarily');
244
+ }
245
+ header ('Location: ' . $to, true, (int) $redirect->status);
246
+ exit();
247
+ }
248
+
249
  }
250
  }
251
+
252
+ /**
253
+ *
254
+ * FORMAT FROM URL
255
+ *
256
+ * Will construct and format the from url from what we have in storage.
257
+ *
258
+ * @return url string
259
+ * @author epstudios
260
+ *
261
+ */
262
  private function format_from_url( $string ) {
263
+ $from = home_url() . '/' . $string;
264
+ return strtolower( rtrim( $from,'/') );
265
  }
266
+
267
  /**
268
  *
269
  * GET_URL
276
  */
277
  function get_url() {
278
  $protocol = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https' : 'http';
279
+ return strtolower( urldecode( $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
280
  }
281
 
282
 
297
  *
298
  * _SAVE
299
  *
300
+ * This function handles various POST requests.
301
  *
302
  * @return html string
303
  * @author epstudios
305
  */
306
  public function _save(){
307
 
308
+ // Refresh the Transient Cache
309
+ if ( isset( $_POST['eps_redirect_refresh'] ) && wp_verify_nonce( $_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce') ) {
310
+ $post_types = get_post_types(array('public'=>true), 'objects');
311
+ foreach ($post_types as $post_type ) {
312
+ $options = eps_dropdown_pages( array('post_type'=>$post_type->name ) );
313
+ set_transient( 'post_type_cache_'.$post_type->name, $options, HOUR_IN_SECONDS );
314
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  }
316
+
317
+ // Save Redirects
318
+ if ( isset( $_POST['eps_redirect_submit'] ) && wp_verify_nonce( $_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce') )
319
+ $this->_save_redirects( self::_parse_serial_array($_POST['redirect']) );
320
+
321
  }
322
 
323
  /**
324
  *
325
+ * PARSE SERIAL ARRAY
326
  *
327
+ * A necessary data parser to change the POST arrays into save-able data.
328
  *
329
+ * @return array of redirects
330
  * @author epstudios
331
+ *
332
  */
333
+ private function _parse_serial_array( $array ){
334
+ $new_redirects = array();
335
+ $total = count( $array['url_from'] );
336
 
337
+ for( $i = 0; $i < $total; $i ++ ) {
 
 
 
 
338
 
339
+ if( empty( $array['url_to'][$i]) || empty( $array['url_from'][$i] ) ) continue;
340
+ $new_redirects[] = array(
341
+ 'id' => isset( $array['id'][$i] ) ? $array['id'][$i] : null,
342
+ 'url_from' => $array['url_from'][$i],
343
+ 'url_to' => $array['url_to'][$i],
344
+ 'type' => ( is_numeric($array['url_to'][$i]) ) ? 'post' : 'url',
345
+ 'status' => isset( $array['status'][$i] ) ? $array['status'][$i] : 'active'
346
+ );
 
 
 
 
 
 
347
  }
348
+ return $new_redirects;
349
  }
 
350
 
 
 
 
351
  /**
352
  *
353
+ * SAVE REDIRECTS
 
354
  *
355
+ * Saves the array of redirects.
356
  *
357
+ * TODO: Maybe refactor this to reduce the number of queries.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  *
359
+ * @return nothing
 
 
 
 
360
  * @author epstudios
 
361
  */
362
+ private function _save_redirects( $array ) {
363
+ if( empty( $array ) ) return false;
364
+ global $wpdb;
365
+ $table_name = $wpdb->prefix . "redirects";
366
+
367
+ foreach( $array as $redirect ) {
368
+ if( !$redirect['id'] || empty($redirect['id']) ) {
369
+ // new
370
+ $wpdb->insert(
371
+ $table_name,
372
+ array(
373
+ 'url_from' => trim( $redirect['url_from'] ),
374
+ 'url_to' => trim( $redirect['url_to']),
375
+ 'type' => trim( $redirect['type']),
376
+ 'status' => trim( $redirect['status'])
377
+ )
378
+ );
379
+
380
+ } else {
381
+ // existing
382
+ $wpdb->update(
383
+ $table_name,
384
+ array(
385
+ 'url_from' => trim( $redirect['url_from']),
386
+ 'url_to' => trim( $redirect['url_to']),
387
+ 'type' => trim( $redirect['type']),
388
+ 'status' => trim( $redirect['status'])
389
+ ),
390
+ array( 'id' => $redirect['id'] )
391
+ );
392
+ }
393
+
394
  }
 
 
 
 
 
 
 
 
 
395
 
 
 
 
396
  }
397
+ /**
398
+ * GET REDIRECTS
 
 
 
 
399
  *
400
+ * Gets the redirects. Can be switched to return Active Only redirects.
401
  *
402
+ * @return array of redirects
 
403
  * @author epstudios
404
+ *
405
  */
406
+ public function get_redirects( $active_only = false ) {
407
+ global $wpdb;
408
+ $table_name = $wpdb->prefix . "redirects";
409
+ $results = $wpdb->get_results(
410
+ "SELECT * FROM $table_name " . ( ( $active_only ) ? "WHERE status != 'inactive'" : null )
411
+ );
412
+ return $results;
413
  }
414
+
415
  /**
416
  *
417
+ * INCREMENT FIELD
418
  *
419
+ * Add +1 to the specified field for a given id
420
  *
421
+ * @return the result
 
422
  * @author epstudios
423
+ *
424
  */
425
+ public function increment_field( $id, $field ) {
426
  global $wpdb;
427
+ $table_name = $wpdb->prefix . "redirects";
428
+ $results = $wpdb->query( "UPDATE $table_name SET $field = $field + 1 WHERE id = $id");
429
+ return $results;
 
 
 
 
430
  }
431
 
432
  /**
433
  *
434
+ * DO_INPUTS
435
  *
436
+ * This function will list out all the current entries.
 
437
  *
438
  * @return html string
 
439
  * @author epstudios
440
  *
441
  */
442
+ public function do_inputs(){
443
+ $redirects = self::get_redirects( );
444
+ $html = '';
445
+ if (empty($redirects)) return false;
446
+ ob_start();
447
+ foreach ($redirects as $redirect ) {
448
+ $dfrom = urldecode($redirect->url_from);
449
+ $dto = urldecode($redirect->url_to );
450
+ include( EPS_REDIRECT_PATH . 'templates/template.redirect-entry.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  }
452
+ $html = ob_get_contents();
453
+ ob_end_clean();
 
 
 
 
 
 
 
 
 
 
454
  return $html;
455
  }
456
+
457
 
458
  /**
459
  *
460
+ * DELETE_ENTRY
461
  *
462
+ * This function will remove an entry.
463
  *
464
+ * @return nothing
465
  * @author epstudios
466
  *
467
  */
468
+ public static function ajax_eps_delete_entry(){
469
+ if( !isset($_POST['id']) ) exit();
 
 
470
 
471
+ global $wpdb;
472
+ $table_name = $wpdb->prefix . "redirects";
473
+ $results = $wpdb->delete( $table_name, array( 'ID' => intval( $_POST['id'] ) ) );
474
+ echo json_encode( array( 'id' => $_POST['id']) );
475
+ exit();
 
 
 
 
 
 
 
 
 
 
 
476
  }
477
 
478
  /**
479
  *
480
+ * GET_BLANK_ENTRY
481
+ * AJAX_GET_BLANK_ENTRY
482
  *
483
+ * This function will return a blank row ready for user input.
484
  *
485
+ * @return html string
486
  * @author epstudios
487
  *
488
  */
489
+ public static function get_blank_entry() {
490
+ ob_start();
491
+ include( EPS_REDIRECT_PATH . 'templates/template.redirect-entry-empty.php');
492
+ $html = ob_get_contents();
493
+ ob_end_clean();
494
+ return $html;
495
  }
496
 
497
+ public static function ajax_get_blank_entry() {
498
+ echo self::get_blank_entry(); exit();
499
+ }
500
 
501
+ public function clear_cache() {
502
+ header("Cache-Control: no-cache, must-revalidate");
503
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
504
+ header("Content-Type: application/xml; charset=utf-8");
 
 
505
  }
506
 
507
 
508
  /**
509
  *
510
+ * SET_AJAX_URL
511
  *
512
+ * This function will output a variable containing the admin ajax url for use in javascript.
513
  *
514
+ * @author epstudios
515
+ *
516
  */
517
+ public static function set_ajax_url() {
518
+ echo '<script>var eps_redirect_ajax_url = "'. admin_url( 'admin-ajax.php' ) . '"</script>';
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
520
+
521
+ public function activation_error() {
522
+ file_put_contents(EPS_REDIRECT_PATH. '/error_activation.html', ob_get_contents());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  }
524
+
525
+
526
  }
527
 
528
 
534
  * @param $string = the object to prettify; Typically a string.
535
  * @author epstudios
536
  */
537
+ if( !function_exists('eps_prettify')) {
538
  function eps_prettify( $string ) {
539
  return ucwords( str_replace("_"," ",$string) );
540
  }
541
+ }
542
+
543
+ if( !function_exists('eps_view')) {
544
+ function eps_view( $object ) {
545
+ echo '<pre>';
546
+ print_r($object);
547
+ echo '</pre>';
548
+ }
549
+ }
550
 
551
 
552
 
eps-form-elements.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * EPS 301 REDIRECTS
5
+ *
6
+ *
7
+ *
8
+ * This plugin creates a nice Wordpress settings page for creating 301 redirects on your Wordpress
9
+ * blog or website. Often used when migrating sites, or doing major redesigns, 301 redirects can
10
+ * sometimes be a pain - it's my hope that this plugin helps you seamlessly create these redirects
11
+ * in with this quick and efficient interface.
12
+ *
13
+ * PHP version 5
14
+ *
15
+ *
16
+ * @package EPS 301 Redirects
17
+ * @author Shawn Wernig ( shawn@eggplantstudios.ca )
18
+ * @version 1.4.0
19
+ */
20
+
21
+ /**
22
+ *
23
+ * GET_TYPE_SELECT
24
+ *
25
+ * This function will initialze a series of html form elements so a user can narrow down their redirect destination.
26
+ *
27
+ * @return html string
28
+ * @author epstudios
29
+ *
30
+ */
31
+
32
+ function eps_get_selector( $redirect = false ) {
33
+ $current_post = ( isset( $redirect->url_to ) && is_numeric( $redirect->url_to ) ) ? get_post( intval( $redirect->url_to ) ) : null;
34
+
35
+ $post_types = get_post_types(array('public'=>true), 'objects');
36
+
37
+
38
+ $html = eps_get_type_select($post_types, $current_post);
39
+
40
+
41
+
42
+ // The default input, javascript will populate this input with the final URL for submission.
43
+ $html .= '<input class="eps-redirect-url"
44
+ type="text"
45
+ name="redirect[url_to][]"
46
+ value="'.( isset( $redirect->url_to ) ? $redirect->url_to : null ).'"
47
+ placeholder="'.get_bloginfo('home').'" '.
48
+ ( ( isset( $redirect->type ) && $redirect->type != 'post' || !isset($redirect->type) ) ? null : ' style="display:none;"' ).
49
+ '/>';
50
+
51
+
52
+ // Get all the post type select boxes.
53
+ foreach ($post_types as $post_type ) {
54
+ $html .= eps_get_post_type_selects($post_type->name, $current_post);
55
+ }
56
+ //$html .=
57
+
58
+ // Get the term select box.
59
+ $html .= eps_get_term_archive_select();
60
+ return $html;
61
+
62
+
63
+ }
64
+
65
+
66
+ function eps_get_post_type_selects( $post_type, $current_post = false ) {
67
+ // Start the select.
68
+ $html = '<select class="'.$post_type.' url-selector" '.( (isset($current_post) && $current_post->post_type == $post_type ) ? null : 'style="display:none;"').'>';
69
+ $html .= '<option value="">...</option>';
70
+
71
+ if ( false === ( $options = get_transient( 'post_type_cache_'.$post_type ) ) ) {
72
+ $options = eps_dropdown_pages( array('post_type'=>$post_type ) );
73
+ set_transient( 'post_type_cache_'.$post_type, $options, HOUR_IN_SECONDS );
74
+ }
75
+
76
+ foreach( $options as $option => $value ) {
77
+ $html .= '<option value="'.$value.'" '.( isset($current_post) && $current_post->ID == $value ? 'selected="selected"' : null ).' >'. ( strlen($option) > 32 ? substr($option,0,32).'...' : $option ) . '</option>';
78
+ }
79
+ $html .= '</select>';
80
+ return $html;
81
+
82
+ }
83
+ function eps_get_type_select( $post_types, $current_post = false ){
84
+ $html = '<select class="type-select">';
85
+ $html .= '<option value="eps-redirect-url">Custom</option>';
86
+
87
+ foreach ($post_types as $post_type ) {
88
+ $html .= '<option value="'.$post_type->name.'" '.( isset( $current_post ) && $current_post->post_type == $post_type->name ? 'selected="selected"' : null).'>'. $post_type->labels->singular_name. '</option>';
89
+ }
90
+ $html .= '<option value="term">Term Archive</option>';
91
+ $html .= '</select>';
92
+ return $html;
93
+ }
94
+
95
+
96
+ /**
97
+ *
98
+ * GET_TERM_ARCHIVE_SELECT
99
+ *
100
+ * This function will output a select box with all the taxonomies and terms.
101
+ *
102
+ * @return html string
103
+ * @author epstudios
104
+ *
105
+ */
106
+ function eps_get_term_archive_select(){
107
+ $taxonomies = get_taxonomies( '', 'objects' );
108
+
109
+ if (!$taxonomies) return false;
110
+
111
+ // Start the select.
112
+ $html = '<select class="term url-selector" style="display:none;">';
113
+ $html .= '<option value="" selected default>...</option>';
114
+
115
+ // Loop through all taxonomies.
116
+ foreach ($taxonomies as $tax ) {
117
+ $terms = get_terms( $tax->name, array('hide_empty' => false) ); // show empty terms.
118
+ $html .= '<option value="'.$tax->name.'" disabled>'. $tax->labels->singular_name. '</option>';
119
+
120
+ // Loop through all terms in this taxonomy and insert them as options.
121
+ foreach($terms as $term)
122
+ $html .= '<option value="'.get_term_link($term).'">&nbsp;&nbsp;- '. $term->name. '</option>';
123
+
124
+ }
125
+ $html .= '</select>';
126
+ return $html;
127
+ }
128
+ ?>
icons/eggplant-64.png DELETED
Binary file
js/scripts.js CHANGED
@@ -4,19 +4,44 @@
4
 
5
 
6
  jQuery(document).ready(function ($) {
7
-
 
 
 
 
 
8
  $(document).on("change", 'select.type-select', function() {
9
  var input_type = $(this).val();
10
  $(this).siblings().hide();
11
  $(this).siblings('.'+input_type).show();
12
  });
13
 
 
 
 
 
 
14
  $(document).on("change", 'select.url-selector', function() {
15
- $(this).siblings('.eps-redirect-url').val( $(this).val() );
 
 
16
  });
17
 
 
 
 
 
 
 
 
 
18
 
19
 
 
 
 
 
 
20
  $('#eps-redirect-add').click( function(e){
21
  e.preventDefault();
22
  var request = $.post( eps_redirect_ajax_url, {
@@ -25,18 +50,35 @@ jQuery(document).ready(function ($) {
25
  request.done(function( data ) {
26
  $('#eps-redirect-entries tr:last-child').before( data );
27
  });
28
-
29
-
30
-
31
  });
32
 
 
 
 
 
 
 
 
 
33
  $('.eps-text-link.remove').click( function(e){
34
  e.preventDefault();
35
- $(this).closest('tr.redirect-entry').remove();
 
 
 
 
 
 
 
 
 
36
  });
37
 
38
 
39
 
 
 
 
40
  /**
41
  *
42
  *
4
 
5
 
6
  jQuery(document).ready(function ($) {
7
+
8
+ /**
9
+ *
10
+ *
11
+ * Loads the relevant sub-selector based on the primary selector.
12
+ */
13
  $(document).on("change", 'select.type-select', function() {
14
  var input_type = $(this).val();
15
  $(this).siblings().hide();
16
  $(this).siblings('.'+input_type).show();
17
  });
18
 
19
+ /**
20
+ *
21
+ *
22
+ * When a select box is changed, send that new value to our input.
23
+ */
24
  $(document).on("change", 'select.url-selector', function() {
25
+ $(this).siblings('.eps-redirect-url').val( $(this).val() );
26
+ console.log( $(this).closest('tr.redirect-entry').find('.eps-text-link.test') );
27
+ $(this).closest('tr.redirect-entry').find('.eps-text-link.test').addClass('inactive');
28
  });
29
 
30
+ /**
31
+ *
32
+ *
33
+ * Grey out the test button if it's been changed.
34
+ */
35
+ $('tr.redirect-entry .eps-text-link.test').on('click', function(e) {
36
+ if( $(this).hasClass('inactive') ) e.preventDefault();
37
+ });
38
 
39
 
40
+ /**
41
+ *
42
+ *
43
+ * Get a new blank input.
44
+ */
45
  $('#eps-redirect-add').click( function(e){
46
  e.preventDefault();
47
  var request = $.post( eps_redirect_ajax_url, {
50
  request.done(function( data ) {
51
  $('#eps-redirect-entries tr:last-child').before( data );
52
  });
 
 
 
53
  });
54
 
55
+
56
+
57
+
58
+ /**
59
+ *
60
+ *
61
+ * Delete an entry.
62
+ */
63
  $('.eps-text-link.remove').click( function(e){
64
  e.preventDefault();
65
+ var request = $.post( eps_redirect_ajax_url, {
66
+ 'action' : 'eps_redirect_delete_entry',
67
+ 'id' : $(this).siblings('.redirect-id').val()
68
+ });
69
+ request.done(function( data ) {
70
+ var response = JSON.parse(data);
71
+ $('tr.redirect-entry.id-'+response.id).remove();
72
+ });
73
+
74
+
75
  });
76
 
77
 
78
 
79
+
80
+
81
+
82
  /**
83
  *
84
  *
readme.txt CHANGED
@@ -3,12 +3,12 @@ Contributors: shawneggplantstudiosca
3
  Donate link: none
4
  Tags: 301 redirects, redirects
5
  Requires at least: 3.0.1
6
- Tested up to: 3.5
7
- Stable tag: 1.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Easily manage and create 301 redirects for your Wordpress website. A robust interface allows you create and validate redirecs.
12
 
13
  == Description ==
14
 
@@ -24,11 +24,13 @@ A 301 redirect indicates that the page requested has been permanently moved to t
24
  **When Should I use EPS 301 Redirects?**
25
  1. Replacing an old site design with a new site design
26
  1. Overhauling or re-organizing your existing Wordpress content
 
27
 
28
 
29
  **Features**
30
  * Choose from Pages, Posts, Custom Post types, Archives, Term Archives,
31
- * Overhauling or re-organizing your existing Wordpress content
 
32
 
33
 
34
 
@@ -50,9 +52,14 @@ Created by Shawn Wernig [Eggplant Studios](http://www.eggplantstudios.ca/ "Eggpl
50
 
51
  == Frequently Asked Questions ==
52
 
 
 
 
 
 
53
  = My redirects aren't working =
54
 
55
- This could be caused by many things, but please ensure that you are supplying valid URLs. If you're sure everything should be working, check the status code for the failing redirects, are both statuses marked Green?
56
 
57
 
58
  = My redirects aren't getting the 301 status code =
@@ -76,6 +83,12 @@ Click the small X beside the redirect you wish to remove. Save changes.
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
79
  = 1.4.0 =
80
  * Performance updates, added a new 'Settings' page.
81
 
@@ -108,6 +121,12 @@ Click the small X beside the redirect you wish to remove. Save changes.
108
 
109
  == Upgrade Notice ==
110
 
 
 
 
 
 
 
111
  = 1.4.0 =
112
  * Performance updates, added a new 'Settings' page.
113
 
3
  Donate link: none
4
  Tags: 301 redirects, redirects
5
  Requires at least: 3.0.1
6
+ Tested up to: 3.8.1
7
+ Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Easily manage and create 301 redirects for your Wordpress website. A robust interface allows you create and validate redirects.
12
 
13
  == Description ==
14
 
24
  **When Should I use EPS 301 Redirects?**
25
  1. Replacing an old site design with a new site design
26
  1. Overhauling or re-organizing your existing Wordpress content
27
+ 1. You have content that expires (or is otherwise no longer available) and you wish to redirect users elsewhere.
28
 
29
 
30
  **Features**
31
  * Choose from Pages, Posts, Custom Post types, Archives, Term Archives,
32
+ * Creates its own database table, for faster indexing
33
+
34
 
35
 
36
 
52
 
53
  == Frequently Asked Questions ==
54
 
55
+ = I'm getting an error about the default permalink structure? =
56
+
57
+ EPS 301 Redirects requires that you use anything but the default permalink structure.
58
+
59
+
60
  = My redirects aren't working =
61
 
62
+ This could be caused by many things, but please ensure that you are supplying valid URLs. Most common are extra spaces, spelling mistakes and invalid characters.
63
 
64
 
65
  = My redirects aren't getting the 301 status code =
83
 
84
  == Changelog ==
85
 
86
+ = 2.0.1 =
87
+ Fixed an issue where the Automatic Update would not call the import process for pre 2.0 versions.
88
+
89
+ = 2.0.0 =
90
+ Overhauled the entire plugin. Redirects are stored in their own table. Gracefully migrates older versions.
91
+
92
  = 1.4.0 =
93
  * Performance updates, added a new 'Settings' page.
94
 
121
 
122
  == Upgrade Notice ==
123
 
124
+ = 2.0.1 =
125
+ Fixed an issue where the Automatic Update would not call the import process for pre 2.0 versions.
126
+
127
+ = 2.0.0 =
128
+ Overhauled the entire plugin. Redirects are stored in their own table. Gracefully migrates older versions.
129
+
130
  = 1.4.0 =
131
  * Performance updates, added a new 'Settings' page.
132
 
templates/admin.php CHANGED
@@ -14,7 +14,6 @@
14
  * @author Shawn Wernig ( shawn@eggplantstudios.ca )
15
  * @version 1.3.4
16
  */
17
- $settings = get_option( 'eps_redirect_settings' );
18
  global $wp_rewrite;
19
 
20
  ?>
@@ -22,12 +21,12 @@ global $wp_rewrite;
22
  <div class="wrap">
23
  <header id="eps-header">
24
  <div id="icon-eggplant">&nbsp;</div>
25
- <h2 class="eps-title"><?php echo self::$page_title; ?></h2>
26
  </header>
27
 
28
  <?php
29
  if( !isset($wp_rewrite->permalink_structure) || empty($wp_rewrite->permalink_structure) ) {
30
- echo '<div class="error clear"><div class="padding">';
31
  echo '<strong>WARNING:</strong> EPS 301 Redirects requires that a permalink structure is set. The Default Wordpress permalink structure is not compatible. Please update the <a href="options-permalink.php" title="Permalinks">Permalink Structure</a>.</div>';
32
  echo '</div></div>';
33
  }
@@ -36,17 +35,28 @@ global $wp_rewrite;
36
 
37
  <div id="eps-tab-nav">
38
  <a href="#eps-redirect-redirects" class="active eps-tab-nav-item">Redirects</a>
39
- <a href="#eps-redirect-settings" class="eps-tab-nav-item">Settings</a>
40
  </div>
41
 
42
  <div id="eps-tabs">
43
  <?php include ( EPS_REDIRECT_PATH . 'templates/admin.redirects.php' ); ?>
44
- <?php include ( EPS_REDIRECT_PATH . 'templates/admin.settings.php' ); ?>
45
  </div>
46
 
47
  </div>
48
-
49
-
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  </div>
51
 
52
 
14
  * @author Shawn Wernig ( shawn@eggplantstudios.ca )
15
  * @version 1.3.4
16
  */
 
17
  global $wp_rewrite;
18
 
19
  ?>
21
  <div class="wrap">
22
  <header id="eps-header">
23
  <div id="icon-eggplant">&nbsp;</div>
24
+ <h2 class="eps-title"><?php echo self::$page_title; ?> <?php echo get_option( 'eps_redirects_version' ); ?></h2>
25
  </header>
26
 
27
  <?php
28
  if( !isset($wp_rewrite->permalink_structure) || empty($wp_rewrite->permalink_structure) ) {
29
+ echo '<div class="error clear"><div class="eps-padding">';
30
  echo '<strong>WARNING:</strong> EPS 301 Redirects requires that a permalink structure is set. The Default Wordpress permalink structure is not compatible. Please update the <a href="options-permalink.php" title="Permalinks">Permalink Structure</a>.</div>';
31
  echo '</div></div>';
32
  }
35
 
36
  <div id="eps-tab-nav">
37
  <a href="#eps-redirect-redirects" class="active eps-tab-nav-item">Redirects</a>
 
38
  </div>
39
 
40
  <div id="eps-tabs">
41
  <?php include ( EPS_REDIRECT_PATH . 'templates/admin.redirects.php' ); ?>
 
42
  </div>
43
 
44
  </div>
45
+ <div id="donate-box">
46
+ <div class="eps-padding">
47
+ <p>Comments, questions, bugs and feature requests can be sent to: <a href="mailto:plugins@eggplantstudios.ca">plugins@eggplantstudios.ca</a></p>
48
+ <hr>
49
+ <h3>Please consider donating</h3>
50
+ <p>Your donations help support future versions EPS 301 Redirects.</p>
51
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
52
+ <p>
53
+ <input type="hidden" name="cmd" value="_s-xclick">
54
+ <input type="hidden" name="hosted_button_id" value="2WC9XYFX49CSQ">
55
+ <input class="button button-secondary" type="submit" name="submit" value="Donate">
56
+ </p>
57
+ </form>
58
+ </div>
59
+ </div>
60
  </div>
61
 
62
 
templates/admin.redirects.php CHANGED
@@ -19,24 +19,24 @@
19
 
20
  <form method="post" action="">
21
  <table id="eps-redirect-entries">
22
- <tr>
23
- <td>
24
- <h3>Request URL</h3>
25
- </td>
26
- <td>
27
- <h3>Redirect to URL</h3>
28
- </td>
29
- </tr>
30
- <?php
31
  echo self::do_inputs();
32
  echo self::get_blank_entry();
33
  ?>
34
- <tr><td colspan="2"><a class="eps-text-link new" href="#" id="eps-redirect-add">+ Add Empty</a></td></tr>
35
  </table>
36
  <hr class="eps-divider">
37
  <p class="submit">
38
  <?php wp_nonce_field('eps_redirect_nonce', 'eps_redirect_nonce_submit'); ?>
 
39
  <input type="submit" name="eps_redirect_submit" id="submit" class="button button-primary" value="Save Changes"/>
 
40
  </p>
41
  </form>
42
 
19
 
20
  <form method="post" action="">
21
  <table id="eps-redirect-entries">
22
+ <tr class="redirect-entry">
23
+ <th>Status</th>
24
+ <th>Request URL</th>
25
+ <th>Redirect To</th>
26
+ <th>Hits</th>
27
+ <th>Actions</th>
28
+ </tr> <?php
 
 
29
  echo self::do_inputs();
30
  echo self::get_blank_entry();
31
  ?>
32
+ <tr><td colspan="3"><a class="eps-text-link new" href="#" id="eps-redirect-add">+ Add Empty</a></td></tr>
33
  </table>
34
  <hr class="eps-divider">
35
  <p class="submit">
36
  <?php wp_nonce_field('eps_redirect_nonce', 'eps_redirect_nonce_submit'); ?>
37
+ <input type="submit" name="eps_redirect_refresh" id="submit" class="button button-secondary" value="Refresh Cache"/>&nbsp;&nbsp;
38
  <input type="submit" name="eps_redirect_submit" id="submit" class="button button-primary" value="Save Changes"/>
39
+ <p><small class="eps-grey-text">Refresh the cache if the dropdowns are out of date.</small></p>
40
  </p>
41
  </form>
42
 
templates/admin.settings.php CHANGED
File without changes
templates/template.redirect-entry-empty.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * EPS redirects
5
+ *
6
+ *
7
+ *
8
+ * PHP version 5
9
+ *
10
+ *
11
+ * @package EPS 301 Redirects
12
+ * @author Shawn Wernig ( shawn@eggplantstudios.ca )
13
+ * @version 1.3.4
14
+ */
15
+
16
+
17
+ ?>
18
+ <tr class="redirect-entry">
19
+ <td>
20
+ <select name="redirect[status][]" class="simple">
21
+ <option value="301">301</option>
22
+ <option value="302">302</option>
23
+ <option value="inactive">Off</option>
24
+ </select>
25
+ </td>
26
+ <td>
27
+ <span class="eps-grey-text"><small><?php bloginfo('home'); ?>/&nbsp;</small></span>
28
+ <input class="eps-request-url" type="text" name="redirect[url_from][]" value="" >
29
+ </td>
30
+ <td><?php echo eps_get_selector(); ?></td>
31
+ <td></td>
32
+ <td class="redirect-actions">&nbsp;</td>
33
+ </tr>
templates/template.redirect-entry.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * EPS redirects
5
+ *
6
+ *
7
+ *
8
+ * PHP version 5
9
+ *
10
+ *
11
+ * @package EPS 301 Redirects
12
+ * @author Shawn Wernig ( shawn@eggplantstudios.ca )
13
+ * @version 1.3.4
14
+ */
15
+
16
+
17
+ ?>
18
+ <tr class="redirect-entry <?php echo $redirect->status; ?> id-<?php echo $redirect->id; ?>">
19
+ <td><span>
20
+ <select name="redirect[status][]" class="simple">
21
+ <option value="301" <?php echo ( $redirect->status == '301' ) ? 'selected="selected"' : null; ?>>301</option>
22
+ <option value="302" <?php echo ( $redirect->status == '302' ) ? 'selected="selected"' : null; ?>>302</option>
23
+ <option value="inactive" <?php echo ( $redirect->status == 'inactive' ) ? 'selected="selected"' : null; ?>>Off</option>
24
+ </select>
25
+ </span>
26
+ </td>
27
+ <td>
28
+ <span class="eps-grey-text"><small><?php bloginfo('home'); ?>/&nbsp;</small></span>
29
+ <input class="eps-request-url" type="text" name="redirect[url_from][]" value="<?php echo $dfrom; ?>" >
30
+ </td>
31
+ <td>
32
+ <?php echo eps_get_selector( $redirect ); ?>
33
+ </td>
34
+ <td class="text-center"><strong><?php echo $redirect->count; ?></strong></td>
35
+ <td class="redirect-actions">
36
+ <input type="hidden" class="redirect-id" name="redirect[id][]" value="<?php echo $redirect->id; ?>" >
37
+ <a class="eps-text-link test" href="<?php echo self::format_from_url( $redirect->url_from ); ?>" target="_blank">Test</a>
38
+ <a class="eps-text-link remove eps-redirect-remove" href="#" class="">&times;</a>
39
+ </td>
40
+ </tr>