404 to 301 - Version 2.0.2

Version Description

(16/08/2015) = Bug Fixes

  • Fixed an issue with https redirect.
  • Fixed an issue with url preg_match.
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.2

404-to-301.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: 404 to 301
4
  * Plugin URI: http://iscode.co/product/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.1
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
@@ -49,10 +49,10 @@ if(!defined('I4T3_LOGS_PAGE')) {
49
  define( 'I4T3_LOGS_PAGE', admin_url( 'admin.php?page=i4t3-logs' ) );
50
  }
51
  if(!defined('I4T3_DB_VERSION')) {
52
- define( 'I4T3_DB_VERSION', '1.0' );
53
  }
54
  if(!defined('I4T3_VERSION')) {
55
- define( 'I4T3_VERSION', '2.0.0' );
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/product/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.2
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
49
  define( 'I4T3_LOGS_PAGE', admin_url( 'admin.php?page=i4t3-logs' ) );
50
  }
51
  if(!defined('I4T3_DB_VERSION')) {
52
+ define( 'I4T3_DB_VERSION', '2' );
53
  }
54
  if(!defined('I4T3_VERSION')) {
55
+ define( 'I4T3_VERSION', '2.0.2' );
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
@@ -351,17 +351,9 @@ class _404_To_301_Logs extends WP_List_Table_404 {
351
  wp_die( 'Nope! Security check failed!' );
352
 
353
  $action = $this->current_action();
354
-
355
- switch ( $action ) {
356
-
357
- case 'clear':
358
- $this->clear_404_logs();
359
- break;
360
-
361
- default:
362
- return;
363
- break;
364
- }
365
  }
366
 
367
  }
@@ -383,7 +375,10 @@ class _404_To_301_Logs extends WP_List_Table_404 {
383
  // Let us hide sql query errors if any
384
  $wpdb->hide_errors();
385
  $total = $wpdb->query( "DELETE FROM $this->table" );
386
- return ( $total > 0 ) ? true : false;
 
 
 
387
  }
388
 
389
  }
351
  wp_die( 'Nope! Security check failed!' );
352
 
353
  $action = $this->current_action();
354
+ if( $action == 'clear' ) {
355
+ $this->clear_404_logs();
356
+ }
 
 
 
 
 
 
 
 
357
  }
358
 
359
  }
375
  // Let us hide sql query errors if any
376
  $wpdb->hide_errors();
377
  $total = $wpdb->query( "DELETE FROM $this->table" );
378
+ if ( $total > 0 ) {
379
+ wp_redirect(admin_url('admin.php?page=i4t3-logs'));
380
+ exit();
381
+ }
382
  }
383
 
384
  }
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.1';
71
  $this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
72
  $this->load_dependencies();
73
  $this->define_admin_hooks();
67
  public function __construct() {
68
 
69
  $this->plugin_name = '404-to-301';
70
+ $this->version = '2.0.2';
71
  $this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
72
  $this->load_dependencies();
73
  $this->define_admin_hooks();
public/class-404-to-301-public.php CHANGED
@@ -69,6 +69,10 @@ class _404_To_301_Public {
69
 
70
  // Filter to change the email address used for admin notifications
71
  $admin_email = apply_filters( 'i4t3_notify_admin_email_address', get_option( 'admin_email' ) );
 
 
 
 
72
  // Get the site name
73
  $site_name = get_bloginfo( 'name' );
74
 
@@ -90,9 +94,6 @@ class _404_To_301_Public {
90
  $message .= '</tr>';
91
  $message .= '</table>';
92
 
93
- // Action hook that will be performed before sending 404 error mail
94
- do_action( 'i4t3_before_404_log_mail', $message );
95
-
96
  $is_sent = wp_mail(
97
  $admin_email,
98
  __( 'Snap! One more 404 on ', '404-to-301' ) . $site_name,
@@ -180,7 +181,7 @@ class _404_To_301_Public {
180
  // Redirect to a custom link given by user
181
  case 'link':
182
  $naked_url = $this->gnrl_options['redirect_link'];
183
- $url = 'http://' . preg_replace( '~^http://~', '', $naked_url );
184
  break;
185
  // If nothing, be chill and do nothing!
186
  default:
@@ -190,12 +191,13 @@ class _404_To_301_Public {
190
  // Perform the redirect if $url is set
191
  if (!empty($url)) {
192
  // Action hook that will be performed before 404 redirect starts
 
193
  do_action( 'i4t3_before_404_redirect' );
194
  wp_redirect( $url, $redirect_type );
195
  exit(); // exit, because WordPress will not exit automatically
196
  }
197
  // Action hook that will be performed after 404 redirect
198
- do_action( 'i4t3_no_redirect_action' );
199
  }
200
  }
201
 
69
 
70
  // Filter to change the email address used for admin notifications
71
  $admin_email = apply_filters( 'i4t3_notify_admin_email_address', get_option( 'admin_email' ) );
72
+
73
+ // Action hook that will be performed before sending 404 error mail
74
+ do_action( 'i4t3_before_404_email_log', $log_data );
75
+
76
  // Get the site name
77
  $site_name = get_bloginfo( 'name' );
78
 
94
  $message .= '</tr>';
95
  $message .= '</table>';
96
 
 
 
 
97
  $is_sent = wp_mail(
98
  $admin_email,
99
  __( 'Snap! One more 404 on ', '404-to-301' ) . $site_name,
181
  // Redirect to a custom link given by user
182
  case 'link':
183
  $naked_url = $this->gnrl_options['redirect_link'];
184
+ $url = (!preg_match("~^(?:f|ht)tps?://~i", $naked_url)) ? "http://" . $naked_url : $naked_url;
185
  break;
186
  // If nothing, be chill and do nothing!
187
  default:
191
  // Perform the redirect if $url is set
192
  if (!empty($url)) {
193
  // Action hook that will be performed before 404 redirect starts
194
+ //echo $url; exit();
195
  do_action( 'i4t3_before_404_redirect' );
196
  wp_redirect( $url, $redirect_type );
197
  exit(); // exit, because WordPress will not exit automatically
198
  }
199
  // Action hook that will be performed after 404 redirect
200
+ do_action( 'i4t3_after_404_redirect' );
201
  }
202
  }
203
 
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.2.4
7
- Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -110,6 +110,12 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://iscode.co/s
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
113
  = 2.0.1 (29/07/2015) =
114
  **New Feature**
115
 
@@ -154,5 +160,5 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://iscode.co/s
154
 
155
  == Upgrade Notice ==
156
 
157
- = 2.0.1 =
158
- * Upgraded the plugin core code.
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.2.4
7
+ Stable tag: 2.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
 
111
  == Changelog ==
112
 
113
+ = 2.0.2 (16/08/2015) =
114
+ **Bug Fixes**
115
+
116
+ - Fixed an issue with https redirect.
117
+ - Fixed an issue with url preg_match.
118
+
119
  = 2.0.1 (29/07/2015) =
120
  **New Feature**
121
 
160
 
161
  == Upgrade Notice ==
162
 
163
+ = 2.0.2 =
164
+ * Fixed issues with https.