WP Meta SEO - Version 3.2.4

Version Description

  • WP Meta SEO Addon compatibility
  • Fix conflict with DIVI layout injector plugin
Download this release

Release Info

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

Code changes from version 3.2.3 to 3.2.4

Files changed (38) hide show
  1. css/broken_link.css +58 -0
  2. css/metaseo_admin.css +11 -3
  3. inc/class.metaseo-admin.php +94 -10
  4. inc/class.metaseo-broken-link-table.php +148 -77
  5. inc/class.metaseo-content-list-table.php +2 -3
  6. inc/class.metaseo-dashboard.php +426 -55
  7. inc/class.metaseo-image-list-table.php +2 -2
  8. inc/class.metaseo-link-list-table.php +2 -2
  9. inc/class.metaseo-metabox.php +9 -3
  10. inc/class.metaseo-sitemap.php +257 -19
  11. inc/google_analytics/tracking/code-classic.php +9 -0
  12. inc/google_analytics/tracking/code-universal.php +9 -0
  13. inc/google_analytics/tracking/events-classic.php +9 -0
  14. inc/google_analytics/tracking/events-universal.php +9 -0
  15. inc/google_analytics/wpmsgapi.php +8 -1
  16. inc/google_analytics/wpmstools.php +8 -1
  17. inc/pages/dashboard.php +45 -58
  18. inc/pages/dashboard/imgsmeta.php +19 -0
  19. inc/pages/dashboard/imgsresize.php +19 -0
  20. inc/pages/dashboard/link_meta.php +19 -0
  21. inc/pages/dashboard/meta_desc.php +19 -0
  22. inc/pages/dashboard/meta_title.php +19 -0
  23. inc/pages/dashboard/new_content.php +19 -0
  24. inc/pages/dashboard/permalink.php +19 -0
  25. inc/pages/metaseo-broken-link.php +5 -1
  26. inc/pages/settings.php +60 -1
  27. inc/pages/sitemaps/metaseo-google-sitemap.php +15 -0
  28. inc/pages/sitemaps/metaseo-source_pages.php +1 -1
  29. inc/pages/sitemaps/metaseo-source_posts.php +19 -16
  30. inc/pages/sitemaps/metaseo-source_posts_custom.php +84 -0
  31. inc/pages/sitemaps/sitemap_menus.php +9 -0
  32. js/dashboard.js +169 -27
  33. js/metaseo_admin.js +24 -25
  34. js/metaseo_sitemap.js +53 -20
  35. js/site-jPages.js +11 -1
  36. js/wpms-broken-link.js +264 -186
  37. readme.txt +7 -2
  38. wp-meta-seo.php +48 -6
css/broken_link.css ADDED
@@ -0,0 +1,58 @@
1
+ .custom_redirect_editor_content{
2
+ display: none;
3
+ width: 100%;
4
+ }
5
+
6
+ .custom_redirect_editor_content.show{
7
+ display:block;
8
+ }
9
+
10
+ .link-target{
11
+ display: none;
12
+ }
13
+
14
+ .wp-list-table .wpms-input-text-wrap{
15
+ width: 100%;
16
+ float: left;
17
+ }
18
+
19
+ table.metaseo_images .wpms-input-text-wrap input{
20
+ max-width:80% !important;
21
+ float: left;
22
+ }
23
+
24
+ .wlink-btn{
25
+ float: left;
26
+ padding: 2px;
27
+ cursor: pointer;
28
+ }
29
+
30
+ .wpms_form_add_customlink{
31
+ width: 50%;
32
+ float: left;
33
+ }
34
+
35
+ .custom_redirect_editor_content .wpms-input-text-wrap th{
36
+ width: 100px;
37
+ }
38
+
39
+ .custom_redirect_editor_content .wpms-input-text-wrap td{
40
+ padding: 15px 0px;
41
+ }
42
+
43
+ .wpms-update-link-button{
44
+ margin-right: 40px !important;
45
+ }
46
+
47
+ .wpms_form_add_customlink .custom_redirect_status{
48
+ float: left;
49
+ margin-left: 15%;
50
+ }
51
+
52
+ .wp-list-table .wpms-inline-editor-content{
53
+ width: 100%;
54
+ }
55
+
56
+ .wpms_outgoing{
57
+ color: #4caf50;
58
+ }
css/metaseo_admin.css CHANGED
@@ -416,7 +416,7 @@ strong {
416
line-height: 26px;
417
}
418
419
- .wpms-link-url-field,.wpms-link-text-field,.wpms-link-redirect-field{
420
width:85%;
421
float: right;
422
}
@@ -500,7 +500,7 @@ strong {
500
padding: 10px;
501
}
502
503
- .content-wpms-redirection{
504
display: none;
505
}
506
@@ -539,7 +539,7 @@ strong {
539
color: #4caf50;
540
}
541
542
- .wpmf_process{
543
background:#81b5ee;
544
height: 2px;
545
width:0%;
@@ -610,6 +610,14 @@ strong {
610
line-height: 18px !important;
611
}
612
613
.metaseo-img-lb{
614
float:left;
615
width: 70px;
416
line-height: 26px;
417
}
418
419
+ .wpms-link-url-field,.wpms-link-text-field,.wpms-link-redirect-field,.custom_redirect_text,.custom_redirect_url,.custom_redirect_url_redirect{
420
width:85%;
421
float: right;
422
}
500
padding: 10px;
501
}
502
503
+ .content-wpms-redirection,.content-wpms-email{
504
display: none;
505
}
506
539
color: #4caf50;
540
}
541
542
+ .wpms_process{
543
background:#81b5ee;
544
height: 2px;
545
width:0%;
610
line-height: 18px !important;
611
}
612
613
+ #numberFrequency{
614
+ width: 70px;
615
+ vertical-align: middle;
616
+ }
617
+
618
+ #showlinkFrequency {
619
+ padding: 3px;
620
+ }
621
.metaseo-img-lb{
622
float:left;
623
width: 70px;
inc/class.metaseo-admin.php CHANGED
@@ -71,8 +71,11 @@ class MetaSeo_Admin {
71
'wpmsga_track_exclude' => array(),
72
'wpmsga_cookiename' => ''
73
);
74
-
75
-
76
add_action('admin_menu', array($this, 'register_menu_page'));
77
78
/** Load admin js * */
@@ -102,8 +105,16 @@ class MetaSeo_Admin {
102
add_action('deleted_comment', array('MetaSeo_Broken_Link_Table', 'wpms_deleted_comment'));
103
104
add_action( 'wp_head', array( 'MetaSeo_Google_Analytics', 'tracking_code' ), 99 );
105
}
106
-
107
/*
108
* Create wpms_links table
109
*/
@@ -713,10 +724,42 @@ class MetaSeo_Admin {
713
function wpms_save_settings404() {
714
if (isset($_POST['wpms_redirect'])) {
715
update_option('wpms_settings_404', $_POST['wpms_redirect']);
716
- wp_send_json(true);
717
}
718
}
719
-
720
/*
721
* Add a new field to a section of a settings page
722
*/
@@ -845,7 +888,7 @@ class MetaSeo_Admin {
845
<?php _e("Provides show or do not show this page in search results in search results.", "wp-meta-seo"); ?></label>
846
<?php
847
}
848
-
849
/*
850
* Display showfacebook input
851
*/
@@ -974,6 +1017,10 @@ class MetaSeo_Admin {
974
wp_localize_script('wpms-bulk', 'wpmseobulkL10n', $this->meta_seo_localize_script());
975
}
976
977
if ($current_screen->base == 'toplevel_page_metaseo_dashboard') {
978
wp_enqueue_script('Chart', plugins_url('js/Chart.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
979
wp_enqueue_script('jquery-knob', plugins_url('js/jquery.knob.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
@@ -1102,7 +1149,6 @@ class MetaSeo_Admin {
1102
* or not a page is included in the menu.
1103
*/
1104
function register_menu_page() {
1105
-
1106
// Add main page
1107
$admin_page = add_menu_page(__('WP Meta SEO:', 'wp-meta-seo') . ' ' . __('Dashboard', 'wp-meta-seo'), __('WP Meta SEO', 'wp-meta-seo'), 'manage_options', 'metaseo_dashboard', array(
1108
$this, 'load_page',), 'dashicons-chart-area');
@@ -1190,8 +1236,6 @@ class MetaSeo_Admin {
1190
),
1191
);
1192
1193
-
1194
-
1195
// Allow submenu pages manipulation
1196
$submenu_pages = apply_filters('metaseo_submenu_pages', $submenu_pages);
1197
@@ -1444,6 +1488,37 @@ class MetaSeo_Admin {
1444
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/metaseo-broken-link.php' );
1445
break;
1446
case 'metaseo_settings':
1447
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/settings.php' );
1448
break;
1449
@@ -1687,7 +1762,9 @@ class MetaSeo_Admin {
1687
add_action('wp_ajax_metaseo_validate_analysis', array($this, 'metaseo_validate_analysis'));
1688
add_action('wp_ajax_metaseo_update_link', array($this, 'metaseo_update_link'));
1689
add_action('wp_ajax_wpms_save_settings404', array($this, 'wpms_save_settings404'));
1690
add_action('wp_ajax_wpms_update_link', array('MetaSeo_Broken_Link_Table', 'wpms_update_link'));
1691
add_action('wp_ajax_wpms_unlink', array('MetaSeo_Broken_Link_Table', 'wpms_unlink'));
1692
add_action('wp_ajax_wpms_recheck_link', array('MetaSeo_Broken_Link_Table', 'wpms_recheck_link'));
1693
add_action('wp_ajax_wpms_scan_link', array('MetaSeo_Broken_Link_Table', 'wpms_scan_link'));
@@ -1698,6 +1775,13 @@ class MetaSeo_Admin {
1698
add_action('wp_ajax_metaseo_update_pageindex', array($this, 'metaseo_update_pageindex'));
1699
add_action('wp_ajax_wpms_backend_item_reports', array('MetaSeo_Google_Analytics', 'ajax_item_reports'));
1700
add_action('wp_ajax_wpmsga_wpmsClearauthor', array('MetaSeo_Google_Analytics', 'wpmsga_wpmsClearauthor'));
1701
- add_action('wp_ajax_wpmsga_update_option', array('MetaSeo_Google_Analytics', 'wpmsga_update_option'));
1702
}
1703
}
71
'wpmsga_track_exclude' => array(),
72
'wpmsga_cookiename' => ''
73
);
74
+
75
+ if (!get_option('_wpms_dash_last_update', false)) {
76
+ update_option('_wpms_dash_last_update',time());
77
+ }
78
+
79
add_action('admin_menu', array($this, 'register_menu_page'));
80
81
/** Load admin js * */
105
add_action('deleted_comment', array('MetaSeo_Broken_Link_Table', 'wpms_deleted_comment'));
106
107
add_action( 'wp_head', array( 'MetaSeo_Google_Analytics', 'tracking_code' ), 99 );
108
+ add_action('admin_footer', array($this, 'add_editor_footer'));
109
}
110
+
111
+ public function add_editor_footer() {
112
+ if ( ! class_exists( '_WP_Editors', false ) ){
113
+ require_once ABSPATH . "wp-includes/class-wp-editor.php";
114
+ _WP_Editors::wp_link_dialog();
115
+ }
116
+ }
117
+
118
/*
119
* Create wpms_links table
120
*/
724
function wpms_save_settings404() {
725
if (isset($_POST['wpms_redirect'])) {
726
update_option('wpms_settings_404', $_POST['wpms_redirect']);
727
+
728
+ }
729
+
730
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)) {
731
+ $params = array('enable','numberFrequency','showlinkFrequency');
732
+ $settinglink = array();
733
+ foreach ($params as $param){
734
+ if(isset($_POST[$param])){
735
+ $settinglink[$param] = $_POST[$param];
736
+ }
737
+ }
738
+
739
+ if(empty($settinglink['wpms_lastRun_scanlink'])){
740
+ $settinglink['wpms_lastRun_scanlink'] = time();
741
+ }
742
+ update_option('wpms_link_settings',$settinglink);
743
}
744
+
745
+ wp_send_json(true);
746
}
747
+
748
+ /*
749
+ * Update option wpms_email_settings
750
+ */
751
+ function wpms_save_settingemail(){
752
+ $params = array('enable','host','type_encryption','port','autentication','username','password');
753
+ $settingemail = array();
754
+ foreach ($params as $param){
755
+ if(isset($_POST[$param])){
756
+ $settingemail[$param] = $_POST[$param];
757
+ }
758
+ }
759
+ update_option('wpms_email_settings',$settingemail);
760
+ wp_send_json(true);
761
+ }
762
+
763
/*
764
* Add a new field to a section of a settings page
765
*/
888
<?php _e("Provides show or do not show this page in search results in search results.", "wp-meta-seo"); ?></label>
889
<?php
890
}
891
+
892
/*
893
* Display showfacebook input
894
*/
1017
wp_localize_script('wpms-bulk', 'wpmseobulkL10n', $this->meta_seo_localize_script());
1018
}
1019
1020
+ if ($current_screen->base == 'wp-meta-seo_page_metaseo_broken_link') {
1021
+ wp_enqueue_style('wpms_brokenlink_style', plugins_url('css/broken_link.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
1022
+ }
1023
+
1024
if ($current_screen->base == 'toplevel_page_metaseo_dashboard') {
1025
wp_enqueue_script('Chart', plugins_url('js/Chart.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
1026
wp_enqueue_script('jquery-knob', plugins_url('js/jquery.knob.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
1149
* or not a page is included in the menu.
1150
*/
1151
function register_menu_page() {
1152
// Add main page
1153
$admin_page = add_menu_page(__('WP Meta SEO:', 'wp-meta-seo') . ' ' . __('Dashboard', 'wp-meta-seo'), __('WP Meta SEO', 'wp-meta-seo'), 'manage_options', 'metaseo_dashboard', array(
1154
$this, 'load_page',), 'dashicons-chart-area');
1236
),
1237
);
1238
1239
// Allow submenu pages manipulation
1240
$submenu_pages = apply_filters('metaseo_submenu_pages', $submenu_pages);
1241
1488
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/metaseo-broken-link.php' );
1489
break;
1490
case 'metaseo_settings':
1491
+ // email settings
1492
+ $email_settings = array(
1493
+ "enable" => 0,
1494
+ "host" => "smtp.gmail.com",
1495
+ "type_encryption" => "ssl",
1496
+ "port" => "465",
1497
+ "autentication" => "yes",
1498
+ "username" => "",
1499
+ "password" => "",
1500
+ );
1501
+
1502
+ $mailsettings = get_option('wpms_email_settings');
1503
+ if (is_array($mailsettings)) {
1504
+ $email_settings = array_merge($email_settings, $mailsettings);
1505
+ }
1506
+
1507
+ $html_tabemail = apply_filters('wpmsaddon_emailsettings','',$email_settings);
1508
+
1509
+ // link settings
1510
+ $link_settings = array(
1511
+ "enable" => 0,
1512
+ "numberFrequency" => 1,
1513
+ "showlinkFrequency" => "month"
1514
+ );
1515
+
1516
+ $linksettings = get_option('wpms_link_settings');
1517
+ if (is_array($linksettings)) {
1518
+ $link_settings = array_merge($link_settings, $linksettings);
1519
+ }
1520
+
1521
+ $link_settings_html = apply_filters('wpmsaddon_linksettings','',$link_settings);
1522
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/settings.php' );
1523
break;
1524
1762
add_action('wp_ajax_metaseo_validate_analysis', array($this, 'metaseo_validate_analysis'));
1763
add_action('wp_ajax_metaseo_update_link', array($this, 'metaseo_update_link'));
1764
add_action('wp_ajax_wpms_save_settings404', array($this, 'wpms_save_settings404'));
1765
+ add_action('wp_ajax_wpms_save_settingemail', array($this, 'wpms_save_settingemail'));
1766
add_action('wp_ajax_wpms_update_link', array('MetaSeo_Broken_Link_Table', 'wpms_update_link'));
1767
+ add_action('wp_ajax_wpms_add_custom_redirect', array('MetaSeo_Broken_Link_Table', 'wpms_add_custom_redirect'));
1768
add_action('wp_ajax_wpms_unlink', array('MetaSeo_Broken_Link_Table', 'wpms_unlink'));
1769
add_action('wp_ajax_wpms_recheck_link', array('MetaSeo_Broken_Link_Table', 'wpms_recheck_link'));
1770
add_action('wp_ajax_wpms_scan_link', array('MetaSeo_Broken_Link_Table', 'wpms_scan_link'));
1775
add_action('wp_ajax_metaseo_update_pageindex', array($this, 'metaseo_update_pageindex'));
1776
add_action('wp_ajax_wpms_backend_item_reports', array('MetaSeo_Google_Analytics', 'ajax_item_reports'));
1777
add_action('wp_ajax_wpmsga_wpmsClearauthor', array('MetaSeo_Google_Analytics', 'wpmsga_wpmsClearauthor'));
1778
+ add_action('wp_ajax_wpmsga_update_option', array('MetaSeo_Google_Analytics', 'wpmsga_update_option'));
1779
+
1780
+ add_action('wp_ajax_wpms_dash_permalink', array('MetaSeo_Dashboard', 'wpms_dash_permalink'));
1781
+ add_action('wp_ajax_wpms_dash_newcontent', array('MetaSeo_Dashboard', 'wpms_dash_newcontent'));
1782
+ add_action('wp_ajax_wpms_dash_linkmeta', array('MetaSeo_Dashboard', 'wpms_dash_linkmeta'));
1783
+ add_action('wp_ajax_wpms_dash_metatitle', array('MetaSeo_Dashboard', 'wpms_dash_metatitle'));
1784
+ add_action('wp_ajax_wpms_dash_metadesc', array('MetaSeo_Dashboard', 'wpms_dash_metadesc'));
1785
+ add_action('wp_ajax_wpms_dash_imgsmeta', array('MetaSeo_Dashboard', 'wpms_dash_imgsmeta'));
1786
}
1787
}
inc/class.metaseo-broken-link-table.php CHANGED
@@ -69,36 +69,6 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
69
<?php
70
}
71
72
- /**
73
- * Extra controls to be displayed between bulk actions and pagination
74
- * @param string $which
75
- */
76
- function extra_tablenav($which) {
77
- echo '<div class="alignleft actions">';
78
- global $wpdb;
79
-
80
- $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
81
- $post_types = "'" . implode("', '", $post_types) . "'";
82
-
83
- $states = get_post_stati(array('show_in_admin_all_list' => true));
84
- $states['trash'] = 'trash';
85
- $all_states = "'" . implode("', '", $states) . "'";
86
-
87
- $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";
88
- $post_types = $wpdb->get_results($query);
89
-
90
- $selected = !empty($_REQUEST['post_type_filter']) ? $_REQUEST['post_type_filter'] : -1;
91
-
92
- $options = '<option value="-1">Show All Post Types</option>';
93
-
94
- foreach ($post_types as $post_type) {
95
- $obj = get_post_type_object($post_type->post_type);
96
- $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));
97
- }
98
-
99
- echo "</div>";
100
- }
101
-
102
/**
103
* Get a list of columns. The format is:
104
* 'internal-name' => 'Title'
@@ -220,7 +190,9 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
220
}
221
222
if (!empty($_REQUEST['sl_broken']) && $_REQUEST['sl_broken'] != 'all') {
223
- if ($_REQUEST['sl_broken'] == 'valid_links') {
224
$where[] = "broken_internal = 0 AND broken_indexed = 0";
225
} elseif ($_REQUEST['sl_broken'] == 'internal_broken_links') {
226
$where[] = "broken_internal = 1";
@@ -319,6 +291,9 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
319
* Displays the search box.
320
*/
321
function search_box1() {
322
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
323
return;
324
$txtkeyword = (!empty($_REQUEST['txtkeyword'])) ? urldecode(stripslashes($_REQUEST['txtkeyword'])) : "";
@@ -332,7 +307,6 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
332
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
333
?>
334
<p class="search-box">
335
-
336
<input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
337
<?php submit_button('Search URL', 'button', 'search', false, array('id' => 'search-submit')); ?>
338
</p>
@@ -363,7 +337,14 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
363
364
/* Add fillter broken */
365
function broken_fillter($name) {
366
- $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'));
367
$curent_broken = isset($_REQUEST['sl_broken']) ? $_REQUEST['sl_broken'] : 'all';
368
?>
369
<label for="filter-by-broken" class="screen-reader-text"><?php _e('Filter by broken', 'wp-meta-seo'); ?></label>
@@ -385,7 +366,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
385
386
/* Add fillter type */
387
function type_fillter($name) {
388
- $types = array('url' => 'URL', 'image' => 'Image', 'other' => 'Other');
389
$curent_type = isset($_REQUEST['sltype']) ? $_REQUEST['sltype'] : 'all';
390
?>
391
<label for="filter-by-type" class="screen-reader-text"><?php _e('Filter by type', 'wp-meta-seo'); ?></label>
@@ -404,7 +385,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
404
405
<?php
406
submit_button(__('Filter'), 'button', 'filter_type_action', false, array('id' => 'broken-submit'));
407
- echo '<div style="float:left;padding-left: 5px;"><div class="wpmf_process" data-w="0"></div>';
408
echo '<div data-comment_paged="1" data-paged="1" class="button wpms_scan_link">' . __('Index internal broken links', 'wp-meta-seo') . '</div></div>';
409
echo '<span class="spinner"></span>';
410
}
@@ -441,7 +422,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
441
if (!empty($records)) {
442
foreach ($records as $rec) {
443
$i++;
444
- echo '<tr id="record_' . $i . '" data-link="' . $i . '" data-post_id="' . $rec->source_id . '">';
445
foreach ($columns as $column_name => $column_display_name) {
446
447
$class = sprintf('class="%1$s column-%1$s"', $column_name);
@@ -462,11 +443,20 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
462
}
463
echo '<td class="wpms_link_html" colspan="3">';
464
echo '<input type="hidden" class="wpms_link_text" value="' . esc_attr($rec->link_text) . '">';
465
- echo '<a class="link_html" target="_blank" href="' . esc_url($value_url) . '">' . $value_url . '</a>';
466
$row_action = array(
467
- '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>',
468
- '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>',
469
- '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>'
470
);
471
echo $this->row_actions($row_action, false);
472
if (!empty($rec->source_id)) {
@@ -515,17 +505,36 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
515
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>';
516
}
517
} else {
518
- 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>';
519
}
520
?>
521
522
- <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>
523
- <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>
524
</label>
525
526
<div class="submit wpms-inline-editor-buttons">
527
<input type="button" class="button-secondary cancel alignleft wpms-cancel-button" value="<?php echo esc_attr(__('Cancel', 'wp-meta-seo')); ?>" />
528
- <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')); ?>" />
529
</div>
530
</div>
531
<?php
@@ -539,7 +548,6 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
539
break;
540
case 'col_status':
541
echo '<td colspan="3" class="col_status">';
542
-
543
if (strpos($rec->status_text, '200') !== false) {
544
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>';
545
} elseif (strpos($rec->status_text, '301') !== false) {
@@ -585,8 +593,8 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
585
$source = get_comment($rec->source_id);
586
if (!empty($source)) {
587
$row_action = array(
588
- 'edit' => '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '" title="Edit this item">Edit</a>',
589
- 'view' => '<a target="_blank" href="' . get_comment_link($rec->source_id) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
590
);
591
592
if ($rec->type == 'comment') {
@@ -600,7 +608,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
600
$source = get_post($rec->source_id);
601
if (!empty($source)) {
602
$row_action = array(
603
- 'edit' => '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '" title="Edit this item">Edit</a>',
604
'view' => '<a target="_blank" href="' . get_post_permalink($rec->source_id) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
605
);
606
@@ -614,7 +622,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
614
echo $source_inner;
615
echo $this->row_actions($row_action, false);
616
} else {
617
- echo '<a>' . __('Source Not Found', 'wp-meta-seo') . '</a>';
618
}
619
echo '</td>';
620
break;
@@ -980,6 +992,8 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
980
$wpdb->prepare("DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d AND (type = %s || type = %s || type = %s)", array($comment_ID, 'comment', 'comment_content_url', 'comment_content_image'))
981
);
982
}
983
}
984
985
/*
@@ -1045,6 +1059,8 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1045
);
1046
}
1047
}
1048
}
1049
1050
/*
@@ -1204,6 +1220,20 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1204
wp_send_json(array('status' => false, 'type' => 'limit_post', 'paged' => $_POST['paged'], 'percent' => $percent_post * count($results)));
1205
}
1206
}
1207
wp_send_json(array('status' => true));
1208
}
1209
@@ -1267,6 +1297,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1267
*/
1268
public static function wpms_check_internal_link($link, $siteUrl, $value) {
1269
$info_link = parse_url($link);
1270
$info_site_url = parse_url($siteUrl);
1271
$domain_link = $info_link['host'] . $info_link['path'] . '/';
1272
$domain_site = $info_site_url['host'] . $info_site_url['path'] . '/';
@@ -1337,6 +1372,14 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1337
}
1338
return $status_text;
1339
}
1340
1341
/*
1342
* Update link
@@ -1349,15 +1392,27 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1349
$link_detail = $wpdb->get_row($sql);
1350
if (empty($link_detail))
1351
wp_send_json(false);
1352
- $status = MetaSeo_Broken_Link_Table::get_urlstatus(($_POST['new_link']));
1353
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
1354
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
1355
-
1356
if ($link_detail->type != '404_automaticaly') {
1357
- $value = array('link_url' => ($_POST['new_link']),
1358
'link_final_url' => '',
1359
'link_url_redirect' => '',
1360
- 'link_text' => stripcslashes($_POST['new_text']),
1361
'status_code' => $status,
1362
'status_text' => $status_text,
1363
'broken_indexed' => 0,
@@ -1365,44 +1420,48 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1365
'warning' => 0,
1366
'dismissed' => 0,
1367
);
1368
- if (strpos($_POST['new_link'], 'mailto:') !== false) {
1369
- $value['link_final_url'] = $_POST['new_link'];
1370
} else {
1371
- if (!preg_match("~^(?:f|ht)tps?://~i", $_POST['new_link'])) {
1372
$perlink = get_option('permalink_structure');
1373
if (empty($perlink)) {
1374
- $value['link_final_url'] = get_site_url() . '/' . $_POST['new_link'];
1375
} else {
1376
if (!empty($link_detail->source_id)) {
1377
- $value['link_final_url'] = get_permalink($link_detail->source_id) . $_POST['new_link'];
1378
} else {
1379
- $value['link_final_url'] = $perlink . '/' . $_POST['new_link'];
1380
}
1381
}
1382
} else {
1383
- $value['link_final_url'] = $_POST['new_link'];
1384
}
1385
}
1386
1387
- if (!empty($_POST['link_redirect']))
1388
- $value['link_url_redirect'] = ($_POST['link_redirect']);
1389
if (isset($status_type) && $status_type != 'ok') {
1390
$value[$status_type] = 1;
1391
}
1392
} else {
1393
- $status = MetaSeo_Broken_Link_Table::get_urlstatus(($_POST['link_redirect']));
1394
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
1395
1396
$value = array(
1397
- 'link_url_redirect' => ($_POST['link_redirect']),
1398
'status_code' => $status,
1399
'status_text' => $status_text,
1400
'broken_indexed' => 1
1401
);
1402
}
1403
1404
$site_url = get_site_url();
1405
- $value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($_POST['new_link'], $site_url, $value);
1406
1407
$wpdb->update(
1408
$wpdb->prefix . 'wpms_links', $value, array('id' => $_POST['link_id'])
@@ -1410,13 +1469,13 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1410
1411
switch ($link_detail->type) {
1412
case '404_automaticaly':
1413
- wp_send_json(array('status' => true, 'type' => '404_automaticaly', 'status_text' => $status_text, 'new_link' => esc_url($_POST['new_link'])));
1414
break;
1415
case 'comment_content_image':
1416
$comment = get_comment($link_detail->source_id);
1417
if (!empty($comment)) {
1418
$old_value = $comment->comment_content;
1419
- $edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
1420
$my_comment = array(
1421
'comment_ID' => $link_detail->source_id,
1422
'comment_content' => $edit_result['content']
@@ -1430,7 +1489,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1430
$post = get_post($link_detail->source_id);
1431
if (!empty($post)) {
1432
$old_value = $post->post_content;
1433
- $edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
1434
$my_post = array(
1435
'ID' => $link_detail->source_id,
1436
'post_content' => $edit_result['content']
@@ -1445,11 +1504,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1445
$comment = get_comment($link_detail->source_id);
1446
if (!empty($comment)) {
1447
$old_value = $comment->comment_content;
1448
- if (isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == '') {
1449
- $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
1450
$new_text = '';
1451
} else {
1452
- $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
1453
$new_text = strip_tags($edit_result['link_text']);
1454
}
1455
@@ -1468,11 +1527,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1468
$post = get_post($link_detail->source_id);
1469
if (!empty($post)) {
1470
$old_value = $post->post_content;
1471
- if (isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == '') {
1472
- $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
1473
$new_text = '';
1474
} else {
1475
- $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
1476
$new_text = strip_tags($edit_result['link_text']);
1477
}
1478
@@ -1487,8 +1546,12 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1487
1488
break;
1489
case 'comment':
1490
- wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => $_POST['new_link']));
1491
- wp_send_json(array('status' => true, 'type' => 'orther', 'status_text' => $status_text, 'new_link' => $_POST['new_link']));
1492
break;
1493
}
1494
}
@@ -1574,6 +1637,9 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1574
wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => ''));
1575
wp_send_json(true);
1576
break;
1577
}
1578
}
1579
wp_send_json(false);
@@ -1957,7 +2023,12 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
1957
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($linkId));
1958
$link = $wpdb->get_row($sql);
1959
if (!empty($link)) {
1960
- $status = MetaSeo_Broken_Link_Table::get_urlstatus(($link->link_url));
1961
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
1962
1963
if ($link->type == '404_automaticaly') {
69
<?php
70
}
71
72
/**
73
* Get a list of columns. The format is:
74
* 'internal-name' => 'Title'
190
}
191
192
if (!empty($_REQUEST['sl_broken']) && $_REQUEST['sl_broken'] != 'all') {
193
+ if ($_REQUEST['sl_broken'] == 'custom_redirect_url') {
194
+ $where[] = "link_url_redirect !=''";
195
+ } else if ($_REQUEST['sl_broken'] == 'valid_links') {
196
$where[] = "broken_internal = 0 AND broken_indexed = 0";
197
} elseif ($_REQUEST['sl_broken'] == 'internal_broken_links') {
198
$where[] = "broken_internal = 1";
291
* Displays the search box.
292
*/
293
function search_box1() {
294
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)) {
295
+ require_once (WPMETASEO_ADDON_PLUGIN_DIR . 'inc/page/custom_redirect_form.php');
296
+ }
297
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
298
return;
299
$txtkeyword = (!empty($_REQUEST['txtkeyword'])) ? urldecode(stripslashes($_REQUEST['txtkeyword'])) : "";
307
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
308
?>
309
<p class="search-box">
310
<input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
311
<?php submit_button('Search URL', 'button', 'search', false, array('id' => 'search-submit')); ?>
312
</p>
337
338
/* Add fillter broken */
339
function broken_fillter($name) {
340
+ $brokens = array(
341
+ 'valid_links' => __('Valid links', 'wp-meta-seo'),
342
+ 'automaticaly_indexed' => __('404 automaticaly indexed', 'wp-meta-seo'),
343
+ 'internal_broken_links' => __('Internal broken links', 'wp-meta-seo')
344
+ );
345
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)){
346
+ $brokens['custom_redirect_url'] = __('Custom redirect URL', 'wp-meta-seo');
347
+ }
348
$curent_broken = isset($_REQUEST['sl_broken']) ? $_REQUEST['sl_broken'] : 'all';
349
?>
350
<label for="filter-by-broken" class="screen-reader-text"><?php _e('Filter by broken', 'wp-meta-seo'); ?></label>
366
367
/* Add fillter type */
368
function type_fillter($name) {
369
+ $types = array('url' => __('URL','wp-meta-seo') , 'image' => __('Image','wp-meta-seo'), 'other' => __('Other','wp-meta-seo'));
370
$curent_type = isset($_REQUEST['sltype']) ? $_REQUEST['sltype'] : 'all';
371
?>
372
<label for="filter-by-type" class="screen-reader-text"><?php _e('Filter by type', 'wp-meta-seo'); ?></label>
385
386
<?php
387
submit_button(__('Filter'), 'button', 'filter_type_action', false, array('id' => 'broken-submit'));
388
+ echo '<div style="float:left;padding-left: 5px;"><div class="wpms_process" data-w="0"></div>';
389
echo '<div data-comment_paged="1" data-paged="1" class="button wpms_scan_link">' . __('Index internal broken links', 'wp-meta-seo') . '</div></div>';
390
echo '<span class="spinner"></span>';
391
}
422
if (!empty($records)) {
423
foreach ($records as $rec) {
424
$i++;
425
+ echo '<tr id="record_' . $i . '" data-linkid="'.$rec->id.'" data-link="' . $i . '" data-post_id="' . $rec->source_id . '">';
426
foreach ($columns as $column_name => $column_display_name) {
427
428
$class = sprintf('class="%1$s column-%1$s"', $column_name);
443
}
444
echo '<td class="wpms_link_html" colspan="3">';
445
echo '<input type="hidden" class="wpms_link_text" value="' . esc_attr($rec->link_text) . '">';
446
+ if ($rec->type == 'add_custom') {
447
+ echo '<a class="link_html" target="_blank" href="' . esc_url(site_url() . '/' . $rec->link_url) . '">' . $value_url . '</a>';
448
+ if($rec->link_url_redirect != ''){
449
+ echo ' to ';
450
+ echo '<a class="link_html" target="_blank" href="' . esc_url($rec->link_url_redirect) . '">' . str_replace(site_url(),'',$rec->link_url_redirect) . '</a>';
451
+ }
452
+ }else{
453
+ echo '<a class="link_html" target="_blank" href="' . esc_url($value_url) . '">' . $value_url . '</a>';
454
+ }
455
+
456
$row_action = array(
457
+ 'edit' => '<a class="wpms_action_link wpms-edit-button" title="'.__('Edit redirect','wp-meta-seo').'"><div class="wpms_icon_action"><i class="material-icons">mode_edit</i></div><span>' . __('Redirect', 'wp-meta-seo') . '</span></a>',
458
+ '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 redirect', 'wp-meta-seo') . '"><div class="wpms_icon_action"><i class="material-icons">delete_forever</i></div><span>' . __('Remove link', 'wp-meta-seo') . '</span></a>',
459
+ '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="' . __('Check redirect or link', 'wp-meta-seo') . '"><div class="wpms_icon_action"><i class="material-icons">loop</i></div><span>' . __('Recheck', 'wp-meta-seo') . '</span></a>'
460
);
461
echo $this->row_actions($row_action, false);
462
if (!empty($rec->source_id)) {
505
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>';
506
}
507
} else {
508
+ if($rec->type != 'add_custom'){
509
+ 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>';
510
+ }else{
511
+ ?>
512
+ <p class="wpms-input-text-wrap">
513
+ <span class="title">
514
+ <?php _e('Status', 'wp-meta-seo') ?>
515
+ </span>
516
+ <select name="custom_redirect_status" class="custom_redirect_status">
517
+ <option value="301" <?php selected($rec->meta_title,301) ?>>301</option>
518
+ <option value="302" <?php selected($rec->meta_title,302) ?>>302</option>
519
+ <option value="307" <?php selected($rec->meta_title,307) ?>>307</option>
520
+ </select>
521
+ </p>
522
+ <?php
523
+ }
524
}
525
?>
526
527
+ <p 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); ?>" /></p>
528
+ <p class="wpms-input-text-wrap">
529
+ <span class="title"><?php _e('Redirect', 'wp-meta-seo'); ?></span>
530
+ <input type="text" name="link_url_redirect" class="wpms-link-redirect-field" value="<?php echo esc_attr($rec->link_url_redirect); ?>" />
531
+ <span class="wlink-btn"><i class="mce-ico mce-i-link link-btn" id="link-btn"></i></span>
532
+ </p>
533
</label>
534
535
<div class="submit wpms-inline-editor-buttons">
536
<input type="button" class="button-secondary cancel alignleft wpms-cancel-button" value="<?php echo esc_attr(__('Cancel', 'wp-meta-seo')); ?>" />
537
+ <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(__('Add custom redirect', 'wp-meta-seo')); ?>" />
538
</div>
539
</div>
540
<?php
548
break;
549
case 'col_status':
550
echo '<td colspan="3" class="col_status">';
551
if (strpos($rec->status_text, '200') !== false) {
552
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>';
553
} elseif (strpos($rec->status_text, '301') !== false) {
593
$source = get_comment($rec->source_id);
594
if (!empty($source)) {
595
$row_action = array(
596
+ 'edit' => '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '" title="'.__('Edit this item','wp-meta-seo').'">'.__('Edit','wp-meta-seo').'</a>',
597
+ 'view' => '<a target="_blank" href="' . get_comment_link($rec->source_id) . '" title="View &#8220;test&#8221;" rel="permalink">'.__('View','wp-meta-seo').'</a>'
598
);
599
600
if ($rec->type == 'comment') {
608
$source = get_post($rec->source_id);
609
if (!empty($source)) {
610
$row_action = array(
611
+ 'edit' => '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '" title="'.__('Edit this item','wp-meta-seo').'">'.__('Edit','wp-meta-seo').'</a>',
612
'view' => '<a target="_blank" href="' . get_post_permalink($rec->source_id) . '" title="View &#8220;test&#8221;" rel="permalink">View</a>'
613
);
614
622
echo $source_inner;
623
echo $this->row_actions($row_action, false);
624
} else {
625
+ if($rec->type == 'add_custom' || $rec->type == 'add_rule'){
626
+ echo '<a><i title="'.__('Custom redirect','wp-meta-seo').'" class="wpms_outgoing material-icons">call_missed_outgoing</i></a>';
627
+ }else{
628
+ echo '<a>'.__('Source Not Found','wp-meta-seo').'</a>';
629
+ }
630
}
631
echo '</td>';
632
break;
992
$wpdb->prepare("DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d AND (type = %s || type = %s || type = %s)", array($comment_ID, 'comment', 'comment_content_url', 'comment_content_image'))
993
);
994
}
995
+
996
+ update_option('wpms_last_update_post',time());
997
}
998
999
/*
1059
);
1060
}
1061
}
1062
+
1063
+ update_option('wpms_last_update_post',time());
1064
}
1065
1066
/*
1220
wp_send_json(array('status' => false, 'type' => 'limit_post', 'paged' => $_POST['paged'], 'percent' => $percent_post * count($results)));
1221
}
1222
}
1223
+
1224
+ $link_settings = array(
1225
+ "enable" => 0,
1226
+ "numberFrequency" => 1,
1227
+ "showlinkFrequency" => "month"
1228
+ );
1229
+
1230
+ $linksettings = get_option('wpms_link_settings');
1231
+ if (is_array($linksettings)) {
1232
+ $link_settings = array_merge($link_settings, $linksettings);
1233
+ }
1234
+
1235
+ $link_settings['wpms_lastRun_scanlink'] = time();
1236
+ update_option('wpms_link_settings', $link_settings);
1237
wp_send_json(array('status' => true));
1238
}
1239
1297
*/
1298
public static function wpms_check_internal_link($link, $siteUrl, $value) {
1299
$info_link = parse_url($link);
1300
+ if(empty($info_link['host'])){
1301
+ $value['internal'] = 0;
1302
+ return $value;
1303
+ }
1304
+
1305
$info_site_url = parse_url($siteUrl);
1306
$domain_link = $info_link['host'] . $info_link['path'] . '/';
1307
$domain_site = $info_site_url['host'] . $info_site_url['path'] . '/';
1372
}
1373
return $status_text;
1374
}
1375
+
1376
+ /*
1377
+ * Add custom redirect
1378
+ */
1379
+ public static function wpms_add_custom_redirect() {
1380
+ do_action('wpms_add_custom_redirect');
1381
+ wp_send_json(array('status' => true , 'message' => __('Done!','wp-meta-seo')));
1382
+ }
1383
1384
/*
1385
* Update link
1392
$link_detail = $wpdb->get_row($sql);
1393
if (empty($link_detail))
1394
wp_send_json(false);
1395
+ $new_link = stripslashes($_POST['new_link']);
1396
+ $link_redirect = stripslashes($_POST['link_redirect']);
1397
+ if(isset($_POST['new_text'])){
1398
+ $new_text = stripcslashes($_POST['new_text']);
1399
+ }else{
1400
+ $new_text = '';
1401
+ }
1402
+
1403
+ if($link_redirect != ''){
1404
+ $status = 'HTTP/1.1 200 OK';
1405
+ }else{
1406
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($new_link);
1407
+ }
1408
+
1409
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
1410
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
1411
if ($link_detail->type != '404_automaticaly') {
1412
+ $value = array('link_url' => $new_link,
1413
'link_final_url' => '',
1414
'link_url_redirect' => '',
1415
+ 'link_text' => stripcslashes($new_text),
1416
'status_code' => $status,
1417
'status_text' => $status_text,
1418
'broken_indexed' => 0,
1420
'warning' => 0,
1421
'dismissed' => 0,
1422
);
1423
+ if (strpos($new_link, 'mailto:') !== false) {
1424
+ $value['link_final_url'] = $new_link;
1425
} else {
1426
+ if (!preg_match("~^(?:f|ht)tps?://~i", $new_link)) {
1427
$perlink = get_option('permalink_structure');
1428
if (empty($perlink)) {
1429
+ $value['link_final_url'] = get_site_url() . '/' . $new_link;
1430
} else {
1431
if (!empty($link_detail->source_id)) {
1432
+ $value['link_final_url'] = get_permalink($link_detail->source_id) . $new_link;
1433
} else {
1434
+ $value['link_final_url'] = $perlink . '/' . $new_link;
1435
}
1436
}
1437
} else {
1438
+ $value['link_final_url'] = $new_link;
1439
}
1440
}
1441
1442
+ if (!empty($link_redirect))
1443
+ $value['link_url_redirect'] = $link_redirect;
1444
if (isset($status_type) && $status_type != 'ok') {
1445
$value[$status_type] = 1;
1446
}
1447
} else {
1448
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus($link_redirect);
1449
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
1450
1451
$value = array(
1452
+ 'link_url_redirect' => stripslashes($link_redirect),
1453
'status_code' => $status,
1454
'status_text' => $status_text,
1455
'broken_indexed' => 1
1456
);
1457
}
1458
1459
+ if($link_detail->type == 'add_custom'){
1460
+ $value['meta_title'] = $_POST['status_redirect'];
1461
+ }
1462
+
1463
$site_url = get_site_url();
1464
+ $value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($new_link, $site_url, $value);
1465
1466
$wpdb->update(
1467
$wpdb->prefix . 'wpms_links', $value, array('id' => $_POST['link_id'])
1469
1470
switch ($link_detail->type) {
1471
case '404_automaticaly':
1472
+ wp_send_json(array('status' => true, 'type' => '404_automaticaly', 'status_text' => $status_text, 'new_link' => esc_url($new_link)));
1473
break;
1474
case 'comment_content_image':
1475
$comment = get_comment($link_detail->source_id);
1476
if (!empty($comment)) {
1477
$old_value = $comment->comment_content;
1478
+ $edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $new_link, $link_detail->link_url);
1479
$my_comment = array(
1480
'comment_ID' => $link_detail->source_id,
1481
'comment_content' => $edit_result['content']
1489
$post = get_post($link_detail->source_id);
1490
if (!empty($post)) {
1491
$old_value = $post->post_content;
1492
+ $edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $new_link, $link_detail->link_url);
1493
$my_post = array(
1494
'ID' => $link_detail->source_id,
1495
'post_content' => $edit_result['content']
1504
$comment = get_comment($link_detail->source_id);
1505
if (!empty($comment)) {
1506
$old_value = $comment->comment_content;
1507
+ if (isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $new_text == '') {
1508
+ $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $new_link, $link_detail->link_url);
1509
$new_text = '';
1510
} else {
1511
+ $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $new_link, $link_detail->link_url, $new_text);
1512
$new_text = strip_tags($edit_result['link_text']);
1513
}
1514
1527
$post = get_post($link_detail->source_id);
1528
if (!empty($post)) {
1529
$old_value = $post->post_content;
1530
+ if (isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $new_text == '') {
1531
+ $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $new_link, $link_detail->link_url);
1532
$new_text = '';
1533
} else {
1534
+ $edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $new_link, $link_detail->link_url, $new_text);
1535
$new_text = strip_tags($edit_result['link_text']);
1536
}
1537
1546
1547
break;
1548
case 'comment':
1549
+ wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => $new_link));
1550
+ wp_send_json(array('status' => true, 'type' => 'orther', 'status_text' => $status_text, 'new_link' => $new_link));
1551
+ break;
1552
+
1553
+ case 'add_custom':
1554
+ wp_send_json(array('status' => true, 'type' => 'orther', 'status_text' => $status_text, 'new_link' => $new_link));
1555
break;
1556
}
1557
}
1637
wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => ''));
1638
wp_send_json(true);
1639
break;
1640
+ case 'add_custom':
1641
+ wp_send_json(true);
1642
+ break;
1643
}
1644
}
1645
wp_send_json(false);
2023
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($linkId));
2024
$link = $wpdb->get_row($sql);
2025
if (!empty($link)) {
2026
+ if($link->link_url_redirect != ''){
2027
+ $status = 'HTTP/1.1 200 OK';
2028
+ }else{
2029
+ $status = MetaSeo_Broken_Link_Table::get_urlstatus(($link->link_url));
2030
+ }
2031
+
2032
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
2033
2034
if ($link->type == '404_automaticaly') {
inc/class.metaseo-content-list-table.php CHANGED
@@ -173,7 +173,7 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
173
/**
174
* Get a list of all registered post type objects.
175
*/
176
- function wpmf_get_post_type(){
177
global $wpdb;
178
179
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
@@ -194,7 +194,7 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
194
*/
195
function prepare_items() {
196
global $wpdb, $_wp_column_headers;
197
- $this->post_types = $this->wpmf_get_post_type();
198
$screen = get_current_screen();
199
200
$where = array();
@@ -214,7 +214,6 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
214
$where[] = "post_type IN ($post_type)";
215
216
$states = get_post_stati(array('show_in_admin_all_list' => true));
217
- $states['trash'] = 'trash';
218
$all_states = "'" . implode("', '", $states) . "'";
219
220
if (empty($_REQUEST['post_status'])) {
173
/**
174
* Get a list of all registered post type objects.
175
*/
176
+ function wpms_get_post_type(){
177
global $wpdb;
178
179
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
194
*/
195
function prepare_items() {
196
global $wpdb, $_wp_column_headers;
197
+ $this->post_types = $this->wpms_get_post_type();
198
$screen = get_current_screen();
199
200
$where = array();
214
$where[] = "post_type IN ($post_type)";
215
216
$states = get_post_stati(array('show_in_admin_all_list' => true));
217
$all_states = "'" . implode("', '", $states) . "'";
218
219
if (empty($_REQUEST['post_status'])) {
inc/class.metaseo-dashboard.php CHANGED
@@ -18,7 +18,7 @@ class MetaSeo_Dashboard {
18
public static $mpermalink = 50;
19
public static $mlink_complete = 0;
20
public static $mcount_link = 0;
21
-
22
/*
23
* Get image optimize
24
*/
@@ -30,8 +30,8 @@ class MetaSeo_Dashboard {
30
$imgs_metas_are_good = array();
31
$meta_keys = array('alt', 'title');
32
$response = array(
33
- 'imgs_statis' => array(0, 0),
34
- 'imgs_metas_statis' => array(0, 0),
35
);
36
foreach ($meta_keys as $meta_key) {
37
$imgs_metas_are_good[$meta_key] = 0;
@@ -39,7 +39,7 @@ class MetaSeo_Dashboard {
39
}
40
41
$post_types = MetaSeo_Content_List_Table::get_post_types();
42
- $query = "SELECT `ID`, `post_title`, `post_content`, `post_type`, `post_date`
43
FROM $wpdb->posts
44
WHERE `post_type` IN ($post_types)
45
AND `post_content` <> ''
@@ -100,10 +100,24 @@ class MetaSeo_Dashboard {
100
}
101
102
//Report analytic of images optimization
103
$response['imgs_statis'][0] = $imgs_are_good;
104
$response['imgs_statis'][1] = $imgs;
105
- $response['imgs_metas_statis'][0] = ceil(($imgs_metas_are_good['alt'] + $imgs_metas_are_good['title']) / 2);
106
$response['imgs_metas_statis'][1] = $imgs;
107
}
108
109
return $response;
@@ -197,78 +211,205 @@ class MetaSeo_Dashboard {
197
curl_multi_close($mh);
198
return $contents;
199
}
200
-
201
/*
202
- * Return params meta title filled , meta description filled , link_meta , permalink_setting for dashboard
203
*/
204
- function evolutive_dashboard() {
205
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
206
if (!empty($post_types['attachment']))
207
unset($post_types['attachment']);
208
- $results = array('permalink_setting' => 50, 'metatitle_filled' => array(0, array(0, 0)), 'metadesc_filled' => array(0, array(0, 0)), 'new_content' => array(0, array(0, 0)), 'link_meta' => array(0, array(0, 0)));
209
$args = array(
210
'posts_per_page' => -1,
211
- 'post_type' => $post_types,
212
- 'suppress_filters' => true
213
);
214
- $mposts = get_posts($args);
215
- if (empty($mposts)) {
216
- return $results;
217
- } else {
218
- foreach ($mposts as $post) {
219
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
220
if (empty($meta_analysis))
221
$meta_analysis = array();
222
223
$meta_title = get_post_meta($post->ID, '_metaseo_metatitle', true);
224
- $meta_desc = get_post_meta($post->ID, '_metaseo_metadesc', true);
225
if (($meta_title != '' && strlen($meta_title) <= self::$meta_title_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle']))) {
226
- self::$metatitle_filled++;
227
}
228
229
- if (($meta_desc != '' && strlen($meta_desc) <= self::$meta_desc_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc']))) {
230
- self::$metadesc_filled++;
231
- }
232
233
- // get link meta
234
-
235
- $dom = new DOMDocument;
236
- libxml_use_internal_errors(true);
237
- if (isset($post->post_content) && $post->post_content != '') {
238
- if ($dom->loadHTML($post->post_content)) {
239
- $tags = $dom->getElementsByTagName('a');
240
- foreach ($tags as $tag) {
241
- self::$mcount_link++;
242
- $link_title = $tag->getAttribute('title');
243
- if (isset($link_title) && $link_title != '') {
244
- self::$mlink_complete++;
245
- }
246
- }
247
- }
248
}
249
}
250
251
- if (self::$mcount_link == 0) {
252
- $link_percent = 100;
253
- } else {
254
- $link_percent = ceil(self::$mlink_complete / self::$mcount_link * 100);
255
- }
256
257
- $results['metatitle_filled'] = array(ceil(self::$metatitle_filled / (count($mposts)) * 100), array(self::$metatitle_filled, count($mposts)));
258
- $results['metadesc_filled'] = array(ceil(self::$metadesc_filled / (count($mposts)) * 100), array(self::$metadesc_filled, count($mposts)));
259
- $results['link_meta'] = array($link_percent, array(self::$mlink_complete, self::$mcount_link));
260
}
261
262
$permalink_structure = get_option('permalink_structure');
263
if (strpos($permalink_structure, 'postname') == false && strpos($permalink_structure, 'category') == false) {
264
- self::$mpermalink = 0;
265
} else if (strpos($permalink_structure, 'postname') == true && strpos($permalink_structure, 'category') == true) {
266
- self::$mpermalink = 100;
267
} else if (strpos($permalink_structure, 'postname') == true || strpos($permalink_structure, 'category') == true) {
268
- self::$mpermalink = 50;
269
}
270
271
- $results['permalink_setting'] = self::$mpermalink;
272
$newcontent_args = array(
273
'date_query' => array(
274
array(
@@ -282,19 +423,31 @@ class MetaSeo_Dashboard {
282
283
$newcontent = new WP_Query($newcontent_args);
284
285
- if (count($newcontent->get_posts()) >= 4) {
286
$count_new = 100;
287
} else {
288
- $count_new = ceil(count($newcontent->get_posts()) / 4 * 100);
289
}
290
- $results['new_content'] = array($count_new, array(count($newcontent->get_posts()), count($mposts)));
291
return $results;
292
}
293
294
/*
295
* Return count link 404 , count link 404 is redirected , percent
296
*/
297
- function get_404_link() {
298
global $wpdb;
299
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "wpms_links WHERE (broken_internal=%d OR broken_indexed=%d) ", array(1, 1));
300
$count_404 = $wpdb->get_var($sql);
@@ -312,7 +465,7 @@ class MetaSeo_Dashboard {
312
/*
313
* Return count image is optimized
314
*/
315
- public function wpmf_getImages_optimizer() {
316
global $wpdb;
317
$query = 'SELECT distinct file FROM ' . $wpdb->prefix . 'wpio_images';
318
$files = $wpdb->get_results($query);
@@ -328,12 +481,12 @@ class MetaSeo_Dashboard {
328
/*
329
* Get count image
330
*/
331
- public function wpmf_getImages_count() {
332
$wpio_settings = get_option('_wpio_settings');
333
$include_folders = $wpio_settings['wpio_api_include'];
334
$allowedPath = explode(',', $include_folders);
335
$images = array();
336
- $image_optimize = $this->wpmf_getImages_optimizer();
337
338
$allowed_ext = array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'pdf');
339
$min_size = (int) $wpio_settings['wpio_api_minfilesize'] * 1024;
@@ -358,4 +511,222 @@ class MetaSeo_Dashboard {
358
return array('image_optimize' => $image_optimize, 'count_image' => $count_image, 'percent' => $precent);
359
}
360
361
}
18
public static $mpermalink = 50;
19
public static $mlink_complete = 0;
20
public static $mcount_link = 0;
21
+
22
/*
23
* Get image optimize
24
*/
30
$imgs_metas_are_good = array();
31
$meta_keys = array('alt', 'title');
32
$response = array(
33
+ 'imgs_statis' => array(0, 0 ,100),
34
+ 'imgs_metas_statis' => array(0, 0 ,100),
35
);
36
foreach ($meta_keys as $meta_key) {
37
$imgs_metas_are_good[$meta_key] = 0;
39
}
40
41
$post_types = MetaSeo_Content_List_Table::get_post_types();
42
+ $query = "SELECT `ID`,`post_content`
43
FROM $wpdb->posts
44
WHERE `post_type` IN ($post_types)
45
AND `post_content` <> ''
100
}
101
102
//Report analytic of images optimization
103
+ $imgs_metas = ceil(($imgs_metas_are_good['alt'] + $imgs_metas_are_good['title']) / 2);
104
$response['imgs_statis'][0] = $imgs_are_good;
105
$response['imgs_statis'][1] = $imgs;
106
+ $response['imgs_metas_statis'][0] = $imgs_metas;
107
$response['imgs_metas_statis'][1] = $imgs;
108
+
109
+ if (!empty($imgs)) {
110
+ $percent_iresizing = ceil($imgs_are_good / $imgs * 100);
111
+ } else {
112
+ $percent_iresizing = 100;
113
+ }
114
+ $response['imgs_statis'][2] = $percent_iresizing;
115
+ if (!empty($imgs)) {
116
+ $percent_imeta = ceil($imgs_metas / $imgs * 100);
117
+ } else {
118
+ $percent_imeta = 100;
119
+ }
120
+ $response['imgs_metas_statis'][2] = $percent_imeta;
121
}
122
123
return $response;
211
curl_multi_close($mh);
212
return $contents;
213
}
214
+
215
+ /**
216
+ * update option dashboard
217
+ */
218
+ public static function update_dashboard($name){
219
+ $options_dashboard = get_option('options_dashboard');
220
+ MetaSeo_Dashboard::_wpms_update_option_dash($options_dashboard,$name);
221
+ $options_dashboard = get_option('options_dashboard');
222
+ $results = $options_dashboard[$name];
223
+ return $results;
224
+ }
225
+
226
+ /**
227
+ * get Count posts
228
+ */
229
+ public static function getCountPost(){
230
+ global $wpdb;
231
+ $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
232
+ $post_types = "'" . implode("', '", $post_types) . "'";
233
+ $states = get_post_stati(array('show_in_admin_all_list' => true));
234
+ $states['trash'] = 'trash';
235
+ $all_states = "'" . implode("', '", $states) . "'";
236
+ $total_posts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types)");
237
+ return $total_posts;
238
+ }
239
+
240
/*
241
+ * get params meta title filled for dashboard
242
*/
243
+ public static function wpms_metatitle(){
244
+ $total_posts = MetaSeo_Dashboard::getCountPost();
245
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
246
if (!empty($post_types['attachment']))
247
unset($post_types['attachment']);
248
+ $results = array(0, array(0, (int)$total_posts));
249
$args = array(
250
'posts_per_page' => -1,
251
+ 'post_type' => $post_types,
252
+ 'meta_key' => '_metaseo_metatitle',
253
+ 'meta_query' => array(
254
+ array(
255
+ 'key' => '_metaseo_metatitle',
256
+ 'value' => '',
257
+ 'compare' => '!=',
258
+ ),
259
+ ),
260
);
261
+ $query = new WP_Query( $args );
262
+ $posts = $query->get_posts();
263
+ $metatitle_filled = 0;
264
+ if (!empty($posts)) {
265
+ foreach ($posts as $post) {
266
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
267
if (empty($meta_analysis))
268
$meta_analysis = array();
269
270
$meta_title = get_post_meta($post->ID, '_metaseo_metatitle', true);
271
if (($meta_title != '' && strlen($meta_title) <= self::$meta_title_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle']))) {
272
+ $metatitle_filled++;
273
}
274
+ }
275
276
+ $results = array(ceil($metatitle_filled / $total_posts * 100), array($metatitle_filled, (int)$total_posts));
277
+ }
278
279
+ return $results;
280
+ }
281
+
282
+ /*
283
+ * get html meta title filled for dashboard
284
+ */
285
+ public static function wpms_dash_metatitle(){
286
+ $results = MetaSeo_Dashboard::update_dashboard('metatitle');
287
+ ob_start();
288
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/meta_title.php';
289
+ $html = ob_get_contents();
290
+ ob_end_clean();
291
+ wp_send_json($html);
292
+ }
293
+
294
+ /*
295
+ * get params meta description filled for dashboard
296
+ */
297
+ public static function wpms_metadesc(){
298
+ $total_posts = MetaSeo_Dashboard::getCountPost();
299
+ $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
300
+ if (!empty($post_types['attachment']))
301
+ unset($post_types['attachment']);
302
+ $results = array(0, array(0, $total_posts));
303
+ $args = array(
304
+ 'posts_per_page' => -1,
305
+ 'post_type' => $post_types,
306
+ 'meta_key' => '_metaseo_metadesc',
307
+ 'meta_query' => array(
308
+ array(
309
+ 'key' => '_metaseo_metadesc',
310
+ 'value' => '',
311
+ 'compare' => '!=',
312
+ ),
313
+ ),
314
+ );
315
+ $query = new WP_Query( $args );
316
+ $posts = $query->get_posts();
317
+ $metadesc_filled = 0;
318
+ if (!empty($posts)) {
319
+ foreach ($posts as $post) {
320
+ $meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
321
+ if (empty($meta_analysis))
322
+ $meta_analysis = array();
323
+
324
+ $meta_desc = get_post_meta($post->ID, '_metaseo_metadesc', true);
325
+ if (($meta_desc != '' && strlen($meta_desc) <= self::$meta_desc_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc']))) {
326
+ $metadesc_filled++;
327
}
328
}
329
330
+ $results = array(ceil($metadesc_filled / $total_posts * 100), array($metadesc_filled, $total_posts));
331
+ }
332
+
333
+ return $results;
334
+ }
335
336
+ /*
337
+ * Return html description filled for dashboard
338
+ */
339
+ public static function wpms_dash_metadesc(){
340
+ $results = MetaSeo_Dashboard::update_dashboard('metadesc');
341
+ ob_start();
342
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/meta_desc.php';
343
+ $html = ob_get_contents();
344
+ ob_end_clean();
345
+ wp_send_json($html);
346
+ }
347
+
348
+ /*
349
+ * Return link_meta for dashboard
350
+ */
351
+ public static function wpms_linkmeta(){
352
+ global $wpdb;
353
+ $mcount_link = 0;
354
+ $mlink_complete = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."wpms_links WHERE meta_title !=''");
355
+ $mcount_link = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."wpms_links WHERE type !='404_automaticaly'");
356
+
357
+ if ($mcount_link == 0) {
358
+ $link_percent = 100;
359
+ } else {
360
+ $link_percent = ceil($mlink_complete / $mcount_link * 100);
361
}
362
363
+ $results = array($link_percent, array($mlink_complete, $mcount_link));
364
+ return $results;
365
+ }
366
+
367
+
368
+ /*
369
+ * Return html link_meta for dashboard
370
+ */
371
+ public static function wpms_dash_linkmeta(){
372
+ $results = MetaSeo_Dashboard::wpms_linkmeta();
373
+ ob_start();
374
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/link_meta.php';
375
+ $html = ob_get_contents();
376
+ ob_end_clean();
377
+ wp_send_json($html);
378
+ }
379
+
380
+ /*
381
+ * Return permalink for dashboard
382
+ */
383
+ public static function wpms_permalink(){
384
+ $permalink = 50;
385
$permalink_structure = get_option('permalink_structure');
386
if (strpos($permalink_structure, 'postname') == false && strpos($permalink_structure, 'category') == false) {
387
+ $permalink = 0;
388
} else if (strpos($permalink_structure, 'postname') == true && strpos($permalink_structure, 'category') == true) {
389
+ $permalink = 100;
390
} else if (strpos($permalink_structure, 'postname') == true || strpos($permalink_structure, 'category') == true) {
391
+ $permalink = 50;
392
}
393
+ return $permalink;
394
+ }
395
396
+ /*
397
+ * Return html permalink for dashboard
398
+ */
399
+ public static function wpms_dash_permalink(){
400
+ $permalink = MetaSeo_Dashboard::wpms_permalink();
401
+ ob_start();
402
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/permalink.php';
403
+ $html = ob_get_contents();
404
+ ob_end_clean();
405
+ wp_send_json($html);
406
+ }
407
+
408
+ /*
409
+ * Return count new content updated for dashboard
410
+ */
411
+ public static function wpms_newcontent(){
412
+ $total_posts = MetaSeo_Dashboard::getCountPost();
413
$newcontent_args = array(
414
'date_query' => array(
415
array(
423
424
$newcontent = new WP_Query($newcontent_args);
425
426
+ if (count($newcontent->get_posts()) >= $total_posts) {
427
$count_new = 100;
428
} else {
429
+ $count_new = ceil(count($newcontent->get_posts()) / $total_posts * 100);
430
}
431
+ $results = array($count_new, array(count($newcontent->get_posts()), $total_posts));
432
return $results;
433
}
434
+
435
+ /*
436
+ * Return html new content updated for dashboard
437
+ */
438
+ public static function wpms_dash_newcontent(){
439
+ $results = MetaSeo_Dashboard::update_dashboard('newcontent');
440
+ ob_start();
441
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/new_content.php';
442
+ $html = ob_get_contents();
443
+ ob_end_clean();
444
+ wp_send_json($html);
445
+ }
446
447
/*
448
* Return count link 404 , count link 404 is redirected , percent
449
*/
450
+ public static function get_404_link() {
451
global $wpdb;
452
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "wpms_links WHERE (broken_internal=%d OR broken_indexed=%d) ", array(1, 1));
453
$count_404 = $wpdb->get_var($sql);
465
/*
466
* Return count image is optimized
467
*/
468
+ public function wpms_getImages_optimizer() {
469
global $wpdb;
470
$query = 'SELECT distinct file FROM ' . $wpdb->prefix . 'wpio_images';
471
$files = $wpdb->get_results($query);
481
/*
482
* Get count image
483
*/
484
+ public function wpms_getImages_count() {
485
$wpio_settings = get_option('_wpio_settings');
486
$include_folders = $wpio_settings['wpio_api_include'];
487
$allowedPath = explode(',', $include_folders);
488
$images = array();
489
+ $image_optimize = $this->wpms_getImages_optimizer();
490
491
$allowed_ext = array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'pdf');
492
$min_size = (int) $wpio_settings['wpio_api_minfilesize'] * 1024;
511
return array('image_optimize' => $image_optimize, 'count_image' => $count_image, 'percent' => $precent);
512
}
513
514
+ /**
515
+ * get meta data dashboard
516
+ */
517
+ public static function getMetaDataDashBoard($name){
518
+ switch ($name){
519
+ case 'metatitle':
520
+ $results = MetaSeo_Dashboard::wpms_metatitle();
521
+ break;
522
+ case 'metadesc':
523
+ $results = MetaSeo_Dashboard::wpms_metadesc();
524
+ break;
525
+ case 'newcontent':
526
+ $results = MetaSeo_Dashboard::wpms_newcontent();
527
+ break;
528
+ case 'image_meta':
529
+ $results = MetaSeo_Dashboard::moptimizationChecking();
530
+ break;
531
+ }
532
+
533
+ return $results;
534
+ }
535
+
536
+ /**
537
+ * update time dashboard update
538
+ */
539
+ public static function _wpms_dash_last_update($name){
540
+ if($name == 'metadesc'){
541
+ update_option('_wpms_dash_last_update',time());
542
+ }
543
+ }
544
+
545
+ /**
546
+ * update option dashboard
547
+ */
548
+ public static function _wpms_update_option_dash($options_dashboard,$name){
549
+ if(!empty($options_dashboard) && is_array($options_dashboard)){
550
+ if (empty($options_dashboard[$name])) {
551
+ $results = MetaSeo_Dashboard::getMetaDataDashBoard($name);
552
+ $options_dashboard[$name] = $results;
553
+ update_option('options_dashboard',$options_dashboard);
554
+ MetaSeo_Dashboard::_wpms_dash_last_update($name);
555
+ }else{
556
+ $option_last_update_post = get_option('wpms_last_update_post');
557
+ $option_last_dash_update = get_option('_wpms_dash_last_update');
558
+ if(!empty($option_last_update_post) && $option_last_update_post > $option_last_dash_update){
559
+ $results = MetaSeo_Dashboard::getMetaDataDashBoard($name);
560
+ $options_dashboard[$name] = $results;
561
+ update_option('options_dashboard',$options_dashboard);
562
+ MetaSeo_Dashboard::_wpms_dash_last_update($name);
563
+ }
564
+ }
565
+ }else{
566
+ $results = MetaSeo_Dashboard::getMetaDataDashBoard($name);
567
+ $options_dashboard[$name] = $results;
568
+ update_option('options_dashboard',$options_dashboard);
569
+ MetaSeo_Dashboard::_wpms_dash_last_update($name);
570
+ }
571
+ }
572
+
573
+
574
+
575
+ public static function wpms_dash_imgsmeta() {
576
+ global $wpdb;
577
+ $imgs = 0;
578
+ $imgs_metas = array('alt' => 0, 'title' => 0);
579
+ $imgs_are_good = 0;
580
+ $imgs_metas_are_good = array();
581
+ $meta_keys = array('alt', 'title');
582
+ $response = array(
583
+ 'imgs_statis' => array(0, 0 ,100),
584
+ 'imgs_metas_statis' => array(0, 0 ,100),
585
+ );
586
+
587
+ $options_dashboard = get_option('options_dashboard');
588
+ $option_last_update_post = get_option('wpms_last_update_post');
589
+ $option_last_dash_update = get_option('_wpms_dash_last_update');
590
+ if(!empty($options_dashboard) && is_array($options_dashboard) && !empty($options_dashboard['image_meta']) && $option_last_update_post < $option_last_dash_update){
591
+ $results = $options_dashboard['image_meta'];
592
+ ob_start();
593
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/imgsresize.php';
594
+ $html_imgresize = ob_get_contents();
595
+ ob_end_clean();
596
+
597
+ ob_start();
598
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/imgsmeta.php';
599
+ $html_imgsmeta = ob_get_contents();
600
+ ob_end_clean();
601
+ wp_send_json(array('status' => true ,'html_imgresize' => $html_imgresize , 'html_imgsmeta' => $html_imgsmeta));
602
+ }
603
+
604
+ foreach ($meta_keys as $meta_key) {
605
+ $imgs_metas_are_good[$meta_key] = 0;
606
+ $imgs_metas_are_not_good[$meta_key] = 0;
607
+ }
608
+
609
+ $limit = 50;
610
+ $offset = ($_POST['page']-1)*$limit;
611
+ $post_types = MetaSeo_Content_List_Table::get_post_types();
612
+ $query = "SELECT `ID`,`post_content`
613
+ FROM $wpdb->posts
614
+ WHERE `post_type` IN ($post_types)
615
+ AND `post_content` <> ''
616
+ AND `post_content` LIKE '%<img%>%'
617
+ ORDER BY ID LIMIT $limit OFFSET $offset";
618
+
619
+ $posts = $wpdb->get_results($query);
620
+ if (count($posts) > 0) {
621
+ $doc = new DOMDocument();
622
+ libxml_use_internal_errors(true);
623
+ $upload_dir = wp_upload_dir();
624
+
625
+ foreach ($posts as $post) {
626
+ $meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
627
+ if (empty($meta_analysis))
628
+ $meta_analysis = array();
629
+ $dom = $doc->loadHTML($post->post_content);
630
+ $tags = $doc->getElementsByTagName('img');
631
+ foreach ($tags as $tag) {
632
+ $img_src = $tag->getAttribute('src');
633
+
634
+ if (!preg_match('/\.(jpg|png|gif)#x2F;i', $img_src, $matches)) {
635
+ continue;
636
+ }
637
+
638
+ $img_path = str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $img_src);
639
+ if (!file_exists($img_path)) {
640
+ continue;
641
+ }
642
+
643
+ $width = $tag->getAttribute('width');
644
+ $height = $tag->getAttribute('height');
645
+ if (list($real_width, $real_height) = @getimagesize($img_path)) {
646
+ $ratio_origin = $real_width / $real_height;
647
+ //Check if img tag is missing with/height attribute value or not
648
+ if (!$width && !$height) {
649
+ $width = $real_width;
650
+ $height = $real_height;
651
+ } elseif ($width && !$height) {
652
+ $height = $width * (1 / $ratio_origin);
653
+ } elseif ($height && !$width) {
654
+ $width = $height * ($ratio_origin);
655
+ }
656
+
657
+ if (($real_width <= $width && $real_height <= $height) || (!empty($meta_analysis) && !empty($meta_analysis['imgresize']))) {
658
+ $imgs_are_good++;
659
+ }
660
+ foreach ($meta_keys as $meta_key) {
661
+
662
+ if (trim($tag->getAttribute($meta_key)) || (!empty($meta_analysis) && !empty($meta_analysis['imgalt']))) {
663
+ $imgs_metas_are_good[$meta_key] ++;
664
+ }
665
+ }
666
+ }
667
+
668
+ $imgs++;
669
+ }
670
+ }
671
+
672
+ //Report analytic of images optimization
673
+ $c_imgs_metas = ceil(($imgs_metas_are_good['alt'] + $imgs_metas_are_good['title']) / 2);
674
+ $response['imgs_statis'][0] = $imgs_are_good + (int)$_POST['imgs_statis'];
675
+ $response['imgs_statis'][1] = $imgs + (int)$_POST['imgs_count'];
676
+ $response['imgs_metas_statis'][0] = $c_imgs_metas + (int)$_POST['imgs_metas_statis'];
677
+ $response['imgs_metas_statis'][1] = $imgs + (int)$_POST['imgs_count'];
678
+ $response['imgs_count'] = $imgs + (int)$_POST['imgs_count'];
679
+ $response['page'] = (int)$_POST['page'];
680
+ }else{
681
+ if (!empty($_POST['imgs_count'])) {
682
+ $percent_iresizing = ceil($_POST['imgs_statis'] / $_POST['imgs_count'] * 100);
683
+ } else {
684
+ $percent_iresizing = 100;
685
+ }
686
+ $response['imgs_statis'][2] = $percent_iresizing;
687
+ if (!empty($_POST['imgs_count'])) {
688
+ $percent_imeta = ceil($_POST['imgs_metas_statis'] / $_POST['imgs_count'] * 100);
689
+ } else {
690
+ $percent_imeta = 100;
691
+ }
692
+
693
+ $response['imgs_metas_statis'][2] = $percent_imeta;
694
+ $options_dashboard['image_meta'] = array(
695
+ 'imgs_statis' => array($_POST['imgs_statis'],$_POST['imgs_count'],$percent_iresizing),
696
+ 'imgs_metas_statis' => array($_POST['imgs_metas_statis'],$_POST['imgs_count'],$percent_imeta)
697
+ );
698
+
699
+ if(!empty($options_dashboard) && is_array($options_dashboard)){
700
+ if (empty($options_dashboard['image_meta'])) {
701
+ update_option('options_dashboard',$options_dashboard);
702
+ MetaSeo_Dashboard::_wpms_dash_last_update('image_meta');
703
+ }else{
704
+ $option_last_update_post = get_option('wpms_last_update_post');
705
+ $option_last_dash_update = get_option('_wpms_dash_last_update');
706
+ if((!empty($option_last_update_post) && $option_last_update_post > $option_last_dash_update) || empty($option_last_update_post)){
707
+ update_option('options_dashboard',$options_dashboard);
708
+ MetaSeo_Dashboard::_wpms_dash_last_update('image_meta');
709
+ }
710
+ }
711
+ }else{
712
+ update_option('options_dashboard',$options_dashboard);
713
+ MetaSeo_Dashboard::_wpms_dash_last_update('image_meta');
714
+ }
715
+
716
+ $options_dashboard = get_option('options_dashboard');
717
+ $results = $options_dashboard['image_meta'];
718
+ ob_start();
719
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/imgsresize.php';
720
+ $html_imgresize = ob_get_contents();
721
+ ob_end_clean();
722
+
723
+ ob_start();
724
+ require_once WPMETASEO_PLUGIN_DIR . 'inc/pages/dashboard/imgsmeta.php';
725
+ $html_imgsmeta = ob_get_contents();
726
+ ob_end_clean();
727
+ wp_send_json(array('status' => true ,'html_imgresize' => $html_imgresize , 'html_imgsmeta' => $html_imgsmeta));
728
+ }
729
+
730
+ wp_send_json($response);
731
+ }
732
}
inc/class.metaseo-image-list-table.php CHANGED
@@ -266,7 +266,7 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
266
/**
267
* Get months
268
*/
269
- function wpmf_get_months(){
270
global $wpdb;
271
$where = " AND ((post_mime_type='image/jpeg') OR (post_mime_type='image/jpg') OR (post_mime_type='image/png') OR (post_mime_type='image/gif')) ";
272
$months = $wpdb->get_results($wpdb->prepare("
@@ -286,7 +286,7 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
286
*/
287
function prepare_items() {
288
global $wpdb, $_wp_column_headers;
289
- $this->months = $this->wpmf_get_months();
290
$screen = get_current_screen();
291
292
$where = array();
266
/**
267
* Get months
268
*/
269
+ function wpms_get_months(){
270
global $wpdb;
271
$where = " AND ((post_mime_type='image/jpeg') OR (post_mime_type='image/jpg') OR (post_mime_type='image/png') OR (post_mime_type='image/gif')) ";
272
$months = $wpdb->get_results($wpdb->prepare("
286
*/
287
function prepare_items() {
288
global $wpdb, $_wp_column_headers;
289
+ $this->months = $this->wpms_get_months();
290
$screen = get_current_screen();
291
292
$where = array();
inc/class.metaseo-link-list-table.php CHANGED
@@ -264,7 +264,7 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
264
/**
265
* Get months
266
*/
267
- function wpmf_get_months(){
268
global $wpdb;
269
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
270
if (!empty($post_types['attachment']))
@@ -287,7 +287,7 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
287
*/
288
function prepare_items() {
289
global $wpdb, $_wp_column_headers;
290
- $this->months = $this->wpmf_get_months();
291
292
$where = array('1=1');
293
264
/**
265
* Get months
266
*/
267
+ function wpms_get_months(){
268
global $wpdb;
269
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
270
if (!empty($post_types['attachment']))
287
*/
288
function prepare_items() {
289
global $wpdb, $_wp_column_headers;
290
+ $this->months = $this->wpms_get_months();
291
292
$where = array('1=1');
293
inc/class.metaseo-metabox.php CHANGED
@@ -516,11 +516,17 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
516
$pageurl = get_permalink($post->ID);
517
$info = pathinfo($pageurl);
518
519
- if ($info['filename'] == sanitize_title($post->post_title) || (!empty($meta_analysis) && !empty($meta_analysis['pageurl']))) {
520
$output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'done', __('Page url matches with page title', 'wp-meta-seo'), 1);
521
$this->perc_score++;
522
- } else {
523
- $output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'warning', __('Page url matches with page title', 'wp-meta-seo'), 0);
524
}
525
526
return $output;
516
$pageurl = get_permalink($post->ID);
517
$info = pathinfo($pageurl);
518
519
+ $page_on_front = get_option('page_on_front');
520
+ if(!empty($page_on_front) && $page_on_front == $post->ID){
521
$output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'done', __('Page url matches with page title', 'wp-meta-seo'), 1);
522
$this->perc_score++;
523
+ }else{
524
+ if ($info['filename'] == sanitize_title($post->post_title) || (!empty($meta_analysis) && !empty($meta_analysis['pageurl']))) {
525
+ $output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'done', __('Page url matches with page title', 'wp-meta-seo'), 1);
526
+ $this->perc_score++;
527
+ } else {
528
+ $output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'warning', __('Page url matches with page title', 'wp-meta-seo'), 0);
529
+ }
530
}
531
532
return $output;
inc/class.metaseo-sitemap.php CHANGED
@@ -27,6 +27,17 @@ class MetaSeo_Sitemap {
27
"wpms_sitemap_pages" => array(),
28
);
29
30
if (is_multisite()) {
31
$home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
32
$this->settings_sitemap['wpms_sitemap_link'] = site_url() . '/wpms-sitemap_' . $home_url . '.xml';
@@ -55,7 +66,7 @@ class MetaSeo_Sitemap {
55
add_action('wp_ajax_wpms_regenerate_sitemaps', array($this, 'wpms_regenerate_sitemaps'));
56
add_action('wp_ajax_wpms_save_sitemap_settings', array($this, 'wpms_save_sitemap_settings'));
57
}
58
-
59
/* load metaseo script and style front-end */
60
public function site_metaseo_sitemap_scripts() {
61
global $post;
@@ -71,7 +82,11 @@ class MetaSeo_Sitemap {
71
72
/* Localize a script */
73
public function wpms_localize_script() {
74
- $arrays = array('wpms_display_column_menus' => $this->settings_sitemap['wpms_display_column_menus']);
75
return $arrays;
76
}
77
@@ -81,6 +96,7 @@ class MetaSeo_Sitemap {
81
if (!empty($current_screen) && $current_screen->base != 'wp-meta-seo_page_metaseo_google_sitemap')
82
return;
83
wp_enqueue_script('metaseositemap', plugins_url('js/metaseo_sitemap.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
84
wp_enqueue_script('jpage-js', plugins_url('js/jPages.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
85
wp_enqueue_style('metaseositemapstyle', plugins_url('css/metaseo_sitemap.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
86
wp_enqueue_style('jpage-css', plugins_url('css/jPages.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
@@ -88,6 +104,18 @@ class MetaSeo_Sitemap {
88
wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
89
}
90
91
/* Add a new field to a section of a sitemap settings page */
92
public function metaseo_field_settings_sitemap() {
93
register_setting('MetaSEO Sitemap', '_metaseo_settings_sitemap');
@@ -395,7 +423,74 @@ class MetaSeo_Sitemap {
395
}
396
}
397
}
398
-
399
// add pages
400
$res = $this->wpms_get_pages_sitemap();
401
if (!empty($res)) {
@@ -588,12 +683,13 @@ class MetaSeo_Sitemap {
588
$query = new WP_Query($args);
589
$postsTest = $query->get_posts();
590
if (!empty($postsTest)) {
591
- $checkSitemap = 'post_types-' . $post_type . '-not_in_sitemap';
592
if (( in_array($post_type, array('post', 'page', 'attachment')))) {
593
continue;
594
}
595
$postType = get_post_type_object($post_type);
596
$postTypeLink = get_post_type_archive_link($postType->name);
597
$html .= '<div id="sitemap_' . str_replace(' ', '', strtolower($postType->labels->name)) . '">';
598
if (!empty($postTypeLink)) {
599
$html .= '<h3><a href="' . $postTypeLink . '">' . $postType->labels->name . '</a></h3>';
@@ -688,8 +784,79 @@ class MetaSeo_Sitemap {
688
}
689
}
690
}
691
692
693
694
$ids_menu = array(0);
695
$check_menu = array();
@@ -878,28 +1045,76 @@ class MetaSeo_Sitemap {
878
$pages = $query->get_posts();
879
return $pages;
880
}
881
-
882
/* get posts by category */
883
public function wpms_get_posts() {
884
$posts = array();
885
$taxo = 'category';
886
$categorys = get_categories(array('hide_empty' => false, 'taxonomy' => $taxo));
887
-
888
foreach ($categorys as $cat) {
889
- $args = array(
890
- 'posts_per_page' => -1,
891
- 'tax_query' => array(
892
- array(
893
- 'taxonomy' => $taxo,
894
- 'field' => 'slug',
895
- 'terms' => $cat->slug,
896
- ),
897
- ),
898
- );
899
- $query = new WP_Query($args);
900
- $results = $query->get_posts();
901
if (!empty($results)) {
902
- $posts[$cat->cat_name . '||' . $cat->cat_ID . '||' . $taxo . '||' . $cat->slug] = $results;
903
}
904
}
905
@@ -1171,6 +1386,9 @@ class MetaSeo_Sitemap {
1171
wp_send_json(array('status' => false, 'message' => $error));
1172
}
1173
}
1174
wp_send_json(array('status' => true, 'message' => 'success'));
1175
}
1176
@@ -1223,6 +1441,17 @@ class MetaSeo_Sitemap {
1223
"wpms_category_link" => array()
1224
);
1225
1226
$wpms_display_column_menus = json_decode(stripslashes($_POST['wpms_display_column_menus']),true);
1227
if (!empty($wpms_display_column_menus)) {
1228
$settings_sitemap['wpms_display_column_menus'] = $wpms_display_column_menus;
@@ -1242,6 +1471,15 @@ class MetaSeo_Sitemap {
1242
"wpms_sitemap_menus" => array()
1243
);
1244
1245
foreach ($lists_selected as $k => $v) {
1246
if (isset($_POST[$k]) && $_POST[$k] != '{}') {
1247
$values = json_decode(stripslashes($_POST[$k]),true);
27
"wpms_sitemap_pages" => array(),
28
);
29
30
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)) {
31
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false, '_builtin' => false));
32
+ if (!empty($custom_post_types)) {
33
+ foreach ($custom_post_types as $post_type => $label) {
34
+ $this->settings_sitemap['wpms_display_column_' . $post_type] = 1;
35
+ $this->settings_sitemap['wpms_public_name_' . $post_type] = "";
36
+ $this->settings_sitemap['wpms_sitemap_' . $post_type] = array();
37
+ }
38
+ }
39
+ }
40
+
41
if (is_multisite()) {
42
$home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
43
$this->settings_sitemap['wpms_sitemap_link'] = site_url() . '/wpms-sitemap_' . $home_url . '.xml';
66
add_action('wp_ajax_wpms_regenerate_sitemaps', array($this, 'wpms_regenerate_sitemaps'));
67
add_action('wp_ajax_wpms_save_sitemap_settings', array($this, 'wpms_save_sitemap_settings'));
68
}
69
+
70
/* load metaseo script and style front-end */
71
public function site_metaseo_sitemap_scripts() {
72
global $post;
82
83
/* Localize a script */
84
public function wpms_localize_script() {
85
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false ,'_builtin' => false));
86
+ $arrays = array(
87
+ 'wpms_display_column_menus' => $this->settings_sitemap['wpms_display_column_menus'],
88
+ 'post_type' => $custom_post_types
89
+ );
90
return $arrays;
91
}
92
96
if (!empty($current_screen) && $current_screen->base != 'wp-meta-seo_page_metaseo_google_sitemap')
97
return;
98
wp_enqueue_script('metaseositemap', plugins_url('js/metaseo_sitemap.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
99
+ wp_localize_script('metaseositemap', 'wpmseositemap', $this->meta_seo_localize_script());
100
wp_enqueue_script('jpage-js', plugins_url('js/jPages.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
101
wp_enqueue_style('metaseositemapstyle', plugins_url('css/metaseo_sitemap.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
102
wp_enqueue_style('jpage-css', plugins_url('css/jPages.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
104
wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
105
}
106
107
+ /**
108
+ * Localize a script.
109
+ *
110
+ * Works only if the script has already been added.
111
+ */
112
+ public function meta_seo_localize_script(){
113
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false ,'_builtin' => false));
114
+ return array(
115
+ 'post_type' => $custom_post_types
116
+ );
117
+ }
118
+
119
/* Add a new field to a section of a sitemap settings page */
120
public function metaseo_field_settings_sitemap() {
121
register_setting('MetaSEO Sitemap', '_metaseo_settings_sitemap');
423
}
424
}
425
}
426
+
427
+ // add custom post type
428
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)){
429
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false ,'_builtin' => false));
430
+ if(!empty($custom_post_types)) {
431
+ foreach ($custom_post_types as $post_type => $label) {
432
+ $ids = array(0);
433
+ $settings_sitemap = get_option('_metaseo_settings_sitemap');
434
+ if (!empty($settings_sitemap['wpms_sitemap_'.$post_type])) {
435
+ foreach ((array) $settings_sitemap['wpms_sitemap_'.$post_type] as $k => $v) {
436
+ if (!empty($v['post_id'])) {
437
+ $ids[] = $v['post_id'];
438
+ }
439
+ }
440
+ }
441
+
442
+ $args = array(
443
+ 'posts_per_page' => -1,
444
+ 'post_type' => $post_type,
445
+ 'post__in' => $ids,
446
+ 'post_status' => 'any'
447
+ );
448
+ $query = new WP_Query($args);
449
+ $posts = $query->get_posts();
450
+ if (!empty($posts)) {
451
+ foreach ($posts as $val) {
452
+ $permalink = get_permalink($val->ID);
453
+ if (!in_array($permalink, $list_links)) {
454
+ $list_links[] = $permalink;
455
+ $gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
456
+ $loc = $gglstmp_url->appendChild($xml->createElement('loc'));
457
+ $loc->appendChild($xml->createTextNode($permalink));
458
+ $lastmod = $gglstmp_url->appendChild($xml->createElement('lastmod'));
459
+ $now = $val->post_modified;
460
+ $date = date('Y-m-d\TH:i:sP', strtotime($now));
461
+ $lastmod->appendChild($xml->createTextNode($date));
462
+ $changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
463
+ if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
464
+ $changefreq->appendChild($xml->createTextNode('monthly'));
465
+ } else {
466
+ if(empty($this->settings_sitemap['wpms_sitemap_'.$post_type][$val->ID]['frequency'])){
467
+ $postfrequency = 'monthly';
468
+ }else{
469
+ $postfrequency = $this->settings_sitemap['wpms_sitemap_'.$post_type][$val->ID]['frequency'];
470
+ }
471
+ $changefreq->appendChild($xml->createTextNode($postfrequency));
472
+ }
473
+
474
+ $priority = $gglstmp_url->appendChild($xml->createElement('priority'));
475
+ if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
476
+ $priority->appendChild($xml->createTextNode('1.0'));
477
+ } else {
478
+ if(empty($this->settings_sitemap['wpms_sitemap_'.$post_type][$val->ID]['priority'])){
479
+ $postpriority = '1.0';
480
+ }else{
481
+ $postpriority = $this->settings_sitemap['wpms_sitemap_'.$post_type][$val->ID]['priority'];
482
+ }
483
+ $priority->appendChild($xml->createTextNode($postpriority));
484
+ }
485
+ }
486
+ }
487
+ }
488
+
489
+ }
490
+ }
491
+ }
492
+ // ========================================
493
+
494
// add pages
495
$res = $this->wpms_get_pages_sitemap();
496
if (!empty($res)) {
683
$query = new WP_Query($args);
684
$postsTest = $query->get_posts();
685
if (!empty($postsTest)) {
686
if (( in_array($post_type, array('post', 'page', 'attachment')))) {
687
continue;
688
}
689
+
690
$postType = get_post_type_object($post_type);
691
$postTypeLink = get_post_type_archive_link($postType->name);
692
+ var_dump(str_replace(' ', '', strtolower($postType->labels->name)));
693
$html .= '<div id="sitemap_' . str_replace(' ', '', strtolower($postType->labels->name)) . '">';
694
if (!empty($postTypeLink)) {
695
$html .= '<h3><a href="' . $postTypeLink . '">' . $postType->labels->name . '</a></h3>';
784
}
785
}
786
}
787
+ // custom post type
788
+ if (is_plugin_active(WPMSEO_ADDON_FILENAME)) {
789
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false, '_builtin' => false));
790
+ if (!empty($custom_post_types)) {
791
+ foreach ($custom_post_types as $post_type => $label) {
792
+ if ($i == (int)$this->settings_sitemap['wpms_display_column_' . $post_type]) {
793
+ //=====================================================================================
794
+ if(isset($this->settings_sitemap['wpms_public_name_'.$post_type]) && $this->settings_sitemap['wpms_public_name_'.$post_type] != ''){
795
+ $postTitle = $this->settings_sitemap['wpms_public_name_'.$post_type];
796
+ }else{
797
+ $postTitle = get_post_type_object($post_type);
798
+ $postTitle = $postTitle->label;
799
+ }
800
801
+ $html .= '<div id="sitemap_posts" class="wpms_sitemap_posts"><h4>';
802
+ $html .= $postTitle;
803
+ $html .= '</h4><ul>';
804
+
805
+ global $wpdb;
806
+ $taxonomy_objects = get_object_taxonomies($post_type, 'names');
807
+ $ids = array(0);
808
+ if (!empty($this->settings_sitemap['wpms_sitemap_' . $post_type])) {
809
+ foreach ((array)$this->settings_sitemap['wpms_sitemap_' . $post_type] as $k => $v) {
810
+ if (!empty($v['post_id'])) {
811
+ $ids[] = $k;
812
+ }
813
+ }
814
+ }
815
+ foreach ($taxonomy_objects as $taxo) {
816
+
817
+ $categorys = get_categories(array('hide_empty' => false, 'taxonomy' => $taxo));
818
+ foreach ($categorys as $cat) {
819
+
820
+ $sql = "SELECT p.ID as ID,p.post_title as post_title
821
+ FROM $wpdb->posts AS p
822
+ INNER JOIN $wpdb->term_relationships AS tr ON (p.ID = tr.object_id)
823
+ INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
824
+ INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id)
825
+ WHERE p.post_status = 'publish'
826
+ AND p.post_type = '$post_type'
827
+ AND tt.taxonomy = '$taxo' AND t.slug='$cat->slug'
828
+ ORDER BY p.post_date DESC";
829
+ $results = $wpdb->get_results($sql);
830
+ if (!empty($results)) {
831
+ if (in_array($cat->cat_ID, $this->settings_sitemap['wpms_category_link'])) {
832
+ $cat_link = "<a href='" . esc_url(get_term_link($cat)) . "'>" . $cat->cat_name . "</a>";
833
+ } else {
834
+ $cat_link = $cat->cat_name;
835
+ }
836
+ $html .= "<li class='wpms_li_cate wpms_li_cate'><div class='cat_name'>$cat_link</div>";
837
+
838
+ if (!empty($this->settings_sitemap['wpms_sitemap_' . $post_type])) {
839
+ $html .= "<ul>";
840
+ foreach ($results as $p) {
841
+ if (isset($this->settings_sitemap['wpms_sitemap_' . $post_type][$cat->cat_ID . '-' . $p->ID])) {
842
+ $html .= '<li><a href="' . get_permalink($p->ID) . '">' . $p->post_title . '</a></li>';
843
+ }
844
+ }
845
+ $html .= "</ul>";
846
+ }
847
+ $html .= "</li>";
848
+ }
849
+ }
850
+ }
851
+ $html .= '</ul></div>';
852
853
+ //======================================================================================
854
+ }
855
+ }
856
+ }
857
+
858
+ }
859
+ // ====================
860
861
$ids_menu = array(0);
862
$check_menu = array();
1045
$pages = $query->get_posts();
1046
return $pages;
1047
}
1048
+
1049
+
1050
+ /* get pages */
1051
+ public function wpms_get_pages() {
1052
+ global $wpdb;
1053
+ $sql = "SELECT ID,post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'page' ORDER BY post_date DESC";
1054
+ $pages = $wpdb->get_results($sql);
1055
+ return $pages;
1056
+ }
1057
+
1058
/* get posts by category */
1059
public function wpms_get_posts() {
1060
$posts = array();
1061
$taxo = 'category';
1062
$categorys = get_categories(array('hide_empty' => false, 'taxonomy' => $taxo));
1063
+ global $wpdb;
1064
foreach ($categorys as $cat) {
1065
+ $sql = $wpdb->prepare("SELECT p.ID as ID,p.post_title as post_title
1066
+ FROM $wpdb->posts AS p
1067
+ INNER JOIN $wpdb->term_relationships AS tr ON (p.ID = tr.object_id)
1068
+ INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
1069
+ INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id)
1070
+ WHERE p.post_status = 'publish'
1071
+ AND p.post_type = 'post'
1072
+ AND tt.taxonomy = %s AND t.slug=%s
1073
+ ORDER BY p.post_date DESC",array($taxo,$cat->slug));
1074
+ $results = $wpdb->get_results($sql);
1075
if (!empty($results)) {
1076
+ $obj = new StdClass();
1077
+ $obj->cat_name = $cat->cat_name;
1078
+ $obj->cat_ID = $cat->cat_ID;
1079
+ $obj->taxo = $taxo;
1080
+ $obj->slug = $cat->slug;
1081
+ $obj->results = $results;
1082
+ $posts[] = $obj;
1083
+ }
1084
+ }
1085
+
1086
+ return $posts;
1087
+ }
1088
+
1089
+ /* get posts by category */
1090
+ public function wpms_get_posts_custom($post_type) {
1091
+ $posts = array();
1092
+ $taxonomy_objects = get_object_taxonomies($post_type, 'names' );
1093
+ foreach ($taxonomy_objects as $taxo){
1094
+ $categorys = get_categories(array('hide_empty' => false, 'taxonomy' => $taxo));
1095
+ global $wpdb;
1096
+
1097
+ foreach ($categorys as $cat) {
1098
+ $sql = $wpdb->prepare("SELECT p.ID as ID,p.post_title as post_title
1099
+ FROM $wpdb->posts AS p
1100
+ INNER JOIN $wpdb->term_relationships AS tr ON (p.ID = tr.object_id)
1101
+ INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
1102
+ INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id)
1103
+ WHERE p.post_status = 'publish'
1104
+ AND p.post_type = %s
1105
+ AND tt.taxonomy = %s AND t.slug=%s
1106
+ ORDER BY p.post_date DESC",array($post_type,$taxo,$cat->slug));
1107
+ $results = $wpdb->get_results($sql);
1108
+
1109
+ if (!empty($results)) {
1110
+ $obj = new StdClass();
1111
+ $obj->cat_name = $cat->cat_name;
1112
+ $obj->cat_ID = $cat->cat_ID;
1113
+ $obj->taxo = $taxo;
1114
+ $obj->slug = $cat->slug;
1115
+ $obj->results = $results;
1116
+ $posts[] = $obj;
1117
+ }
1118
}
1119
}
1120
1386
wp_send_json(array('status' => false, 'message' => $error));
1387
}
1388
}
1389
+
1390
+ // Don't ping if blog is not public.
1391
+ do_action('wpms_submit_sitemap');
1392
wp_send_json(array('status' => true, 'message' => 'success'));
1393
}
1394
1441
"wpms_category_link" => array()
1442
);
1443
1444
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)) {
1445
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false, '_builtin' => false));
1446
+ if (!empty($custom_post_types)) {
1447
+ foreach ($custom_post_types as $post_type => $label) {
1448
+ $lists['wpms_display_column_' . $post_type] = 1;
1449
+ $lists['wpms_public_name_' . $post_type] = "";
1450
+ $lists['wpms_sitemap_' . $post_type] = array();
1451
+ }
1452
+ }
1453
+ }
1454
+
1455
$wpms_display_column_menus = json_decode(stripslashes($_POST['wpms_display_column_menus']),true);
1456
if (!empty($wpms_display_column_menus)) {
1457
$settings_sitemap['wpms_display_column_menus'] = $wpms_display_column_menus;
1471
"wpms_sitemap_menus" => array()
1472
);
1473
1474
+ if(is_plugin_active(WPMSEO_ADDON_FILENAME)){
1475
+ $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false ,'_builtin' => false));
1476
+ if(!empty($custom_post_types)) {
1477
+ foreach ($custom_post_types as $post_type => $label) {
1478
+ $lists_selected["wpms_sitemap_".$post_type] = array();
1479
+ }
1480
+ }
1481
+ }
1482
+
1483
foreach ($lists_selected as $k => $v) {
1484
if (isset($_POST[$k]) && $_POST[$k] != '{}') {
1485
$values = json_decode(stripslashes($_POST[$k]),true);
inc/google_analytics/tracking/code-classic.php CHANGED
@@ -1,4 +1,13 @@
1
<?php
2
// Exit if accessed directly
3
if ( ! defined( 'ABSPATH' ) )
4
exit();
1
<?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ * Modified by Joomunited
9
+ */
10
+
11
// Exit if accessed directly
12
if ( ! defined( 'ABSPATH' ) )
13
exit();
inc/google_analytics/tracking/code-universal.php CHANGED
@@ -1,4 +1,13 @@
1
<?php
2
// Exit if accessed directly
3
if ( ! defined( 'ABSPATH' ) )
4
exit();
1
<?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ * Modified by Joomunited
9
+ */
10
+
11
// Exit if accessed directly
12
if ( ! defined( 'ABSPATH' ) )
13
exit();
inc/google_analytics/tracking/events-classic.php CHANGED
@@ -1,4 +1,13 @@
1
<?php