404 to 301 - Version 2.0.8

Version Description

(28/10/2015) = New Feature

  • New option to exclude paths from error logs and redirect - See details.

Bug Fixes

  • Fixed issue - Email notifications are being sent even after disabling it.
  • Fixed issue - Settings reset after reactivation of plugin.
Download this release

Release Info

Developer joelcj91
Plugin Icon 128x128 404 to 301
Version 2.0.8
Comparing to
See all releases

Code changes from version 2.0.7 to 2.0.8

404-to-301.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: http://iscode.co/products/404-to-301/
5
  * Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
6
- * Version: 2.0.7
7
  * Author: Joel James
8
  * Author URI: http://iscode.co/
9
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
@@ -52,7 +52,7 @@ if(!defined('I4T3_DB_VERSION')) {
52
  define( 'I4T3_DB_VERSION', '3' );
53
  }
54
  if(!defined('I4T3_VERSION')) {
55
- define( 'I4T3_VERSION', '2.0.7' );
56
  }
57
  // Set who all can access 404 settings. You can change this if you want to give others access.
58
  if(!defined('I4T3_ADMIN_PERMISSION')) {
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: http://iscode.co/products/404-to-301/
5
  * Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
6
+ * Version: 2.0.8
7
  * Author: Joel James
8
  * Author URI: http://iscode.co/
9
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
52
  define( 'I4T3_DB_VERSION', '3' );
53
  }
54
  if(!defined('I4T3_VERSION')) {
55
+ define( 'I4T3_VERSION', '2.0.8' );
56
  }
57
  // Set who all can access 404 settings. You can change this if you want to give others access.
58
  if(!defined('I4T3_ADMIN_PERMISSION')) {
admin/class-404-to-301-logs.php CHANGED
@@ -5,7 +5,7 @@ if ( ! defined( 'WPINC' ) ) {
5
  }
6
 
7
  /**
8
- * WP_List_Table is marked as private by WordPress. So they change it.
9
  * Details here - https://codex.wordpress.org/Class_Reference/WP_List_Table
10
  * So we have copied this class and using independently to avoid future issues.
11
  */
@@ -67,8 +67,6 @@ class _404_To_301_Logs extends WP_List_Table_404 {
67
  'ajax' => false //does this table support ajax?
68
  )
69
  );
70
-
71
- $this->process_bulk_action(); // To perform bulk delete action
72
  }
73
 
74
  /**
@@ -347,6 +345,7 @@ class _404_To_301_Logs extends WP_List_Table_404 {
347
  );
348
 
349
  $this->items = $this->log_data;
 
350
  }
351
 
352
 
@@ -376,35 +375,13 @@ class _404_To_301_Logs extends WP_List_Table_404 {
376
  if ( ! wp_verify_nonce( $nonce, $action ) )
377
  wp_die( 'Nope! Security check failed!' );
378
 
379
- $action = $this->current_action();
380
- if( $action == 'clear' ) {
381
- $this->clear_404_logs();
 
 
382
  }
383
  }
384
 
385
  }
386
-
387
- /**
388
- * To perform clear logs.
389
- *
390
- * This function is used to clear the entire log from db. This function is called
391
- * from process_bulk_action() method.
392
- * This function will delete the entire data from our log table and this can't be UNDONE.
393
- *
394
- * @since 2.0.0
395
- * @author Joel James.
396
- * @retun true if deleted something, else false.
397
- */
398
- public function clear_404_logs() {
399
-
400
- global $wpdb;
401
- // Let us hide sql query errors if any
402
- $wpdb->hide_errors();
403
- $total = $wpdb->query( "DELETE FROM $this->table" );
404
- if ( $total > 0 ) {
405
- wp_redirect(admin_url('admin.php?page=i4t3-logs'));
406
- exit();
407
- }
408
- }
409
-
410
  }
5
  }
6
 
7
  /**
8
+ * WP_List_Table is marked as private by WordPress. So they may change it.
9
  * Details here - https://codex.wordpress.org/Class_Reference/WP_List_Table
10
  * So we have copied this class and using independently to avoid future issues.
11
  */
67
  'ajax' => false //does this table support ajax?
68
  )
69
  );
 
 
70
  }
71
 
72
  /**
345
  );
346
 
347
  $this->items = $this->log_data;
348
+ $this->process_bulk_action(); // To perform bulk delete action
349
  }
350
 
351
 
375
  if ( ! wp_verify_nonce( $nonce, $action ) )
376
  wp_die( 'Nope! Security check failed!' );
377
 
378
+ else if( 'clear' === $this->current_action() ) {
379
+ global $wpdb;
380
+ // Let us hide sql query errors if any
381
+ $wpdb->hide_errors();
382
+ $total = $wpdb->query( "DELETE FROM $this->table" );
383
  }
384
  }
385
 
386
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  }
admin/partials/404-to-301-admin-general-tab.php CHANGED
@@ -91,6 +91,13 @@
91
  <p class="description"><?php _e( 'Change the recipient email address for error log notifications', '404-to-301' ); ?>.</p>
92
  </td>
93
  </tr>
 
 
 
 
 
 
 
94
  </tbody>
95
  </table>
96
  <?php submit_button( __( 'Save All Changes', '404-to-301' ) ); ?>
91
  <p class="description"><?php _e( 'Change the recipient email address for error log notifications', '404-to-301' ); ?>.</p>
92
  </td>
93
  </tr>
94
+ <tr>
95
+ <th><?php _e( 'Exclude paths', '404-to-301' ); ?></th>
96
+ <td>
97
+ <textarea rows="5" cols="50" placeholder="http://example.com&#13;&#10;wp-content/plugins/abc-plugin/css/" name="i4t3_gnrl_options[exclude_paths]"><?php echo $options['exclude_paths']; ?></textarea>
98
+ <p class="description"><?php _e( 'If you want to exclude few paths from error logs, enter here. One per line.', '404-to-301' ); ?>.</p>
99
+ </td>
100
+ </tr>
101
  </tbody>
102
  </table>
103
  <?php submit_button( __( 'Save All Changes', '404-to-301' ) ); ?>
includes/class-404-to-301-activator.php CHANGED
@@ -34,8 +34,9 @@ class _404_To_301_Activator {
34
  $i4t3_enable = self::transfer( '', 'redirect_log', 1 );
35
  $i4t3_to = self::transfer( '', 'redirect_to', 'link' );
36
  $i4t3_page = self::transfer( '', 'redirect_page', '' );
37
- $i4t3_notify = self::transfer( '', 'email_notify', 1 );
38
  $i4t3_notify_email = self::transfer( '', 'email_notify_address', get_option( 'admin_email' ) );
 
39
 
40
  // New general settings array to be added
41
  $i4t3GnrlOptions = array(
@@ -45,7 +46,8 @@ class _404_To_301_Activator {
45
  'redirect_to' => $i4t3_to,
46
  'redirect_page' => $i4t3_page,
47
  'email_notify' => $i4t3_notify,
48
- 'email_notify_address' => $i4t3_notify_email
 
49
  );
50
 
51
  /**
34
  $i4t3_enable = self::transfer( '', 'redirect_log', 1 );
35
  $i4t3_to = self::transfer( '', 'redirect_to', 'link' );
36
  $i4t3_page = self::transfer( '', 'redirect_page', '' );
37
+ $i4t3_notify = self::transfer( '', 'email_notify', 0 );
38
  $i4t3_notify_email = self::transfer( '', 'email_notify_address', get_option( 'admin_email' ) );
39
+ $i4t3_exclude = self::transfer( '', 'exclude_paths', '' );
40
 
41
  // New general settings array to be added
42
  $i4t3GnrlOptions = array(
46
  'redirect_to' => $i4t3_to,
47
  'redirect_page' => $i4t3_page,
48
  'email_notify' => $i4t3_notify,
49
+ 'email_notify_address' => $i4t3_notify_email,
50
+ 'exclude_paths' => $i4t3_exclude
51
  );
52
 
53
  /**
includes/class-404-to-301.php CHANGED
@@ -67,7 +67,7 @@ class _404_To_301 {
67
  public function __construct() {
68
 
69
  $this->plugin_name = '404-to-301';
70
- $this->version = '2.0.7';
71
  $this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
72
  $this->load_dependencies();
73
  $this->set_locale();
67
  public function __construct() {
68
 
69
  $this->plugin_name = '404-to-301';
70
+ $this->version = '2.0.8';
71
  $this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
72
  $this->load_dependencies();
73
  $this->set_locale();
public/class-404-to-301-public.php CHANGED
@@ -114,13 +114,15 @@ class _404_To_301_Public {
114
  public function i4t3_redirect_404() {
115
 
116
  // Check if 404 page and not admin side
117
- if ( is_404() && !is_admin() ) {
118
 
119
  // Get the settings options
120
- $logging_status = ( $this->gnrl_options['redirect_log'] ) ? $this->gnrl_options['redirect_log'] : 1;
 
121
  $redirect_type = ( $this->gnrl_options['redirect_type'] ) ? $this->gnrl_options['redirect_type'] : '301';
122
  // Get the email notification settings
123
- $is_email_send = ( !empty( $this->gnrl_options['email_notify'] ) ) ? true : false;
 
124
  // Get error details if emailnotification or log is enabled
125
  if( $logging_status == 1 || $is_email_send ) {
126
 
@@ -213,13 +215,13 @@ class _404_To_301_Public {
213
  public function i4t3_is_bot() {
214
 
215
  $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
216
- "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
217
- "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
218
- "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
219
- "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
220
- "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
221
- "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
222
- "Butterfly","Twitturls","Me.dium","Twiceler");
223
 
224
  foreach($botlist as $bot){
225
  if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
@@ -228,5 +230,27 @@ class _404_To_301_Public {
228
 
229
  return false; // Not a bot
230
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  }
114
  public function i4t3_redirect_404() {
115
 
116
  // Check if 404 page and not admin side
117
+ if ( is_404() && !is_admin() && !$this->i4t3_excluded_paths() ) {
118
 
119
  // Get the settings options
120
+ $logging_status = ( !empty( $this->gnrl_options['redirect_log'] ) ) ? $this->gnrl_options['redirect_log'] : 0;
121
+
122
  $redirect_type = ( $this->gnrl_options['redirect_type'] ) ? $this->gnrl_options['redirect_type'] : '301';
123
  // Get the email notification settings
124
+ $is_email_send = ( !empty( $this->gnrl_options['email_notify'] ) && $this->gnrl_options['email_notify'] == 1 ) ? true : false;
125
+
126
  // Get error details if emailnotification or log is enabled
127
  if( $logging_status == 1 || $is_email_send ) {
128
 
215
  public function i4t3_is_bot() {
216
 
217
  $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
218
+ "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
219
+ "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
220
+ "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
221
+ "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
222
+ "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
223
+ "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
224
+ "Butterfly","Twitturls","Me.dium","Twiceler");
225
 
226
  foreach($botlist as $bot){
227
  if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
230
 
231
  return false; // Not a bot
232
  }
233
+
234
+
235
+ /**
236
+ * Exclude specific uri strings/paths from errors
237
+ *
238
+ * @retun True if requested uri matches specified one
239
+ * @since 2.0.8
240
+ * @author Joel James
241
+ */
242
+ public function i4t3_excluded_paths() {
243
+
244
+ // Add links to be excluded in this array.
245
+ $links_string = $this->gnrl_options['exclude_paths'];
246
+ $links = explode( "\n", $links_string );
247
+ if( !empty( $links ) ) {
248
+ foreach( $links as $link ){
249
+ if( strpos($_SERVER['REQUEST_URI'], trim($link) )!== false )
250
+ return true;
251
+ }
252
+ }
253
+ return false;
254
+ }
255
 
256
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
5
  Requires at least: 3.0
6
  Tested up to: 4.3.1
7
- Stable tag: 2.0.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -28,6 +28,7 @@ You will not see any 404 error reports in your webmaster tool dashboard.
28
  > - No more 404 errors in your website. Seriously!<br />
29
  > - **Translation ready!**<br />
30
  > - You can optionally monitor/log all errors.<br />
 
31
  > - You can optionally enable email notification on all 404 errors.<br />
32
  > - You can choose which redirect method to be used (301,302,307).<br />
33
  > - Will not irritate your visitors if they land on a non-existing page/url.<br />
@@ -111,32 +112,45 @@ Bug reports for 404 to 301 are always welcome. [Report here](http://iscode.co/bu
111
 
112
  == Changelog ==
113
 
114
- = 2.0.7 (25/09/2015) =
 
 
 
 
 
115
 
 
 
 
 
116
  **New Feature**
 
117
  - New option to change error notification email address.
118
  - Now **100% Translation ready**.
119
 
120
  **Improvements**
 
121
  - Minor code improvements.
122
 
123
  = 2.0.6 (13/09/2015) =
124
-
125
  **Improvements**
 
126
  - Introduced new website for the plugin.
127
  - Fixed few dead link issues
128
 
129
  = 2.0.5 (03/09/2015) =
130
-
131
  **Improvements**
 
132
  - Added option to avoid search engine crawlers/bots from logging errors.
133
 
134
  **Bug Fixes**
 
135
  - Fixed error log per page issue.
136
 
137
  = 2.0.4 (26/08/2015) =
138
 
139
  **Bug Fixes**
 
140
  - Fixed an issue where error log table is not being created.
141
 
142
  = 2.0.3 (21/08/2015) =
@@ -196,6 +210,4 @@ Bug reports for 404 to 301 are always welcome. [Report here](http://iscode.co/bu
196
  == Upgrade Notice ==
197
 
198
  = 2.0.7 =
199
- **Improvements**
200
- - New option to change error notification email address.
201
- - Now **100% Translation ready**.
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
5
  Requires at least: 3.0
6
  Tested up to: 4.3.1
7
+ Stable tag: 2.0.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
28
  > - No more 404 errors in your website. Seriously!<br />
29
  > - **Translation ready!**<br />
30
  > - You can optionally monitor/log all errors.<br />
31
+ > - Exclude paths from errors.<br />
32
  > - You can optionally enable email notification on all 404 errors.<br />
33
  > - You can choose which redirect method to be used (301,302,307).<br />
34
  > - Will not irritate your visitors if they land on a non-existing page/url.<br />
112
 
113
  == Changelog ==
114
 
115
+ = 2.0.8 (28/10/2015) =
116
+ **New Feature**
117
+
118
+ - New option to exclude paths from error logs and redirect - [See details](https://iscode.co/docs/excluding-paths-from-error-logs-and-redirects/).
119
+
120
+ **Bug Fixes**
121
 
122
+ - Fixed issue - Email notifications are being sent even after disabling it.
123
+ - Fixed issue - Settings reset after reactivation of plugin.
124
+
125
+ = 2.0.7 (25/09/2015) =
126
  **New Feature**
127
+
128
  - New option to change error notification email address.
129
  - Now **100% Translation ready**.
130
 
131
  **Improvements**
132
+
133
  - Minor code improvements.
134
 
135
  = 2.0.6 (13/09/2015) =
 
136
  **Improvements**
137
+
138
  - Introduced new website for the plugin.
139
  - Fixed few dead link issues
140
 
141
  = 2.0.5 (03/09/2015) =
 
142
  **Improvements**
143
+
144
  - Added option to avoid search engine crawlers/bots from logging errors.
145
 
146
  **Bug Fixes**
147
+
148
  - Fixed error log per page issue.
149
 
150
  = 2.0.4 (26/08/2015) =
151
 
152
  **Bug Fixes**
153
+
154
  - Fixed an issue where error log table is not being created.
155
 
156
  = 2.0.3 (21/08/2015) =
210
  == Upgrade Notice ==
211
 
212
  = 2.0.7 =
213
+ - New option to exclude paths from error logs and redirect.
 
 
screenshot-1.png CHANGED
Binary file