SEO Redirection Plugin - Version 8.4

Version Description

  • ui enhancement
Download this release

Release Info

Developer osamaesh
Plugin Icon 128x128 SEO Redirection Plugin
Version 8.4
Comparing to
See all releases

Code changes from version 8.3 to 8.4

common/controls/cf_tab.php CHANGED
@@ -6,109 +6,97 @@ Contact: www.clogica.com info@clogica.com mobile: +972599322252
6
 
7
  */
8
 
9
- if(!class_exists('phptab')){
10
- class phptab{
 
11
 
12
- var $tabs; // each tab has num,title,content,parameter.
13
- var $parameter = 'tab';
14
- var $ignore_parameters='';
15
 
16
 
17
- function __construct($parameter='tab')
18
- {
19
- $this->tabs = array();
20
- $this->$parameter = $parameter;
21
- }
22
-
23
- //----------------------------------------------------------------------------
24
-
25
- function add_file_tab($num, $title, $content, $type )
26
- {
27
- $index=$this->tabs_count();
28
- $this->tabs[$index] = array('num' => $num , 'title'=> $title, 'content'=> $content, 'type' => $type );
29
 
30
- }
31
 
32
-
33
- //----------------------------------------------------------------------------
 
 
 
34
 
35
- function tabs_count()
36
- {
37
- if(is_array($this->tabs))
38
- return count($this->tabs);
39
- else
40
- return 0;
41
- }
42
-
43
- //----------------------------------------------------------------------------
44
-
45
- function set_ignore_parameter($ar)
46
- {
47
- if(is_array($ar))
48
- $this->ignore_parameters =$ar;
49
- else
50
- $this->ignore_parameters =array($ar);
51
- }
52
-
53
- //----------------------------------------------------------------------------
54
 
55
- function get_ignore_parameter($ar)
56
- {
57
- return $this->ignore_parameters;
58
- }
59
-
60
- //----------------------------------------------------------------------------
61
- function run()
62
- {
63
- global $util;
64
-
65
- $tab_index= htmlspecialchars(strip_tags($util->get($this->parameter, 'url')));
66
-
67
- if($tab_index=='')
68
- $tab_index=$this->tabs[0]['num'];
69
-
70
- $options_path='';
71
- if(is_array($this->ignore_parameters))
72
  {
73
- $ignore=array_merge(array($this->parameter),$this->ignore_parameters);
74
- $options_path= $util->WPSR_get_current_parameters($ignore);
75
- }else
 
 
 
 
 
 
76
  {
77
- $options_path= $util->WPSR_get_current_parameters($this->parameter);
 
 
 
78
  }
79
-
80
-
81
- $num_index=-1;
82
- echo '<ul class="tabs">';
83
-
84
- for($i=0;$i<$this->tabs_count();$i++)
 
 
 
 
85
  {
86
- if($this->tabs[$i]['num']==$tab_index){
87
- echo '<li class="active"><a href="' . esc_url($options_path . '&' . $this->parameter .'=' . $this->tabs[$i]['num']) . '">' . esc_html(strip_tags($this->tabs[$i]['title'])) . '</a></li>';
88
- $num_index=$i;
 
 
 
 
 
 
 
 
 
 
89
  }
90
- else
91
- {
92
- echo '<li><a href="' . esc_url($options_path . '&' . $this->parameter .'=' . $this->tabs[$i]['num']) . '">' . esc_html(strip_tags($this->tabs[$i]['title'])) . '</a></li>';
 
 
 
 
 
 
 
 
 
93
  }
94
- }
95
-
96
- echo '</ul>';
97
-
98
-
99
-
100
- if($num_index>=0)
101
- {
102
- echo '<div class="tabContainer"><div id="tab1" class="tabContent">';
103
- include $util->get_plugin_path() . 'options/' . $this->tabs[$num_index]['content'];
104
- echo '</div></div>';
105
- }
106
-
107
-
108
-
109
- }
110
 
 
111
 
112
- }}
113
 
114
- ?>
 
 
 
 
 
 
 
 
6
 
7
  */
8
 
9
+ if (!class_exists('phptab')) {
10
+ class phptab
11
+ {
12
 
13
+ var $tabs; // each tab has num,title,content,parameter.
14
+ var $parameter = 'tab';
15
+ var $ignore_parameters = '';
16
 
17
 
18
+ function __construct($parameter = 'tab')
19
+ {
20
+ $this->tabs = array();
21
+ $this->$parameter = $parameter;
22
+ }
 
 
 
 
 
 
 
23
 
24
+ //----------------------------------------------------------------------------
25
 
26
+ function add_file_tab($num, $title, $content, $type)
27
+ {
28
+ $index = $this->tabs_count();
29
+ $this->tabs[$index] = array('num' => $num, 'title' => $title, 'content' => $content, 'type' => $type);
30
+ }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ //----------------------------------------------------------------------------
34
+
35
+ function tabs_count()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  {
37
+ if (is_array($this->tabs))
38
+ return count($this->tabs);
39
+ else
40
+ return 0;
41
+ }
42
+
43
+ //----------------------------------------------------------------------------
44
+
45
+ function set_ignore_parameter($ar)
46
  {
47
+ if (is_array($ar))
48
+ $this->ignore_parameters = $ar;
49
+ else
50
+ $this->ignore_parameters = array($ar);
51
  }
52
+
53
+ //----------------------------------------------------------------------------
54
+
55
+ function get_ignore_parameter($ar)
56
+ {
57
+ return $this->ignore_parameters;
58
+ }
59
+
60
+ //----------------------------------------------------------------------------
61
+ function run()
62
  {
63
+ global $util;
64
+
65
+ $tab_index = htmlspecialchars(strip_tags($util->get($this->parameter, 'url')));
66
+
67
+ if ($tab_index == '')
68
+ $tab_index = $this->tabs[0]['num'];
69
+
70
+ $options_path = '';
71
+ if (is_array($this->ignore_parameters)) {
72
+ $ignore = array_merge(array($this->parameter), $this->ignore_parameters);
73
+ $options_path = $util->WPSR_get_current_parameters($ignore);
74
+ } else {
75
+ $options_path = $util->WPSR_get_current_parameters($this->parameter);
76
  }
77
+
78
+
79
+ $num_index = -1;
80
+ echo '<ul class="tabs">';
81
+
82
+ for ($i = 0; $i < $this->tabs_count(); $i++) {
83
+ if ($this->tabs[$i]['num'] == $tab_index) {
84
+ echo '<li class="active"> <a href="' . esc_url($options_path . '&' . $this->parameter . '=' . $this->tabs[$i]['num']) . '"> ' . esc_html(strip_tags($this->tabs[$i]['title'])) . '</a></li>';
85
+ $num_index = $i;
86
+ } else {
87
+ echo '<li><a href="' . esc_url($options_path . '&' . $this->parameter . '=' . $this->tabs[$i]['num']) . '">' . esc_html(strip_tags($this->tabs[$i]['title'])) . '</a></li>';
88
+ }
89
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ echo '</ul>';
92
 
 
93
 
94
+
95
+ if ($num_index >= 0) {
96
+ echo '<div class="tabContainer"><div id="tab1" class="tabContent">';
97
+ include $util->get_plugin_path() . 'options/' . $this->tabs[$num_index]['content'];
98
+ echo '</div></div>';
99
+ }
100
+ }
101
+ }
102
+ }
common/custom.css ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
2
+ ul.tabs{
3
+ display: flex;
4
+ align-items: center;
5
+ height: 55px;
6
+ font-family: 'Poppins', sans-serif;
7
+ background-color: #6c79e025 !important;
8
+ }
9
+ ul.tabs li{
10
+ border:none;
11
+ background: transparent !important;
12
+ margin: 0;
13
+ position: relative;
14
+ border-radius: 0 !important;
15
+ overflow:inherit;
16
+ height: 55px;
17
+ line-height: 55px;
18
+ transition: .3s all;
19
+ }
20
+
21
+ ul.tabs li a{
22
+ display: inline-block;
23
+ border:none;
24
+ color: #666;
25
+ transition: .3s all;
26
+ text-align: center;
27
+ height:55px;
28
+ line-height: 55px;
29
+ font-size: 14px;
30
+ padding: 1px 28px 1px 40px;
31
+ }
32
+ ul.tabs li:nth-child(1):before ,ul.tabs li:nth-child(2):before ,ul.tabs li:nth-child(3):before ,ul.tabs li:nth-child(4):before , ul.tabs li:nth-child(5):before,ul.tabs li:nth-child(6):before {
33
+ font-size: 24px;
34
+ position: absolute;
35
+ left: 10px;
36
+ color: #6C7AE0 ;
37
+ }
38
+ ul.tabs li:nth-child(2):before {
39
+ content: "✎";
40
+ }
41
+ ul.tabs li:nth-child(1)::before{
42
+ content: "✔";
43
+ }
44
+ ul.tabs li:nth-child(3)::before{
45
+ content: "✉";
46
+ }
47
+ ul.tabs li:nth-child(4)::before{
48
+ font-size: 23px;
49
+ content: "✘";
50
+ }
51
+ ul.tabs li:nth-child(5)::before{
52
+ content: "☰";
53
+ }
54
+ ul.tabs li:nth-child(6)::before{
55
+ content: "✇";
56
+ }
57
+ html ul.tabs li.active{
58
+ border-top: 3px solid #6C7AE0;
59
+ height: 57px;
60
+ }
61
+ html ul.tabs li:nth-of-type(1).active{
62
+ border-left: 1px solid #ddd;
63
+ }
64
+ ul.tabs li.active a {
65
+ color: #6C7AE0 ;
66
+ background: #fff !important;
67
+ }
68
+ html ul.tabs li a:focus{
69
+ box-shadow: none !important;
70
+ }
71
+ html ul.tabs li.active a:hover{
72
+ border-bottom: none !important;
73
+ }
74
+ .tabContainer{
75
+ border: 1px solid #ddd;
76
+ border-top: none !important;
77
+ }
78
+
79
+ /* btn */
80
+ .btn-custom{
81
+ padding: 1px 10px !important;
82
+ border-radius: 2px !important;
83
+ border: none !important;
84
+ color: #fff !important;
85
+ transition: .3s all;
86
+ font-family: 'Poppins', sans-serif;
87
+ }
88
+ .btn-add{
89
+ background-color: #00C851 !important;
90
+ box-shadow: #00c8507e 0px 10px 15px -10px ;
91
+ }
92
+ .btn-search{
93
+ background-color: #4285F4 !important;
94
+ box-shadow: #4286f48a 0px 10px 15px -10px ;
95
+ }
96
+ .btn-showAll{
97
+ background-color: #212121 !important;
98
+ box-shadow: #21212193 0px 10px 15px -10px ;
99
+ }
100
+ .btn-delete{
101
+ background-color: #FF3547 !important;
102
+ box-shadow: #ff35469f 0px 10px 15px -10px ;
103
+ }
104
+ .btn-custom:hover {
105
+ transform: translateY(-2px);
106
+ }
107
+ .link_buttons a{
108
+ margin: 0 2px auto !important;
109
+ }
110
+ .btn-right{
111
+ display: flex ;
112
+ align-items: flex-start;
113
+ justify-content: flex-end;
114
+ }
115
+
116
+ .dashicons-admin-media{
117
+ line-height: 2 !important;
118
+ }
119
+
120
+ /**** table ****/
121
+ table.widefat {
122
+ border: 1px solid #eee !important;
123
+ box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px !important;
124
+ border-radius: 5px !important;
125
+ }
126
+ .widefat tfoot tr td, .widefat tfoot tr th, .widefat thead tr td, .widefat thead tr th {
127
+ background-color: #6C7AE0 !important;
128
+ color: #fff !important;
129
+ font-family: 'Poppins', sans-serif;
130
+ padding: 12px !important;
131
+ }
132
+ .widefat td, .widefat th {
133
+ padding: 12px ;
134
+ transition: .3s all;
135
+ }
136
+ .widefat tr:hover{
137
+ background-color: #6c79e025 !important;
138
+ }
139
+ .widefat tr{
140
+ background-color: #fff !important;
141
+ border-bottom: 1px solid #eee;
142
+ }
143
+ .cform tbody tr:nth-child(odd){
144
+ background-color: transparent !important;
145
+ }
146
+ .pagination a{
147
+ background: #212121;
148
+ color: #fff;
149
+ padding: 3px 20px;
150
+ box-shadow: #21212193 0px 10px 20px -10px ;
151
+ transition: .3s all;
152
+ border-radius: 3px !important;
153
+ }
154
+ .pagination a:hover{
155
+ background-color: #111111 !important;
156
+ box-shadow: #21212193 0px 10px 20px -5px ;
157
+ transform: translateY(-2px);
158
+ }
159
+ .Page_background_1 , .widefat td, .widefat th , .modal-title , #myform .cform select , .cform tbody td.label , h3 , td{
160
+ font-family: 'Poppins', sans-serif;
161
+ }
162
+ .wp-core-ui select{
163
+ border-radius: 5px !important;
164
+ border-color: #c4ccd3 !important;
165
+ }
166
+
167
+ /* modal */
168
+ .close{
169
+ color:#212121 ;
170
+ font-size: 26px;
171
+ font-weight: bold;
172
+ padding: 3px 12px;
173
+ border: none;
174
+ outline: none;
175
+ transition: .3s all;
176
+ background: none !important;
177
+ }
178
+ .modal-title{
179
+ font-size: 22px !important;
180
+ }
181
+ .cform td{
182
+ padding: 5px 7px !important;
183
+ font-size: 12px;
184
+ }
185
+ .modal-body .cform td{
186
+ font-size: 14px;
187
+ width: 70%;
188
+ }
189
+ #redirect_from, #redirect_to{
190
+ width: 90% !important;
191
+ margin-top: 10px !important;
192
+ outline: none !important;
193
+ border-color: #c4ccd3 !important;
194
+ }
195
+ #myform .cform select{
196
+ width: 40%;
197
+ border-radius: 3px !important;
198
+ border-color: #c4ccd3 !important;
199
+ }
200
+ .link_buttons a{
201
+ background: #4285F4 ;
202
+ font-size: 14px;
203
+ }
204
+ input[type=text]{
205
+ border-color: #c4ccd3 !important;
206
+ }
207
+
208
+ /* sweetalert */
209
+ .placeholder{
210
+ background: transparent !important;
211
+ border-color: #00C851;
212
+ }
options/help.php CHANGED
@@ -1,30 +1,30 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
- $imgpath= $util->get_plugin_url().'custom/images/';
4
  ?>
5
- <h2><img height="30px" src="<?php echo esc_url($imgpath) ?>help-icon.png">&nbsp;<?php _e("Help Center","seo-redirection") ?>;</h2>
6
- <hr/>
7
  <div class="row">
8
- <div class="col-sm-12">
9
- <p><?php _e('We recommend before contacting us and wait for reply, to explore the product page in our knowledge base, it contains many articles about how to use the plugin','seo-redirection') ?><br/>
10
- <b><?php _e("To go to the",'seo-redirection') ?> <a target="_blank" href="http://www.clogica.com/kb/topics/seo-redirection-premium"><?php _e("knowledge base click here","seo-redirection") ?></a></b></p>
11
- <br/>
12
- <h2 style="display: inline; color: #636465; font-size:24px"><b><?php _e("Open a new ticket?","seo-redirection") ?></b></h2>
13
- </div>
14
  </div>
15
- <div class="row">
16
- <div class="col-sm-10">
17
-
18
-
19
-
20
- <div class="form-group">
21
- <div class="col-sm-offset-1 col-sm-7">
22
- <p><?php _e("Please provide as much details as possible so we can best assist you. To update a previously submitted ticket, Please login.",'seo-redirection') ?></p>
23
-
24
- <button class="button-secondary" type="button" name="new_ticket" target="newwindow" onclick="window.open('http://www.clogica.com/support-center','_blank')" value="btn_send"><?php _e("Open a new ticket now","seo-redirection") ?></button>
25
- </div>
26
- </div>
27
 
 
 
 
 
 
 
28
  </div>
29
- </div>
30
 
 
 
1
  <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+ $imgpath = $util->get_plugin_url() . 'custom/images/';
4
  ?>
5
+ <h2><img height="30px" src="<?php echo esc_url($imgpath) ?>help-icon.png">&nbsp;<?php _e("Help Center", "seo-redirection") ?>;</h2>
6
+ <hr />
7
  <div class="row">
8
+ <div class="col-sm-12">
9
+ <p><?php _e('We recommend before contacting us and wait for reply, to explore the product page in our knowledge base, it contains many articles about how to use the plugin', 'seo-redirection') ?><br />
10
+ <b><?php _e("To go to the", 'seo-redirection') ?> <a target="_blank" href="http://www.clogica.com/kb/topics/seo-redirection-premium"><?php _e("knowledge base click here", "seo-redirection") ?></a></b>
11
+ </p>
12
+ <br />
13
+ <h2 style="display: inline; color: #636465; font-size:24px"><b><?php _e("Open a new ticket?", "seo-redirection") ?></b></h2>
14
  </div>
15
+ </div>
16
+ <div class="row">
17
+ <div class="col-sm-10">
18
+
19
+
 
 
 
 
 
 
 
20
 
21
+ <div class="form-group">
22
+ <div class="col-sm-offset-1 col-sm-7">
23
+ <p><?php _e("Please provide as much details as possible so we can best assist you. To update a previously submitted ticket, Please login.", 'seo-redirection') ?></p>
24
+
25
+ <button class="button-secondary btn-custom btn-search" type="button" name="new_ticket" target="newwindow" onclick="window.open('https://www.wp-buy.com/support-center','_blank')" value="btn_send"><?php _e("Open a new ticket now", "seo-redirection") ?></button>
26
+ </div>
27
  </div>
 
28
 
29
+ </div>
30
+ </div>
options/option_page_404.php CHANGED
@@ -1,168 +1,162 @@
1
  <?php
2
 
3
- global $wpdb,$table_prefix,$util;
4
-
5
- $table_name = $table_prefix . 'WP_SEO_404_links';
6
-
7
- if($util->post('redirect_to')!='')
8
- {
9
- global $util;
10
-
11
- $util->update_post_option('p404_status');
12
- $util->update_option('p404_redirect_to',$util->make_relative_url($util->post('redirect_to')));
13
- $util->success_option_msg('Options Saved!');
14
-
15
- if($util->there_is_cache()!='')
16
- $util->info_option_msg("You have a cache plugin installed <b>'" . $util->there_is_cache() . "'</b>, you have to clear cache after any changes to get the changes reflected immediately! ");
17
-
 
 
 
 
 
 
 
18
  }
19
-
20
- if($util->get('do_404_del')!='')
21
- {
22
- if($util->get('do_404_del') == 1)
23
- {
24
- $wpdb->query("delete from $table_name where ctime <= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)");
25
-
26
- }else if($util->get('do_404_del') == 2)
27
- {
28
- $wpdb->query("delete from $table_name where ctime <= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)");
29
- }else if($util->get('do_404_del') == 3)
30
- {
31
- $wpdb->query("Truncate table $table_name ");
32
- }
33
-
34
  }
35
-
36
 
37
-
38
- $options= $util->get_my_options();
39
 
40
 
41
- if($util->get_option_value('p404_discovery_status')!='1')
42
- $util->info_option_msg("404 error pages discovery property is disabled now!, you can re-enable it from options tab.");
 
 
 
43
 
44
 
45
 
46
- $WPSR_get_current_parameters_ = $util->WPSR_get_current_parameters(array('search','page_num','add','edit'));
47
 
48
  ?>
49
 
50
  <script type="text/javascript">
 
51
 
52
- //---------------------------------------------------------
 
 
 
 
53
 
54
- function decodeHtmlCharCodes(str) {
55
- return str.replace(/(&#(\d+);)/g, function(match, capture, charCode) {
56
- return String.fromCharCode(charCode);
57
- });
58
- }
59
 
 
 
 
 
 
 
 
 
 
60
 
61
- function go_search(){
62
- var sword = document.getElementById('search').value;
63
- if(sword!=''){
64
- var link = decodeHtmlCharCodes("<?php echo sprintf('%s', esc_js($WPSR_get_current_parameters_));?>")+"&search=" + sword;
65
- window.location = link ;
66
- }else
67
- {
68
- alert('Please input any search words!');
69
- document.getElementById('search').focus();
70
  }
71
-
72
- }
73
-
74
 
75
- function go_del()
76
- {
77
-
78
- if (confirm('Are you sure you want to delete all 404 links?')) {
79
- var goto_url = decodeHtmlCharCodes("<?php echo sprintf('%s', esc_js($WPSR_get_current_parameters_));?>");
80
-
81
- window.location = goto_url+"&do_404_del=" + document.getElementById('del_404_option').value;
82
- }
83
- }
84
 
 
85
 
 
 
86
 
 
 
 
87
  </script>
88
 
89
- <h3>New Discovered 404 links<hr></h3>
 
 
90
  <div class="link_buttons">
91
- <table border="0" width="100%">
92
- <tr>
93
- <td align="left">
94
- <input onkeyup="if (event.keyCode == 13) go_search();" style="height: 30px;" id="search" type="text" name="search" value="<?php echo htmlentities(esc_attr($util->get('search')))?>" size="40">
95
- <a onclick="go_search()" href="#"><div class="search_link">Search</div></a>
96
- <a href="<?php echo esc_url($util->WPSR_get_current_parameters('search'));?>"><div class="see_link">Show All</div></a>
97
- </td>
98
- <td align="right">
99
- <select data-size="5" class="selectpicker" name="del_404_option" id="del_404_option">
100
- <option value="1"><?php echo __('Keep this month','seo-redirection');?></option>
101
- <option value="2"><?php echo __('Keep last 3 months','seo-redirection');?></option>
102
- <option value="3"><?php echo __('Delete all','seo-redirection');?></option>
103
- </select>
104
- <a onclick="go_del()" href="#"><div class="del_link">Delete</div></a>
105
- </td>
106
- </tr>
107
- </table>
 
 
 
 
 
 
 
 
 
108
  </div>
109
  <?php
110
-
111
- $grid = new datagrid();
112
- $grid->set_data_source($table_name);
113
- $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
114
- $grid->add_select_field('ID');
115
- $grid->add_select_field('link');
116
- $grid->add_select_field('ip');
117
- $grid->add_select_field('referrer');
118
-
119
- $grid->set_order(" ID desc ");
120
-
121
- if($util->get('search')!='')
122
- {
123
- $search=$util->get('search');
124
-
125
- $grid->set_filter(" link like '%%$search%%' or ctime like '%%$search%%'
126
  or referrer like '%%$search%%' or country like '%%$search%%' or ip like '%%$search%%'
127
  or os like '%%$search%%' or browser like '%%$search%%'
128
  ");
129
- }
130
-
131
- $grid->set_table_attr('width','100%');
132
-
133
- $grid->set_col_attr(1,'width','60%');
134
- $grid->set_col_attr(1,'align','left');
135
-
136
- $grid->set_col_attr(2,'width','30%');
137
- $grid->set_col_attr(2,'align','left');
138
-
139
- $grid->set_col_attr(3,'width','30%');
140
- $grid->set_col_attr(3,'align','left');
141
-
142
-
143
-
144
- $grid->add_php_col(" <a target='_blank' href='db_link_url'>db_link</a>",'Link');
145
- $grid->add_data_col('ctime','Discovered');
146
-
147
- if($util->get_option_value('ip_logging_status') == 0)
148
- {
149
- $grid->add_html_col('--',__('IP','seo-redirection'));
150
- }else if($util->get_option_value('ip_logging_status') == 1)
151
- {
152
- $grid->add_html_col('<a target="_blank" href="https://tools.keycdn.com/geo?host={db_ip}">{db_ip}</a>',__('IP','seo-redirection'));
153
- }else{
154
-
155
- $grid->add_php_col(' db_ip ',__('IP','seo-redirection'));
156
- }
157
-
158
-
159
-
160
-
161
- $grid->run();
162
-
163
-
164
-
165
  ?>
166
  <div><b style="color:red">Have many broken links?</b><br />
167
- keep track of 404 errors using our powerful SEO Redirection Plugin to show and fix all broken links & 404 errors that occur on your site. <a target="_blank" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/">click here to fix and improve your site SEO</a></div>
168
- <br/><br/>
1
  <?php
2
 
3
+ global $wpdb, $table_prefix, $util;
4
+
5
+ $table_name = $table_prefix . 'WP_SEO_404_links';
6
+
7
+ if ($util->post('redirect_to') != '') {
8
+ global $util;
9
+
10
+ $util->update_post_option('p404_status');
11
+ $util->update_option('p404_redirect_to', $util->make_relative_url($util->post('redirect_to')));
12
+ $util->success_option_msg('Options Saved!');
13
+
14
+ if ($util->there_is_cache() != '')
15
+ $util->info_option_msg("You have a cache plugin installed <b>'" . $util->there_is_cache() . "'</b>, you have to clear cache after any changes to get the changes reflected immediately! ");
16
+ }
17
+
18
+ if ($util->get('do_404_del') != '') {
19
+ if ($util->get('do_404_del') == 1) {
20
+ $wpdb->query("delete from $table_name where ctime <= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)");
21
+ } else if ($util->get('do_404_del') == 2) {
22
+ $wpdb->query("delete from $table_name where ctime <= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)");
23
+ } else if ($util->get('do_404_del') == 3) {
24
+ $wpdb->query("Truncate table $table_name ");
25
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
 
27
 
 
 
28
 
29
 
30
+ $options = $util->get_my_options();
31
+
32
+
33
+ if ($util->get_option_value('p404_discovery_status') != '1')
34
+ $util->info_option_msg("404 error pages discovery property is disabled now!, you can re-enable it from options tab.");
35
 
36
 
37
 
38
+ $WPSR_get_current_parameters_ = $util->WPSR_get_current_parameters(array('search', 'page_num', 'add', 'edit'));
39
 
40
  ?>
41
 
42
  <script type="text/javascript">
43
+ //---------------------------------------------------------
44
 
45
+ function decodeHtmlCharCodes(str) {
46
+ return str.replace(/(&#(\d+);)/g, function(match, capture, charCode) {
47
+ return String.fromCharCode(charCode);
48
+ });
49
+ }
50
 
 
 
 
 
 
51
 
52
+ function go_search() {
53
+ var sword = document.getElementById('search').value;
54
+ if (sword != '') {
55
+ var link = decodeHtmlCharCodes("<?php echo sprintf('%s', esc_js($WPSR_get_current_parameters_)); ?>") + "&search=" + sword;
56
+ window.location = link;
57
+ } else {
58
+ alert('Please input any search words!');
59
+ document.getElementById('search').focus();
60
+ }
61
 
 
 
 
 
 
 
 
 
 
62
  }
 
 
 
63
 
 
 
 
 
 
 
 
 
 
64
 
65
+ function go_del() {
66
 
67
+ if (confirm('Are you sure you want to delete all 404 links?')) {
68
+ var goto_url = decodeHtmlCharCodes("<?php echo sprintf('%s', esc_js($WPSR_get_current_parameters_)); ?>");
69
 
70
+ window.location = goto_url + "&do_404_del=" + document.getElementById('del_404_option').value;
71
+ }
72
+ }
73
  </script>
74
 
75
+ <h3>New Discovered 404 links
76
+ <hr>
77
+ </h3>
78
  <div class="link_buttons">
79
+ <table border="0" width="100%">
80
+ <tr>
81
+ <td align="left">
82
+ <input onkeyup="if (event.keyCode == 13) go_search();" style="height: 30px; border-radius: 3px !important;" id="search" type="text" name="search" value="<?php echo htmlentities(esc_attr($util->get('search'))) ?>" size="40">
83
+ <a onclick="go_search()" style="padding:3px 10px !important" class="btn-custom btn-search" href="#">
84
+ <span class="dashicons dashicons-search"></span>
85
+ Search
86
+ </a>
87
+ <a class="btn-custom btn-search" style="padding:3px 10px !important" href="<?php echo esc_url($util->WPSR_get_current_parameters('search')); ?>">
88
+ <span class="dashicons dashicons-screenoptions"></span>
89
+ Show All
90
+ </a>
91
+ </td>
92
+ <td align="right">
93
+ <select style="height: 30px; border-radius: 3px !important;" data-size="5" class="selectpicker" name="del_404_option" id="del_404_option">
94
+ <option value="1"><?php echo __('Keep this month', 'seo-redirection'); ?></option>
95
+ <option value="2"><?php echo __('Keep last 3 months', 'seo-redirection'); ?></option>
96
+ <option value="3"><?php echo __('Delete all', 'seo-redirection'); ?></option>
97
+ </select>
98
+ <a class="btn-custom btn-delete" style="padding:3px 10px !important" onclick="go_del()" href="#">
99
+ <span class="dashicons dashicons-trash"></span>
100
+ Delete
101
+ </a>
102
+ </td>
103
+ </tr>
104
+ </table>
105
  </div>
106
  <?php
107
+
108
+ $grid = new datagrid();
109
+ $grid->set_data_source($table_name);
110
+ $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
111
+ $grid->add_select_field('ID');
112
+ $grid->add_select_field('link');
113
+ $grid->add_select_field('ip');
114
+ $grid->add_select_field('referrer');
115
+
116
+ $grid->set_order(" ID desc ");
117
+
118
+ if ($util->get('search') != '') {
119
+ $search = $util->get('search');
120
+
121
+ $grid->set_filter(" link like '%%$search%%' or ctime like '%%$search%%'
 
122
  or referrer like '%%$search%%' or country like '%%$search%%' or ip like '%%$search%%'
123
  or os like '%%$search%%' or browser like '%%$search%%'
124
  ");
125
+ }
126
+
127
+ $grid->set_table_attr('width', '100%');
128
+
129
+ $grid->set_col_attr(1, 'width', '60%');
130
+ $grid->set_col_attr(1, 'align', 'left');
131
+
132
+ $grid->set_col_attr(2, 'width', '30%');
133
+ $grid->set_col_attr(2, 'align', 'left');
134
+
135
+ $grid->set_col_attr(3, 'width', '30%');
136
+ $grid->set_col_attr(3, 'align', 'left');
137
+
138
+
139
+
140
+ $grid->add_php_col(" <a target='_blank' href='db_link_url'>db_link</a>", 'Link');
141
+ $grid->add_data_col('ctime', 'Discovered');
142
+
143
+ if ($util->get_option_value('ip_logging_status') == 0) {
144
+ $grid->add_html_col('--', __('IP', 'seo-redirection'));
145
+ } else if ($util->get_option_value('ip_logging_status') == 1) {
146
+ $grid->add_html_col('<a target="_blank" href="https://tools.keycdn.com/geo?host={db_ip}">{db_ip}</a>', __('IP', 'seo-redirection'));
147
+ } else {
148
+
149
+ $grid->add_php_col(' db_ip ', __('IP', 'seo-redirection'));
150
+ }
151
+
152
+
153
+
154
+
155
+ $grid->run();
156
+
157
+
158
+
 
 
159
  ?>
160
  <div><b style="color:red">Have many broken links?</b><br />
161
+ keep track of 404 errors using our powerful SEO Redirection Plugin to show and fix all broken links & 404 errors that occur on your site. <a target="_blank" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/">click here to fix and improve your site SEO</a></div>
162
+ <br /><br />
options/option_page_custome_redirection_list.php CHANGED
@@ -6,327 +6,309 @@ $table_name = $table_prefix . 'WP_SEO_Redirection';
6
 
7
 
8
 
9
- $rlink = $util->WPSR_get_current_parameters(array( 'search', 'page_num', 'add', 'edit', 'tab'));
10
 
11
  $redirect_from = isset($redirect_from) ? $redirect_from : '';
12
  $redirect_to = isset($redirect_to) ? $redirect_to : '';
13
  ?>
14
- <br/>
15
 
16
  <script type="text/javascript">
 
17
 
18
- //---------------------------------------------------------
19
-
20
- function check_valid_redirect_from()
21
- {
22
- var site = "<?php echo home_url();?>";
23
  var redirect_from = document.getElementById('redirect_from').value;
24
  var redirect_from_type = document.getElementById('redirect_from_type').value;
25
 
26
- if((redirect_from_type =='Page' || redirect_from_type == 'Folder') && redirect_from !="")
27
- {
28
- if(redirect_from.length >= site.length)
29
- {
30
- if(redirect_from.substr(0,site.length) == site)
31
- {
32
- return true;
33
- }
34
- }
35
- if(redirect_from.substr(0,1) == '/')
36
- {
37
  return true;
38
  }
39
- }else
40
- {
41
  return true;
42
  }
 
 
 
43
  return false;
44
  }
45
-
46
- function check_redirect_from_all()
47
- {
48
- check_redirect_from();
49
- var valid_url = check_valid_redirect_from();
50
- if(!valid_url)
51
- {
52
- document.getElementById('invalid_redirect_from').style.display = 'block';
53
- }else
54
- {
55
- document.getElementById('invalid_redirect_from').style.display = 'none';
56
- }
57
  }
58
-
59
 
60
  function go_search() {
61
- <?php
62
- isset($_REQUEST['tab']) ? $url_op = WPSR_sanitize_text_or_array_field($_REQUEST['tab']) : $url_op = "";
63
- ?>
64
  var sword = document.getElementById('search').value;
65
  if (sword != '') {
66
 
67
-
68
- var url = "<?php echo sprintf('%s&tab=%s', esc_url($rlink),esc_html($url_op)); ?>&search=" + sword;
69
  url = decodeURIComponent(url);
70
 
71
 
72
  window.location = url;
73
- } else
74
- {
75
  alert('<?php _e("Please input any search words!", 'seo-redirection') ?>');
76
  document.getElementById('search').focus();
77
  }
78
 
79
  }
80
-
81
  </script>
82
- <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
83
- <div class="modal-dialog" role="document">
84
- <div class="modal-content">
85
- <div class="modal-header">
86
- <button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="$('#myModal').modal('hide')"><span aria-hidden="true">&times;</span></button>
87
- <h4 class="modal-title" id="myModalLabel">Add Custom Redirects</h4>
88
- </div>
89
- <div class="modal-body">
90
-
91
- <form onsubmit="return check_from();" method="POST" id="myform" action="<?php echo esc_attr($util->WPSR_get_current_parameters(array('add', 'edit', 'page404'))); ?>">
92
- <table class="cform" width="100%">
93
- <tr>
94
- <td class="label"><?php _e('Redirect status:', 'seo-redirection') ?></td>
95
- <td> <select size="1" name="enabled" id="enabled">
96
- <option value="1"><?php _e('Enabled', 'seo-redirection') ?></option>
97
- <option value="0"><?php _e('Disabled', 'seo-redirection') ?></option>
98
- </select>
99
-
100
- </td>
101
- </tr>
102
- <tr>
103
-
104
- <td class="label"><?php _e('Redirect from:', 'seo-redirection') ?></td>
105
- <td>
106
- <div id="rfrom_div">
107
- <select onchange="redirect_from_type_change()" size="1" name="redirect_from_type" id="redirect_from_type">
108
- <option value="Page"><?php _e('Page', 'seo-redirection') ?></option>
109
- <option value="Folder"><?php _e('Folder', 'seo-redirection') ?></option>
110
- <option value="Regex"><?php _e('Regex', 'seo-redirection') ?></option>
111
- </select>
112
- <input onblur="check_redirect_from_all()" type="text" id="redirect_from" style="height: 40px;" placeholder="<?php _e("Redirect from", 'seo-redirection') ?>" name="redirect_from" size="45" value="<?php echo esc_attr($redirect_from); ?>">
113
- <span class="help-block"></span>
114
- <select onchange="redirect_to_folder_settings_change()" size="1" name="redirect_from_folder_settings" id="redirect_from_folder_settings">
115
- <option value="1"><?php _e('Only the folder', 'seo-redirection') ?></option>
116
- <option value="2"><?php _e("The folder and it's content", 'seo-redirection') ?></option>
117
- <option value="3"><?php _e("Only the folder's content", 'seo-redirection') ?></option>
118
- </select>
119
- <br>
120
- <select size="1" name="redirect_from_subfolders" id="redirect_from_subfolders" class="cmb2_select">
121
- <option value="0"><?php _e("Include sub-folders", 'seo-redirection') ?></option>
122
- <option value="1"><?php _e("Do not include sub-folders", 'seo-redirection') ?></option>
123
- </select>
124
-
125
-
126
- </div>
127
- <?php if ($util->get('page404') != '') echo esc_html($redirect_from); ?>
128
- </td>
129
- </tr>
130
- <tr>
131
- <td class="label"><?php _e("Redirect to:", 'seo-redirection') ?></td>
132
- <td>
133
- <select onchange="redirect_to_type_change()" size="1" class="cmb2_select" name="redirect_to_type" id="redirect_to_type">
134
- <option value="Page"><?php _e("Page:", 'seo-redirection') ?></option>
135
- <option value="Folder"><?php _e("Folder", 'seo-redirection') ?></option>
136
  </select>
137
-
138
- <input onblur="check_redirect_to()" type="text" id="redirect_to" placeholder="<?php _e("Redirect to", 'seo-redirection') ?>" class="regular-text" style="height: 40px;" name="redirect_to" size="45" value="<?php echo esc_attr($redirect_to); ?>">
139
  <span class="help-block"></span>
140
- <select size="1" name="redirect_to_folder_settings" id="redirect_to_folder_settings">
141
- <option value="1"><?php _e("Normal", 'seo-redirection') ?></option>
142
- <option value="2"><?php _e("Wild Card Redirect", 'seo-redirection') ?></option>
 
143
  </select>
144
- </td>
145
- </tr>
146
- <tr>
147
- <td class="label"><?php _e("Redirect type:", 'seo-redirection') ?></td>
148
- <td>
149
- <select size="1" name="redirect_type" id="redirect_type">
150
- <option value="301"><?php _e("301 (SEO)", 'seo-redirection') ?></option>
151
- <option value="302"><?php _e("302", 'seo-redirection') ?></option>
152
- <option value="307"><?php _e("307", 'seo-redirection') ?></option>
153
  </select>
154
- <script type="text/javascript">
155
- <?php
156
- if (isset($redirect_type) && $redirect_type != '')
157
- echo "document.getElementById('redirect_type').value='".esc_attr($redirect_type)."';";
158
-
159
- if (isset($redirect_from_type) && $redirect_from_type != '')
160
- echo "document.getElementById('redirect_from_type').value='".esc_attr($redirect_from_type)."';";
161
-
162
- if (isset($redirect_from_folder_settings) && $redirect_from_type == 'Folder')
163
- echo "document.getElementById('redirect_from_folder_settings').value='".esc_attr($redirect_from_folder_settings)."';";
164
-
165
- if (isset($redirect_from_subfolders) && $redirect_from_type == 'Folder')
166
- echo "document.getElementById('redirect_from_subfolders').value='".esc_attr($redirect_from_subfolders)."';";
167
-
168
- if (isset($redirect_to_type) && $redirect_to_type != '')
169
- echo "document.getElementById('redirect_to_type').value='".esc_attr($redirect_to_type)."';";
170
-
171
- if (isset($redirect_to_folder_settings) && $redirect_to_type == 'Folder')
172
- echo "document.getElementById('redirect_to_folder_settings').value='".esc_attr($redirect_to_folder_settings)."';";
173
-
174
- if (isset($enabled) && $enabled != '')
175
- echo "document.getElementById('enabled').value='".esc_attr($enabled)."';";
176
-
177
-
178
- if ($util->get('page404') != '')
179
- echo "document.getElementById('rfrom_div').style.display = 'none';";
180
- ?>
181
- </script>
182
- </td>
183
- </tr>
184
- </table>
185
-
186
- <label id="msg_response">
187
- </label>
188
- <br/>
189
- </div>
190
- <div class="modal-footer">
191
- <?php
192
- echo '<input class="button-primary" id="btnSave" type="button" value="' . __("Add New", "seo-redirection") . '" onclick="return save_function()">';
193
- ?>
194
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce('seoredirection')); ?>" />
195
- <input type="hidden" id="edit" name="edit" value="<?php echo intval($util->get('edit')) ?>">
196
- <input type="hidden" id="add_new" name="add_new" value="">
197
- <input type="hidden" id="edit_exist" name="edit_exist" value="">
198
- <input type="hidden" id="action" name="action" value="customAddUpdate">
199
-
200
- <button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="$('#myModal').modal('hide')"><?php _e("Close", 'seo-redirection') ?></button>
201
-
202
-
203
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  </div>
205
- </form>
206
  </div>
 
207
  </div>
 
208
  <div class="link_buttons">
209
-
210
- <table border="0" width="100%">
211
- <tr>
212
- <td > <button type="button" class="button-secondary" onclick="add_rec()" >
213
- <span style="padding-top: 5px;" class="dashicons dashicons-plus"></span><?php _e('Add New', 'seo-redirection') ?>
214
- </button>
215
-
216
- <label id="waiting_lbl"><div class="loading" style="display: none">Loading&#8230;</div>
217
- </label>
218
- </td>
219
- <td align="right">
220
- <input onkeyup="if (event.keyCode == 13)
221
- go_search();" style="height: 30px;" id="search" type="text" name="search" value="<?php echo htmlentities($util->get('search'), ENT_QUOTES) ?>" size="30">
222
- <a class="button" onclick="go_search()" href="#" ><span style="padding-top: 3px;" class="dashicons dashicons-search"></span>&nbsp;<?php _e("Search", 'seo-redirection') ?></a>
223
- <a class="button" href="<?php echo esc_url(htmlentities($util->WPSR_get_current_parameters('search'))) ?>"><span style="padding-top: 3px;" class="dashicons dashicons-screenoptions"></span>&nbsp;<?php _e("Show All", 'seo-redirection') ?></a>
224
- </td>
225
- </tr>
226
- </table>
227
-
228
-
 
229
  </div>
230
  <form method='post'>
231
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce('seoredirection')); ?>" />
232
- <?php
233
- $grid = new datagrid();
234
-
235
-
236
- $grid->set_data_source($table_name);
237
- $grid->add_select_field('ID');
238
- $grid->add_select_field('redirect_from');
239
- $grid->add_select_field('redirect_from_type');
240
- $grid->add_select_field('redirect_to');
241
- $grid->add_select_field('redirect_to_type');
242
- $grid->add_select_field('hits');
243
- $grid->add_select_field('access_date');
244
- $grid->add_select_field('enabled');
245
-
246
-
247
-
248
- //$grid->add_select_field('redirect_hits');
249
- //$grid->add_select_field('redirect_last_access');
250
-
251
-
252
- $grid->set_table_attr('width', '100%');
253
- $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
254
-
255
- $grid->set_col_attr(1, 'width', '10px', 'header');
256
- $grid->set_col_attr(2, 'width', '30%', 'header');
257
- $grid->set_col_attr(3, 'width', '30%','header');
258
- $grid->set_col_attr(4, 'width', '50px','header');
259
- $grid->set_col_attr(4, 'style', 'text-align:center;','header');
260
- $grid->set_col_attr(5, 'width', '50px', 'header');
261
- $grid->set_col_attr(5, 'style', 'text-align:center;','header');
262
- $grid->set_col_attr(6, 'width', '150px', 'header');
263
- $grid->set_col_attr(6, 'style', 'text-align:center;','header');
264
- $grid->set_col_attr(7, 'width', '60px', 'header');
265
- $grid->set_col_attr(8, 'width', '60px','header');
266
-
267
- $grid->set_col_attr(4, 'style', 'text-align:center;');
268
- $grid->set_col_attr(5, 'style', 'text-align:center;');
269
- $grid->set_col_attr(6, 'style', 'text-align:center;');
270
-
271
-
272
-
273
- if(isset($_REQUEST['type']) && $_REQUEST['type']=='hits')
274
- {
275
- if(isset($_REQUEST['sort']) && $_REQUEST['sort']!='')
276
- $grid->set_order('hits '. sanitize_text_field($_REQUEST['sort']));
277
- }
278
- else if(isset($_REQUEST['type']) && $_REQUEST['type']=='dt')
279
- {
280
- if(isset($_REQUEST['sort']) && $_REQUEST['sort']!='')
281
- $grid->set_order('hits '. sanitize_text_field($_REQUEST['sort']));
282
- }
283
- else
284
- $grid->set_order(" ID desc ");
285
-
286
- $grid->set_filter("url_type=1");
287
-
288
- if ($util->get('search') != '') {
289
- $search = $util->get('search');
290
- $grid->set_filter("url_type=1 and (redirect_from like '%%$search%%' or redirect_to like '%%$search%%' or redirect_type like '%%$search%%' )");
291
- }
292
-
293
- $grid->add_php_col("<input type='checkbox' class='chkthis' name='redirect_id[]' value='DB_ID' />","<input type='checkbox' class='chkall' name='check_all' />");
294
- $grid->add_php_col( "<div class='db_redirect_from_type_background_db_enabled'><a target='_blank' href='db_redirect_from_url'>db_redirect_from</a></div>" , __('Redirect from ', 'seo-redirection'));
295
- $grid->add_php_col("<div class='db_redirect_to_type_background_db_enabled'><a target='_blank' href='db_redirect_to_url'>db_redirect_to</a></div>", __('Redirect to ', 'seo-redirection'));
296
- $grid->add_data_col('redirect_type', __('Type', 'seo-redirection'));
297
-
298
-
299
- $url = admin_url('options-general.php?page='.sanitize_text_field($_REQUEST['page']));
300
- $url .= isset($_REQUEST['tab']) ? '&tab='.sanitize_text_field($_REQUEST['tab']) : '';
301
-
302
- if(isset($_REQUEST['sort']) && $_REQUEST['sort'] =='asc')
303
- {
304
- $grid->add_data_col('hits','<a class="hit" href="'.esc_url($url).'&type=hits&sort=desc" data-sort="desc">Hits</a>');
305
- $grid->add_data_col('access_date','<a href="'.esc_url($url).'&type=dt&sort=desc" class="hit" data-sort="desc">Last Access</a>');
306
- }
307
- else if(isset($_REQUEST['sort']) && $_REQUEST['sort'] =='desc')
308
- {
309
- $grid->add_data_col('hits','<a class="hit" href="'.esc_url($url).'&type=hits&sort=asc" data-sort="asc">Hits</a>');
310
- $grid->add_data_col('access_date','<a href="'.esc_url($url).'&type=dt&sort=asc" class="dt" data-sort="asc">Last Access</a>');
311
- }
312
- else
313
- {
314
- $grid->add_data_col('hits','<a class="hit" href="'.esc_url($url).'&type=hits&sort=asc" data-sort="asc">Hits</a>');
315
- $grid->add_data_col('access_date','<a href="'.esc_url($url).'&type=dt&sort=asc" class="dt" data-sort="asc">Last Access</a>');
316
- }
317
-
318
- //$grid->add_template_col( $util->WPSR_get_current_parameters('del') . '&del={db_ID}', __('Actions', 'seo-redirection'));
319
- $grid->add_template_col('edit', '{db_ID}', __('', 'seo-redirection'));
320
- $grid->run();
321
- ?>
322
- <?php
323
- echo '<input class="button-primary" id="btnDelete" type="submit" value="' . __("Delete", "seo-redirection") . '" onclick="return delete_function()">
324
  <style>
325
 
326
  td:first-child { text-align: left; width:30px }
327
 
328
  </style>
329
-
330
  ';
331
- ?>
332
  </form>
 
 
 
 
 
6
 
7
 
8
 
9
+ $rlink = $util->WPSR_get_current_parameters(array('search', 'page_num', 'add', 'edit', 'tab'));
10
 
11
  $redirect_from = isset($redirect_from) ? $redirect_from : '';
12
  $redirect_to = isset($redirect_to) ? $redirect_to : '';
13
  ?>
14
+ <br />
15
 
16
  <script type="text/javascript">
17
+ //---------------------------------------------------------
18
 
19
+ function check_valid_redirect_from() {
20
+ var site = "<?php echo home_url(); ?>";
 
 
 
21
  var redirect_from = document.getElementById('redirect_from').value;
22
  var redirect_from_type = document.getElementById('redirect_from_type').value;
23
 
24
+ if ((redirect_from_type == 'Page' || redirect_from_type == 'Folder') && redirect_from != "") {
25
+ if (redirect_from.length >= site.length) {
26
+ if (redirect_from.substr(0, site.length) == site) {
 
 
 
 
 
 
 
 
27
  return true;
28
  }
29
+ }
30
+ if (redirect_from.substr(0, 1) == '/') {
31
  return true;
32
  }
33
+ } else {
34
+ return true;
35
+ }
36
  return false;
37
  }
38
+
39
+ function check_redirect_from_all() {
40
+ check_redirect_from();
41
+ var valid_url = check_valid_redirect_from();
42
+ if (!valid_url) {
43
+ document.getElementById('invalid_redirect_from').style.display = 'block';
44
+ } else {
45
+ document.getElementById('invalid_redirect_from').style.display = 'none';
46
+ }
 
 
 
47
  }
48
+
49
 
50
  function go_search() {
51
+ <?php
52
+ isset($_REQUEST['tab']) ? $url_op = WPSR_sanitize_text_or_array_field($_REQUEST['tab']) : $url_op = "";
53
+ ?>
54
  var sword = document.getElementById('search').value;
55
  if (sword != '') {
56
 
57
+
58
+ var url = "<?php echo sprintf('%s&tab=%s', esc_url($rlink), esc_html($url_op)); ?>&search=" + sword;
59
  url = decodeURIComponent(url);
60
 
61
 
62
  window.location = url;
63
+ } else {
 
64
  alert('<?php _e("Please input any search words!", 'seo-redirection') ?>');
65
  document.getElementById('search').focus();
66
  }
67
 
68
  }
 
69
  </script>
70
+ <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
71
+ <div class="modal-dialog" role="document">
72
+ <div class="modal-content">
73
+ <div class="modal-header">
74
+ <h4 class="modal-title" id="myModalLabel">Add Custom Redirects</h4>
75
+ <button type="button" class="close " data-dismiss="modal" aria-label="Close" onclick="$('#myModal').modal('hide')"><span aria-hidden="true">&times;</span></button>
76
+ </div>
77
+ <div class="modal-body">
78
+
79
+ <form onsubmit="return check_from();" method="POST" id="myform" action="<?php echo esc_attr($util->WPSR_get_current_parameters(array('add', 'edit', 'page404'))); ?>">
80
+ <table class="cform" width="100%">
81
+ <tr>
82
+ <td class="label"><?php _e('Redirect status:', 'seo-redirection') ?></td>
83
+ <td> <select size="1" name="enabled" id="enabled">
84
+ <option value="1"><?php _e('Enabled', 'seo-redirection') ?></option>
85
+ <option value="0"><?php _e('Disabled', 'seo-redirection') ?></option>
86
+ </select>
87
+
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+
92
+ <td class="label"><?php _e('Redirect from:', 'seo-redirection') ?></td>
93
+ <td>
94
+ <div id="rfrom_div">
95
+ <select onchange="redirect_from_type_change()" size="1" name="redirect_from_type" id="redirect_from_type">
96
+ <option value="Page"><?php _e('Page', 'seo-redirection') ?></option>
97
+ <option value="Folder"><?php _e('Folder', 'seo-redirection') ?></option>
98
+ <option value="Regex"><?php _e('Regex', 'seo-redirection') ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  </select>
100
+ <input onblur="check_redirect_from_all()" type="text" id="redirect_from" style="height: 40px;" placeholder="<?php _e("Redirect from", 'seo-redirection') ?>" name="redirect_from" size="45" value="<?php echo esc_attr($redirect_from); ?>">
 
101
  <span class="help-block"></span>
102
+ <select onchange="redirect_to_folder_settings_change()" size="1" name="redirect_from_folder_settings" id="redirect_from_folder_settings">
103
+ <option value="1"><?php _e('Only the folder', 'seo-redirection') ?></option>
104
+ <option value="2"><?php _e("The folder and it's content", 'seo-redirection') ?></option>
105
+ <option value="3"><?php _e("Only the folder's content", 'seo-redirection') ?></option>
106
  </select>
107
+ <br>
108
+ <select size="1" name="redirect_from_subfolders" id="redirect_from_subfolders" class="cmb2_select">
109
+ <option value="0"><?php _e("Include sub-folders", 'seo-redirection') ?></option>
110
+ <option value="1"><?php _e("Do not include sub-folders", 'seo-redirection') ?></option>
 
 
 
 
 
111
  </select>
112
+
113
+
114
+ </div>
115
+ <?php if ($util->get('page404') != '') echo esc_html($redirect_from); ?>
116
+ </td>
117
+ </tr>
118
+ <tr>
119
+ <td class="label"><?php _e("Redirect to:", 'seo-redirection') ?></td>
120
+ <td>
121
+ <select onchange="redirect_to_type_change()" size="1" class="cmb2_select" name="redirect_to_type" id="redirect_to_type">
122
+ <option value="Page"><?php _e("Page:", 'seo-redirection') ?></option>
123
+ <option value="Folder"><?php _e("Folder", 'seo-redirection') ?></option>
124
+ </select>
125
+
126
+ <input onblur="check_redirect_to()" type="text" id="redirect_to" placeholder="<?php _e("Redirect to", 'seo-redirection') ?>" class="regular-text" style="height: 40px;" name="redirect_to" size="45" value="<?php echo esc_attr($redirect_to); ?>">
127
+ <span class="help-block"></span>
128
+ <select size="1" name="redirect_to_folder_settings" id="redirect_to_folder_settings">
129
+ <option value="1"><?php _e("Normal", 'seo-redirection') ?></option>
130
+ <option value="2"><?php _e("Wild Card Redirect", 'seo-redirection') ?></option>
131
+ </select>
132
+ </td>
133
+ </tr>
134
+ <tr>
135
+ <td class="label"><?php _e("Redirect type:", 'seo-redirection') ?></td>
136
+ <td>
137
+ <select size="1" name="redirect_type" id="redirect_type">
138
+ <option value="301"><?php _e("301 (SEO)", 'seo-redirection') ?></option>
139
+ <option value="302"><?php _e("302", 'seo-redirection') ?></option>
140
+ <option value="307"><?php _e("307", 'seo-redirection') ?></option>
141
+ </select>
142
+ <script type="text/javascript">
143
+ <?php
144
+ if (isset($redirect_type) && $redirect_type != '')
145
+ echo "document.getElementById('redirect_type').value='" . esc_attr($redirect_type) . "';";
146
+
147
+ if (isset($redirect_from_type) && $redirect_from_type != '')
148
+ echo "document.getElementById('redirect_from_type').value='" . esc_attr($redirect_from_type) . "';";
149
+
150
+ if (isset($redirect_from_folder_settings) && $redirect_from_type == 'Folder')
151
+ echo "document.getElementById('redirect_from_folder_settings').value='" . esc_attr($redirect_from_folder_settings) . "';";
152
+
153
+ if (isset($redirect_from_subfolders) && $redirect_from_type == 'Folder')
154
+ echo "document.getElementById('redirect_from_subfolders').value='" . esc_attr($redirect_from_subfolders) . "';";
155
+
156
+ if (isset($redirect_to_type) && $redirect_to_type != '')
157
+ echo "document.getElementById('redirect_to_type').value='" . esc_attr($redirect_to_type) . "';";
158
+
159
+ if (isset($redirect_to_folder_settings) && $redirect_to_type == 'Folder')
160
+ echo "document.getElementById('redirect_to_folder_settings').value='" . esc_attr($redirect_to_folder_settings) . "';";
161
+
162
+ if (isset($enabled) && $enabled != '')
163
+ echo "document.getElementById('enabled').value='" . esc_attr($enabled) . "';";
164
+
165
+
166
+ if ($util->get('page404') != '')
167
+ echo "document.getElementById('rfrom_div').style.display = 'none';";
168
+ ?>
169
+ </script>
170
+ </td>
171
+ </tr>
172
+ </table>
173
+
174
+ <label id="msg_response">
175
+ </label>
176
+ <br />
177
+ </div>
178
+ <div class="modal-footer">
179
+ <?php
180
+ echo '<input class="button-primary btn-custom btn-add" id="btnSave" type="button" value="' . __("Add New", "seo-redirection") . '" onclick="return save_function()">';
181
+ ?>
182
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce('seoredirection')); ?>" />
183
+ <input type="hidden" id="edit" name="edit" value="<?php echo intval($util->get('edit')) ?>">
184
+ <input type="hidden" id="add_new" name="add_new" value="">
185
+ <input type="hidden" id="edit_exist" name="edit_exist" value="">
186
+ <input type="hidden" id="action" name="action" value="customAddUpdate">
187
+
188
+ <button type="button" style="margin-left: 4px;" class="button-primary btn-custom btn-delete" data-dismiss="modal" onclick="$('#myModal').modal('hide')"> <?php _e("Close", 'seo-redirection') ?> </button>
189
  </div>
 
190
  </div>
191
+ </form>
192
  </div>
193
+ </div>
194
  <div class="link_buttons">
195
+
196
+ <table border="0" width="100%">
197
+ <tr>
198
+ <td> <button type="button" class="button-secondary btn-custom btn-add" onclick="add_rec()">
199
+ <span style="padding-top: 5px;" class="dashicons dashicons-plus"></span><?php _e('Add New', 'seo-redirection') ?>
200
+ </button>
201
+
202
+ <label id="waiting_lbl">
203
+ <div class="loading" style="display: none">Loading&#8230;</div>
204
+ </label>
205
+ </td>
206
+ <td align="right" class="btn-right">
207
+ <input onkeyup="if (event.keyCode == 13)
208
+ go_search();" style="height: 30px; border-radius: 3px !important;" id="search" type="text" name="search" value="<?php echo htmlentities($util->get('search'), ENT_QUOTES) ?>" size="30">
209
+ <a class="button btn-custom btn-search" onclick="go_search()" href="#"><span style="padding-top: 3px;" class="dashicons dashicons-search "></span>&nbsp;<?php _e("Search", 'seo-redirection') ?></a>
210
+ <a class="button btn-custom btn-search" href="<?php echo esc_url(htmlentities($util->WPSR_get_current_parameters('search'))) ?>"><span style="padding-top: 3px;" class="dashicons dashicons-screenoptions"></span>&nbsp;<?php _e("Show All", 'seo-redirection') ?></a>
211
+ </td>
212
+ </tr>
213
+ </table>
214
+
215
+
216
  </div>
217
  <form method='post'>
218
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce('seoredirection')); ?>" />
219
+ <?php
220
+ $grid = new datagrid();
221
+
222
+
223
+ $grid->set_data_source($table_name);
224
+ $grid->add_select_field('ID');
225
+ $grid->add_select_field('redirect_from');
226
+ $grid->add_select_field('redirect_from_type');
227
+ $grid->add_select_field('redirect_to');
228
+ $grid->add_select_field('redirect_to_type');
229
+ $grid->add_select_field('hits');
230
+ $grid->add_select_field('access_date');
231
+ $grid->add_select_field('enabled');
232
+
233
+
234
+
235
+ //$grid->add_select_field('redirect_hits');
236
+ //$grid->add_select_field('redirect_last_access');
237
+
238
+
239
+ $grid->set_table_attr('width', '100%');
240
+ $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
241
+
242
+ $grid->set_col_attr(1, 'width', '10px', 'header');
243
+ $grid->set_col_attr(2, 'width', '30%', 'header');
244
+ $grid->set_col_attr(3, 'width', '30%', 'header');
245
+ $grid->set_col_attr(4, 'width', '50px', 'header');
246
+ $grid->set_col_attr(4, 'style', 'text-align:center;', 'header');
247
+ $grid->set_col_attr(5, 'width', '50px', 'header');
248
+ $grid->set_col_attr(5, 'style', 'text-align:center;', 'header');
249
+ $grid->set_col_attr(6, 'width', '150px', 'header');
250
+ $grid->set_col_attr(6, 'style', 'text-align:center;', 'header');
251
+ $grid->set_col_attr(7, 'width', '60px', 'header');
252
+ $grid->set_col_attr(8, 'width', '60px', 'header');
253
+
254
+ $grid->set_col_attr(4, 'style', 'text-align:center;');
255
+ $grid->set_col_attr(5, 'style', 'text-align:center;');
256
+ $grid->set_col_attr(6, 'style', 'text-align:center;');
257
+
258
+
259
+
260
+ if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'hits') {
261
+ if (isset($_REQUEST['sort']) && $_REQUEST['sort'] != '')
262
+ $grid->set_order('hits ' . sanitize_text_field($_REQUEST['sort']));
263
+ } else if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'dt') {
264
+ if (isset($_REQUEST['sort']) && $_REQUEST['sort'] != '')
265
+ $grid->set_order('hits ' . sanitize_text_field($_REQUEST['sort']));
266
+ } else
267
+ $grid->set_order(" ID desc ");
268
+
269
+ $grid->set_filter("url_type=1");
270
+
271
+ if ($util->get('search') != '') {
272
+ $search = $util->get('search');
273
+ $grid->set_filter("url_type=1 and (redirect_from like '%%$search%%' or redirect_to like '%%$search%%' or redirect_type like '%%$search%%' )");
274
+ }
275
+
276
+ $grid->add_php_col("<input type='checkbox' class='chkthis' onclick='showhidebtn()' name='redirect_id[]' value='DB_ID' />", "<input type='checkbox' class='chkall' name='check_all' />");
277
+ $grid->add_php_col("<div class='db_redirect_from_type_background_db_enabled'><a target='_blank' href='db_redirect_from_url'>db_redirect_from</a></div>", __('Redirect from ', 'seo-redirection'));
278
+ $grid->add_php_col("<div class='db_redirect_to_type_background_db_enabled'><a target='_blank' href='db_redirect_to_url'>db_redirect_to</a></div>", __('Redirect to ', 'seo-redirection'));
279
+ $grid->add_data_col('redirect_type', __('Type', 'seo-redirection'));
280
+
281
+
282
+ $url = admin_url('options-general.php?page=' . sanitize_text_field($_REQUEST['page']));
283
+ $url .= isset($_REQUEST['tab']) ? '&tab=' . sanitize_text_field($_REQUEST['tab']) : '';
284
+
285
+ if (isset($_REQUEST['sort']) && $_REQUEST['sort'] == 'asc') {
286
+ $grid->add_data_col('hits', '<a class="hit text-white" href="' . esc_url($url) . '&type=hits&sort=desc" data-sort="desc">Hits <span class="dashicons dashicons-arrow-up"></span></a>');
287
+ $grid->add_data_col('access_date', '<a href="' . esc_url($url) . '&type=dt&sort=desc" class="hit text-white" data-sort="desc">Last Access <span class="dashicons dashicons-arrow-up"></span></a>');
288
+ } else if (isset($_REQUEST['sort']) && $_REQUEST['sort'] == 'desc') {
289
+ $grid->add_data_col('hits', '<a class="hit text-white" href="' . esc_url($url) . '&type=hits&sort=asc" data-sort="asc">Hits <span class="dashicons dashicons-arrow-up"></span></a>');
290
+ $grid->add_data_col('access_date', '<a href="' . esc_url($url) . '&type=dt&sort=asc" class="dt text-white" data-sort="asc">Last Access <span class="dashicons dashicons-arrow-up"></span></a>');
291
+ } else {
292
+ $grid->add_data_col('hits', '<a class="hit text-white" href="' . esc_url($url) . '&type=hits&sort=asc" data-sort="asc">Hits <span class="dashicons dashicons-arrow-up"></span></a>');
293
+ $grid->add_data_col('access_date', '<a href="' . esc_url($url) . '&type=dt&sort=asc" class="dt text-white" data-sort="asc">Last Access <span class="dashicons dashicons-arrow-up"></span></a>');
294
+ }
295
+
296
+ //$grid->add_template_col( $util->WPSR_get_current_parameters('del') . '&del={db_ID}', __('Actions', 'seo-redirection'));
297
+ $grid->add_template_col('edit', '{db_ID}', __('', 'seo-redirection'));
298
+ $grid->run();
299
+ ?>
300
+ <?php
301
+ echo '<input style="display: none;" class="button-primary btn-custom btn-delete btn-show" id="btnDelete" type="submit" value="' . __("Delete", "seo-redirection") . '" onclick="return delete_function()">
 
 
 
 
 
 
 
 
 
302
  <style>
303
 
304
  td:first-child { text-align: left; width:30px }
305
 
306
  </style>
 
307
  ';
308
+ ?>
309
  </form>
310
+ <script>
311
+ function showhidebtn() {
312
+ document.querySelector('.btn-show').style.display = "block";
313
+ }
314
+ </script>
options/option_page_goptions.php CHANGED
@@ -1,221 +1,248 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  global $util;
4
 
5
- $nonce="";
6
- if(isset($_REQUEST['_wpnonce']))
7
- $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
8
-
9
- if(isset($_POST) && wp_verify_nonce( $nonce, 'seoredirection' ) ){
10
- if($util->post('reset_all_options')!='')
11
- {
12
- c_init_my_options();
13
- $util->success_option_msg(__('All Options Restored to Defaults','seo-redirection'));
14
-
15
- }else if($util->post('Save_general_options')!='')
16
- {
17
- c_save_redirection_general_options();
18
- $util->success_option_msg(__('General Options Saved!','seo-redirection'));
19
-
20
- }else if($util->post('save_history_options')!='')
21
- {
22
- c_save_redirection_history_options();
23
- $util->success_option_msg(__('History Options Saved!','seo-redirection'));
24
- }
25
- else if($util->post('clear_history')!='')
26
- {
27
- c_clear_redirection_history();
28
- $util->success_option_msg(__('History Cleared!','seo-redirection'));
29
- }
30
- else if($util->post('save_404_options')!='')
31
- {
32
- c_save_404_redirection_options();
33
- $util->success_option_msg(__('404 Redirection Options Saved!','seo-redirection'));
34
- }
35
- else if($util->post('clear_all_404')!='')
36
- {
37
- c_clear_all_404();
38
- $util->success_option_msg(__('All Discovered 404 Pages Cleared!','seo-redirection'));
39
- }
40
- else if($util->post('save_data_options')!='')
41
- {
42
- c_save_keep_data();
43
- $util->success_option_msg(__('Data Options Saved!','seo-redirection'));
44
- }
45
- else if($util->post('optimize_tables')!='')
46
- {
47
- c_optimize_tables();
48
- $util->success_option_msg(__('Data Tables Optimized!','seo-redirection'));
49
- }
50
- else if($util->post('save_all_options'))
51
- {
52
- c_save_redirection_general_options();
53
- c_save_redirection_history_options();
54
- c_save_404_redirection_options();
55
- c_save_keep_data();
56
-
57
- $util->success_option_msg(__('All options saved!','seo-redirection'));
58
-
59
  }
60
 
 
61
 
 
62
 
63
 
64
 
65
-
66
- if($util->there_is_cache()!='')
67
-
68
- $util->info_option_msg(__("You have a cache plugin installed",'seo-redirection')." <b>'" . $util->there_is_cache() . "'</b>, ".__("you have to clear cache after any changes to get the changes reflected immediately! ",'seo-redirection'));
69
- }
70
-
71
- $options= $util->get_my_options();
72
-
73
- ?>
74
  <form method="POST">
75
- <h3><?php _e("General Options","seo-redirection") ?><hr></h3>
76
-
77
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce('seoredirection')); ?>" />
78
-
79
- <table class="cform" align="center" width="100%">
80
- <tr><td>
81
- <?php _e("Plugin Status:","seo-redirection") ?>
82
- <?php
83
- $drop = new dropdown('plugin_status');
84
- $drop->add(__('Enabled','seo-redirection'),'1');
85
- $drop->add(__('Disabled','seo-redirection'),'0');
86
- $drop->add(__('Disabled for admin only','seo-redirection'),'2');
87
- $drop->dropdown_print();
88
- $drop->select($options['plugin_status']);
89
- ?>
90
-
91
- </td></tr>
92
-
93
-
94
- <tr><td>
95
- <?php _e("IP Logging:","seo-redirection") ?>
96
- <?php
97
- $drop = new dropdown('ip_logging_status');
98
- $drop->add(__('No IP logging','seo-redirection'),'0');
99
- $drop->add(__('Full IP logging','seo-redirection'),'1');
100
- $drop->add(__('Anonymize IP (mask last part)','seo-redirection'),'2');
101
- $drop->dropdown_print();
102
- $drop->select($options['ip_logging_status']);
103
- ?>
104
- <small>&nbsp; used for <a href="https://eugdpr.org/" target="_blank">GDPR</a> compliance</small>
105
- </td></tr>
106
-
107
- <tr><td>
108
- <?php $check = new checkoption('redirect_control_panel',$options['redirect_control_panel']); ?>
109
- <?php _e("Do not redirect control panel links (This will be usefull when making wrong expressions that may cause an infinit redirection loop).","seo-redirection"); ?>
110
-
111
- <br/>
112
- <?php $check = new checkoption('show_redirect_box',$options['show_redirect_box']); ?>
113
- <?php _e("Show redirect box in posts & pages edit page (Important to set up redirection for posts and pages easily).","seo-redirection"); ?>
114
-
115
-
116
- <br/>
117
- <?php $check = new checkoption('reflect_modifications',$options['reflect_modifications']); ?>
118
- <?php _e("Reflect any modifications in the post permalink to all redirection links (Mostly Recommended).","seo-redirection"); ?>
119
-
120
-
121
-
122
-
123
- <script type="text/javascript">
124
-
125
- </script>
126
- </td></tr>
127
-
128
- </table>
129
- <br/><input style="margin-left:5px" class="button-primary" type="submit" value="<?php _e("Save General Options","seo-redirection") ?>" name="Save_general_options">
130
-
131
-
132
- <br/><br/>
133
- <h3><?php _e("Redirection History Options","seo-redirection") ?><hr></h3>
134
- <table class="cform" align="center" width="100%">
135
- <tr><td>
136
- <?php _e("Redirection History Status:","seo-redirection") ?>
137
- <?php
138
- $drop = new dropdown('history_status');
139
- $drop->add(__('Enabled','seo-redirection'),'1');
140
- $drop->add(__('Disabled','seo-redirection'),'0');
141
- $drop->dropdown_print();
142
- $drop->select($options['history_status']);
143
- ?>
144
-
145
- </td></tr>
146
- <tr><td>
147
- <?php _e("Redirection History Limit:","seo-redirection") ?>
148
- <?php
149
- $drop = new dropdown('history_limit');
150
- $drop->add(__('7 days','seo-redirection'),'7');
151
- $drop->add(__('1 month','seo-redirection'),'30');
152
- $drop->add(__('2 months','seo-redirection'),'60');
153
- $drop->add(__('3 months','seo-redirection'),'90');
154
- $drop->dropdown_print();
155
- $drop->select($options['history_limit']);
156
- ?>
157
-
158
- </td></tr>
159
-
160
- </table>
161
- <br/>
162
- <input style="margin-left:5px" class="button-primary" type="submit" value="Save History Options" name="save_history_options">
163
- <input style="margin-left:5px" class="button-primary" type="submit" value="Clear History" name="clear_history">
164
-
165
-
166
- <br/><br/>
167
- <h3>404 Error Pages Options<hr></h3>
168
-
169
-
170
- <table class="cform" align="center" width="100%">
171
- <tr><td>
172
- 404 Error Pages Discovery:
173
- <?php
174
- $drop = new dropdown('p404_discovery_status');
175
- $drop->add('Enabled','1');
176
- $drop->add('Disabled','0');
177
- $drop->dropdown_print();
178
- $drop->select($options['p404_discovery_status']);
179
- ?>
180
-
181
- </td></tr>
182
-
183
- <tr><td>
184
- Unknown 404 Redirection Status:
185
- <?php
186
- $drop = new dropdown('p404_status');
187
- $drop->add('Enabled','1');
188
- $drop->add('Disabled','2');
189
- $drop->dropdown_print();
190
- $drop->select($options['p404_status']);
191
- ?>
192
- </td></tr>
193
-
194
- <tr><td>
195
- Redirect All Unknown 404 Pages to: <input type="text" name="redirect_to" id="redirect_to" size="30" value="<?php echo esc_attr_e($options['p404_redirect_to'])?>">&nbsp;<span style="color:red">Have many broken links?</span>&nbsp;<a target="_blank" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/">Click here to fix and improve your site SEO</a>
196
- </td></tr>
197
-
198
- </table>
199
- <br/>
200
- <input style="margin-left:5px" class="button-primary" type="submit" value="Save 404 Redirection Options" name="save_404_options">
201
- <input style="margin-left:5px" class="button-primary" type="submit" value="Clear All Discovered 404 Pages" name="clear_all_404">
202
-
203
- <br/><br/>
204
-
205
- <h3><?php _e("Redrection Data Options","seo-redirection"); ?><hr></h3>
206
- <table class="cform" align="center" width="100%">
207
- <tr><td>
208
- <?php $check = new checkoption('keep_data',$options['keep_data'],'1'); ?>
209
- <?php _e("Keep redirection data after uninstall the plugin, this will be useful when you install it later.","seo-redirection"); ?>
210
-
211
- </td></tr>
212
- </table>
213
- <br/>
214
- <input style="margin-left:5px" class="button-primary" type="submit" value="<?php _e("Save Data Options","seo-redirection") ?>" name="save_data_options">
215
- <input style="margin-left:5px" class="button-primary" type="submit" value="<?php _e("Optimize Data Tables","seo-redirection") ?>" name="optimize_tables">
216
- <br/><br/><br/>
217
- <hr>
218
- <input style="margin-left:5px" class="button-primary" type="submit" value="<?php _e("Save All Options","seo-redirection") ?>" name="save_all_options">
219
- <input style="margin-left:5px" class="button-primary" type="submit" value="<?php _e("Restore Default Settings","seo-redirection") ?>" name="reset_all_options">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
  </form>
1
  <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
  global $util;
4
 
5
+ $nonce = "";
6
+ if (isset($_REQUEST['_wpnonce']))
7
+ $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
8
+
9
+ if (isset($_POST) && wp_verify_nonce($nonce, 'seoredirection')) {
10
+ if ($util->post('reset_all_options') != '') {
11
+ c_init_my_options();
12
+ $util->success_option_msg(__('All Options Restored to Defaults', 'seo-redirection'));
13
+ } else if ($util->post('Save_general_options') != '') {
14
+ c_save_redirection_general_options();
15
+ $util->success_option_msg(__('General Options Saved!', 'seo-redirection'));
16
+ } else if ($util->post('save_history_options') != '') {
17
+ c_save_redirection_history_options();
18
+ $util->success_option_msg(__('History Options Saved!', 'seo-redirection'));
19
+ } else if ($util->post('clear_history') != '') {
20
+ c_clear_redirection_history();
21
+ $util->success_option_msg(__('History Cleared!', 'seo-redirection'));
22
+ } else if ($util->post('save_404_options') != '') {
23
+ c_save_404_redirection_options();
24
+ $util->success_option_msg(__('404 Redirection Options Saved!', 'seo-redirection'));
25
+ } else if ($util->post('clear_all_404') != '') {
26
+ c_clear_all_404();
27
+ $util->success_option_msg(__('All Discovered 404 Pages Cleared!', 'seo-redirection'));
28
+ } else if ($util->post('save_data_options') != '') {
29
+ c_save_keep_data();
30
+ $util->success_option_msg(__('Data Options Saved!', 'seo-redirection'));
31
+ } else if ($util->post('optimize_tables') != '') {
32
+ c_optimize_tables();
33
+ $util->success_option_msg(__('Data Tables Optimized!', 'seo-redirection'));
34
+ } else if ($util->post('save_all_options')) {
35
+ c_save_redirection_general_options();
36
+ c_save_redirection_history_options();
37
+ c_save_404_redirection_options();
38
+ c_save_keep_data();
39
+
40
+ $util->success_option_msg(__('All options saved!', 'seo-redirection'));
41
+ }
42
+
43
+
44
+
45
+
46
+
47
+
48
+ if ($util->there_is_cache() != '')
49
+
50
+ $util->info_option_msg(__("You have a cache plugin installed", 'seo-redirection') . " <b>'" . $util->there_is_cache() . "'</b>, " . __("you have to clear cache after any changes to get the changes reflected immediately! ", 'seo-redirection'));
 
 
 
 
 
 
 
 
51
  }
52
 
53
+ $options = $util->get_my_options();
54
 
55
+ ?>
56
 
57
 
58
 
 
 
 
 
 
 
 
 
 
59
  <form method="POST">
60
+
61
+ <div class="container">
62
+ <div class="row">
63
+
64
+
65
+ <div class="col-md-6 mt-4">
66
+
67
+ <h3><?php _e("General Options", "seo-redirection") ?>
68
+ <hr>
69
+ </h3>
70
+
71
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce('seoredirection')); ?>" />
72
+
73
+ <table class="cform" align="center" width="100%">
74
+ <tr>
75
+ <td>
76
+ <?php _e("Plugin Status:", "seo-redirection") ?>
77
+ <?php
78
+ $drop = new dropdown('plugin_status');
79
+ $drop->add(__('Enabled', 'seo-redirection'), '1');
80
+ $drop->add(__('Disabled', 'seo-redirection'), '0');
81
+ $drop->add(__('Disabled for admin only', 'seo-redirection'), '2');
82
+ $drop->dropdown_print();
83
+ $drop->select($options['plugin_status']);
84
+ ?>
85
+
86
+ </td>
87
+ </tr>
88
+
89
+
90
+ <tr>
91
+ <td>
92
+ <?php _e("IP Logging:", "seo-redirection") ?>
93
+ <?php
94
+ $drop = new dropdown('ip_logging_status');
95
+ $drop->add(__('No IP logging', 'seo-redirection'), '0');
96
+ $drop->add(__('Full IP logging', 'seo-redirection'), '1');
97
+ $drop->add(__('Anonymize IP (mask last part)', 'seo-redirection'), '2');
98
+ $drop->dropdown_print();
99
+ $drop->select($options['ip_logging_status']);
100
+ ?>
101
+ <small>&nbsp; used for <a href="https://eugdpr.org/" target="_blank">GDPR</a> compliance</small>
102
+ </td>
103
+ </tr>
104
+
105
+ <tr>
106
+ <td>
107
+ <?php $check = new checkoption('redirect_control_panel', $options['redirect_control_panel']); ?>
108
+ <?php _e("Do not redirect control panel links (This will be usefull when making wrong expressions that may cause an infinit redirection loop).", "seo-redirection"); ?>
109
+
110
+ <br />
111
+ <?php $check = new checkoption('show_redirect_box', $options['show_redirect_box']); ?>
112
+ <?php _e("Show redirect box in posts & pages edit page (Important to set up redirection for posts and pages easily).", "seo-redirection"); ?>
113
+
114
+
115
+ <br />
116
+ <?php $check = new checkoption('reflect_modifications', $options['reflect_modifications']); ?>
117
+ <?php _e("Reflect any modifications in the post permalink to all redirection links (Mostly Recommended).", "seo-redirection"); ?>
118
+
119
+ <script type="text/javascript">
120
+
121
+ </script>
122
+ </td>
123
+ </tr>
124
+
125
+ </table>
126
+ <br />
127
+ <br />
128
+
129
+
130
+ </div>
131
+ <div class="col-md-6 mt-4">
132
+
133
+ <h3><?php _e("Redirection History Options", "seo-redirection") ?>
134
+ <hr>
135
+ </h3>
136
+ <table class="cform" align="center" width="100%">
137
+ <tr>
138
+ <td>
139
+ <?php _e("Redirection History Status:", "seo-redirection") ?>
140
+ <?php
141
+ $drop = new dropdown('history_status');
142
+ $drop->add(__('Enabled', 'seo-redirection'), '1');
143
+ $drop->add(__('Disabled', 'seo-redirection'), '0');
144
+ $drop->dropdown_print();
145
+ $drop->select($options['history_status']);
146
+ ?>
147
+
148
+ </td>
149
+ </tr>
150
+ <tr>
151
+ <td>
152
+ <?php _e("Redirection History Limit:", "seo-redirection") ?>
153
+ <?php
154
+ $drop = new dropdown('history_limit');
155
+ $drop->add(__('7 days', 'seo-redirection'), '7');
156
+ $drop->add(__('1 month', 'seo-redirection'), '30');
157
+ $drop->add(__('2 months', 'seo-redirection'), '60');
158
+ $drop->add(__('3 months', 'seo-redirection'), '90');
159
+ $drop->dropdown_print();
160
+ $drop->select($options['history_limit']);
161
+ ?>
162
+
163
+ </td>
164
+ </tr>
165
+
166
+ </table>
167
+ <br />
168
+ <input style="margin-left:5px" class="button-primary btn-custom btn-search" type="submit" value='Clear History ⊗' name="clear_history">
169
+
170
+ <br />
171
+ <br />
172
+
173
+ </div>
174
+ <div class="col-md-6 mt-4">
175
+
176
+ <h3>404 Error Pages Options
177
+ <hr>
178
+ </h3>
179
+
180
+
181
+ <table class="cform" align="center" width="100%">
182
+ <tr>
183
+ <td>
184
+ 404 Error Pages Discovery:
185
+ <?php
186
+ $drop = new dropdown('p404_discovery_status');
187
+ $drop->add('Enabled', '1');
188
+ $drop->add('Disabled', '0');
189
+ $drop->dropdown_print();
190
+ $drop->select($options['p404_discovery_status']);
191
+ ?>
192
+
193
+ </td>
194
+ </tr>
195
+
196
+ <tr>
197
+ <td>
198
+ Unknown 404 Redirection Status:
199
+ <?php
200
+ $drop = new dropdown('p404_status');
201
+ $drop->add('Enabled', '1');
202
+ $drop->add('Disabled', '2');
203
+ $drop->dropdown_print();
204
+ $drop->select($options['p404_status']);
205
+ ?>
206
+ </td>
207
+ </tr>
208
+
209
+ <tr>
210
+ <td>
211
+ Redirect All Unknown 404 Pages to: <input type="text" name="redirect_to" id="redirect_to" size="30" value="<?php echo esc_attr_e($options['p404_redirect_to']) ?>">&nbsp;<span style="color:red"><br>Have many broken links?</span>&nbsp;<a target="_blank" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/">Click here to fix and improve your site SEO</a>
212
+ </td>
213
+ </tr>
214
+
215
+ </table>
216
+ <br />
217
+ <input style="margin-left:5px" class="button-primary btn-custom btn-search" type="submit" value="Clear All Discovered 404 Pages ⊗" name="clear_all_404">
218
+
219
+ <br /><br />
220
+
221
+ </div>
222
+ <div class="col-md-6 mt-4">
223
+ <h3><?php _e("Redrection Data Options", "seo-redirection"); ?>
224
+ <hr>
225
+ </h3>
226
+ <table class="cform" align="center" width="100%">
227
+ <tr>
228
+ <td>
229
+ <?php $check = new checkoption('keep_data', $options['keep_data'], '1'); ?>
230
+ <?php _e("Keep redirection data after uninstall the plugin, this will be useful when you install it later.", "seo-redirection"); ?>
231
+
232
+ </td>
233
+ </tr>
234
+ </table>
235
+ <br />
236
+ <input style="margin-left:5px" class="button-primary btn-custom btn-search" type="submit" value="<?php _e("Optimize Data Tables ⊗", "seo-redirection") ?>" name="optimize_tables">
237
+ <br /><br /><br />
238
+
239
+ </div>
240
+ </div>
241
+ </div>
242
+
243
+ <hr>
244
+
245
+ <input style="margin-left:5px" class="button-primary btn-custom btn-add" type="submit" value="<?php _e("Save All Options", "seo-redirection") ?>" name="save_all_options">
246
+ <input style="margin-left:5px" class="button-primary btn-custom btn-search" type="submit" value="<?php _e("Restore Default Settings", "seo-redirection") ?>" name="reset_all_options">
247
 
248
  </form>
options/option_page_history.php CHANGED
@@ -1,126 +1,123 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
- global $wpdb,$table_prefix,$util;
4
- $table_name = $table_prefix . 'WP_SEO_Redirection_LOG';
5
- $rlink=$util->WPSR_get_current_parameters(array('search','page_num','add','edit'));
6
 
7
- if($util->get('del')!=''){
8
- if($util->get('del')=='all'){
9
  c_clear_redirection_history();
10
-
11
- if($util->there_is_cache()!='')
12
- $util->info_option_msg(__("You have a cache plugin installed",'seo-redirection')." <b>'" . $util->there_is_cache() . "'</b>, ".__("you have to clear cache after any changes to get the changes reflected immediately! ",'seo-redirection'));
13
  }
14
  }
15
 
16
- if($util->get_option_value('history_status')!='1')
17
- $util->info_option_msg(__("Redirection history property is disabled now!, you can re-enable it from options tab.",'seo-redirection'));
18
 
19
  ?>
20
 
21
  <script type="text/javascript">
22
- //---------------------------------------------------------
23
- function go_search(){
24
- var sword = document.getElementById('search').value;
25
- if(sword!=''){
26
- window.location = "<?php echo esc_url($rlink)?>&search=" + sword ;
27
- }else
28
- {
29
- alert('<?php _e("Please input any search words!","seo-redirection") ?>');
30
- document.getElementById('search').focus();
31
- }
32
-
33
- }
34
 
 
35
  </script>
36
 
37
- <h3><?php _e("Redirection History","seo-redirection"); ?><hr></h3>
 
 
38
  <div class="link_buttons">
39
- <table border="0" width="100%">
40
- <tr>
41
- <td width="150"><a href="<?php echo esc_url($rlink)?>&del=all" class="button"><span style="padding-top: 3px;" class="dashicons dashicons-trash"></span>&nbsp;<?php _e("Clear History","seo-redirection"); ?></a></td>
42
- <td align="right">
43
- <input onkeyup="if (event.keyCode == 13) go_search();" style="height: 30px;" id="search" type="text" name="search" value="<?php echo htmlentities($util->get('search'),ENT_QUOTES)?>" size="30">
44
- <a onclick="go_search()" href="#" class="button"><span style="padding-top: 3px;" class="dashicons dashicons-search"></span>&nbsp;<?php _e("Search","seo-redirection"); ?></a>
45
- <a href="<?php echo esc_url($util->WPSR_get_current_parameters('search'))?>" class="button"><span style="padding-top: 3px;" class="dashicons dashicons-screenoptions"></span>&nbsp;<?php _e("Show All","seo-redirection"); ?></a>
46
- </td>
47
- </tr>
48
- </table>
49
  </div>
50
 
51
  <?php
52
-
53
-
54
- $grid = new datagrid();
55
- $grid->set_data_source($table_name);
56
- $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
57
- $grid->set_order(" ID desc ");
58
-
59
- if($util->get('search')!='')
60
- {
61
- $search=$util->get('search');
62
-
63
- $grid->set_filter(" rfrom like '%%$search%%' or rto like '%%$search%%' or ctime like '%%$search%%'
64
  or referrer like '%%$search%%' or country like '%%$search%%' or ip like '%%$search%%'
65
  or os like '%%$search%%' or browser like '%%$search%%' or rsrc like '%%$search%%' or rtype like '%%$search%%'
66
  ");
67
- }
68
-
69
- $grid->add_select_field('rID');
70
- $grid->add_select_field('postID');
71
- $grid->add_select_field('referrer');
72
- $grid->add_select_field('ip');
73
- $grid->add_select_field('os');
74
- $grid->add_select_field('browser');
75
- $grid->add_select_field('rsrc');
76
- $grid->add_select_field('rfrom');
77
- $grid->add_select_field('rto');
78
- $grid->add_select_field('ctime');
79
-
80
- $grid->set_table_attr('width','100%');
81
- $grid->set_col_attr(1,'width','120px');
82
- $grid->set_col_attr(3,'width','20px');
83
- $grid->set_col_attr(3,'align','center');
84
- $grid->set_col_attr(4,'width','20px');
85
- $grid->set_col_attr(4,'align','center');
86
- $grid->set_col_attr(7,'width','30px');
87
- $grid->set_col_attr(7,'align','center');
88
- $grid->set_col_attr(6,'width','75px');
89
- $grid->set_col_attr(5,'width','130px');
90
-
91
- $grid->set_col_attr(1, 'width', '90px', 'header');
92
- $grid->set_col_attr(3, 'width', '40px', 'header');
93
- $grid->set_col_attr(4, 'width', '40px', 'header');
94
- $grid->set_col_attr(5, 'width', '125px', 'header');
95
- $grid->set_col_attr(6, 'width', '120px', 'header');
96
- $grid->set_col_attr(7, 'width', '50px', 'header');
97
-
98
- $grid->add_php_col('db_date_y<br/>db_date_h',__('Time','seo-redirection'));
99
-
100
- $grid->add_php_col("<div class='arrow_from'><a target='_blank' href='db_rfrom_url'>db_rfrom</a></div><div class='arrow_to'><a target='_blank' href='db_rto_url'>db_rto</a></div>",__('Redirection','seo-redirection'));
101
- $grid->add_data_col('rtype','Type');
102
- $grid->add_php_col('db_referrer_var',__('Ref','seo-redirection'));
103
-
104
-
105
-
106
- if($util->get_option_value('ip_logging_status') == 0)
107
- {
108
- $grid->add_html_col('--',__('IP','seo-redirection'));
109
- }else if($util->get_option_value('ip_logging_status') == 1)
110
- {
111
- $grid->add_html_col('<a target="_blank" href="https://tools.keycdn.com/geo?host={db_ip}">{db_ip}</a>',__('IP','seo-redirection'));
112
- }else{
113
-
114
- $grid->add_php_col('db_ip',__('IP','seo-redirection'));
115
- }
116
-
117
-
118
- $grid->add_html_col('{db_os}<br/>{db_browser}',__('Agent','seo-redirection'));
119
-
120
- $grid->add_php_col('db_rsrc_custom',__('Class','seo-redirection'));
121
-
122
-
123
- $grid->run();
124
-
125
 
126
  ?>
1
  <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+ global $wpdb, $table_prefix, $util;
4
+ $table_name = $table_prefix . 'WP_SEO_Redirection_LOG';
5
+ $rlink = $util->WPSR_get_current_parameters(array('search', 'page_num', 'add', 'edit'));
6
 
7
+ if ($util->get('del') != '') {
8
+ if ($util->get('del') == 'all') {
9
  c_clear_redirection_history();
10
+
11
+ if ($util->there_is_cache() != '')
12
+ $util->info_option_msg(__("You have a cache plugin installed", 'seo-redirection') . " <b>'" . $util->there_is_cache() . "'</b>, " . __("you have to clear cache after any changes to get the changes reflected immediately! ", 'seo-redirection'));
13
  }
14
  }
15
 
16
+ if ($util->get_option_value('history_status') != '1')
17
+ $util->info_option_msg(__("Redirection history property is disabled now!, you can re-enable it from options tab.", 'seo-redirection'));
18
 
19
  ?>
20
 
21
  <script type="text/javascript">
22
+ //---------------------------------------------------------
23
+ function go_search() {
24
+ var sword = document.getElementById('search').value;
25
+ if (sword != '') {
26
+ window.location = "<?php echo esc_url($rlink) ?>&search=" + sword;
27
+ } else {
28
+ alert('<?php _e("Please input any search words!", "seo-redirection") ?>');
29
+ document.getElementById('search').focus();
30
+ }
 
 
 
31
 
32
+ }
33
  </script>
34
 
35
+ <h3><?php _e("Redirection History", "seo-redirection"); ?>
36
+ <hr>
37
+ </h3>
38
  <div class="link_buttons">
39
+ <table border="0" width="100%">
40
+ <tr>
41
+ <td width="150"><a href="<?php echo esc_url($rlink) ?>&del=all" class="button btn-custom btn-delete"><span style="padding-top: 3px;" class="dashicons dashicons-trash"></span>&nbsp;<?php _e("Clear History", "seo-redirection"); ?></a></td>
42
+ <td align="right">
43
+ <input onkeyup="if (event.keyCode == 13) go_search();" style="height: 30px; border-radius: 3px !important;" id="search" type="text" name="search" value="<?php echo htmlentities($util->get('search'), ENT_QUOTES) ?>" size="30">
44
+ <a onclick="go_search()" href="#" class="button btn-custom btn-search"><span style="padding-top: 3px;" class="dashicons dashicons-search"></span>&nbsp;<?php _e("Search", "seo-redirection"); ?></a>
45
+ <a href="<?php echo esc_url($util->WPSR_get_current_parameters('search')) ?>" class="button btn-custom btn-search"><span style="padding-top: 3px;" class="dashicons dashicons-screenoptions"></span>&nbsp;<?php _e("Show All", "seo-redirection"); ?></a>
46
+ </td>
47
+ </tr>
48
+ </table>
49
  </div>
50
 
51
  <?php
52
+
53
+
54
+ $grid = new datagrid();
55
+ $grid->set_data_source($table_name);
56
+ $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
57
+ $grid->set_order(" ID desc ");
58
+
59
+ if ($util->get('search') != '') {
60
+ $search = $util->get('search');
61
+
62
+ $grid->set_filter(" rfrom like '%%$search%%' or rto like '%%$search%%' or ctime like '%%$search%%'
 
63
  or referrer like '%%$search%%' or country like '%%$search%%' or ip like '%%$search%%'
64
  or os like '%%$search%%' or browser like '%%$search%%' or rsrc like '%%$search%%' or rtype like '%%$search%%'
65
  ");
66
+ }
67
+
68
+ $grid->add_select_field('rID');
69
+ $grid->add_select_field('postID');
70
+ $grid->add_select_field('referrer');
71
+ $grid->add_select_field('ip');
72
+ $grid->add_select_field('os');
73
+ $grid->add_select_field('browser');
74
+ $grid->add_select_field('rsrc');
75
+ $grid->add_select_field('rfrom');
76
+ $grid->add_select_field('rto');
77
+ $grid->add_select_field('ctime');
78
+
79
+ $grid->set_table_attr('width', '100%');
80
+ $grid->set_col_attr(1, 'width', '120px');
81
+ $grid->set_col_attr(3, 'width', '20px');
82
+ $grid->set_col_attr(3, 'align', 'center');
83
+ $grid->set_col_attr(4, 'width', '20px');
84
+ $grid->set_col_attr(4, 'align', 'center');
85
+ $grid->set_col_attr(7, 'width', '30px');
86
+ $grid->set_col_attr(7, 'align', 'center');
87
+ $grid->set_col_attr(6, 'width', '75px');
88
+ $grid->set_col_attr(5, 'width', '130px');
89
+
90
+ $grid->set_col_attr(1, 'width', '90px', 'header');
91
+ $grid->set_col_attr(3, 'width', '40px', 'header');
92
+ $grid->set_col_attr(4, 'width', '40px', 'header');
93
+ $grid->set_col_attr(5, 'width', '125px', 'header');
94
+ $grid->set_col_attr(6, 'width', '120px', 'header');
95
+ $grid->set_col_attr(7, 'width', '50px', 'header');
96
+
97
+ $grid->add_php_col('db_date_y<br/>db_date_h', __('Time', 'seo-redirection'));
98
+
99
+ $grid->add_php_col("<div class='arrow_from'><a target='_blank' href='db_rfrom_url'>db_rfrom</a></div><div class='arrow_to'><a target='_blank' href='db_rto_url'>db_rto</a></div>", __('Redirection', 'seo-redirection'));
100
+ $grid->add_data_col('rtype', 'Type');
101
+ $grid->add_php_col('db_referrer_var', __('Ref', 'seo-redirection'));
102
+
103
+
104
+
105
+ if ($util->get_option_value('ip_logging_status') == 0) {
106
+ $grid->add_html_col('--', __('IP', 'seo-redirection'));
107
+ } else if ($util->get_option_value('ip_logging_status') == 1) {
108
+ $grid->add_html_col('<a target="_blank" href="https://tools.keycdn.com/geo?host={db_ip}">{db_ip}</a>', __('IP', 'seo-redirection'));
109
+ } else {
110
+
111
+ $grid->add_php_col('db_ip', __('IP', 'seo-redirection'));
112
+ }
113
+
114
+
115
+ $grid->add_html_col('{db_os}<br/>{db_browser}', __('Agent', 'seo-redirection'));
116
+
117
+ $grid->add_php_col('db_rsrc_custom', __('Class', 'seo-redirection'));
118
+
119
+
120
+ $grid->run();
121
+
 
 
122
 
123
  ?>
options/option_page_post_redirection_list.php CHANGED
@@ -1,118 +1,112 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
- global $wpdb,$table_prefix,$util;
4
  $table_name = $table_prefix . 'WP_SEO_Redirection';
5
 
6
- if($util->get('del')!='')
7
- {
8
- $delid=intval($util->get('del'));
9
-
10
- $wpdb->query($wpdb->prepare(" delete from $table_name where ID=%s ",$delid));
11
-
12
-
13
- if($util->there_is_cache()!='')
14
- $util->info_option_msg(__("You have a cache plugin installed",'seo-redirection')." <b>'" . $util->there_is_cache() . "'</b>, ".__("you have to clear cache after any changes to get the changes reflected immediately! ",'seo-redirection'));
15
-
16
- $SR_redirect_cache = new free_SR_redirect_cache();
17
- $SR_redirect_cache->free_cache();
18
- }
19
-
20
- $rlink=$util->WPSR_get_current_parameters(array('search','page_num','add','edit','tab'));
21
-
22
  ?>
23
- <br/>
24
 
25
  <script type="text/javascript">
 
26
 
27
- //---------------------------------------------------------
 
 
 
 
 
28
 
29
- function go_search(){
30
- <?php
31
- isset($_REQUEST['tab'])?$url_op= sanitize_text_field($_REQUEST['tab']) :$url_op="";
32
- ?>
33
- var sword = document.getElementById('search').value;
34
- if(sword!=''){
35
-
36
- var url= "sprintf('%s&tab=%s', esc_url($rlink),esc_html($url_op)); ?>&search=" + sword;
37
- url=decodeURIComponent(url);
38
-
39
- window.location =url;
40
- }else
41
- {
42
- alert('<?php _e("Please input any search words!",'seo-redirection') ?>');
43
- document.getElementById('search').focus();
44
- }
45
-
46
- }
47
 
 
 
 
 
 
48
 
 
49
  </script>
50
 
51
  <div class="link_buttons">
52
- <table border="0" width="100%">
53
- <tr>
54
- <td align="right">
55
- <input onkeyup="if (event.keyCode == 13) go_search();" style="height: 30px;" id="search" type="text" name="search" value="<?php echo htmlentities($util->get('search','title'))?>" size="30">
56
- <!--<a onclick="go_search()" href="#"><div class="search_link"><?php _e("Search","seo-redirection"); ?></div></a>-->
57
- <a onclick="go_search()" href="#" class="button"><span style="padding-top: 3px;" class="dashicons dashicons-search"></span>&nbsp;<?php _e("Search","seo-redirection"); ?></a>
58
-
59
- <a href="<?php echo esc_url($util->WPSR_get_current_parameters('search'))?>" class="button"><span style="padding-top: 3px;" class="dashicons dashicons-screenoptions"></span>&nbsp;<?php _e("Show All","seo-redirection"); ?></a>
60
- </td>
61
- </tr>
62
- </table>
63
  </div>
64
  <?php
65
 
66
- $grid = new datagrid();
67
- $grid->set_data_source($table_name);
68
- $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
69
- $grid->add_select_field('ID');
70
- $grid->add_select_field('postID');
71
- $grid->add_select_field('redirect_from');
72
- $grid->add_select_field('redirect_from_type');
73
- $grid->add_select_field('redirect_to');
74
- $grid->add_select_field('redirect_to_type');
75
-
76
- $grid->set_table_attr('width','100%');
77
-
78
- $grid->set_col_attr(1,'width','30%','header');
79
- $grid->set_col_attr(2,'width','30%','header');
80
- $grid->set_col_attr(3,'width','50px','header');
81
- $grid->set_col_attr(3, 'style', 'text-align:center;','header');
82
- $grid->set_col_attr(4,'width','50px','header');
83
- $grid->set_col_attr(4, 'style', 'text-align:center;','header');
84
- $grid->set_col_attr(5,'width','150px','header');
85
- $grid->set_col_attr(5, 'style', 'text-align:center;','header');
86
- $grid->set_col_attr(6,'width','50px','header');
87
- $grid->set_col_attr(7,'width','50px','header');
88
-
89
- $grid->set_col_attr(3, 'style', 'text-align:center;');
90
- $grid->set_col_attr(4, 'style', 'text-align:center;');
91
- $grid->set_col_attr(5, 'style', 'text-align:center;');
92
-
93
- $grid->set_order(" ID desc ");
94
-
95
- $grid->set_filter("url_type=2");
96
-
97
- if($util->get('search')!='')
98
- {
99
- $search=$util->get('search');
100
- $grid->set_filter("url_type!=1 and (redirect_from like '%%$search%%' or redirect_to like '%%$search%%' or redirect_type like '%%$search%%' )");
101
- }
102
-
103
- //$grid->add_data_col('redirect_from','Redirect from');
104
- //$grid->add_data_col('redirect_to','Redirect to');
105
- $grid->add_php_col( "<div class='db_redirect_from_type_background_db_enabled'><a target='_blank' href='db_redirect_from_url'>db_redirect_from</a></div>",__('Redirect from ','seo-redirection'));
106
- $grid->add_php_col("<div class='db_redirect_to_type_background_db_enabled'><a target='_blank' href='db_redirect_to_url'>db_redirect_to</a></div>",__('Redirect to ','seo-redirection'));
107
- $grid->add_data_col('redirect_type',__('Type','seo-redirection'));
108
- $grid->add_data_col('hits',__('Hits','seo-redirection'));
109
- $grid->add_data_col('access_date',__('Last Access','seo-redirection'));
110
- $grid->add_template_col('go_link','post.php?post={db_postID}&action=edit','Actions');
111
- // $grid->add_template_col( $util->WPSR_get_current_parameters('del') . '&del={db_ID}','');
112
-
113
- $grid->run();
114
-
115
-
116
 
117
  ?>
118
- <?php echo "<b>Note</b>:".__("To add a redirection for any post or page , use custom redirection or go to the edit page, you will find the redirection box, use it to set your redirection.","seo-redirection")."<br/>" ?>
1
+ <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+ global $wpdb, $table_prefix, $util;
4
  $table_name = $table_prefix . 'WP_SEO_Redirection';
5
 
6
+ if ($util->get('del') != '') {
7
+ $delid = intval($util->get('del'));
8
+
9
+ $wpdb->query($wpdb->prepare(" delete from $table_name where ID=%s ", $delid));
10
+
11
+
12
+ if ($util->there_is_cache() != '')
13
+ $util->info_option_msg(__("You have a cache plugin installed", 'seo-redirection') . " <b>'" . $util->there_is_cache() . "'</b>, " . __("you have to clear cache after any changes to get the changes reflected immediately! ", 'seo-redirection'));
14
+
15
+ $SR_redirect_cache = new free_SR_redirect_cache();
16
+ $SR_redirect_cache->free_cache();
17
+ }
18
+
19
+ $rlink = $util->WPSR_get_current_parameters(array('search', 'page_num', 'add', 'edit', 'tab'));
20
+
 
21
  ?>
22
+ <br />
23
 
24
  <script type="text/javascript">
25
+ //---------------------------------------------------------
26
 
27
+ function go_search() {
28
+ <?php
29
+ isset($_REQUEST['tab']) ? $url_op = sanitize_text_field($_REQUEST['tab']) : $url_op = "";
30
+ ?>
31
+ var sword = document.getElementById('search').value;
32
+ if (sword != '') {
33
 
34
+ var url = "sprintf('%s&tab=%s', esc_url($rlink),esc_html($url_op)); ?>&search=" + sword;
35
+ url = decodeURIComponent(url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ window.location = url;
38
+ } else {
39
+ alert('<?php _e("Please input any search words!", 'seo-redirection') ?>');
40
+ document.getElementById('search').focus();
41
+ }
42
 
43
+ }
44
  </script>
45
 
46
  <div class="link_buttons">
47
+ <table border="0" width="100%">
48
+ <tr>
49
+ <td align="right">
50
+ <input onkeyup="if (event.keyCode == 13) go_search();" style="height: 30px; border-radius: 2px !important;" id="search" type="text" name="search" value="<?php echo htmlentities($util->get('search', 'title')) ?>" size="30">
51
+ <!--<a onclick="go_search()" href="#"><div class="search_link"><?php _e("Search", "seo-redirection"); ?></div></a>-->
52
+ <a onclick="go_search()" href="#" class="button btn-custom btn-search"><span style="padding-top: 3px;" class="dashicons dashicons-search"></span>&nbsp;<?php _e("Search", "seo-redirection"); ?></a>
53
+
54
+ <a href="<?php echo esc_url($util->WPSR_get_current_parameters('search')) ?>" class="button btn-custom btn-search"><span style="padding-top: 3px;" class="dashicons dashicons-screenoptions"></span>&nbsp;<?php _e("Show All", "seo-redirection"); ?></a>
55
+ </td>
56
+ </tr>
57
+ </table>
58
  </div>
59
  <?php
60
 
61
+ $grid = new datagrid();
62
+ $grid->set_data_source($table_name);
63
+ $grid->set_table_attr('class', 'wp-list-table widefat fixed striped');
64
+ $grid->add_select_field('ID');
65
+ $grid->add_select_field('postID');
66
+ $grid->add_select_field('redirect_from');
67
+ $grid->add_select_field('redirect_from_type');
68
+ $grid->add_select_field('redirect_to');
69
+ $grid->add_select_field('redirect_to_type');
70
+
71
+ $grid->set_table_attr('width', '100%');
72
+
73
+ $grid->set_col_attr(1, 'width', '30%', 'header');
74
+ $grid->set_col_attr(2, 'width', '30%', 'header');
75
+ $grid->set_col_attr(3, 'width', '50px', 'header');
76
+ $grid->set_col_attr(3, 'style', 'text-align:center;', 'header');
77
+ $grid->set_col_attr(4, 'width', '50px', 'header');
78
+ $grid->set_col_attr(4, 'style', 'text-align:center;', 'header');
79
+ $grid->set_col_attr(5, 'width', '150px', 'header');
80
+ $grid->set_col_attr(5, 'style', 'text-align:center;', 'header');
81
+ $grid->set_col_attr(6, 'width', '50px', 'header');
82
+ $grid->set_col_attr(7, 'width', '50px', 'header');
83
+
84
+ $grid->set_col_attr(3, 'style', 'text-align:center;');
85
+ $grid->set_col_attr(4, 'style', 'text-align:center;');
86
+ $grid->set_col_attr(5, 'style', 'text-align:center;');
87
+
88
+ $grid->set_order(" ID desc ");
89
+
90
+ $grid->set_filter("url_type=2");
91
+
92
+ if ($util->get('search') != '') {
93
+ $search = $util->get('search');
94
+ $grid->set_filter("url_type!=1 and (redirect_from like '%%$search%%' or redirect_to like '%%$search%%' or redirect_type like '%%$search%%' )");
95
+ }
96
+
97
+ //$grid->add_data_col('redirect_from','Redirect from');
98
+ //$grid->add_data_col('redirect_to','Redirect to');
99
+ $grid->add_php_col("<div class='db_redirect_from_type_background_db_enabled'><a target='_blank' href='db_redirect_from_url'>db_redirect_from</a></div>", __('Redirect from ', 'seo-redirection'));
100
+ $grid->add_php_col("<div class='db_redirect_to_type_background_db_enabled'><a target='_blank' href='db_redirect_to_url'>db_redirect_to</a></div>", __('Redirect to ', 'seo-redirection'));
101
+ $grid->add_data_col('redirect_type', __('Type', 'seo-redirection'));
102
+ $grid->add_data_col('hits', __('Hits', 'seo-redirection'));
103
+ $grid->add_data_col('access_date', __('Last Access', 'seo-redirection'));
104
+ $grid->add_template_col('go_link', 'post.php?post={db_postID}&action=edit', 'Actions');
105
+ // $grid->add_template_col( $util->WPSR_get_current_parameters('del') . '&del={db_ID}','');
106
+
107
+ $grid->run();
108
+
109
+
 
110
 
111
  ?>
112
+ <?php echo "<b>Note</b>:" . __("To add a redirection for any post or page , use custom redirection or go to the edit page, you will find the redirection box, use it to set your redirection.", "seo-redirection") . "<br/>" ?>
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: wp-buy, osama.esh
3
  Tags: post, admin, seo, pages, manage, 301, 404, soft 404, redirect, permalink, redirection, redirection, https, automatic redirection, htaccess, ssl, https redirection, ssl certificate, secure page, secure, force ssl, force https, seo redirection, post redirect, 404 to 301
4
  Requires at least: 4.1
5
- Tested up to: 5.8.2
6
  Stable tag: 8.4
7
 
8
  SEO Redirection is a powerful redirect manager to manage 301 redirects without requiring knowledge of Apache .htaccess files.
@@ -73,6 +73,10 @@ Yes, here is the plugin full knowledge base http://www.clogica.com/kb/
73
 
74
  == Upgrade Notice ==
75
 
 
 
 
 
76
  = 8.3 =
77
  * add settings page link under plugin name
78
  * Bug fixing in updating redirects
2
  Contributors: wp-buy, osama.esh
3
  Tags: post, admin, seo, pages, manage, 301, 404, soft 404, redirect, permalink, redirection, redirection, https, automatic redirection, htaccess, ssl, https redirection, ssl certificate, secure page, secure, force ssl, force https, seo redirection, post redirect, 404 to 301
4
  Requires at least: 4.1
5
+ Tested up to: 5.9.1
6
  Stable tag: 8.4
7
 
8
  SEO Redirection is a powerful redirect manager to manage 301 redirects without requiring knowledge of Apache .htaccess files.
73
 
74
  == Upgrade Notice ==
75
 
76
+
77
+ = 8.4 =
78
+ * ui enhancement
79
+
80
  = 8.3 =
81
  * add settings page link under plugin name
82
  * Bug fixing in updating redirects
seo-redirection.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: SEO Redirection
4
  Plugin URI: https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/
5
  Description: By this plugin you can manage all your website redirection types easily.
6
  Author: wp-buy
7
- Version: 8.3
8
  Author URI: https://www.wp-buy.com
9
  Text Domain: seo-redirection
10
  */
@@ -561,12 +561,12 @@ if(!function_exists("WPSR_header_code")) {
561
  $my_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
562
  if ($my_page == 'seo-redirection.php') {
563
 
564
- wp_register_style('c_admin_css_common', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "style.css");
565
  wp_enqueue_style('sweetalert', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "sweetalert.css");
566
  wp_register_style('c_admin_css_custom', plugins_url() . '/' . basename(dirname(__FILE__)) . '/custom/' . "style.css");
567
  wp_enqueue_script('jquery');
568
  wp_localize_script('jquery', 'seoredirection', array('ajax_url' => admin_url('admin-ajax.php'), 'msg' => ""));
569
- wp_enqueue_style('c_admin_css_common');
570
  wp_enqueue_style('c_admin_css_custom');
571
 
572
  wp_enqueue_script('custom', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/js/' . 'bootstrap.min.js', array('jquery'), false, true);
4
  Plugin URI: https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/
5
  Description: By this plugin you can manage all your website redirection types easily.
6
  Author: wp-buy
7
+ Version: 8.4
8
  Author URI: https://www.wp-buy.com
9
  Text Domain: seo-redirection
10
  */
561
  $my_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
562
  if ($my_page == 'seo-redirection.php') {
563
 
564
+ wp_register_style('c_admin_css_common', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "style.css");
565
  wp_enqueue_style('sweetalert', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "sweetalert.css");
566
  wp_register_style('c_admin_css_custom', plugins_url() . '/' . basename(dirname(__FILE__)) . '/custom/' . "style.css");
567
  wp_enqueue_script('jquery');
568
  wp_localize_script('jquery', 'seoredirection', array('ajax_url' => admin_url('admin-ajax.php'), 'msg' => ""));
569
+ wp_enqueue_style('c_admin_css_common'); $rand = rand( 1, 99999999999 ); wp_register_style('c_css_common', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "custom.css", '', $rand); wp_enqueue_style('c_css_common');
570
  wp_enqueue_style('c_admin_css_custom');
571
 
572
  wp_enqueue_script('custom', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/js/' . 'bootstrap.min.js', array('jquery'), false, true);
seo-redirection.php.bak ADDED
@@ -0,0 +1,1333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: SEO Redirection
4
+ Plugin URI: https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/
5
+ Description: By this plugin you can manage all your website redirection types easily.
6
+ Author: wp-buy
7
+ Version: 8.5
8
+ Author URI: https://www.wp-buy.com
9
+ Text Domain: seo-redirection
10
+ */
11
+
12
+ require_once('common/controls.php');
13
+ require_once('custom/controls.php');
14
+ require_once('custom/controls/cf.SR_redirect_cache.class.php');
15
+
16
+ define('WPSR_PATH', plugin_dir_path(__FILE__));
17
+
18
+ if (!defined('WPSR_URL')) define('WPSR_URL', plugin_dir_url(__FILE__));
19
+
20
+
21
+ if (!defined('WP_SEO_REDIRECTION_OPTIONS')) {
22
+ define('WP_SEO_REDIRECTION_OPTIONS', 'wp-seo-redirection-group');
23
+ }
24
+
25
+ if (!defined('WP_SEO_REDIRECTION_VERSION')) {
26
+ define('WP_SEO_REDIRECTION_VERSION', 6.4);
27
+ }
28
+
29
+ $util = new clogica_util_1();
30
+ $util->init(WP_SEO_REDIRECTION_OPTIONS, __FILE__);
31
+
32
+
33
+ add_action('admin_enqueue_scripts', 'WPSR_header_code');
34
+ add_action('admin_menu', 'WPSR_admin_menu');
35
+ add_action('wp', 'WPSR_redirect', 1);
36
+ add_action('save_post', 'WPSR_get_post_redirection');
37
+ add_action('add_meta_boxes', 'WPSR_adding_custom_meta_boxes', 10, 3);
38
+ add_action('admin_head', 'WPSR_check_default_permalink');
39
+ add_action('plugins_loaded', 'WPSR_upgrade');
40
+
41
+ register_activation_hook(__FILE__, 'WPSR_upgrade');
42
+ register_uninstall_hook(__FILE__, 'WPSR_uninstall');
43
+
44
+ /////////////////////////////////////////////////////////////////////////
45
+
46
+ if(!function_exists("WPSR__filter_action_links")){
47
+ function WPSR__filter_action_links( $links ) {
48
+ $links['settings'] = sprintf('<a href="%s">Settings</a>', admin_url( 'options-general.php?page=seo-redirection.php' ));
49
+ $links['MorePlugins'] = sprintf('<a href="%s"><b style="color:#f18500">More Plugins</b></a>', admin_url( 'plugin-install.php?s=wp-buy&tab=search&type=author' ));
50
+ return $links;
51
+ }
52
+ add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'WPSR__filter_action_links', 10, 1 );
53
+ }
54
+
55
+ if(!function_exists("WPSR_multiple_plugin_activate_trial")){
56
+ function WPSR_multiple_plugin_activate_trial()
57
+ {
58
+ global $wpdb;
59
+ if (is_multisite()) {
60
+ if (is_plugin_active_for_network(__FILE__)) {
61
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
62
+ foreach ($blogids as $blog_id) {
63
+ switch_to_blog($blog_id);
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ register_activation_hook(__FILE__, 'WPSR_multiple_plugin_activate_trial');
70
+
71
+ }
72
+
73
+ if(!function_exists("WPSR_adding_custom_meta_boxes")) {
74
+
75
+ function WPSR_adding_custom_meta_boxes()
76
+ {
77
+ global $util;
78
+ if ($util->get_option_value('show_redirect_box') == '1') {
79
+
80
+ $screens = array('post', 'page');
81
+
82
+ foreach ($screens as $screen) {
83
+
84
+ add_meta_box(
85
+ 'WPSR_meta_box',
86
+ __('SEO Redirection'),
87
+ 'WPSR_render_meta_box',
88
+ $screen
89
+ );
90
+ }
91
+
92
+ }
93
+ }
94
+ }
95
+ if(!function_exists("WPSR_render_meta_box")) {
96
+
97
+ function WPSR_render_meta_box($post)
98
+ {
99
+ global $wpdb, $table_prefix, $util;
100
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
101
+
102
+ if (get_post_status() != 'auto-draft') {
103
+ $permalink = "";
104
+ if (in_array($post->post_status, array('draft', 'pending'))) {
105
+ list($permalink, $postname) = get_sample_permalink($post->ID);
106
+ $permalink = str_replace('%postname%', $postname, $permalink);
107
+
108
+ } else {
109
+
110
+ $permalink = get_permalink($post->ID);
111
+ }
112
+
113
+ $permalink = $util->make_relative_url(urldecode($permalink));
114
+
115
+ $postID = $post->ID;
116
+
117
+
118
+ $theurl = $wpdb->get_row($wpdb->prepare(" select redirect_to,redirect_from from $table_name where postID=%d ", $postID));
119
+
120
+ $urlredirect_to = '';
121
+ if ($wpdb->num_rows > 0)
122
+ $urlredirect_to = $theurl->redirect_to;
123
+
124
+ if ($urlredirect_to != '' && $theurl->redirect_from != $permalink) {
125
+ // the post_name field changed!
126
+ $wpdb->query($wpdb->prepare(" update $table_name set redirect_from=%s where postID=%d ", $permalink, $postID));
127
+ if ($util->get_option_value('reflect_modifications') == '1') {
128
+ $wpdb->query($wpdb->prepare(" update $table_name set redirect_to=%s where redirect_to=%s ", $permalink, $theurl->redirect_from));
129
+ $util->info_option_msg('<b>' . __("SEO Redirection", 'seo-redirection') . '</b>' . __('has detected a change in Permalink, this will be reflected to the redirection records!', 'seo-redirection'));
130
+ }
131
+ //-------------------------------------------
132
+ }
133
+
134
+ echo '
135
+ <table border="0" width="100%" cellpadding="2">
136
+ <tr>
137
+ <td width="99%"><input onchange="redirect_check_click()" type="checkbox" name="redirect_check" id="redirect_check" value="ON">
138
+ Redirect&nbsp;<font id="wp_seo_redirection_url_from_label" color="#008000">' . esc_html($permalink) . '</font><input type="hidden" ID="wp_seo_redirection_url_from" name="wp_seo_redirection_url_from" value="' . esc_attr($permalink) . '"></td>
139
+ </tr>
140
+ </table>
141
+ <div id="redirect_frame">
142
+ <table border="0" width="100%" cellpadding="2">
143
+ <tr>
144
+ <td>
145
+
146
+ <b>' . __(" Redirect to", 'seo-redirection') . '</b><input type="text" name="wp_seo_redirection_url" id="wp_seo_redirection_url" value="' . esc_attr($urlredirect_to) . '" size="62"></td>
147
+ </tr>
148
+ <tr>
149
+ <td>
150
+ <ul>
151
+ <li>' . __(" To make a redirection, put the", 'seo-redirection') . ' <b>' . __("URL", 'seo-redirection') . '</b> ' . __("in the text field above and then click the button ", 'seo-redirection') . '<b>' . __("Update", 'seo-redirection') . '</b>.</li>
152
+ <li>' . __("If you have a caching plugin installed, clear cache to reflect the
153
+ changes immediately.", 'seo-redirection') . '</li>
154
+
155
+ <li>' . __("To remove the redirection, just uncheck the check box above and then click the button", 'seo-redirection') . ' <b>' . __("Update", 'seo-redirection') . '</b>.</li>
156
+ </ul>
157
+ </td>
158
+ </tr>
159
+ </table>
160
+ </div>';
161
+
162
+ echo "
163
+
164
+ <script type='text/javascript'>
165
+ function WSR_check_status(x)
166
+ {
167
+
168
+ if(x==0)
169
+ {
170
+ document.getElementById('redirect_check').checked=false;
171
+ document.getElementById('redirect_frame').style.display = 'none';
172
+ document.getElementById('wp_seo_redirection_url').value='';
173
+ }else
174
+ {
175
+ document.getElementById('redirect_check').checked=true;
176
+ document.getElementById('redirect_frame').style.display= 'block';
177
+ }
178
+
179
+ }
180
+
181
+ function redirect_check_click()
182
+ {
183
+ if(document.getElementById('redirect_check').checked)
184
+ WSR_check_status(1);
185
+ else
186
+ WSR_check_status(0);
187
+ }
188
+ </script>
189
+ ";
190
+
191
+ if ($urlredirect_to == '')
192
+ echo "<script type='text/javascript'>WSR_check_status(0);</script>";
193
+ else
194
+ echo "<script type='text/javascript'>WSR_check_status(1);</script>";
195
+
196
+
197
+ } else {
198
+ echo __('You can not make a redirection for the new posts before saving them.', 'seo-redirection');
199
+ }
200
+ }
201
+ }
202
+
203
+ //--------------------------------------------------------------------------------------------
204
+
205
+ //---------------------------------------------------------------
206
+ // added 2/2/2020
207
+ if(!function_exists("WPSR_get_site_404_page_path")) {
208
+
209
+ function WPSR_get_site_404_page_path()
210
+ {
211
+ $url = str_ireplace("://", "", site_url());
212
+ $site_404_page = substr($url, stripos($url, "/"));
213
+
214
+ if (stripos($url, "/") === FALSE || $site_404_page == "/")
215
+ $site_404_page = "/index.php?error=404";
216
+ else
217
+ $site_404_page = $site_404_page . "/index.php?error=404";
218
+
219
+ return $site_404_page;
220
+ }
221
+
222
+ }
223
+ //---------------------------------------------------------------
224
+ // updated 2/2/2020
225
+
226
+ function WPSR_check_default_permalink()
227
+ {
228
+ $file= get_home_path() . "/.htaccess";
229
+ $content="ErrorDocument 404 " . WPSR_get_site_404_page_path();
230
+
231
+ $marker_name="FRedirect_ErrorDocument";
232
+ $filestr ="";
233
+
234
+ if(file_exists($file)){
235
+ $f = @fopen( $file, 'r+' );
236
+ $filestr = @fread($f , filesize($file));
237
+ if (strpos($filestr , $marker_name) === false)
238
+ {
239
+ insert_with_markers( $file, $marker_name, $content );
240
+ }
241
+ }else
242
+ {
243
+ insert_with_markers( $file, $marker_name, $content );
244
+ }
245
+
246
+ }
247
+
248
+ //------------------------------------------------------------------------
249
+
250
+
251
+ /**
252
+ * Recursive sanitation for text or array
253
+ *
254
+ * @param $array_or_string (array|string)
255
+ * @since 0.1
256
+ * @return mixed
257
+ */
258
+ if(!function_exists("WPSR_sanitize_text_or_array_field")) {
259
+
260
+ function WPSR_sanitize_text_or_array_field($array_or_string)
261
+ {
262
+ if (is_string($array_or_string)) {
263
+ $array_or_string = sanitize_text_field($array_or_string);
264
+ } elseif (is_array($array_or_string)) {
265
+ foreach ($array_or_string as $key => &$value) {
266
+ if (is_array($value)) {
267
+ $value = WPSR_sanitize_text_or_array_field($value);
268
+ } else {
269
+ $value = sanitize_text_field($value);
270
+ }
271
+ }
272
+ }
273
+
274
+ return $array_or_string;
275
+ }
276
+ }
277
+ if(!function_exists("WPSR_get_post_redirection")) {
278
+
279
+ function WPSR_get_post_redirection($post_id)
280
+ {
281
+
282
+ global $wpdb, $util, $table_prefix;
283
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
284
+
285
+ // Autosave
286
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
287
+ return;
288
+ // AJAX
289
+ if (defined('DOING_AJAX') && DOING_AJAX)
290
+ return;
291
+ // Post revision
292
+ if (false !== wp_is_post_revision($post_id))
293
+ return;
294
+
295
+ $redirect_from = isset($_POST['wp_seo_redirection_url_from']) ? WPSR_sanitize_text_or_array_field($_POST['wp_seo_redirection_url_from']) : '';
296
+ $redirect_to = isset($_POST['wp_seo_redirection_url']) ? WPSR_sanitize_text_or_array_field($_POST['wp_seo_redirection_url']) : '';
297
+
298
+ if ($redirect_to != '') {
299
+
300
+
301
+ $wpdb->get_results($wpdb->prepare("select ID from $table_name where postID=%d ", $post_id));
302
+
303
+ if ($wpdb->num_rows > 0) {
304
+
305
+ $sql = $wpdb->prepare("update $table_name set redirect_to=%s,redirect_from=%s,redirect_type='301',url_type=2 where postID=%d", $redirect_to, $redirect_from, $post_id);
306
+ $wpdb->query($sql);
307
+
308
+ } else {
309
+ $wpdb->query($wpdb->prepare("delete from $table_name where redirect_from=%s", $redirect_from));
310
+ $sql = $wpdb->prepare("insert into $table_name(redirect_from,redirect_to,redirect_type,url_type,postID) values (%s,%s,'301',2,%d) ", $redirect_from, $redirect_to, $post_id);
311
+ $wpdb->query($sql);
312
+ }
313
+
314
+
315
+ } else {
316
+ $wpdb->query($wpdb->prepare("delete from $table_name where postID=%d", $post_id));
317
+ }
318
+
319
+ $SR_redirect_cache = new free_SR_redirect_cache();
320
+ $SR_redirect_cache->free_cache();
321
+ }
322
+
323
+ }
324
+ //-------------------------------------------------------------
325
+ if(!function_exists("WPSR_log_404_redirection")) {
326
+
327
+ function WPSR_log_404_redirection($link)
328
+ {
329
+ global $wpdb, $table_prefix, $util;
330
+ $table_name = $table_prefix . 'WP_SEO_404_links';
331
+
332
+ $referrer = $util->get_ref();
333
+ $ip = $util->get_visitor_IP();
334
+ $country = "";//$util->get_visitor_country();
335
+ $os = $util->get_visitor_OS();
336
+ $browser = $util->get_visitor_Browser();
337
+
338
+ if ($os != 'Unknown' || $browser != 'Unknown') {
339
+ $wpdb->query($wpdb->prepare(" insert IGNORE into $table_name(ctime,link,referrer,ip,country,os,browser) values(NOW(),%s,%s,%s,%s,%s,%s) ", $link, $referrer, $ip, $country, $os, $browser));
340
+ }
341
+ }
342
+
343
+ }
344
+ //-------------------------------------------------------------
345
+ if(!function_exists("WPSR_log_redirection_history")) {
346
+
347
+ function WPSR_log_redirection_history($rID, $postID, $rfrom, $rto, $rtype, $rsrc)
348
+ {
349
+ global $wpdb, $table_prefix, $util;
350
+ $SR_redirect_cache = new free_SR_redirect_cache();
351
+ $SR_redirect_cache->free_cache();
352
+ $table_name = $table_prefix . 'WP_SEO_Redirection_LOG';
353
+ $rfrom = esc_url($rfrom);
354
+ $referrer = $util->get_ref();
355
+ $ip = $util->get_visitor_IP();
356
+ $country = "";//$util->get_visitor_country();
357
+ $os = $util->get_visitor_OS();
358
+ $browser = $util->get_visitor_Browser();
359
+
360
+ $wpdb->query($wpdb->prepare(" insert into $table_name(rID,postID,rfrom,rto,rtype,rsrc,ctime,referrer,ip,country,os,browser) values(%d ,%d,%s,%s,%s,%s,NOW(),%s,%s,%s,%s,%s) ", $rID, $postID, $rfrom, $rto, $rtype, $rsrc, $referrer, $ip, $country, $os, $browser));
361
+
362
+ $limit = $util->get_option_value('history_limit');
363
+
364
+ $expdate = date('Y-n-j', time() - (intval($limit) * 24 * 60 * 60));
365
+ $wpdb->query("delete FROM $table_name WHERE date_format(date(ctime),'%Y-%m-%d') < date_format(date('$expdate'),'%Y-%m-%d')");
366
+
367
+
368
+ }
369
+ }
370
+ //-------------------------------------------------------------
371
+ if(!function_exists("WPSR_make_redirect")) {
372
+
373
+ function WPSR_make_redirect($redirect_to, $redirect_type, $redirect_from, $obj = '')
374
+ {
375
+
376
+ global $wpdb, $util, $table_prefix, $post;
377
+
378
+ if (is_admin()) {
379
+ return 0;
380
+ }
381
+ $SR_redirect_cache = new free_SR_redirect_cache();
382
+ if ($redirect_to == $redirect_from || !$util->is_valid_url($redirect_to))
383
+ return 0;
384
+
385
+ if ($util->make_relative_url($redirect_from) == $util->make_relative_url($redirect_to))
386
+ return 0;
387
+
388
+ if (substr($redirect_from, -1) == "/" || substr($redirect_to, -1) == "/") {
389
+ if (substr($redirect_from, -1) != "/") {
390
+ if (($redirect_from . "/") == $redirect_to)
391
+ return 0;
392
+ } else {
393
+ if (($redirect_to . "/") == $redirect_from)
394
+ return 0;
395
+ }
396
+ }
397
+
398
+
399
+ if ($util->make_relative_url($redirect_from) == $util->make_relative_url($redirect_to))
400
+ return 0;
401
+
402
+ if (is_object($obj)) {
403
+ if ($obj->ID > 0) {
404
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
405
+ $sql = "update " . $table_name . " set hits=hits+1, access_date= NOW() where ID='" . $obj->ID . "'";
406
+ $wpdb->query($sql);
407
+ }
408
+ }
409
+
410
+ if (is_object($obj) && $obj->redirect_to_type == 'Folder' && $obj->redirect_to_folder_settings == '2') {
411
+
412
+ if ($obj->redirect_from_type == 'Folder') {
413
+
414
+ if ($obj->redirect_from_folder_settings == '2' || $obj->redirect_from_folder_settings == '3') {
415
+ if (strlen($redirect_from) > strlen($obj->redirect_from)) {
416
+ $difference = substr($redirect_from, intval(strlen($obj->redirect_from) - strlen($redirect_from)));
417
+ $redirect_to = $redirect_to . $difference;
418
+ }
419
+ }
420
+
421
+ } else if ($obj->redirect_from_type == 'Regex') {
422
+ $page = substr(strrchr($redirect_from, "/"), 1);
423
+ $redirect_to = $redirect_to . '/' . $page;
424
+ }
425
+
426
+ }
427
+
428
+ $rID = 0;
429
+ $rsrc = '404';
430
+ $postID = 0;
431
+
432
+ if (is_object($obj)) {
433
+ $rID = $obj->ID;
434
+ $postID = $obj->postID;
435
+ if ($obj->url_type == 1)
436
+ $rsrc = 'Custom';
437
+ else if ($obj->url_type == 2)
438
+ $rsrc = 'Post';
439
+
440
+ }
441
+
442
+ if ($util->get_option_value('history_status') == '1') {
443
+
444
+ WPSR_log_redirection_history($rID, $postID, $redirect_from, $redirect_to, $redirect_type, $rsrc);
445
+ }
446
+
447
+ $redirect_to = $util->make_absolute_url($redirect_to);
448
+
449
+
450
+ if (is_singular()) {
451
+ //$SR_redirect_cache = new free_SR_redirect_cache();
452
+
453
+ $SR_redirect_cache->add_redirect($post->ID, 1, $redirect_from, $redirect_to, $redirect_type);
454
+ $SR_redirect_cache->free_cache();
455
+ }
456
+
457
+ if ($redirect_type == '301') {
458
+ header('HTTP/1.1 301 Moved Permanently');
459
+ header("Location: " . $redirect_to);
460
+ exit();
461
+ } else if ($redirect_type == '307') {
462
+ header('HTTP/1.0 307 Temporary Redirect');
463
+ header("Location: " . $redirect_to);
464
+ exit();
465
+ } else if ($redirect_type == '302') {
466
+ header("Location: " . $redirect_to);
467
+ exit();
468
+ }
469
+
470
+ }
471
+ }
472
+
473
+ //-------------------------------------------------------------
474
+ if(!function_exists("WPSR_redirect")) {
475
+
476
+ function WPSR_redirect()
477
+ {
478
+ global $wpdb, $post, $table_prefix, $util;
479
+
480
+
481
+ if ($util->get_option_value('plugin_status') != '0') { // if not disabled
482
+
483
+ // if disable for admin and the user is admin
484
+ if (current_user_can('manage_options') == 1 && $util->get_option_value('plugin_status') == 2) {
485
+ // nothing
486
+
487
+ } else {
488
+
489
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
490
+ $permalink = urldecode($util->get_current_relative_url());
491
+
492
+ if (substr($permalink, 0, 1) == ":") {
493
+ $first_slash = stripos($permalink, "/");
494
+ $permalink = substr($permalink, $first_slash, strlen($permalink) - $first_slash);
495
+ }
496
+ $permalink_alternative = "";
497
+ if (substr($permalink, -1) == '/') {
498
+ $permalink_alternative = substr($permalink, 0, intval(strlen($permalink) - 1));
499
+ } else {
500
+ $permalink_alternative = $permalink . '/';
501
+ }
502
+
503
+ $post_cache_result = "";
504
+ $SR_redirect_cache = new free_SR_redirect_cache();
505
+ if (is_singular()) {
506
+ $post_cache_result = $SR_redirect_cache->redirect_cached($post->ID);
507
+ }
508
+
509
+ if ($post_cache_result == 'not_redirected') {
510
+
511
+ return 0;
512
+ }
513
+
514
+ $permalink_options = $wpdb->prepare("( redirect_from = %s OR redirect_from = %s)", $permalink, $permalink_alternative);
515
+
516
+ $permalink_regex_options = $wpdb->prepare("(%s regexp regex or %s regexp regex )", $permalink, $permalink_alternative);
517
+
518
+
519
+ if (($util->get_option_value('redirect_control_panel') != '1') || ($util->get_option_value('redirect_control_panel') == '1' && !preg_match('/^' . str_replace('/', '\/', get_admin_url()) . '/i', $permalink) && !preg_match('/^' . str_replace('/', '\/', site_url()) . '\/wp-login.php/i', $permalink))) {
520
+
521
+ $theurl = $wpdb->get_row(" select * from $table_name where enabled=1 and regex='' and $permalink_options ");
522
+ if ($wpdb->num_rows > 0 && $theurl->redirect_to != '') {
523
+ WPSR_make_redirect($theurl->redirect_to, $theurl->redirect_type, $permalink, $theurl);
524
+ }
525
+
526
+ $theurl = $wpdb->get_row(" select * from $table_name where enabled=1 and regex<>'' and $permalink_regex_options order by LENGTH(regex) desc ");
527
+ if ($wpdb->num_rows > 0 && $theurl->redirect_to != '') {
528
+ WPSR_make_redirect($theurl->redirect_to, $theurl->redirect_type, $permalink, $theurl);
529
+ }
530
+
531
+
532
+ if (is_404()) {
533
+
534
+ if ($util->get_option_value('p404_discovery_status') == '1') {
535
+ WPSR_log_404_redirection($permalink);
536
+ }
537
+
538
+ $options = $util->get_my_options();
539
+ if ($options['p404_status'] == '1') {
540
+
541
+ WPSR_make_redirect($options['p404_redirect_to'], '301', $permalink);
542
+
543
+ }
544
+ }
545
+ }
546
+
547
+ if (is_singular() && $post_cache_result == 'not_found') {
548
+ $SR_redirect_cache->add_redirect($post->ID, 0, '', '', 0);
549
+ }
550
+
551
+ }
552
+ }
553
+ }
554
+ }
555
+ //---------------------------------------------------------------
556
+ if(!function_exists("WPSR_header_code")) {
557
+
558
+ function WPSR_header_code()
559
+ {
560
+
561
+ $my_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
562
+ if ($my_page == 'seo-redirection.php') {
563
+
564
+ wp_register_style('c_admin_css_common', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "style.css");
565
+ wp_enqueue_style('sweetalert', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "sweetalert.css");
566
+ wp_register_style('c_admin_css_custom', plugins_url() . '/' . basename(dirname(__FILE__)) . '/custom/' . "style.css");
567
+ wp_enqueue_script('jquery');
568
+ wp_localize_script('jquery', 'seoredirection', array('ajax_url' => admin_url('admin-ajax.php'), 'msg' => ""));
569
+ wp_enqueue_style('c_admin_css_common'); $rand = rand( 1, 99999999999 ); wp_register_style('c_css_common', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "custom.css", '', $rand); wp_enqueue_style('c_css_common');
570
+ wp_enqueue_style('c_admin_css_custom');
571
+
572
+ wp_enqueue_script('custom', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/js/' . 'bootstrap.min.js', array('jquery'), false, true);
573
+ wp_enqueue_script('customJS', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "customJs.js", array('jquery'), 1.1, true);
574
+ wp_enqueue_script('sweetalert', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/js/' . "sweetalert.min.js", array('jquery'), false, true);
575
+
576
+ wp_enqueue_style('bootstrap', plugins_url() . '/' . basename(dirname(__FILE__)) . '/common/' . "bootstrap.css");
577
+
578
+
579
+ }
580
+ }
581
+ }
582
+ //---------------------------------------------------------------
583
+ if(!function_exists("WPSR_customAddUpdate_callback")) {
584
+
585
+ add_action("wp_ajax_customAddUpdate", "WPSR_customAddUpdate_callback");
586
+
587
+ function WPSR_customAddUpdate_callback()
588
+ {
589
+ global $wpdb, $table_prefix, $util;
590
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
591
+ $table_name_404 = $table_prefix . 'WP_SEO_404_links';
592
+ parse_str($_POST['formData'], $_POST);
593
+ $nonce = "";
594
+ if (isset($_POST['_wpnonce']))
595
+ $nonce = WPSR_sanitize_text_or_array_field($_POST['_wpnonce']);
596
+ $data = array();
597
+ $data['error_string'] = array();
598
+ $data['inputerror'] = array();
599
+ $data['bool'] = TRUE;
600
+ if (trim($_POST['redirect_from']) == '') {
601
+ $data['inputerror'][] = 'redirect_from';
602
+ $data['error_string'][] = __("You must input the 'Redirect From' URL", "seo-redirection");
603
+ $data['bool'] = FALSE;
604
+ }
605
+
606
+ $redirect_from = isset($_POST['redirect_from']) ? WPSR_sanitize_text_or_array_field($_POST['redirect_from']) : '';
607
+
608
+ /* $wpdb->get_results(" select ID from $table_name where redirect_from='" . trim($redirect_from) . "' ");
609
+ if ($wpdb->num_rows > 0) {
610
+ $data['inputerror'][] = 'redirect_from';
611
+ $data['error_string'][] = __("This 'Redirect From' value already exists in database!", "seo-redirection");
612
+ $data['bool'] = FALSE;
613
+ }
614
+
615
+ */
616
+ // elseif (!preg_match( '/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/', $_POST['redirect_from'])) {
617
+ // $data['inputerror'][] = 'redirect_from';
618
+ // $data['error_string'][] = __("Invalid redirect from target URL!",'seo-redirection');
619
+ // $data['bool'] = FALSE;
620
+ // }
621
+ if (trim($_POST['redirect_to']) == '') {
622
+ $data['inputerror'][] = 'redirect_to';
623
+ $data['error_string'][] = __("You must input the 'Redirect To' URL", "seo-redirection");
624
+ $data['bool'] = FALSE;
625
+ } elseif ($_POST['edit_exist'] == '' && substr(strtolower($_POST['redirect_to']), 0, 4) != "http" && substr(strtolower($_POST['redirect_to']), 0, 1) != "/") {
626
+ $data['inputerror'][] = 'redirect_to';
627
+ $data['error_string'][] = __("Invalid redirect target URL!", 'seo-redirection');
628
+ $data['bool'] = FALSE;
629
+ }
630
+ if ($data['bool'] === FALSE) {
631
+ echo json_encode($data);
632
+ exit();
633
+ } else {
634
+ if ($_POST['redirect_from'] != '' && wp_verify_nonce($nonce, 'seoredirection')) {
635
+
636
+
637
+ $redirect_from = isset($_POST['redirect_from']) ? WPSR_sanitize_text_or_array_field($_POST['redirect_from']) : '';
638
+ $redirect_to = isset($_POST['redirect_to']) ? WPSR_sanitize_text_or_array_field($_POST['redirect_to']) : '';
639
+
640
+
641
+ $redirect_from = urldecode($util->make_relative_url($redirect_from));
642
+
643
+ $redirect_to = $util->make_relative_url($redirect_to);
644
+ $redirect_type = WPSR_sanitize_text_or_array_field($_POST['redirect_type']);
645
+
646
+ $redirect_from_type = WPSR_sanitize_text_or_array_field($_POST['redirect_from_type']);
647
+ $redirect_from_folder_settings = WPSR_sanitize_text_or_array_field($_POST['redirect_from_folder_settings']);
648
+ $redirect_from_subfolders = WPSR_sanitize_text_or_array_field($_POST['redirect_from_subfolders']);
649
+
650
+ $redirect_to_type = WPSR_sanitize_text_or_array_field($_POST['redirect_to_type']);
651
+ $redirect_to_folder_settings = WPSR_sanitize_text_or_array_field($_POST['redirect_to_folder_settings']);
652
+
653
+ $enabled = WPSR_sanitize_text_or_array_field($_POST['enabled']);
654
+
655
+ $regex = "";
656
+
657
+ if ($redirect_from_type == 'Folder') {
658
+
659
+ if (substr($redirect_from, -1) != '/')
660
+ $redirect_from = $redirect_from . '/';
661
+
662
+ if ($redirect_from_folder_settings == 2) {
663
+ if ($redirect_from_subfolders == 0) {
664
+ $regex = '^' . $util->regex_prepare($redirect_from) . '.*';;
665
+ } else {
666
+ $regex = '^' . $util->regex_prepare($redirect_from) . '[^/]*$';
667
+ }
668
+ } else if ($redirect_from_folder_settings == 3) {
669
+ if ($redirect_from_subfolders == 0) {
670
+ $regex = '^' . $util->regex_prepare($redirect_from) . '.+';
671
+ } else {
672
+ $regex = '^' . $util->regex_prepare($redirect_from) . '[^/]+$';
673
+ }
674
+ }
675
+
676
+ } else if ($redirect_from_type == 'Regex') {
677
+ $regex = $redirect_from;
678
+ }
679
+
680
+ if ($redirect_from_type == 'Page' || $redirect_from_type == 'Regex') {
681
+ $redirect_from_folder_settings = "";
682
+ $redirect_from_subfolders = "";
683
+ }
684
+
685
+ if ($redirect_to_type == 'Page') {
686
+ $redirect_to_folder_settings = "";
687
+ }
688
+
689
+ if ($redirect_to_type == 'Folder') {
690
+ if (substr($redirect_to, -1) != '/')
691
+ $redirect_to = $redirect_to . '/';
692
+ }
693
+
694
+
695
+ if ($_POST['add_new'] != '') {
696
+
697
+ $theurl = $wpdb->get_row($wpdb->prepare(" select count(ID) as cnt from $table_name where redirect_from=%s ", $redirect_from));
698
+
699
+ if ($theurl->cnt > 0) {
700
+ $msg = __("This URL", 'seo-redirection') . " <b>".esc_html($redirect_from)."</b>" . __("is added previously!", 'seo-redirection');
701
+ echo json_encode(array('status' => 'error', 'msg' => $msg));
702
+ // $util->failure_option_msg(__("This URL",'seo-redirection')." <b>'$redirect_from'</b>". __("is added previously!",'seo-redirection'));
703
+ } else {
704
+
705
+
706
+ if ($redirect_from == '' || $redirect_to == '' || $redirect_type == '') {
707
+ $util->failure_option_msg(__('Please input all required fields!', 'seo-redirection'));
708
+ } else {
709
+
710
+ $wpdb->insert($table_name, array(
711
+ 'redirect_from' => $redirect_from,
712
+ 'redirect_to' => $redirect_to,
713
+ 'redirect_type' => $redirect_type,
714
+ 'url_type' => 1,
715
+ 'redirect_from_type' => $redirect_from_type,
716
+ 'redirect_from_folder_settings' => $redirect_from_folder_settings,
717
+ 'redirect_from_subfolders' => $redirect_from_subfolders,
718
+ 'redirect_to_type' => $redirect_to_type,
719
+ 'redirect_to_folder_settings' => $redirect_to_folder_settings,
720
+ 'regex' => $regex,
721
+ 'enabled' => $enabled
722
+
723
+ ));
724
+
725
+ $wpdb->query($wpdb->prepare(" delete from $table_name_404 where link=%s ", $redirect_from));
726
+ $SR_redirect_cache = new free_SR_redirect_cache();
727
+ $SR_redirect_cache->free_cache();
728
+ $msg = "Redirection Added Successfully";
729
+ echo json_encode(array('status' => 'success', 'msg' => $msg, 'url' => admin_url('options-general.php?page=seo-redirection.php')));
730
+ die;
731
+ }
732
+
733
+ }
734
+ } else if ($_POST['edit_exist'] != '') {
735
+
736
+ $edit = WPSR_sanitize_text_or_array_field($_POST['edit']);
737
+
738
+ if ($redirect_from == '' || $redirect_to == '' || $redirect_type == '') {
739
+ $util->failure_option_msg('Please input all required fields!');
740
+ } else {
741
+
742
+ $wpdb->query($wpdb->prepare("update $table_name set redirect_from=%s,redirect_to=%s,redirect_type=%s,redirect_from_type=%s ,redirect_from_folder_settings=%d,redirect_from_subfolders=%d ,redirect_to_type=%s ,redirect_to_folder_settings=%d ,regex=%s,enabled=%s where ID=%d ", $redirect_from, $redirect_to, $redirect_type, $redirect_from_type, $redirect_from_folder_settings, $redirect_from_subfolders, $redirect_to_type, $redirect_to_folder_settings, $regex, $enabled, $edit));
743
+
744
+ $SR_redirect_cache = new free_SR_redirect_cache();
745
+ $SR_redirect_cache->free_cache();
746
+ }
747
+ $msg = "Redirection Update Successfully";
748
+ echo json_encode(array('status' => 'success', 'msg' => $msg, 'url' => admin_url('options-general.php?page=seo-redirection.php')));
749
+ die;
750
+
751
+ }
752
+
753
+ if ($util->there_is_cache() != '')
754
+ $util->info_option_msg(__("You have a cache plugin installed", 'seo-redirection') . " <b>'" . $util->there_is_cache() . "'</b>, " . __("you have to clear cache after any changes to get the changes reflected immediately! ", 'seo-redirection'));
755
+
756
+ }
757
+
758
+ }
759
+
760
+
761
+ die;
762
+ }
763
+ }
764
+ if(!function_exists("WPSR_customUpdateRec_callback")) {
765
+
766
+ add_action("wp_ajax_customUpdateRec", "WPSR_customUpdateRec_callback");
767
+ function WPSR_customUpdateRec_callback()
768
+ {
769
+
770
+
771
+ global $wpdb, $table_prefix, $util;
772
+
773
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
774
+ $table_name_404 = $table_prefix . 'WP_SEO_404_links';
775
+
776
+ $myid = (int)$_POST['ID'];
777
+ $item = $wpdb->get_row($wpdb->prepare(" select * from $table_name where ID=%d ", $myid));
778
+
779
+ if ($wpdb->num_rows == 0) {
780
+ echo json_encode(array('status' => 'error', 'msg' => __("Sorry, this redirect rule is not found, it may deleted by the user!", 'seo-redirection')));
781
+ die;
782
+ }
783
+
784
+
785
+ $data = array(
786
+ "redirect_from" => $item->redirect_from,
787
+ "redirect_to" => $item->redirect_to,
788
+ "redirect_type" => $item->redirect_type,
789
+
790
+ "redirect_from_type" => $item->redirect_from_type,
791
+ "redirect_from_folder_settings" => $item->redirect_from_folder_settings,
792
+ "redirect_from_subfolders" => $item->redirect_from_subfolders,
793
+
794
+ "redirect_to_type" => $item->redirect_to_type,
795
+ "redirect_to_folder_settings" => $item->redirect_to_folder_settings,
796
+
797
+ "enabled" => $item->enabled
798
+ );
799
+ echo json_encode(array('status' => 'suucess', 'rec' => $data));
800
+ die;
801
+ }
802
+ }
803
+
804
+ if(!function_exists("WPSR_admin_menu")) {
805
+
806
+ function WPSR_admin_menu()
807
+ {
808
+ add_options_page('SEO Redirection', 'SEO Redirection', 'manage_options', basename(__FILE__), 'WPSR_options_menu');
809
+ }
810
+ }
811
+ //---------------------------------------------------------------
812
+ if(!function_exists("WPSR_options_menu")) {
813
+
814
+ function WPSR_options_menu()
815
+ {
816
+ global $util;
817
+
818
+ if (!current_user_can('manage_options')) {
819
+ wp_die(__('You do not have sufficient permissions to access this page.', 'seo-redirection'));
820
+ }
821
+
822
+
823
+ if ($util->get_option_value('plugin_status') == '0') {
824
+ $util->info_option_msg(__('SEO Redirection is disabled now, you can go to option tab and enable it!', 'seo-redirection'));
825
+ } else if ($util->get_option_value('plugin_status') == '2') {
826
+ $util->info_option_msg(__('SEO Redirection is', 'seo-redirection') . ' <b>' . __('disabled for admin', 'seo-redirection') . '</b>' . __(' only, you can go to option tab and enable it!', 'seo-redirection'));
827
+ }
828
+ $total_404_errors = (WPSR_Get_total_404() > 5) ? __('You have', 'seo-redirection') . ' <b style="color:red; background-color:yellow; padding:3px;">' . intval(WPSR_Get_total_404()) .'</b>' . __(' broken link (404 links)', 'seo-redirection') . ', <br>'.'<div class="wrap" style="font-weight:normal; line-height:30px">' . __('Upgrade to', 'wsr') . ' <a target="_blank" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin">' . __("pro version", "wsr") . '</a>' . __(" to manage 404 errors and empower your site SEO", "wsr").'</div>' : '';
829
+
830
+
831
+ echo '<div class="wrap"><h2>' . __("SEO Redirection Free", 'seo-redirection') . '</h2><b>' . __('Upgrade to', 'seo-redirection') . ' <a target="_blank" onclick="swal.clickConfirm();" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/">' . __("Pro Version", "seo-redirection") . '</a>' . __(" to manage 404 errors and empower your site SEO", "seo-redirection") . '&nbsp;&nbsp;&nbsp;<strong style="color:yellow; background-color:red; padding:3px;"> ' . __("NOW 50% OFF ", 'seo-redirection') . '</strong></b><br/><br/>';
832
+
833
+ if ($total_404_errors != '') {
834
+ ?>
835
+ <script type="text/javascript">
836
+
837
+ seoredirection.msg = '<?php echo wp_kses_post($total_404_errors); ?>';
838
+
839
+ </script>
840
+
841
+ <?php
842
+ }
843
+
844
+ if (is_multisite()) {
845
+
846
+ echo '<div class="error" id="message"><p></p><div class="warning_icon"></div>' . __('This version does not support Multisite WordPress installation, you may face troubles like losing redirects when adding new sites to your network, the premium version supports multisite well', 'seo-redirection') . '(<a target="_blank" href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/">
847
+ https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/</a>) <p></p></div>';
848
+
849
+ }
850
+
851
+ $mytabs = new phptab();
852
+
853
+ $mytabs->set_ignore_parameter(array( 'search', 'page_num', 'add', 'edit', 'page404', 'do_404_del'));
854
+ $mytabs->add_file_tab('cutom', __('Custom Redirects', 'seo-redirection'), 'option_page_custome_redirection.php', 'file');
855
+ $mytabs->add_file_tab('posts', __('Post Redirects', 'seo-redirection'), 'option_page_post_redirection_list.php', 'file');
856
+ $mytabs->add_file_tab('history', __('History', 'seo-redirection'), 'option_page_history.php', 'file');
857
+ $mytabs->add_file_tab('404', '<span style="color:red;"><b>404 Errors</b></span>', 'option_page_404.php', 'file');
858
+ $mytabs->add_file_tab('goptions', __('Options', 'seo-redirection'), 'option_page_goptions.php', 'file');
859
+ $mytabs->add_file_tab('help', '<span style="color:green;"><b>' . __('Help', 'seo-redirection') . '</b></span>', 'help.php', 'file');
860
+ $mytabs->add_file_tab('premium', '<span style="color:brown;"><b>&#9658; ' . __('Premium Features', 'seo-redirection') . '</b></span>', 'premium.php', 'file');
861
+ $mytabs->run();
862
+
863
+ $imgpath = $util->get_plugin_url() . 'custom/images/';
864
+
865
+ echo '<p>&nbsp;</p><p style="color:green"><a target="_blank" href="http://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin"><b>' . __("Upgrade to premium version now", "wsr") . '</b></a>' . __(" to get more features", "wsr") . ' , <small>' . __("The premium version of SEO redirection is completely different from the free version as there are a lot more features included.", "wsr") . '</small></p>';
866
+ echo __('<p><a href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin" target="_blank"><img src="' . $imgpath . 'seopro.png" /></a></p>');
867
+ }
868
+ }
869
+ if(!function_exists("WPSR_upgrade")) {
870
+
871
+ function WPSR_upgrade()
872
+ {
873
+
874
+ $util = new clogica_util_1();
875
+ $util->init(WP_SEO_REDIRECTION_OPTIONS, __FILE__);
876
+
877
+ if ($util->get_option_value('plugin_version') != WP_SEO_REDIRECTION_VERSION) {
878
+ WPSR_install();
879
+ $util->update_option('plugin_version', WP_SEO_REDIRECTION_VERSION);
880
+ }
881
+ }
882
+ }
883
+ //-----------------------------------------------------
884
+ if(!function_exists("WPSR_install")) {
885
+
886
+ function WPSR_install()
887
+ {
888
+ global $wpdb, $table_prefix;
889
+
890
+ $util = new clogica_util_1();
891
+ $util->init(WP_SEO_REDIRECTION_OPTIONS, __FILE__);
892
+
893
+ $options = get_option(WP_SEO_REDIRECTION_OPTIONS);
894
+ if (!is_array($options)) {
895
+ add_option(WP_SEO_REDIRECTION_OPTIONS);
896
+ $options = array();
897
+ }
898
+
899
+
900
+ if (!array_key_exists('plugin_status', $options))
901
+ $options['plugin_status'] = '1';
902
+
903
+ if (!array_key_exists('ip_logging_status', $options))
904
+ $options['ip_logging_status'] = '1';
905
+
906
+ if (!array_key_exists('redirection_base', $options))
907
+ $options['redirection_base'] = site_url();
908
+
909
+ if (!array_key_exists('redirect_control_panel', $options))
910
+ $options['redirect_control_panel'] = '1';
911
+
912
+ if (!array_key_exists('show_redirect_box', $options))
913
+ $options['show_redirect_box'] = '1';
914
+
915
+ if (!array_key_exists('reflect_modifications', $options))
916
+ $options['reflect_modifications'] = '1';
917
+
918
+ if (!array_key_exists('history_status', $options))
919
+ $options['history_status'] = '1';
920
+
921
+ if (!array_key_exists('history_limit', $options))
922
+ $options['history_limit'] = '30';
923
+
924
+ if (!array_key_exists('p404_discovery_status', $options))
925
+ $options['p404_discovery_status'] = '1';
926
+
927
+ if (!array_key_exists('p404_redirect_to', $options))
928
+ $options['p404_redirect_to'] = site_url();
929
+
930
+ if (!array_key_exists('p404_status', $options))
931
+ $options['p404_status'] = '2';
932
+
933
+ if (!array_key_exists('keep_data', $options))
934
+ $options['keep_data'] = '1';
935
+
936
+ update_option(WP_SEO_REDIRECTION_OPTIONS, $options);
937
+
938
+
939
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
940
+ if (strtolower($wpdb->get_var("show tables like '$table_name'")) != strtolower($table_name)) {
941
+ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
942
+ `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
943
+ `enabled` int(1) NOT NULL DEFAULT '1',
944
+ `redirect_from` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
945
+ `redirect_from_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
946
+ `redirect_from_folder_settings` int(1) NOT NULL,
947
+ `redirect_from_subfolders` int(1) NOT NULL DEFAULT '1',
948
+ `redirect_to` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
949
+ `redirect_to_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
950
+ `redirect_to_folder_settings` int(1) NOT NULL DEFAULT '1',
951
+ `regex` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
952
+ `redirect_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
953
+ `url_type` int(2) NOT NULL DEFAULT 1,
954
+ `postID` int(11) unsigned DEFAULT NULL,
955
+ `import_flag` tinyint(1) NOT NULL DEFAULT 0,
956
+ `hits` int(11) unsigned NOT NULL DEFAULT 0,
957
+ `access_date` datetime DEFAULT NULL,
958
+ PRIMARY KEY (`ID`),
959
+ UNIQUE KEY `redirect_from` (`redirect_from`)
960
+ )ENGINE = MyISAM ;";
961
+ $wpdb->query($sql);
962
+
963
+
964
+ } else {
965
+ //check if Innodb convert it to myisam.
966
+ $status = $wpdb->get_row("SHOW TABLE STATUS WHERE Name = '$table_name'");
967
+ if ($status->Engine == 'InnoDB') {
968
+ $wpdb->query("alter table $table_name engine = MyISAM;");
969
+ }
970
+
971
+ /* add column for import flag */
972
+ $column_data = $wpdb->get_row("SHOW COLUMNS FROM $table_name LIKE 'import_flag'");
973
+
974
+ if (!$column_data) {
975
+ $wpdb->query("ALTER TABLE $table_name ADD COLUMN import_flag tinyint(1) DEFAULT 0");
976
+ }
977
+
978
+ // if the table exists
979
+ $redirects = $wpdb->get_results(" select redirect_from,redirect_to,ID from $table_name; ");
980
+ foreach ($redirects as $redirect) {
981
+ $redirect_from = $util->make_relative_url($redirect->redirect_from);
982
+ $redirect_to = $util->make_relative_url($redirect->redirect_to);
983
+ $ID = $redirect->ID;
984
+ $wpdb->query($wpdb->prepare(" update $table_name set redirect_from=%s,redirect_to=%s where ID=%d", $redirect_from, $redirect_to, $ID));
985
+ }
986
+
987
+ // Fix add blog field if not exist.
988
+ if ($wpdb->get_var(" SELECT count(*) as cnt FROM INFORMATION_SCHEMA.COLUMNS
989
+ WHERE TABLE_NAME = '$table_name'
990
+ AND table_schema = DATABASE()
991
+ AND COLUMN_NAME = 'hits' ") == '0') {
992
+
993
+ $sql = "
994
+ ALTER TABLE $table_name
995
+ ADD COLUMN `hits` int(11) unsigned NOT NULL DEFAULT 0,
996
+ ADD COLUMN `access_date` datetime DEFAULT NULL;
997
+ ";
998
+
999
+ $wpdb->query($sql);
1000
+ }
1001
+
1002
+
1003
+ }
1004
+
1005
+ $table_name = $table_prefix . 'WP_SEO_Cache';
1006
+ if (strtolower($wpdb->get_var("show tables like '$table_name'")) != strtolower($table_name)) {
1007
+ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
1008
+ `ID` int(11) unsigned NOT NULL,
1009
+ `is_redirected` int(1) unsigned NOT NULL,
1010
+ `redirect_from` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1011
+ `redirect_to` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1012
+ `redirect_type` int(3) unsigned NOT NULL DEFAULT 301,
1013
+ PRIMARY KEY (`ID`)
1014
+ ) ENGINE = MyISAM ;
1015
+ ";
1016
+ $wpdb->query($sql);
1017
+ } else {
1018
+ //check if Innodb convert it to myisam.
1019
+ $status = $wpdb->get_row("SHOW TABLE STATUS WHERE Name = '$table_name'");
1020
+ if ($status->Engine == 'InnoDB') {
1021
+ $wpdb->query("alter table $table_name engine = MyISAM;");
1022
+ }
1023
+ }
1024
+
1025
+
1026
+ $res = $wpdb->get_var(" SELECT count(*) as cnt FROM INFORMATION_SCHEMA.COLUMNS
1027
+ WHERE TABLE_NAME = '$table_name'
1028
+ AND table_schema = DATABASE()
1029
+ AND COLUMN_NAME = 'redirect_from' ");
1030
+
1031
+ if ($res == '0') {
1032
+
1033
+ $sql = "
1034
+ ALTER TABLE $table_name
1035
+ ADD COLUMN `redirect_from` varchar(255) COLLATE utf8_unicode_ci NOT NULL;
1036
+ ";
1037
+ $wpdb->query($sql);
1038
+ }
1039
+
1040
+
1041
+ $table_name = $table_prefix . 'WP_SEO_404_links';
1042
+ if (strtolower($wpdb->get_var("show tables like '$table_name'")) != strtolower($table_name)) {
1043
+ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
1044
+ `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
1045
+ `ctime` datetime NOT NULL,
1046
+ `link` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1047
+ `referrer` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1048
+ `ip` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1049
+ `country` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
1050
+ `os` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1051
+ `browser` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1052
+ PRIMARY KEY (`ID`),
1053
+ UNIQUE KEY `link` (`link`)
1054
+ ) ENGINE = MyISAM ;
1055
+ ";
1056
+ $wpdb->query($sql);
1057
+ } else {
1058
+ //check if Innodb convert it to myisam.
1059
+ $status = $wpdb->get_row("SHOW TABLE STATUS WHERE Name = '$table_name'");
1060
+ if ($status->Engine == 'InnoDB') {
1061
+ $wpdb->query("alter table $table_name engine = MyISAM;");
1062
+ }
1063
+ }
1064
+
1065
+
1066
+ $table_name = $table_prefix . 'WP_SEO_Redirection_LOG';
1067
+ if (strtolower($wpdb->get_var("show tables like '$table_name'")) != strtolower($table_name)) {
1068
+ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
1069
+ `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
1070
+ `rID` int(11) unsigned DEFAULT NULL,
1071
+ `postID` int(11) unsigned DEFAULT NULL,
1072
+ `ctime` datetime NOT NULL,
1073
+ `rfrom` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1074
+ `rto` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1075
+ `rtype` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1076
+ `rsrc` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1077
+ `referrer` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
1078
+ `ip` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1079
+ `country` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
1080
+ `os` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1081
+ `browser` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
1082
+ PRIMARY KEY (`ID`)
1083
+ ) ENGINE = MyISAM ;
1084
+ ";
1085
+
1086
+ $wpdb->query($sql);
1087
+ } else {
1088
+ //check if Innodb convert it to myisam.
1089
+ $status = $wpdb->get_row("SHOW TABLE STATUS WHERE Name = '$table_name'");
1090
+ if ($status->Engine == 'InnoDB') {
1091
+ $wpdb->query("alter table $table_name engine = MyISAM;");
1092
+ }
1093
+
1094
+ $res = $wpdb->get_var(" SELECT count(*) as cnt FROM INFORMATION_SCHEMA.COLUMNS
1095
+ WHERE TABLE_NAME = '$table_name'
1096
+ AND table_schema = DATABASE()
1097
+ AND COLUMN_NAME = 'postID' ");
1098
+
1099
+ if ($res == '0') {
1100
+
1101
+ $sql = "
1102
+ ALTER TABLE $table_name
1103
+ ADD COLUMN `postID` int(11) unsigned DEFAULT NULL;
1104
+ ";
1105
+ $wpdb->query($sql);
1106
+ }
1107
+
1108
+
1109
+ }
1110
+
1111
+ }
1112
+
1113
+ }
1114
+ //---------------------------------------------------------------
1115
+
1116
+ if(!function_exists("WPSR_uninstall")) {
1117
+
1118
+ function WPSR_uninstall()
1119
+ {
1120
+ global $wpdb, $table_prefix;
1121
+
1122
+ $util = new clogica_util_1();
1123
+ $util->init(WP_SEO_REDIRECTION_OPTIONS, __FILE__);
1124
+
1125
+
1126
+ if ($util->get_option_value('keep_data') != '1') {
1127
+
1128
+ $table_name = $table_prefix . 'WP_SEO_Redirection';
1129
+ $wpdb->query($wpdb->prepare(" DROP TABLE %s ", $table_name));
1130
+
1131
+ $table_name = $table_prefix . 'WP_SEO_Cache';
1132
+ $wpdb->query($wpdb->prepare(" DROP TABLE %s ", $table_name));
1133
+
1134
+ $table_name = $table_prefix . 'WP_SEO_404_links';
1135
+ $wpdb->query($wpdb->prepare(" DROP TABLE %s ", $table_name));
1136
+
1137
+ $table_name = $table_prefix . 'WP_SEO_Redirection_LOG';
1138
+ $wpdb->query($wpdb->prepare(" DROP TABLE %s ", $table_name));
1139
+
1140
+
1141
+ $util->delete_my_options();
1142
+ }
1143
+
1144
+
1145
+ }
1146
+
1147
+ }
1148
+ //---------------------------------------------------------------
1149
+ if(!function_exists("WPSR_HideMessageAjaxFunction")) {
1150
+
1151
+ function WPSR_HideMessageAjaxFunction()
1152
+ {
1153
+ add_option('nsr_upgrade_message', 'yes');
1154
+ }
1155
+ }
1156
+ //---------------------------------------------------------------
1157
+ if(!function_exists("WPSR_admin_notice_callback")) {
1158
+
1159
+ /* display import from redirection plugin in admin notice */
1160
+ function WPSR_admin_notice_callback() {
1161
+ global $wpdb;
1162
+ global $current_user;
1163
+ $plugins = get_option( 'active_plugins', array() );
1164
+ $found = false;
1165
+ $user_id = $current_user->ID;
1166
+ $val = get_user_meta($user_id, 'sr_notice_dismissed',true);
1167
+
1168
+ foreach ( $plugins as $plugin )
1169
+ {
1170
+ if ( strpos( strval($plugin), 'redirection.php' ) == true && $val != 1 && strpos( strval($plugin), 'seo-redirection.php' ) == FALSE )
1171
+ {
1172
+ $found = true;
1173
+ //$total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_items");
1174
+ $total = WPSR_getRedirectCount();
1175
+ if($total > 0){
1176
+ ?>
1177
+ <div class="notice-success notice is-dismissible sr_notice">
1178
+ <p>
1179
+ <strong><?php _e('SEO Redirection : ', 'seo-redirection'); ?></strong><?php echo __( 'The plugin detected ','seo-redirection').intval($total).__(' redirects in the Redirection plugin, Import it now. ','seo-redirection'); ?>
1180
+ <?php
1181
+ $SR_import = isset($_GET['SR_import']) ? sanitize_text_field($_GET['SR_import']) : '';
1182
+ if($SR_import == 'yes'){?>
1183
+ <button type='button' data-toggle="modal" class="button" href="#" data-target="#import_modal" value="btn_import"><span style="margin-top: 3px;" class="dashicons dashicons-migrate"></span>&nbsp; <?php _e('Import Now','seo-redirection'); ?></button>
1184
+ <?php }else{ ?>
1185
+ <a href="options-general.php?page=seo-redirection.php&tab=export_import&SR_import=yes" data-target="#import_modal" value="btn_import"><?php _e('Import','seo-redirection'); ?></a>
1186
+ <?php }?>
1187
+ </p>
1188
+ </div>
1189
+ <?php
1190
+ }
1191
+ break;
1192
+ }
1193
+ }
1194
+ }
1195
+ add_action( 'admin_notices', 'WPSR_admin_notice_callback' );
1196
+ }
1197
+
1198
+ if(!function_exists("WPSR_dismiss_notice_callback")) {
1199
+
1200
+ add_action('wp_ajax_sr_dismiss_notice', 'WPSR_dismiss_notice_callback');
1201
+ function WPSR_dismiss_notice_callback()
1202
+ {
1203
+ global $current_user;
1204
+ $user_id = $current_user->ID;
1205
+ update_user_meta($user_id, 'sr_notice_dismissed', '1');
1206
+ echo "1";
1207
+ exit;
1208
+ }
1209
+ }
1210
+ if(!function_exists("WPSR_getRedirectCount")) {
1211
+
1212
+ function WPSR_getRedirectCount()
1213
+ {
1214
+ global $wpdb;
1215
+
1216
+ $table_name_ = $wpdb->prefix . 'redirection_items';
1217
+ if (strtolower($wpdb->get_var("show tables like '$table_name_'")) == strtolower($table_name_)) {
1218
+ $result = $wpdb->get_results("SELECT url FROM {$wpdb->prefix}redirection_items");
1219
+ $cnt = 0;
1220
+ $table_name = $wpdb->prefix . 'WP_SEO_Redirection';
1221
+ if ($result) {
1222
+ foreach ($result as $redirect) {
1223
+ $redirect_from = stripslashes($redirect->url);
1224
+ $redirect_from_slash = ltrim(stripslashes($redirect->url), '/');
1225
+ $redirectID = $wpdb->get_var($wpdb->prepare("select ID from $table_name where redirect_from=%s or redirect_from=%s", $redirect_from, $redirect_from_slash));
1226
+ if ($redirectID > 0) {
1227
+
1228
+ } else {
1229
+ $cnt++;
1230
+ }
1231
+ }
1232
+
1233
+ }
1234
+ return $cnt;
1235
+ } else {
1236
+ return 0;
1237
+ }
1238
+ }
1239
+ }
1240
+ if(!function_exists("SR_init_delete_callback")) {
1241
+
1242
+ add_action('admin_init', 'SR_init_delete_callback');
1243
+ function SR_init_delete_callback()
1244
+ {
1245
+ if (isset($_POST['redirect_id']) && count($_POST['redirect_id']) > 0) {
1246
+
1247
+ $nonce = '';
1248
+ if(isset($_REQUEST['_wpnonce']))
1249
+ $nonce = WPSR_sanitize_text_or_array_field($_REQUEST['_wpnonce']);
1250
+
1251
+ if(wp_verify_nonce( $nonce, 'seoredirection' )){
1252
+
1253
+ global $wpdb, $table_prefix, $util;
1254
+ $table_name = $wpdb->prefix . 'WP_SEO_Redirection';
1255
+ foreach ($_POST['redirect_id'] as $post_id) {
1256
+ $post_id = (int)$post_id;
1257
+ $wpdb->query($wpdb->prepare(" delete from $table_name where ID=%s ", $post_id));
1258
+ $SR_redirect_cache = new free_SR_redirect_cache();
1259
+ $SR_redirect_cache->free_cache();
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+ }
1265
+
1266
+
1267
+
1268
+
1269
+ //---------------------------------------------------------------
1270
+
1271
+ function WPSR_HideMessageAjaxFunction()
1272
+ {
1273
+ add_option('nsr_upgrade_message', 'yes');
1274
+ }
1275
+
1276
+
1277
+ function WPSR_after_plugin_row($plugin_file, $plugin_data, $status)
1278
+ {
1279
+
1280
+ if (get_option('nsr_upgrade_message') != 'yes') {
1281
+ $class_name = $plugin_data['slug'];
1282
+
1283
+ echo '<tr id="' . $class_name . '-plugin-update-tr" class="plugin-update-tr active">';
1284
+ echo '<td colspan="6" class="plugin-update">';
1285
+ echo '<div id="' . $class_name . '-upgradeMsg" class="update-message notice inline notice-warning notice-alt" >';
1286
+
1287
+ echo 'You are running SEO redirection free. To get more features, you can <a href="http://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin" target="_blank"><strong>upgrade now</strong></a> or ';
1288
+
1289
+ echo '<span id="HideMe" style="cursor:pointer" ><a href="javascript:void(0)"><strong>dismiss</strong></a> this message</span>';
1290
+ echo '</div>';
1291
+ echo '</td>';
1292
+ echo '</tr>';
1293
+
1294
+ ?>
1295
+
1296
+ <script type="text/javascript">
1297
+ jQuery(document).ready(function () {
1298
+ var row = jQuery('#<?php echo $class_name;?>-plugin-update-tr').closest('tr').prev();
1299
+ jQuery(row).addClass('update');
1300
+
1301
+ jQuery("#HideMe").click(function () {
1302
+ jQuery.ajax({
1303
+ type: 'POST',
1304
+ url: '<?php echo admin_url();?>/admin-ajax.php',
1305
+ data: {
1306
+ action: 'WPSR_HideMessageAjaxFunction'
1307
+ },
1308
+ success: function (data, textStatus, XMLHttpRequest) {
1309
+
1310
+ jQuery("#<?php echo $class_name;?>-upgradeMsg").hide();
1311
+
1312
+ },
1313
+ error: function (MLHttpRequest, textStatus, errorThrown) {
1314
+ alert(errorThrown);
1315
+ }
1316
+ });
1317
+ });
1318
+
1319
+ });
1320
+ </script>
1321
+
1322
+ <?php
1323
+ }
1324
+ }
1325
+
1326
+ $path = plugin_basename(__FILE__);
1327
+ add_action("after_plugin_row_{$path}", 'WPSR_after_plugin_row', 10, 3);
1328
+ // creating Ajax call for WordPress
1329
+ add_action('wp_ajax_nopriv_WPSR_HideMessageAjaxFunction', 'WPSR_HideMessageAjaxFunction');
1330
+ add_action('wp_ajax_WPSR_HideMessageAjaxFunction', 'WPSR_HideMessageAjaxFunction');
1331
+ //---------------------------------------------------------------
1332
+
1333
+ ?>