404 to 301 - Version 3.1.0

Version Description

(18/10/2021) = ** Improvements**

  • Tested with WP 5.8.
  • Added sanitization.
Download this release

Release Info

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

Code changes from version 3.0.9 to 3.1.0

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.0.9
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.0.9' );
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.0
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.0' );
48
  // Define plugin version.
49
  define( 'JJ4T3_DB_VERSION', '11.0' );
50
  // Define plugin log table.
includes/admin/class-jj4t3-log-listing.php CHANGED
@@ -15,21 +15,21 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
15
  * This class defines all the methods to output the error logs display table using
16
  * WordPress listing table class.
17
  *
18
- * @category Core
19
- * @package JJ4T3
20
- * @subpackage ErrorLogListing
21
  * @author Joel James <mail@cjoel.com>
22
  * @license http://www.gnu.org/licenses/ GNU General Public License
 
23
  * @link https://duckdev.com/products/404-to-301/
 
 
24
  */
25
  class JJ4T3_Log_Listing extends WP_List_Table {
26
 
27
  /**
28
  * Group by column name.
29
  *
 
30
  * @since 3.0.0
31
  * @access private
32
- * @var string
33
  */
34
  private $group_by = '';
35
 
@@ -44,8 +44,8 @@ class JJ4T3_Log_Listing extends WP_List_Table {
44
  parent::__construct(
45
  array(
46
  'singular' => __( '404 Error Log', '404-to-301' ),
47
- 'plural' => __( '404 Error Logs', '404-to-301' ),
48
- 'ajax' => false,
49
  )
50
  );
51
  }
@@ -61,9 +61,9 @@ class JJ4T3_Log_Listing extends WP_List_Table {
61
  * $this->items - Push our custom log data to the listing table.
62
  * Registering filter - "jj4t3_logs_list_per_page".
63
  *
64
- * @global object $wpdb WP DB object
65
  * @since 2.0.0
66
  * @access public
 
67
  */
68
  public function prepare_items() {
69
 
@@ -98,7 +98,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
98
  $this->set_pagination_args(
99
  array(
100
  'total_items' => $total_items,
101
- 'per_page' => $per_page,
102
  )
103
  );
104
 
@@ -113,13 +113,13 @@ class JJ4T3_Log_Listing extends WP_List_Table {
113
  * Apply all filtering, sorting and paginations.
114
  * Registering filter - "jj4t3_logs_list_result".
115
  *
116
- * @param int $per_page Logs per page.
117
- * @param int $page_number Current page number.
118
  *
119
- * @global object $wpdb WP DB object
120
  * @since 3.0.0
121
  * @access public
122
  *
 
123
  * @return array
124
  */
125
  private function get_error_logs( $per_page = 20, $page_number = 1 ) {
@@ -284,10 +284,10 @@ class JJ4T3_Log_Listing extends WP_List_Table {
284
  * listing, we need to get count of total items for proper pagination.
285
  * Registering filter - "jj4t3_log_list_count".
286
  *
287
- * @global object $wpdb WP DB object
288
  * @since 2.0.3
289
  * @access private
290
  *
 
291
  * @return int Total count.
292
  */
293
  private function total_logs() {
@@ -324,13 +324,13 @@ class JJ4T3_Log_Listing extends WP_List_Table {
324
  public function get_columns() {
325
 
326
  $columns = array(
327
- 'cb' => '<input type="checkbox" style="width: 5%;" />',
328
- 'date' => __( 'Date', '404-to-301' ),
329
- 'url' => __( '404 Path', '404-to-301' ),
330
- 'ref' => __( 'From', '404-to-301' ),
331
- 'ip' => __( 'IP Address', '404-to-301' ),
332
- 'ua' => __( 'User Agent', '404-to-301' ),
333
- 'redirect' => __( 'Customization', '404-to-301' )
334
  );
335
 
336
  /**
@@ -360,15 +360,15 @@ class JJ4T3_Log_Listing extends WP_List_Table {
360
 
361
  $columns = array(
362
  'date' => array( 'date', true ),
363
- 'url' => array( 'url', false ),
364
- 'ref' => array( 'ref', false ),
365
- 'ip' => array( 'ip', false )
366
  );
367
 
368
  /**
369
  * Filter hook to change column titles.
370
  *
371
- * @note DO NOT add extra columns.
372
  *
373
  * @since 3.0.0
374
  */
@@ -404,7 +404,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
404
  * for switch, printing the whole array.
405
  * Registering filter - "jj4t3_log_list_column_default".
406
  *
407
- * @param array $item Column data
408
  * @param string $column_name Column name
409
  *
410
  * @since 2.0.0
@@ -419,7 +419,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
419
  /**
420
  * Filter hook to change column names.
421
  *
422
- * @note DO NOT add extra columns.
423
  *
424
  * @since 3.0.0
425
  */
@@ -693,15 +693,15 @@ class JJ4T3_Log_Listing extends WP_List_Table {
693
  public function get_bulk_actions() {
694
 
695
  $actions = array(
696
- 'bulk_delete' => __( 'Delete Selected', '404-to-301' ),
697
- 'bulk_clean' => __( 'Delete All', '404-to-301' ),
698
  'bulk_delete_all' => __( 'Delete All (Keep redirects)', '404-to-301' ),
699
  );
700
 
701
  /**
702
  * Filter hook to change actions.
703
  *
704
- * @note If you are adding extra actions
705
  * Make sure it's actions are properly added.
706
  *
707
  * @since 3.0.0
@@ -734,7 +734,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
734
  echo '<select name="group_by_top" class="404_group_by">';
735
  echo '<option value="">' . __( 'Group by', '404-to-301' ) . '</option>';
736
  foreach ( $column_names as $column ) {
737
- echo '<option value="' . $column . '" ' . selected( $column, $this->group_by ) . '>' . $available_columns[ $column ] . '</option>';
738
  }
739
  echo '</select>';
740
  submit_button( __( 'Apply', '404-to-301' ), 'button', 'filter_action', false, array( 'id' => 'post-query' ) );
@@ -743,7 +743,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
743
  /**
744
  * Action hook to add extra items in actions area.
745
  *
746
- * @param object $this Class instance.
747
  * @param string $which Current location (top or bottom).
748
  */
749
  do_action( 'jj4t3_log_list_extra_tablenav', $this, $which );
@@ -836,7 +836,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
836
  * the user selection. We are using IF ELSE loop instead of
837
  * switch to easily handle conditions.
838
  *
839
- * @param mixed $ids ID(s) of the log(s).
840
  * @param string $action Current bulk action.
841
  *
842
  * @since 2.0.0
@@ -852,7 +852,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
852
  $query = "DELETE FROM " . JJ4T3_TABLE . " WHERE id = " . absint( $ids );
853
  } elseif ( is_array( $ids ) && 'bulk_delete' === $action ) {
854
  // If multiple selected logs are being deleted.
855
- $ids = implode( ',', array_map( 'absint', $ids ) );
856
  $query = "DELETE FROM " . JJ4T3_TABLE . " WHERE id IN($ids)";
857
  } elseif ( 'bulk_delete_all' === $action ) {
858
  // If deleting all logs except custom redirected ones.
@@ -875,7 +875,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
875
  *
876
  * @param string $status Status.
877
  * @param string $option Option name.
878
- * @param mixed $value Value of the option.
879
  *
880
  * @since 2.1.0
881
  * @access public
@@ -890,10 +890,10 @@ class JJ4T3_Log_Listing extends WP_List_Table {
890
  /**
891
  * Get custom redirect modal content
892
  *
893
- * @global object $wpdb WP DB object
894
  * @since 2.2.0
895
  * @access public
896
  *
 
897
  * @return void
898
  */
899
  public static function open_redirect() {
@@ -911,30 +911,30 @@ class JJ4T3_Log_Listing extends WP_List_Table {
911
  wp_die();
912
  }
913
 
914
- $url_404 = $_POST['url_404'];
915
 
916
  global $wpdb;
917
 
918
  // Get custom redirect value from db, if exist.
919
- $result = $wpdb->get_row( $wpdb->prepare( "SELECT redirect, options FROM " . JJ4T3_TABLE . " WHERE url = %s AND redirect IS NOT NULL LIMIT 0,1", esc_url( $url_404 ) ), 'OBJECT' );
920
 
921
  // Get custom redirect type and url.
922
- $url = empty( $result->redirect ) ? '' : esc_url( $result->redirect );
923
 
924
  // Get custom options.
925
  $options = empty( $result->options ) ? array() : maybe_unserialize( $result->options );
926
 
927
  // Get result in an array.
928
  $data = array(
929
- 'url_404' => esc_url( $url_404 ),
930
- 'url' => esc_url( $url ),
931
  );
932
 
933
  // Set the custom options for the 404.
934
- $data['type'] = empty( $options['type'] ) ? jj4t3_get_option( 'redirect_type' ) : intval( $options['type'] );
935
- $data['redirect'] = isset( $options['redirect'] ) ? intval( $options['redirect'] ) : -1;
936
- $data['log'] = isset( $options['log'] ) ? intval( $options['log'] ) : -1;
937
- $data['alert'] = isset( $options['alert'] ) ? intval( $options['alert'] ) : -1;
938
 
939
  /**
940
  * Filter to alter custom redirect modal response array.
@@ -952,12 +952,12 @@ class JJ4T3_Log_Listing extends WP_List_Table {
952
  * When user set a custom redirect url for a 404 link, save the data
953
  * from modal by updating all error logs of the current 404 links.
954
  *
955
- * @global object $wpdb WP DB object
956
  * @since 2.2.0
957
  * @access public
958
  *
959
- * @note Always die() for wp_ajax
960
  *
 
961
  * @return void
962
  */
963
  public static function save_redirect() {
@@ -973,20 +973,20 @@ class JJ4T3_Log_Listing extends WP_List_Table {
973
  // Custom options for the 404 path.
974
  $options = maybe_serialize(
975
  array(
976
- 'redirect' => jj4t3_from_request( 'jj4t3_custom_redirect_redirect' ),
977
- 'log' => jj4t3_from_request( 'jj4t3_custom_redirect_log' ),
978
- 'alert' => jj4t3_from_request( 'jj4t3_custom_redirect_alert' ),
979
- 'type' => jj4t3_from_request( 'jj4t3_custom_redirect_type' ),
980
  )
981
  );
982
 
983
  // Get 404 url.
984
- $url = jj4t3_from_request( 'jj4t3_custom_redirect', false ) ? esc_url( jj4t3_from_request( 'jj4t3_custom_redirect' ) ) : '';
985
 
986
  global $wpdb;
987
 
988
  // Get custom redirect url.
989
- $url_404 = jj4t3_from_request( 'jj4t3_redirect_404', false ) ? esc_url( jj4t3_from_request( 'jj4t3_redirect_404' ) ) : '';
990
 
991
  /**
992
  * Action hook to run before updating a custom redirect.
@@ -995,7 +995,7 @@ class JJ4T3_Log_Listing extends WP_List_Table {
995
  * after your custom function.
996
  *
997
  * @param string $url_404 404 link.
998
- * @param string $url Link to redirect.
999
  *
1000
  * @since 3.0.0
1001
  */
15
  * This class defines all the methods to output the error logs display table using
16
  * WordPress listing table class.
17
  *
 
 
 
18
  * @author Joel James <mail@cjoel.com>
19
  * @license http://www.gnu.org/licenses/ GNU General Public License
20
+ * @category Core
21
  * @link https://duckdev.com/products/404-to-301/
22
+ * @package JJ4T3
23
+ * @subpackage ErrorLogListing
24
  */
25
  class JJ4T3_Log_Listing extends WP_List_Table {
26
 
27
  /**
28
  * Group by column name.
29
  *
30
+ * @var string
31
  * @since 3.0.0
32
  * @access private
 
33
  */
34
  private $group_by = '';
35
 
44
  parent::__construct(
45
  array(
46
  'singular' => __( '404 Error Log', '404-to-301' ),
47
+ 'plural' => __( '404 Error Logs', '404-to-301' ),
48
+ 'ajax' => false,
49
  )
50
  );
51
  }
61
  * $this->items - Push our custom log data to the listing table.
62
  * Registering filter - "jj4t3_logs_list_per_page".
63
  *
 
64
  * @since 2.0.0
65
  * @access public
66
+ * @global object $wpdb WP DB object
67
  */
68
  public function prepare_items() {
69
 
98
  $this->set_pagination_args(
99
  array(
100
  'total_items' => $total_items,
101
+ 'per_page' => $per_page,
102
  )
103
  );
104
 
113
  * Apply all filtering, sorting and paginations.
114
  * Registering filter - "jj4t3_logs_list_result".
115
  *
116
+ * @param int $per_page Logs per page.
117
+ * @param int $page_number Current page number.
118
  *
 
119
  * @since 3.0.0
120
  * @access public
121
  *
122
+ * @global object $wpdb WP DB object
123
  * @return array
124
  */
125
  private function get_error_logs( $per_page = 20, $page_number = 1 ) {
284
  * listing, we need to get count of total items for proper pagination.
285
  * Registering filter - "jj4t3_log_list_count".
286
  *
 
287
  * @since 2.0.3
288
  * @access private
289
  *
290
+ * @global object $wpdb WP DB object
291
  * @return int Total count.
292
  */
293
  private function total_logs() {
324
  public function get_columns() {
325
 
326
  $columns = array(
327
+ 'cb' => '<input type="checkbox" style="width: 5%;" />',
328
+ 'date' => __( 'Date', '404-to-301' ),
329
+ 'url' => __( '404 Path', '404-to-301' ),
330
+ 'ref' => __( 'From', '404-to-301' ),
331
+ 'ip' => __( 'IP Address', '404-to-301' ),
332
+ 'ua' => __( 'User Agent', '404-to-301' ),
333
+ 'redirect' => __( 'Customization', '404-to-301' ),
334
  );
335
 
336
  /**
360
 
361
  $columns = array(
362
  'date' => array( 'date', true ),
363
+ 'url' => array( 'url', false ),
364
+ 'ref' => array( 'ref', false ),
365
+ 'ip' => array( 'ip', false ),
366
  );
367
 
368
  /**
369
  * Filter hook to change column titles.
370
  *
371
+ * @note DO NOT add extra columns.
372
  *
373
  * @since 3.0.0
374
  */
404
  * for switch, printing the whole array.
405
  * Registering filter - "jj4t3_log_list_column_default".
406
  *
407
+ * @param array $item Column data
408
  * @param string $column_name Column name
409
  *
410
  * @since 2.0.0
419
  /**
420
  * Filter hook to change column names.
421
  *
422
+ * @note DO NOT add extra columns.
423
  *
424
  * @since 3.0.0
425
  */
693
  public function get_bulk_actions() {
694
 
695
  $actions = array(
696
+ 'bulk_delete' => __( 'Delete Selected', '404-to-301' ),
697
+ 'bulk_clean' => __( 'Delete All', '404-to-301' ),
698
  'bulk_delete_all' => __( 'Delete All (Keep redirects)', '404-to-301' ),
699
  );
700
 
701
  /**
702
  * Filter hook to change actions.
703
  *
704
+ * @note If you are adding extra actions
705
  * Make sure it's actions are properly added.
706
  *
707
  * @since 3.0.0
734
  echo '<select name="group_by_top" class="404_group_by">';
735
  echo '<option value="">' . __( 'Group by', '404-to-301' ) . '</option>';
736
  foreach ( $column_names as $column ) {
737
+ echo '<option value="' . $column . '" ' . selected( $column, $this->group_by ) . '>' . esc_attr( $available_columns[ $column ] ) . '</option>';
738
  }
739
  echo '</select>';
740
  submit_button( __( 'Apply', '404-to-301' ), 'button', 'filter_action', false, array( 'id' => 'post-query' ) );
743
  /**
744
  * Action hook to add extra items in actions area.
745
  *
746
+ * @param object $this Class instance.
747
  * @param string $which Current location (top or bottom).
748
  */
749
  do_action( 'jj4t3_log_list_extra_tablenav', $this, $which );
836
  * the user selection. We are using IF ELSE loop instead of
837
  * switch to easily handle conditions.
838
  *
839
+ * @param mixed $ids ID(s) of the log(s).
840
  * @param string $action Current bulk action.
841
  *
842
  * @since 2.0.0
852
  $query = "DELETE FROM " . JJ4T3_TABLE . " WHERE id = " . absint( $ids );
853
  } elseif ( is_array( $ids ) && 'bulk_delete' === $action ) {
854
  // If multiple selected logs are being deleted.
855
+ $ids = implode( ',', array_map( 'absint', $ids ) );
856
  $query = "DELETE FROM " . JJ4T3_TABLE . " WHERE id IN($ids)";
857
  } elseif ( 'bulk_delete_all' === $action ) {
858
  // If deleting all logs except custom redirected ones.
875
  *
876
  * @param string $status Status.
877
  * @param string $option Option name.
878
+ * @param mixed $value Value of the option.
879
  *
880
  * @since 2.1.0
881
  * @access public
890
  /**
891
  * Get custom redirect modal content
892
  *
 
893
  * @since 2.2.0
894
  * @access public
895
  *
896
+ * @global object $wpdb WP DB object
897
  * @return void
898
  */
899
  public static function open_redirect() {
911
  wp_die();
912
  }
913
 
914
+ $url_404 = esc_url_raw( $_POST['url_404'] );
915
 
916
  global $wpdb;
917
 
918
  // Get custom redirect value from db, if exist.
919
+ $result = $wpdb->get_row( $wpdb->prepare( "SELECT redirect, options FROM " . JJ4T3_TABLE . " WHERE url = %s AND redirect IS NOT NULL LIMIT 0,1", $url_404 ), 'OBJECT' );
920
 
921
  // Get custom redirect type and url.
922
+ $url = empty( $result->redirect ) ? '' : esc_url_raw( $result->redirect );
923
 
924
  // Get custom options.
925
  $options = empty( $result->options ) ? array() : maybe_unserialize( $result->options );
926
 
927
  // Get result in an array.
928
  $data = array(
929
+ 'url_404' => $url_404,
930
+ 'url' => $url,
931
  );
932
 
933
  // Set the custom options for the 404.
934
+ $data['type'] = empty( $options['type'] ) ? jj4t3_get_option( 'redirect_type' ) : intval( $options['type'] );
935
+ $data['redirect'] = isset( $options['redirect'] ) ? intval( $options['redirect'] ) : - 1;
936
+ $data['log'] = isset( $options['log'] ) ? intval( $options['log'] ) : - 1;
937
+ $data['alert'] = isset( $options['alert'] ) ? intval( $options['alert'] ) : - 1;
938
 
939
  /**
940
  * Filter to alter custom redirect modal response array.
952
  * When user set a custom redirect url for a 404 link, save the data
953
  * from modal by updating all error logs of the current 404 links.
954
  *
 
955
  * @since 2.2.0
956
  * @access public
957
  *
958
+ * @note Always die() for wp_ajax
959
  *
960
+ * @global object $wpdb WP DB object
961
  * @return void
962
  */
963
  public static function save_redirect() {
973
  // Custom options for the 404 path.
974
  $options = maybe_serialize(
975
  array(
976
+ 'redirect' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_redirect' ) ),
977
+ 'log' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_log' ) ),
978
+ 'alert' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_alert' ) ),
979
+ 'type' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_type' ) ),
980
  )
981
  );
982
 
983
  // Get 404 url.
984
+ $url = jj4t3_from_request( 'jj4t3_custom_redirect', false ) ? esc_url_raw( jj4t3_from_request( 'jj4t3_custom_redirect' ) ) : '';
985
 
986
  global $wpdb;
987
 
988
  // Get custom redirect url.
989
+ $url_404 = jj4t3_from_request( 'jj4t3_redirect_404', false ) ? esc_url_raw( jj4t3_from_request( 'jj4t3_redirect_404' ) ) : '';
990
 
991
  /**
992
  * Action hook to run before updating a custom redirect.
995
  * after your custom function.
996
  *
997
  * @param string $url_404 404 link.
998
+ * @param string $url Link to redirect.
999
  *
1000
  * @since 3.0.0
1001
  */
includes/admin/views/custom-redirect.php CHANGED
@@ -1,45 +1,46 @@
1
  <?php
2
 
3
  // If this file is called directly, abort.
4
- defined( 'ABSPATH' ) or exit; ?>
 
5
 
6
  <div id="jj4t3-redirect-modal" style="display:none;">
7
  <div id="jj4t3-thickbox-content" class="wrap">
8
  <form id="jj4t3_custom_redirect_form" action="javascript:void(0)">
9
  <table class="form-table">
10
  <tr>
11
- <th><?php _e( 'Redirecting from', '404-to-301' ); ?> :</th>
12
  <td><strong><p id="jj4t3_redirect_404_text"></p></strong></td>
13
  </tr>
14
  <tr>
15
- <th><?php _e( 'Redirect', '404-to-301' ); ?> :</th>
16
  <td>
17
- <input type="radio" name="jj4t3_custom_redirect_redirect" value="-1" checked> <?php _e( 'Default', '404-to-301' ); ?>
18
- <input type="radio" name="jj4t3_custom_redirect_redirect" value="1"> <?php _e( 'Enable', '404-to-301' ); ?>
19
- <input type="radio" name="jj4t3_custom_redirect_redirect" value="0"> <?php _e( 'Disable', '404-to-301' ); ?>
20
  </td>
21
  </tr>
22
  <tr>
23
- <th><?php _e( 'Error logging', '404-to-301' ); ?> :</th>
24
  <td>
25
- <input type="radio" name="jj4t3_custom_redirect_log" value="-1" checked> <?php _e( 'Default', '404-to-301' ); ?>
26
- <input type="radio" name="jj4t3_custom_redirect_log" value="1"> <?php _e( 'Enable', '404-to-301' ); ?>
27
- <input type="radio" name="jj4t3_custom_redirect_log" value="0"> <?php _e( 'Disable', '404-to-301' ); ?>
28
  </td>
29
  </tr>
30
  <tr>
31
- <th><?php _e( 'Email alert', '404-to-301' ); ?> :</th>
32
  <td>
33
- <input type="radio" name="jj4t3_custom_redirect_alert" value="-1" checked> <?php _e( 'Default', '404-to-301' ); ?>
34
- <input type="radio" name="jj4t3_custom_redirect_alert" value="1"> <?php _e( 'Enable', '404-to-301' ); ?>
35
- <input type="radio" name="jj4t3_custom_redirect_alert" value="0"> <?php _e( 'Disable', '404-to-301' ); ?>
36
  </td>
37
  </tr>
38
  <tr>
39
- <th><?php _e( 'Redirect to', '404-to-301' ); ?> :</th>
40
  <td>
41
  <input type="text" size="40" name="jj4t3_custom_redirect" id="jj4t3_redirect_url" value="">
42
- <p class="description"><?php _e( 'Enter the url if you want to set custom redirect for above 404 path. Enter the full url including http://. Leave empty if you want to follow default settings.', '404-to-301' ); ?></p>
43
  <input type="hidden" value="" id="jj4t3_redirect_404" name="jj4t3_redirect_404">
44
  <input type="hidden" value="<?php echo wp_create_nonce( "jj4t3_redirect_nonce" ); ?>" id="jj4t3_redirect_nonce" name="jj4t3_redirect_nonce">
45
  <input type="hidden" value="jj4t3_redirect_form" name="action">
@@ -48,14 +49,14 @@ defined( 'ABSPATH' ) or exit; ?>
48
  <?php $statuses = jj4t3_redirect_statuses(); ?>
49
  <?php if ( ! empty( $statuses ) ) : ?>
50
  <tr>
51
- <th><?php _e( 'Redirect type', '404-to-301' ); ?></th>
52
  <td>
53
  <select name="jj4t3_custom_redirect_type" id="jj4t3_custom_redirect_type">
54
  <?php foreach ( $statuses as $status => $label ) : ?>
55
- <option value='<?php echo $status; ?>' <?php selected( jj4t3_get_option( 'redirect_type' ), $status ); ?>><?php echo $label; ?></option>
56
  <?php endforeach; ?>
57
  </select>
58
- <p class="description jj4t3-p-desc"><?php _e( 'Select redirect type to override default one.', '404-to-301' ); ?></p>
59
  </td>
60
  </tr>
61
  <?php endif; ?>
1
  <?php
2
 
3
  // If this file is called directly, abort.
4
+ defined( 'ABSPATH' ) || exit;
5
+ ?>
6
 
7
  <div id="jj4t3-redirect-modal" style="display:none;">
8
  <div id="jj4t3-thickbox-content" class="wrap">
9
  <form id="jj4t3_custom_redirect_form" action="javascript:void(0)">
10
  <table class="form-table">
11
  <tr>
12
+ <th><?php esc_html_e( 'Redirecting from', '404-to-301' ); ?> :</th>
13
  <td><strong><p id="jj4t3_redirect_404_text"></p></strong></td>
14
  </tr>
15
  <tr>
16
+ <th><?php esc_html_e( 'Redirect', '404-to-301' ); ?> :</th>
17
  <td>
18
+ <input type="radio" name="jj4t3_custom_redirect_redirect" value="-1" checked> <?php esc_html_e( 'Default', '404-to-301' ); ?>
19
+ <input type="radio" name="jj4t3_custom_redirect_redirect" value="1"> <?php esc_html_e( 'Enable', '404-to-301' ); ?>
20
+ <input type="radio" name="jj4t3_custom_redirect_redirect" value="0"> <?php esc_html_e( 'Disable', '404-to-301' ); ?>
21
  </td>
22
  </tr>
23
  <tr>
24
+ <th><?php esc_html_e( 'Error logging', '404-to-301' ); ?> :</th>
25
  <td>
26
+ <input type="radio" name="jj4t3_custom_redirect_log" value="-1" checked> <?php esc_html_e( 'Default', '404-to-301' ); ?>
27
+ <input type="radio" name="jj4t3_custom_redirect_log" value="1"> <?php esc_html_e( 'Enable', '404-to-301' ); ?>
28
+ <input type="radio" name="jj4t3_custom_redirect_log" value="0"> <?php esc_html_e( 'Disable', '404-to-301' ); ?>
29
  </td>
30
  </tr>
31
  <tr>
32
+ <th><?php esc_html_e( 'Email alert', '404-to-301' ); ?> :</th>
33
  <td>
34
+ <input type="radio" name="jj4t3_custom_redirect_alert" value="-1" checked> <?php esc_html_e( 'Default', '404-to-301' ); ?>
35
+ <input type="radio" name="jj4t3_custom_redirect_alert" value="1"> <?php esc_html_e( 'Enable', '404-to-301' ); ?>
36
+ <input type="radio" name="jj4t3_custom_redirect_alert" value="0"> <?php esc_html_e( 'Disable', '404-to-301' ); ?>
37
  </td>
38
  </tr>
39
  <tr>
40
+ <th><?php esc_html_e( 'Redirect to', '404-to-301' ); ?> :</th>
41
  <td>
42
  <input type="text" size="40" name="jj4t3_custom_redirect" id="jj4t3_redirect_url" value="">
43
+ <p class="description"><?php esc_html_e( 'Enter the url if you want to set custom redirect for above 404 path. Enter the full url including http://. Leave empty if you want to follow default settings.', '404-to-301' ); ?></p>
44
  <input type="hidden" value="" id="jj4t3_redirect_404" name="jj4t3_redirect_404">
45
  <input type="hidden" value="<?php echo wp_create_nonce( "jj4t3_redirect_nonce" ); ?>" id="jj4t3_redirect_nonce" name="jj4t3_redirect_nonce">
46
  <input type="hidden" value="jj4t3_redirect_form" name="action">
49
  <?php $statuses = jj4t3_redirect_statuses(); ?>
50
  <?php if ( ! empty( $statuses ) ) : ?>
51
  <tr>
52
+ <th><?php esc_html_e( 'Redirect type', '404-to-301' ); ?></th>
53
  <td>
54
  <select name="jj4t3_custom_redirect_type" id="jj4t3_custom_redirect_type">
55
  <?php foreach ( $statuses as $status => $label ) : ?>
56
+ <option value='<?php echo esc_attr( $status ); ?>' <?php selected( jj4t3_get_option( 'redirect_type' ), $status ); ?>><?php echo esc_attr( $label ); ?></option>
57
  <?php endforeach; ?>
58
  </select>
59
+ <p class="description jj4t3-p-desc"><?php esc_html_e( 'Select redirect type to override default one.', '404-to-301' ); ?></p>
60
  </td>
61
  </tr>
62
  <?php endif; ?>
includes/functions/jj4t3-general-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  // If this file is called directly, abort.
4
- defined( 'ABSPATH' ) or exit;
5
 
6
  /**
7
  * Get plugin setting value.
@@ -9,7 +9,7 @@ defined( 'ABSPATH' ) or exit;
9
  * Handle the exceptional case properly
10
  * and return false.
11
  *
12
- * @param mixed $option Option name.
13
  * @param mixed $default Default value if not exist.
14
  *
15
  * @since 3.0.0
@@ -43,7 +43,7 @@ function jj4t3_get_option( $option = false, $default = false ) {
43
  * update the the array only.
44
  *
45
  * @param string $option Option name.
46
- * @param mixed $value Value to update.
47
  *
48
  * @since 3.0.0
49
  * @access public
@@ -219,6 +219,9 @@ function jj4t3_redirect_type() {
219
  * DO NOT relay on this function for serious actions
220
  * as it may be wrong in some cases.
221
  *
 
 
 
222
  * @global bool $is_gecko
223
  * @global bool $is_opera
224
  * @global bool $is_safari
@@ -228,9 +231,6 @@ function jj4t3_redirect_type() {
228
  * @global bool $is_NS4
229
  * @global bool $is_lynx
230
  *
231
- * @since 3.0.0
232
- * @access private
233
- *
234
  * @return boolean
235
  */
236
  function jj4t3_is_human() {
@@ -271,7 +271,7 @@ function jj4t3_is_human() {
271
  * You can modify this to use more status using the filter.
272
  * Registering filter - "jj4t3_redirect_statuses".
273
  *
274
- * @link https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html HTTP status codes.
275
  * @since 3.0.0
276
  * @access private
277
  *
@@ -314,11 +314,11 @@ function jj4t3_redirect_statuses() {
314
  function jj4t3_log_columns() {
315
 
316
  $columns = array(
317
- 'date' => __( 'Date', '404-to-301' ),
318
- 'url' => __( '404 Path', '404-to-301' ),
319
- 'ref' => __( 'From', '404-to-301' ),
320
- 'ip' => __( 'IP Address', '404-to-301' ),
321
- 'ua' => __( 'User Agent', '404-to-301' ),
322
  'redirect' => __( 'Redirect', '404-to-301' ),
323
  );
324
 
@@ -345,8 +345,8 @@ function jj4t3_log_columns() {
345
  * or empty.
346
  * Output will be trimmed.
347
  *
348
- * @param string $key Key to get from request.
349
- * @param mixed $default Default value.
350
  *
351
  * @since 3.0.0
352
  * @access public
@@ -361,15 +361,15 @@ function jj4t3_from_request( $key = '', $default = '' ) {
361
  }
362
 
363
  // Return default value if key not set.
364
- if ( ! isset( $_REQUEST[ $key ] ) ) {
365
  return $default;
366
  }
367
 
368
  // Trim output.
369
- if ( is_string( $_REQUEST[ $key ] ) ) {
370
- return trim( $_REQUEST[ $key ] );
371
- } elseif ( is_array( $_REQUEST[ $key ] ) ) {
372
- return array_map( 'trim', $_REQUEST[ $key ] );
373
  }
374
 
375
  return $default;
1
  <?php
2
 
3
  // If this file is called directly, abort.
4
+ defined( 'ABSPATH' ) || exit;
5
 
6
  /**
7
  * Get plugin setting value.
9
  * Handle the exceptional case properly
10
  * and return false.
11
  *
12
+ * @param mixed $option Option name.
13
  * @param mixed $default Default value if not exist.
14
  *
15
  * @since 3.0.0
43
  * update the the array only.
44
  *
45
  * @param string $option Option name.
46
+ * @param mixed $value Value to update.
47
  *
48
  * @since 3.0.0
49
  * @access public
219
  * DO NOT relay on this function for serious actions
220
  * as it may be wrong in some cases.
221
  *
222
+ * @since 3.0.0
223
+ * @access private
224
+ *
225
  * @global bool $is_gecko
226
  * @global bool $is_opera
227
  * @global bool $is_safari
231
  * @global bool $is_NS4
232
  * @global bool $is_lynx
233
  *
 
 
 
234
  * @return boolean
235
  */
236
  function jj4t3_is_human() {
271
  * You can modify this to use more status using the filter.
272
  * Registering filter - "jj4t3_redirect_statuses".
273
  *
274
+ * @link https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html HTTP status codes.
275
  * @since 3.0.0
276
  * @access private
277
  *
314
  function jj4t3_log_columns() {
315
 
316
  $columns = array(
317
+ 'date' => __( 'Date', '404-to-301' ),
318
+ 'url' => __( '404 Path', '404-to-301' ),
319
+ 'ref' => __( 'From', '404-to-301' ),
320
+ 'ip' => __( 'IP Address', '404-to-301' ),
321
+ 'ua' => __( 'User Agent', '404-to-301' ),
322
  'redirect' => __( 'Redirect', '404-to-301' ),
323
  );
324
 
345
  * or empty.
346
  * Output will be trimmed.
347
  *
348
+ * @param string $key Key to get from request.
349
+ * @param mixed $default Default value.
350
  *
351
  * @since 3.0.0
352
  * @access public
361
  }
362
 
363
  // Return default value if key not set.
364
+ if ( ! isset( $_REQUEST[ $key ] ) ) { // phpcs:ignore
365
  return $default;
366
  }
367
 
368
  // Trim output.
369
+ if ( is_string( $_REQUEST[ $key ] ) ) { // phpcs:ignore
370
+ return trim( $_REQUEST[ $key ] ); // phpcs:ignore
371
+ } elseif ( is_array( $_REQUEST[ $key ] ) ) { // phpcs:ignore
372
+ return array_map( 'trim', $_REQUEST[ $key ] ); // phpcs:ignore
373
  }
374
 
375
  return $default;
languages/404-to-301.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the GPL-2.0+.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: 404 to 301 - Redirect, Log and Notify 404 Errors 3.0.9\n"
6
  "Report-Msgid-Bugs-To: https://duckdev.com/products/404-to-301/\n"
7
- "POT-Creation-Date: 2021-10-06 07:58:16+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -130,9 +130,9 @@ msgid "Delete"
130
  msgstr ""
131
 
132
  #: includes/admin/class-jj4t3-log-listing.php:624
133
- #: includes/admin/views/custom-redirect.php:17
134
- #: includes/admin/views/custom-redirect.php:25
135
- #: includes/admin/views/custom-redirect.php:33
136
  msgid "Default"
137
  msgstr ""
138
 
@@ -164,57 +164,57 @@ msgstr ""
164
  msgid "by <a href=\"%s\">Joel James</a>"
165
  msgstr ""
166
 
167
- #: includes/admin/views/custom-redirect.php:11
168
  msgid "Redirecting from"
169
  msgstr ""
170
 
171
- #: includes/admin/views/custom-redirect.php:15
172
  #: includes/functions/jj4t3-general-functions.php:322
173
  msgid "Redirect"
174
  msgstr ""
175
 
176
- #: includes/admin/views/custom-redirect.php:18
177
- #: includes/admin/views/custom-redirect.php:26
178
- #: includes/admin/views/custom-redirect.php:34
179
- msgid "Enable"
180
- msgstr ""
181
-
182
  #: includes/admin/views/custom-redirect.php:19
183
  #: includes/admin/views/custom-redirect.php:27
184
  #: includes/admin/views/custom-redirect.php:35
 
 
 
 
 
 
185
  msgid "Disable"
186
  msgstr ""
187
 
188
- #: includes/admin/views/custom-redirect.php:23
189
  msgid "Error logging"
190
  msgstr ""
191
 
192
- #: includes/admin/views/custom-redirect.php:31
193
  msgid "Email alert"
194
  msgstr ""
195
 
196
- #: includes/admin/views/custom-redirect.php:39
197
  #: includes/admin/views/settings.php:30
198
  msgid "Redirect to"
199
  msgstr ""
200
 
201
- #: includes/admin/views/custom-redirect.php:42
202
  msgid ""
203
  "Enter the url if you want to set custom redirect for above 404 path. Enter "
204
  "the full url including http://. Leave empty if you want to follow default "
205
  "settings."
206
  msgstr ""
207
 
208
- #: includes/admin/views/custom-redirect.php:51
209
  #: includes/admin/views/settings.php:17
210
  msgid "Redirect type"
211
  msgstr ""
212
 
213
- #: includes/admin/views/custom-redirect.php:58
214
  msgid "Select redirect type to override default one."
215
  msgstr ""
216
 
217
- #: includes/admin/views/custom-redirect.php:65
218
  msgid "Save Redirect"
219
  msgstr ""
220
 
2
  # This file is distributed under the GPL-2.0+.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: 404 to 301 - Redirect, Log and Notify 404 Errors 3.1.0\n"
6
  "Report-Msgid-Bugs-To: https://duckdev.com/products/404-to-301/\n"
7
+ "POT-Creation-Date: 2021-10-18 05:32:30+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
130
  msgstr ""
131
 
132
  #: includes/admin/class-jj4t3-log-listing.php:624
133
+ #: includes/admin/views/custom-redirect.php:18
134
+ #: includes/admin/views/custom-redirect.php:26
135
+ #: includes/admin/views/custom-redirect.php:34
136
  msgid "Default"
137
  msgstr ""
138
 
164
  msgid "by <a href=\"%s\">Joel James</a>"
165
  msgstr ""
166
 
167
+ #: includes/admin/views/custom-redirect.php:12
168
  msgid "Redirecting from"
169
  msgstr ""
170
 
171
+ #: includes/admin/views/custom-redirect.php:16
172
  #: includes/functions/jj4t3-general-functions.php:322
173
  msgid "Redirect"
174
  msgstr ""
175
 
 
 
 
 
 
 
176
  #: includes/admin/views/custom-redirect.php:19
177
  #: includes/admin/views/custom-redirect.php:27
178
  #: includes/admin/views/custom-redirect.php:35
179
+ msgid "Enable"
180
+ msgstr ""
181
+
182
+ #: includes/admin/views/custom-redirect.php:20
183
+ #: includes/admin/views/custom-redirect.php:28
184
+ #: includes/admin/views/custom-redirect.php:36
185
  msgid "Disable"
186
  msgstr ""
187
 
188
+ #: includes/admin/views/custom-redirect.php:24
189
  msgid "Error logging"
190
  msgstr ""
191
 
192
+ #: includes/admin/views/custom-redirect.php:32
193
  msgid "Email alert"
194
  msgstr ""
195
 
196
+ #: includes/admin/views/custom-redirect.php:40
197
  #: includes/admin/views/settings.php:30
198
  msgid "Redirect to"
199
  msgstr ""
200
 
201
+ #: includes/admin/views/custom-redirect.php:43
202
  msgid ""
203
  "Enter the url if you want to set custom redirect for above 404 path. Enter "
204
  "the full url including http://. Leave empty if you want to follow default "
205
  "settings."
206
  msgstr ""
207
 
208
+ #: includes/admin/views/custom-redirect.php:52
209
  #: includes/admin/views/settings.php:17
210
  msgid "Redirect type"
211
  msgstr ""
212
 
213
+ #: includes/admin/views/custom-redirect.php:59
214
  msgid "Select redirect type to override default one."
215
  msgstr ""
216
 
217
+ #: includes/admin/views/custom-redirect.php:66
218
  msgid "Save Redirect"
219
  msgstr ""
220
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: joelcj91,duckdev
3
  Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo, custom 404 page
4
  Donate link: https://www.paypal.me/JoelCJ
5
  Requires at least: 3.5
6
- Tested up to: 5.7
7
- Stable tag: 3.0.9
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -128,10 +128,15 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com
128
 
129
  == Changelog ==
130
 
131
- = 3.0.9 (06/10/2021) =
132
  **👌 Improvements**
133
 
134
  * Tested with WP 5.8.
 
 
 
 
 
135
  * Added nonce verification for bulk actions.
136
 
137
  = 3.0.8 (12/06/2021) =
@@ -440,8 +445,8 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com
440
 
441
  == Upgrade Notice ==
442
 
443
- = 3.0.9 (06/10/2021) =
444
  **👌 Improvements**
445
 
446
  * Tested with WP 5.8.
447
- * Added nonce verification for bulk actions.
3
  Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo, custom 404 page
4
  Donate link: https://www.paypal.me/JoelCJ
5
  Requires at least: 3.5
6
+ Tested up to: 5.8
7
+ Stable tag: 3.1.0
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.0 (18/10/2021) =
132
  **👌 Improvements**
133
 
134
  * Tested with WP 5.8.
135
+ * Added sanitization.
136
+
137
+ = 3.0.9 (06/10/2021) =
138
+ **👌 Improvements**
139
+
140
  * Added nonce verification for bulk actions.
141
 
142
  = 3.0.8 (12/06/2021) =
445
 
446
  == Upgrade Notice ==
447
 
448
+ = 3.1.0 (18/10/2021) =
449
  **👌 Improvements**
450
 
451
  * Tested with WP 5.8.
452
+ * Added sanitization.