Eggplant 301 Redirects - Version 2.70

Version Description

  • 2021/05/01
  • 404 error log widget is now visible only to users with manage_options permission
  • added "Delete all redirect rules" tool
Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 Eggplant 301 Redirects
Version 2.70
Comparing to
See all releases

Code changes from version 2.67 to 2.70

eps-301-redirects.php CHANGED
@@ -2,13 +2,13 @@
2
  /*
3
  Plugin Name: 301 Redirects
4
  Description: Easily create and manage redirect rules, and view 404 error log.
5
- Version: 2.67
6
  Author: WebFactory Ltd
7
  Author URI: https://www.webfactoryltd.com/
8
  Plugin URI: https://wp301redirects.com/
9
  Text Domain: eps-301-redirects
10
  Requires at least: 3.6
11
- Tested up to: 5.6
12
  Requires PHP: 5.2
13
 
14
  Copyright 2015 - 2021 WebFactory Ltd (email: 301redirects@webfactoryltd.com)
@@ -36,9 +36,11 @@ if (!defined('WF301_PLUGIN_FILE')) {
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.67');
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-options.php');
@@ -53,7 +55,6 @@ if (!defined('WF301_PLUGIN_FILE')) {
53
 
54
  class EPS_Redirects
55
  {
56
-
57
  /**
58
  *
59
  * Constructor
@@ -117,7 +118,9 @@ if (!defined('WF301_PLUGIN_FILE')) {
117
 
118
  // add widget to dashboard
119
  function add_widget() {
120
- add_meta_box('wp301_404_errors', '404 Error Log', array($this, 'widget_content'), 'dashboard', 'side', 'high');
 
 
121
  } // add_widget
122
 
123
 
2
  /*
3
  Plugin Name: 301 Redirects
4
  Description: Easily create and manage redirect rules, and view 404 error log.
5
+ Version: 2.70
6
  Author: WebFactory Ltd
7
  Author URI: https://www.webfactoryltd.com/
8
  Plugin URI: https://wp301redirects.com/
9
  Text Domain: eps-301-redirects
10
  Requires at least: 3.6
11
+ Tested up to: 5.7
12
  Requires PHP: 5.2
13
 
14
  Copyright 2015 - 2021 WebFactory Ltd (email: 301redirects@webfactoryltd.com)
36
 
37
  define('EPS_REDIRECT_PATH', plugin_dir_path(__FILE__));
38
  define('EPS_REDIRECT_URL', plugins_url() . '/eps-301-redirects/');
 
39
  define('EPS_REDIRECT_PRO', false);
40
 
41
+ $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
42
+ define('EPS_REDIRECT_VERSION', $plugin_data['version']);
43
+
44
  include(EPS_REDIRECT_PATH . 'eps-form-elements.php');
45
  include(EPS_REDIRECT_PATH . 'class.drop-down-pages.php');
46
  include(EPS_REDIRECT_PATH . 'libs/eps-plugin-options.php');
55
 
56
  class EPS_Redirects
57
  {
 
58
  /**
59
  *
60
  * Constructor
118
 
119
  // add widget to dashboard
120
  function add_widget() {
121
+ if (current_user_can('manage_options')) {
122
+ add_meta_box('wp301_404_errors', '404 Error Log', array($this, 'widget_content'), 'dashboard', 'side', 'high');
123
+ }
124
  } // add_widget
125
 
126
 
eps-form-elements.php CHANGED
@@ -55,7 +55,7 @@ function eps_get_selector($redirect = false)
55
  name="redirect[url_to][]"
56
  value="' . (isset($redirect->url_to) ? stripslashes(esc_attr($redirect->url_to)) : null) . '"
57
  placeholder="' . get_bloginfo('url') . '" ' . (!isset($redirect->type) || ((isset($redirect->type) && $redirect->type != 'post')) ? null : ' style="display:none;"') .
58
- '" />';
59
 
60
  return $html;
61
  }
55
  name="redirect[url_to][]"
56
  value="' . (isset($redirect->url_to) ? stripslashes(esc_attr($redirect->url_to)) : null) . '"
57
  placeholder="' . get_bloginfo('url') . '" ' . (!isset($redirect->type) || ((isset($redirect->type) && $redirect->type != 'post')) ? null : ' style="display:none;"') .
58
+ '" /><br><small>Remember: all external URLs have to start with <code>https://</code></small>';
59
 
60
  return $html;
61
  }
js/scripts.js CHANGED
@@ -202,6 +202,18 @@ jQuery(document).ready(function($) {
202
  });
203
  });
204
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  /**
206
  * Tabs
207
  */
202
  });
203
  });
204
 
205
+ /**
206
+ * Delete all redirect rules
207
+ */
208
+ $('#eps_delete_rules').on('click', function(e) {
209
+ if (confirm('Are you sure you want to delete ALL redirect rules? There is NO undo!')) {
210
+ return true;
211
+ } else {
212
+ e.preventDefault();
213
+ return false;
214
+ }
215
+ });
216
+
217
  /**
218
  * Tabs
219
  */
plugin.php CHANGED
@@ -191,16 +191,16 @@ class EPS_Redirects_Plugin
191
  *
192
  */
193
  public function update_self()
194
- {
195
- $version = get_option('eps_redirects_version');
196
 
197
- if (version_compare($version, '2.0.0', '<')) {
198
- // migrate old format to new format.
199
- add_action('admin_init', array($this, '_migrate_to_v2'), 1);
 
 
 
200
  }
201
- $this->set_current_version(EPS_REDIRECT_VERSION);
202
- return EPS_REDIRECT_VERSION;
203
- }
204
 
205
  /**
206
  *
@@ -371,6 +371,12 @@ class EPS_Redirects_Plugin
371
  $this->add_admin_message("Success: Cache Emptied.", "updated");
372
  }
373
 
 
 
 
 
 
 
374
  // Save Redirects
375
  if (isset($_POST['eps_redirect_submit']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
376
  self::_save_redirects(EPS_Redirects::_parse_serial_array($_POST['redirect']));
@@ -383,6 +389,14 @@ class EPS_Redirects_Plugin
383
  }
384
  }
385
 
 
 
 
 
 
 
 
 
386
  static function empty_3rd_party_cache() {
387
  wp_cache_flush();
388
  if (function_exists('w3tc_flush_all')) {
191
  *
192
  */
193
  public function update_self()
194
+ {
195
+ $version = get_option('eps_redirects_version');
196
 
197
+ if (version_compare($version, '2.0.0', '<')) {
198
+ // migrate old format to new format.
199
+ add_action('admin_init', array($this, '_migrate_to_v2'), 1);
200
+ }
201
+ $this->set_current_version(EPS_REDIRECT_VERSION);
202
+ return EPS_REDIRECT_VERSION;
203
  }
 
 
 
204
 
205
  /**
206
  *
371
  $this->add_admin_message("Success: Cache Emptied.", "updated");
372
  }
373
 
374
+ // delete all rules
375
+ if (isset($_POST['eps_delete_rules']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
376
+ self::delete_all_rules();
377
+ $this->add_admin_message("Success: All Redirect Rules Deleted.", "updated");
378
+ }
379
+
380
  // Save Redirects
381
  if (isset($_POST['eps_redirect_submit']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
382
  self::_save_redirects(EPS_Redirects::_parse_serial_array($_POST['redirect']));
389
  }
390
  }
391
 
392
+ static function delete_all_rules() {
393
+ global $wpdb;
394
+ $table = $wpdb->prefix . 'redirects';
395
+ $wpdb->query('TRUNCATE TABLE ' . $table);
396
+
397
+ return true;
398
+ }
399
+
400
  static function empty_3rd_party_cache() {
401
  wp_cache_flush();
402
  if (function_exists('w3tc_flush_all')) {
readme.txt CHANGED
@@ -2,17 +2,17 @@
2
  Contributors: WebFactory
3
  Tags: 301 redirect, redirects, redirect, 404 error log, redirection, 302 redirect, 302, seo, 302 redirect, 404, 404 redirect, 301, 307, 404 log
4
  Requires at least: 4.0
5
- Tested up to: 5.7
6
- Stable tag: 2.67
7
  Requires PHP: 5.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Easily manage 301 & 302 redirects. Simple to use & validate redirects. Includes redirect stats & 404 error log.
12
 
13
  == Description ==
14
 
15
- <a href="https://wp301redirects.com/?ref=wporg">301 Redirects</a> helps you manage and create 301, 302, 307 redirects for your WordPress site to **improve SEO and visitor experience**. With a user-friendly interface, 301 Redirects is easy to use. Perfect for new sites or repairing links after reorganizing your existing WordPress content, or when your site has content that expires and you wish to avoid sending visitors to a 404 error page. Use the 404 error log to identify problematic links.
16
 
17
  301 Redirects GUI is located in WP Admin - Settings - 301 Redirects
18
  404 Error Log widget can be found in the WP Admin - Dashboard
@@ -20,7 +20,7 @@ Easily manage 301 & 302 redirects. Simple to use & validate redirects. Includes
20
  **Features**
21
 
22
  * Choose from Pages, Posts, Custom Post types, Archives, and Term Archives from dropdown menu
23
- * Or, set a custom destination URL!
24
  * Retain query strings across redirects
25
  * Super-fast redirection
26
  * 404 error log
@@ -69,6 +69,11 @@ The 404 error log does not collect user IPs. It collects the following data: tim
69
 
70
  == Changelog ==
71
 
 
 
 
 
 
72
  = 2.67 =
73
  * 2021/03/16
74
  * fixed a small security issue
2
  Contributors: WebFactory
3
  Tags: 301 redirect, redirects, redirect, 404 error log, redirection, 302 redirect, 302, seo, 302 redirect, 404, 404 redirect, 301, 307, 404 log
4
  Requires at least: 4.0
5
+ Tested up to: 5.8
6
+ Stable tag: 2.70
7
  Requires PHP: 5.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Easily manage 301 & 302 redirects. Simple to use & validate redirects. Includes redirection stats & 404 error log.
12
 
13
  == Description ==
14
 
15
+ <a href="https://wp301redirects.com/?ref=wporg">301 Redirects</a> helps you manage and create 301, 302, 307 redirects for your WordPress site to **improve SEO and visitor experience**. With a user-friendly interface, 301 Redirects is easy to use. Perfect for new sites or repairing links after reorganizing your existing WordPress content, or when your site has content that expires and you wish to avoid sending visitors to a 404 error page. Use the 404 error log to identify problematic links and make redirection easy.
16
 
17
  301 Redirects GUI is located in WP Admin - Settings - 301 Redirects
18
  404 Error Log widget can be found in the WP Admin - Dashboard
20
  **Features**
21
 
22
  * Choose from Pages, Posts, Custom Post types, Archives, and Term Archives from dropdown menu
23
+ * Or, set a custom destination URL for redirection
24
  * Retain query strings across redirects
25
  * Super-fast redirection
26
  * 404 error log
69
 
70
  == Changelog ==
71
 
72
+ = 2.70 =
73
+ * 2021/05/01
74
+ * 404 error log widget is now visible only to users with manage_options permission
75
+ * added "Delete all redirect rules" tool
76
+
77
  = 2.67 =
78
  * 2021/03/16
79
  * fixed a small security issue
templates/admin-tab-import-export.php CHANGED
@@ -19,23 +19,32 @@ if (!defined('ABSPATH')) {
19
 
20
  <?php do_action('eps_redirects_admin_head'); ?>
21
 
22
- <div class="eps-panel eps-margin-top">
23
- <h3>Empty Cache</h3>
24
- <form method="post" action="">
25
- <?php wp_nonce_field('eps_redirect_nonce', 'eps_redirect_nonce_submit'); ?>
26
- <input type="submit" name="eps_redirect_refresh" id="submit" class="button button-secondary" value="Empty Cache" />
27
- <p class="eps-grey-text">Empty the cache if you're having problems with redirect rules or if dropdowns on "add new rule" are out of date.</p>
28
- </form>
29
- </div>
30
 
31
  <div class="eps-panel eps-margin-top">
32
  <h3>PRO Options</h3>
 
33
  <input class="open-301-pro-dialog" data-pro-feature="pro-option-typos" type="checkbox" id="pro-typos"> <label for="pro-typos">Automatically fix URL typos without having to create redirect rules</label><br>
34
  <input class="open-301-pro-dialog" data-pro-feature="pro-option-permalinks" type="checkbox" id="pro-monitor"> <label for="pro-monitor">Monitor permalink changes on posts &amp; pages and automatically create redirect rules so no traffic is lost</label><br>
35
  <input class="open-301-pro-dialog" data-pro-feature="pro-option-custom-404" type="checkbox" id="pro-custom-404"> <label for="pro-custom-404">Set a custom 404 page from any page</label>
36
  <p><a href="#" class="open-301-pro-dialog" data-pro-feature="pro-options">WP 301 Redirects PRO</a> offers advanced options to easily fix 2 most overlooked SEO issues - redirections and 404 errors.<br>If you have more than one site, the centralized Dashboard will save you hours of work with its centralized log for all sites.</p>
37
  </div>
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  <div class="eps-panel eps-margin-top">
40
  <h3>Import Redirect Rules</h3>
41
  <form method="post" action="" class="eps-padding" enctype="multipart/form-data">
19
 
20
  <?php do_action('eps_redirects_admin_head'); ?>
21
 
22
+
 
 
 
 
 
 
 
23
 
24
  <div class="eps-panel eps-margin-top">
25
  <h3>PRO Options</h3>
26
+ <input class="open-301-pro-dialog" data-pro-feature="pro-option-email-reports" type="checkbox" id="pro-email-reports"> <label for="pro-email-reports">Send me daily or weekly email reports about 404 errors &amp; redirects</label><br>
27
  <input class="open-301-pro-dialog" data-pro-feature="pro-option-typos" type="checkbox" id="pro-typos"> <label for="pro-typos">Automatically fix URL typos without having to create redirect rules</label><br>
28
  <input class="open-301-pro-dialog" data-pro-feature="pro-option-permalinks" type="checkbox" id="pro-monitor"> <label for="pro-monitor">Monitor permalink changes on posts &amp; pages and automatically create redirect rules so no traffic is lost</label><br>
29
  <input class="open-301-pro-dialog" data-pro-feature="pro-option-custom-404" type="checkbox" id="pro-custom-404"> <label for="pro-custom-404">Set a custom 404 page from any page</label>
30
  <p><a href="#" class="open-301-pro-dialog" data-pro-feature="pro-options">WP 301 Redirects PRO</a> offers advanced options to easily fix 2 most overlooked SEO issues - redirections and 404 errors.<br>If you have more than one site, the centralized Dashboard will save you hours of work with its centralized log for all sites.</p>
31
  </div>
32
 
33
+ <div class="eps-panel eps-margin-top">
34
+ <h3>Tools</h3>
35
+ <form method="post" action="">
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="Empty Cache" />
38
+ <p class="eps-grey-text">Empty the cache if you're having problems with redirect rules or if dropdowns on "add new rule" are out of date.</p>
39
+ </form>
40
+ <br>
41
+ <form method="post" action="">
42
+ <?php wp_nonce_field('eps_redirect_nonce', 'eps_redirect_nonce_submit'); ?>
43
+ <input type="submit" name="eps_delete_rules" id="eps_delete_rules" class="button button-secondary" value="Delete all Redirect Rules" />
44
+ <p class="eps-grey-text">If you have a lot of rules and don't want to delete them one by one, use this tool. Please be carefull. There is NO UNDO.</p>
45
+ </form>
46
+ </div>
47
+
48
  <div class="eps-panel eps-margin-top">
49
  <h3>Import Redirect Rules</h3>
50
  <form method="post" action="" class="eps-padding" enctype="multipart/form-data">
templates/template.redirect-entry-edit.php CHANGED
@@ -24,7 +24,7 @@ $redirect = self::get_redirect($redirect_id);
24
  </select>
25
 
26
  <div class="eps-url"><span class="eps-url-root"><?php bloginfo('url'); ?>/&nbsp;</span></div>
27
- <input class="eps-url-input" type="text" name="redirect[url_from][]" value="<?php echo ($redirect) ? esc_attr(stripslashes($redirect->url_from)) : ''; ?>">
28
  </td>
29
  <td>
30
  <?php echo eps_get_selector($redirect); ?>
24
  </select>
25
 
26
  <div class="eps-url"><span class="eps-url-root"><?php bloginfo('url'); ?>/&nbsp;</span></div>
27
+ <input class="eps-url-input" type="text" name="redirect[url_from][]" value="<?php echo ($redirect) ? esc_attr(stripslashes($redirect->url_from)) : ''; ?>"><br><small>Need wildcard support for matching multiple URLs? Check out the <a href="#" class="open-301-pro-dialog" data-pro-feature="new-rule-wildcard">PRO version.</small>
28
  </td>
29
  <td>
30
  <?php echo eps_get_selector($redirect); ?>