WP Meta SEO - Version 2.0.0

Version Description

  • Add: 404 and redirect manager
  • Add: Options to redirect all 404 to home page
  • Add: Setup 404 page as: WP Meta SEO page, custom page, defulat page
Download this release

Release Info

Developer JoomUnited
Plugin Icon 128x128 WP Meta SEO
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.7.3 to 2.0.0

css/googlefonticon.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face {
2
+ font-family: 'Material Icons';
3
+ font-style: normal;
4
+ font-weight: 400;
5
+ src: local('Material Icons'), local('MaterialIcons-Regular'), url(https://fonts.gstatic.com/s/materialicons/v12/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2');
6
+ }
7
+
8
+ .material-icons {
9
+ font-family: 'Material Icons';
10
+ font-weight: normal;
11
+ font-style: normal;
12
+ font-size: 24px;
13
+ line-height: 1;
14
+ letter-spacing: normal;
15
+ text-transform: none;
16
+ display: inline-block;
17
+ white-space: nowrap;
18
+ word-wrap: normal;
19
+ direction: ltr;
20
+ -webkit-font-feature-settings: 'liga';
21
+ -webkit-font-smoothing: antialiased;
22
+ }
css/metabox-tabs.css CHANGED
@@ -325,9 +325,9 @@ table.wpmseoanalysis td.score {
325
  font-weight: 600;
326
  }
327
 
328
- img.metaseo_help {
329
  cursor: pointer;
330
- width: 20px;
331
  }
332
 
333
  .metaseo-qtip {
@@ -363,29 +363,7 @@ div.wpmseo-tab-content {
363
 
364
  .metaseo-dashicons{
365
  float: left;
366
- width: 30px;
367
- }
368
-
369
- .metaseo-dashicons:before{
370
- width: 30px;
371
- }
372
-
373
- .metaseo-dashicons.dashicons-yes {
374
- color: #1d9757;
375
-
376
- }
377
-
378
- .metaseo-dashicons.dashicons-yes:before{
379
- font-size: 25px;
380
- }
381
-
382
- .metaseo-dashicons.icons-mwarning {
383
- /* color: #f00;*/
384
- width: 20px;
385
- height: 20px;
386
- margin: 0px 5px;
387
- background-image: url(../img/warnig-red.png);
388
- background-size: 100% 100%;
389
  }
390
 
391
  .metaseo_analysis{
325
  font-weight: 600;
326
  }
327
 
328
+ i.metaseo_help {
329
  cursor: pointer;
330
+ font-size: 20px;
331
  }
332
 
333
  .metaseo-qtip {
363
 
364
  .metaseo-dashicons{
365
  float: left;
366
+ line-height:18px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  }
368
 
369
  .metaseo_analysis{
css/metaseo_admin.css CHANGED
@@ -386,4 +386,186 @@ strong {
386
  display:none;
387
  line-height:28px;
388
  color: #F00;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  }
386
  display:none;
387
  line-height:28px;
388
  color: #F00;
389
+ }
390
+
391
+ .wpms-inline-editor-content{
392
+ display: none;
393
+ float: left;
394
+ }
395
+
396
+ #col_link_url{
397
+ width:30%;
398
+ }
399
+ .wpms-inline-editor-content span.title {
400
+ display: block;
401
+ float: left;
402
+ width: 5em;
403
+ }
404
+
405
+ .wpms-inline-editor-buttons{
406
+ padding: 0 !important;
407
+ }
408
+
409
+ .wpms-input-text-wrap .title{
410
+ line-height: 26px;
411
+ }
412
+
413
+ .wpms-link-url-field,.wpms-link-text-field,.wpms-link-redirect-field{
414
+ width:85%;
415
+ float: right;
416
+ }
417
+
418
+ .wpms-cancel-button{
419
+ float: left;
420
+ margin-top: 10px !important;
421
+ }
422
+
423
+ .wpms-update-link-button{
424
+ float: right;
425
+ margin-top: 10px !important;
426
+ }
427
+
428
+ #wp-seo-meta-form .bulkactions select,#wp-seo-meta-form .bulkactions #broken-submit{
429
+ float: left;
430
+ }
431
+
432
+ .wpms_scan_link{
433
+ float: left;
434
+ }
435
+
436
+ .wpms_scan_link.scanding{
437
+ background-image: url('../img/loading1.gif') !important;
438
+ background-size: 100% 100% !important;
439
+ }
440
+
441
+ .wpms_action_link{
442
+ cursor: pointer;
443
+ }
444
+ .column-col_hit{
445
+ text-align: center !important;
446
+ }
447
+ .broken_link_table th#col_hit{width:10%;}
448
+ .broken_link_table th#cb{width:3%}
449
+ .broken_link_table th#col_source{width:20%}
450
+ .broken_link_table th#col_link_url{width:40%}
451
+ .broken_link_table th#col_status{width:10%}
452
+
453
+ .tab-header{
454
+ width: 99%;
455
+ float: left;
456
+ }
457
+
458
+ .wpms-tabs{
459
+ float: left;
460
+ }
461
+
462
+ .wpms-tab-header{
463
+ float: left;
464
+ -webkit-box-sizing: content-box;
465
+ -moz-box-sizing: content-box;
466
+ box-sizing: content-box;
467
+ position: relative;
468
+ top: 1px;
469
+ background: #ebebeb;
470
+ color: #777;
471
+ cursor: pointer;
472
+ font: 13px/19px "Open Sans", sans-serif;
473
+ height: 20px;
474
+ margin: 5px 0 0 5px;
475
+ padding: 3px 8px 4px;
476
+ border: 1px solid #e5e5e5;
477
+ }
478
+
479
+ .wpms-tab-header:first-child{
480
+ margin: 5px 0 0 0px;
481
+ }
482
+
483
+ .wpms-tab-header.active{
484
+ background: #f5f5f5;
485
+ color: #555;
486
+ border-bottom-color: #f5f5f5;
487
+ }
488
+
489
+ .wpms-global{
490
+ display: block;
491
+ }
492
+
493
+ .content-box{
494
+ padding: 10px;
495
+ }
496
+
497
+ .content-wpms-redirection{
498
+ display: none;
499
+ }
500
+
501
+ .wpms_content_settings{
502
+ background: #fff;
503
+ }
504
+
505
+ .metaseo-dashicons{
506
+ float: left;
507
+ width: 30px;
508
+ }
509
+
510
+ .metaseo-dashicons:before{
511
+ width: 30px;
512
+ }
513
+
514
+ .metaseo-dashicons.icons-mwarning {
515
+ width: 20px;
516
+ height: 20px;
517
+ margin: 0px 5px;
518
+ background-image: url(../img/warnig-red.png);
519
+ background-size: 100% 100%;
520
+ }
521
+
522
+ .message_saved{
523
+ line-height: 28px;
524
+ color: #0073aa;
525
+ display: none;
526
+ }
527
+
528
+ .wpms_warning{
529
+ color: #FFB900;
530
+ }
531
+
532
+ .wpms_ok{
533
+ color: #4caf50;
534
+ }
535
+
536
+ .wpmf_process{
537
+ background:#81b5ee;
538
+ height: 2px;
539
+ width:0%;
540
+ display: none;
541
+ }
542
+
543
+ .wp-meta-seo_page_metaseo_broken_link .metaseo-qtip {
544
+ font-size: 12px !important;
545
+ line-height: 18px !important;
546
+ }
547
+
548
+ .link_html{
549
+ float: none;
550
+ }
551
+ .row-actions > span{
552
+ float: left;
553
+ }
554
+
555
+ .wpms_action_link{
556
+ color:#32373C !important;
557
+ }
558
+
559
+ .wpms_action_link i.material-icons{
560
+ font-size:20px !important;
561
+ }
562
+
563
+ .wpms_icon_action{
564
+ height: 20px;
565
+ float: left;
566
+ }
567
+
568
+ td.link_text i.material-icons{
569
+ font-size:20px;
570
+ color:#32373C
571
  }
inc/class.metaseo-admin.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  //Main plugin functions here
4
  class MetaSeo_Admin {
5
 
@@ -40,13 +39,13 @@ class MetaSeo_Admin {
40
 
41
  /** Load admin css * */
42
  add_action('admin_init', array($this, 'addAdminStylesheets'));
43
-
44
  $this->ajaxHandle();
45
 
46
  //register ajax update meta handler...
47
  add_action( 'wp_ajax_updateContentMeta', array($this, 'updateContentMeta_callback') );
48
  add_action( 'admin_init', array($this, 'stop_heartbeat') , 1 );
49
  add_action('admin_init', array($this,'metaseo_field_settings'));
 
50
  add_action('init', array($this,'wpms_load_langguage'));
51
 
52
  if(!get_option('wpms_set_ignore', false)){
@@ -58,6 +57,60 @@ class MetaSeo_Admin {
58
  add_action( 'admin_notices', array( $this, 'wpms_public_warning' ) );
59
  }
60
  add_action( 'wp_enqueue_editor', array( $this,'wpms_link_title_field'), 20 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  function wpms_link_title_field() {
@@ -116,7 +169,7 @@ class MetaSeo_Admin {
116
  }
117
 
118
  function metaseo_create_field($data_title,$alt,$dashicon,$label,$value_hidden){
119
- $output = '<div class="metaseo_analysis metaseo_tool 123" data-title="'.$data_title.'" alt="'.$alt.'"><div class="metaseo-dashicons dashicons-before '.$dashicon.'"></div>'.$label.'</div>';
120
  $output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms['.$data_title.']" value="'.$value_hidden.'">';
121
  return $output;
122
  }
@@ -158,14 +211,14 @@ class MetaSeo_Admin {
158
  }
159
 
160
  if($test){
161
- $output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'dashicons-yes',__('Page title word in content heading','wp-meta-seo'),1);
162
  $check ++;
163
  }else{
164
- $output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'icons-mwarning',__('Page title word in content heading','wp-meta-seo'),0);
165
  }
166
 
167
  }else{
168
- $output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'dashicons-yes',__('Page title word in content heading','wp-meta-seo'),1);
169
  $check ++;
170
  }
171
 
@@ -186,41 +239,41 @@ class MetaSeo_Admin {
186
  }
187
 
188
  if($test1){
189
- $output .= $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'dashicons-yes',__('Page title word in content','wp-meta-seo'),1);
190
  $check ++;
191
  }else{
192
- $output .= $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'icons-mwarning',__('Page title word in content','wp-meta-seo'),0);
193
  }
194
 
195
  // page url matches page title
196
  $mtitle = $_POST['datas']['title'];
197
  if($_POST['datas']['mpageurl'] == sanitize_title($mtitle)){
198
- $output .= $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'dashicons-yes',__('Page url matches with page title','wp-meta-seo'),1);
199
  $check ++;
200
  }else{
201
- $output .= $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'icons-mwarning',__('Page url matches with page title','wp-meta-seo'),0);
202
  }
203
 
204
  // meta title filled
205
  if(($_POST['datas']['meta_title'] != '' && strlen($_POST['datas']['meta_title']) <= self::$title_length)){
206
- $output .= $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'dashicons-yes',__('Meta title filled','wp-meta-seo'),1);
207
  $check++;
208
  }else{
209
- $output .= $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'icons-mwarning',__('Meta title filled','wp-meta-seo'),0);
210
  }
211
 
212
  // desc filled
213
  if(($_POST['datas']['meta_desc'] != '' && strlen($_POST['datas']['meta_desc']) <= self::$desc_length)){
214
- $output .= $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'dashicons-yes',__('Meta description filled','wp-meta-seo'),1);
215
  $check++;
216
  }else{
217
- $output .= $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'icons-mwarning',__('Meta description filled','wp-meta-seo'),0);
218
  }
219
 
220
  // image resize
221
  if($_POST['datas']['content'] == '') {
222
- $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'dashicons-yes',__('Wrong image resize','wp-meta-seo'),1);
223
- $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'dashicons-yes',__('Image have meta title or alt','wp-meta-seo'),1);
224
  $check += 2;
225
  }else{
226
  $dom = new DOMDocument;
@@ -250,21 +303,21 @@ class MetaSeo_Admin {
250
  }
251
 
252
  if($img_wrong == false){
253
- $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'dashicons-yes',__('Wrong image resize','wp-meta-seo'),1);
254
  $check++;
255
  }else{
256
- $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'icons-mwarning',__('Wrong image resize','wp-meta-seo'),0);
257
  }
258
 
259
  if($img_wrong_alt == false){
260
- $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'dashicons-yes',__('Image have meta title or alt','wp-meta-seo'),1);
261
  $check++;
262
  }else{
263
- $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'icons-mwarning',__('Image have meta title or alt','wp-meta-seo'),0);
264
  }
265
  }else{
266
- $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'icons-mwarning',__('Wrong image resize','wp-meta-seo'),0);
267
- $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'icons-mwarning',__('Image have meta title or alt','wp-meta-seo'),0);
268
  }
269
  }
270
 
@@ -309,8 +362,15 @@ class MetaSeo_Admin {
309
  }
310
  }
311
  wp_send_json(false);
312
- }
313
 
 
 
 
 
 
 
 
314
  function metaseo_field_settings(){
315
  register_setting('Wp Meta SEO','_metaseo_settings');
316
  add_settings_section('metaseo_dashboard','',array( $this, 'showSettings' ),'metaseo_settings');
@@ -339,7 +399,7 @@ class MetaSeo_Admin {
339
  public function showSettings(){
340
 
341
  }
342
-
343
  public function metaseo_title_home(){
344
  $home_title = isset( $this->settings['metaseo_title_home'] ) ? $this->settings['metaseo_title_home'] : '';
345
  echo '<input id="metaseo_title_home" name="_metaseo_settings[metaseo_title_home]" type="text" value="'.esc_attr( $home_title ).'" size="50"/>';
@@ -505,10 +565,13 @@ class MetaSeo_Admin {
505
  wp_enqueue_script('metaseo-dashboard', plugins_url('js/dashboard.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
506
  wp_enqueue_style('chart', plugins_url('/css/chart.css', dirname(__FILE__) ) );
507
  wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__) ) );
508
- wp_enqueue_style('m-style-qtip', plugins_url('css/jquery.qtip.css', WPMSEO_FILE), array(), WPMSEO_VERSION);
509
- wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', WPMSEO_FILE), array('jquery'), '2.2.1', true);
510
  }
511
 
 
 
 
 
512
  if($current_screen->base == 'wp-meta-seo_page_metaseo_image_meta'){
513
  wp_enqueue_script('mautosize', plugins_url('js/autosize.js', dirname(__FILE__)), array('jquery'), '0.1', true);
514
  }
@@ -528,7 +591,8 @@ class MetaSeo_Admin {
528
  * of jquery-ui
529
  *
530
  */
531
- function addAdminStylesheets() {
 
532
  wp_enqueue_style('wpmetaseoAdmin', plugins_url('css/metaseo_admin.css', dirname(__FILE__)),array(), WPMSEO_VERSION);
533
  wp_enqueue_style('tooltip-metaimage', plugins_url('/css/tooltip-metaimage.css',dirname(__FILE__)),array(), WPMSEO_VERSION);
534
  wp_enqueue_style('style', plugins_url('/css/style.css', dirname(__FILE__) ),array(), WPMSEO_VERSION);
@@ -576,6 +640,15 @@ class MetaSeo_Admin {
576
  array($this, 'load_page'),
577
  null,
578
  ),
 
 
 
 
 
 
 
 
 
579
  array(
580
  'metaseo_dashboard',
581
  '',
@@ -620,6 +693,9 @@ class MetaSeo_Admin {
620
  function load_page() {
621
  if (isset($_GET['page'])) {
622
  switch ($_GET['page']) {
 
 
 
623
  case 'metaseo_settings':
624
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/settings.php' );
625
  break;
@@ -865,6 +941,12 @@ class MetaSeo_Admin {
865
  add_action('wp_ajax_metaseo_reload_analysis',array($this,'metaseo_reload_analysis'));
866
  add_action('wp_ajax_metaseo_validate_analysis',array($this,'metaseo_validate_analysis'));
867
  add_action('wp_ajax_metaseo_update_link',array($this,'metaseo_update_link'));
 
 
 
 
 
 
868
  }
869
 
870
  }
1
  <?php
 
2
  //Main plugin functions here
3
  class MetaSeo_Admin {
4
 
39
 
40
  /** Load admin css * */
41
  add_action('admin_init', array($this, 'addAdminStylesheets'));
 
42
  $this->ajaxHandle();
43
 
44
  //register ajax update meta handler...
45
  add_action( 'wp_ajax_updateContentMeta', array($this, 'updateContentMeta_callback') );
46
  add_action( 'admin_init', array($this, 'stop_heartbeat') , 1 );
47
  add_action('admin_init', array($this,'metaseo_field_settings'));
48
+ add_action('admin_init', array($this,'metaseo_create_404page'));
49
  add_action('init', array($this,'wpms_load_langguage'));
50
 
51
  if(!get_option('wpms_set_ignore', false)){
57
  add_action( 'admin_notices', array( $this, 'wpms_public_warning' ) );
58
  }
59
  add_action( 'wp_enqueue_editor', array( $this,'wpms_link_title_field'), 20 );
60
+ add_action( 'post_updated', array('MetaSeo_Broken_Link_Table','wpms_update_post'), 10, 3 );
61
+ add_action( 'delete_post', array('MetaSeo_Broken_Link_Table','wpms_delete_post' ));
62
+ add_action( 'edit_comment', array('MetaSeo_Broken_Link_Table','wpms_update_comment') );
63
+ add_action( 'deleted_comment', array('MetaSeo_Broken_Link_Table','wpms_deleted_comment') );
64
+
65
+ }
66
+
67
+ function metaseo_create_404page(){
68
+ global $wpdb;
69
+ // create table wpms_links
70
+ $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}wpms_links`(
71
+ `id` int(20) unsigned NOT NULL AUTO_INCREMENT,
72
+ `link_url` text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
73
+ `link_final_url` text CHARACTER SET latin1 COLLATE latin1_general_cs,
74
+ `link_url_redirect` text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
75
+ `link_text` text NOT NULL DEFAULT '',
76
+ `source_id` int(20) DEFAULT '0',
77
+ `type` varchar(100) DEFAULT '',
78
+ `status_code` varchar(100) DEFAULT '',
79
+ `status_text` varchar(250) DEFAULT '',
80
+ `hit` int(20) NOT NULL DEFAULT '1',
81
+ `redirect` tinyint(1) NOT NULL DEFAULT '0',
82
+ `broken_indexed` tinyint(1) unsigned NOT NULL DEFAULT '0',
83
+ `broken_internal` tinyint(1) unsigned NOT NULL DEFAULT '0',
84
+ `warning` tinyint(1) unsigned NOT NULL DEFAULT '0',
85
+ `dismissed` tinyint(1) NOT NULL DEFAULT '0',
86
+ PRIMARY KEY (id))";
87
+
88
+ require_once(ABSPATH.'wp-admin/includes/upgrade.php');
89
+ dbDelta($sql);
90
+
91
+ // create page 404
92
+ $sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "posts WHERE post_title = %s" , array("WP Meta SEO 404 Page"));
93
+ $post_if = $wpdb->get_var($sql);
94
+ if($post_if < 1){
95
+ $content = '<div class="wall" style="background-color: #F2F3F7; border: 30px solid #fff; width: 90%; height: 90%; margin: 0 auto;">
96
+
97
+ <h1 style="text-align: center; font-family:\'open-sans\', arial; color: #444; font-size: 60px; padding: 50px;">ERROR 404 <br />-<br />NOT FOUND</h1>
98
+ <p style="text-align: center; font-family:\'open-sans\', arial; color: #444; font-size: 40px; padding: 20px; line-height: 55px;">
99
+ // You may have mis-typed the URL,<br />
100
+ // Or the page has been removed,<br />
101
+ // Actually, there is nothing to see here...</p>
102
+ <p style="text-align: center;"><a style=" font-family:\'open-sans\', arial; color: #444; font-size: 20px; padding: 20px; line-height: 30px; text-decoration: none;" href="'. get_home_url().'"><< Go back to home page >></a></p>
103
+ </div>';
104
+ $_page404 = array(
105
+ 'post_title' => 'WP Meta SEO 404 Page',
106
+ 'post_content' => $content,
107
+ 'post_status' => 'publish',
108
+ 'post_excerpt' => 'metaseo_404_page',
109
+ 'post_type' => 'page',
110
+ );
111
+ wp_insert_post( $_page404 );
112
+ }
113
+
114
  }
115
 
116
  function wpms_link_title_field() {
169
  }
170
 
171
  function metaseo_create_field($data_title,$alt,$dashicon,$label,$value_hidden){
172
+ $output = '<div class="metaseo_analysis metaseo_tool" data-title="'.$data_title.'" alt="'.$alt.'"><i class="metaseo-dashicons material-icons dashicons-before" style="'.($dashicon == 'done'?'color:#46B450':'color:#FFB900').'">'.$dashicon.'</i>'.$label.'</div>';
173
  $output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms['.$data_title.']" value="'.$value_hidden.'">';
174
  return $output;
175
  }
211
  }
212
 
213
  if($test){
214
+ $output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'done',__('Page title word in content heading','wp-meta-seo'),1);
215
  $check ++;
216
  }else{
217
+ $output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'warning',__('Page title word in content heading','wp-meta-seo'),0);
218
  }
219
 
220
  }else{
221
+ $output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'done',__('Page title word in content heading','wp-meta-seo'),1);
222
  $check ++;
223
  }
224
 
239
  }
240
 
241
  if($test1){
242
+ $output .= $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'done',__('Page title word in content','wp-meta-seo'),1);
243
  $check ++;
244
  }else{
245
+ $output .= $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'warning',__('Page title word in content','wp-meta-seo'),0);
246
  }
247
 
248
  // page url matches page title
249
  $mtitle = $_POST['datas']['title'];
250
  if($_POST['datas']['mpageurl'] == sanitize_title($mtitle)){
251
+ $output .= $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'done',__('Page url matches with page title','wp-meta-seo'),1);
252
  $check ++;
253
  }else{
254
+ $output .= $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'warning',__('Page url matches with page title','wp-meta-seo'),0);
255
  }
256
 
257
  // meta title filled
258
  if(($_POST['datas']['meta_title'] != '' && strlen($_POST['datas']['meta_title']) <= self::$title_length)){
259
+ $output .= $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'done',__('Meta title filled','wp-meta-seo'),1);
260
  $check++;
261
  }else{
262
+ $output .= $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'warning',__('Meta title filled','wp-meta-seo'),0);
263
  }
264
 
265
  // desc filled
266
  if(($_POST['datas']['meta_desc'] != '' && strlen($_POST['datas']['meta_desc']) <= self::$desc_length)){
267
+ $output .= $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'done',__('Meta description filled','wp-meta-seo'),1);
268
  $check++;
269
  }else{
270
+ $output .= $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'warning',__('Meta description filled','wp-meta-seo'),0);
271
  }
272
 
273
  // image resize
274
  if($_POST['datas']['content'] == '') {
275
+ $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'done',__('Wrong image resize','wp-meta-seo'),1);
276
+ $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'done',__('Image have meta title or alt','wp-meta-seo'),1);
277
  $check += 2;
278
  }else{
279
  $dom = new DOMDocument;
303
  }
304
 
305
  if($img_wrong == false){
306
+ $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'done',__('Wrong image resize','wp-meta-seo'),1);
307
  $check++;
308
  }else{
309
+ $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'warning',__('Wrong image resize','wp-meta-seo'),0);
310
  }
311
 
312
  if($img_wrong_alt == false){
313
+ $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'done',__('Image have meta title or alt','wp-meta-seo'),1);
314
  $check++;
315
  }else{
316
+ $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'warning',__('Image have meta title or alt','wp-meta-seo'),0);
317
  }
318
  }else{
319
+ $output .= $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'warning',__('Wrong image resize','wp-meta-seo'),0);
320
+ $output .= $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'warning',__('Image have meta title or alt','wp-meta-seo'),0);
321
  }
322
  }
323
 
362
  }
363
  }
364
  wp_send_json(false);
365
+ }
366
 
367
+ function wpms_save_settings404(){
368
+ if(isset($_POST['wpms_redirect'])){
369
+ update_option('wpms_settings_404', $_POST['wpms_redirect']);
370
+ wp_send_json(true);
371
+ }
372
+ }
373
+
374
  function metaseo_field_settings(){
375
  register_setting('Wp Meta SEO','_metaseo_settings');
376
  add_settings_section('metaseo_dashboard','',array( $this, 'showSettings' ),'metaseo_settings');
399
  public function showSettings(){
400
 
401
  }
402
+
403
  public function metaseo_title_home(){
404
  $home_title = isset( $this->settings['metaseo_title_home'] ) ? $this->settings['metaseo_title_home'] : '';
405
  echo '<input id="metaseo_title_home" name="_metaseo_settings[metaseo_title_home]" type="text" value="'.esc_attr( $home_title ).'" size="50"/>';
565
  wp_enqueue_script('metaseo-dashboard', plugins_url('js/dashboard.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
566
  wp_enqueue_style('chart', plugins_url('/css/chart.css', dirname(__FILE__) ) );
567
  wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__) ) );
568
+ wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__) ) );
 
569
  }
570
 
571
+ wp_register_style('m-style-qtip', plugins_url('css/jquery.qtip.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
572
+ wp_register_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
573
+
574
+ wp_register_style('metaseo-google-icon', plugins_url('/css/googlefonticon.css', dirname(__FILE__) ) , array(), WPMSEO_VERSION );
575
  if($current_screen->base == 'wp-meta-seo_page_metaseo_image_meta'){
576
  wp_enqueue_script('mautosize', plugins_url('js/autosize.js', dirname(__FILE__)), array('jquery'), '0.1', true);
577
  }
591
  * of jquery-ui
592
  *
593
  */
594
+
595
+ function addAdminStylesheets() {
596
  wp_enqueue_style('wpmetaseoAdmin', plugins_url('css/metaseo_admin.css', dirname(__FILE__)),array(), WPMSEO_VERSION);
597
  wp_enqueue_style('tooltip-metaimage', plugins_url('/css/tooltip-metaimage.css',dirname(__FILE__)),array(), WPMSEO_VERSION);
598
  wp_enqueue_style('style', plugins_url('/css/style.css', dirname(__FILE__) ),array(), WPMSEO_VERSION);
640
  array($this, 'load_page'),
641
  null,
642
  ),
643
+ array(
644
+ 'metaseo_dashboard',
645
+ '',
646
+ __('404 & Redirects', 'wp-meta-seo'),
647
+ $manage_options_cap,
648
+ 'metaseo_broken_link',
649
+ array($this, 'load_page'),
650
+ null,
651
+ ),
652
  array(
653
  'metaseo_dashboard',
654
  '',
693
  function load_page() {
694
  if (isset($_GET['page'])) {
695
  switch ($_GET['page']) {
696
+ case 'metaseo_broken_link':
697
+ require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/metaseo-broken-link.php' );
698
+ break;
699
  case 'metaseo_settings':
700
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/settings.php' );
701
  break;
941
  add_action('wp_ajax_metaseo_reload_analysis',array($this,'metaseo_reload_analysis'));
942
  add_action('wp_ajax_metaseo_validate_analysis',array($this,'metaseo_validate_analysis'));
943
  add_action('wp_ajax_metaseo_update_link',array($this,'metaseo_update_link'));
944
+ add_action('wp_ajax_wpms_save_settings404',array($this,'wpms_save_settings404'));
945
+ add_action('wp_ajax_wpms_update_link',array('MetaSeo_Broken_Link_Table','wpms_update_link'));
946
+ add_action('wp_ajax_wpms_unlink',array('MetaSeo_Broken_Link_Table','wpms_unlink'));
947
+ add_action('wp_ajax_wpms_recheck_link',array('MetaSeo_Broken_Link_Table','wpms_recheck_link'));
948
+ add_action('wp_ajax_wpms_scan_link',array('MetaSeo_Broken_Link_Table','wpms_scan_link'));
949
+ add_action('wp_ajax_wpms_flush_link',array('MetaSeo_Broken_Link_Table','wpms_flush_link'));
950
  }
951
 
952
  }
inc/class.metaseo-broken-link-table.php ADDED
@@ -0,0 +1,1554 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Comments to come later
4
+ *
5
+ *
6
+ */
7
+
8
+ if (!class_exists('WP_List_Table')) {
9
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
10
+ }
11
+
12
+ class MetaSeo_Broken_Link_Table extends WP_List_Table {
13
+
14
+ public $link_view = array();
15
+ public static $img_pattern = '/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i';
16
+ public static $old_url = '';
17
+ public static $new_url = '';
18
+
19
+ function __construct() {
20
+ parent::__construct(array(
21
+ 'singular' => 'metaseo_image',
22
+ 'plural' => 'metaseo_images',
23
+ 'ajax' => true
24
+ ));
25
+ }
26
+
27
+ function display_tablenav($which) {
28
+ $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
29
+ if (!empty($post_types['attachment']))
30
+ unset($post_types['attachment']);
31
+ $p_type = "('" . implode("','", $post_types) . "')";
32
+ ?>
33
+ <div class="tablenav <?php echo esc_attr($which); ?>">
34
+
35
+ <?php if ($which == 'top'): ?>
36
+ <input type="hidden" name="page" value="metaseo_image_meta" />
37
+
38
+ <div class="alignleft actions bulkactions">
39
+ <?php $this->broken_fillter('sl_broken'); ?>
40
+ <?php $this->redirect_fillter('sl_redirect'); ?>
41
+ <?php $this->type_fillter('sltype'); ?>
42
+ <?php $this->flush_fillter('sl_flush'); ?>
43
+ </div>
44
+ <?php elseif ($which == 'bottom'): ?>
45
+ <input type="hidden" name="page" value="metaseo_image_meta" />
46
+ <div class="alignleft actions bulkactions">
47
+ <?php $this->broken_fillter('sl_broken1'); ?>
48
+ <?php $this->redirect_fillter('sl_redirect1'); ?>
49
+ <?php $this->type_fillter('sltype1'); ?>
50
+ </div>
51
+ <?php endif ?>
52
+
53
+ <input type="hidden" name="page" value="metaseo_image_meta" />
54
+ <?php if (!empty($_REQUEST['post_status'])): ?>
55
+ <input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
56
+ <?php endif ?>
57
+
58
+ <?php //$this->extra_tablenav($which); ?>
59
+
60
+ <div style="float:right;margin-left:8px;">
61
+ <input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_broken_link_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
62
+ <input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
63
+ </div>
64
+
65
+ <?php $this->pagination($which); ?>
66
+ <br class="clear" />
67
+ </div>
68
+
69
+ <?php
70
+ }
71
+
72
+ function extra_tablenav($which) {
73
+
74
+ #if ('top' == $which) {
75
+ echo '<div class="alignleft actions">';
76
+ global $wpdb;
77
+
78
+ $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
79
+ $post_types = "'" . implode("', '", $post_types) . "'";
80
+
81
+ $states = get_post_stati(array('show_in_admin_all_list' => true));
82
+ $states['trash'] = 'trash';
83
+ $all_states = "'" . implode("', '", $states) . "'";
84
+
85
+ $query = "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types) ORDER BY 'post_type' ASC";
86
+ $post_types = $wpdb->get_results($query);
87
+
88
+ $selected = !empty($_REQUEST['post_type_filter']) ? $_REQUEST['post_type_filter'] : -1;
89
+
90
+ $options = '<option value="-1">Show All Post Types</option>';
91
+
92
+ foreach ($post_types as $post_type) {
93
+ $obj = get_post_type_object($post_type->post_type);
94
+ $options .= sprintf('<option value="%2$s" %3$s>%1$s</option>', $obj->labels->name, $post_type->post_type, selected($selected, $post_type->post_type, false));
95
+ }
96
+
97
+ echo "</div>";
98
+ #echo "</form>";
99
+ #}
100
+ }
101
+
102
+ function get_columns() {
103
+ return $columns = array(
104
+ 'col_link_url' => __('URL', 'wp-meta-seo'),
105
+ 'col_hit' => __('Hits number', 'wp-meta-seo'),
106
+ 'col_status' => __('Status', 'wp-meta-seo'),
107
+ 'col_link_text' => __('Type or Link text', 'wp-meta-seo'),
108
+ 'col_source' => __('Source', 'wp-meta-seo'),
109
+ );
110
+ }
111
+
112
+ function get_sortable_columns() {
113
+ return $sortable = array(
114
+ 'col_status' => array('status_text', true),
115
+ 'col_link_url' => array('link_url', true)
116
+ );
117
+ }
118
+
119
+ /**
120
+ * Print column headers, accounting for hidden and sortable columns.
121
+ *
122
+ * @since 3.1.0
123
+ * @access public
124
+ *
125
+ * @param bool $with_id Whether to set the id attribute or not
126
+ */
127
+ public function print_column_headers($with_id = true) {
128
+ list( $columns, $hidden, $sortable ) = $this->get_column_info();
129
+
130
+ $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
131
+ $current_url = remove_query_arg('paged', $current_url);
132
+
133
+ if (isset($_GET['orderby']))
134
+ $current_orderby = $_GET['orderby'];
135
+ else
136
+ $current_orderby = '';
137
+
138
+ if (isset($_GET['order']) && 'desc' == $_GET['order'])
139
+ $current_order = 'desc';
140
+ else
141
+ $current_order = 'asc';
142
+
143
+ if (!empty($columns['cb'])) {
144
+ static $cb_counter = 1;
145
+ $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>'
146
+ . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" style="margin:0;" />';
147
+ $cb_counter++;
148
+ }
149
+
150
+ foreach ($columns as $column_key => $column_display_name) {
151
+ $class = array('manage-column', "column-$column_key");
152
+
153
+ $style = '';
154
+ if (in_array($column_key, $hidden))
155
+ $style = 'display:none;';
156
+
157
+ $style = ' style="' . $style . '"';
158
+
159
+ if ('cb' == $column_key)
160
+ $class[] = 'check-column';
161
+ elseif (in_array($column_key, array('posts', 'comments', 'links')))
162
+ $class[] = 'num';
163
+
164
+ if (isset($sortable[$column_key])) {
165
+ list( $orderby, $desc_first ) = $sortable[$column_key];
166
+
167
+ if ($current_orderby == $orderby) {
168
+ $order = 'asc' == $current_order ? 'desc' : 'asc';
169
+ $class[] = 'sorted';
170
+ $class[] = $current_order;
171
+ } else {
172
+ $order = $desc_first ? 'desc' : 'asc';
173
+ $class[] = 'sortable';
174
+ $class[] = $desc_first ? 'asc' : 'desc';
175
+ }
176
+
177
+ $column_display_name = '<a href="' . esc_url(add_query_arg(compact('orderby', 'order'), $current_url)) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
178
+ }
179
+
180
+ $id = $with_id ? "id='$column_key'" : '';
181
+
182
+ if (!empty($class))
183
+ $class = "class='" . join(' ', $class) . "'";
184
+
185
+ if ($column_key === 'cb') {
186
+ echo "<th scope='col' $id $class style='padding:8px 10px;'>$column_display_name</th>";
187
+ } else {
188
+ echo "<th scope='col' $id $class $style colspan=\"3\">$column_display_name</th>";
189
+ }
190
+ }
191
+ }
192
+
193
+ function prepare_items() {
194
+ global $wpdb, $_wp_column_headers;
195
+ $where = array('1=1');
196
+ if (!empty($_REQUEST['sltype']) && $_REQUEST['sltype'] != 'all') {
197
+ if ($_REQUEST['sltype'] != 'other') {
198
+ $where[] = "type = '" . $_REQUEST['sltype'] . "'";
199
+ } else {
200
+ $where[] = "type IN ('comment','404_automaticaly')";
201
+ }
202
+ }
203
+
204
+ if (!empty($_REQUEST['sl_broken']) && $_REQUEST['sl_broken'] != 'all') {
205
+ if ($_REQUEST['sl_broken'] == 'valid_links') {
206
+ $where[] = "broken_internal = 0 AND broken_indexed = 0";
207
+ }elseif ($_REQUEST['sl_broken'] == 'internal_broken_links') {
208
+ $where[] = "broken_internal = 1";
209
+ } else {
210
+ $where[] = "broken_indexed = 1";
211
+ }
212
+ }
213
+
214
+ if (!empty($_REQUEST['sl_redirect']) && $_REQUEST['sl_redirect'] != 'all') {
215
+ if ($_REQUEST['sl_redirect'] == 'already_redirect') {
216
+ $where[] = "(broken_internal = 1 OR broken_indexed = 1)";
217
+ $where[] = "link_url_redirect !='' ";
218
+ } else {
219
+ $where[] = "(broken_internal = 1 OR broken_indexed = 1)";
220
+ $where[] = "link_url_redirect ='' ";
221
+ }
222
+ }
223
+
224
+ $keyword = !empty($_GET["txtkeyword"]) ? $_GET["txtkeyword"] : '';
225
+ if (isset($keyword) && $keyword != '') {
226
+ $where[] .= '(link_text LIKE "%' . $keyword . '%" OR link_url LIKE "%' . $keyword . '%")';
227
+ }
228
+
229
+ $orderby = !empty($_GET["orderby"]) ? ($_GET["orderby"]) : 'id';
230
+ $order = !empty($_GET["order"]) ? ($_GET["order"]) : 'asc';
231
+ $sortable = $this->get_sortable_columns();
232
+ if (in_array($orderby, $sortable)) {
233
+ $orderStr = $orderby;
234
+ } else {
235
+ $orderStr = 'id';
236
+ }
237
+
238
+ if ($order == "asc") {
239
+ $orderStr .= " ASC";
240
+ } else {
241
+ $orderStr .= " DESC";
242
+ }
243
+
244
+ if (!empty($orderby) & !empty($order)) {
245
+ $orderStr = ' ORDER BY ' . $orderStr;
246
+ }
247
+
248
+ $query = "SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE " . implode(' AND ', $where) . $orderStr;
249
+ $columns = $this->get_columns();
250
+ $hidden = array();
251
+ $sortable = $this->get_sortable_columns();
252
+ $this->_column_headers = array($columns, $hidden, $sortable);
253
+ $total_items = $wpdb->query($query);
254
+ if (!empty($_REQUEST['metaseo_broken_link_per_page'])) {
255
+ $_per_page = intval($_REQUEST['metaseo_broken_link_per_page']);
256
+ } else {
257
+ $_per_page = 0;
258
+ }
259
+
260
+ $per_page = get_user_option('metaseo_broken_link_per_page');
261
+ if ($per_page !== false) {
262
+ if ($_per_page && $_per_page !== $per_page) {
263
+ $per_page = $_per_page;
264
+ update_user_option(get_current_user_id(), 'metaseo_broken_link_per_page', $per_page);
265
+ }
266
+ } else {
267
+ if ($_per_page > 0) {
268
+ $per_page = $_per_page;
269
+ } else {
270
+ $per_page = 10;
271
+ }
272
+ add_user_meta(get_current_user_id(), 'metaseo_broken_link_per_page', $per_page);
273
+ }
274
+
275
+ $paged = !empty($_GET["paged"]) ? $_GET["paged"] : '';
276
+ if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
277
+ $paged = 1;
278
+ }
279
+
280
+ $total_pages = ceil($total_items / $per_page);
281
+
282
+ if (!empty($paged) && !empty($per_page)) {
283
+ $offset = ($paged - 1) * $per_page;
284
+ $query .= ' LIMIT ' . (int) $offset . ',' . (int) $per_page;
285
+ }
286
+
287
+ $this->set_pagination_args(array(
288
+ 'total_items' => $total_items,
289
+ 'total_pages' => $total_pages,
290
+ 'per_page' => $per_page
291
+ ));
292
+
293
+
294
+ $this->items = $wpdb->get_results($query);
295
+ }
296
+
297
+ function search_box1() {
298
+ if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
299
+ return;
300
+ $txtkeyword = (!empty($_REQUEST['txtkeyword'])) ? urldecode(stripslashes($_REQUEST['txtkeyword'])) : "";
301
+ if (!empty($_REQUEST['orderby']))
302
+ echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />';
303
+ if (!empty($_REQUEST['order']))
304
+ echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />';
305
+ if (!empty($_REQUEST['post_mime_type']))
306
+ echo '<input type="hidden" name="post_mime_type" value="' . esc_attr($_REQUEST['post_mime_type']) . '" />';
307
+ if (!empty($_REQUEST['detached']))
308
+ echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
309
+ ?>
310
+ <p class="search-box">
311
+
312
+ <input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
313
+ <?php submit_button('Search URL', 'button', 'search', false, array('id' => 'search-submit')); ?>
314
+ </p>
315
+ <?php
316
+ }
317
+
318
+ function redirect_fillter($name) {
319
+ $redirects = array('not_yet_redirect' => __('Not yet redirected', 'wp-meta-seo'), 'already_redirect' => __('Already redirected', 'wp-meta-seo'));
320
+ $curent_redirect = isset($_REQUEST['sl_redirect']) ? $_REQUEST['sl_redirect'] : 'all';
321
+ ?>
322
+ <label for="filter-by-redirect" class="screen-reader-text"><?php _e('Filter by redirect', 'wp-meta-seo'); ?></label>
323
+ <select name="<?php echo $name ?>" id="filter-by-redirect" class="redirect_fillter">
324
+ <option<?php selected($curent_redirect, 'all'); ?> value="all"><?php _e('Status', 'wp-meta-seo'); ?></option>
325
+ <?php
326
+ foreach ($redirects as $k => $redirect) {
327
+ if ($curent_redirect == $k) {
328
+ echo '<option selected value="' . $k . '">' . $redirect . '</option>';
329
+ } else {
330
+ echo '<option value="' . $k . '">' . $redirect . '</option>';
331
+ }
332
+ }
333
+ ?>
334
+ </select>
335
+
336
+ <?php
337
+ }
338
+
339
+ function broken_fillter($name) {
340
+ $brokens = array('valid_links' => __('Valid links', 'wp-meta-seo') ,'automaticaly_indexed' => __('404 automaticaly indexed', 'wp-meta-seo'), 'internal_broken_links' => __('Internal broken links', 'wp-meta-seo'));
341
+ $curent_broken = isset($_REQUEST['sl_broken']) ? $_REQUEST['sl_broken'] : 'all';
342
+ ?>
343
+ <label for="filter-by-broken" class="screen-reader-text"><?php _e('Filter by broken', 'wp-meta-seo'); ?></label>
344
+ <select name="<?php echo $name ?>" id="filter-by-broken" class="broken_fillter">
345
+ <option<?php selected($curent_broken, 'all'); ?> value="all"><?php _e('All', 'wp-meta-seo'); ?></option>
346
+ <?php
347
+ foreach ($brokens as $k => $broken) {
348
+ if ($curent_broken == $k) {
349
+ echo '<option selected value="' . $k . '">' . $broken . '</option>';
350
+ } else {
351
+ echo '<option value="' . $k . '">' . $broken . '</option>';
352
+ }
353
+ }
354
+ ?>
355
+ </select>
356
+
357
+ <?php
358
+ }
359
+
360
+ function type_fillter($name) {
361
+ $types = array('url' => 'URL', 'image' => 'Image', 'other' => 'Other');
362
+ $curent_type = isset($_REQUEST['sltype']) ? $_REQUEST['sltype'] : 'all';
363
+ ?>
364
+ <label for="filter-by-type" class="screen-reader-text"><?php _e('Filter by type', 'wp-meta-seo'); ?></label>
365
+ <select name="<?php echo $name ?>" id="filter-by-type" class="metaseo-filter">
366
+ <option<?php selected($curent_type, 'all'); ?> value="all"><?php _e('Type', 'wp-meta-seo'); ?></option>
367
+ <?php
368
+ foreach ($types as $k => $type) {
369
+ if ($curent_type == $k) {
370
+ echo '<option selected value="' . $k . '">' . $type . '</option>';
371
+ } else {
372
+ echo '<option value="' . $k . '">' . $type . '</option>';
373
+ }
374
+ }
375
+ ?>
376
+ </select>
377
+
378
+ <?php
379
+ submit_button(__('Filter'), 'button', 'filter_type_action', false, array('id' => 'broken-submit'));
380
+ echo '<div style="float:left;padding-left: 5px;"><div class="wpmf_process" data-w="0"></div>';
381
+ echo '<div data-paged="1" class="button wpms_scan_link">' . __('Index internal broken links', 'wp-meta-seo') . '</div></div>';
382
+ echo '<span class="spinner"></span>';
383
+
384
+ }
385
+
386
+ function flush_fillter($name) {
387
+ $flushs = array('automaticaly_indexed' => __('Automatic indexed 404', 'wp-meta-seo'), 'internal_broken_links' => __('Internal broken links', 'wp-meta-seo') , 'all' => __('Flush all 404', 'wp-meta-seo'));
388
+ ?>
389
+ <label for="filter-by-flush" class="screen-reader-text"><?php _e('Filter by flush', 'wp-meta-seo'); ?></label>
390
+ <select name="<?php echo $name ?>" id="filter-by-flush">
391
+ <option value="none"><?php _e('Select', 'wp-meta-seo'); ?></option>
392
+ <?php
393
+ foreach ($flushs as $k => $flush) {
394
+ echo '<option value="' . $k . '">' . $flush . '</option>';
395
+ }
396
+ ?>
397
+ </select>
398
+
399
+ <?php
400
+ echo '<div class="button wpms_flush_link">' . __('Flush', 'wp-meta-seo') . '</div>';
401
+
402
+ }
403
+
404
+ function display_rows() {
405
+ $url = URL;
406
+ $url = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', $url);
407
+ $records = $this->items;
408
+ $i = 0;
409
+ $alternate = "";
410
+ list( $columns, $hidden ) = $this->get_column_info();
411
+ if (!empty($records)) {
412
+ foreach ($records as $rec) {
413
+ $i++;
414
+ echo '<tr id="record_' . $i . '" data-link="' . $i . '" data-post_id="' . $rec->source_id . '">';
415
+ foreach ($columns as $column_name => $column_display_name) {
416
+
417
+ $class = sprintf('class="%1$s column-%1$s"', $column_name);
418
+ $style = "";
419
+
420
+ if (in_array($column_name, $hidden)) {
421
+ $style = ' style="display:none;"';
422
+ }
423
+
424
+ $attributes = $class . $style;
425
+
426
+ switch ($column_name) {
427
+ case 'col_link_url':
428
+ if($rec->type == 'url'){
429
+ $value_url = $rec->link_final_url;
430
+ }else{
431
+ $value_url = $rec->link_url;
432
+ }
433
+ echo '<td class="wpms_link_html" colspan="3">';
434
+ echo '<input type="hidden" class="wpms_link_text" value="' . esc_attr($rec->link_text) . '">';
435
+ echo '<a class="link_html" target="_blank" href="' . esc_url($value_url) . '">' . $value_url . '</a>';
436
+ $row_action = array(
437
+ 'edit' => '<a class="wpms_action_link wpms-edit-button" title="Edit this link"><div class="wpms_icon_action"><i class="material-icons">mode_edit</i></div><span>' . __('Redirect', 'wp-meta-seo') . '</span></a>',
438
+ 'delete' => '<a class="wpms_action_link submitdelete wpms-unlink-button" data-link_id="' . $rec->id . '" data-type="' . $rec->type . '" data-source_id="' . $rec->source_id . '" title="' . __('Remove this link from all posts', 'wp-meta-seo') . '"><div class="wpms_icon_action"><i class="material-icons">delete_forever</i></div><span>' . __('Remove link', 'wp-meta-seo') . '</span></a>',
439
+ 'recheck' => '<a class="wpms_action_link wpms-recheck-button" data-link_id="' . $rec->id . '" data-type="' . $rec->type . '" data-source_id="' . $rec->source_id . '" title="' . __('Recheck this link', 'wp-meta-seo') . '"><div class="wpms_icon_action"><i class="material-icons">loop</i></div><span>' . __('Recheck', 'wp-meta-seo') . '</span></a>'
440
+ );
441
+ echo $this->row_actions($row_action, false);
442
+ if(!empty($rec->source_id) && $rec->type == 'url'){
443
+ $iii = 0;
444
+ $pos = get_post($rec->source_id);
445
+ if(!empty($pos)){
446
+ preg_match_all("#<a[^>]*>.*?</a>#si", $pos->post_content, $matches, PREG_PATTERN_ORDER);
447
+ foreach ($matches[0] as $i => $content) {
448
+ preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
449
+ $href = $matches[1];
450
+ if($href == $rec->link_url){
451
+ $iii++;
452
+ }
453
+
454
+ }
455
+ }
456
+ }
457
+ ?>
458
+ <div class="wpms-inline-editor-content">
459
+ <h4><?php echo _x('Edit Link', 'inline editor title', 'wp-meta-seo'); ?></h4>
460
+ <?php
461
+ if($rec->type == 'url'){
462
+ if($iii>1){
463
+ echo '<span class="wpms-input-text-wrap"><span class="title">'.__('Text', 'wp-meta-seo').'</span><input type="text" name="link_text" class="wpms-link-text-field" placeholder="'.__('Multiple link', 'wp-meta-seo').'" data-type="multi" /></span>';
464
+ }else{
465
+ echo '<span class="wpms-input-text-wrap"><span class="title">'.__('Text', 'wp-meta-seo').'</span><input type="text" name="link_text" class="wpms-link-text-field" value="'.esc_attr($rec->link_text).'" data-type="only" /></span>';
466
+ }
467
+ }else{
468
+ echo '<span class="wpms-input-text-wrap"><span class="title">'.__('Text', 'wp-meta-seo').'</span><input readonly type="text" name="link_text" class="wpms-link-text-field" value="(None)" data-type="only" /></span>';
469
+ }
470
+ ?>
471
+
472
+ <span class="wpms-input-text-wrap"><span class="title"><?php _e('URL', 'wp-meta-seo'); ?></span><input <?php echo ($rec->type == '404_automaticaly') ? 'readonly' : '' ?> type="text" name="link_url" class="wpms-link-url-field" value="<?php echo esc_attr($value_url); ?>" /></span>
473
+ <span class="wpms-input-text-wrap"><span class="title"><?php _e('Redirect', 'wp-meta-seo'); ?></span><input type="text" name="link_url_redirect" class="wpms-link-redirect-field" value="<?php echo esc_attr($rec->link_url_redirect); ?>" /></span>
474
+ </label>
475
+
476
+ <div class="submit wpms-inline-editor-buttons">
477
+ <input type="button" class="button-secondary cancel alignleft wpms-cancel-button" value="<?php echo esc_attr(__('Cancel', 'wp-meta-seo')); ?>" />
478
+ <input type="button" data-type="<?php echo $rec->type ?>" data-link_id="<?php echo $rec->id ?>" data-source_id="<?php echo $rec->source_id ?>" class="button-primary save alignright wpms-update-link-button" value="<?php echo esc_attr(__('Update', 'wp-meta-seo')); ?>" />
479
+ </div>
480
+ </div>
481
+ <?php
482
+ echo '</td>';
483
+ break;
484
+
485
+ case 'col_hit':
486
+ echo '<td colspan="3" style="text-align:center;">';
487
+ echo $rec->hit;
488
+ echo '</td>';
489
+ break;
490
+ case 'col_status':
491
+ echo '<td colspan="3" class="col_status">';
492
+
493
+ if(strpos($rec->status_text, '200') !== false){
494
+ echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>';
495
+ }elseif(strpos($rec->status_text, '301') !== false){
496
+ echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>';
497
+ }elseif(strpos($rec->status_text, '302') !== false){
498
+ echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>';
499
+ }elseif(strpos($rec->status_text, '404') !== false || $rec->status_text == 'Server Not Found'){
500
+ $wpms_settings_404 = get_option('wpms_settings_404');
501
+ if((isset($wpms_settings_404['wpms_redirect_homepage']) && $wpms_settings_404['wpms_redirect_homepage'] == 1) || $rec->link_url_redirect != ''){
502
+ echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>';
503
+ }else{
504
+ echo '<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>';
505
+ }
506
+ }else{
507
+ echo $rec->status_text;
508
+ }
509
+
510
+ echo '</td>';
511
+ break;
512
+
513
+ case 'col_link_text':
514
+ if ($rec->type == 'image') {
515
+ echo '<td colspan="3" class="link_text"><span style="float: left;margin-right: 5px;"><i class="material-icons">photo</i></span><span> ' . __('Image', 'wp-meta-seo') . '</span></td>';
516
+ } elseif ($rec->type == 'comment') {
517
+ echo '<td colspan="3" class="link_text"><span style="float: left;margin-right: 5px;"><i class="material-icons">chat_bubble</i></span><span> ' . $rec->link_text . '</span></td>';
518
+ } else {
519
+ if (strip_tags($rec->link_text) != '') {
520
+ echo '<td colspan="3" class="link_text">' . strip_tags($rec->link_text) . '</td>';
521
+ } else {
522
+ echo '<td colspan="3" class="link_text"><i>(None)</i></td>';
523
+ }
524
+ }
525
+
526
+ break;
527
+
528
+ case 'col_source':
529
+ if ($rec->type == '404_automaticaly') {
530
+ echo '<td colspan="3">' . __('404 automaticaly indexed', 'wp-meta-seo') . '</td>';
531
+ } else {
532
+ if ($rec->type == 'comment') {
533
+ $source = get_comment($rec->source_id);
534
+ if(!empty($source)){
535
+ $row_action = array(
536
+ 'edit' => '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '" title="Edit this item">Edit</a>',
537
+ 'view' => '<a target="_blank" href="' . get_comment_link($rec->source_id) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
538
+ );
539
+ $source_inner = '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '">' . $source->comment_author . '</a>';
540
+ }
541
+ } else {
542
+ $source = get_post($rec->source_id);
543
+ if(!empty($source)){
544
+ $row_action = array(
545
+ 'edit' => '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '" title="Edit this item">Edit</a>',
546
+ 'view' => '<a target="_blank" href="' . get_post_permalink($rec->source_id) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
547
+ );
548
+
549
+ $source_inner = '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '">' . $source->post_title . '</a>';
550
+ }
551
+ }
552
+
553
+ echo '<td colspan="3">';
554
+ if(!empty($source)){
555
+ echo $source_inner;
556
+ echo $this->row_actions($row_action, false);
557
+ }else{
558
+ echo '<a>'.__('Source Not Found','wp-meta-seo').'</a>';
559
+ }
560
+ echo '</td>';
561
+ break;
562
+ }
563
+ }
564
+ }
565
+
566
+ echo '</tr>';
567
+ }
568
+ }
569
+ }
570
+
571
+ public function process_action() {
572
+ global $wpdb;
573
+ $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
574
+ $redirect = false;
575
+
576
+ if (isset($_POST['search'])) {
577
+ $current_url = add_query_arg(array("search" => "Search", "txtkeyword" => urlencode(stripslashes($_POST["txtkeyword"]))), $current_url);
578
+ $redirect = true;
579
+ }
580
+
581
+ if (isset($_POST['filter_type_action']) and $_POST['filter_type_action'] === 'Filter') {
582
+ $current_url = add_query_arg(array("sltype" => $_POST["sltype"], 'sl_redirect' => $_POST["sl_redirect"], 'sl_broken' => $_POST["sl_broken"]), $current_url);
583
+ $redirect = true;
584
+ }
585
+
586
+ if (!empty($_POST['paged'])) {
587
+ $current_url = add_query_arg(array("paged" => intval($_POST['paged'])), $current_url);
588
+ $redirect = true;
589
+ }
590
+
591
+ if (!empty($_POST['metaseo_broken_link_per_page'])) {
592
+ $current_url = add_query_arg(array("metaseo_broken_link_per_page" => intval($_POST['metaseo_broken_link_per_page'])), $current_url);
593
+ $redirect = true;
594
+ }
595
+
596
+ if ($redirect === true) {
597
+ wp_redirect($current_url);
598
+ ob_end_flush();
599
+ exit();
600
+ }
601
+ }
602
+
603
+ public static function wpms_get_links() {
604
+ global $wpdb, $_wp_column_headers;
605
+
606
+ $where = array();
607
+ $post_type = isset($_REQUEST['post_type_filter']) ? $_REQUEST['post_type_filter'] : "";
608
+ if ($post_type == "-1") {
609
+ $post_type = "";
610
+ }
611
+
612
+ $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
613
+ unset($post_types['attachment']);
614
+ if (!empty($post_type) && !in_array($post_type, $post_types))
615
+ $post_type = '\'post\'';
616
+ else if (empty($post_type)) {
617
+ $post_type = "'" . implode("', '", $post_types) . "'";
618
+ } else {
619
+ $post_type = "'" . $post_type . "'";
620
+ }
621
+
622
+ $where[] = "post_type IN ($post_type)";
623
+ $states = get_post_stati(array('show_in_admin_all_list' => true));
624
+ $states['trash'] = 'trash';
625
+ $all_states = "'" . implode("', '", $states) . "'";
626
+
627
+ if (empty($_REQUEST['post_status'])) {
628
+ $where[] = "post_status IN ($all_states)";
629
+ } else {
630
+ $requested_state = $_REQUEST['post_status'];
631
+ if (in_array($requested_state, $states)) {
632
+ $where[] = "post_status IN ('$requested_state')";
633
+ } else {
634
+ $where[] = "post_status IN ($all_states)";
635
+ }
636
+ }
637
+
638
+ $query = "SELECT ID, post_title, post_excerpt , post_content ,post_name, post_type, post_status"
639
+ . " FROM $wpdb->posts "
640
+ . " WHERE " . implode(' AND ', $where);
641
+
642
+ $results = $wpdb->get_results($query);
643
+ $list_link = array();
644
+
645
+ $comments = get_comments();
646
+ foreach ($comments as $comment) {
647
+ if (!empty($comment->comment_author_url)) {
648
+
649
+ $row_action = array(
650
+ 'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
651
+ 'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
652
+ );
653
+ $source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
654
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($comment->comment_author_url);
655
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
656
+ $list_link[$comment->comment_author_url . $comment->comment_ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $comment->comment_ID, $comment->comment_author_url, $comment->comment_author, 'comment', $status, $status_type);
657
+ }
658
+ }
659
+
660
+ foreach ($results as $post) {
661
+ if($post->post_excerpt != 'metaseo_404_page'){
662
+ $dom = new DOMDocument;
663
+ libxml_use_internal_errors(true);
664
+ if (isset($post->post_content) && $post->post_content != '') {
665
+ preg_match_all("#<a[^>]*>.*?</a>#si", $post->post_content, $matches, PREG_PATTERN_ORDER);
666
+ foreach (array_unique($matches[0]) as $i => $content) {
667
+ preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
668
+ $href = $matches[1];
669
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
670
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
671
+ $link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
672
+ $row_action = array(
673
+ 'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
674
+ 'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
675
+ );
676
+ $source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
677
+ $list_link[$href.'url'.$post->ID.$link_text] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $post->ID, $href, $link_text, 'url', $status, $status_type);
678
+ }
679
+ preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
680
+ foreach (array_unique($matches[0]) as $content) {
681
+
682
+ $row_action = array(
683
+ 'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
684
+ 'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
685
+ );
686
+ $source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
687
+ preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
688
+ $src = $matches[1];
689
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
690
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
691
+ $link_text = '';
692
+ $list_link[$src.'img'.$post->ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $post->ID, $src, $link_text, 'image', $status, $status_type);
693
+ }
694
+ }
695
+ }
696
+ }
697
+
698
+ return $list_link;
699
+ }
700
+
701
+ public static function get_result_link( $source_link, $row_action, $source_id, $url, $link_text, $type, $status, $status_type) {
702
+ $res = array(
703
+ 'source_link' => $source_link,
704
+ 'row_action' => $row_action,
705
+ 'source_id' => (int) $source_id,
706
+ 'link_url' => $url,
707
+ 'link_text' => $link_text,
708
+ 'type' => $type,
709
+ 'status' => $status,
710
+ 'status_type' => $status_type);
711
+
712
+ if($type == 'url'){
713
+ if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
714
+ $perlink = get_option('permalink_structure');
715
+ if(empty($perlink)){
716
+ $res['link_final_url'] = get_site_url().'/'.$url;
717
+ }else{
718
+ $res['link_final_url'] = $perlink.'/'.$url;
719
+ }
720
+ }else{
721
+ $res['link_final_url'] = $url;
722
+ }
723
+ }else{
724
+ $res['link_final_url'] = $url;
725
+ }
726
+ return $res;
727
+ }
728
+
729
+ public static function get_urlstatus($url) {
730
+ $status = @get_headers($url, 0);
731
+ if (isset($status[0])) {
732
+ return $status[0];
733
+ } else {
734
+ return 'Server Not Found';
735
+ }
736
+ }
737
+
738
+ public static function get_urlstatus_type($status) {
739
+ if (isset($status) && $status != 'Server Not Found') {
740
+ if (((int) substr($status, 9, 3) >= 200 && (int) substr($status, 9, 3) <= 204) || (int) substr($status, 9, 3) == 401) {
741
+ $type = 'ok';
742
+ } elseif (((int) substr($status, 9, 3) >= 400 && (int) substr($status, 9, 3) <= 503 && (int) substr($status, 9, 3) != 401)) {
743
+ if (in_array((int) substr($status, 9, 3), array(404, 410))) {
744
+ $type = 'broken_internal';
745
+ } else {
746
+ $type = 'warning';
747
+ }
748
+ } elseif (((int) substr($status, 9, 3) >= 301 && (int) substr($status, 9, 3) <= 304)) {
749
+ $type = 'ok';
750
+ } else {
751
+ $type = 'dismissed';
752
+ }
753
+ } else {
754
+ $type = 'broken_internal';
755
+ }
756
+ return $type;
757
+ }
758
+
759
+ public static function wpms_deleted_comment($comment_ID) {
760
+
761
+ global $wpdb;
762
+ $wpdb->query(
763
+ $wpdb->prepare(
764
+ "DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d
765
+ AND type = %s
766
+ ", $comment_ID, 'comment'
767
+ )
768
+ );
769
+ }
770
+
771
+ public static function wpms_delete_post($post_id) {
772
+ global $wpdb;
773
+ $wpdb->query(
774
+ $wpdb->prepare(
775
+ "DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d
776
+ AND type != %s
777
+ ", $post_id, 'comment'
778
+ )
779
+ );
780
+ }
781
+
782
+ public static function wpms_update_comment($comment_ID) {
783
+ $comment = get_comment($comment_ID);
784
+ if (!empty($comment->comment_author_url)) {
785
+ global $wpdb;
786
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus(($comment->comment_author_url));
787
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
788
+ $sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "wpms_links WHERE source_id=%d AND type=%s ", array($comment_ID, 'comment'));
789
+ $check = $wpdb->get_var($sql);
790
+ if ($check == 0) {
791
+ $value = array(
792
+ 'link_url' => $comment->comment_author_url,
793
+ 'link_text' => $comment->comment_author,
794
+ 'source_id' => $comment_ID,
795
+ 'type' => 'comment',
796
+ 'status_code' => $status,
797
+ 'status_text' => ($status != 'Server Not Found') ? substr($status, 9) : 'Server Not Found',
798
+ 'broken_indexed' => 0,
799
+ 'broken_internal' => 0,
800
+ 'warning' => 0,
801
+ 'dismissed' => 0,
802
+ );
803
+ if (isset($status_type) && $status_type != 'ok') {
804
+ $value[$status_type] = 1;
805
+ }
806
+ $wpdb->insert(
807
+ $wpdb->prefix . 'wpms_links', $value
808
+ );
809
+ } else {
810
+ $value = array('link_url' => $comment->comment_author_url,
811
+ 'status_code' => $status,
812
+ 'status_text' => ($status != 'Server Not Found') ? substr($status, 9) : 'Server Not Found',
813
+ 'broken_indexed' => 0,
814
+ 'broken_internal' => 0,
815
+ 'warning' => 0,
816
+ 'dismissed' => 0,
817
+ );
818
+
819
+ if (isset($_POST['link_redirect']))
820
+ $value['link_url_redirect'] = ($_POST['link_redirect']);
821
+
822
+ if (isset($status_type) && $status_type != 'ok') {
823
+ $value[$status_type] = 1;
824
+ }
825
+ $wpdb->update(
826
+ $wpdb->prefix . 'wpms_links', $value, array('source_id' => $comment_ID, 'type' => 'comment'), array('%s', '%s', '%s', '%d', '%d', '%d', '%d'), array('%d', '%s')
827
+ );
828
+ }
829
+ }
830
+ }
831
+
832
+ public static function wpms_update_post($post_ID, $post_after, $post_before) {
833
+ $post = $post_after;
834
+ $dom = new DOMDocument;
835
+ libxml_use_internal_errors(true);
836
+ $links_in_content = array();
837
+
838
+ if($post->post_excerpt != 'metaseo_404_page'){
839
+ if (isset($post->post_content) && $post->post_content != '') {
840
+ preg_match_all("#<a[^>]*>.*?</a>#si", $post->post_content, $matches, PREG_PATTERN_ORDER);
841
+ foreach (array_unique($matches[0]) as $i => $content) {
842
+ preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
843
+ $href = $matches[1];
844
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
845
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
846
+ $link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
847
+ $row_action = array(
848
+ 'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
849
+ 'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
850
+ );
851
+ $source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
852
+ $links_in_content[$href.'url'.$post->ID.$link_text] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $post->ID, $href, $link_text, 'url', $status, $status_type);
853
+ }
854
+ preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
855
+ foreach (array_unique($matches[0]) as $content) {
856
+
857
+ $row_action = array(
858
+ 'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
859
+ 'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
860
+ );
861
+ $source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
862
+ preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
863
+ $src = $matches[1];
864
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
865
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
866
+ $link_text = '';
867
+ $links_in_content[$src.'img'.$post->ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $post->ID, $src, $link_text, 'image', $status, $status_type);
868
+ }
869
+ }
870
+
871
+ global $wpdb;
872
+ $sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE source_id=%d AND type != %s", array($post->ID, "comment"));
873
+ $links = $wpdb->get_results($sql);
874
+ foreach ($links as $link) {
875
+ if (empty($links_in_content[$link->link_url.$link->type])) {
876
+ $wpdb->delete($wpdb->prefix . "wpms_links", array('id' => $link->id), array('%d'));
877
+ } else {
878
+ unset($links_in_content[$link->link_url.$link->type.$link->link_text]);
879
+ }
880
+ }
881
+
882
+ if (!empty($links_in_content)) {
883
+ foreach ($links_in_content as $link){
884
+ MetaSeo_Broken_Link_Table::wpms_insert_link($link, $wpdb);
885
+ }
886
+ }
887
+ }
888
+ }
889
+
890
+ public static function wpms_scan_link() {
891
+
892
+ global $wpdb, $_wp_column_headers;
893
+ $limit_comment = 10;
894
+ $limit_post = 1;
895
+
896
+ $where = array();
897
+ $post_type = isset($_REQUEST['post_type_filter']) ? $_REQUEST['post_type_filter'] : "";
898
+ if ($post_type == "-1") {
899
+ $post_type = "";
900
+ }
901
+
902
+ $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
903
+ unset($post_types['attachment']);
904
+ if (!empty($post_type) && !in_array($post_type, $post_types))
905
+ $post_type = '\'post\'';
906
+ else if (empty($post_type)) {
907
+ $post_type = "'" . implode("', '", $post_types) . "'";
908
+ } else {
909
+ $post_type = "'" . $post_type . "'";
910
+ }
911
+
912
+ $where[] = "post_type IN ($post_type)";
913
+ $states = get_post_stati(array('show_in_admin_all_list' => true));
914
+ $states['trash'] = 'trash';
915
+ $all_states = "'" . implode("', '", $states) . "'";
916
+
917
+ if (empty($_REQUEST['post_status'])) {
918
+ $where[] = "post_status IN ($all_states)";
919
+ } else {
920
+ $requested_state = $_REQUEST['post_status'];
921
+ if (in_array($requested_state, $states)) {
922
+ $where[] = "post_status IN ('$requested_state')";
923
+ } else {
924
+ $where[] = "post_status IN ($all_states)";
925
+ }
926
+ }
927
+
928
+ $total_comments = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "comments");
929
+ $total_posts = $wpdb->get_var("SELECT COUNT(*)"
930
+ . " FROM $wpdb->posts "
931
+ . " WHERE " . implode(' AND ', $where));
932
+
933
+ $total_link = (int)$total_comments + (int) $total_posts;
934
+ $percent_comment = 50;
935
+ $percent_post = 50;
936
+ if(!empty($total_comments)) $percent_comment = 50/$total_comments;
937
+ if($total_comments < $limit_comment) $percent_comment = 50;
938
+ if(!empty($total_posts)) $percent_post = 50/$total_posts;
939
+ if($total_posts < $limit_post) $percent_post = 50;
940
+
941
+ // scan link in comment
942
+ $comments = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "comments WHERE comment_author_url != '' AND comment_author_url NOT IN (SELECT link_url FROM " . $wpdb->prefix . "wpms_links WHERE type='comment') LIMIT $limit_comment");
943
+ $i = 0;
944
+ if (!empty($comments)) {
945
+ foreach ($comments as $comment) {
946
+ if (!empty($comment->comment_author_url)) {
947
+
948
+ $row_action = array(
949
+ 'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
950
+ 'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
951
+ );
952
+ $source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
953
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($comment->comment_author_url);
954
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
955
+ $coms = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $comment->comment_ID, $comment->comment_author_url, $comment->comment_author, 'comment', $status, $status_type);
956
+ MetaSeo_Broken_Link_Table::wpms_insert_link($coms, $wpdb);
957
+ $i++;
958
+ }
959
+ }
960
+ wp_send_json(array('status' => false, 'type' => 'limit' , 'percent' => $percent_comment));
961
+ }
962
+
963
+ // scan link in post
964
+ $j = 0;
965
+ $off_set = ($_POST['paged'] - 1) * $limit_post;
966
+ $query = "SELECT ID, post_title, post_excerpt , post_content ,post_name, post_type, post_status"
967
+ . " FROM $wpdb->posts "
968
+ . " WHERE " . implode(' AND ', $where) . "LIMIT $limit_post OFFSET $off_set";
969
+
970
+ $results = $wpdb->get_results($query);
971
+ if (empty($results))
972
+ wp_send_json(array('status' => true));
973
+
974
+ foreach ($results as $post) {
975
+ if ($post->post_excerpt != 'metaseo_404_page') {
976
+ $dom = new DOMDocument;
977
+ libxml_use_internal_errors(true);
978
+ if (isset($post->post_content) && $post->post_content != '') {
979
+ preg_match_all("#<a[^>]*>.*?</a>#si", $post->post_content, $matches, PREG_PATTERN_ORDER);
980
+ foreach (array_unique($matches[0]) as $i => $content) {
981
+ preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
982
+ $href = $matches[1];
983
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
984
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
985
+ $link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
986
+ $row_action = array(
987
+ 'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
988
+ 'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
989
+ );
990
+ $source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
991
+ $link_a = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $post->ID, $href, $link_text, 'url', $status, $status_type);
992
+ MetaSeo_Broken_Link_Table::wpms_insert_link($link_a, $wpdb);
993
+ }
994
+ preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
995
+ foreach (array_unique($matches[0]) as $content) {
996
+
997
+ $row_action = array(
998
+ 'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
999
+ 'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
1000
+ );
1001
+ $source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
1002
+ preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
1003
+ $src = $matches[1];
1004
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
1005
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
1006
+ $link_text = '';
1007
+ $link_sou = MetaSeo_Broken_Link_Table::get_result_link($source_link, $row_action, $post->ID, $src, $link_text, 'image', $status, $status_type);
1008
+ MetaSeo_Broken_Link_Table::wpms_insert_link($link_sou, $wpdb);
1009
+ }
1010
+ }
1011
+ }
1012
+ $j++;
1013
+ if ($j >= $limit_post) {
1014
+ wp_send_json(array('status' => false, 'type' => 'limit_post', 'paged' => $_POST['paged'] ,'percent' => $percent_post*count($results)));
1015
+ }
1016
+ }
1017
+ wp_send_json(array('status' => true));
1018
+ }
1019
+
1020
+ public static function wpms_insert_link($link, $wpdb) {
1021
+ $sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "wpms_links WHERE link_url=%s AND type=%s AND source_id=%d ", array($link['link_url'], $link['type'], $link['source_id']));
1022
+ $check = $wpdb->get_var($sql);
1023
+ if ($check == 0) {
1024
+ $columns = array(
1025
+ 'link_url' => $link['link_url'],
1026
+ 'link_final_url' => $link['link_final_url'],
1027
+ 'link_text' => $link['link_text'],
1028
+ 'source_id' => $link['source_id'],
1029
+ 'type' => $link['type'],
1030
+ 'status_code' => $link['status'],
1031
+ 'status_text' => ($link['status'] != 'Server Not Found') ? substr($link['status'], 9) : 'Server Not Found',
1032
+ 'broken_indexed' => 0,
1033
+ 'broken_internal' => 0,
1034
+ 'warning' => 0,
1035
+ 'dismissed' => 0,
1036
+ );
1037
+ if (isset($link['status_type']) && $link['status_type'] != 'ok') {
1038
+ $columns[$link['status_type']] = 1;
1039
+ }
1040
+
1041
+ $wpdb->insert(
1042
+ $wpdb->prefix . 'wpms_links', $columns
1043
+ );
1044
+ }
1045
+ }
1046
+
1047
+ public static function wpms_flush_link() {
1048
+ global $wpdb;
1049
+ if(isset($_POST['type']) && $_POST['type'] != 'none'){
1050
+ switch ($_POST['type']){
1051
+ case 'automaticaly_indexed':
1052
+ $wpdb->query(
1053
+ $wpdb->prepare(
1054
+ "
1055
+ DELETE FROM ".$wpdb->prefix . "wpms_links
1056
+ WHERE broken_indexed = %d AND link_url_redirect = %s
1057
+ " , array(1,'')
1058
+ )
1059
+ );
1060
+ break;
1061
+ case 'internal_broken_links':
1062
+ $wpdb->query(
1063
+ $wpdb->prepare(
1064
+ "
1065
+ DELETE FROM ".$wpdb->prefix . "wpms_links
1066
+ WHERE broken_internal = %d AND link_url_redirect = %s
1067
+ " , array(1,'')
1068
+ )
1069
+ );
1070
+ break;
1071
+ case 'all':
1072
+ $wpdb->query(
1073
+ $wpdb->prepare(
1074
+ "
1075
+ DELETE FROM ".$wpdb->prefix . "wpms_links
1076
+ WHERE (broken_internal = %d
1077
+ OR broken_indexed = %d) AND link_url_redirect = %s
1078
+ " , array(1,1,'')
1079
+ )
1080
+ );
1081
+
1082
+ break;
1083
+ }
1084
+ wp_send_json(true);
1085
+
1086
+ }
1087
+ wp_send_json(false);
1088
+ }
1089
+
1090
+ public static function wpms_update_link() {
1091
+
1092
+ if (isset($_POST['link_id'])) {
1093
+ global $wpdb;
1094
+ $sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($_POST['link_id']));
1095
+ $link_detail = $wpdb->get_row($sql);
1096
+ if (empty($link_detail))
1097
+ wp_send_json(false);
1098
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus(($_POST['new_link']));
1099
+ if ($status == 'Server Not Found') {
1100
+ $status_text = 'Server Not Found';
1101
+ } else {
1102
+ $status_text = substr($status, 9);
1103
+ }
1104
+
1105
+ $status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
1106
+
1107
+ if ($link_detail->type != '404_automaticaly') {
1108
+ $value = array('link_url' => ($_POST['new_link']),
1109
+ 'link_final_url' => '',
1110
+ 'link_url_redirect' => '',
1111
+ 'link_text' => stripcslashes($_POST['new_text']),
1112
+ 'status_code' => $status,
1113
+ 'status_text' => $status_text,
1114
+ 'broken_indexed' => 0,
1115
+ 'broken_internal' => 0,
1116
+ 'warning' => 0,
1117
+ 'dismissed' => 0,
1118
+ );
1119
+
1120
+ if (!preg_match("~^(?:f|ht)tps?://~i", $_POST['new_link'])) {
1121
+ $perlink = get_option('permalink_structure');
1122
+ if(empty($perlink)){
1123
+ $value['link_final_url'] = get_site_url().'/'.$_POST['new_link'];
1124
+ }else{
1125
+ $value['link_final_url'] = $perlink.'/'.$_POST['new_link'];
1126
+ }
1127
+ }else{
1128
+ $value['link_final_url'] = $_POST['new_link'];
1129
+ }
1130
+
1131
+ if (!empty($_POST['link_redirect']))
1132
+ $value['link_url_redirect'] = ($_POST['link_redirect']);
1133
+ if (isset($status_type) && $status_type != 'ok') {
1134
+ $value[$status_type] = 1;
1135
+ }
1136
+ } else {
1137
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus(($_POST['link_redirect']));
1138
+ if ($status == 'Server Not Found') {
1139
+ $status_text = 'Server Not Found';
1140
+ } else {
1141
+ $status_text = substr($status, 9);
1142
+ }
1143
+
1144
+ $value = array(
1145
+ 'link_url_redirect' => ($_POST['link_redirect']),
1146
+ 'status_code' => $status,
1147
+ 'status_text' => $status_text,
1148
+ 'broken_indexed' => 1
1149
+ );
1150
+ }
1151
+
1152
+ $wpdb->update(
1153
+ $wpdb->prefix . 'wpms_links', $value, array('ID' => $_POST['link_id'])
1154
+ );
1155
+
1156
+ switch ($link_detail->type) {
1157
+ case '404_automaticaly':
1158
+ wp_send_json(array('status' => true, 'type' => '404_automaticaly', 'status_text' => $status_text, 'new_link' => esc_url($_POST['new_link'])));
1159
+ break;
1160
+ case 'image':
1161
+ $post = get_post($link_detail->source_id);
1162
+ if(!empty($post)){
1163
+ $old_value = $post->post_content;
1164
+ $edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
1165
+ $my_post = array(
1166
+ 'ID' => $link_detail->source_id,
1167
+ 'post_content' => $edit_result['content']
1168
+ );
1169
+ remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
1170
+ wp_update_post($my_post);
1171
+ wp_send_json(array('status' => true, 'type' => 'image', 'status_text' => $status_text, 'new_link' => esc_url($edit_result['raw_url']) ));
1172
+ }
1173
+ break;
1174
+ case 'url':
1175
+ $post = get_post($link_detail->source_id);
1176
+ if(!empty($post)){
1177
+ $old_value = $post->post_content;
1178
+ if(isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == ''){
1179
+ $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
1180
+ $new_text = '';
1181
+ }else{
1182
+ $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
1183
+ $new_text = strip_tags($edit_result['link_text']);
1184
+ }
1185
+
1186
+ $my_post = array(
1187
+ 'ID' => $link_detail->source_id,
1188
+ 'post_content' => $edit_result['content']
1189
+ );
1190
+ remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
1191
+ wp_update_post($my_post);
1192
+ wp_send_json(array('status' => true, 'type' => 'url', 'status_text' => $status_text, 'new_link' => $edit_result['raw_url'], 'new_text' => $new_text ));
1193
+ }
1194
+
1195
+ break;
1196
+ case 'comment':
1197
+ wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => $_POST['new_link']));
1198
+ wp_send_json(array('status' => true, 'type' => 'orther', 'status_text' => $status_text, 'new_link' => $_POST['new_link']));
1199
+ break;
1200
+ }
1201
+ }
1202
+ wp_send_json(false);
1203
+ }
1204
+
1205
+ public static function wpms_unlink() {
1206
+ if (isset($_POST['link_id'])) {
1207
+ global $wpdb;
1208
+ $sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($_POST['link_id']));
1209
+ $link_detail = $wpdb->get_row($sql);
1210
+ if (empty($link_detail))
1211
+ wp_send_json(false);
1212
+ $wpdb->delete($wpdb->prefix . 'wpms_links', array('id' => $_POST['link_id']));
1213
+ switch ($link_detail->type) {
1214
+ case '404_automaticaly':
1215
+ wp_send_json(true);
1216
+ break;
1217
+ case 'image':
1218
+ $post = get_post($link_detail->source_id);
1219
+ if(!empty($post)){
1220
+ $old_value = $post->post_content;
1221
+ $new_content = MetaSeo_Broken_Link_Table::wpms_unlink_img($old_value, $link_detail->link_url);
1222
+ remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
1223
+ $my_post = array(
1224
+ 'ID' => $link_detail->source_id,
1225
+ 'post_content' => $new_content
1226
+ );
1227
+ wp_update_post($my_post);
1228
+ }
1229
+ wp_send_json(true);
1230
+ break;
1231
+ case 'url':
1232
+ $post = get_post($link_detail->source_id);
1233
+ if(!empty($post)){
1234
+ $old_value = $post->post_content;
1235
+ $new_content = MetaSeo_Broken_Link_Table::wpms_unlink_html($old_value, $link_detail->link_url);
1236
+ remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
1237
+ $my_post = array(
1238
+ 'ID' => $link_detail->source_id,
1239
+ 'post_content' => $new_content
1240
+ );
1241
+ wp_update_post($my_post);
1242
+ }
1243
+ wp_send_json(true);
1244
+ break;
1245
+ case 'comment':
1246
+ wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => ''));
1247
+ wp_send_json(true);
1248
+ break;
1249
+ }
1250
+ }
1251
+ wp_send_json(false);
1252
+ }
1253
+
1254
+ public static function edit_linkimg($content, $new_url, $old_url) {
1255
+ self::$old_url = $old_url;
1256
+ self::$new_url = htmlentities($new_url);
1257
+ $content = preg_replace_callback(self::$img_pattern, array('MetaSeo_Broken_Link_Table', 'editimg_callback'), $content);
1258
+
1259
+ return array(
1260
+ 'content' => $content,
1261
+ 'raw_url' => self::$new_url,
1262
+ );
1263
+ }
1264
+
1265
+ public static function editimg_callback($matches) {
1266
+ $url = $matches[3];
1267
+ if (($url) == self::$old_url) {
1268
+ return $matches[1] . '"' . self::$new_url . '"' . $matches[4];
1269
+ } else {
1270
+ return $matches[0];
1271
+ }
1272
+ }
1273
+
1274
+ public static function wpms_unlink_img($content, $url){
1275
+ self::$old_url = $url; //used by the callback
1276
+ $content = preg_replace_callback(self::$img_pattern, array('MetaSeo_Broken_Link_Table', 'wpms_unlink_img_callback'), $content);
1277
+ return $content;
1278
+ }
1279
+
1280
+ public static function wpms_unlink_img_callback($matches){
1281
+ $url = $matches[3];
1282
+ if (($url) == self::$old_url){
1283
+ return ''; //Completely remove the IMG tag
1284
+ } else {
1285
+ return $matches[0]; //return the image unchanged
1286
+ }
1287
+ }
1288
+
1289
+ public static function wpms_unlink_html($content, $url){
1290
+ $args = array(
1291
+ 'old_url' => $url,
1292
+ );
1293
+
1294
+ $content = MetaSeo_Broken_Link_Table::wpms_multi_edit($content, array('MetaSeo_Broken_Link_Table', 'wpms_unlink_html_callback'), $args);
1295
+
1296
+ return $content;
1297
+ }
1298
+
1299
+ public static function wpms_unlink_html_callback($link, $params){
1300
+ if ($link['href'] != $params['old_url']){
1301
+ return $link['#raw'];
1302
+ }
1303
+
1304
+ return $link['#link_text'];
1305
+ }
1306
+
1307
+ public static function wpms_edit_linkhtml($content, $new_url, $old_url, $new_text = null) {
1308
+ //Save the old & new URLs for use in the edit callback.
1309
+ $args = array(
1310
+ 'old_url' => $old_url,
1311
+ 'new_url' => $new_url,
1312
+ 'new_text' => $new_text,
1313
+ );
1314
+
1315
+ //Find all links and replace those that match $old_url.
1316
+ $content = MetaSeo_Broken_Link_Table::wpms_multi_edit($content, array('MetaSeo_Broken_Link_Table', 'wpms_edithtml_callback'), $args);
1317
+
1318
+ $result = array(
1319
+ 'content' => $content,
1320
+ 'raw_url' => $new_url,
1321
+ );
1322
+ if (isset($new_text)) {
1323
+ $result['link_text'] = $new_text;
1324
+ }
1325
+ return $result;
1326
+ }
1327
+
1328
+ public static function wpms_edithtml_callback($link, $params) {
1329
+ if ($link['href'] == $params['old_url']) {
1330
+ $modified = array(
1331
+ 'href' => $params['new_url'],
1332
+ );
1333
+ if (isset($params['new_text'])) {
1334
+ $modified['#link_text'] = $params['new_text'];
1335
+ }
1336
+ return $modified;
1337
+ } else {
1338
+ return $link['#raw'];
1339
+ }
1340
+ }
1341
+
1342
+ public static function wpms_edit_callback($link, $info) {
1343
+ list($callback, $extra) = $info;
1344
+
1345
+ //Prepare arguments for the callback
1346
+ $params = array($link);
1347
+ if (isset($extra)) {
1348
+ $params[] = $extra;
1349
+ }
1350
+
1351
+ $new_link = call_user_func_array($callback, $params);
1352
+
1353
+ if (is_array($new_link)) {
1354
+ $link = array_merge($link, $new_link);
1355
+ } elseif (is_string($new_link)) {
1356
+ $link['#new_raw'] = $new_link;
1357
+ }
1358
+
1359
+ return $link;
1360
+ }
1361
+
1362
+ public static function wpms_multi_edit($content, $callback, $extra = null) {
1363
+ //Just reuse map() + a little helper func. to apply the callback to all links and get modified links
1364
+ $modified_links = MetaSeo_Broken_Link_Table::map($content, array('MetaSeo_Broken_Link_Table', 'wpms_edit_callback'), array($callback, $extra));
1365
+ //Replace each old link with the modified one
1366
+ $offset = 0;
1367
+ foreach ($modified_links as $link) {
1368
+ if (isset($link['#new_raw'])) {
1369
+ $new_html = $link['#new_raw'];
1370
+ } else {
1371
+ //Assemble the new link tag
1372
+ $new_html = '<a';
1373
+ foreach ($link as $name => $value) {
1374
+ //Skip special keys like '#raw' and '#offset'
1375
+ if (substr($name, 0, 1) == '#') {
1376
+ continue;
1377
+ }
1378
+
1379
+ $new_html .= sprintf(' %s="%s"', $name, esc_attr($value));
1380
+ }
1381
+ $new_html .= '>' . $link['#link_text'] . '</a>';
1382
+ }
1383
+
1384
+ $content = substr_replace($content, $new_html, $link['#offset'] + $offset, strlen($link['#raw']));
1385
+ //Update the replacement offset
1386
+ $offset += ( strlen($new_html) - strlen($link['#raw']) );
1387
+ }
1388
+
1389
+ return $content;
1390
+ }
1391
+
1392
+ public static function extract_tags($html, $tag, $selfclosing = null, $return_the_entire_tag = false, $charset = 'ISO-8859-1') {
1393
+
1394
+ if (is_array($tag)) {
1395
+ $tag = implode('|', $tag);
1396
+ }
1397
+
1398
+ $selfclosing_tags = array('area', 'base', 'basefont', 'br', 'hr', 'input', 'img', 'link', 'meta', 'col', 'param');
1399
+ if (is_null($selfclosing)) {
1400
+ $selfclosing = in_array($tag, $selfclosing_tags);
1401
+ }
1402
+
1403
+ if ($selfclosing) {
1404
+ $tag_pattern = '@<(?P<tag>' . $tag . ') # <tag
1405
+ (?P<attributes>\s[^>]+)? # attributes, if any
1406
+ \s*/?> # /> or just >, being lenient here
1407
+ @xsi';
1408
+ } else {
1409
+ $tag_pattern = '@<(?P<tag>' . $tag . ') # <tag
1410
+ (?P<attributes>\s[^>]+)? # attributes, if any
1411
+ \s*> # >
1412
+ (?P<contents>.*?) # tag contents
1413
+ </(?P=tag)> # the closing </tag>
1414
+ @xsi';
1415
+ }
1416
+
1417
+ $attribute_pattern = '@
1418
+ (?P<name>\w+) # attribute name
1419
+ \s*=\s*
1420
+ (
1421
+ (?P<quote>[\"\'])(?P<value_quoted>.*?)(?P=quote) # a quoted value
1422
+ | # or
1423
+ (?P<value_unquoted>[^\s"\']+?)(?:\s+|$) # an unquoted value (terminated by whitespace or EOF)
1424
+ )
1425
+ @xsi';
1426
+
1427
+ //Find all tags
1428
+ if (!preg_match_all($tag_pattern, $html, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
1429
+ //Return an empty array if we didn't find anything
1430
+ return array();
1431
+ }
1432
+
1433
+ $tags = array();
1434
+ foreach ($matches as $match) {
1435
+
1436
+ //Parse tag attributes, if any
1437
+ $attributes = array();
1438
+ if (!empty($match['attributes'][0])) {
1439
+
1440
+ if (preg_match_all($attribute_pattern, $match['attributes'][0], $attribute_data, PREG_SET_ORDER)) {
1441
+ //Turn the attribute data into a name->value array
1442
+ foreach ($attribute_data as $attr) {
1443
+ if (!empty($attr['value_quoted'])) {
1444
+ $value = $attr['value_quoted'];
1445
+ } else if (!empty($attr['value_unquoted'])) {
1446
+ $value = $attr['value_unquoted'];
1447
+ } else {
1448
+ $value = '';
1449
+ }
1450
+
1451
+ //Passing the value through html_entity_decode is handy when you want
1452
+ //to extract link URLs or something like that. You might want to remove
1453
+ //or modify this call if it doesn't fit your situation.
1454
+ $value = html_entity_decode($value, ENT_QUOTES, $charset);
1455
+
1456
+ $attributes[$attr['name']] = $value;
1457
+ }
1458
+ }
1459
+ }
1460
+
1461
+ $tag = array(
1462
+ 'tag_name' => $match['tag'][0],
1463
+ 'offset' => $match[0][1],
1464
+ 'contents' => !empty($match['contents']) ? $match['contents'][0] : '', //empty for self-closing tags
1465
+ 'attributes' => $attributes,
1466
+ );
1467
+ if ($return_the_entire_tag) {
1468
+ $tag['full_tag'] = $match[0][0];
1469
+ }
1470
+
1471
+ $tags[] = $tag;
1472
+ }
1473
+
1474
+ return $tags;
1475
+ }
1476
+
1477
+ public static function map($content, $callback, $extra = null) {
1478
+ $results = array();
1479
+
1480
+ //Find all links
1481
+ $links = MetaSeo_Broken_Link_Table::extract_tags($content, 'a', false, true);
1482
+
1483
+ //Iterate over the links and apply $callback to each
1484
+ foreach ($links as $link) {
1485
+
1486
+ //Massage the found link into a form required for the callback function
1487
+ $param = $link['attributes'];
1488
+ $param = array_merge(
1489
+ $param, array(
1490
+ '#raw' => $link['full_tag'],
1491
+ '#offset' => $link['offset'],
1492
+ '#link_text' => $link['contents'],
1493
+ 'href' => isset($link['attributes']['href']) ? $link['attributes']['href'] : '',
1494
+ )
1495
+ );
1496
+
1497
+ //Prepare arguments for the callback
1498
+ $params = array($param);
1499
+ if (isset($extra)) {
1500
+ $params[] = $extra;
1501
+ }
1502
+
1503
+ //Execute & store :)
1504
+ $results[] = call_user_func_array($callback, $params);
1505
+ }
1506
+
1507
+ return $results;
1508
+ }
1509
+
1510
+ public static function wpms_recheck_link() {
1511
+ if (isset($_POST['link_id'])) {
1512
+ global $wpdb;
1513
+ $linkId = $_POST['link_id'];
1514
+ $sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($linkId));
1515
+ $link = $wpdb->get_row($sql);
1516
+ if (!empty($link)) {
1517
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus(($link->link_url));
1518
+ if ($status == 'Server Not Found') {
1519
+ $status_text = 'Server Not Found';
1520
+ } else {
1521
+ $status_text = substr($status, 9);
1522
+ }
1523
+
1524
+ if ($link->type == '404_automaticaly') {
1525
+ if (((int) substr($status, 9, 3) >= 301 && (int) substr($status, 9, 3) <= 304) || ((int) substr($status, 9, 3) >= 400 && (int) substr($status, 9, 3) <= 503 && (int) substr($status, 9, 3) != 401) || $status == 'Server Not Found') {
1526
+ $type = array('broken_indexed' => 1, 'broken_internal' => 0);
1527
+ } else {
1528
+ $type = array('broken_indexed' => 0, 'broken_internal' => 0);
1529
+ }
1530
+ } else {
1531
+ if (((int) substr($status, 9, 3) >= 301 && (int) substr($status, 9, 3) <= 304) || ((int) substr($status, 9, 3) >= 400 && (int) substr($status, 9, 3) <= 503 && (int) substr($status, 9, 3) != 401) || $status == 'Server Not Found') {
1532
+ $type = array('broken_internal' => 1, 'broken_indexed' => 0);
1533
+ } else {
1534
+ $type = array('broken_internal' => 0, 'broken_indexed' => 0);
1535
+ }
1536
+ }
1537
+
1538
+ $value = array(
1539
+ 'status_code' => $status,
1540
+ 'status_text' => $status_text,
1541
+ 'broken_indexed' => $type['broken_indexed'],
1542
+ 'broken_internal' => $type['broken_internal']
1543
+ );
1544
+
1545
+ $wpdb->update(
1546
+ $wpdb->prefix . 'wpms_links', $value, array('ID' => $_POST['link_id'])
1547
+ );
1548
+ wp_send_json(array('status' => true, 'status_text' => $status_text));
1549
+ }
1550
+ wp_send_json(array('status' => false));
1551
+ }
1552
+ }
1553
+
1554
+ }
inc/class.metaseo-dashboard.php CHANGED
@@ -279,4 +279,19 @@ class MetaSeo_Dashboard {
279
  $results['new_content'] = array($count_new , array(count($newcontent->get_posts()) , count($mposts)));
280
  return $results;
281
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  }
279
  $results['new_content'] = array($count_new , array(count($newcontent->get_posts()) , count($mposts)));
280
  return $results;
281
  }
282
+
283
+ function get_404_link(){
284
+ global $wpdb;
285
+ $sql = $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix. "wpms_links WHERE (broken_internal=%d OR broken_indexed=%d) ",array(1, 1) );
286
+ $count_404 = $wpdb->get_var($sql);
287
+
288
+ $sql = $wpdb->prepare( "SELECT COUNT(*) FROM ".$wpdb->prefix. "wpms_links WHERE link_url_redirect != '' AND (broken_internal=%d OR broken_indexed=%d) ",array(1, 1) );
289
+ $count_404_redirected = $wpdb->get_var($sql);
290
+ if($count_404 != 0){
291
+ $percent = ceil($count_404_redirected/$count_404*100);
292
+ }else{
293
+ $percent = 100;
294
+ }
295
+ return array('count_404' => $count_404 , 'count_404_redirected' => $count_404_redirected , 'percent' => $percent);
296
+ }
297
  }
inc/class.metaseo-image-list-table.php CHANGED
@@ -979,7 +979,6 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
979
  global $wpdb;
980
  $response = new stdClass();
981
  $response->updated = false;
982
-
983
  if(!empty($_POST['addition']['meta_key'])){
984
  self::updateImgMeta_call_back($_POST['addition']);
985
  }
979
  global $wpdb;
980
  $response = new stdClass();
981
  $response->updated = false;
 
982
  if(!empty($_POST['addition']['meta_key'])){
983
  self::updateImgMeta_call_back($_POST['addition']);
984
  }
inc/class.metaseo-metabox.php CHANGED
@@ -317,7 +317,7 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
317
  }
318
 
319
  function metaseo_create_field($data_title,$alt,$dashicon,$label,$value_hidden){
320
- $output = '<div class="metaseo_analysis metaseo_tool 123" data-title="'.$data_title.'" alt="'.$alt.'"><div class="metaseo-dashicons dashicons-before '.$dashicon.'"></div>'.$label.'</div>';
321
  $output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms['.$data_title.']" value="'.$value_hidden.'">';
322
  return $output;
323
  }
@@ -341,14 +341,14 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
341
  }
342
 
343
  if($test || (!empty($meta_analysis) && !empty($meta_analysis['heading_title']))){
344
- $output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'dashicons-yes',__('Page title word in content heading','wp-meta-seo'),1);
345
  $this->perc_score++;
346
  }else{
347
- $output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'icons-mwarning',__('Page title word in content heading','wp-meta-seo'),0);
348
  }
349
 
350
  }else{
351
- $output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'dashicons-yes',__('Page title word in content heading','wp-meta-seo'),1);
352
  $this->perc_score++;
353
  }
354
  return $output;
@@ -370,10 +370,10 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
370
  }
371
 
372
  if($test1 || (!empty($meta_analysis) && !empty($meta_analysis['content_title']))){
373
- $output = $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'dashicons-yes',__('Page title word in content','wp-meta-seo'),1);
374
  $this->perc_score++;
375
  }else{
376
- $output = $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'icons-mwarning',__('Page title word in content','wp-meta-seo'),0);
377
  }
378
 
379
  return $output;
@@ -384,10 +384,10 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
384
  $info = pathinfo($pageurl);
385
 
386
  if($info['filename'] == sanitize_title($post->post_title) || (!empty($meta_analysis) && !empty($meta_analysis['pageurl']))){
387
- $output = $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'dashicons-yes',__('Page url matches with page title','wp-meta-seo'),1);
388
  $this->perc_score++;
389
  }else{
390
- $output = $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'icons-mwarning',__('Page url matches with page title','wp-meta-seo'),0);
391
  }
392
 
393
  return $output;
@@ -395,27 +395,27 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
395
 
396
  function metaseo_check_metatitle($meta_title,$tooltip_page,$meta_analysis){
397
  if(($meta_title != '' && strlen($meta_title) <= self::$meta_title_length) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle'])) ){
398
- $output = $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'dashicons-yes',__('Meta title filled','wp-meta-seo'),1);
399
  $this->perc_score++;
400
  }else{
401
- $output = $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'icons-mwarning',__('Meta title filled','wp-meta-seo'),0);
402
  }
403
  return $output;
404
  }
405
 
406
  function metaseo_check_metadesc($meta_desc,$tooltip_page,$meta_analysis){
407
  if(($meta_desc != '' && strlen($meta_desc) <= self::$meta_length) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc'])) ){
408
- $output = $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'dashicons-yes',__('Meta description filled','wp-meta-seo'),1);
409
  $this->perc_score++;
410
  }else{
411
- $output = $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'icons-mwarning',__('Meta description filled','wp-meta-seo'),0);
412
  }
413
  return $output;
414
  }
415
 
416
  function metaseo_check_imageresize($content,$tooltip_page,$meta_analysis){
417
  if($content == '') {
418
- $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'dashicons-yes',__('Wrong image resize','wp-meta-seo'),1);
419
  $this->perc_score++;
420
  return $output;
421
  }
@@ -439,21 +439,21 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
439
  }
440
 
441
  if($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgresize']))){
442
- $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'dashicons-yes',__('Wrong image resize','wp-meta-seo'),1);
443
  $this->perc_score++;
444
  }else{
445
- $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'icons-mwarning',__('Wrong image resize','wp-meta-seo'),0);
446
  }
447
 
448
  }else{
449
- $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'icons-mwarning',__('Wrong image resize','wp-meta-seo'),0);
450
  }
451
  return $output;
452
  }
453
 
454
  function metaseo_check_imagealt($content,$tooltip_page,$meta_analysis){
455
  if($content == '') {
456
- $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'dashicons-yes',__('Image have meta title or alt','wp-meta-seo'),1);
457
  $this->perc_score++;
458
  return $output;
459
  }
@@ -472,14 +472,14 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
472
  }
473
 
474
  if($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgalt']))){
475
- $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'dashicons-yes',__('Image have meta title or alt','wp-meta-seo'),1);
476
  $this->perc_score++;
477
  }else{
478
- $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'icons-mwarning',__('Image have meta title or alt','wp-meta-seo'),0);
479
  }
480
 
481
  }else{
482
- $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'icons-mwarning',__('Image have meta title or alt','wp-meta-seo'),0);
483
  }
484
  return $output;
485
  }
@@ -554,6 +554,7 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
554
  }
555
 
556
  function do_meta_box($meta_field_def, $key = '') {
 
557
  $content = '';
558
  $esc_form_key = esc_attr(self::$form_prefix . $key);
559
  $post = $this->get_metabox_post();
@@ -679,7 +680,7 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
679
 
680
  $help = '';
681
  if (isset($meta_field_def['help']) && $meta_field_def['help'] !== '') {
682
- $help = '<img src="' . plugins_url('img/metaseo_sms.png', WPMSEO_FILE) . '" class="alignright metaseo_help" id="' . esc_attr($key . 'help') . '" alt="' . esc_attr($meta_field_def['help']) . '" />';
683
  }
684
 
685
  $html = '
317
  }
318
 
319
  function metaseo_create_field($data_title,$alt,$dashicon,$label,$value_hidden){
320
+ $output = '<div class="metaseo_analysis metaseo_tool" data-title="'.$data_title.'" alt="'.$alt.'"><i class="metaseo-dashicons material-icons dashicons-before" style="'.($dashicon == 'done'?'color:#46B450':'color:#FFB900').'">'.$dashicon.'</i>'.$label.'</div>';
321
  $output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms['.$data_title.']" value="'.$value_hidden.'">';
322
  return $output;
323
  }
341
  }
342
 
343
  if($test || (!empty($meta_analysis) && !empty($meta_analysis['heading_title']))){
344
+ $output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'done',__('Page title word in content heading','wp-meta-seo'),1);
345
  $this->perc_score++;
346
  }else{
347
+ $output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'warning',__('Page title word in content heading','wp-meta-seo'),0);
348
  }
349
 
350
  }else{
351
+ $output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'done',__('Page title word in content heading','wp-meta-seo'),1);
352
  $this->perc_score++;
353
  }
354
  return $output;
370
  }
371
 
372
  if($test1 || (!empty($meta_analysis) && !empty($meta_analysis['content_title']))){
373
+ $output = $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'done',__('Page title word in content','wp-meta-seo'),1);
374
  $this->perc_score++;
375
  }else{
376
+ $output = $this->metaseo_create_field('content_title',$tooltip_page['title_in_content'],'warning',__('Page title word in content','wp-meta-seo'),0);
377
  }
378
 
379
  return $output;
384
  $info = pathinfo($pageurl);
385
 
386
  if($info['filename'] == sanitize_title($post->post_title) || (!empty($meta_analysis) && !empty($meta_analysis['pageurl']))){
387
+ $output = $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'done',__('Page url matches with page title','wp-meta-seo'),1);
388
  $this->perc_score++;
389
  }else{
390
+ $output = $this->metaseo_create_field('pageurl',$tooltip_page['page_url'],'warning',__('Page url matches with page title','wp-meta-seo'),0);
391
  }
392
 
393
  return $output;
395
 
396
  function metaseo_check_metatitle($meta_title,$tooltip_page,$meta_analysis){
397
  if(($meta_title != '' && strlen($meta_title) <= self::$meta_title_length) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle'])) ){
398
+ $output = $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'done',__('Meta title filled','wp-meta-seo'),1);
399
  $this->perc_score++;
400
  }else{
401
+ $output = $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'warning',__('Meta title filled','wp-meta-seo'),0);
402
  }
403
  return $output;
404
  }
405
 
406
  function metaseo_check_metadesc($meta_desc,$tooltip_page,$meta_analysis){
407
  if(($meta_desc != '' && strlen($meta_desc) <= self::$meta_length) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc'])) ){
408
+ $output = $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'done',__('Meta description filled','wp-meta-seo'),1);
409
  $this->perc_score++;
410
  }else{
411
+ $output = $this->metaseo_create_field('metadesc',$tooltip_page['meta_desc'],'warning',__('Meta description filled','wp-meta-seo'),0);
412
  }
413
  return $output;
414
  }
415
 
416
  function metaseo_check_imageresize($content,$tooltip_page,$meta_analysis){
417
  if($content == '') {
418
+ $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'done',__('Wrong image resize','wp-meta-seo'),1);
419
  $this->perc_score++;
420
  return $output;
421
  }
439
  }
440
 
441
  if($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgresize']))){
442
+ $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'done',__('Wrong image resize','wp-meta-seo'),1);
443
  $this->perc_score++;
444
  }else{
445
+ $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'warning',__('Wrong image resize','wp-meta-seo'),0);
446
  }
447
 
448
  }else{
449
+ $output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'warning',__('Wrong image resize','wp-meta-seo'),0);
450
  }
451
  return $output;
452
  }
453
 
454
  function metaseo_check_imagealt($content,$tooltip_page,$meta_analysis){
455
  if($content == '') {
456
+ $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'done',__('Image have meta title or alt','wp-meta-seo'),1);
457
  $this->perc_score++;
458
  return $output;
459
  }
472
  }
473
 
474
  if($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgalt']))){
475
+ $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'done',__('Image have meta title or alt','wp-meta-seo'),1);
476
  $this->perc_score++;
477
  }else{
478
+ $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'warning',__('Image have meta title or alt','wp-meta-seo'),0);
479
  }
480
 
481
  }else{
482
+ $output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'warning',__('Image have meta title or alt','wp-meta-seo'),0);
483
  }
484
  return $output;
485
  }
554
  }
555
 
556
  function do_meta_box($meta_field_def, $key = '') {
557
+ wp_enqueue_style('metaseo-google-icon');
558
  $content = '';
559
  $esc_form_key = esc_attr(self::$form_prefix . $key);
560
  $post = $this->get_metabox_post();
680
 
681
  $help = '';
682
  if (isset($meta_field_def['help']) && $meta_field_def['help'] !== '') {
683
+ $help = '<i class="material-icons alignright metaseo_help" id="' . esc_attr($key . 'help') . '" alt="' . esc_attr($meta_field_def['help']) . '" style="color:#32373C">chat_bubble</i>';
684
  }
685
 
686
  $html = '
inc/class.wp-metaseo.php CHANGED
@@ -37,6 +37,8 @@ class WpMetaSeo {
37
  wp_die('<p>The <strong>WP Meta SEO</strong> plugin requires WordPress ' . WPMETASEO_MINIMUM_WP_VERSION . ' or higher.</p>', 'Plugin Activation Error', array('response' => 200, 'back_link' => TRUE));
38
  }
39
 
 
 
40
  //Set two param as flags that determine whether show import meta data from other SEO plugin button or not to 0
41
  update_option('_aio_import_notice_flag', 0);
42
  update_option('_yoast_import_notice_flag', 0);
37
  wp_die('<p>The <strong>WP Meta SEO</strong> plugin requires WordPress ' . WPMETASEO_MINIMUM_WP_VERSION . ' or higher.</p>', 'Plugin Activation Error', array('response' => 200, 'back_link' => TRUE));
38
  }
39
 
40
+
41
+ global $wpdb;
42
  //Set two param as flags that determine whether show import meta data from other SEO plugin button or not to 0
43
  update_option('_aio_import_notice_flag', 0);
44
  update_option('_yoast_import_notice_flag', 0);
inc/pages/content-meta.php CHANGED
@@ -21,7 +21,7 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
21
  <div class="wrap seo_extended_table_page">
22
  <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
23
 
24
- <?php echo '<h2>' . __('Content Meta', 'wp-meta-seo') . '</h2>'; ?>
25
 
26
  <form id="wp-seo-meta-form" action="" method="post">
27
  <?php
21
  <div class="wrap seo_extended_table_page">
22
  <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
23
 
24
+ <?php echo '<h1>' . __('Content Meta', 'wp-meta-seo') . '</h1>'; ?>
25
 
26
  <form id="wp-seo-meta-form" action="" method="post">
27
  <?php
inc/pages/dashboard.php CHANGED
@@ -3,11 +3,15 @@ if (!class_exists('MetaSeo_Dashboard')) {
3
  require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-dashboard.php' );
4
  }
5
 
 
 
 
6
  $site_name = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', get_site_url());
7
  //$site_name = 'testdev-united.com';
8
  $url = 'http://www.alexa.com/siteinfo/' . $site_name;
9
  $dashboard = new MetaSeo_Dashboard();
10
  $results = $dashboard->evolutive_dashboard();
 
11
  $results_image = $dashboard->moptimizationChecking();
12
  if(!empty($results_image['imgs_statis'][1])){
13
  $percent_iresizing = ceil($results_image['imgs_statis'][0]/$results_image['imgs_statis'][1]*100);
@@ -180,6 +184,28 @@ if(!empty($results_image['imgs_metas_statis'][1])){
180
  </div>
181
  </div>
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  </div>
184
  </div>
185
 
3
  require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-dashboard.php' );
4
  }
5
 
6
+ wp_enqueue_style('m-style-qtip');
7
+ wp_enqueue_script('jquery-qtip');
8
+
9
  $site_name = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', get_site_url());
10
  //$site_name = 'testdev-united.com';
11
  $url = 'http://www.alexa.com/siteinfo/' . $site_name;
12
  $dashboard = new MetaSeo_Dashboard();
13
  $results = $dashboard->evolutive_dashboard();
14
+ $link_errors = $dashboard->get_404_link();
15
  $results_image = $dashboard->moptimizationChecking();
16
  if(!empty($results_image['imgs_statis'][1])){
17
  $percent_iresizing = ceil($results_image['imgs_statis'][0]/$results_image['imgs_statis'][1]*100);
184
  </div>
185
  </div>
186
 
187
+ <div class="col-sm-6 metaseo_tool" alt="<?php _e('A website with a bunch of 404 errors doesn’t provide a good user experience, which is significantly important in content marketing and SEO. We recommend to use our internal broken link checker and redirect tool to fix all the 404 error you can periodically.','wp-meta-seo') ?>">
188
+ <div class="panel panel-updates">
189
+ <div class="panel-body">
190
+ <div class="row">
191
+ <div class="col-xs-7 col-lg-8">
192
+ <h4 class="panel-title text-success"><?php _e('404 ERRORS','wp-meta-seo') ?></h4>
193
+ <h3><?php echo $link_errors['percent'].'%' ?></h3>
194
+ <div class="progress">
195
+ <div style="width: <?php echo $link_errors['percent'].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $link_errors['percent'] ?>" role="progressbar" class="progress-bar progress-bar-success">
196
+ <span class="sr-only"><?php echo $link_errors['percent'].'%' ?> Complete (success)</span>
197
+ </div>
198
+ </div>
199
+ <p><?php _e('Redirected 404 errors','wp-meta-seo') ?>: <?php echo $link_errors['count_404_redirected'].'/'.$link_errors['count_404'] ?></p>
200
+ </div>
201
+ <div class="col-xs-5 col-lg-4 text-right">
202
+ <input type="text" value="<?php echo $link_errors['percent'] ?>" class="dial-success">
203
+ </div>
204
+ </div>
205
+ </div>
206
+ </div>
207
+ </div>
208
+
209
  </div>
210
  </div>
211
 
inc/pages/image-meta.php CHANGED
@@ -20,7 +20,7 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
20
  <div class="wrap seo_extended_table_page">
21
  <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
22
 
23
- <?php echo '<h2>' . __('Image Meta', 'wp-meta-seo') . '</h2>'; ?>
24
 
25
  <form id="wp-seo-meta-form" action="" method="post">
26
 
20
  <div class="wrap seo_extended_table_page">
21
  <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
22
 
23
+ <?php echo '<h1>' . __('Image Meta', 'wp-meta-seo') . '</h1>'; ?>
24
 
25
  <form id="wp-seo-meta-form" action="" method="post">
26
 
inc/pages/link-meta.php CHANGED
@@ -20,7 +20,7 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
20
  <div class="wrap seo_extended_table_page">
21
  <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
22
 
23
- <?php echo '<h2>' . __('Link Meta', 'wp-meta-seo') . '</h2>'; ?>
24
 
25
  <form id="wp-seo-meta-form" action="" method="post">
26
 
20
  <div class="wrap seo_extended_table_page">
21
  <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
22
 
23
+ <?php echo '<h1>' . __('Link Meta', 'wp-meta-seo') . '</h1>'; ?>
24
 
25
  <form id="wp-seo-meta-form" action="" method="post">
26
 
inc/pages/metaseo-broken-link.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Meta image
4
+ */
5
+
6
+ if (!class_exists('MetaSeo_Broken_Link_Table')) {
7
+ require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-broken-link-table.php' );
8
+ }
9
+ wp_enqueue_style('metaseo-google-icon');
10
+ wp_enqueue_style('m-style-qtip');
11
+ wp_enqueue_script('jquery-qtip');
12
+
13
+ $metaseo_list_table = new MetaSeo_Broken_Link_Table();
14
+ $metaseo_list_table->process_action();
15
+ $metaseo_list_table->prepare_items();
16
+ $a = json_encode($metaseo_list_table->items);
17
+ if (!empty($_REQUEST['_wp_http_referer'])) {
18
+ wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
19
+ exit;
20
+ }
21
+ ?>
22
+
23
+ <div class="wrap broken_link_table seo_extended_table_page">
24
+ <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
25
+
26
+ <?php echo '<h1>' . __('404 & Redirects', 'wp-meta-seo') . '</h1>'; ?>
27
+ <form id="wp-seo-meta-form" action="" method="post">
28
+ <?php $metaseo_list_table->search_box1(); ?>
29
+
30
+ <?php $metaseo_list_table->display(); ?>
31
+ </form>
32
+
33
+ </div>
34
+ <script type="text/javascript">
35
+ jQuery(document).ready(function ($) {
36
+ var correctedURL;
37
+ $('.wpms-link-url-field').on('keyup',function(){
38
+ var url = $.trim( $(this).val() );
39
+ if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
40
+ $(this).val( 'http://' + url );
41
+ correctedURL = url;
42
+ }
43
+ });
44
+
45
+ $('.wpms_scan_link').on('click',function(){
46
+ var $this = $(this);
47
+ $.ajax({
48
+ url: ajaxurl,
49
+ method: 'POST',
50
+ dataType: 'json',
51
+ data: {
52
+ 'action': 'wpms_scan_link',
53
+ 'paged' : $this.data('paged')
54
+ },
55
+ success: function (res) {
56
+ if(res.status == false){
57
+
58
+ if(res.type == 'limit'){
59
+ var wpmf_process = $('.wpmf_process').data('w');
60
+ var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
61
+ if(wpmf_process_new > 100) wpmf_process_new = 100;
62
+ $('.wpmf_process').data('w' , wpmf_process_new);
63
+ $('.wpmf_process').css('width' , wpmf_process_new +'%').show();
64
+ $this.click();
65
+ }else if(res.type == 'limit_post'){
66
+ var wpmf_process = $('.wpmf_process').data('w');
67
+ if(wpmf_process < 50 ) wpmf_process = 50;
68
+ var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
69
+ if(wpmf_process_new > 100) wpmf_process_new = 100;
70
+ $('.wpmf_process').data('w' , wpmf_process_new);
71
+ $('.wpmf_process').css('width' , wpmf_process_new +'%').show();
72
+ $this.data('paged' , parseInt(res.paged)+1);
73
+ $this.click();
74
+ }
75
+ }else{
76
+ $('.wpmf_process').data('w' , 100);
77
+ $('.wpmf_process').css('width' , '100%');
78
+ $('#wp-seo-meta-form .spinner').hide();
79
+ window.location.assign(document.URL);
80
+ }
81
+ }
82
+ });
83
+ });
84
+
85
+ $('.wpms_flush_link').on('click',function(){
86
+ var $this = $(this);
87
+ var flush_val = $('#filter-by-flush').val();
88
+ if(flush_val != 'none'){
89
+ $('#wp-seo-meta-form .spinner').css('visibility','visible').show();
90
+ $.ajax({
91
+ url: ajaxurl,
92
+ method: 'POST',
93
+ dataType: 'json',
94
+ data: {
95
+ 'action': 'wpms_flush_link',
96
+ 'type' : $('#filter-by-flush').val()
97
+ },
98
+ success: function (res) {
99
+ $('#wp-seo-meta-form .spinner').hide();
100
+ window.location.assign(document.URL);
101
+ }
102
+ });
103
+ }
104
+ });
105
+
106
+ $('.wpms-edit-button').on('click', function () {
107
+ $(this).closest('td').find('.wpms-inline-editor-content').show();
108
+ });
109
+
110
+ $('.wpms-cancel-button').on('click', function () {
111
+ $(this).closest('td').find('.wpms-inline-editor-content').hide();
112
+ });
113
+
114
+ $('.wpms-update-link-button').on('click', function () {
115
+ var $this = $(this);
116
+ var link_id = $this.data('link_id');
117
+ var new_link = $this.closest('td').find('.wpms-link-url-field').val();
118
+ var new_text = $this.closest('td').find('.wpms-link-text-field').val();
119
+ var link_redirect = $this.closest('td').find('.wpms-link-redirect-field').val();
120
+ var data_type = $this.closest('td').find('.wpms-link-text-field').data('type');
121
+ if (new_link == '') {
122
+ alert('Error: Link URL must not be empty');
123
+ } else {
124
+ wpms_update_link($this, link_id, new_link,new_text,link_redirect,data_type);
125
+ }
126
+ });
127
+
128
+ $('.wpms-unlink-button').on('click', function () {
129
+ var $this = $(this);
130
+ var link_id = $this.data('link_id');
131
+ wpms_unlink($this, link_id);
132
+ });
133
+
134
+ $('.wpms-recheck-button').on('click', function () {
135
+ var $this = $(this);
136
+ var link_id = $this.data('link_id');
137
+ wpms_recheck_link($this, link_id);
138
+ });
139
+
140
+ function wpms_recheck_link($this,link_id) {
141
+ var oldColor = $this.closest('tr').css('background-color');
142
+ $this.closest('tr').css({ 'background-color' : "rgba(0, 115, 170, 0.1)" });
143
+ $.ajax({
144
+ url: ajaxurl,
145
+ method: 'POST',
146
+ dataType: 'json',
147
+ data: {
148
+ 'action': 'wpms_recheck_link',
149
+ 'link_id': link_id,
150
+ },
151
+ success: function (res) {
152
+ if(res.status){
153
+ var status = res.status_text;
154
+ if(status.indexOf('404') != -1 || status == 'Server Not Found'){
155
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>');
156
+ }else if(status.indexOf('200') != -1){
157
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>');
158
+ }else if(status.indexOf('301') != -1){
159
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>');
160
+ }else if(status.indexOf('302') != -1){
161
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>');
162
+ }else{
163
+ $this.closest('tr').find('.col_status').html(res.status_text);
164
+ }
165
+ wpms_tooltip();
166
+ $this.closest('tr').css({ 'background-color' : oldColor });
167
+ }
168
+ }
169
+ });
170
+ }
171
+
172
+
173
+ function wpms_unlink($this,link_id) {
174
+ $this.closest('tr').css({ 'background-color' : "rgba(0, 115, 170, 0.1)" });
175
+ $.ajax({
176
+ url: ajaxurl,
177
+ method: 'POST',
178
+ dataType: 'json',
179
+ data: {
180
+ 'action': 'wpms_unlink',
181
+ 'link_id': link_id,
182
+ },
183
+ success: function (res) {
184
+ if (res) {
185
+ $this.closest('tr').remove();
186
+ }
187
+ }
188
+ });
189
+ }
190
+
191
+
192
+ function wpms_update_link($this, link_id, new_link,new_text,link_redirect,data_type) {
193
+ $.ajax({
194
+ url: ajaxurl,
195
+ method: 'POST',
196
+ dataType: 'json',
197
+ data: {
198
+ 'action': 'wpms_update_link',
199
+ 'link_id': link_id,
200
+ 'new_link': new_link,
201
+ 'new_text': new_text,
202
+ 'link_redirect' : link_redirect,
203
+ 'data_type' : data_type
204
+ },
205
+ success: function (res) {
206
+ if (res.status) {
207
+ $this.closest('td').find('.wpms-inline-editor-content').hide();
208
+ //if(res.type != '404_automaticaly'){
209
+ $this.closest('td').find('.link_html').html(res.new_link).attr('href', res.new_link);
210
+ $this.closest('tr').find('.col_status').html(res.status_text);
211
+
212
+ var status = res.status_text;
213
+ if(status.indexOf('404') != -1 || status == 'Server Not Found'){
214
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>');
215
+ }else if(status.indexOf('200') != -1){
216
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>');
217
+ }else if(status.indexOf('301') != -1){
218
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>');
219
+ }else if(status.indexOf('302') != -1){
220
+ $this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>');
221
+ }else{
222
+ $this.closest('tr').find('.col_status').html(res.status_text);
223
+ }
224
+ wpms_tooltip();
225
+ //}
226
+
227
+ if(res.type == 'url'){
228
+ if(res.new_text != ''){
229
+ $this.closest('tr').find('.link_text').html(new_text);
230
+ }
231
+ }
232
+ }
233
+ }
234
+ });
235
+ }
236
+
237
+ function wpms_tooltip(){
238
+ jQuery('.metaseo_help_status').qtip({
239
+ content: {
240
+ attr: 'alt'
241
+ },
242
+ position: {
243
+ my: 'bottom left',
244
+ at: 'top center'
245
+ },
246
+ style: {
247
+ tip: {
248
+ corner: true
249
+ },
250
+ classes: 'metaseo-qtip qtip-rounded'
251
+ },
252
+ show: 'hover',
253
+ hide: {
254
+ fixed: true,
255
+ delay: 500
256
+ }
257
+
258
+ });
259
+ }
260
+ wpms_tooltip();
261
+ });
262
+
263
+ </script>
inc/pages/settings.php CHANGED
@@ -1,8 +1,132 @@
 
 
 
 
 
 
 
 
 
 
1
  <h2 id="wpio_settings"><?php _e('Wp Meta SEO Settings','wp-meta-seo') ?></h2>
2
- <form method="post" action="options.php">
3
- <?php
4
- settings_fields( 'Wp Meta SEO' );
5
- do_settings_sections('metaseo_settings');
6
- submit_button();
7
- ?>
8
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $posts = get_posts(array('post_type' => 'page','posts_per_page'=>-1,'numberposts' => -1));
3
+ $types_404 = array('none' => 'None','wp-meta-seo-page' => __('WP Meta SEO page','wp-meta-seo'), 'custom_page' => __('Custom page','wp-meta-seo'));
4
+
5
+ $defaul_settings_404 = array('wpms_redirect_homepage' => 0, 'wpms_type_404' => 'none' , 'wpms_page_redirected' => 'none');
6
+ $wpms_settings_404 = get_option('wpms_settings_404');
7
+ if(is_array($wpms_settings_404)){
8
+ $defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
9
+ }
10
+ ?>
11
  <h2 id="wpio_settings"><?php _e('Wp Meta SEO Settings','wp-meta-seo') ?></h2>
12
+ <div class="tab-header">
13
+ <div class="wpms-tabs">
14
+ <div class="wpms-tab-header active" data-label="wpms-global"><?php _e('Global','wp-meta-seo') ?></div>
15
+ <div class="wpms-tab-header" data-label="wpms-redirection"><?php _e('Redirections and 404','wp-meta-seo') ?></div>
16
+ </div>
17
+ </div>
18
+ <div class="wpms_content_settings">
19
+ <div class="content-box content-wpms-global">
20
+ <form method="post" action="options.php">
21
+ <?php
22
+ settings_fields( 'Wp Meta SEO' );
23
+ do_settings_sections('metaseo_settings');
24
+ submit_button();
25
+ ?>
26
+ </form>
27
+ </div>
28
+
29
+ <div class="content-box content-wpms-redirection">
30
+ <table class="form-table">
31
+ <tbody>
32
+ <tr>
33
+ <th scope="row"><?php _e('Global home redirect','wp-meta-seo') ?></th>
34
+ <td><label>
35
+ <input <?php checked($defaul_settings_404['wpms_redirect_homepage'], 1) ?> data-label="wpms_redirect_homepage" type="checkbox" class="cb_option" id="wpms_redirect_homepage">
36
+ <?php _e('Redirect all 404 errors to home page','wp-meta-seo') ?>
37
+ <input type="hidden" class="wpms_redirect_homepage" name="wpms_redirect[wpms_redirect_homepage]" value="<?php echo $defaul_settings_404['wpms_redirect_homepage'] ?>">
38
+ </label>
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <th scope="row"><?php _e('Custom 404 page','wp-meta-seo') ?></th>
43
+ <td>
44
+ <select name="wpms_redirect[wpms_type_404]" class="wpms_type_404" <?php echo ($defaul_settings_404['wpms_redirect_homepage']==1)?"disabled":"" ?>>
45
+ <?php foreach ($types_404 as $k => $type_404): ?>
46
+ <option <?php selected($defaul_settings_404['wpms_type_404'], $k) ?> value="<?php echo $k ?>"><?php echo $type_404 ?></option>
47
+ <?php endforeach; ?>
48
+ </select>
49
+ <select name="wpms_redirect[wpms_page_redirected]" class="wpms_page_redirected" <?php echo (($defaul_settings_404['wpms_redirect_homepage']==1) || $defaul_settings_404['wpms_type_404'] != 'custom_page')?"disabled":"" ?>>
50
+ <option value="none"><?php _e('— Select —','wp-meta-seo') ?></option>
51
+ <?php foreach ($posts as $post): ?>
52
+ <option <?php selected($defaul_settings_404['wpms_page_redirected'], $post->ID) ?> value="<?php echo $post->ID ?>"><?php echo $post->post_title ?></option>
53
+ <?php endforeach; ?>
54
+ </select>
55
+ </td>
56
+ </tr>
57
+ </tbody>
58
+ </table>
59
+ <div class="button wpms_save_settings404"><?php _e('Save','wp-meta-seo') ?></div>
60
+ <span class="message_saved"><?php _e('Saved','wp-meta-seo') ?></span>
61
+ </div>
62
+
63
+ </div>
64
+ <script type="text/javascript">
65
+ jQuery(document).ready(function ($) {
66
+ $('.wpms-tab-header').on('click',function(){
67
+ var $this = $(this);
68
+ var label = $this.data('label');
69
+ $('.wpms-tab-header').removeClass('active');
70
+ $this.addClass('active');
71
+ $('.content-box').addClass('content-noactive').removeClass('content-active').hide();
72
+ $('.content-'+ label +'').addClass('content-active').removeClass('content-noactive').slideDown();
73
+ });
74
+
75
+ $('.wpms_save_settings404').on('click',function(){
76
+ var home_redirected = $('.wpms_redirect_homepage').val();
77
+ var type_404 = $('.wpms_type_404').val();
78
+ var page_redirected = $('.wpms_page_redirected').val();
79
+ $.ajax({
80
+ url: ajaxurl,
81
+ method: 'POST',
82
+ dataType: 'json',
83
+ data: {
84
+ 'action': 'wpms_save_settings404',
85
+ 'wpms_redirect[wpms_redirect_homepage]': home_redirected,
86
+ 'wpms_redirect[wpms_type_404]' : type_404,
87
+ 'wpms_redirect[wpms_page_redirected]': page_redirected
88
+ },
89
+ success: function (res) {
90
+ if(res == true){
91
+ $('.message_saved').fadeIn(10).delay(2000).fadeOut(2000);
92
+ }else{
93
+ alert('Save errors !')
94
+ }
95
+ }
96
+ });
97
+ });
98
+
99
+ $('.wpms_type_404').on('change',function(){
100
+ var type_404 = $(this).val();
101
+ if(type_404 == 'wp-meta-seo-page' || type_404 == 'none'){
102
+ $('.wpms_page_redirected').prop('disabled',true);
103
+ }else if(type_404 == 'custom_page'){
104
+ $('.wpms_page_redirected').prop('disabled',false);
105
+ }
106
+ });
107
+
108
+ $('.cb_option').unbind('click').bind('click', function() {
109
+ var check = $(this).attr('checked');
110
+ var type = $(this).attr('type');
111
+ var value;
112
+ var $this = $(this);
113
+ if (type == 'checkbox') {
114
+ if (check == 'checked') {
115
+ value = 1;
116
+ } else {
117
+ value = 0;
118
+ }
119
+ $('input[name="wpms_redirect['+ $(this).data('label') +']"]').val(value);
120
+
121
+ if($(this).data('label') == 'wpms_redirect_homepage'){
122
+ if (check == 'checked') {
123
+ $('.wpms_type_404,.wpms_page_redirected').prop('disabled',true);
124
+ } else {
125
+ $('.wpms_type_404,.wpms_page_redirected').prop('disabled',false);
126
+ }
127
+ }
128
+ }
129
+ });
130
+ });
131
+
132
+ </script>
js/metaseo_admin.js CHANGED
@@ -727,6 +727,24 @@ jQuery(document).ready(function($) {
727
  });
728
  });
729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  $('.mbulk_copy').bind('change', function(){
731
  var value = $(this).val();
732
  $('.mbulk_copy').each(function(i,e){
727
  });
728
  });
729
 
730
+ $('.redirect_fillter').bind('change', function(){
731
+ var value = $(this).val();
732
+ $('.redirect_fillter').each(function(i,e){
733
+ if($(e).val() != value){
734
+ $(e).val(value);
735
+ }
736
+ });
737
+ });
738
+
739
+ $('.broken_fillter').bind('change', function(){
740
+ var value = $(this).val();
741
+ $('.broken_fillter').each(function(i,e){
742
+ if($(e).val() != value){
743
+ $(e).val(value);
744
+ }
745
+ });
746
+ });
747
+
748
  $('.mbulk_copy').bind('change', function(){
749
  var value = $(this).val();
750
  $('.mbulk_copy').each(function(i,e){
readme.txt CHANGED
@@ -1,30 +1,31 @@
1
  === WP Meta SEO ===
2
  Contributors: JoomUnited
3
- Tags: google, webmaster tools, keywords, meta, meta description, meta keywords, meta title, robots meta, search engine optimization, seo, wordpress seo, yahoo, image optimization, image resize, custom post seo
4
  Requires at least: 4.0
5
- Tested up to: 4.4.1
6
- Stable tag: 1.7.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- WP Meta SEO gives you the control over all your meta content and images. Bulk SEO content and image optimization, SEO on page analysis.
11
 
12
 
13
  == Description ==
14
 
15
- = WP meta SEO got 6 major functionalities: =
16
 
17
  * Bulk edit all website meta on a single view
18
  * Edit meta in content with live SEO analysis
19
  * Fix HTML image resizing
20
  * Bulk edit image file name and meta
21
  * Bulk edit SEO link title
 
22
  * Facebook and Twitter social sharing custom elements per content
23
 
24
 
25
  = Bulk meta edition and image resizing =
26
 
27
- It was annoying to edit meta on an existing website, open each post, page and almost nobody was doing it. Especially if you need to edit content + image meta.
28
  WP Meta SEO is going to list all posts, pages, custom post types and all images. Type your meta content and fix image size and everything is AJAX saved.
29
  Plus, a bulk copy feature is available to save tons of time in your SEO optimization process:
30
  * Content title to All meta titles (optional meta keywords)
@@ -35,7 +36,6 @@ Plus, a bulk copy feature is available to save tons of time in your SEO optimiza
35
  A bunch of people reduce the size of the pictures in content using handles that results to a HTML resizing. And that's something wrong for SEO, for page loading time and for image quality.
36
  WP Meta SEO also include this feature in the bulk edition view, you are notified and you can now optimize the size of your images in articles, click fix and it's replaced in your content (no broken links).
37
 
38
-
39
  = On page SEO optimization and analysis =
40
 
41
  * Content SEO smart analysis bellow content
@@ -51,6 +51,27 @@ WP Meta SEO also include this feature in the bulk edition view, you are notified
51
  * Check: Wrong image resizing
52
  * Check: Image meta title or alt
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  **More details here:** http://www.joomunited.com/wordpress-products/wp-meta-seo
55
 
56
  = Video demo: =
@@ -83,6 +104,11 @@ WP Meta SEO also include this feature in the bulk edition view, you are notified
83
  * One click image title copy
84
  * SEO bulk copy: Copy image name to image alt and/or image title
85
  * SEO bulk copy: Copy content title to content meta title
 
 
 
 
 
86
  * Check for SEO error: is robot.txt blocking search engine
87
  * Bulk edit SEO link title in your content
88
  * Add SEO link title box in editor link manager
@@ -134,6 +160,9 @@ Nope :) All your SEO content is properly stored in the database and automatic SE
134
  = Is WP Meta SEO compatible with 3rd party plugins? =
135
  YES it is :) All plugins and themes that are using custom post type are compatible and you'll be able to setup SEO for those content. Plus, Yoast SEO and All in one SEO content can also be imported.
136
 
 
 
 
137
  = Can I translate WP Meta SEO? =
138
  You're welcome! in the WP Meta SEO package you got English and French included as standard .po/.mo files. Use the .pot file also available in the /language folder to create your own.
139
  You can contact us if you want it to be included in the WP Meta SEO package.
@@ -174,6 +203,11 @@ This manual SEO validation on click on the reload analysis button.
174
 
175
  == Changelog ==
176
 
 
 
 
 
 
177
  = 1.7.3 =
178
  * Fix og: link broken (facebook)
179
 
1
  === WP Meta SEO ===
2
  Contributors: JoomUnited
3
+ Tags: google, webmaster tools, keywords, meta, meta description, meta keywords, meta title, robots meta, search engine optimization, seo, wordpress seo, yahoo, image optimization, image resize, custom post seo, redirect, redirection, 301, broken link
4
  Requires at least: 4.0
5
+ Tested up to: 4.4.2
6
+ Stable tag: 2.0.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ WP Meta SEO gives you the control over all your meta content and images. Bulk SEO content and image optimization, SEO on page, 404 & redirect
11
 
12
 
13
  == Description ==
14
 
15
+ = WP meta SEO got 7 major functionalities: =
16
 
17
  * Bulk edit all website meta on a single view
18
  * Edit meta in content with live SEO analysis
19
  * Fix HTML image resizing
20
  * Bulk edit image file name and meta
21
  * Bulk edit SEO link title
22
+ * 404 errors redirect and internal broken link checker
23
  * Facebook and Twitter social sharing custom elements per content
24
 
25
 
26
  = Bulk meta edition and image resizing =
27
 
28
+ Editing meta information on an existing website can be veeeery long, open each post, edit, close it, open again and almost nobody was doing it. Especially if you need to edit content + image meta.
29
  WP Meta SEO is going to list all posts, pages, custom post types and all images. Type your meta content and fix image size and everything is AJAX saved.
30
  Plus, a bulk copy feature is available to save tons of time in your SEO optimization process:
31
  * Content title to All meta titles (optional meta keywords)
36
  A bunch of people reduce the size of the pictures in content using handles that results to a HTML resizing. And that's something wrong for SEO, for page loading time and for image quality.
37
  WP Meta SEO also include this feature in the bulk edition view, you are notified and you can now optimize the size of your images in articles, click fix and it's replaced in your content (no broken links).
38
 
 
39
  = On page SEO optimization and analysis =
40
 
41
  * Content SEO smart analysis bellow content
51
  * Check: Wrong image resizing
52
  * Check: Image meta title or alt
53
 
54
+ = 404 and redirect manager =
55
+
56
+ 404 errors are really bad for user experience and for your backlinks, Google hates it too: this is something that has to be fixed to improve your SEO.
57
+ The redirect manager will help you to fix all types of 404 errors you can encounter on your website.
58
+
59
+ * Index all 404 errors from external source (external websites)
60
+ * Internal broken links check: index all broken links you got in your posts, pages, custom posts, comments
61
+ * Possibility to redirect URL, remove link, recheck link
62
+ * Redirect all 404 errors to home page
63
+ * Index all 404 types: URL and images
64
+ * Monitor the 404 hits number
65
+ * Flush existing indexed URLs and hits number
66
+
67
+ = 404 custom page =
68
+
69
+ * Setup the 404 page as a custom page of your choice
70
+ * Setup the 404 page with the WP Meta SEO one
71
+ * Use the default theme 404 page
72
+ * WP Meta SEO 404 page is editable like any other WordPress page
73
+
74
+
75
  **More details here:** http://www.joomunited.com/wordpress-products/wp-meta-seo
76
 
77
  = Video demo: =
104
  * One click image title copy
105
  * SEO bulk copy: Copy image name to image alt and/or image title
106
  * SEO bulk copy: Copy content title to content meta title
107
+ * SEO 404 and redirect: all 404 errors monitoring
108
+ * SEO 404 and redirect: Redirect all 404 errors
109
+ * SEO 404 and redirect: Internal broken link checker
110
+ * SEO 404 and redirect: Custom 404 error page
111
+ * SEO 404 and redirect: Redirect all 404 in one click
112
  * Check for SEO error: is robot.txt blocking search engine
113
  * Bulk edit SEO link title in your content
114
  * Add SEO link title box in editor link manager
160
  = Is WP Meta SEO compatible with 3rd party plugins? =
161
  YES it is :) All plugins and themes that are using custom post type are compatible and you'll be able to setup SEO for those content. Plus, Yoast SEO and All in one SEO content can also be imported.
162
 
163
+ = Is WP Meta SEO fixing 404 errors? =
164
+ Yes, using a redirect manager tool. WP Meta SEO will index all the 404 you have in your content (internal broken links).
165
+
166
  = Can I translate WP Meta SEO? =
167
  You're welcome! in the WP Meta SEO package you got English and French included as standard .po/.mo files. Use the .pot file also available in the /language folder to create your own.
168
  You can contact us if you want it to be included in the WP Meta SEO package.
203
 
204
  == Changelog ==
205
 
206
+ = 2.0.0 =
207
+ * Add: 404 and redirect manager
208
+ * Add: Options to redirect all 404 to home page
209
+ * Add: Setup 404 page as: WP Meta SEO page, custom page, defulat page
210
+
211
  = 1.7.3 =
212
  * Fix og: link broken (facebook)
213
 
wp-meta-seo.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: WP Meta SEO
5
  * Plugin URI: http://www.joomunited.com/wordpress-products/wp-meta-seo
6
  * Description: WP Meta SEO is a plugin for WordPress to fill meta for content, images and main SEO info in a single view.
7
- * Version: 1.7.3
8
  * Text Domain: wp-meta-seo
9
  * Domain Path: /languages
10
  * Author: JoomUnited
@@ -46,8 +46,9 @@ if (!defined('WPMETASEO_PLUGIN_DIR'))
46
  if (!defined('URL'))
47
  define('URL', get_site_url());
48
 
49
- if (!defined('WPMSEO_VERSION'))
50
- define('WPMSEO_VERSION', '1.7.3');
 
51
 
52
  if (!defined('WPMSEO_FILE'))
53
  define('WPMSEO_FILE', __FILE__);
@@ -60,9 +61,10 @@ require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.wp-metaseo.php' );
60
  add_action('init', array('WpMetaSeo', 'init'));
61
 
62
  if (is_admin()) {
63
- require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-content-list-table.php' );
64
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-image-list-table.php' );
65
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-dashboard.php' );
 
66
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-admin.php' );
67
 
68
  $GLOBALS['metaseo_admin'] = new MetaSeo_Admin;
@@ -443,4 +445,85 @@ function text_link( $field, $meta ) {
443
  echo '<input class="cmb_link_button button" type="button" value="Voeg link toe" />','<p class="cmb_metabox_description">', $field['desc'], '</p>';
444
  }
445
  add_action( 'cmb_render_text_link', 'text_link', 10, 2 );
446
- /**********************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  * Plugin Name: WP Meta SEO
5
  * Plugin URI: http://www.joomunited.com/wordpress-products/wp-meta-seo
6
  * Description: WP Meta SEO is a plugin for WordPress to fill meta for content, images and main SEO info in a single view.
7
+ * Version: 2.0.0
8
  * Text Domain: wp-meta-seo
9
  * Domain Path: /languages
10
  * Author: JoomUnited
46
  if (!defined('URL'))
47
  define('URL', get_site_url());
48
 
49
+ if (!defined('WPMSEO_VERSION')) {
50
+ define('WPMSEO_VERSION', '2.0.0');
51
+ }
52
 
53
  if (!defined('WPMSEO_FILE'))
54
  define('WPMSEO_FILE', __FILE__);
61
  add_action('init', array('WpMetaSeo', 'init'));
62
 
63
  if (is_admin()) {
64
+ require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-content-list-table.php' );
65
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-image-list-table.php' );
66
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-dashboard.php' );
67
+ require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-broken-link-table.php' );
68
  require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-admin.php' );
69
 
70
  $GLOBALS['metaseo_admin'] = new MetaSeo_Admin;
445
  echo '<input class="cmb_link_button button" type="button" value="Voeg link toe" />','<p class="cmb_metabox_description">', $field['desc'], '</p>';
446
  }
447
  add_action( 'cmb_render_text_link', 'text_link', 10, 2 );
448
+
449
+ add_action( 'template_redirect', 'wpms_template_redirect' );
450
+ function wpms_template_redirect() {
451
+ if ( is_404() ) {
452
+ if ( isset( $_SERVER['REQUEST_URI'] ) )
453
+ $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
454
+ global $wpdb;
455
+
456
+ //$sql = $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix. "wpms_links WHERE link_url=%s AND broken_indexed=%d ",array(( $url ), 1) );
457
+ $sql = $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix. "wpms_links WHERE (link_url=%s OR link_url=%s)",array( $url,esc_url($url)) );
458
+ $check = $wpdb->get_results($sql);
459
+ if(count($check) == 0){
460
+ $insert = array(
461
+ 'link_url' => ( $url ),
462
+ 'status_code' => '404 Not Found',
463
+ 'status_text' => '404 Not Found',
464
+ 'type' => '404_automaticaly',
465
+ 'broken_indexed' => 1,
466
+ 'broken_internal' => 0,
467
+ 'warning' => 0,
468
+ 'dismissed' => 0
469
+ );
470
+
471
+ $wpdb->insert( $wpdb->prefix.'wpms_links', $insert );
472
+ }else{
473
+
474
+ $sql = $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix. "wpms_links WHERE (link_url=%s OR link_url=%s) ",array( $url,esc_url($url) ) );
475
+ //$sql = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix. "wpms_links WHERE link_url=%s AND (broken_indexed = %d OR broken_internal = %d) AND link_url_redirect != %s ",array(( $url ),1,1,""));
476
+ $links_broken = $wpdb->get_row($sql);
477
+ if(!empty($links_broken)){
478
+
479
+ $value = array('hit' => (int)$links_broken->hit + 1);
480
+ $wpdb->update(
481
+ $wpdb->prefix . 'wpms_links', $value, array('id' => $links_broken->id), array('%d'), array('%d')
482
+ );
483
+ if( ($url == $links_broken->link_url || esc_url( $url ) == $links_broken->link_url) && $links_broken->link_url_redirect != ''){
484
+ wp_redirect (($links_broken->link_url_redirect));
485
+ exit();
486
+ }
487
+ }
488
+ }
489
+
490
+ $defaul_settings_404 = array('wpms_redirect_homepage' => 0, 'wpms_type_404' => 'none' , 'wpms_page_redirected' => 'none');
491
+ $wpms_settings_404 = get_option('wpms_settings_404');
492
+ if(is_array($wpms_settings_404)){
493
+ $defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
494
+ }
495
+
496
+ if(isset($defaul_settings_404['wpms_redirect_homepage']) && $defaul_settings_404['wpms_redirect_homepage'] == 1){
497
+ wp_redirect (get_home_url());
498
+ exit();
499
+ }else{
500
+ if(isset($defaul_settings_404['wpms_type_404'])){
501
+ switch ($defaul_settings_404['wpms_type_404']){
502
+ case 'wp-meta-seo-page':
503
+ global $wpdb;
504
+ $sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s" , array("WP Meta SEO 404 Page","metaseo_404_page"));
505
+ $wpms_page = $wpdb->get_row($sql);
506
+ if(!empty($wpms_page)){
507
+ $link_redirect = get_permalink($wpms_page->ID);
508
+ if($link_redirect){
509
+ wp_redirect ($link_redirect);
510
+ exit();
511
+ }
512
+ }
513
+ break;
514
+
515
+ case 'custom_page':
516
+ if(isset($defaul_settings_404['wpms_page_redirected']) && $defaul_settings_404['wpms_page_redirected'] != 'none'){
517
+ $link_redirect = get_permalink($defaul_settings_404['wpms_page_redirected']);
518
+ if($link_redirect){
519
+ wp_redirect ($link_redirect);
520
+ exit();
521
+ }
522
+ }
523
+ break;
524
+ }
525
+ }
526
+
527
+ }
528
+ }
529
+ }