404 to 301 - Version 3.1.3

Version Description

(17/06/2022) = ** Improvements**

  • Security checks and improvements.
Download this release

Release Info

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

Code changes from version 3.1.2 to 3.1.3

404-to-301.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: 404 to 301 - Redirect, Log and Notify 404 Errors
4
  * Plugin URI: https://duckdev.com/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: 3.1.2
7
  * Author: Joel James
8
  * Author URI: https://duckdev.com/
9
  * Donate link: https://paypal.me/JoelCJ
@@ -44,7 +44,7 @@ define( 'JJ4T3_URL', plugin_dir_url( __FILE__ ) );
44
  // Define plugin base file.
45
  define( 'JJ4T3_BASE_FILE', __FILE__ );
46
  // Define plugin version.
47
- define( 'JJ4T3_VERSION', '3.1.2' );
48
  // Define plugin version.
49
  define( 'JJ4T3_DB_VERSION', '11.0' );
50
  // Define plugin log table.
3
  * Plugin Name: 404 to 301 - Redirect, Log and Notify 404 Errors
4
  * Plugin URI: https://duckdev.com/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: 3.1.3
7
  * Author: Joel James
8
  * Author URI: https://duckdev.com/
9
  * Donate link: https://paypal.me/JoelCJ
44
  // Define plugin base file.
45
  define( 'JJ4T3_BASE_FILE', __FILE__ );
46
  // Define plugin version.
47
+ define( 'JJ4T3_VERSION', '3.1.3' );
48
  // Define plugin version.
49
  define( 'JJ4T3_DB_VERSION', '11.0' );
50
  // Define plugin log table.
includes/admin/class-jj4t3-admin.php CHANGED
@@ -241,8 +241,8 @@ class JJ4T3_Admin {
241
  * Show error listing table view.
242
  *
243
  * This method displays the listing table HTML to the page.
244
- * Regitsering action hook - "jj4t3_log_list_above_form".
245
- * Regitsering action hook - "jj4t3_log_list_below_form".
246
  *
247
  * @since 2.1.0
248
  * @access public
@@ -252,7 +252,7 @@ class JJ4T3_Admin {
252
  public function error_list() {
253
  ?>
254
  <div class="wrap">
255
- <h2><?php _e( '404 Error Logs', '404-to-301' ); ?></h2>
256
  <div id="poststuff">
257
  <div id="post-body" class="metabox-holder">
258
  <div id="post-body-content">
@@ -465,7 +465,7 @@ class JJ4T3_Admin {
465
  <?php
466
  printf(
467
  __( 'Hey %1$s, I noticed you\'ve been using %2$s404 to 301%3$s for more than 1 week – that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.', '404-to-301' ),
468
- empty( $current_user->display_name ) ? __( 'there', '404-to-301' ) : ucwords( $current_user->display_name ),
469
  '<strong>',
470
  '</strong>'
471
  );
241
  * Show error listing table view.
242
  *
243
  * This method displays the listing table HTML to the page.
244
+ * Registering action hook - "jj4t3_log_list_above_form".
245
+ * Registering action hook - "jj4t3_log_list_below_form".
246
  *
247
  * @since 2.1.0
248
  * @access public
252
  public function error_list() {
253
  ?>
254
  <div class="wrap">
255
+ <h2><?php esc_html_e( '404 Error Logs', '404-to-301' ); ?></h2>
256
  <div id="poststuff">
257
  <div id="post-body" class="metabox-holder">
258
  <div id="post-body-content">
465
  <?php
466
  printf(
467
  __( 'Hey %1$s, I noticed you\'ve been using %2$s404 to 301%3$s for more than 1 week – that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.', '404-to-301' ),
468
+ empty( $current_user->display_name ) ? esc_html__( 'there', '404-to-301' ) : esc_html( ucwords( $current_user->display_name ) ),
469
  '<strong>',
470
  '</strong>'
471
  );
includes/admin/class-jj4t3-log-listing.php CHANGED
@@ -261,11 +261,6 @@ class JJ4T3_Log_Listing extends WP_List_Table {
261
  // Get group by value from request.
262
  $group_by = jj4t3_from_request( 'group_by_top', '' );
263
 
264
- // Verify if the group by value is allowed.
265
- if ( ! in_array( $group_by, $allowed_values, true ) ) {
266
- return;
267
- }
268
-
269
  /**
270
  * Filter to alter the log listing groupby param.
271
  *
@@ -273,7 +268,14 @@ class JJ4T3_Log_Listing extends WP_List_Table {
273
  *
274
  * @since 2.0.0
275
  */
276
- $this->group_by = apply_filters( 'jj4t3_log_list_groupby', $group_by );
 
 
 
 
 
 
 
277
  }
278
 
279
  /**
@@ -720,7 +722,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
720
  echo '<select name="group_by_top" class="404_group_by">';
721
  echo '<option value="">' . esc_html__( 'Group by', '404-to-301' ) . '</option>';
722
  foreach ( $column_names as $column ) {
723
- echo '<option value="' . $column . '" ' . selected( $column, $this->group_by ) . '>' . esc_attr( $available_columns[ $column ] ) . '</option>';
724
  }
725
  echo '</select>';
726
  submit_button( __( 'Apply', '404-to-301' ), 'button', 'filter_action', false, array( 'id' => 'post-query' ) );
261
  // Get group by value from request.
262
  $group_by = jj4t3_from_request( 'group_by_top', '' );
263
 
 
 
 
 
 
264
  /**
265
  * Filter to alter the log listing groupby param.
266
  *
268
  *
269
  * @since 2.0.0
270
  */
271
+ $group_by = apply_filters( 'jj4t3_log_list_groupby', $group_by );
272
+
273
+ // Verify if the group by value is allowed.
274
+ if ( ! in_array( $group_by, $allowed_values, true ) ) {
275
+ return;
276
+ }
277
+
278
+ $this->group_by = $group_by;
279
  }
280
 
281
  /**
722
  echo '<select name="group_by_top" class="404_group_by">';
723
  echo '<option value="">' . esc_html__( 'Group by', '404-to-301' ) . '</option>';
724
  foreach ( $column_names as $column ) {
725
+ echo '<option value="' . esc_attr( $column ) . '" ' . selected( $column, $this->group_by ) . '>' . esc_attr( $available_columns[ $column ] ) . '</option>';
726
  }
727
  echo '</select>';
728
  submit_button( __( 'Apply', '404-to-301' ), 'button', 'filter_action', false, array( 'id' => 'post-query' ) );
includes/admin/views/settings.php CHANGED
@@ -52,7 +52,7 @@ defined( 'ABSPATH' ) || exit;
52
  <tr id="custom_url" class="<?php echo esc_attr( $cl_style ); ?>">
53
  <th><?php esc_html_e( 'Custom URL', '404-to-301' ); ?></th>
54
  <td>
55
- <input type="url" size="40" placeholder="<?php echo home_url(); ?>" name="i4t3_gnrl_options[redirect_link]" value="<?php echo esc_url( $options['redirect_link'] ); ?>">
56
  <p class="description jj4t3-p-desc"><?php esc_html_e( 'Enter any url (including http://)', '404-to-301' ); ?></p>
57
  </td>
58
  </tr>
52
  <tr id="custom_url" class="<?php echo esc_attr( $cl_style ); ?>">
53
  <th><?php esc_html_e( 'Custom URL', '404-to-301' ); ?></th>
54
  <td>
55
+ <input type="url" size="40" placeholder="<?php echo esc_url( home_url() ); ?>" name="i4t3_gnrl_options[redirect_link]" value="<?php echo esc_url( $options['redirect_link'] ); ?>">
56
  <p class="description jj4t3-p-desc"><?php esc_html_e( 'Enter any url (including http://)', '404-to-301' ); ?></p>
57
  </td>
58
  </tr>
includes/public/class-jj4t3-404-data.php CHANGED
@@ -10,12 +10,12 @@ defined( 'ABSPATH' ) or exit;
10
  * 404 page. This class can be extended to access the 404
11
  * page details such as URL, Time, User Agent etc.
12
  *
 
 
 
13
  * @category Core
14
  * @package JJ4T3
15
  * @subpackage 404Data
16
- * @author Joel James <mail@cjoel.com>
17
- * @license http://www.gnu.org/licenses/ GNU General Public License
18
- * @link https://duckdev.com/products/404-to-301/
19
  */
20
  class JJ4T3_404_Data {
21
 
@@ -66,7 +66,6 @@ class JJ4T3_404_Data {
66
  * @access private
67
  */
68
  public function init() {
69
-
70
  $this->set_ip();
71
  $this->set_ref();
72
  $this->set_ua();
@@ -80,20 +79,19 @@ class JJ4T3_404_Data {
80
  * Get real IP address of the user.
81
  * http://stackoverflow.com/a/55790/3845839
82
  *
83
- * @param string $ip Default value for IP Address.
84
- *
85
  * @since 2.2.6
86
  * @access private
87
  *
 
 
88
  * @return void
89
  */
90
  private function set_ip( $ip = '' ) {
91
-
92
- // IP varibals in priority oder.
93
- $ips = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' );
94
- foreach ( $ips as $ip ) {
95
- if ( isset( $_SERVER[ $ip ] ) ) {
96
- $ip = $_SERVER[ $ip ];
97
  }
98
  }
99
 
@@ -102,23 +100,24 @@ class JJ4T3_404_Data {
102
  *
103
  * @since 3.0.0
104
  */
105
- $this->ip = apply_filters( 'jj4t3_404_ip', $ip );
 
 
106
  }
107
 
108
  /**
109
  * Set visitors user agent/browser.
110
  *
111
- * @param string $ua Default value for User Agent.
112
- *
113
  * @since 3.0.0
114
  * @access private
115
  *
 
 
116
  * @return void
117
  */
118
  private function set_ua( $ua = '' ) {
119
-
120
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
121
- $ua = $_SERVER['HTTP_USER_AGENT'];
122
  }
123
 
124
  /**
@@ -126,23 +125,24 @@ class JJ4T3_404_Data {
126
  *
127
  * @since 3.0.0
128
  */
129
- $this->ua = apply_filters( 'jj4t3_404_ua', $ua );
 
 
130
  }
131
 
132
  /**
133
  * Set visitors referring link.
134
  *
135
- * @param string $ref Default value for Ref.
136
- *
137
  * @since 3.0.0
138
  * @access private
139
  *
 
 
140
  * @return void
141
  */
142
  private function set_ref( $ref = '' ) {
143
-
144
  if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
145
- $ref = esc_url( $_SERVER['HTTP_REFERER'] );
146
  }
147
 
148
  /**
@@ -152,23 +152,24 @@ class JJ4T3_404_Data {
152
  *
153
  * @since 3.0.0
154
  */
155
- $this->ref = apply_filters( 'jj4t3_404_ref', $ref );
 
 
156
  }
157
 
158
  /**
159
  * Set visitors referring link.
160
  *
161
- * @param string $url Default value for 404 URL.
162
- *
163
  * @since 3.0.0
164
  * @access private
165
  *
 
 
166
  * @return void
167
  */
168
  private function set_url( $url = '' ) {
169
-
170
  if ( isset( $_SERVER['REQUEST_URI'] ) ) {
171
- $url = untrailingslashit( esc_url( $_SERVER['REQUEST_URI'] ) );
172
  }
173
 
174
  /**
@@ -178,7 +179,9 @@ class JJ4T3_404_Data {
178
  *
179
  * @since 3.0.0
180
  */
181
- $this->url = apply_filters( 'jj4t3_404_url', $url );
 
 
182
  }
183
 
184
  /**
@@ -190,11 +193,10 @@ class JJ4T3_404_Data {
190
  * @return void
191
  */
192
  private function set_time() {
193
-
194
  /**
195
  * Filter to alter current time.
196
  *
197
- * @note If you using this filter, remember to
198
  * return proper MySQL time format.
199
  *
200
  * @since 3.0.0
@@ -215,7 +217,6 @@ class JJ4T3_404_Data {
215
  * @return boolean
216
  */
217
  public function is_excluded() {
218
-
219
  $excluded = jj4t3_get_option( 'exclude_paths', '' );
220
 
221
  $paths = array();
@@ -229,7 +230,7 @@ class JJ4T3_404_Data {
229
  /**
230
  * Filter to alter exclude path values.
231
  *
232
- * @note You should return array if strings .
233
  *
234
  * @since 3.0.0
235
  */
@@ -249,5 +250,4 @@ class JJ4T3_404_Data {
249
 
250
  return false;
251
  }
252
-
253
  }
10
  * 404 page. This class can be extended to access the 404
11
  * page details such as URL, Time, User Agent etc.
12
  *
13
+ * @link https://duckdev.com/products/404-to-301/
14
+ * @author Joel James <mail@cjoel.com>
15
+ * @license http://www.gnu.org/licenses/ GNU General Public License
16
  * @category Core
17
  * @package JJ4T3
18
  * @subpackage 404Data
 
 
 
19
  */
20
  class JJ4T3_404_Data {
21
 
66
  * @access private
67
  */
68
  public function init() {
 
69
  $this->set_ip();
70
  $this->set_ref();
71
  $this->set_ua();
79
  * Get real IP address of the user.
80
  * http://stackoverflow.com/a/55790/3845839
81
  *
 
 
82
  * @since 2.2.6
83
  * @access private
84
  *
85
+ * @param string $ip Default value for IP Address.
86
+ *
87
  * @return void
88
  */
89
  private function set_ip( $ip = '' ) {
90
+ // IP variables in priority oder.
91
+ $headers = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' );
92
+ foreach ( $headers as $header ) {
93
+ if ( isset( $_SERVER[ $header ] ) ) {
94
+ $ip = $_SERVER[ $header ]; // phpcs:ignore
 
95
  }
96
  }
97
 
100
  *
101
  * @since 3.0.0
102
  */
103
+ $ip = apply_filters( 'jj4t3_404_ip', $ip );
104
+
105
+ $this->ip = sanitize_text_field( $ip );
106
  }
107
 
108
  /**
109
  * Set visitors user agent/browser.
110
  *
 
 
111
  * @since 3.0.0
112
  * @access private
113
  *
114
+ * @param string $ua Default value for User Agent.
115
+ *
116
  * @return void
117
  */
118
  private function set_ua( $ua = '' ) {
 
119
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
120
+ $ua = $_SERVER['HTTP_USER_AGENT']; // phpcs:ignore
121
  }
122
 
123
  /**
125
  *
126
  * @since 3.0.0
127
  */
128
+ $ua = apply_filters( 'jj4t3_404_ua', $ua );
129
+
130
+ $this->ua = sanitize_text_field( $ua );
131
  }
132
 
133
  /**
134
  * Set visitors referring link.
135
  *
 
 
136
  * @since 3.0.0
137
  * @access private
138
  *
139
+ * @param string $ref Default value for Ref.
140
+ *
141
  * @return void
142
  */
143
  private function set_ref( $ref = '' ) {
 
144
  if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
145
+ $ref = $_SERVER['HTTP_REFERER']; // phpcs:ignore
146
  }
147
 
148
  /**
152
  *
153
  * @since 3.0.0
154
  */
155
+ $ref = apply_filters( 'jj4t3_404_ref', $ref );
156
+
157
+ $this->ref = esc_url_raw( $ref );
158
  }
159
 
160
  /**
161
  * Set visitors referring link.
162
  *
 
 
163
  * @since 3.0.0
164
  * @access private
165
  *
166
+ * @param string $url Default value for 404 URL.
167
+ *
168
  * @return void
169
  */
170
  private function set_url( $url = '' ) {
 
171
  if ( isset( $_SERVER['REQUEST_URI'] ) ) {
172
+ $url = $_SERVER['REQUEST_URI']; // phpcs:ignore
173
  }
174
 
175
  /**
179
  *
180
  * @since 3.0.0
181
  */
182
+ $url = apply_filters( 'jj4t3_404_url', $url );
183
+
184
+ $this->url = untrailingslashit( esc_url_raw( $url ) );
185
  }
186
 
187
  /**
193
  * @return void
194
  */
195
  private function set_time() {
 
196
  /**
197
  * Filter to alter current time.
198
  *
199
+ * @note If you using this filter, remember to
200
  * return proper MySQL time format.
201
  *
202
  * @since 3.0.0
217
  * @return boolean
218
  */
219
  public function is_excluded() {
 
220
  $excluded = jj4t3_get_option( 'exclude_paths', '' );
221
 
222
  $paths = array();
230
  /**
231
  * Filter to alter exclude path values.
232
  *
233
+ * @note You should return array if strings .
234
  *
235
  * @since 3.0.0
236
  */
250
 
251
  return false;
252
  }
 
253
  }
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.me/JoelCJ
5
  Requires at least: 3.5
6
  Tested up to: 6.0
7
- Stable tag: 3.1.2
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -128,6 +128,11 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com
128
 
129
  == Changelog ==
130
 
 
 
 
 
 
131
  = 3.1.2 (07/06/2022) =
132
  **👌 Improvements**
133
 
@@ -455,7 +460,7 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com
455
 
456
  == Upgrade Notice ==
457
 
458
- = 3.1.2 (07/06/2022) =
459
  **👌 Improvements**
460
 
461
  * Security checks and improvements.
4
  Donate link: https://www.paypal.me/JoelCJ
5
  Requires at least: 3.5
6
  Tested up to: 6.0
7
+ Stable tag: 3.1.3
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
128
 
129
  == Changelog ==
130
 
131
+ = 3.1.3 (17/06/2022) =
132
+ **👌 Improvements**
133
+
134
+ * Security checks and improvements.
135
+
136
  = 3.1.2 (07/06/2022) =
137
  **👌 Improvements**
138
 
460
 
461
  == Upgrade Notice ==
462
 
463
+ = 3.1.3 (17/06/2022) =
464
  **👌 Improvements**
465
 
466
  * Security checks and improvements.