Skip to content

Commit c3f3d3a

Browse files
committed
🚀 Release: Releasing 3.1.3
1 parent cfb1a9d commit c3f3d3a

File tree

6 files changed

+51
-49
lines changed

6 files changed

+51
-49
lines changed

404-to-301.php

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: 404 to 301 - Redirect, Log and Notify 404 Errors
44
* Plugin URI: https://duckdev.com/products/404-to-301/
55
* 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.1
6+
* Version: 3.1.3
77
* Author: Joel James
88
* Author URI: https://duckdev.com/
99
* Donate link: https://paypal.me/JoelCJ
@@ -44,7 +44,7 @@
4444
// Define plugin base file.
4545
define( 'JJ4T3_BASE_FILE', __FILE__ );
4646
// Define plugin version.
47-
define( 'JJ4T3_VERSION', '3.1.1' );
47+
define( 'JJ4T3_VERSION', '3.1.3' );
4848
// Define plugin version.
4949
define( 'JJ4T3_DB_VERSION', '11.0' );
5050
// Define plugin log table.

includes/admin/class-jj4t3-admin.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ public function screen_option() {
241241
* Show error listing table view.
242242
*
243243
* 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".
244+
* Registering action hook - "jj4t3_log_list_above_form".
245+
* Registering action hook - "jj4t3_log_list_below_form".
246246
*
247247
* @since 2.1.0
248248
* @access public
@@ -252,7 +252,7 @@ public function screen_option() {
252252
public function error_list() {
253253
?>
254254
<div class="wrap">
255-
<h2><?php _e( '404 Error Logs', '404-to-301' ); ?></h2>
255+
<h2><?php esc_html_e( '404 Error Logs', '404-to-301' ); ?></h2>
256256
<div id="poststuff">
257257
<div id="post-body" class="metabox-holder">
258258
<div id="post-body-content">
@@ -465,7 +465,7 @@ public function review_notice() {
465465
<?php
466466
printf(
467467
__( '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 ),
468+
empty( $current_user->display_name ) ? esc_html__( 'there', '404-to-301' ) : esc_html( ucwords( $current_user->display_name ) ),
469469
'<strong>',
470470
'</strong>'
471471
);
@@ -475,10 +475,10 @@ public function review_notice() {
475475
<a href="https://wordpress.org/support/plugin/404-to-301/reviews/#new-post" target="_blank"><?php esc_html_e( 'Ok, you deserve it', '404-to-301' ); ?></a>
476476
</p>
477477
<p>
478-
<a href="<?php echo add_query_arg( 'jj4t3_rating', 'later' ); // later. ?>"><?php esc_html_e( 'Nope, maybe later', '404-to-301' ); ?></a>
478+
<a href="<?php echo esc_url( add_query_arg( 'jj4t3_rating', 'later' ) ); // later. ?>"><?php esc_html_e( 'Nope, maybe later', '404-to-301' ); ?></a>
479479
</p>
480480
<p>
481-
<a href="<?php echo add_query_arg( 'jj4t3_rating', 'dismiss' ); // dismiss link. ?>"><?php esc_html_e( 'I already did', '404-to-301' ); ?></a>
481+
<a href="<?php echo esc_url( add_query_arg( 'jj4t3_rating', 'dismiss' ) ); // dismiss link. ?>"><?php esc_html_e( 'I already did', '404-to-301' ); ?></a>
482482
</p>
483483
</div>
484484
<?php

includes/admin/class-jj4t3-log-listing.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,21 @@ private function set_groupby() {
261261
// Get group by value from request.
262262
$group_by = jj4t3_from_request( 'group_by_top', '' );
263263

264-
// Verify if the group by value is allowed.
265-
if ( ! in_array( $group_by, $allowed_values, true ) ) {
266-
return;
267-
}
268-
269264
/**
270265
* Filter to alter the log listing groupby param.
271266
*
272267
* Only allowed column names are accepted.
273268
*
274269
* @since 2.0.0
275270
*/
276-
$this->group_by = apply_filters( 'jj4t3_log_list_groupby', $group_by );
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;
277279
}
278280

279281
/**
@@ -720,7 +722,7 @@ public function extra_tablenav( $which ) {
720722
echo '<select name="group_by_top" class="404_group_by">';
721723
echo '<option value="">' . esc_html__( 'Group by', '404-to-301' ) . '</option>';
722724
foreach ( $column_names as $column ) {
723-
echo '<option value="' . $column . '" ' . selected( $column, $this->group_by ) . '>' . esc_attr( $available_columns[ $column ] ) . '</option>';
725+
echo '<option value="' . esc_attr( $column ) . '" ' . selected( $column, $this->group_by ) . '>' . esc_attr( $available_columns[ $column ] ) . '</option>';
724726
}
725727
echo '</select>';
726728
submit_button( __( 'Apply', '404-to-301' ), 'button', 'filter_action', false, array( 'id' => 'post-query' ) );

includes/admin/views/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<tr id="custom_url" class="<?php echo esc_attr( $cl_style ); ?>">
5353
<th><?php esc_html_e( 'Custom URL', '404-to-301' ); ?></th>
5454
<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'] ); ?>">
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'] ); ?>">
5656
<p class="description jj4t3-p-desc"><?php esc_html_e( 'Enter any url (including http://)', '404-to-301' ); ?></p>
5757
</td>
5858
</tr>

includes/index.php

100755100644
File mode changed.

includes/public/class-jj4t3-404-data.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
* 404 page. This class can be extended to access the 404
1111
* page details such as URL, Time, User Agent etc.
1212
*
13+
* @link https://duckdev.com/products/404-to-301/
14+
* @author Joel James <[email protected]>
15+
* @license http://www.gnu.org/licenses/ GNU General Public License
1316
* @category Core
1417
* @package JJ4T3
1518
* @subpackage 404Data
16-
* @author Joel James <[email protected]>
17-
* @license http://www.gnu.org/licenses/ GNU General Public License
18-
* @link https://duckdev.com/products/404-to-301/
1919
*/
2020
class JJ4T3_404_Data {
2121

@@ -66,7 +66,6 @@ class JJ4T3_404_Data {
6666
* @access private
6767
*/
6868
public function init() {
69-
7069
$this->set_ip();
7170
$this->set_ref();
7271
$this->set_ua();
@@ -80,20 +79,19 @@ public function init() {
8079
* Get real IP address of the user.
8180
* http://stackoverflow.com/a/55790/3845839
8281
*
83-
* @param string $ip Default value for IP Address.
84-
*
8582
* @since 2.2.6
8683
* @access private
8784
*
85+
* @param string $ip Default value for IP Address.
86+
*
8887
* @return void
8988
*/
9089
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 ];
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
9795
}
9896
}
9997

@@ -102,47 +100,49 @@ private function set_ip( $ip = '' ) {
102100
*
103101
* @since 3.0.0
104102
*/
105-
$this->ip = apply_filters( 'jj4t3_404_ip', $ip );
103+
$ip = apply_filters( 'jj4t3_404_ip', $ip );
104+
105+
$this->ip = sanitize_text_field( $ip );
106106
}
107107

108108
/**
109109
* Set visitors user agent/browser.
110110
*
111-
* @param string $ua Default value for User Agent.
112-
*
113111
* @since 3.0.0
114112
* @access private
115113
*
114+
* @param string $ua Default value for User Agent.
115+
*
116116
* @return void
117117
*/
118118
private function set_ua( $ua = '' ) {
119-
120119
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
121-
$ua = $_SERVER['HTTP_USER_AGENT'];
120+
$ua = $_SERVER['HTTP_USER_AGENT']; // phpcs:ignore
122121
}
123122

124123
/**
125124
* Filter to alter User Agent.
126125
*
127126
* @since 3.0.0
128127
*/
129-
$this->ua = apply_filters( 'jj4t3_404_ua', $ua );
128+
$ua = apply_filters( 'jj4t3_404_ua', $ua );
129+
130+
$this->ua = sanitize_text_field( $ua );
130131
}
131132

132133
/**
133134
* Set visitors referring link.
134135
*
135-
* @param string $ref Default value for Ref.
136-
*
137136
* @since 3.0.0
138137
* @access private
139138
*
139+
* @param string $ref Default value for Ref.
140+
*
140141
* @return void
141142
*/
142143
private function set_ref( $ref = '' ) {
143-
144144
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
145-
$ref = esc_url( $_SERVER['HTTP_REFERER'] );
145+
$ref = $_SERVER['HTTP_REFERER']; // phpcs:ignore
146146
}
147147

148148
/**
@@ -152,23 +152,24 @@ private function set_ref( $ref = '' ) {
152152
*
153153
* @since 3.0.0
154154
*/
155-
$this->ref = apply_filters( 'jj4t3_404_ref', $ref );
155+
$ref = apply_filters( 'jj4t3_404_ref', $ref );
156+
157+
$this->ref = esc_url_raw( $ref );
156158
}
157159

158160
/**
159161
* Set visitors referring link.
160162
*
161-
* @param string $url Default value for 404 URL.
162-
*
163163
* @since 3.0.0
164164
* @access private
165165
*
166+
* @param string $url Default value for 404 URL.
167+
*
166168
* @return void
167169
*/
168170
private function set_url( $url = '' ) {
169-
170171
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
171-
$url = untrailingslashit( esc_url( $_SERVER['REQUEST_URI'] ) );
172+
$url = $_SERVER['REQUEST_URI']; // phpcs:ignore
172173
}
173174

174175
/**
@@ -178,7 +179,9 @@ private function set_url( $url = '' ) {
178179
*
179180
* @since 3.0.0
180181
*/
181-
$this->url = apply_filters( 'jj4t3_404_url', $url );
182+
$url = apply_filters( 'jj4t3_404_url', $url );
183+
184+
$this->url = untrailingslashit( esc_url_raw( $url ) );
182185
}
183186

184187
/**
@@ -190,11 +193,10 @@ private function set_url( $url = '' ) {
190193
* @return void
191194
*/
192195
private function set_time() {
193-
194196
/**
195197
* Filter to alter current time.
196198
*
197-
* @note If you using this filter, remember to
199+
* @note If you using this filter, remember to
198200
* return proper MySQL time format.
199201
*
200202
* @since 3.0.0
@@ -215,7 +217,6 @@ private function set_time() {
215217
* @return boolean
216218
*/
217219
public function is_excluded() {
218-
219220
$excluded = jj4t3_get_option( 'exclude_paths', '' );
220221

221222
$paths = array();
@@ -229,7 +230,7 @@ public function is_excluded() {
229230
/**
230231
* Filter to alter exclude path values.
231232
*
232-
* @note You should return array if strings .
233+
* @note You should return array if strings .
233234
*
234235
* @since 3.0.0
235236
*/
@@ -249,5 +250,4 @@ public function is_excluded() {
249250

250251
return false;
251252
}
252-
253253
}

0 commit comments

Comments
 (0)