Platinum SEO Pack - Version 2.0.7

Version Description

  • 2020-04-05 - Updation to help file links in Redirections Settings.
Download this release

Release Info

Developer Rajesh Babu
Plugin Icon 128x128 Platinum SEO Pack
Version 2.0.7
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.7

Changelog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  = 2.0.5 =
2
  * 2020-02-21 - Introduces Patinum SEO Content analysis that does a basic analysis of your content for focus keywords that you need to enter in meta ketwords input field as comma separated items. Note that meta keywords can be turned off sitewide in SEO -> General settings, if you do not want to add a meta keywords tag for posts and /or pages. You can even control it at the post or page level by switching it On/Off, if the sitewide setting is ON. Sitewide setting is Off by default. But you can get content analysis findings in your analysis dashboard, even if it is switched off. Also fixed a few other minor bugs.
3
 
@@ -14,7 +20,7 @@
14
  * 2020-02-06 - Fixed an issue that does not pull description for existing users of the plugin, in respect of posts where they had filled them (description) in the older version of Platinum SEO Pack.
15
 
16
  = 2.0.0 =
17
- * 2020-02-01 - Techblissonline Platinum SEO Wordpress plugin has been completely rewriiten and offers several new features in adiition to fixing the bugs in the earlier version and improving Plugin Security.
18
 
19
  = 1.3.8 =
20
  * 2013-09-12 - Fixed a security issue (thanks to James Pearson)
1
+ = 2.0.7 =
2
+ * 2020-04-05 - Updation to help file links in Redirections Settings.
3
+
4
+ = 2.0.6 =
5
+ * 2020-04-05 - Introduces a complete HTTP Redirections Manager. It also now has a 404 Manager that lets you track and fix any 404 Error. This 404 Manager is integrated with Redirections to resolve the 404 Error by Creating appropriate HTTP Redirection. Make sure to clear browser cache after updating the plugin.
6
+
7
  = 2.0.5 =
8
  * 2020-02-21 - Introduces Patinum SEO Content analysis that does a basic analysis of your content for focus keywords that you need to enter in meta ketwords input field as comma separated items. Note that meta keywords can be turned off sitewide in SEO -> General settings, if you do not want to add a meta keywords tag for posts and /or pages. You can even control it at the post or page level by switching it On/Off, if the sitewide setting is ON. Sitewide setting is Off by default. But you can get content analysis findings in your analysis dashboard, even if it is switched off. Also fixed a few other minor bugs.
9
 
20
  * 2020-02-06 - Fixed an issue that does not pull description for existing users of the plugin, in respect of posts where they had filled them (description) in the older version of Platinum SEO Pack.
21
 
22
  = 2.0.0 =
23
+ * 2020-02-01 - Techblissonline Platinum SEO WordPress plugin has been completely rewritten and it now offers several new features in addition to fixing the bugs in the earlier version and improving Plugin Security.
24
 
25
  = 1.3.8 =
26
  * 2013-09-12 - Fixed a security issue (thanks to James Pearson)
platinum-seo-pack.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Platinum SEO Pack
5
  Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
6
  Description: Complete SEO and Social optimization solution for your Wordpress blog/site. It is Simple, Uncomplicated and User friendly with several useful features.
7
- Version: 2.0.5
8
  Author: Techblissonline.com (Rajesh)
9
  Author URI: https://techblissonline.com/
10
  Text Domain: platinum-seo-pack
@@ -59,13 +59,19 @@ include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_settings.php' );
59
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_pre_settings.php' );
60
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_social_settings.php' );
61
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_tools_settings.php' );
62
-
63
 
64
  global $psp;
65
  $psp = PspMain::get_instance();
66
 
 
 
 
67
  register_activation_hook ( __FILE__, array ($psp, 'psp_activate' ) );
68
  register_deactivation_hook ( __FILE__, array ($psp, 'psp_deactivate' ) );
69
  add_action( 'upgrader_process_complete', array ($psp, 'psp_plugin_upgrade'),10, 2);
 
 
 
70
 
71
  ?>
4
  Plugin Name: Platinum SEO Pack
5
  Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
6
  Description: Complete SEO and Social optimization solution for your Wordpress blog/site. It is Simple, Uncomplicated and User friendly with several useful features.
7
+ Version: 2.0.7
8
  Author: Techblissonline.com (Rajesh)
9
  Author URI: https://techblissonline.com/
10
  Text Domain: platinum-seo-pack
59
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_pre_settings.php' );
60
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_social_settings.php' );
61
  include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_tools_settings.php' );
62
+ include_once( PSP_PLUGIN_HOME . PSPINC . '/settings/psp_redirect_404.php' );
63
 
64
  global $psp;
65
  $psp = PspMain::get_instance();
66
 
67
+ global $psp_db_version;
68
+ $psp_db_version = '2.0.6';
69
+
70
  register_activation_hook ( __FILE__, array ($psp, 'psp_activate' ) );
71
  register_deactivation_hook ( __FILE__, array ($psp, 'psp_deactivate' ) );
72
  add_action( 'upgrader_process_complete', array ($psp, 'psp_plugin_upgrade'),10, 2);
73
+ register_activation_hook ( __FILE__, array ($psp, 'psp_db_install' ) );
74
+ add_action( 'plugins_loaded', array ($psp, 'psp_db_install'),10, 2);
75
+ add_action( 'plugins_loaded', array ($psp, 'psp_loaded_filter'),10, 1);
76
 
77
  ?>
psp-include/generators/psp_home_others_seo_metas.php CHANGED
@@ -716,33 +716,53 @@ class PspHomeOthersSeoMetas {
716
 
717
  public function get_404_psp_title() {
718
 
719
- $title = "";
720
-
721
- if ( is_404() ) {
722
-
723
- $title_format = isset($this->psp_404_settings['title']) ? $this->psp_404_settings['title'] : "";
724
- if (empty($title_format)) {
725
- $title_format = "%title_404%";
726
- $title = str_replace('%title_404%', "404 Not Found", $title_format);
727
- } else {
728
- //get_option('aiosp_search_title_format');
729
- //$title = str_replace('%blog_title%', $this->psp_helper->internationalize(get_bloginfo('name')), $title_format);
730
- //$title = str_replace('%blog_description%', $this->psp_helper->internationalize(get_bloginfo('description')), $title);
731
- //$title = str_replace('%blog_title%', $this->sitename, $title_format);
732
- //$title = str_replace('%blog_description%', $this->sitedescription, $title);
733
- $title = str_replace('%title_404%', "404 Not Found", $title_format);
734
- $title = str_replace('%title%', "404 Not Found", $title);
735
- $title = str_replace('%seo_title%', "404 Not Found", $title);
736
- $title = str_replace('%site_name%', $this->sitename, $title);
737
- //$title = str_replace('%sep%', htmlentities($this->psp_sitewide_settungs['separator']), $title);
738
- $title = str_replace('%sep%', $this->psp_sitewide_settungs['separator'], $title);
739
- //$title = $this->paged_title($title);
740
- }
741
- }
742
- $title = trim($title);
743
- return $title;
744
-
745
- } // end get_404_psp_title
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
 
747
  public function get_date_archive_psp_title() {
748
 
716
 
717
  public function get_404_psp_title() {
718
 
719
+ $title = "";
720
+
721
+ global $wpdb;
722
+ $psp_404_log = $wpdb->prefix . "psp_404_log";
723
+ global $wp;
724
+ $id_404 = '';
725
+ $error_title = "404 Not Found";
726
+
727
+ $path_to_page = trim($wp->request); // /path/to/page
728
+
729
+ $sql_404 = $wpdb->prepare("SELECT id, source_uri, source_url, total_hits, referrer, status FROM $psp_404_log a WHERE a.source_uri = %s", $path_to_page );
730
+
731
+ if (!empty($path_to_page) && ($wpdb->get_var("show tables like '$psp_404_log'") == $psp_404_log)) {
732
+ $id_404 = $wpdb->get_row($sql_404, OBJECT);
733
+ }
734
+
735
+ if (!empty($id_404) && trim($id_404->status) == "410") {
736
+
737
+ $error_title = '410 Gone';
738
+ }
739
+
740
+
741
+ if ( is_404() ) {
742
+
743
+ $title_format = isset($this->psp_404_settings['title']) ? $this->psp_404_settings['title'] : "";
744
+ if (empty($title_format)) {
745
+ $title_format = "%title_404%";
746
+ $title = str_replace('%title_404%', $error_title, $title_format);
747
+ } else {
748
+ //get_option('aiosp_search_title_format');
749
+ //$title = str_replace('%blog_title%', $this->psp_helper->internationalize(get_bloginfo('name')), $title_format);
750
+ //$title = str_replace('%blog_description%', $this->psp_helper->internationalize(get_bloginfo('description')), $title);
751
+ //$title = str_replace('%blog_title%', $this->sitename, $title_format);
752
+ //$title = str_replace('%blog_description%', $this->sitedescription, $title);
753
+ $title = str_replace('%title_404%', $error_title, $title_format);
754
+ $title = str_replace('%title%', $error_title, $title);
755
+ $title = str_replace('%seo_title%', $error_title, $title);
756
+ $title = str_replace('%site_name%', $this->sitename, $title);
757
+ //$title = str_replace('%sep%', htmlentities($this->psp_sitewide_settungs['separator']), $title);
758
+ $title = str_replace('%sep%', $this->psp_sitewide_settungs['separator'], $title);
759
+ //$title = $this->paged_title($title);
760
+ }
761
+ }
762
+ $title = trim($title);
763
+ return $title;
764
+
765
+ } // end get_404_psp_title
766
 
767
  public function get_date_archive_psp_title() {
768
 
psp-include/settings/css/psp-settings.css CHANGED
@@ -27,6 +27,14 @@ body {
27
  appearance:none;
28
  }
29
 
 
 
 
 
 
 
 
 
30
  .psp-radio-separator{
31
  cursor:pointer;
32
  background-size:contain;
27
  appearance:none;
28
  }
29
 
30
+ .psp-d {
31
+ width:10%;height:10%;
32
+ }
33
+
34
+ .alternate {
35
+ background-color: #F2F2F2;
36
+ }
37
+
38
  .psp-radio-separator{
39
  cursor:pointer;
40
  background-size:contain;
psp-include/settings/js/psp-404.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ jQuery('#psp_action').on('change', function (){
3
+ $("#source-url-input").val('');
4
+ $( "#psp-edit-div" ).slideUp( "slow", function() {
5
+ $("#psp-edit-div").addClass('hidden');
6
+ $("#insertit").addClass('hidden');
7
+ $("#cancelit").addClass('hidden');
8
+ $("#source-tr").removeClass('hidden');
9
+ //$("#updateit").addClass('hidden');
10
+ //$("#psp-delete-div").removeClass('hidden');
11
+ });
12
+
13
+ if($(this).val() == 'addredirect') {
14
+
15
+ $( "#psp-edit-div" ).slideDown( "slow", function() {
16
+ $("#source-url-input").val('');
17
+ $("#source-tr").addClass('hidden');
18
+ $("#insertit").removeClass('hidden');
19
+ $("#cancelit").removeClass('hidden');
20
+ $("#psp-edit-div").removeClass('hidden');
21
+ });
22
+
23
+ }
24
+ if($(this).val() == 'edit') {
25
+ $("#psp-status-div").removeClass('hidden');
26
+ $("#updateit").removeClass('hidden');
27
+ } else {
28
+ $("#psp-status-div").addClass('hidden');
29
+ $("#updateit").addClass('hidden');
30
+ }
31
+
32
+ if($(this).val() == 'delete' || $(this).val() == 'deleteall') {
33
+ $("#psp-delete-div").removeClass('hidden');
34
+ } else {
35
+ $("#psp-delete-div").addClass('hidden');
36
+ }
37
+ });
38
+ $('#cancelit').on('click', function (){
39
+ $( "#psp-edit-div" ).slideUp( "slow", function() {
40
+ $("#psp-edit-div").addClass('hidden');
41
+ $("#insertit").addClass('hidden');
42
+ $("#cancelit").addClass('hidden');
43
+ //$("#updateit").addClass('hidden');
44
+ //$("#psp-delete-div").removeClass('hidden');
45
+ });
46
+ });
47
+ $('a.create').on('click', function (){
48
+ $('#id-input').val( $(this).attr('title'));
49
+ $('#source-url-input').val( $(this).siblings("div").text());
50
+ $( "#psp-edit-div" ).slideDown( "slow", function() { $("#source-tr").removeClass('hidden');
51
+ $("#insertit").removeClass('hidden');
52
+ $("#cancelit").removeClass('hidden');
53
+ $("#psp-edit-div").removeClass('hidden');
54
+ });
55
+ });
56
+ $('.moretr').on('click', function (){
57
+ $(this).toggle('slow');
58
+ });
59
+ $('a.more').on('click', function (){
60
+ $(this).closest("tr").next('tr').toggle('slow');
61
+ });
62
+ if($('#psp_filter').val() === '') {
63
+ $( "#pspsearchfield" ).addClass('hidden');
64
+ } else {
65
+ $( "#pspsearchfield" ).removeClass('hidden');
66
+ }
67
+ jQuery('#psp_filter').on('change', function (){
68
+ if($(this).val() === '') {
69
+ $( "#pspsearchfield" ).addClass('hidden');
70
+ } else {
71
+ $( "#pspsearchfield" ).removeClass('hidden');
72
+ }
73
+ });
74
+ });
psp-include/settings/js/psp-redirect.js ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+
3
+ jQuery('#psp_action').on('change', function (){
4
+
5
+ $( "#psp-edit-div" ).slideUp( "slow", function() {
6
+ $("#psp-edit-div").addClass('hidden');
7
+ $("#updateit").addClass('hidden');
8
+ $("#source-tr").addClass('hidden');
9
+ $("#insertit").addClass('hidden');
10
+ $("#log-div").addClass('hidden');
11
+ $("#cancelit").addClass('hidden');
12
+ });
13
+
14
+ if($(this).val() == 'edit' || $(this).val() == 'addnew') {
15
+ if($(this).val() == 'edit') {
16
+ $( "#psp-edit-div" ).slideDown( "slow", function() {
17
+ if( $( "#psp_redir_type" ).val() !== "") {
18
+ $("#log-div").removeClass('hidden');
19
+ }
20
+ $("#updateit").removeClass('hidden');
21
+ $("#psp-edit-div").removeClass('hidden');
22
+ $("#cancelit").removeClass('hidden');
23
+
24
+ });
25
+ }
26
+ if($(this).val() == 'addnew') {
27
+ $( "#psp-edit-div" ).slideDown( "slow", function() {
28
+ $("#source-tr").removeClass('hidden');
29
+ $("#insertit").removeClass('hidden');
30
+ $("#psp-edit-div").removeClass('hidden');
31
+ $("#cancelit").removeClass('hidden');
32
+ if( $( "#psp_redir_type" ).val() !== "") {
33
+ $("#log-div").removeClass('hidden');
34
+ }
35
+ });
36
+ }
37
+ }
38
+
39
+ if($(this).val() == 'delete' || $(this).val() == 'deleteall') {
40
+
41
+ $("#psp-delete-div").removeClass('hidden');
42
+
43
+ } else {
44
+
45
+ $("#psp-delete-div").addClass('hidden');
46
+
47
+ }
48
+ });
49
+ jQuery('#psp_redir_type').on('change', function (){
50
+
51
+ if($(this).val() !== '') {
52
+ $('select[id="psp_filter"]').find('option[value=""]').text("All");
53
+ } else {
54
+ $('select[id="psp_filter"]').find('option[value=""]').text("Redirected");
55
+ }
56
+
57
+ if($(this).val() !== $("#pspredirtype").val()) {
58
+ $( "#psp-edit-div" ).slideUp( "slow");
59
+ $("#psp_action").val('');
60
+ $("#psp_action").addClass('hidden');
61
+ $("#psp-delete-div").addClass('hidden');
62
+ } else {
63
+ $("#psp_action").removeClass('hidden');
64
+ if($("#psp_action").val() == 'delete' || $("#psp_action").val() == 'deleteall') {
65
+ $("#psp-delete-div").removeClass('hidden');
66
+ }
67
+ }
68
+
69
+ });
70
+ $('#cancelit').on('click', function (){
71
+ $( "#psp-edit-div" ).slideUp( "slow", function() {
72
+ $("#psp-edit-div").addClass('hidden');
73
+ $("#insertit").addClass('hidden');
74
+ $("#cancelit").addClass('hidden');
75
+ });
76
+ })
77
+ if($('#psp_filter').val() === '') {
78
+ $( "#pspsearchfield" ).addClass('hidden');
79
+ } else {
80
+ $( "#pspsearchfield" ).removeClass('hidden');
81
+ }
82
+ jQuery('#psp_filter').on('change', function (){
83
+ if($(this).val() === '') {
84
+ $( "#pspsearchfield" ).addClass('hidden');
85
+ } else {
86
+ $( "#pspsearchfield" ).removeClass('hidden');
87
+ }
88
+ });
89
+ if (jQuery('#ipaddress-hide').is(":not(:checked)")) {
90
+ $( "#ipaddress" ).addClass('hidden');
91
+ $( ".ipaddress" ).addClass('hidden');
92
+ }
93
+ if (jQuery('#referrer-hide').is(":not(:checked)")) {
94
+ $( "#referrer" ).addClass('hidden');
95
+ $( ".referrer" ).addClass('hidden');
96
+ }
97
+ if (jQuery('#useragent-hide').is(":not(:checked)")) {
98
+ $( "#useragent" ).addClass('hidden');
99
+ $( ".useragent" ).addClass('hidden');
100
+ }
101
+ jQuery('#ipaddress-hide').click(function(){
102
+ if($(this).is(":checked")){
103
+ $( "#ipaddress" ).removeClass('hidden');
104
+ $( ".ipaddress" ).removeClass('hidden');
105
+ }
106
+ else if($(this).is(":not(:checked)")){
107
+ $( "#ipaddress" ).addClass('hidden');
108
+ $( ".ipaddress" ).addClass('hidden');
109
+ }
110
+ });
111
+
112
+ jQuery('#useragent-hide').click(function(){
113
+ if($(this).is(":checked")){
114
+ $( "#useragent" ).removeClass('hidden');
115
+ $( ".useragent" ).removeClass('hidden');
116
+ }
117
+ else if($(this).is(":not(:checked)")){
118
+ $( "#useragent" ).addClass('hidden');
119
+ $( ".useragent" ).addClass('hidden');
120
+ }
121
+ });
122
+
123
+ jQuery('#referrer-hide').click(function(){
124
+ if($(this).is(":checked")){
125
+ $( "#referrer" ).removeClass('hidden');
126
+ $( ".referrer" ).removeClass('hidden');
127
+ }
128
+ else if($(this).is(":not(:checked)")){
129
+ $( "#referrer" ).addClass('hidden');
130
+ $( ".referrer" ).addClass('hidden');
131
+ }
132
+ });
133
+
134
+ });
psp-include/settings/psp_404_list_renderer.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Platinum SEO Pack
4
+ Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
5
+ Author: Rajesh - Techblissonline
6
+ Author URI: http://techblissonline.com/
7
+ */
8
+ ?>
9
+ <?php
10
+ wp_enqueue_script( 'psp-404', plugins_url( '/js/psp-404.js', __FILE__ ), array( 'jquery' ) );
11
+ ?>
12
+ <style>
13
+ .page-numbers {
14
+ display: inline-block;
15
+ padding: 5px 10px;
16
+ margin: 0 2px 0 0;
17
+ border: 1px solid #eee;
18
+ line-height: 1;
19
+ text-decoration: none;
20
+ border-radius: 2px;
21
+ font-weight: 600;
22
+ olor:#111;
23
+
24
+ }
25
+ .page-numbers.current,
26
+ a.page-numbers:hover {
27
+ background: grey; /* color:#f9f9f9;*/
28
+ color:#fff;
29
+ }
30
+ </style>
31
+
32
+ <div class="wrap">
33
+
34
+ <h2>Manage 404 Errors:</h2>
35
+ <a href="/wp-admin/admin.php?page=platinum-seo-social-pack-by-techblissonline&psptab=psp_permalink#psp_301_limit">404 Settings</a> | <a href="https://techblissonline.com/http-404-error/" target="_blank" rel="noopener">How to handle 404 Errors</a>
36
+ <form id="psp-search" action="" method="get">
37
+ <div class="tablenav top">
38
+ <div class="alignleft actions">
39
+
40
+ <input type="hidden" name="page" id="page" value="manager404">
41
+ <div id="pspredirmethod" class="alignleft">
42
+ <select id="psp_404_type" name="psp_404_type"><?php $dditems = array('' => 'All Errors', 'all_with_referrers' => 'Errors with referrers only','all_404' => 'All 404s', 'all_410' => 'All 410s', 'all_404_with_referrers' => 'All 404s with referrers', 'all_410_with_referrers' => 'All 410s with referrers');
43
+ foreach($dditems as $key => $val) {
44
+ $selected = (isset($_GET['psp_404_type']) && $_GET['psp_404_type']==$key) ? 'selected="selected"' : '';
45
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
46
+ } ?></select></div>
47
+ <div id="pspfilter" class="alignleft">
48
+ <select id="psp_filter" name="psp_filter"><?php $dditems = array('' => 'Logged', 'equals' => 'Equal to', 'contains' => 'that Contain', 'starts-with' => 'that Start with', 'ends-with' => 'that End With');
49
+ foreach($dditems as $key => $val) {
50
+ $selected = (isset($_GET['psp_filter']) && $_GET['psp_filter']==$key) ? 'selected="selected"' : '';
51
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
52
+ } ?></select></div>
53
+ <div id="pspsearchfield" class="alignleft hidden">
54
+ <input type="search" name="post-search-input" id="post-search-input" value="<?php echo (isset($_GET['post-search-input']) ? esc_attr(sanitize_text_field($_GET['post-search-input'])) : ''); ?>">
55
+ </div>
56
+
57
+ <div id="searchitdiv" class="alignleft"><input type="submit" name="searchit" id="searchit" class="button-secondary search" value="Search"></div>
58
+
59
+ </div>
60
+
61
+ </div>
62
+ </form>
63
+ <br class="clear" />
64
+ <form id="psp-edit" action="" method="post">
65
+ <div id="psp-edit-div" class="hidden">
66
+ <table class="form-table">
67
+
68
+ <tr id="id-tr" class="form-field hidden">
69
+ <th style="width:20%;" scope="row" valign="top"><label for="id-input"><?php esc_html_e('Source ID: ', 'platinum-seo-pack'); ?></label></div></th>
70
+ <td><input type="hidden" id="id-input" name="id-input" value="" /></td>
71
+ </tr>
72
+
73
+ <tr id="source-tr" class="form-field">
74
+ <th style="width:20%;" scope="row" valign="top"><label for="source-url-input"><?php esc_html_e('Source URI: ', 'platinum-seo-pack'); ?></label></div></th>
75
+ <td><input type="text" id="source-url-input" name="source-url-input" value="" placeholder="<?php esc_html_e('Enter the source URI or URL ', 'platinum-seo-pack'); ?>" /></td>
76
+ </tr>
77
+
78
+ <tr class="form-field">
79
+ <th style="width:20%;" scope="row" valign="top"><label for="redirect-url-input"><?php esc_html_e('Redirect to: ', 'platinum-seo-pack'); ?></label></th>
80
+ <td><input type="text" id="redirect-url-input" name="redirect-url-input" value="" placeholder="<?php esc_html_e('Enter a valid Destination URL ', 'platinum-seo-pack'); ?>" /></td>
81
+ </tr>
82
+ <tr class="form-field">
83
+ <th style="width:20%;" scope="row" valign="top"><label for="redirect-url-input"><?php echo esc_html__('Redirection Method: ', 'platinum-seo-pack').'<br>'.'<a href="https://techblissonline.com/http-redirection-status-codes-301-302-307-308/" target="_blank" rel="noopener">'.esc_html__('What to Select?', 'platinum-seo-pack').'</a>'; ?></label></th>
84
+ <td>
85
+ <div class="alignleft"><select id="psp-redirect-code" name="psp-redirect-code">
86
+ <?php $dditems = array('' => 'Select a redirection method', '301' => '301 Moved Permanently', '302' => '302 Found', '302' => '302 Found', '303' => '303 See Other', '307' => '307 Temporary Redirect');
87
+
88
+ foreach($dditems as $key => $val) {
89
+ $selected = (isset($_POST['psp-redirect-code']) && $_POST['psp-redirect-code']==$key) ? 'selected="selected"' : '';
90
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
91
+ } ?>
92
+ </select></div>
93
+ <div id="insertit-div" class="alignleft"><input type="submit" value="<?php _e('Add New'); ?>" name="insertit" id="insertit" class="button-secondary update hidden" />
94
+ </div>
95
+ <div id="cancelit-div" class="alignleft"><input type="reset" value="<?php _e('Cancel'); ?>" name="cancelit" id="cancelit" class="button-secondary update hidden" />
96
+ </div>
97
+ </td>
98
+ </tr>
99
+ </table>
100
+ </div>
101
+ <?php
102
+ wp_nonce_field( 'do_psp_404_actions', 'psp_404_actions_nonce' );
103
+ ?>
104
+ <div class="tablenav">
105
+ <div class="alignleft">
106
+ <div id="psp-select-div" class="alignleft">
107
+ <select id="psp_action" name="psp_action">
108
+ <?php
109
+ $dditems = array('' => 'Bulk Actions', 'addredirect' => 'Add Redirection', 'edit' => 'update Status', 'delete' => 'Delete Permanently', 'deleteall' => 'Delete All');
110
+ foreach($dditems as $key => $val) {
111
+ //$selected = (isset($_POST['psp_action']) && $_POST['psp_action']==$key) ? 'selected="selected"' : '';
112
+ $selected = '';
113
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
114
+ } ?>
115
+ </select>
116
+ </div>
117
+ <div id="psp-delete-div" class="hidden alignleft">
118
+ <input type="submit" value="<?php _e('Delete'); ?>" id="deleteit" name="deleteit" class="button-secondary delete" />
119
+ </div>
120
+ <div id="psp-status-div" class="hidden alignleft">
121
+ <select id="psp_status" name="psp_status">
122
+ <?php
123
+ $dditems = array('' => 'Leave it as 404', '410' => 'Change status to 410');
124
+ foreach($dditems as $key => $val) {
125
+ //$selected = (isset($_POST['psp_action']) && $_POST['psp_action']==$key) ? 'selected="selected"' : '';
126
+ $selected = '';
127
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
128
+ } ?>
129
+ </select>
130
+ </div>
131
+ <div id="updateit" class="alignleft hidden"><input type="submit" value="<?php _e('Update'); ?>" name="updateit" class="button-secondary update hidden" />
132
+ </div>
133
+ </div>
134
+ <script type="text/javascript">
135
+ <!--
136
+ function checkAll(form) {
137
+ for (i = 0, n = form.elements.length; i < n; i++) {
138
+ if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) {
139
+ if(form.elements[i].checked == true)
140
+ form.elements[i].checked = false;
141
+ else
142
+ form.elements[i].checked = true;
143
+ }
144
+ }
145
+ }
146
+ //-->
147
+ </script>
148
+ <?php
149
+ if ( $page_links )
150
+ echo "<div class='tablenav-pages alignright'>$page_links</div>";
151
+ ?>
152
+ </div>
153
+ <table class="widefat">
154
+ <thead>
155
+ <tr>
156
+ <th scope="col" class=""><input onclick="checkAll(document.getElementById('psp-edit'));" type="checkbox"></th>
157
+ <th scope="col">ID</th>
158
+ <th scope="col">Request Path(Name)</th>
159
+ <th scope="col">Status</th>
160
+ <th scope="col">Referrer</th>
161
+ <th scope="col">Hits</th>
162
+ <th scope="col">IP Address</th>
163
+ <th scope="col">More</th>
164
+ </tr>
165
+ </thead>
166
+ <?php
167
+ if(count($bad_links) > 0) { ?>
168
+ <tbody>
169
+ <?php
170
+ $bgcolor = '';
171
+ //$class = 'alternate' == $class ? '' : 'alternate';
172
+ $class = 'alternate';
173
+ foreach($bad_links as $bad_link){
174
+
175
+ $post_psp_id = sanitize_key($bad_link->psp_id);
176
+ $class = 'alternate' == $class ? '' : 'alternate';
177
+ ?>
178
+ <tr class="<?php echo trim( esc_attr($class) . ' author-self status-publish'); ?>" valign="top">
179
+ <th scope="row" class=""><?php if ( current_user_can( 'edit_posts', $post_psp_id ) ) { ?><input type="checkbox" name="update[]" value="<?php echo esc_attr($post_psp_id); ?>" /><input type="hidden" id="<?php echo "psp-".esc_attr($post_psp_id); ?>" name="<?php echo "psp-".esc_attr($post_psp_id); ?>" value="<?php echo esc_attr($bad_link->psp_post_name); ?>" /><?php } ?></th>
180
+ <td><a href="<?php echo esc_url_raw($bad_link->psp_rel_url); ?>" target="_blank"><?php echo esc_attr($post_psp_id); ?></a></td>
181
+ <td><?php echo esc_attr($bad_link->psp_post_name); ?><div class="create-div"><div class="uri hidden"><?php echo esc_attr($bad_link->psp_post_name); ?></div><a href="#" title="<?php echo esc_attr($post_psp_id); ?>" class="create"><?php echo "Create Redirection"; ?></a></div></td>
182
+ <td><?php echo empty($bad_link->status) ? '404' : esc_html($bad_link->status); ?></td>
183
+ <td><?php echo !empty($bad_link->referrer) ? esc_html($bad_link->referrer) : ''; ?></td>
184
+ <td><?php echo !empty($bad_link->total_hits) ? esc_html($bad_link->total_hits) : ''; ?></td>
185
+ <td><?php echo !empty($bad_link->ipaddress) ? esc_html($bad_link->ipaddress) : ''; ?></td>
186
+ <td><a href="#.more" class="more button"><?php echo "..."; ?></a></td>
187
+ </tr><tr class="moretr hidden"><td colspan="7">
188
+ <div id="more-<?php echo esc_attr($bad_link->psp_id); ?>" class="alignleft">
189
+ <div class="alignleft"><b>Request URL: </b><?php echo !empty($bad_link->psp_rel_url) ? esc_html($bad_link->psp_rel_url) : ''; ?></div><br class="clear" />
190
+ <div class="alignleft"><b>IP address: </b><?php echo !empty($bad_link->ipaddress) ? esc_html($bad_link->ipaddress) : ''; ?></div><br class="clear" />
191
+ <div class="alignleft"><b>User Agent: </b><?php echo !empty($bad_link->user_agent) ? esc_html($bad_link->user_agent) : ''; ?></div><br class="clear" />
192
+ <div class="alignleft"><b>Created: </b><?php echo !empty($bad_link->created) ? esc_html($bad_link->created) : ''; ?></div><br class="clear" />
193
+ <div class="alignleft"><b>Last Logged: </b><?php echo !empty($bad_link->last_logged) ? esc_html($bad_link->last_logged) :''; ?></div>
194
+ <div id="cancelmore-div" class="alignright"><input type="reset" value="<?php _e('Cancel'); ?>" name="cancelmore" id="cancelmore" class="button-secondary update hidden" />
195
+ </div>
196
+ </div></td>
197
+ </tr>
198
+ <?php } ?>
199
+ </tbody>
200
+ <?php } ?>
201
+ </table>
202
+ </form>
203
+
204
+ <div class="tablenav top">
205
+
206
+ <?php
207
+ if ( $page_links )
208
+ echo "<div class='tablenav-pages'>$page_links</div>";
209
+ ?>
210
+
211
+ </div>
212
+
213
+ <br class="clear" />
214
+
215
+ </div>
psp-include/settings/psp_advanced_metabox_renderer.php CHANGED
@@ -55,7 +55,7 @@ Author URI: https://techblissonline.com/
55
  <tr class="form-field">
56
  <th style="width:20%;" scope="row" valign="top"><label for="psp_seo_meta[maxvideo]"><?php esc_html_e('Max Video Preview: ', 'platinum-seo-pack'); ?></label></th>
57
  <td><input style="width:15%;" type="number" min="-1" name="psp_seo_meta[maxvideo]" id="psp_seo_meta[maxvideo]" size="3" maxlength="3" value="<?php echo ( isset($psp_seo_meta['maxvideo']) ? ($psp_seo_meta['maxvideo'] == 'zero' ? 0 : esc_attr($psp_seo_meta['maxvideo'])) : ''); ?>" /><?php esc_html_e(' Seconds. [Optional]', 'platinum-seo-pack'); ?><br />
58
- <p class="description"><?php echo esc_html__('Set max video preview length directive to Google for this post/page.', 'platinum-seo-pack').' <a href="https://techblissonline.com/" target="_blank">'.esc_html__('Read more', 'platinum-seo-pack').'...</a>'; ?></p>
59
  </td>
60
  </tr>
61
  <tr class="form-field">
@@ -85,9 +85,9 @@ Author URI: https://techblissonline.com/
85
  </td>
86
  </tr>
87
  <tr class="form-field">
88
- <th style="width:20%;" scope="row" valign="top"><label for="psp_seo_meta[schema_string]"><?php esc_html_e('JSON_LD Schema String: ', 'platinum-seo-pack'); ?></label><br /><br /><i><a class="permalink" id="schemagenerator" href="https://techblissonline.com/tools/json-schema-generator/" target="_blank"><?php esc_html_e('Techblissonline Json Schema Generator Tool', 'platinum-seo-pack'); ?></a></i><br /><br /><i><a class="permalink" id="joinschemas" href="https://techblissonline.com/combine-json-schema/" target="_blank"><?php esc_html_e('How to combine several Json schema?', 'platinum-seo-pack'); ?></a></i></th>
89
  <td><div class='pspeditor'><textarea name="psp_seo_meta[schema_string]" id="psp_seo_meta[schema_string]" class="pspjsoneditor"><?php echo ( isset($psp_seo_meta['schema_string']) ? (esc_textarea(stripcslashes($psp_seo_meta['schema_string']))) : ' '); ?></textarea></div><br />
90
- <p class="description"><?php echo esc_html__('Set JSON_LD Schema String (without the script tag) for this post/page. Use', 'platinum-seo-pack').' <a href="https://techblissonline.com/tools/schema-markup-generator/" target="_blank">'.esc_html__('Techblissonline Schema Generator Tool', 'platinum-seo-pack').'</a>'; ?></p>
91
  </td>
92
  </tr>
93
 
@@ -102,7 +102,7 @@ Author URI: https://techblissonline.com/
102
  </td>
103
  </tr>
104
  <tr class="form-field">
105
- <th style="width:20%;" scope="row" valign="top"><label for="psp_seo_meta[redirect_status_code]"><?php esc_html_e('Use: ', 'platinum-seo-pack'); ?></label></th>
106
  <td><select id="psp_seo_meta[redirect_status_code]" name="psp_seo_meta[redirect_status_code]"><?php $dditems = array('' => 'Select a redirection method', '301' => '301 Moved Permanently', '302' => '302 Found', '303' => '303 See Other', '307' => '307 Temporary Redirect');
107
  foreach($dditems as $key => $val) {
108
  $selected = (isset($psp_seo_meta['redirect_status_code']) && $psp_seo_meta['redirect_status_code']==$key) ? 'selected="selected"' : '';
55
  <tr class="form-field">
56
  <th style="width:20%;" scope="row" valign="top"><label for="psp_seo_meta[maxvideo]"><?php esc_html_e('Max Video Preview: ', 'platinum-seo-pack'); ?></label></th>
57
  <td><input style="width:15%;" type="number" min="-1" name="psp_seo_meta[maxvideo]" id="psp_seo_meta[maxvideo]" size="3" maxlength="3" value="<?php echo ( isset($psp_seo_meta['maxvideo']) ? ($psp_seo_meta['maxvideo'] == 'zero' ? 0 : esc_attr($psp_seo_meta['maxvideo'])) : ''); ?>" /><?php esc_html_e(' Seconds. [Optional]', 'platinum-seo-pack'); ?><br />
58
+ <p class="description"><?php echo esc_html__('Set max video preview length directive to Google for this post/page.', 'platinum-seo-pack').' <a href="https://techblissonline.com/" target="_blank" rel="noopener">'.esc_html__('Read more', 'platinum-seo-pack').'...</a>'; ?></p>
59
  </td>
60
  </tr>
61
  <tr class="form-field">
85
  </td>
86
  </tr>
87
  <tr class="form-field">
88
+ <th style="width:20%;" scope="row" valign="top"><label for="psp_seo_meta[schema_string]"><?php esc_html_e('JSON_LD Schema String: ', 'platinum-seo-pack'); ?></label><br /><br /><i><a class="permalink" id="schemagenerator" href="https://techblissonline.com/tools/json-schema-generator/" target="_blank" rel="noopener"><?php esc_html_e('Techblissonline Json Schema Generator Tool', 'platinum-seo-pack'); ?></a></i><br /><br /><i><a class="permalink" id="joinschemas" href="https://techblissonline.com/combine-json-schema/" target="_blank" rel="noopener"><?php esc_html_e('How to combine several Json schema?', 'platinum-seo-pack'); ?></a></i></th>
89
  <td><div class='pspeditor'><textarea name="psp_seo_meta[schema_string]" id="psp_seo_meta[schema_string]" class="pspjsoneditor"><?php echo ( isset($psp_seo_meta['schema_string']) ? (esc_textarea(stripcslashes($psp_seo_meta['schema_string']))) : ' '); ?></textarea></div><br />
90
+ <p class="description"><?php echo esc_html__('Set JSON_LD Schema String (without the script tag) for this post/page. Use', 'platinum-seo-pack').' <a href="https://techblissonline.com/tools/json-schema-generator/" target="_blank" rel="noopener">'.esc_html__('Techblissonline Schema Generator Tool', 'platinum-seo-pack').'</a>'; ?></p>
91
  </td>
92
  </tr>
93
 
102
  </td>
103
  </tr>
104
  <tr class="form-field">
105
+ <th style="width:20%;" scope="row" valign="top"><label for="psp_seo_meta[redirect_status_code]"><?php echo esc_html__('Use: ', 'platinum-seo-pack').'<br>'.'<a href="https://techblissonline.com/http-redirection-status-codes-301-302-307-308/" target="_blank" rel="noopener">'.esc_html__('What to Select?', 'platinum-seo-pack').'</a>'; ?></label></th>
106
  <td><select id="psp_seo_meta[redirect_status_code]" name="psp_seo_meta[redirect_status_code]"><?php $dditems = array('' => 'Select a redirection method', '301' => '301 Moved Permanently', '302' => '302 Found', '303' => '303 See Other', '307' => '307 Temporary Redirect');
107
  foreach($dditems as $key => $val) {
108
  $selected = (isset($psp_seo_meta['redirect_status_code']) && $psp_seo_meta['redirect_status_code']==$key) ? 'selected="selected"' : '';
psp-include/settings/psp_redirect_404.php ADDED
@@ -0,0 +1,1034 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Platinum SEO Pack
4
+ Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
5
+ Author: Rajesh - Techblissonline
6
+ Author URI: http://techblissonline.com/
7
+ */
8
+ class PspRedirections {
9
+
10
+ private static $obj_handle = null;
11
+
12
+ protected $psp_helper;
13
+
14
+ public static function get_instance() {
15
+
16
+ if ( null == self::$obj_handle ) {
17
+ self::$obj_handle = new self;
18
+ }
19
+
20
+ return self::$obj_handle;
21
+
22
+ } // end get_instance;
23
+ //can be made private for singleton pattern
24
+ public function __construct() {
25
+
26
+ $psp_helper_instance = PspHelper::get_instance();
27
+ $this->psp_helper = $psp_helper_instance;
28
+
29
+ add_action('admin_menu', array(&$this, 'psp_redirect_admin_menu'));
30
+
31
+ add_filter('set-screen-option', array(&$this, 'psp_set_screen_option'), 10, 3);
32
+
33
+ }
34
+
35
+ public function psp_redirect_admin_menu() {
36
+
37
+ $psp_redir_page = add_management_page('Redirection Manager', 'Platinum SEO Redirections Manager', 'manage_options', 'redirectionmanager', array($this, 'redir_mgmtpage'));
38
+ $psp_redir_page_2 = 'platinum-seo-and-social-pack_page_redirectionmanager';
39
+ //error_log('redir '. $psp_redir_page);
40
+
41
+ add_action("load-$psp_redir_page", array($this, 'psp_screen_options'));
42
+ add_action("load-$psp_redir_page_2", array($this, 'psp_screen_options'));
43
+
44
+ $psp_404_page = add_management_page('404 Manager', 'Platinum SEO 404 Manager', 'manage_options', 'manager404', array($this, 'manage_404_page'));
45
+ $psp_404_page_2 = 'platinum-seo-and-social-pack_page_manager404';
46
+
47
+ add_action("load-$psp_404_page", array($this, 'psp_screen_options'));
48
+ add_action("load-$psp_404_page_2", array($this, 'psp_screen_options'));
49
+ add_filter("manage_".$psp_redir_page."_columns", array($this, 'psp_screen_column_options'));
50
+ add_filter("manage_".$psp_redir_page_2."_columns", array($this, 'psp_screen_column_options'));
51
+
52
+ }
53
+
54
+ public function psp_screen_options() {
55
+
56
+ $psp_404_page = "tools_page_manager404";
57
+ $psp_404_page_2 = 'platinum-seo-and-social-pack_page_manager404';
58
+ $psp_redir_page = "tools_page_redirectionmanager";
59
+ $psp_redir_page_2 = "platinum-seo-and-social-pack_page_redirectionmanager";
60
+
61
+ $screen = get_current_screen();
62
+
63
+ //error_log($screen->id);
64
+
65
+ // get out of here if we are not on our settings page
66
+ if(!is_object($screen) || ($screen->id != $psp_redir_page_2 && $screen->id != $psp_redir_page && $screen->id != $psp_404_page && $screen->id != $psp_404_page_2))
67
+ {
68
+ return;
69
+ }
70
+ if ($screen->id == $psp_redir_page_2 || $screen->id == $psp_redir_page) {
71
+ $redir_args = array(
72
+ 'label' => __('Rows per page'),
73
+ 'default' => 10,
74
+ 'option' => 'psp_redir_rows_per_page'
75
+ );
76
+ add_screen_option( 'per_page', $redir_args );
77
+ }
78
+
79
+ if ($screen->id == $psp_404_page || $screen->id == $psp_404_page_2) {
80
+ $filter_args = array(
81
+ 'label' => __('Rows per page'),
82
+ 'default' => 10,
83
+ 'option' => 'psp_filter_rows_per_page'
84
+ );
85
+ add_screen_option( 'per_page', $filter_args );
86
+ }
87
+ }
88
+
89
+ public function psp_screen_column_options() {
90
+
91
+ $psp_404_page = "tools_page_manager404";
92
+ $psp_404_page_2 = 'platinum-seo-and-social-pack_page_manager404';
93
+ $psp_redir_page = "tools_page_redirectionmanager";
94
+ $psp_redir_page_2 = "platinum-seo-and-social-pack_page_redirectionmanager";
95
+
96
+ $screen = get_current_screen();
97
+
98
+ //error_log($screen->id);
99
+
100
+ // get out of here if we are not on our settings page
101
+ if(!is_object($screen) || ($screen->id != $psp_redir_page_2 && $screen->id != $psp_redir_page && $screen->id != $psp_404_page && $screen->id != $psp_404_page_2))
102
+ {
103
+ return;
104
+ }
105
+
106
+ $psp_redir_type = isset($_GET['psp_redir_type']) ? sanitize_key($_GET['psp_redir_type']) : '';
107
+
108
+ if ($psp_redir_type != "psplogs") {
109
+ return;
110
+ }
111
+
112
+ if ($screen->id == $psp_redir_page_2 || $screen->id == $psp_redir_page) {
113
+ $columns = array('ipaddress' => 'IP Address', 'useragent' => 'User Agent','referrer' => 'Referrer');
114
+ return $columns;
115
+
116
+ }
117
+ }
118
+
119
+ public function psp_set_screen_option($status, $option, $value) {
120
+
121
+ //error_log('option '.$option.' '.$status.' '.$value);
122
+
123
+ if ( 'psp_redir_rows_per_page' == $option || 'psp_filter_rows_per_page' == $option) {
124
+ //error_log("psp rows ".$value);
125
+ return sanitize_key($value);
126
+ }
127
+ }
128
+
129
+ public function manage_404_page() {
130
+
131
+ global $wpdb;
132
+
133
+ $psp_redirections_tbl = $wpdb->prefix . "psp_redirections";
134
+ $psp_404_log = $wpdb->prefix . "psp_404_log";
135
+
136
+ $posts_list = array();
137
+ $sql_posts = '';
138
+ $bad_links = array();
139
+ $sql_posts_1 = '';
140
+ $sql_posts_2 = '';
141
+ $psp_404_type = isset($_GET['psp_404_type']) ? sanitize_key($_GET['psp_404_type']) : '';
142
+
143
+ //handle single addnew
144
+ if ( isset($_POST['insertit']) && !empty($_POST['source-url-input']) && !empty($_POST['id-input']) )
145
+ {
146
+ if (isset( $_POST['psp_404_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_404_actions_nonce']), 'do_psp_404_actions' )) {
147
+
148
+ $psp_id = isset($_POST['id-input']) ? sanitize_key($_POST['id-input']) : '';
149
+ $psp_source_url = isset($_POST['source-url-input']) ? sanitize_text_field(html_entity_decode($_POST['source-url-input'])) : '';
150
+ $psp_redirect_to = isset($_POST['redirect-url-input']) ? esc_url_raw(html_entity_decode($_POST['redirect-url-input'])) : '';
151
+ $psp_redirect_code = isset($_POST['psp-redirect-code']) ? sanitize_key($_POST['psp-redirect-code']) : '';
152
+
153
+ if ($psp_action == 'addredirect' && !empty($psp_source_url) && !empty($psp_redirect_to) && !empty($psp_redirect_code)) {
154
+ //Add new redirect
155
+ if (!empty($psp_source_url)) $pspinsert['source_url'] = $psp_source_url;
156
+ if (!empty($psp_redirect_to)) $pspinsert['dest_url'] = $psp_redirect_to;
157
+ if (!empty($psp_redirect_code)) $pspinsert['redir_code'] = $psp_redirect_code;
158
+
159
+ //insert into $psp_redirections_tbl
160
+ $wpdb->insert( $psp_redirections_tbl, $pspinsert );
161
+ //delete from $psp_404_log
162
+ $wpdb->delete( $psp_404_log, array( 'id' => $psp_id ) );
163
+ }
164
+
165
+ }
166
+
167
+ }
168
+
169
+ //handle bulk addnew
170
+ if ( isset($_POST['insertit']) && isset($_POST['update']) )
171
+ {
172
+
173
+ if (isset( $_POST['psp_404_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_404_actions_nonce']), 'do_psp_404_actions' )) {
174
+
175
+ foreach( (array) $_POST['update'] as $psp_id ) {
176
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
177
+ $psp_id = sanitize_key($psp_id);
178
+
179
+ //$psp_source_url = isset($_POST['source-url-input']) ? esc_url_raw(html_entity_decode($_POST['source-url-input'])) : '';
180
+ $psp_source_url = isset($_POST["psp-".$psp_id]) ? sanitize_text_field(html_entity_decode($_POST["psp-".$psp_id])) : '';
181
+ $psp_redirect_to = isset($_POST['redirect-url-input']) ? esc_url_raw(html_entity_decode($_POST['redirect-url-input'])) : '';
182
+ $psp_redirect_code = isset($_POST['psp-redirect-code']) ? sanitize_key($_POST['psp-redirect-code']) : '';
183
+
184
+ if ($psp_action == 'addredirect' && !empty($psp_source_url) && !empty($psp_redirect_to) && !empty($psp_redirect_code)) {
185
+ //Add new redirect
186
+ if (!empty($psp_source_url)) $pspinsert['source_url'] = $psp_source_url;
187
+ if (!empty($psp_redirect_to)) $pspinsert['dest_url'] = $psp_redirect_to;
188
+ if (!empty($psp_redirect_code)) $pspinsert['redir_code'] = $psp_redirect_code;
189
+
190
+ //insert into $psp_redirections_tbl
191
+ $wpdb->insert( $psp_redirections_tbl, $pspinsert );
192
+ //delete from $psp_404_log
193
+ $wpdb->delete( $psp_404_log, array( 'id' => $psp_id ) );
194
+ }
195
+ }
196
+
197
+ }
198
+ }
199
+
200
+ // Handle bulk deletes
201
+ if ( isset($_POST['deleteit']) && isset($_POST['update']) ) {
202
+
203
+ if (isset( $_POST['psp_404_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_404_actions_nonce']), 'do_psp_404_actions' )) {
204
+
205
+ foreach( (array) $_POST['update'] as $psp_id ) {
206
+
207
+ $psp_id = sanitize_key($psp_id);
208
+
209
+ if ( !current_user_can('edit_posts', $psp_id) )
210
+ wp_die( __('You are not allowed to Delete.') );
211
+
212
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
213
+
214
+ //Delete SQL here
215
+
216
+ if($wpdb->get_var("show tables like '$psp_404_log'") == $psp_404_log && $psp_action == 'delete')
217
+ {
218
+ //delete from $psp_404_log
219
+ $wpdb->delete( $psp_404_log, array( 'id' => $psp_id ) );
220
+ }
221
+
222
+ }
223
+
224
+ }
225
+ }
226
+
227
+ // Handle delete all
228
+ if ( isset($_POST['deleteit']) && isset( $_POST['psp_404_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_404_actions_nonce']), 'do_psp_404_actions' ) ) {
229
+
230
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
231
+
232
+ if ($psp_action == 'deleteall') {
233
+
234
+ if ( !current_user_can('edit_posts') )
235
+ wp_die( __('You are not allowed to Truncate.') );
236
+
237
+ if($wpdb->get_var("show tables like '$psp_404_log'") == $psp_404_log)
238
+ {
239
+ //delete all from $psp_redirections_log
240
+ $deleteall = $wpdb->query("TRUNCATE TABLE $psp_404_log");
241
+ }
242
+
243
+ }
244
+
245
+ }
246
+
247
+ //Handle bulk update
248
+ if ( isset($_POST['updateit']) && isset($_POST['update']) ) {
249
+
250
+ if (isset( $_POST['psp_404_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_404_actions_nonce']), 'do_psp_404_actions' )) {
251
+
252
+ foreach( (array) $_POST['update'] as $psp_id ) {
253
+
254
+ $psp_id = sanitize_key($psp_id);
255
+
256
+ if ( !current_user_can('edit_posts', $psp_id) )
257
+ wp_die( __('You are not allowed to update.') );
258
+
259
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
260
+
261
+ //$psp_redirect_to = isset($_POST['redirect-url-input']) ? esc_url_raw(html_entity_decode($_POST['redirect-url-input'])) : '';
262
+ //$psp_source_url = isset($_POST['source-url-input']) ? esc_url_raw(html_entity_decode($_POST['source-url-input'])) : '';
263
+ //$psp_redirect_code = isset($_POST['psp-redirect-code']) ? sanitize_key($_POST['psp-redirect-code']) : '';
264
+ $psp_status = isset($_POST['psp_status']) ? sanitize_key($_POST['psp_status']) : '';
265
+
266
+ //update status to 410 instead of 404
267
+ if($wpdb->get_var("show tables like '$psp_404_log'") == $psp_404_log && $psp_action == 'edit') {
268
+ //update $psp_404_log
269
+ $pspupdate = array();
270
+ $pspupdate['status'] = $psp_status;
271
+ $pspupdate['total_hits'] = 1; //reinitialize for 410
272
+ $wpdb->update( $psp_404_log, $pspupdate, array( 'id' => $psp_id ) );
273
+ }
274
+ }
275
+
276
+ }
277
+ }
278
+
279
+ //Handle search
280
+ if ( !empty($_GET['psp_filter']) && !empty($_GET['post-search-input']) ) {
281
+
282
+ if (!empty($_GET['post-search-input'])) {
283
+
284
+ $psp_search = sanitize_title($_GET['post-search-input']);
285
+
286
+ if ($_GET['psp_filter'] == "contains") {
287
+
288
+ $psp_like = '%'.$wpdb->esc_like($psp_search).'%';
289
+ //$psp_like = '%'. $psp_search.'%';
290
+
291
+ }
292
+
293
+ if ($_GET['psp_filter'] == "starts-with") {
294
+
295
+ $psp_like = $wpdb->esc_like($psp_search).'%';
296
+ }
297
+
298
+ if ($_GET['psp_filter'] == "ends-with") {
299
+
300
+ $psp_like = '%'.$wpdb->esc_like($psp_search);
301
+
302
+ }
303
+
304
+ if ($_GET['psp_filter'] == "equals") {
305
+
306
+ $psp_like = "equals";
307
+ }
308
+
309
+ }
310
+
311
+ if (!empty($psp_like)) {
312
+ //$sql_posts = $wpdb->prepare("SELECT a.ID AS psp_id, a.post_name AS psp_post_name, b.meta_value AS psp_redirect, c. meta_value AS psp_redirect_code FROM $tbl_posts a, $tbl_postmeta b, $tbl_postmeta c WHERE a.post_name LIKE %s AND a.ID = b.post_id AND a.ID = c.post_id AND (b.meta_key='_techblissonline_psp_redirect_to_url' or 1=1) AND (c.meta_key='_techblissonline_psp_redirect_status_code' or 1=1)", $psp_like );
313
+ if (empty($psp_404_type)) {
314
+ $sql_posts_2 = $wpdb->prepare("SELECT a.ID AS psp_id, a.source_uri AS psp_post_name, a.source_url AS psp_rel_url, a.referrer as referrer, a.status as status, a.user_agent as user_agent, a.ipaddress as ipaddress, a.total_hits as total_hits, a.last_logged as last_logged, a.created as created FROM $psp_404_log a WHERE a.source_uri LIKE %s", $psp_like );
315
+ if ($psp_like == "equals") {
316
+ $sql_posts_2 = $wpdb->prepare("SELECT a.ID AS psp_id, a.source_uri AS psp_post_name, a.source_url AS psp_rel_url, a.referrer as referrer, a.status as status, a.user_agent as user_agent, a.ipaddress as ipaddress, a.total_hits as total_hits, a.last_logged as last_logged, a.created as created FROM $psp_404_log a WHERE a.source_uri = %s", $psp_search );
317
+ }
318
+ } else {
319
+ if ($psp_404_type == "all_404") $psp_where = "status = '' and ";
320
+ if ($psp_404_type == "all_410") $psp_where = "status = '410' and ";
321
+ if ($psp_404_type == "all_404_with_referrers") $psp_where = "status = '' and referrer != '' and ";
322
+ if ($psp_404_type == "all_410_with_referrers") $psp_where = "status = '410' and referrer != '' and ";
323
+ if ($psp_404_type == "all_with_referrers") $psp_where = "referrer != '' and ";
324
+
325
+ $sql_posts_2 = $wpdb->prepare("SELECT a.ID AS psp_id, a.source_uri AS psp_post_name, a.source_url AS psp_rel_url, a.referrer as referrer, a.status as status, a.user_agent as user_agent, a.ipaddress as ipaddress, a.total_hits as total_hits, a.last_logged as last_logged, a.created as created FROM $psp_404_log a WHERE $psp_where a.source_url LIKE %s", $psp_like );
326
+ if ($psp_like == "equals") {
327
+
328
+ $sql_posts_2 = $wpdb->prepare("SELECT a.ID AS psp_id, a.source_uri AS psp_post_name, a.source_url AS psp_rel_url, a.referrer as referrer, a.status as status, a.user_agent as user_agent, a.ipaddress as ipaddress, a.total_hits as total_hits, a.last_logged as last_logged,a.created as created FROM $psp_404_log a WHERE $psp_where a.source_url = %s", $psp_search );
329
+
330
+ }
331
+
332
+ }
333
+ //error_log($sql_posts_2);
334
+ $posts_list = $wpdb->get_results($sql_posts_2, OBJECT);
335
+
336
+ }
337
+
338
+ } else if ( empty($_GET['psp_filter']) ) {
339
+
340
+ if ($psp_404_type == "") $psp_where = " ";
341
+ if ($psp_404_type == "all_404") $psp_where = "where status = '' ";
342
+ if ($psp_404_type == "all_410") $psp_where = "where status = '410' ";
343
+ if ($psp_404_type == "all_404_with_referrers") $psp_where = "where status = '' and referrer != '' ";
344
+ if ($psp_404_type == "all_410_with_referrers") $psp_where = "where status = '410' and referrer != '' ";
345
+ if ($psp_404_type == "all_with_referrers") $psp_where = "where referrer != '' ";
346
+
347
+ $sql_posts_1 = "SELECT a.ID AS psp_id, a.source_uri AS psp_post_name, a.source_url AS psp_rel_url, a.referrer as referrer, a.status as status, a.user_agent as user_agent, a.ipaddress as ipaddress, a.total_hits as total_hits, a.last_logged as last_logged, a.created as created FROM $psp_404_log a $psp_where";
348
+
349
+ $posts_list = $wpdb->get_results($sql_posts_1, OBJECT);
350
+ }
351
+
352
+ $total_no_posts = count($posts_list);
353
+ $max_posts_per_page = 10;
354
+ $user = get_current_user_id();
355
+ $screen = get_current_screen();
356
+ // retrieve the "per_page" option
357
+ $screen_option = $screen->get_option('per_page', 'option');
358
+ // retrieve the value of the option stored for the current user
359
+ //error_log('screen option '.$screen_option);
360
+ $max_posts_per_page = get_user_meta($user, $screen_option, true);
361
+
362
+ if ( empty ( $max_posts_per_page) || $max_posts_per_page < 1 ) {
363
+ // get the default value if none is set
364
+ $max_posts_per_page = $screen->get_option( 'per_page', 'default' );
365
+ }
366
+
367
+
368
+
369
+ $link_count = ceil($total_no_posts/$max_posts_per_page);
370
+ $page_no = isset( $_GET['paged'] ) ? sanitize_key( $_GET['paged'] ) : 1;
371
+
372
+ $limit_sql = ' LIMIT '.(($page_no - 1) * $max_posts_per_page).', '.$max_posts_per_page;
373
+ //if($sql_posts != '') $sql_posts .= $limit_sql;
374
+ if($sql_posts_1 != '') $sql_posts = $sql_posts_1 . $limit_sql;
375
+ if($sql_posts_2 != '') $sql_posts = $sql_posts_2 . $limit_sql;
376
+
377
+ if($sql_posts != '') $bad_links = $wpdb->get_results( $sql_posts );
378
+ //if($sql_posts_2 != '') $bad_links_2 = $wpdb->get_results( $sql_posts_2 );
379
+
380
+ $page_links = paginate_links( array(
381
+ 'base' => add_query_arg( 'paged', '%#%' ),
382
+ 'format' => '',
383
+ 'total' => ceil($total_no_posts/$max_posts_per_page),
384
+ 'current' => $page_no
385
+ ));
386
+
387
+ include_once( 'psp_404_list_renderer.php' );
388
+ }
389
+
390
+ public function redir_mgmtpage() {
391
+
392
+ global $wpdb;
393
+ //$psp_bad_links_table = $this->psp_bad_links_table;
394
+
395
+ $tbl_posts = $wpdb->prefix . "posts";
396
+ $tbl_postmeta = $wpdb->prefix . "postmeta";
397
+ $psp_redirections_tbl = $wpdb->prefix . "psp_redirections";
398
+ $psp_redirections_log = $wpdb->prefix . "psp_redirections_log";
399
+
400
+ $posts_list = array();
401
+ $sql_posts = '';
402
+ $bad_links = array();
403
+ $sql_posts_1 = '';
404
+ $sql_posts_2 = '';
405
+ $psp_redir_type = isset($_GET['psp_redir_type']) ? sanitize_key($_GET['psp_redir_type']) : '';
406
+
407
+ //handle addnew
408
+ if ( isset($_POST['insertit']) && !empty($psp_redir_type) ) {
409
+
410
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
411
+
412
+ $psp_source_url = isset($_POST['source-url-input']) ? sanitize_text_field(html_entity_decode($_POST['source-url-input'])) : '';
413
+ $psp_redirect_to = isset($_POST['redirect-url-input']) ? esc_url_raw(html_entity_decode($_POST['redirect-url-input'])) : '';
414
+ $psp_redirect_code = isset($_POST['psp-redirect-code']) ? sanitize_key($_POST['psp-redirect-code']) : '';
415
+ $psp_log = isset($_POST['psplog']) ? sanitize_key($_POST['psplog']) : '';
416
+
417
+ if (!empty($psp_redir_type) && isset( $_POST['psp_urls_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_urls_redirect_actions_nonce']), 'do_psp_urls_redirect_actions' )) {
418
+
419
+ if ($psp_action == 'addnew' && !empty($psp_source_url) && !empty($psp_redirect_to) && !empty($psp_redirect_code)) {
420
+ //Add new
421
+ if (!empty($psp_source_url)) $pspinsert['source_url'] = $psp_source_url;
422
+ if (!empty($psp_redirect_to)) $pspinsert['dest_url'] = $psp_redirect_to;
423
+ if (!empty($psp_redirect_code)) $pspinsert['redir_code'] = $psp_redirect_code;
424
+ if (!empty($psp_log)) $pspinsert['log_redirect'] = $psp_log;
425
+
426
+ $wpdb->insert( $psp_redirections_tbl, $pspinsert );
427
+ }
428
+ }
429
+ }
430
+
431
+ // Handle bulk deletes
432
+ if ( isset($_POST['deleteit']) && isset($_POST['update']) ) {
433
+
434
+ foreach( (array) $_POST['update'] as $psp_id ) {
435
+
436
+ $psp_id = sanitize_key($psp_id);
437
+ if ( !current_user_can('edit_posts', $psp_id) )
438
+ wp_die( __('You are not allowed to Delete.') );
439
+
440
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
441
+
442
+ //$psp_redirect_to = isset($_POST['redirect-url-input']) ? esc_url_raw($_POST['redirect-url-input']) : '';
443
+ //$psp_redirect_code = isset($_POST['psp-redirect-code']) ? sanitize_key($_POST['psp-redirect-code']) : '';
444
+
445
+ //Delete SQL here
446
+
447
+ if (empty($psp_redir_type) && isset( $_POST['psp_posts_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_posts_redirect_actions_nonce']), 'do_psp_posts_redirect_actions' )) {
448
+ if ($psp_action == 'delete' && !empty($psp_id) ) {
449
+ delete_post_meta( $psp_id, '_techblissonline_psp_redirect_to_url');
450
+ delete_post_meta( $psp_id, '_techblissonline_psp_redirect_status_code');
451
+ }
452
+ } else {
453
+
454
+ if ($psp_redir_type == "pspurls" && isset( $_POST['psp_urls_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_urls_redirect_actions_nonce']), 'do_psp_urls_redirect_actions' )) {
455
+
456
+ if($wpdb->get_var("show tables like '$psp_redirections_tbl'") == $psp_redirections_tbl && $psp_action == 'delete')
457
+ {
458
+ //delete from $psp_redirections_tbl
459
+ $wpdb->delete( $psp_redirections_tbl, array( 'id' => $psp_id ) );
460
+
461
+ }
462
+
463
+ } else if ($psp_redir_type == "psplogs" && isset( $_POST['psp_logs_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_logs_redirect_actions_nonce']), 'do_psp_logs_redirect_actions' )) {
464
+
465
+ if($wpdb->get_var("show tables like '$psp_redirections_log'") == $psp_redirections_log && $psp_action == 'delete')
466
+ {
467
+ //delete from $psp_redirections_log
468
+ $wpdb->delete( $psp_redirections_log, array( 'id' => $psp_id ) );
469
+ }
470
+
471
+ }
472
+ }
473
+
474
+ }
475
+ }
476
+
477
+ // Handle delete all
478
+ if ( isset($_POST['deleteit']) ) {
479
+
480
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
481
+
482
+ if ($psp_action == 'deleteall' && $psp_redir_type == "psplogs" && isset( $_POST['psp_logs_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_logs_redirect_actions_nonce']), 'do_psp_logs_redirect_actions' )) {
483
+
484
+ if ( !current_user_can('edit_posts') )
485
+ wp_die( __('You are not allowed to Truncate.') );
486
+
487
+ if($wpdb->get_var("show tables like '$psp_redirections_log'") == $psp_redirections_log)
488
+ {
489
+ //delete all from $psp_redirections_log
490
+ $deleteall = $wpdb->query("TRUNCATE TABLE $psp_redirections_log");
491
+ }
492
+
493
+ }
494
+
495
+ }
496
+
497
+ //Handle bulk update
498
+ if ( isset($_POST['updateit']) && isset($_POST['update']) ) {
499
+
500
+ foreach( (array) $_POST['update'] as $psp_id ) {
501
+
502
+ $psp_id = sanitize_key($psp_id);
503
+
504
+ if ( !current_user_can('edit_posts', $psp_id) )
505
+ wp_die( __('You are not allowed to update.') );
506
+
507
+ $psp_action = isset($_POST['psp_action']) ? sanitize_key($_POST['psp_action']) : '';
508
+
509
+ $psp_redirect_to = isset($_POST['redirect-url-input']) ? esc_url_raw(html_entity_decode($_POST['redirect-url-input'])) : '';
510
+ $psp_source_url = isset($_POST['source-url-input']) ? sanitize_text_field(html_entity_decode($_POST['source-url-input'])) : '';
511
+ $psp_redirect_code = isset($_POST['psp-redirect-code']) ? sanitize_key($_POST['psp-redirect-code']) : '';
512
+ $psp_log = isset($_POST['psplog']) ? sanitize_key($_POST['psplog']) : '';
513
+
514
+ //Update or Delete SQL here
515
+ if (empty($psp_redir_type) && isset( $_POST['psp_posts_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_posts_redirect_actions_nonce']), 'do_psp_posts_redirect_actions' )) {
516
+ if ($psp_action == 'edit' && !empty($psp_redirect_to) && !empty($psp_redirect_code)) {
517
+ update_post_meta( $psp_id, '_techblissonline_psp_redirect_to_url', $psp_redirect_to);
518
+ update_post_meta( $psp_id, '_techblissonline_psp_redirect_status_code', $psp_redirect_code);
519
+ }
520
+ } else if ($psp_redir_type == "pspurls" && isset( $_POST['psp_urls_redirect_actions_nonce'] ) && wp_verify_nonce( sanitize_key($_POST['psp_urls_redirect_actions_nonce']), 'do_psp_urls_redirect_actions' )) {
521
+ if($wpdb->get_var("show tables like '$psp_redirections_tbl'") == $psp_redirections_tbl && $psp_action == 'edit') {
522
+ //update $psp_redirections_tbl
523
+ $pspupdate = array();
524
+ if (!empty($psp_redirect_to)) $pspupdate['dest_url'] = $psp_redirect_to;
525
+ if (!empty($psp_redirect_code)) $pspupdate['redir_code'] = $psp_redirect_code;
526
+ //if (!empty($psp_log)) $pspupdate['log_redirect'] = $psp_log;
527
+ if (!empty($psp_source_url)) $pspupdate['source_url'] = $psp_source_url;
528
+ $pspupdate['log_redirect'] = !empty($psp_log) ? $psp_log : '';
529
+
530
+ $wpdb->update( $psp_redirections_tbl, $pspupdate, array( 'id' => $psp_id ) );
531
+ }
532
+ }
533
+
534
+ //$delete_bad_links = "Delete from $psp_bad_links_table where psp_id = '".$psp_id."'";
535
+ //$wpdb->query( $delete_bad_links );
536
+ }
537
+ }
538
+
539
+ //Handle search
540
+ if ( !empty($_GET['psp_filter']) && !empty($_GET['post-search-input']) ) {
541
+
542
+ if (!empty($_GET['post-search-input'])) {
543
+
544
+ $psp_search = sanitize_title($_GET['post-search-input']);
545
+
546
+ if ($_GET['psp_filter'] == "contains") {
547
+
548
+ $psp_like = '%'.$wpdb->esc_like($psp_search).'%';
549
+ //$psp_like = '%'. $psp_search.'%';
550
+
551
+ }
552
+
553
+ if ($_GET['psp_filter'] == "starts-with") {
554
+
555
+ $psp_like = $wpdb->esc_like($psp_search).'%';
556
+ }
557
+
558
+ if ($_GET['psp_filter'] == "ends-with") {
559
+
560
+ $psp_like = '%'.$wpdb->esc_like($psp_search);
561
+
562
+ }
563
+
564
+ if ($_GET['psp_filter'] == "equals") {
565
+
566
+ $psp_like = "equals";
567
+ }
568
+
569
+ }
570
+
571
+ if (!empty($psp_like)) {
572
+ //$sql_posts = $wpdb->prepare("SELECT a.ID AS psp_id, a.post_name AS psp_post_name, b.meta_value AS psp_redirect, c. meta_value AS psp_redirect_code FROM $tbl_posts a, $tbl_postmeta b, $tbl_postmeta c WHERE a.post_name LIKE %s AND a.ID = b.post_id AND a.ID = c.post_id AND (b.meta_key='_techblissonline_psp_redirect_to_url' or 1=1) AND (c.meta_key='_techblissonline_psp_redirect_status_code' or 1=1)", $psp_like );
573
+ if (empty($psp_redir_type)) {
574
+ $sql_posts_2 = $wpdb->prepare("SELECT a.ID AS psp_id, a.post_name AS psp_post_name FROM $tbl_posts a WHERE a.post_name LIKE %s", $psp_like );
575
+ if ($psp_like == "equals") {
576
+ $sql_posts_2 = $wpdb->prepare("SELECT a.ID AS psp_id, a.post_name AS psp_post_name FROM $tbl_posts a WHERE a.post_name = %s", $psp_search );
577
+ }
578
+ } else if($psp_redir_type == "pspurls") {
579
+ //$sql_posts_2 = $wpdb-prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code FROM %s a WHERE a.source_url LIKE %s", array( $psp_redirections_tbl, $psp_like ));
580
+ $sql_posts_2 = $wpdb->prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.log_redirect as psp_log FROM $psp_redirections_tbl a WHERE a.source_url LIKE %s", $psp_like );
581
+ if ($psp_like == "equals") {
582
+
583
+ $sql_posts_2 = $wpdb->prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.log_redirect as psp_log FROM $psp_redirections_tbl a WHERE a.source_url = %s", $psp_search );
584
+
585
+ }
586
+
587
+ } else if($psp_redir_type == "psplogs") {
588
+
589
+ $sql_posts_2 = $wpdb->prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.referrer as psp_referrer, a.ipaddress as psp_ipaddress, a.user_agent as psp_useragent FROM $psp_redirections_log a WHERE a.source_url LIKE %s", $psp_like );
590
+
591
+ if ($psp_like == "equals") {
592
+
593
+ $sql_posts_2 = $wpdb->prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.referrer as psp_referrer, a.ipaddress as psp_ipaddress, a.user_agent as psp_useragent FROM $psp_redirections_log a WHERE a.source_url = %s", $psp_search );
594
+
595
+ }
596
+
597
+ }
598
+ //error_log($sql_posts_2);
599
+ if (empty($psp_redir_type)) {
600
+ $posts_list = $wpdb->get_results($sql_posts_2, OBJECT);
601
+ } else {
602
+ if($psp_redir_type == "pspurls") {
603
+ if($wpdb->get_var("show tables like '$psp_redirections_tbl'") == $psp_redirections_tbl)
604
+ {
605
+ $posts_list = $wpdb->get_results($sql_posts_2, OBJECT);
606
+ }
607
+ } else if($psp_redir_type == "psplogs") {
608
+ if($wpdb->get_var("show tables like '$psp_redirections_log'") == $psp_redirections_log)
609
+ {
610
+ $posts_list = $wpdb->get_results($sql_posts_2, OBJECT);
611
+ }
612
+ }
613
+ }
614
+
615
+ }
616
+
617
+ } else if ( empty($_GET['psp_filter']) ) {
618
+
619
+ if (empty($psp_redir_type)) {
620
+
621
+ $sql_posts_1 = $wpdb->prepare("SELECT a.ID AS psp_id, a.post_name AS psp_post_name, b.meta_value AS psp_redirect, c. meta_value AS psp_redirect_code FROM $tbl_posts a, $tbl_postmeta b, $tbl_postmeta c WHERE a.ID = b.post_id AND a.ID = c.post_id AND (b.meta_key=%s) AND (c.meta_key=%s)", array('_techblissonline_psp_redirect_to_url', '_techblissonline_psp_redirect_status_code') );
622
+ } else {
623
+
624
+ if($psp_redir_type == "pspurls") {
625
+ $sql_posts_1 = "SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.log_redirect as psp_log FROM $psp_redirections_tbl a";
626
+ } else if($psp_redir_type == "psplogs") {
627
+ $sql_posts_1 = "SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.referrer as psp_referrer, a.ipaddress as psp_ipaddress, a.user_agent as psp_useragent FROM $psp_redirections_log a";
628
+ }
629
+
630
+ }
631
+ //error_log($sql_posts_1);
632
+ //$posts_list = $wpdb->get_results($sql_posts_1, OBJECT);
633
+ //error_log(print_r($posts_list));
634
+ if (empty($psp_redir_type)) {
635
+ $posts_list = $wpdb->get_results($sql_posts_1, OBJECT);
636
+ } else {
637
+ if($wpdb->get_var("show tables like '$psp_redirections_tbl'") == $psp_redirections_tbl)
638
+ {
639
+ $posts_list = $wpdb->get_results($sql_posts_1, OBJECT);
640
+ }
641
+ }
642
+ }
643
+
644
+ $total_no_posts = count($posts_list);
645
+
646
+ $max_posts_per_page = 10;
647
+ $user = get_current_user_id();
648
+ $screen = get_current_screen();
649
+ // retrieve the "per_page" option
650
+ $screen_option = $screen->get_option('per_page', 'option');
651
+ // retrieve the value of the option stored for the current user
652
+ //error_log('screen option '.$screen_option);
653
+ $max_posts_per_page = get_user_meta($user, $screen_option, true);
654
+
655
+ if ( empty ( $max_posts_per_page) || $max_posts_per_page < 1 ) {
656
+ // get the default value if none is set
657
+ $max_posts_per_page = $screen->get_option( 'per_page', 'default' );
658
+ }
659
+
660
+ // now use $per_page to set the number of items displayed
661
+ //$max_posts_per_page = 10;
662
+ $link_count = ceil($total_no_posts/$max_posts_per_page);
663
+ $page_no = isset( $_GET['paged'] ) ? sanitize_key( $_GET['paged'] ) : 1;
664
+
665
+ $limit_sql = ' LIMIT '.(($page_no - 1) * $max_posts_per_page).', '.$max_posts_per_page;
666
+ //if($sql_posts != '') $sql_posts .= $limit_sql;
667
+ if($sql_posts_1 != '') $sql_posts = $sql_posts_1 . $limit_sql;
668
+ if($sql_posts_2 != '') $sql_posts = $sql_posts_2 . $limit_sql;
669
+
670
+ if($sql_posts != '') $bad_links = $wpdb->get_results( $sql_posts );
671
+ //if($sql_posts_2 != '') $bad_links_2 = $wpdb->get_results( $sql_posts_2 );
672
+
673
+ $page_links = paginate_links( array(
674
+ 'base' => add_query_arg( 'paged', '%#%' ),
675
+ 'format' => '',
676
+ 'total' => ceil($total_no_posts/$max_posts_per_page),
677
+ 'current' => $page_no
678
+ ));
679
+
680
+ include_once( 'psp_redirect_list_renderer.php' );
681
+ }
682
+
683
+ public function psp_handle_404() {
684
+
685
+ global $wp;
686
+ global $wpdb;
687
+
688
+ $req_uri = '';
689
+ $req_url = '';
690
+ $requested_url = '';
691
+
692
+ if (empty($wp) || empty($wp->request)) return;
693
+
694
+ $path_to_page = trim($wp->request); // /path/to/page
695
+ /***
696
+ if (filter_var($path_to_page, FILTER_VALIDATE_URL)) {
697
+ $requested_url = trim(add_query_arg( $wp->query_vars, $wp->request ));
698
+ } else {
699
+ $requested_url = trim(add_query_arg( $wp->query_vars, home_url( $wp->request ) ));
700
+ }
701
+ ***/
702
+ list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
703
+ if($req_uri) $req_url = home_url($req_uri);
704
+ $requested_url = filter_var( $req_url, FILTER_VALIDATE_URL, '' );
705
+ //error_log("path to page ".$path_to_page);
706
+ //error_log("requested url ".$requested_url);
707
+
708
+ $redirections = array();
709
+ $psp_redirections_tbl = $wpdb->prefix . "psp_redirections";
710
+ $psp_redirection_settings = get_option('psp_permalink_settings');
711
+ $do_redirect = isset($psp_redirection_settings['redirection']) ? ($psp_redirection_settings['redirection']) : '';
712
+ $do_auto_redirect = isset($psp_redirection_settings['auto_redirection']) ? ($psp_redirection_settings['auto_redirection']) : '';
713
+
714
+ if ( is_404() ) {
715
+
716
+ if ( $do_redirect ) {
717
+
718
+ $sql_redirections_1 = $wpdb->prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.log_redirect AS psp_log_redirect FROM $psp_redirections_tbl a WHERE a.source_url = %s", $path_to_page );
719
+
720
+ $sql_redirections_2 = $wpdb->prepare("SELECT a.id AS psp_id, a.source_url AS psp_post_name, a.dest_url AS psp_redirect, a.redir_code AS psp_redirect_code, a.log_redirect AS psp_log_redirect FROM $psp_redirections_tbl a WHERE a.source_url = %s", $requested_url );
721
+
722
+ $redirections = $wpdb->get_results($sql_redirections_1, OBJECT);
723
+ if (!$redirections) {
724
+ //error_log("nothings exists for path ".$path_to_page);
725
+ $redirections = $wpdb->get_results($sql_redirections_2, OBJECT);
726
+ //error_log(print_r($redirections, true));
727
+ }
728
+
729
+ if (!$redirections) {
730
+ //error_log("nothings exists for requested url ".$requested_url);
731
+ }
732
+
733
+ if ($redirections) {
734
+
735
+ $redirect_to = $redirections[0]->psp_redirect;
736
+ $redirect_method = $redirections[0]->psp_redirect_code;
737
+
738
+ //error_log("redirect to ".$redirect_to);
739
+
740
+ if (!empty($redirect_method) && !empty($redirect_to)) {
741
+ wp_safe_redirect($redirect_to, $redirect_method);
742
+ if($redirections[0]->psp_log_redirect) {
743
+
744
+ $limit_301 = isset($psp_redirection_settings['limit_301']) ? ($psp_redirection_settings['limit_301']) : '';
745
+ $psp_redirections_log = $wpdb->prefix . 'psp_redirections_log';
746
+ $sql_301_count = $wpdb->get_var("SELECT count(*) FROM $psp_redirections_log" );
747
+ //error_log("rowcount ".$sql_301_count);
748
+ if ($limit_301 && ($limit_301 <= $sql_301_count)) {
749
+ return;
750
+ }
751
+
752
+
753
+ $this->psp_log_redirect($redirections);
754
+ }
755
+ exit();
756
+ }
757
+ }
758
+
759
+ }
760
+
761
+
762
+ if ($do_auto_redirect) {
763
+ $this->psp_auto_redirect();
764
+ }
765
+ $this->psp_log_404();
766
+
767
+ }
768
+
769
+ return;
770
+ }
771
+
772
+ public function psp_log_redirect($redirections) {
773
+
774
+ global $wp;
775
+ global $wpdb;
776
+
777
+ $pspinsert = array();
778
+ $req_uri = '';
779
+ $req_url = '';
780
+ $requested_url = '';
781
+ $psp_redirections_log = $wpdb->prefix . 'psp_redirections_log';
782
+
783
+ $referrer = wp_get_original_referer();
784
+ //$referrer = isset( $_SERVER[ 'HTTP_REFERER' ] ) ? filter_var( $_SERVER[ 'HTTP_REFERER' ], FILTER_VALIDATE_URL, '' ) : '';
785
+ //$user_agent = isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? filter_var( $_SERVER[ 'HTTP_USER_AGENT' ], FILTER_DEFAULT, '' ) : '';
786
+ $user_agent = isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? sanitize_text_field( $_SERVER[ 'HTTP_USER_AGENT'] ) : '';
787
+ $ipaddress = $this->psp_get_user_ip();
788
+
789
+ $pspinsert['referrer'] = !empty($referrer) ? esc_url_raw($referrer) : '';
790
+ $pspinsert['ipaddress'] = !empty($ipaddress) ? $ipaddress : '';
791
+ $pspinsert['user_agent'] = !empty($user_agent) ? $user_agent : '';
792
+
793
+ list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
794
+ if($req_uri) $req_url = home_url($req_uri);
795
+ $requested_url = filter_var( $req_url, FILTER_VALIDATE_URL, '' );
796
+
797
+ $pspinsert['source_uri'] = !empty($req_uri) ? $req_uri : '';
798
+ $pspinsert['source_url'] = !empty($requested_url) ? esc_url_raw($requested_url) : '';
799
+
800
+ if (!empty($redirections)) {
801
+ $pspinsert['dest_url'] = !empty($redirections[0]->psp_redirect) ? esc_url_raw($redirections[0]->psp_redirect) : '';
802
+ $pspinsert['redir_code'] = !empty($redirections[0]->psp_redirect_code) ? sanitize_key($redirections[0]->psp_redirect_code) : '';
803
+
804
+ }
805
+
806
+ if(!empty($pspinsert)) {
807
+ $wpdb->insert( $psp_redirections_log, $pspinsert );
808
+ }
809
+ return;
810
+ }
811
+
812
+ public function psp_loaded_filter() {
813
+ add_filter('status_header', array($this, 'psp_log_404'), 10, 4);
814
+ }
815
+
816
+ public function psp_log_404($sh = '', $code = '', $descrption = '', $protocol = '') {
817
+
818
+ $error_codes = array('404', '410', '');
819
+
820
+ //error_log('startcode '.$code);
821
+
822
+ if ( !in_array($code, $error_codes)) {
823
+
824
+ return $sh;
825
+ }
826
+
827
+ global $wp;
828
+ global $wpdb;
829
+
830
+ $pspinsert = array();
831
+ $psp_404_log = $wpdb->prefix . "psp_404_log";
832
+ $ipaddress = "";
833
+ $referrer = "";
834
+ $req_uri = '';
835
+ $req_url = '';
836
+ $requested_url = '';
837
+
838
+ $psp_404_settings = get_option('psp_permalink_settings');
839
+ $bots_only = isset($psp_404_settings['bots_404']) ? ($psp_404_settings['bots_404']) : '';
840
+ $referrer_only = isset($psp_404_settings['referrer_404']) ? ($psp_404_settings['referrer_404']) :'';
841
+ $track_404 = isset($psp_404_settings['enable_404']) ? ($psp_404_settings['enable_404']) : '';
842
+ $limit_404 = isset($psp_redirection_settings['limit_404']) ? ($psp_redirection_settings['limit_404']) : '';
843
+
844
+ $path_to_page = trim($wp->request); // /path/to/page
845
+
846
+ // Check if excluded.
847
+ /***
848
+ if ( $this->is_url_excluded( $path_to_page ) ) {
849
+ return;
850
+ }
851
+ ***/
852
+ //$requested_url = trim(add_query_arg( $wp->query_vars, home_url( $wp->request ) ));
853
+
854
+ //list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
855
+ //if($req_uri) $req_url = home_url($req_uri);
856
+ $req_url = home_url($_SERVER['REQUEST_URI']);
857
+ $requested_url = filter_var( $req_url, FILTER_VALIDATE_URL, '' );
858
+
859
+ if ( $bots_only ) {
860
+ //$requested_url = trim(home_url( $wp->request ));
861
+ }
862
+
863
+ $pspinsert['source_uri'] = !empty($path_to_page) ? $path_to_page : '';
864
+ $pspinsert['source_url'] = !empty($requested_url) ? esc_url_raw($requested_url) : '';
865
+
866
+ if (empty($path_to_page) || empty($requested_url)) {
867
+
868
+ return $sh;
869
+ }
870
+
871
+ $sql_404 = $wpdb->prepare("SELECT id, source_uri, source_url, total_hits, referrer, status FROM $psp_404_log a WHERE a.source_uri = %s", $path_to_page );
872
+ //error_log('path to page '.$path_to_page);
873
+ $id_404 = $wpdb->get_row($sql_404, OBJECT);
874
+ //error_log('middlecode '.$code);
875
+ if($code == '404') {
876
+ //error_log('status '.$id_404->status);
877
+ if (!empty($id_404) && trim($id_404->status) == "410") {
878
+ //set status tp 410 via filter
879
+ $code = '410';
880
+ $description = get_status_header_desc( $code );
881
+ //error_log('410 return '.$code);
882
+ return "$protocol $code $description";
883
+ } else {
884
+ //error_log('404 return '.$code);
885
+ return $sh;
886
+ }
887
+ }
888
+
889
+ if(!$track_404) {
890
+ return;
891
+ }
892
+ //error_log('404 logging enabled '.$code);
893
+ $sql_404_count = $wpdb->get_var("SELECT count(*) FROM $psp_404_log" );
894
+ //error_log("rowcount ".$sql_404_count);
895
+ if ($limit_404 && ($limit_404 <= $sql_404_count) && empty($id_404)) {
896
+ return;
897
+ }
898
+ $referrer = wp_get_original_referer();
899
+ //$referrer = isset( $_SERVER[ 'HTTP_REFERER' ] ) ? filter_var( $_SERVER[ 'HTTP_REFERER' ], FILTER_VALIDATE_URL, '' ) : '';
900
+
901
+ if ( $referrer_only && empty($referrer) ) {
902
+ return;
903
+ }
904
+
905
+ $pspinsert['referrer'] = !empty($referrer) ? esc_url_raw($referrer) : '';
906
+ //$user_agent = isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? filter_var( $_SERVER[ 'HTTP_USER_AGENT' ], FILTER_DEFAULT, '' ) : '';
907
+ $user_agent = isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? sanitize_text_field( $_SERVER[ 'HTTP_USER_AGENT'] ) : '';
908
+ $ipaddress = $this->psp_get_user_ip();
909
+
910
+ $pspinsert['ipaddress'] = !empty($ipaddress) ? $ipaddress : '';
911
+ $pspinsert['user_agent'] = !empty($user_agent) ? $user_agent : '';
912
+
913
+ if ($bots_only && !$this->detectSearchBot($pspinsert['ipaddress'], $pspinsert['user_agent'])) {
914
+ return;
915
+ }
916
+ //error_log('404 logged as it is googlebot and error code is '.$code);
917
+ if (!empty($path_to_page) && !empty($requested_url)) {
918
+
919
+ if (!empty($id_404)) {
920
+ $pspinsert['total_hits'] = (int) $id_404->total_hits+1;
921
+ $wpdb->update( $psp_404_log, $pspinsert, array('id' => $id_404->id) );
922
+ } else {
923
+ $wpdb->insert( $psp_404_log, $pspinsert );
924
+ }
925
+ }
926
+
927
+ return;
928
+ }
929
+
930
+ private function psp_get_user_ip() {
931
+
932
+ $ip = "";
933
+
934
+ if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
935
+
936
+ //check ip from share internet //ip = $_SERVER['HTTP_CLIENT_IP'];
937
+ $ip = isset( $_SERVER[ 'HTTP_CLIENT_IP' ] ) ? filter_var( $_SERVER[ 'HTTP_CLIENT_IP' ], FILTER_VALIDATE_IP, '' ) : '';
938
+
939
+ } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
940
+
941
+ //to check ip is pass from proxy //$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
942
+ $ip = isset( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) ? filter_var( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ], FILTER_VALIDATE_IP, '' ) : '';
943
+
944
+ } else {
945
+
946
+ //to get remote address // $ip = $_SERVER['REMOTE_ADDR'];
947
+ $ip = isset( $_SERVER[ 'REMOTE_ADDR' ] ) ? filter_var( $_SERVER[ 'REMOTE_ADDR' ], FILTER_VALIDATE_IP, '' ) : '';
948
+ }
949
+ return apply_filters( 'psp_get_user_ip', $ip );
950
+ }
951
+
952
+ private function psp_auto_redirect() {
953
+
954
+ global $wpdb;
955
+ $ID = '';
956
+ $slug = '';
957
+ $pspurl = '';
958
+ $exts=array("/",".php",".html",".htm");
959
+ $psp_posts = $wpdb->prefix . "posts";
960
+
961
+ list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
962
+ $req_url = home_url($req_uri);
963
+ //error_log("auto redirect uri ".$req_url);
964
+ $pspurl = filter_var( $req_url, FILTER_VALIDATE_URL, '' );
965
+ //error_log("auto redirect url ".$pspurl);
966
+ if (!$pspurl) {
967
+ return;
968
+ }
969
+
970
+ if ($pspurl) $slug = sanitize_title(basename( $pspurl ));
971
+
972
+ // error_log("auto redirect slug ".$slug);
973
+
974
+ // This will also work with PHP version <= 5.x.x
975
+ foreach( $exts as $ext ) {
976
+ $slug = str_replace( $ext, "", $slug );
977
+ $slug = trim($slug);
978
+ }
979
+
980
+ if (!$slug) return;
981
+
982
+ if ($slug) {
983
+ $sql = $wpdb->prepare("SELECT ID FROM $psp_posts WHERE post_name = %s AND post_status = 'publish'", $slug);
984
+ $ID = $wpdb->get_var( $sql );
985
+ }
986
+ //error_log("post id ".$ID);
987
+ if (!$ID) return;
988
+
989
+ if( $ID ) {
990
+ //$this->redirect_to_new_location( get_permalink( $ID ));
991
+ $psp_redirect_to_url = get_permalink( $ID );
992
+ $psp_redirect_status_code = '301';
993
+ wp_safe_redirect($psp_redirect_to_url,$psp_redirect_status_code);
994
+ exit();
995
+ }
996
+ }
997
+
998
+ private function validate_url($url) {
999
+ $path = parse_url($url, PHP_URL_PATH);
1000
+ $encoded_path = array_map('urlencode', explode('/', $path));
1001
+ $url = str_replace($path, implode('/', $encoded_path), $url);
1002
+
1003
+ return filter_var($url, FILTER_VALIDATE_URL) ? true : false;
1004
+ }
1005
+
1006
+ private function detectSearchBot($ip, $agent) {
1007
+
1008
+ $hostname = $ip;
1009
+ //error_log("ip address ".$ip);
1010
+ // error_log("user agent ".$agent);
1011
+ // check HTTP_USER_AGENT what not to touch gethostbyaddr in vain
1012
+ if (preg_match('/(?:google?|bing)bot/iu', $agent)) {
1013
+ // success - return host, fail - return ip or false
1014
+ $hostname = gethostbyaddr($ip);
1015
+ //error_log("host name ".$hostname);
1016
+ // https://support.google.com/webmasters/answer/80553
1017
+ if ($hostname !== false && $hostname != $ip) {
1018
+ // detect google and yandex search bots
1019
+ //if (preg_match('/\.((?:google(?:bot)?|yandex)\.(?:com|ru))$/iu', $hostname)) {
1020
+ if (preg_match('/\.((?:google(?:bot)?|bing|googleusercontent)\.(?:com))$/iu', $hostname)) {
1021
+ // success - return ip, fail - return hostname
1022
+ $ip = gethostbyname($hostname);
1023
+
1024
+ if ($ip != $hostname) {
1025
+ return true;
1026
+ }
1027
+ }
1028
+ }
1029
+ }
1030
+
1031
+ return false;
1032
+ }
1033
+ }
1034
+ ?>
psp-include/settings/psp_redirect_list_renderer.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Platinum SEO Pack
4
+ Plugin URI: https://techblissonline.com/platinum-wordpress-seo-plugin/
5
+ Author: Rajesh - Techblissonline
6
+ Author URI: http://techblissonline.com/
7
+ */
8
+ ?>
9
+ <?php
10
+ wp_enqueue_script( 'psp-redirect', plugins_url( '/js/psp-redirect.js', __FILE__ ), array( 'jquery' ) );
11
+ wp_enqueue_style("psp-settings-css", plugins_url( '/css/psp-settings.css', __FILE__ ));
12
+ ?>
13
+ <style>
14
+ .page-numbers {
15
+ display: inline-block;
16
+ padding: 5px 10px;
17
+ margin: 0 2px 0 0;
18
+ border: 1px solid #eee;
19
+ line-height: 1;
20
+ text-decoration: none;
21
+ border-radius: 2px;
22
+ font-weight: 600;
23
+ color:#111;
24
+
25
+ }
26
+ .page-numbers.current,
27
+ a.page-numbers:hover {
28
+ background: grey; /* color:#f9f9f9;*/
29
+ color:#fff;
30
+ }
31
+ a.check {
32
+ color:#fff;
33
+ }
34
+ a.check:hover {
35
+ color:#0073aa;
36
+ }
37
+ </style>
38
+
39
+ <div class="wrap">
40
+
41
+ <h2>Redirection Management:</h2>
42
+ <a href="/wp-admin/admin.php?page=platinum-seo-social-pack-by-techblissonline&psptab=psp_permalink">Redirection Settings</a> | <a href="https://techblissonline.com/redirection-in-wordpress/" target="_blank" rel="noopener">Manage Redirections in WordPress</a> | <a href="https://techblissonline.com/http-redirection-status-codes-301-302-307-308/" target="_blank" rel="noopener">HTTP Redirection Status Codes</a>
43
+ <form id="psp-search" action="" method="get">
44
+ <div class="tablenav top">
45
+ <div class="alignleft actions">
46
+
47
+ <input type="hidden" name="page" id="page" value="redirectionmanager">
48
+ <div id="pspredirmethod" class="alignleft">
49
+ <select id="psp_redir_type" name="psp_redir_type"><?php $dditems = array('' => 'Posts', 'pspurls' => 'Redirected URLs', 'psplogs' => 'Redirection Logs');
50
+ foreach($dditems as $key => $val) {
51
+ $selected = (isset($_GET['psp_redir_type']) && $_GET['psp_redir_type']==$key) ? 'selected="selected"' : '';
52
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
53
+ } ?></select></div>
54
+ <div id="pspfilter" class="alignleft">
55
+ <select id="psp_filter" name="psp_filter"><?php if ($psp_redir_type == '') {
56
+ $dditems = array('' => 'Redirected', 'equals' => 'Equal to', 'contains' => 'that Contain', 'starts-with' => 'that Start with', 'ends-with' => 'that End With');
57
+ } else {
58
+ $dditems = array('' => 'All', 'equals' => 'Equal to', 'contains' => 'that Contain', 'starts-with' => 'that Start with', 'ends-with' => 'that End With');
59
+ }
60
+ foreach($dditems as $key => $val) {
61
+ $selected = (isset($_GET['psp_filter']) && $_GET['psp_filter']==$key) ? 'selected="selected"' : '';
62
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
63
+ } ?></select></div>
64
+ <div id="pspsearchfield" class="alignleft hidden">
65
+ <input type="search" name="post-search-input" id="post-search-input" value="<?php echo (isset($_GET['post-search-input']) ? esc_attr(sanitize_text_field($_GET['post-search-input'])) : ''); ?>">
66
+ </div>
67
+
68
+ <div id="searchitdiv" class="alignleft"><input type="submit" name="searchit" id="searchit" class="button-secondary search" value="Search"></div>
69
+
70
+ </div>
71
+
72
+ </div>
73
+ </form>
74
+ <br class="clear" />
75
+ <form id="psp-edit" action="" method="post">
76
+ <div id="psp-edit-div" class="hidden">
77
+ <table class="form-table">
78
+
79
+ <tr id="source-tr" class="form-field hidden">
80
+ <th style="width:20%;" scope="row" valign="top"><label for="source-url-input"><?php esc_html_e('Source URL: ', 'platinum-seo-pack'); ?></label></div></th>
81
+ <td><input type="text" id="source-url-input" name="source-url-input" value="" placeholder="<?php esc_html_e('Enter the source URI or URL ', 'platinum-seo-pack'); ?>" /><input type="hidden" id="pspredirtype" name="pspredirtype" value="<?php echo $psp_redir_type ?>" /></td>
82
+ </tr>
83
+
84
+ <tr class="form-field">
85
+ <th style="width:20%;" scope="row" valign="top"><label for="redirect-url-input"><?php esc_html_e('Redirect to: ', 'platinum-seo-pack'); ?></label></th>
86
+ <td><input type="text" id="redirect-url-input" name="redirect-url-input" value="" placeholder="<?php esc_html_e('Enter a valid Destination URL ', 'platinum-seo-pack'); ?>" /></td>
87
+ </tr>
88
+ <tr class="form-field">
89
+ <th style="width:20%;" scope="row" valign="top"><label for="redirect-url-input"><?php echo esc_html__('Redirection Method: ', 'platinum-seo-pack').'<br>'.'<a href="https://techblissonline.com/http-redirection-status-codes-301-302-307-308/" target="_blank" rel="noopener">'.esc_html__('What to Select?', 'platinum-seo-pack').'</a>'; ?></label></th>
90
+ <td>
91
+ <div class="alignleft"><select id="psp-redirect-code" name="psp-redirect-code">
92
+ <?php $dditems = array('' => 'Select a redirection method', '301' => '301 Moved Permanently', '302' => '302 Found', '302' => '302 Found', '303' => '303 See Other', '307' => '307 Temporary Redirect');
93
+
94
+ foreach($dditems as $key => $val) {
95
+ $selected = (isset($_POST['psp-redirect-code']) && $_POST['psp-redirect-code']==$key) ? 'selected="selected"' : '';
96
+ echo "<option value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
97
+ } ?>
98
+ </select></div>
99
+ <div id="log-div" class="psp-separator"><input id="do-not-log" checked="checked" type="radio" name="psplog" value="" /><label class="psp-radio-separator psp-d" for="do-not-log">Do not log</label>
100
+ <input id="do-log" type="radio" name="psplog" value="do-log" /><label class="psp-radio-separator psp-d" for="do-log">Log Redirect</label></div>
101
+ <div id="updateit" class="alignleft"><input type="submit" value="<?php _e('Update'); ?>" name="updateit" class="button-secondary update hidden" />
102
+ </div>
103
+ <div id="insertit" class="alignleft"><input type="submit" value="<?php _e('Add New'); ?>" name="insertit" id="insertit" class="button-secondary update hidden" />
104
+ </div>
105
+ <div id="cancelit-div" class="alignleft"><input type="reset" value="<?php _e('Cancel'); ?>" name="cancelit" id="cancelit" class="button-secondary update hidden" />
106
+ </div>
107
+ </td>
108
+ </tr>
109
+ </table>
110
+ </div>
111
+ <?php
112
+ if (empty($psp_redir_type)) {
113
+
114
+ wp_nonce_field( 'do_psp_posts_redirect_actions', 'psp_posts_redirect_actions_nonce' );
115
+
116
+ } else if ($psp_redir_type == "pspurls") {
117
+
118
+ wp_nonce_field( 'do_psp_urls_redirect_actions', 'psp_urls_redirect_actions_nonce' );
119
+
120
+ } else {
121
+
122
+ wp_nonce_field( 'do_psp_logs_redirect_actions', 'psp_logs_redirect_actions_nonce' );
123
+ }
124
+ ?>
125
+ <div class="tablenav">
126
+ <div class="alignleft">
127
+ <select id="psp_action" name="psp_action">
128
+ <?php
129
+ if (empty($psp_redir_type)) {
130
+ //$dditems = array('' => 'Bulk Actions', 'addnew' => 'Add New', 'edit' => 'Edit', 'delete' => 'Move to Trash');
131
+ $dditems = array('' => 'Bulk Actions', 'edit' => 'Edit', 'delete' => 'Delete Permanently');
132
+ //wp_nonce_field( 'do_psp_posts_redirect_actions', 'psp_posts_redirect_actions_nonce' );
133
+
134
+ } else if ($psp_redir_type == "pspurls") {
135
+
136
+ $dditems = array('' => 'Bulk Actions', 'addnew' => 'Add New', 'edit' => 'Edit', 'delete' => 'Delete Permanently');
137
+ //wp_nonce_field( 'do_psp_urls_redirect_actions', 'psp_urls_redirect_actions_nonce' );
138
+
139
+ } else {
140
+
141
+ $dditems = array('' => 'Bulk Actions', 'delete' => 'Delete Permanently', 'deleteall' => 'Delete All');
142
+ //wp_nonce_field( 'do_psp_logs_redirect_actions', 'psp_logs_redirect_actions_nonce' );
143
+ }
144
+
145
+ foreach($dditems as $key => $val) {
146
+ //$selected = (isset($_POST['psp_action']) && $_POST['psp_action']==$key) ? 'selected="selected"' : '';
147
+ $selected = '';
148
+ echo "<option id='$key' value='".esc_attr($key)."' ".esc_attr($selected).">".esc_html($val)."</option>";
149
+ } ?>
150
+ </select>
151
+ </div>
152
+ <div id="psp-delete-div" class="hidden alignleft">
153
+ <input type="submit" value="<?php _e('Delete'); ?>" id="deleteit" name="deleteit" class="button-secondary delete" />
154
+ </div>
155
+
156
+ <script type="text/javascript">
157
+ <!--
158
+ function checkAll(form) {
159
+ for (i = 0, n = form.elements.length; i < n; i++) {
160
+ if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) {
161
+ if(form.elements[i].checked == true)
162
+ form.elements[i].checked = false;
163
+ else
164
+ form.elements[i].checked = true;
165
+ }
166
+ }
167
+ }
168
+ //-->
169
+ </script>
170
+ <?php
171
+ if ( $page_links )
172
+ echo "<div class='tablenav-pages alignright'>$page_links</div>";
173
+ ?>
174
+ </div>
175
+ <?php if($psp_redir_type == "psplogs") { ?>
176
+
177
+ <table class="widefat">
178
+ <thead>
179
+ <tr class="psp-header">
180
+ <th scope="col" class=""><input onclick="checkAll(document.getElementById('psp-edit'));" type="checkbox"></th>
181
+ <td scope="col" class="pspth">ID</th>
182
+ <td scope="col" class="pspth">Request URL</th>
183
+ <td scope="col" class="pspth">Redirect To</th>
184
+ <td scope="col" class="pspth">Redirect Method</th>
185
+ <th id='referrer'class='manage-column column-referrer pspth' scope="col">Referrer</th>
186
+ <th id='ipaddress'class='manage-column column-ipaddress pspth' scope="col">IP Address</th>
187
+ <th id='useragent'class='manage-column column-useragent pspth' scope="col">User Agent</th>
188
+ </tr>
189
+ </thead>
190
+ <?php
191
+ if(count($bad_links) > 0) { ?>
192
+ <tbody>
193
+ <?php
194
+ $bgcolor = '';
195
+ //$class = 'alternate' == $class ? '' : 'alternate';
196
+ $class = 'alternate';
197
+ foreach($bad_links as $bad_link){
198
+
199
+ $psp_redirect = $bad_link->psp_redirect;
200
+ $psp_redirect_code = $bad_link->psp_redirect_code;
201
+ $psp_referrer = $bad_link->psp_referrer;
202
+ $psp_ip = $bad_link->psp_ipaddress;
203
+ $psp_ua = $bad_link->psp_useragent;
204
+
205
+ $class = 'alternate' == $class ? '' : 'alternate';
206
+ ?>
207
+ <tr id="<?php echo esc_attr($bad_link->psp_id); ?>" class="<?php echo trim( esc_attr($class) . ' author-self status-publish'); ?>" valign="top">
208
+ <th scope="row" class=""><?php if ( current_user_can( 'edit_posts', $bad_link->psp_id ) ) { ?><input type="checkbox" name="update[]" value="<?php echo esc_attr($bad_link->psp_id); ?>" /><?php } ?></th>
209
+ <td><strong><?php if ( current_user_can( 'edit_posts', $bad_link->psp_id ) && empty($psp_redir_type)) { ?><a class="row-title" href="post.php?action=edit&amp;post=<?php echo esc_attr($bad_link->psp_id); ?>" target="_blank" title="<?php echo esc_attr(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo esc_attr($bad_link->psp_id); ?></a><?php } else { echo esc_attr($bad_link->psp_id); } ?></strong></td>
210
+ <td><?php echo esc_attr($bad_link->psp_post_name); ?><div class="check-div"><a href="<?php if (!filter_var($bad_link->psp_post_name, FILTER_VALIDATE_URL)) { echo esc_url_raw(home_url($bad_link->psp_post_name)); } else { echo esc_url_raw($bad_link->psp_post_name); } ?>" class="check" target="_blank" rel="noopener"><?php echo "Check Redirection"; ?></a></div></td>
211
+ <td><?php echo !empty($psp_redirect) ? esc_url_raw($psp_redirect) : ' - '; ?></td>
212
+ <td><?php echo !empty($psp_redirect_code) ? esc_html($psp_redirect_code) : ' - ';?></td>
213
+ <td class='referrer'><?php echo !empty($psp_referrer) ? esc_url_raw($psp_referrer) : ' - ';?></td>
214
+ <td class='ipaddress'><?php echo !empty($psp_ip) ? esc_html($psp_ip) : ' - ';?></td>
215
+ <td class='useragent'><?php echo !empty($psp_ua) ? esc_html($psp_ua) : ' - ';?></td>
216
+ </tr>
217
+ <?php } ?>
218
+ </tbody>
219
+ <?php } ?>
220
+ </table>
221
+
222
+ <?php } else { ?>
223
+
224
+ <table class="widefat">
225
+ <thead>
226
+ <tr>
227
+ <th scope="col" class=""><input onclick="checkAll(document.getElementById('psp-edit'));" type="checkbox"></th>
228
+ <th scope="col">ID</th>
229
+ <?php if ($psp_redir_type !== '') { ?>
230
+ <th scope="col">Request Path/URL</th>
231
+ <?php } else { ?>
232
+ <th scope="col">Post Name</th>
233
+ <?php } ?>
234
+ <th scope="col">Redirect To</th>
235
+ <th scope="col">Redirect Method</th>
236
+ <?php if ($psp_redir_type !== '') { ?>
237
+ <th scope="col">Logging</th>
238
+ <?php } ?>
239
+ </tr>
240
+ </thead>
241
+ <?php
242
+ if(count($bad_links) > 0) { ?>
243
+ <tbody>
244
+ <?php
245
+ $bgcolor = '';
246
+ //$class = 'alternate' == $class ? '' : 'alternate';
247
+ $class = 'alternate';
248
+ foreach($bad_links as $bad_link){
249
+
250
+ $psp_redirect = ' - ';
251
+ $psp_redirect_code =' - ';
252
+ $title = '';
253
+
254
+ if($sql_posts_2 != '') {
255
+ $post_psp_id = $bad_link->psp_id;
256
+ $post_psp = get_post($post_psp_id);
257
+ $title = !empty($post_ps) ? $post_psp->post_title : '';
258
+ if ($psp_redir_type == '') {
259
+ $psp_redirect = get_post_meta($post_psp_id, '_techblissonline_psp_redirect_to_url', true);
260
+ $psp_redirect_code = get_post_meta($post_psp_id, '_techblissonline_psp_redirect_status_code', true);
261
+ } else {
262
+ $psp_redirect = $bad_link->psp_redirect;
263
+ $psp_redirect_code = $bad_link->psp_redirect_code;
264
+ $psp_log = $bad_link->psp_log;
265
+ }
266
+ } else {
267
+ $post_psp_id = $bad_link->psp_id;
268
+ $post_psp = get_post($post_psp_id);
269
+ $title = !empty($post_ps) ? $post_psp->post_title : '';
270
+ $psp_redirect = $bad_link->psp_redirect;
271
+ $psp_redirect_code = $bad_link->psp_redirect_code;
272
+ if ($psp_redir_type !== '') {
273
+ $psp_log = $bad_link->psp_log;
274
+ }
275
+ }
276
+ $class = 'alternate' == $class ? '' : 'alternate';
277
+ ?>
278
+ <tr id="<?php echo esc_attr($bad_link->psp_id); ?>" class="<?php echo trim( esc_attr($class) . ' author-self status-publish'); ?>" valign="top">
279
+ <th scope="row" class=""><?php if ( current_user_can( 'edit_posts', $bad_link->psp_id ) ) { ?><input type="checkbox" name="update[]" value="<?php echo esc_attr($bad_link->psp_id); ?>" /><?php } ?></th>
280
+ <td><strong><?php if ( current_user_can( 'edit_posts', $bad_link->psp_id ) && empty($psp_redir_type)) { ?><a class="row-title" href="post.php?action=edit&amp;post=<?php echo esc_attr($bad_link->psp_id); ?>" target="_blank" title="<?php echo esc_attr(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo esc_attr($bad_link->psp_id); ?></a><?php } else { echo esc_attr($bad_link->psp_id); } ?></strong></td>
281
+ <td><?php echo esc_attr($bad_link->psp_post_name); ?><div class="check-div"><a href="<?php if (!filter_var($bad_link->psp_post_name, FILTER_VALIDATE_URL)) { echo esc_url_raw(home_url($bad_link->psp_post_name)); } else { echo esc_url_raw($bad_link->psp_post_name); } ?>" class="check" target="_blank" rel="noopener"><?php echo "Check Redirection"; ?></a></div></td>
282
+ <td><?php echo !empty($psp_redirect) ? esc_url_raw($psp_redirect) : ' - '; ?></td>
283
+ <td><?php echo !empty($psp_redirect_code) ? esc_html($psp_redirect_code) : ' - ';?></td>
284
+ <?php if ($psp_redir_type !== '') { ?>
285
+ <td><?php echo !empty($psp_log) ? 'On' : 'Off';?></td>
286
+ <?php } ?>
287
+ </tr>
288
+ <?php } ?>
289
+ </tbody>
290
+ <?php } ?>
291
+ </table>
292
+ <?php } ?>
293
+ </form>
294
+
295
+ <div class="tablenav top">
296
+
297
+ <?php
298
+ if ( $page_links )
299
+ echo "<div class='tablenav-pages'>$page_links</div>";
300
+ ?>
301
+
302
+ </div>
303
+
304
+ <br class="clear" />
305
+
306
+ </div>
psp-include/settings/psp_settings.php CHANGED
@@ -18,7 +18,7 @@ class PspSettings {
18
  public $psp_wmt_instance;
19
  public $psp_tools_instance;
20
  public $psp_pre_instance;
21
- public $psp_ga_instance;
22
  public $psp_social_instance;
23
 
24
  private $psp_helper;
@@ -82,6 +82,8 @@ class PspSettings {
82
  $psp_social_instance = PspSocialSettings::get_instance();
83
  $this->psp_social_instance = $psp_social_instance;
84
 
 
 
85
  $this->sitename = $psp_helper_instance->get_sitename();
86
 
87
  $psp_do_rewrite_rules = false;
@@ -1668,6 +1670,118 @@ class PspSettings {
1668
  //register_setting( $this->psp_permalink_settings_group, $psp_settings_name );
1669
  register_setting( $this->psp_permalink_settings_group, $psp_settings_name, array( &$this, 'sanitize_permalink_settings' ));
1670
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1671
  //Section
1672
  $section_id = 'psp_permalink_section';
1673
  $section_title = esc_html__('Permalink Structure for Taxonomies', 'platinum-seo-pack');
@@ -1709,11 +1823,45 @@ class PspSettings {
1709
 
1710
  function sanitize_permalink_settings($settings) {
1711
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1712
  if ( isset( $settings['category'] ) ) {
1713
  $settings['category'] = !is_null(filter_var($settings['category'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['category'] : '';
1714
  } else {
1715
  $settings['category'] = "";
1716
- }
1717
 
1718
  $custom_tax = array();
1719
  if (!empty($this->custom_taxonomies)) {
@@ -1729,7 +1877,7 @@ class PspSettings {
1729
  }
1730
 
1731
  }
1732
- }
1733
 
1734
  return $settings;
1735
  }
@@ -2390,6 +2538,8 @@ class PspSettings {
2390
  function section_404_desc() { esc_html_e('Set the title format for 404 page.', 'platinum-seo-pack'); }
2391
  function section_nofollow_desc() { esc_html_e('These Nofollow settings are applied throughout the site wherever appropriate.', 'platinum-seo-pack'); }
2392
  function section_permalinks_desc() { echo esc_html__('These settings, if checked, will remove the base from taxonomies like Category and other custom taxonomies, if any. If "Remove base" is chosen for Category then the corresponding base will be removed from the permalink structure for categories.', 'platinum-seo-pack'). ' i.e. <code>Category</code>'; }
 
 
2393
  function section_cleanup_head_desc() { echo esc_html__('Remove unwanted links from HTML', 'platinum-seo-pack'). ' <code>&lt;head&gt;&lt;&#47;head&gt;</code>'.
2394
  esc_html__('Many of these links might not be needed in the head section for most sites and removing these might help reduce page size and also improve crawlability of more imortant links. So you may choose to remove those that are not needed for you site.', 'platinum-seo-pack'); }
2395
  function section_cleanup_comment_desc() { esc_html_e('Strip HTML and anchor tags embedded in comments. Note that these remove the HTML and links embedded in the comments and not the comment author links.', 'platinum-seo-pack'); }
@@ -2406,6 +2556,20 @@ class PspSettings {
2406
  function section_breadcrumb_desc() { echo esc_html__('These breadcrumb settings are for displaying breadcrumbs on the Post. It is built on top of Justin Tadlock\'s @BreadcrumbTrail package. Place the code', 'platinum-seo-pack').' <code>&lt;?php if ( function_exists( \'psp_breadcrumb_trail\' ) ) { psp_breadcrumb_trail(); } ?&gt;</code> '.esc_html__(' in your theme\'s single.php, at an apppropriate location, to display the generated breadcrumb trail. You may add the breadcrumb Json-LD schema (along with other schemas) in the Techblissonline Platinum SEO metabox for the Post.', 'platinum-seo-pack'); }
2407
  function section_schema_desc() {echo esc_html__('The following settings are not necessary if you had added these schemas in the Home page and/or Contacts Page JSON Schema Editor settings of this plugin.', 'platinum-seo-pack'). ' i.e. <br /> 1. '.esc_html__('Schema for enabling Sitelink Search Box in Google and', 'platinum-seo-pack').' <br /> 2. '. esc_html__('Schema for Knowledge Graph', 'platinum-seo-pack'); }
2408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2409
  /*
2410
  * Callback for adding a textfield.
2411
  */
@@ -2617,6 +2781,8 @@ class PspSettings {
2617
  //add_submenu_page($this->psp_plugin_options_key, __('Techblissonline Platinum SEO Analytics', 'platinum_seo_pack'), __('SEO - Analytics', 'platinum_seo_pack'), 'manage_options', 'psp-gatracking-by-techblissonline', array($this->psp_ga_instance, 'psp_ga_options_page'));
2618
  add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Tools', 'platinum_seo_pack'), '<span class="dashicons dashicons-edit"></span> '.esc_html__('SEO - Editors', 'platinum_seo_pack'), 'manage_options', 'psp-tools-by-techblissonline', array($this->psp_tools_instance, 'psp_tools_options_page'));
2619
  add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Premium Pack', 'platinum_seo_pack'), '<span class="dashicons dashicons-admin-tools"></span> '.esc_html__(' SEO Tools', 'platinum_seo_pack'), 'manage_options', 'psp-seo-tools-by-techblissonline', array( &$this, 'psp_pre_tools_display_page'));
 
 
2620
  //add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Premium Pack', 'platinum_seo_pack'), __('Techblissonline - SEO Tools', 'platinum_seo_pack'), 'manage_options', 'psp-seo-tools-by-techblissonline', array($this->psp_pre_instance, 'psp_pre_options_page'));
2621
  if ($psp_premium_valid) add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Premium Pack', 'platinum_seo_pack'), '<span class="dashicons dashicons-admin-network"></span> '.esc_html__('Premium - Licenses', 'platinum_seo_pack'), 'manage_options', 'pspp-licenses', array($this->psp_pre_instance, 'psp_premium_options_page'));
2622
  }
18
  public $psp_wmt_instance;
19
  public $psp_tools_instance;
20
  public $psp_pre_instance;
21
+ public $psp_redirect_instance;
22
  public $psp_social_instance;
23
 
24
  private $psp_helper;
82
  $psp_social_instance = PspSocialSettings::get_instance();
83
  $this->psp_social_instance = $psp_social_instance;
84
 
85
+ $psp_redirect_instance = PspRedirections::get_instance();
86
+ $this->psp_redirect_instance = $psp_redirect_instance;
87
  $this->sitename = $psp_helper_instance->get_sitename();
88
 
89
  $psp_do_rewrite_rules = false;
1670
  //register_setting( $this->psp_permalink_settings_group, $psp_settings_name );
1671
  register_setting( $this->psp_permalink_settings_group, $psp_settings_name, array( &$this, 'sanitize_permalink_settings' ));
1672
 
1673
+ //Redirection Section
1674
+ $section_id = 'psp_redirection_section';
1675
+ $section_title = esc_html__('Redirections', 'platinum-seo-pack');
1676
+
1677
+ add_settings_section( $section_id, $section_title, array( &$this, 'section_redirections_desc' ), $this->psp_permalink_settings_group );
1678
+
1679
+ //Fields
1680
+
1681
+ $redirection_field = array (
1682
+ 'label_for' => 'psp_redirection',
1683
+ 'option_name' => $psp_settings_name.'[redirection]',
1684
+ 'option_value' => isset($psp_settings['redirection']) ? $psp_settings['redirection'] : '',
1685
+ 'checkbox_label' => esc_html__('', 'platinum-seo-pack'),
1686
+ 'option_description' => esc_html__( 'Turn ON to enable redirections created using Platinum SEO (Recommended).', 'platinum-seo-pack' ),
1687
+ );
1688
+
1689
+ $redirection_field_id = 'psp_redirection';
1690
+ //$redirection_field_title = esc_html__('Redirection: ', 'platinum-seo-pack');
1691
+ $redirection_field_title = esc_html__('Redirection: ', 'platinum-seo-pack').'<a href="https://techblissonline.com/redirection-in-wordpress/" target="_blank" rel="noopener">'.'<br>'.esc_html__('what does this do?', 'platinum-seo-pack').'</a>';
1692
+
1693
+ add_settings_field( $redirection_field_id, $redirection_field_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_permalink_settings_group, $section_id, $redirection_field );
1694
+
1695
+ $auto_redirection_field = array (
1696
+ 'label_for' => 'psp_auto_redirection',
1697
+ 'option_name' => $psp_settings_name.'[auto_redirection]',
1698
+ 'option_value' => isset($psp_settings['auto_redirection']) ? $psp_settings['auto_redirection'] : '',
1699
+ 'checkbox_label' => esc_html__('', 'platinum-seo-pack'),
1700
+ 'option_description' => esc_html__( 'Turn ON to enable automatics redirection of all Posts using Platinum SEO. this will automatically take care of changes in permalink format (Recommended).', 'platinum-seo-pack' ),
1701
+ );
1702
+
1703
+ $auto_redirection_field_id = 'psp_auto_redirection';
1704
+ //$auto_redirection_field_title = esc_html__('Automatically Redirect Posts: ', 'platinum-seo-pack');
1705
+ $auto_redirection_field_title = esc_html__('Automatically Redirect Posts: ', 'platinum-seo-pack').'<a href="https://techblissonline.com/redirection-in-wordpress/#automatic-http-redirection-in-wordpress" target="_blank" rel="noopener">'.'<br>'.esc_html__('How does this help?', 'platinum-seo-pack').'</a>';
1706
+
1707
+ add_settings_field( $auto_redirection_field_id, $auto_redirection_field_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_permalink_settings_group, $section_id, $auto_redirection_field );
1708
+
1709
+ $psp_301_limit_field = array (
1710
+ 'label_for' => 'psp_301_limit',
1711
+ 'option_name' => $psp_settings_name.'[limit_301]',
1712
+ 'option_value' => isset($psp_settings['limit_301']) ? $psp_settings['limit_301'] : '',
1713
+ 'option_label' => esc_html__( 'Rows', 'platinum-seo-pack' ),
1714
+ 'option_description' => esc_html__( 'Set the max number of entries in Redirection log.(Highly Recommended)', 'platinum-seo-pack' ),
1715
+ );
1716
+
1717
+ $psp_301_limit_field_id = 'psp_301_limit';
1718
+ $psp_301_limit_field_title = esc_html__('Limit Redirection Log to: ', 'platinum-seo-pack');
1719
+
1720
+ add_settings_field( $psp_301_limit_field_id, $psp_301_limit_field_title, array( &$this, 'psp_add_field_text_number' ), $this->psp_permalink_settings_group, $section_id, $psp_301_limit_field);
1721
+
1722
+ //404 Section
1723
+ $section_id = 'psp_404_section';
1724
+ $section_title = esc_html__('404 Errors', 'platinum-seo-pack');
1725
+
1726
+ add_settings_section( $section_id, $section_title, array( &$this, 'section_404errors_desc' ), $this->psp_permalink_settings_group );
1727
+
1728
+ //Fields
1729
+
1730
+ $enable_404_field = array (
1731
+ 'label_for' => 'psp_enable_404',
1732
+ 'option_name' => $psp_settings_name.'[enable_404]',
1733
+ 'option_value' => isset($psp_settings['enable_404']) ? $psp_settings['enable_404'] : '',
1734
+ 'checkbox_label' => esc_html__('', 'platinum-seo-pack'),
1735
+ 'option_description' => esc_html__( 'Turn ON to monitor 404 errors using Platinum SEO.', 'platinum-seo-pack' ),
1736
+ );
1737
+
1738
+ $psp_enable_404_field_id = 'psp_enable_404';
1739
+ $psp_enable_404_field_title = esc_html__('Track 404 errors: ', 'platinum-seo-pack');
1740
+
1741
+ add_settings_field( $psp_enable_404_field_id, $psp_enable_404_field_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_permalink_settings_group, $section_id, $enable_404_field );
1742
+
1743
+ $referrer_404_field = array (
1744
+ 'label_for' => 'psp_referrer_404',
1745
+ 'option_name' => $psp_settings_name.'[referrer_404]',
1746
+ 'option_value' => isset($psp_settings['referrer_404']) ? $psp_settings['referrer_404'] : '',
1747
+ 'checkbox_label' => esc_html__('', 'platinum-seo-pack'),
1748
+ 'option_description' => esc_html__( 'Turn ON to track only 404 errors that occur due to a bad link reference from the site linking to your site.', 'platinum-seo-pack' ),
1749
+ );
1750
+
1751
+ $psp_referrer_404_field_id = 'psp_referrer_404';
1752
+ $psp_referrer_404_field_title = esc_html__('Log 404s with referrers only: ', 'platinum-seo-pack');
1753
+
1754
+ //add_settings_field( $psp_referrer_404_field_id, $psp_referrer_404_field_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_permalink_settings_group, $section_id, $referrer_404_field );
1755
+
1756
+ $bots_404_field = array (
1757
+ 'label_for' => 'psp_bots_404',
1758
+ 'option_name' => $psp_settings_name.'[bots_404]',
1759
+ 'option_value' => isset($psp_settings['bots_404']) ? $psp_settings['bots_404'] : '',
1760
+ 'checkbox_label' => esc_html__('', 'platinum-seo-pack'),
1761
+ 'option_description' => esc_html__( 'Turn ON to log 404/410 errors encountered on your site by Search Engine Bots only - Eg. Googlebot and Bingbot (Recommended).', 'platinum-seo-pack' ),
1762
+ );
1763
+
1764
+ $psp_bots_404_field_id = 'psp_bots_404';
1765
+ //$psp_bots_404_field_title = esc_html__('Log errors for Search Engine Bots only: ', 'platinum-seo-pack');
1766
+ $psp_bots_404_field_title = esc_html__('Log errors for Search Engine Bots only: ', 'platinum-seo-pack').'<a href="https://techblissonline.com/http-404-error/#fix-404-errors" target="_blank" rel="noopener">'.'<br>'.esc_html__('How does this work?', 'platinum-seo-pack').'</a>';
1767
+
1768
+ add_settings_field( $psp_bots_404_field_id, $psp_bots_404_field_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_permalink_settings_group, $section_id, $bots_404_field );
1769
+
1770
+ add_settings_field( $psp_referrer_404_field_id, $psp_referrer_404_field_title, array( &$this, 'psp_add_field_checkbox' ), $this->psp_permalink_settings_group, $section_id, $referrer_404_field );
1771
+
1772
+ $psp_404_limit_field = array (
1773
+ 'label_for' => 'psp_404_limit',
1774
+ 'option_name' => $psp_settings_name.'[limit_404]',
1775
+ 'option_value' => isset($psp_settings['limit_404']) ? $psp_settings['limit_404'] : '',
1776
+ 'option_label' => esc_html__( 'Rows', 'platinum-seo-pack' ),
1777
+ 'option_description' => esc_html__( 'Set the max number of entries in 404 log.(Highly Recommended)', 'platinum-seo-pack' ),
1778
+ );
1779
+
1780
+ $psp_404_limit_field_id = 'psp_404_limit';
1781
+ $psp_404_limit_field_title = esc_html__('Limit 404 Log to: ', 'platinum-seo-pack');
1782
+
1783
+ add_settings_field( $psp_404_limit_field_id, $psp_404_limit_field_title, array( &$this, 'psp_add_field_text_number' ), $this->psp_permalink_settings_group, $section_id, $psp_404_limit_field);
1784
+
1785
  //Section
1786
  $section_id = 'psp_permalink_section';
1787
  $section_title = esc_html__('Permalink Structure for Taxonomies', 'platinum-seo-pack');
1823
 
1824
  function sanitize_permalink_settings($settings) {
1825
 
1826
+ if( isset( $settings['redirection'] ) ) {
1827
+ $settings['redirection'] = !is_null(filter_var($settings['redirection'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['redirection'] : '';
1828
+ }
1829
+
1830
+ if( isset( $settings['auto_redirection'] ) ) {
1831
+ $settings['auto_redirection'] = !is_null(filter_var($settings['auto_redirection'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['auto_redirection'] : '';
1832
+ }
1833
+
1834
+ if ( isset( $settings['limit_301'] ) ) {
1835
+ $settings['limit_301'] = sanitize_text_field( $settings['limit_301'] );
1836
+ if (!filter_var($settings['limit_301'], FILTER_VALIDATE_INT) ) {
1837
+ $settings['limit_301'] = '';
1838
+ }
1839
+ }
1840
+
1841
+ if( isset( $settings['enable_404'] ) ) {
1842
+ $settings['enable_404'] = !is_null(filter_var($settings['enable_404'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['enable_404'] : '';
1843
+ }
1844
+
1845
+ if( isset( $settings['referrer_404'] ) ) {
1846
+ $settings['referrer_404'] = !is_null(filter_var($settings['referrer_404'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['referrer_404'] : '';
1847
+ }
1848
+
1849
+ if( isset( $settings['bots_404'] ) ) {
1850
+ $settings['bots_404'] = !is_null(filter_var($settings['bots_404'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['bots_404'] : '';
1851
+ }
1852
+
1853
+ if ( isset( $settings['limit_404'] ) ) {
1854
+ $settings['limit_404'] = sanitize_text_field( $settings['limit_404'] );
1855
+ if (!filter_var($settings['limit_404'], FILTER_VALIDATE_INT) ) {
1856
+ $settings['limit_404'] = '';
1857
+ }
1858
+ }
1859
+
1860
  if ( isset( $settings['category'] ) ) {
1861
  $settings['category'] = !is_null(filter_var($settings['category'],FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE)) ? $settings['category'] : '';
1862
  } else {
1863
  $settings['category'] = "";
1864
+ }
1865
 
1866
  $custom_tax = array();
1867
  if (!empty($this->custom_taxonomies)) {
1877
  }
1878
 
1879
  }
1880
+ }
1881
 
1882
  return $settings;
1883
  }
2538
  function section_404_desc() { esc_html_e('Set the title format for 404 page.', 'platinum-seo-pack'); }
2539
  function section_nofollow_desc() { esc_html_e('These Nofollow settings are applied throughout the site wherever appropriate.', 'platinum-seo-pack'); }
2540
  function section_permalinks_desc() { echo esc_html__('These settings, if checked, will remove the base from taxonomies like Category and other custom taxonomies, if any. If "Remove base" is chosen for Category then the corresponding base will be removed from the permalink structure for categories.', 'platinum-seo-pack'). ' i.e. <code>Category</code>'; }
2541
+ function section_redirections_desc() {echo esc_html__('Manage your Redirecions ', 'platinum-seo-pack'). '<a href="/wp-admin/admin.php?page=redirectionmanager">'.esc_html__('here ', 'platinum-seo-pack').'</a>'; }
2542
+ function section_404errors_desc() {echo esc_html__('Manage your 404 errors ', 'platinum-seo-pack'). '<a id="404errors" href="/wp-admin/admin.php?page=manager404">'.esc_html__('here ', 'platinum-seo-pack').'</a>'; }
2543
  function section_cleanup_head_desc() { echo esc_html__('Remove unwanted links from HTML', 'platinum-seo-pack'). ' <code>&lt;head&gt;&lt;&#47;head&gt;</code>'.
2544
  esc_html__('Many of these links might not be needed in the head section for most sites and removing these might help reduce page size and also improve crawlability of more imortant links. So you may choose to remove those that are not needed for you site.', 'platinum-seo-pack'); }
2545
  function section_cleanup_comment_desc() { esc_html_e('Strip HTML and anchor tags embedded in comments. Note that these remove the HTML and links embedded in the comments and not the comment author links.', 'platinum-seo-pack'); }
2556
  function section_breadcrumb_desc() { echo esc_html__('These breadcrumb settings are for displaying breadcrumbs on the Post. It is built on top of Justin Tadlock\'s @BreadcrumbTrail package. Place the code', 'platinum-seo-pack').' <code>&lt;?php if ( function_exists( \'psp_breadcrumb_trail\' ) ) { psp_breadcrumb_trail(); } ?&gt;</code> '.esc_html__(' in your theme\'s single.php, at an apppropriate location, to display the generated breadcrumb trail. You may add the breadcrumb Json-LD schema (along with other schemas) in the Techblissonline Platinum SEO metabox for the Post.', 'platinum-seo-pack'); }
2557
  function section_schema_desc() {echo esc_html__('The following settings are not necessary if you had added these schemas in the Home page and/or Contacts Page JSON Schema Editor settings of this plugin.', 'platinum-seo-pack'). ' i.e. <br /> 1. '.esc_html__('Schema for enabling Sitelink Search Box in Google and', 'platinum-seo-pack').' <br /> 2. '. esc_html__('Schema for Knowledge Graph', 'platinum-seo-pack'); }
2558
 
2559
+ /**Callback for number textfield **/
2560
+ function psp_add_field_text_number(array $args) {
2561
+
2562
+ $option_name = isset($args['option_name']) ? $args['option_name'] : '';
2563
+ $id = isset($args['label_for']) ? $args['label_for'] : '';
2564
+ $option_value = isset($args['option_value']) ? $args['option_value'] : '';
2565
+ $option_description = isset($args['option_description']) ? esc_html( $args['option_description'] ) : '';
2566
+ $option_label = isset($args['option_label']) ? esc_html( $args['option_label'] ) : '';
2567
+ $desc_allowed_html = array('br' => array(), 'code' => array(), 'strong' => array(), 'em' => array(), 'i' => array(), 'bold' => array(), 'a' => array('href' => array(), 'target' => array()));
2568
+
2569
+ echo "<input id='".esc_attr($id)."' name='".esc_attr($option_name)."' style='width:20%' type='number' min='1' maxlength='5' value='".esc_attr($option_value)."' /> ".$option_label."<br/><p class='description'>".wp_kses(html_entity_decode($option_description), $desc_allowed_html)."</p>";//<br /><span class='describe'>Describe title</span>";
2570
+
2571
+ }
2572
+
2573
  /*
2574
  * Callback for adding a textfield.
2575
  */
2781
  //add_submenu_page($this->psp_plugin_options_key, __('Techblissonline Platinum SEO Analytics', 'platinum_seo_pack'), __('SEO - Analytics', 'platinum_seo_pack'), 'manage_options', 'psp-gatracking-by-techblissonline', array($this->psp_ga_instance, 'psp_ga_options_page'));
2782
  add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Tools', 'platinum_seo_pack'), '<span class="dashicons dashicons-edit"></span> '.esc_html__('SEO - Editors', 'platinum_seo_pack'), 'manage_options', 'psp-tools-by-techblissonline', array($this->psp_tools_instance, 'psp_tools_options_page'));
2783
  add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Premium Pack', 'platinum_seo_pack'), '<span class="dashicons dashicons-admin-tools"></span> '.esc_html__(' SEO Tools', 'platinum_seo_pack'), 'manage_options', 'psp-seo-tools-by-techblissonline', array( &$this, 'psp_pre_tools_display_page'));
2784
+ $psp_redir_page = add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Redirections', 'platinum_seo_pack'), '<span class="dashicons dashicons-admin-tools"></span> '.esc_html__('Redirections', 'platinum_seo_pack'), 'manage_options', 'redirectionmanager', array($this->psp_redirect_instance, 'redir_mgmtpage'));
2785
+ $psp_404_page = add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO 404 Manager', 'platinum_seo_pack'), '<span class="dashicons dashicons-admin-tools"></span> '.esc_html__('Manage 404 Errors', 'platinum_seo_pack'), 'manage_options', 'manager404', array($this->psp_redirect_instance, 'manage_404_page'));
2786
  //add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Premium Pack', 'platinum_seo_pack'), __('Techblissonline - SEO Tools', 'platinum_seo_pack'), 'manage_options', 'psp-seo-tools-by-techblissonline', array($this->psp_pre_instance, 'psp_pre_options_page'));
2787
  if ($psp_premium_valid) add_submenu_page($this->psp_plugin_options_key, esc_html__('Techblissonline Platinum SEO Premium Pack', 'platinum_seo_pack'), '<span class="dashicons dashicons-admin-network"></span> '.esc_html__('Premium - Licenses', 'platinum_seo_pack'), 'manage_options', 'pspp-licenses', array($this->psp_pre_instance, 'psp_premium_options_page'));
2788
  }
psp_main.php CHANGED
@@ -13,6 +13,8 @@ class PspMain {
13
  protected $psp_can_link = "";
14
  protected $psp_seo_meta_string = "";
15
 
 
 
16
  public $psp_breadcrumb_settings = array();
17
  public $psp_ga_settings = array();
18
 
@@ -29,6 +31,7 @@ class PspMain {
29
  $this->psp_social_handle = $psp_social_instance;
30
 
31
  $psp_tools_instance = PspToolSettings::get_instance();
 
32
 
33
 
34
  //get value for rss feeds indexing
@@ -541,6 +544,9 @@ class PspMain {
541
  $psp_redirect_to_url = isset($posttype_archive_settings['redirect_to_url']) ? $posttype_archive_settings['redirect_to_url'] : '';
542
  $psp_redirect_status_code = isset($posttype_archive_settings['redirect_status_code']) ? $posttype_archive_settings['redirect_status_code'] : '';
543
 
 
 
 
544
  }
545
  $psp_redirect_to_url = esc_url_raw($psp_redirect_to_url);
546
  //do wp redirect here
@@ -1266,6 +1272,82 @@ class PspMain {
1266
  }
1267
 
1268
  $psp_settings_instance->psp_refresh_rewrite_rules();
1269
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1270
  }
1271
  ?>
13
  protected $psp_can_link = "";
14
  protected $psp_seo_meta_string = "";
15
 
16
+ protected $psp_redirect_instance;
17
+
18
  public $psp_breadcrumb_settings = array();
19
  public $psp_ga_settings = array();
20
 
31
  $this->psp_social_handle = $psp_social_instance;
32
 
33
  $psp_tools_instance = PspToolSettings::get_instance();
34
+ $this->psp_redirect_instance = PspRedirections::get_instance();
35
 
36
 
37
  //get value for rss feeds indexing
544
  $psp_redirect_to_url = isset($posttype_archive_settings['redirect_to_url']) ? $posttype_archive_settings['redirect_to_url'] : '';
545
  $psp_redirect_status_code = isset($posttype_archive_settings['redirect_status_code']) ? $posttype_archive_settings['redirect_status_code'] : '';
546
 
547
+ } else if (is_404()) {
548
+ //$this->psp_handle_404();
549
+ if($this->psp_redirect_instance) $this->psp_redirect_instance->psp_handle_404();
550
  }
551
  $psp_redirect_to_url = esc_url_raw($psp_redirect_to_url);
552
  //do wp redirect here
1272
  }
1273
 
1274
  $psp_settings_instance->psp_refresh_rewrite_rules();
1275
+ }
1276
+
1277
+ public function psp_db_install() {
1278
+ global $wpdb;
1279
+ global $psp_db_version;
1280
+
1281
+ $psp_redirections_tbl = $wpdb->prefix . 'psp_redirections';
1282
+ $psp_redirections_log = $wpdb->prefix . 'psp_redirections_log';
1283
+ $psp_404_log = $wpdb->prefix . "psp_404_log";
1284
+
1285
+ $charset_collate = $wpdb->get_charset_collate();
1286
+ if ( get_site_option( 'psp_db_version' ) == $psp_db_version ) {
1287
+ return;
1288
+ }
1289
+
1290
+ if($wpdb->get_var("show tables like '$psp_redirections_tbl'") != $psp_redirections_tbl)
1291
+ {
1292
+ $psp_sql = "CREATE TABLE $psp_redirections_tbl (
1293
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
1294
+ source_url varchar(255) DEFAULT '' NOT NULL,
1295
+ dest_url varchar(255) DEFAULT '' NOT NULL,
1296
+ redir_code varchar(55) DEFAULT '' NOT NULL,
1297
+ log_redirect varchar(10) DEFAULT '' NOT NULL,
1298
+ created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
1299
+ PRIMARY KEY (id)
1300
+ ) $charset_collate;";
1301
+
1302
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1303
+ dbDelta( $psp_sql );
1304
+ }
1305
+
1306
+ if($wpdb->get_var("show tables like '$psp_redirections_log'") != $psp_redirections_log)
1307
+ {
1308
+ $psp_sql = "CREATE TABLE $psp_redirections_log (
1309
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
1310
+ source_uri varchar(255) DEFAULT '' NOT NULL,
1311
+ source_url varchar(255) DEFAULT '' NOT NULL,
1312
+ dest_url varchar(255) DEFAULT '' NOT NULL,
1313
+ redir_code varchar(55) DEFAULT '' NOT NULL,
1314
+ referrer varchar(255) DEFAULT '' NOT NULL,
1315
+ user_agent varchar(255) DEFAULT '' NOT NULL,
1316
+ ipaddress varchar(255) DEFAULT '' NOT NULL,
1317
+ created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
1318
+ PRIMARY KEY (id)
1319
+ ) $charset_collate;";
1320
+
1321
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1322
+ dbDelta( $psp_sql );
1323
+ }
1324
+
1325
+ if($wpdb->get_var("show tables like '$psp_404_log'") != $psp_404_log)
1326
+ {
1327
+ $psp_sql = "CREATE TABLE $psp_404_log (
1328
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
1329
+ source_uri varchar(255) DEFAULT '' NOT NULL,
1330
+ source_url varchar(255) DEFAULT '' NOT NULL,
1331
+ referrer varchar(255) DEFAULT '' NOT NULL,
1332
+ status varchar(20) DEFAULT '' NOT NULL,
1333
+ user_agent varchar(255) DEFAULT '' NOT NULL,
1334
+ ipaddress varchar(255) DEFAULT '' NOT NULL,
1335
+ total_hits mediumint(9) DEFAULT 1 NOT NULL,
1336
+ created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
1337
+ last_logged TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
1338
+ PRIMARY KEY (id)
1339
+ ) $charset_collate;";
1340
+
1341
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1342
+ dbDelta( $psp_sql );
1343
+ }
1344
+
1345
+ add_option( 'psp_db_version', $psp_db_version );
1346
+
1347
+ }
1348
+
1349
+ public function psp_loaded_filter() {
1350
+ add_filter('status_header', array($this->psp_redirect_instance, 'psp_log_404'), 10, 4);
1351
+ }
1352
  }
1353
  ?>
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: Techblissonline (Rajesh)
3
  Plugin link: https://techblissonline.com/platinum-wordpress-seo-plugin/
4
  Tags: seo, wordpress seo, plugin, google seo, platinum seo, schema, schema markup, Json schema
5
  Requires at least: 4.0
6
- Tested up to: 5.3.2
7
  Requires PHP: 5.6
8
- Stable tag: 2.0.5
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -15,7 +15,8 @@ Techblissonline Platinum wordpress SEO Plugin offers Complete onpage SEO solutio
15
 
16
  Techblissonline's **[ WordPress SEO Plugin](https://techblissonline.com/platinum-wordpress-seo-plugin/)** , [Platinum SEO Pack](https://techblissonline.com/platinum-seo-pack/) offers the ultimate onpage SEO solution to your Wordpress blog or website.The latest version of Techblissonline Platinum SEO Plugin has been completely rewritten and offers all the essential features you need to do your SEO and be the best WordPress Blog or Website.
17
 
18
- **[Download now!](http://downloads.wordpress.org/plugin/platinum-seo-pack.zip)**
 
19
 
20
  [FAQ](https://techblissonline.com/platinum-seo-pack-faq/)
21
 
@@ -34,7 +35,8 @@ Some features:
34
  * Support for custom post types
35
  * Support for custom taxonomies
36
  * Compatible with most other plugins. You can use Google XML Sitemap Generator to generate your sitemap. You can exclude any particular post/page/taxonomy from the sitemap through settings in the Techblissonline Platinum Wordpress SEO Plugin.
37
- * you can redirect any post or page to the desired location using 301, 302, 303 and 307.
 
38
  * Add index, noindex, follow or nofollow, noodp, noydir, noarchive, nosnippet meta tags to any post/page.
39
  * Plenty of other features.
40
 
@@ -62,6 +64,12 @@ Please read these **[FAQs](https://techblissonline.com/platinum-seo-pack-faq/)**
62
  4. Social Settings for Facebook, Twitter, Pinterest and LinkedIn. Generates Open Grah Tags and Twitter compatible Tags.
63
 
64
  == Changelog ==
 
 
 
 
 
 
65
  = 2.0.5 =
66
  * 2020-02-21 - Introduces Patinum SEO Content analysis that does a basic analysis of your content for focus keywords that you need to enter in meta ketwords input field as comma separated items. Note that meta keywords can be turned off sitewide in SEO -> General settings, if you do not want to add a meta keywords tag for posts and /or pages. You can even control it at the post or page level by switching it On/Off, if the sitewide setting is ON. Sitewide setting is Off by default. But you can get content analysis findings in your analysis dashboard, even if it is switched off. Also fixed a few other minor bugs.
67
 
3
  Plugin link: https://techblissonline.com/platinum-wordpress-seo-plugin/
4
  Tags: seo, wordpress seo, plugin, google seo, platinum seo, schema, schema markup, Json schema
5
  Requires at least: 4.0
6
+ Tested up to: 5.4
7
  Requires PHP: 5.6
8
+ Stable tag: 2.0.7
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
15
 
16
  Techblissonline's **[ WordPress SEO Plugin](https://techblissonline.com/platinum-wordpress-seo-plugin/)** , [Platinum SEO Pack](https://techblissonline.com/platinum-seo-pack/) offers the ultimate onpage SEO solution to your Wordpress blog or website.The latest version of Techblissonline Platinum SEO Plugin has been completely rewritten and offers all the essential features you need to do your SEO and be the best WordPress Blog or Website.
17
 
18
+ **[Fix 404 Errors](https://techblissonline.com/http-404-error/)**
19
+ **[Manage HTTP Redirections](https://techblissonline.com/redirection-in-wordpress/)**
20
 
21
  [FAQ](https://techblissonline.com/platinum-seo-pack-faq/)
22
 
35
  * Support for custom post types
36
  * Support for custom taxonomies
37
  * Compatible with most other plugins. You can use Google XML Sitemap Generator to generate your sitemap. You can exclude any particular post/page/taxonomy from the sitemap through settings in the Techblissonline Platinum Wordpress SEO Plugin.
38
+ * You have a 404 Manager.You can HTTP Redirect any Post or URL that returns a 404 Error. You can also set status to 410, if needed.
39
+ * You now have a complete Redirection Manager.You can redirect any post or page to the desired location using 301, 302, 303 and 307.
40
  * Add index, noindex, follow or nofollow, noodp, noydir, noarchive, nosnippet meta tags to any post/page.
41
  * Plenty of other features.
42
 
64
  4. Social Settings for Facebook, Twitter, Pinterest and LinkedIn. Generates Open Grah Tags and Twitter compatible Tags.
65
 
66
  == Changelog ==
67
+ = 2.0.7 =
68
+ * 2020-04-05 - Updation to help file links in Redirections Settings.
69
+
70
+ = 2.0.6 =
71
+ * 2020-04-05 - Introduces a complete HTTP Redirections Manager. It also now has a 404 Manager that lets you track and fix any 404 Error. This 404 Manager is integrated with Redirections to resolve the 404 Error by Creating appropriate HTTP Redirection. Make sure to clear browser cache after updating the plugin.
72
+
73
  = 2.0.5 =
74
  * 2020-02-21 - Introduces Patinum SEO Content analysis that does a basic analysis of your content for focus keywords that you need to enter in meta ketwords input field as comma separated items. Note that meta keywords can be turned off sitewide in SEO -> General settings, if you do not want to add a meta keywords tag for posts and /or pages. You can even control it at the post or page level by switching it On/Off, if the sitewide setting is ON. Sitewide setting is Off by default. But you can get content analysis findings in your analysis dashboard, even if it is switched off. Also fixed a few other minor bugs.
75