SEOPress - Version 4.7.0.2

Version Description

(5/07/2021) = * FIX AIO SEO import tool

Download this release

Release Info

Developer rainbowgeek
Plugin Icon 128x128 SEOPress
Version 4.7.0.2
Comparing to
See all releases

Code changes from version 4.7 to 4.7.0.2

Files changed (3) hide show
  1. inc/admin/ajax-migrate/aio.php +143 -64
  2. readme.txt +8 -4
  3. seopress.php +196 -140
inc/admin/ajax-migrate/aio.php CHANGED
@@ -5,7 +5,8 @@ defined('ABSPATH') or exit('Please don’t call the plugin directly. Thanks
5
  ///////////////////////////////////////////////////////////////////////////////////////////////////
6
  //AIO migration
7
  ///////////////////////////////////////////////////////////////////////////////////////////////////
8
- function seopress_aio_migration() {
 
9
  check_ajax_referer('seopress_aio_migrate_nonce', $_POST['_ajax_nonce'], true);
10
 
11
  if (current_user_can(seopress_capability('manage_options', 'migration')) && is_admin()) {
@@ -20,58 +21,6 @@ function seopress_aio_migration() {
20
  global $post;
21
 
22
  if ($offset > $total_count_posts) {
23
- wp_reset_query();
24
-
25
- $args = [
26
- //'number' => $increment,
27
- 'hide_empty' => false,
28
- //'offset' => $offset,
29
- 'fields' => 'ids',
30
- ];
31
- $aio_query_terms = get_terms($args);
32
-
33
- if ($aio_query_terms) {
34
- foreach ($aio_query_terms as $term_id) {
35
- if ('' != get_term_meta($term_id, '_aioseop_title', true)) { //Import title tag
36
- update_term_meta($term_id, '_seopress_titles_title', get_term_meta($term_id, '_aioseop_title', true));
37
- }
38
- if ('' != get_term_meta($term_id, '_aioseop_description', true)) { //Import meta desc
39
- update_term_meta($term_id, '_seopress_titles_desc', get_term_meta($term_id, '_aioseop_description', true));
40
- }
41
- if ('' != get_term_meta($term_id, '_aioseop_opengraph_settings', true)) { //Import Facebook / Twitter Title
42
- $_aioseop_opengraph_settings = get_term_meta($term_id, '_aioseop_opengraph_settings', true);
43
- if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_title'])) {
44
- update_term_meta($term_id, '_seopress_social_fb_title', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
45
- update_term_meta($term_id, '_seopress_social_twitter_title', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
46
- }
47
- }
48
- if ('' != get_term_meta($term_id, '_aioseop_opengraph_settings', true)) { //Import Facebook / Twitter Title
49
- $_aioseop_opengraph_settings = get_term_meta($term_id, '_aioseop_opengraph_settings', true);
50
- if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_desc'])) {
51
- update_term_meta($term_id, '_seopress_social_fb_desc', $_aioseop_opengraph_settings['aioseop_opengraph_settings_desc']);
52
- update_term_meta($term_id, '_seopress_social_twitter_desc', $_aioseop_opengraph_settings['aioseop_opengraph_settings_desc']);
53
- }
54
- }
55
- if ('' != get_term_meta($term_id, '_aioseop_opengraph_settings', true)) { //Import Facebook Image
56
- $_aioseop_opengraph_settings = get_term_meta($term_id, '_aioseop_opengraph_settings', true);
57
- if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_image'])) {
58
- update_term_meta($term_id, '_seopress_social_fb_img', $_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg']);
59
- }
60
- }
61
- if ('' != get_term_meta($term_id, '_aioseop_opengraph_settings', true)) { //Import Twitter Image
62
- $_aioseop_opengraph_settings = get_term_meta($term_id, '_aioseop_opengraph_settings', true);
63
- if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_image'])) {
64
- update_term_meta($term_id, '_seopress_social_twitter_img', $_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg_twitter']);
65
- }
66
- }
67
- if ('on' == get_term_meta($term_id, '_aioseop_noindex', true)) { //Import Robots NoIndex
68
- update_term_meta($term_id, '_seopress_robots_index', 'yes');
69
- }
70
- if ('on' == get_term_meta($term_id, '_aioseop_nofollow', true)) { //Import Robots NoIndex
71
- update_term_meta($term_id, '_seopress_robots_follow', 'yes');
72
- }
73
- }
74
- }
75
  $offset = 'done';
76
  wp_reset_query();
77
  } else {
@@ -86,44 +35,174 @@ function seopress_aio_migration() {
86
 
87
  if ($aio_query) {
88
  foreach ($aio_query as $post) {
89
- if ('' != get_post_meta($post->ID, '_aioseop_title', true)) { //Import title tag
 
 
90
  update_post_meta($post->ID, '_seopress_titles_title', get_post_meta($post->ID, '_aioseop_title', true));
91
  }
92
- if ('' != get_post_meta($post->ID, '_aioseop_description', true)) { //Import meta desc
 
 
93
  update_post_meta($post->ID, '_seopress_titles_desc', get_post_meta($post->ID, '_aioseop_description', true));
94
  }
95
- if ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import Facebook / Twitter Title
 
 
 
96
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
97
  if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_title'])) {
98
  update_post_meta($post->ID, '_seopress_social_fb_title', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
 
 
 
 
 
 
 
 
99
  update_post_meta($post->ID, '_seopress_social_twitter_title', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
100
  }
101
  }
102
- if ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import Facebook / Twitter Desc
 
 
 
103
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
104
- if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_desc'])) {
105
- update_post_meta($post->ID, '_seopress_social_fb_desc', $_aioseop_opengraph_settings['aioseop_opengraph_settings_desc']);
106
- update_post_meta($post->ID, '_seopress_social_twitter_desc', $_aioseop_opengraph_settings['aioseop_opengraph_settings_desc']);
107
  }
108
  }
109
- if ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import Facebook Image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
111
  if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_image'])) {
112
  update_post_meta($post->ID, '_seopress_social_fb_img', $_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg']);
113
  }
114
  }
115
- if ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import Twitter Image
 
 
 
 
 
 
 
 
 
116
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
117
  if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg_twitter'])) {
118
  update_post_meta($post->ID, '_seopress_social_twitter_img', $_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg_twitter']);
119
  }
120
  }
121
- if ('on' == get_post_meta($post->ID, '_aioseop_noindex', true)) { //Import Robots NoIndex
 
 
 
 
 
 
 
 
 
122
  update_post_meta($post->ID, '_seopress_robots_index', 'yes');
123
  }
124
- if ('on' == get_post_meta($post->ID, '_aioseop_nofollow', true)) { //Import Robots NoFollow
 
 
 
 
 
 
 
 
 
125
  update_post_meta($post->ID, '_seopress_robots_follow', 'yes');
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
  }
129
  $offset += $increment;
5
  ///////////////////////////////////////////////////////////////////////////////////////////////////
6
  //AIO migration
7
  ///////////////////////////////////////////////////////////////////////////////////////////////////
8
+ function seopress_aio_migration()
9
+ {
10
  check_ajax_referer('seopress_aio_migrate_nonce', $_POST['_ajax_nonce'], true);
11
 
12
  if (current_user_can(seopress_capability('manage_options', 'migration')) && is_admin()) {
21
  global $post;
22
 
23
  if ($offset > $total_count_posts) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  $offset = 'done';
25
  wp_reset_query();
26
  } else {
35
 
36
  if ($aio_query) {
37
  foreach ($aio_query as $post) {
38
+ if ('' != get_post_meta($post->ID, '_aioseo_title', true)) { //Import title tag
39
+ update_post_meta($post->ID, '_seopress_titles_title', get_post_meta($post->ID, '_aioseo_title', true));
40
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_title', true)) { //Import old title tag
41
  update_post_meta($post->ID, '_seopress_titles_title', get_post_meta($post->ID, '_aioseop_title', true));
42
  }
43
+ if ('' != get_post_meta($post->ID, '_aioseo_description', true)) { //Import meta desc
44
+ update_post_meta($post->ID, '_seopress_titles_desc', get_post_meta($post->ID, '_aioseo_description', true));
45
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_description', true)) { //Import old meta desc
46
  update_post_meta($post->ID, '_seopress_titles_desc', get_post_meta($post->ID, '_aioseop_description', true));
47
  }
48
+
49
+ if ('' != get_post_meta($post->ID, '_aioseo_og_title', true)) { //Import Facebook Title
50
+ update_post_meta($post->ID, '_seopress_social_fb_title', get_post_meta($post->ID, '_aioseo_og_title', true));
51
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import old Facebook
52
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
53
  if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_title'])) {
54
  update_post_meta($post->ID, '_seopress_social_fb_title', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
55
+ }
56
+ }
57
+
58
+ if ('' != get_post_meta($post->ID, '_aioseo_twitter_title', true)) { //Import Twitter Title
59
+ update_post_meta($post->ID, '_seopress_social_twitter_title', get_post_meta($post->ID, '_aioseo_twitter_title', true));
60
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import old Twitter Title
61
+ $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
62
+ if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_title'])) {
63
  update_post_meta($post->ID, '_seopress_social_twitter_title', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
64
  }
65
  }
66
+
67
+ if ('' != get_post_meta($post->ID, '_aioseo_og_description', true)) { //Import Facebook Desc
68
+ update_post_meta($post->ID, '_seopress_social_fb_desc', get_post_meta($post->ID, '_aioseo_og_description', true));
69
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import old Facebook Desc
70
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
71
+ if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_title'])) {
72
+ update_post_meta($post->ID, '_seopress_social_fb_desc', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
 
73
  }
74
  }
75
+
76
+ if ('' != get_post_meta($post->ID, '_aioseo_twitter_description', true)) { //Import Twitter Desc
77
+ update_post_meta($post->ID, '_seopress_social_twitter_desc', get_post_meta($post->ID, '_aioseo_twitter_description', true));
78
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import old Twitter Desc
79
+ $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
80
+ if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_title'])) {
81
+ update_post_meta($post->ID, '_seopress_social_twitter_desc', $_aioseop_opengraph_settings['aioseop_opengraph_settings_title']);
82
+ }
83
+ }
84
+
85
+ $canonical_url = "SELECT p.canonical_url, p.post_id
86
+ FROM {$wpdb->prefix}aioseo_posts p
87
+ WHERE p.post_id = $post->ID";
88
+
89
+ $canonical_url = $wpdb->get_results($canonical_url, ARRAY_A);
90
+
91
+ if (! empty($canonical_url[0]['canonical_url'])) {//Import Canonical URL
92
+ update_post_meta($post->ID, '_seopress_robots_canonical', $canonical_url[0]['canonical_url']);
93
+ }
94
+
95
+ $og_img_url = "SELECT p.og_image_custom_url, p.post_id
96
+ FROM {$wpdb->prefix}aioseo_posts p
97
+ WHERE p.og_image_type = 'custom_image' AND p.post_id = $post->ID";
98
+
99
+ $og_img_url = $wpdb->get_results($og_img_url, ARRAY_A);
100
+
101
+ if (! empty($og_img_url[0]['og_image_custom_url'])) {//Import Facebook Image
102
+ update_post_meta($post->ID, '_seopress_social_fb_img', $og_img_url[0]['og_image_custom_url']);
103
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import old Facebook Image
104
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
105
  if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_image'])) {
106
  update_post_meta($post->ID, '_seopress_social_fb_img', $_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg']);
107
  }
108
  }
109
+
110
+ $tw_img_url = "SELECT p.twitter_image_custom_url, p.post_id
111
+ FROM {$wpdb->prefix}aioseo_posts p
112
+ WHERE p.twitter_image_type = 'custom_image' AND p.post_id = $post->ID";
113
+
114
+ $tw_img_url = $wpdb->get_results($tw_img_url, ARRAY_A);
115
+
116
+ if (! empty($tw_img_url[0]['twitter_image_custom_url'])) {//Import Twitter Image
117
+ update_post_meta($post->ID, '_seopress_social_twitter_img', $tw_img_url[0]['twitter_image_custom_url']);
118
+ } elseif ('' != get_post_meta($post->ID, '_aioseop_opengraph_settings', true)) { //Import old Twitter Image
119
  $_aioseop_opengraph_settings = get_post_meta($post->ID, '_aioseop_opengraph_settings', true);
120
  if (isset($_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg_twitter'])) {
121
  update_post_meta($post->ID, '_seopress_social_twitter_img', $_aioseop_opengraph_settings['aioseop_opengraph_settings_customimg_twitter']);
122
  }
123
  }
124
+
125
+ $robots_noindex = "SELECT p.robots_noindex, p.post_id
126
+ FROM {$wpdb->prefix}aioseo_posts p
127
+ WHERE p.post_id = $post->ID";
128
+
129
+ $robots_noindex = $wpdb->get_results($robots_noindex, ARRAY_A);
130
+
131
+ if (! empty($robots_noindex[0]['robots_noindex']) && '1' === $robots_noindex[0]['robots_noindex']) {//Import Robots NoIndex
132
+ update_post_meta($post->ID, '_seopress_robots_index', 'yes');
133
+ } elseif ('on' == get_post_meta($post->ID, '_aioseop_noindex', true)) { //Import old Robots NoIndex
134
  update_post_meta($post->ID, '_seopress_robots_index', 'yes');
135
  }
136
+
137
+ $robots_nofollow = "SELECT p.robots_nofollow, p.post_id
138
+ FROM {$wpdb->prefix}aioseo_posts p
139
+ WHERE p.post_id = $post->ID";
140
+
141
+ $robots_nofollow = $wpdb->get_results($robots_nofollow, ARRAY_A);
142
+
143
+ if (! empty($robots_nofollow[0]['robots_nofollow']) && '1' === $robots_nofollow[0]['robots_nofollow']) {//Import Robots NoFollow
144
+ update_post_meta($post->ID, '_seopress_robots_follow', 'yes');
145
+ } elseif ('on' == get_post_meta($post->ID, '_aioseop_nofollow', true)) { //Import old Robots NoFollow
146
  update_post_meta($post->ID, '_seopress_robots_follow', 'yes');
147
  }
148
+
149
+ $robots_noimageindex = "SELECT p.robots_noimageindex, p.post_id
150
+ FROM {$wpdb->prefix}aioseo_posts p
151
+ WHERE p.post_id = $post->ID";
152
+
153
+ $robots_noimageindex = $wpdb->get_results($robots_noimageindex, ARRAY_A);
154
+
155
+ if (! empty($robots_noimageindex[0]['robots_noimageindex']) && '1' === $robots_noimageindex[0]['robots_noimageindex']) {//Import Robots NoImageIndex
156
+ update_post_meta($post->ID, '_seopress_robots_imageindex', 'yes');
157
+ }
158
+
159
+ $robots_noodp = "SELECT p.robots_noodp, p.post_id
160
+ FROM {$wpdb->prefix}aioseo_posts p
161
+ WHERE p.post_id = $post->ID";
162
+
163
+ $robots_noodp = $wpdb->get_results($robots_noodp, ARRAY_A);
164
+
165
+ if (! empty($robots_noodp[0]['robots_noodp']) && '1' === $robots_noodp[0]['robots_noodp']) {//Import Robots NoOdp
166
+ update_post_meta($post->ID, '_seopress_robots_odp', 'yes');
167
+ }
168
+
169
+ $robots_nosnippet = "SELECT p.robots_nosnippet, p.post_id
170
+ FROM {$wpdb->prefix}aioseo_posts p
171
+ WHERE p.post_id = $post->ID";
172
+
173
+ $robots_nosnippet = $wpdb->get_results($robots_nosnippet, ARRAY_A);
174
+
175
+ if (! empty($robots_nosnippet[0]['robots_nosnippet']) && '1' === $robots_nosnippet[0]['robots_nosnippet']) {//Import Robots NoSnippet
176
+ update_post_meta($post->ID, '_seopress_robots_snippet', 'yes');
177
+ }
178
+
179
+ $robots_noarchive = "SELECT p.robots_noarchive, p.post_id
180
+ FROM {$wpdb->prefix}aioseo_posts p
181
+ WHERE p.post_id = $post->ID";
182
+
183
+ $robots_noarchive = $wpdb->get_results($robots_noarchive, ARRAY_A);
184
+
185
+ if (! empty($robots_noarchive[0]['robots_noarchive']) && '1' === $robots_noarchive[0]['robots_noarchive']) {//Import Robots NoArchive
186
+ update_post_meta($post->ID, '_seopress_robots_archive', 'yes');
187
+ }
188
+
189
+ $keyphrases = "SELECT p.keyphrases, p.post_id
190
+ FROM {$wpdb->prefix}aioseo_posts p
191
+ WHERE p.post_id = $post->ID";
192
+
193
+ $keyphrases = $wpdb->get_results($keyphrases, ARRAY_A);
194
+
195
+ if (! empty($keyphrases)) {
196
+ $keyphrases = json_decode($keyphrases[0]['keyphrases']);
197
+
198
+ if (isset($keyphrases->focus->keyphrase)) {
199
+ $keyphrases = $keyphrases->focus->keyphrase;
200
+
201
+ if ('' != $keyphrases) { //Import focus kw
202
+ update_post_meta($post->ID, '_seopress_analysis_target_kw', $keyphrases);
203
+ }
204
+ }
205
+ }
206
  }
207
  }
208
  $offset += $increment;
readme.txt CHANGED
@@ -4,9 +4,9 @@ Contributors: rainbowgeek, gmulti, juliobox, maigret, mgris
4
  Donate link: https://www.seopress.org/
5
  Tags: SEO, XML sitemap, meta title, open graph, content analysis, knowledge graph, redirection, breadcrumbs, google analytics, rich snippets, broken link checker, Schema.org
6
  Requires at least: 4.7+
7
- Tested up to: 5.7
8
  Requires PHP: 5.6
9
- Stable tag: 4.7.0
10
  License: GPLv2 or later
11
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -77,7 +77,7 @@ SEOPress is a powerful WordPress SEO plugin to optimize your SEO, boost your tra
77
  <ol>
78
  <li>article schema</li>
79
  <li>local business schema</li>
80
- <li>service schema</li>
81
  <li>how-to schema</li>
82
  <li>FAQ schema</li>
83
  <li>course schema</li>
@@ -325,7 +325,11 @@ You're theme is probably using a deprecated function to handle the title. <a hre
325
  9. Schemas metabox
326
 
327
  == Changelog ==
328
- = 4.7 (19/05/2021) - <a href="https://www.seopress.org/blog/seopress-4-7/">Read our blog post update</a> =
 
 
 
 
329
  * NEW Apply automatic schemas based on post ID
330
  * NEW Speakable schema (visible under Article manual or automatic schema)
331
  * NEW ReviewBody property for Review schema (manual and automatic)
4
  Donate link: https://www.seopress.org/
5
  Tags: SEO, XML sitemap, meta title, open graph, content analysis, knowledge graph, redirection, breadcrumbs, google analytics, rich snippets, broken link checker, Schema.org
6
  Requires at least: 4.7+
7
+ Tested up to: 5.8
8
  Requires PHP: 5.6
9
+ Stable tag: 4.7.0.2
10
  License: GPLv2 or later
11
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
 
77
  <ol>
78
  <li>article schema</li>
79
  <li>local business schema</li>
80
+ <li>service schema</li>
81
  <li>how-to schema</li>
82
  <li>FAQ schema</li>
83
  <li>course schema</li>
325
  9. Schemas metabox
326
 
327
  == Changelog ==
328
+ = 4.7.0.2 (5/07/2021) =
329
+ * FIX AIO SEO import tool
330
+ = 4.7.0.1 (21/05/2021) =
331
+ * FIX Remove old file generating a bug in schema rendering
332
+ = 4.7 (19/05/2021) - <a href="https://www.seopress.org/blog/seopress-4-7/">Read our blog post update</a> =
333
  * NEW Apply automatic schemas based on post ID
334
  * NEW Speakable schema (visible under Article manual or automatic schema)
335
  * NEW ReviewBody property for Review schema (manual and automatic)
seopress.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: SEOPress
4
  Plugin URI: https://www.seopress.org/
5
  Description: One of the best SEO plugins for WordPress.
6
  Author: SEOPress
7
- Version: 4.7.0
8
  Author URI: https://www.seopress.org/
9
  License: GPLv2
10
  Text Domain: wp-seopress
@@ -28,7 +28,7 @@ Domain Path: /languages
28
  */
29
 
30
  // To prevent calling the plugin directly
31
- if ( ! function_exists('add_action')) {
32
  echo 'Please don&rsquo;t call the plugin directly. Thanks :)';
33
  exit;
34
  }
@@ -36,14 +36,16 @@ if ( ! function_exists('add_action')) {
36
  ///////////////////////////////////////////////////////////////////////////////////////////////////
37
  //Hooks activation
38
  ///////////////////////////////////////////////////////////////////////////////////////////////////
39
- function seopress_activation() {
 
40
  add_option('seopress_activated', 'yes');
41
  flush_rewrite_rules(false);
42
  do_action('seopress_activation');
43
  }
44
  register_activation_hook(__FILE__, 'seopress_activation');
45
 
46
- function seopress_deactivation() {
 
47
  deactivate_plugins(['wp-seopress-pro/seopress-pro.php', 'wp-seopress-insights/seopress-insights.php']);
48
 
49
  delete_option('seopress_activated');
@@ -55,7 +57,7 @@ register_deactivation_hook(__FILE__, 'seopress_deactivation');
55
  ///////////////////////////////////////////////////////////////////////////////////////////////////
56
  //Define
57
  ///////////////////////////////////////////////////////////////////////////////////////////////////
58
- define('SEOPRESS_VERSION', '4.7.0');
59
  define('SEOPRESS_AUTHOR', 'Benjamin Denis');
60
  define('SEOPRESS_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
61
  define('SEOPRESS_TEMPLATE_DIR', SEOPRESS_PLUGIN_DIR_PATH . 'templates');
@@ -76,10 +78,11 @@ if (file_exists(__DIR__ . '/vendor/autoload.php')) {
76
  ]);
77
  }
78
 
79
- function seopress_titles_single_cpt_enable_option($cpt) {
 
80
  $current_cpt = null;
81
  $seopress_titles_single_enable_option = get_option('seopress_titles_option_name');
82
- if ( ! empty($seopress_titles_single_enable_option)) {
83
  foreach ($seopress_titles_single_enable_option as $key => $seopress_titles_single_enable_value) {
84
  $options[$key] = $seopress_titles_single_enable_value;
85
  if (isset($seopress_titles_single_enable_option['seopress_titles_single_titles'][$cpt]['enable'])) {
@@ -92,12 +95,13 @@ function seopress_titles_single_cpt_enable_option($cpt) {
92
  }
93
 
94
  //Archive CPT Titles
95
- function seopress_titles_archive_titles_option() {
 
96
  global $post;
97
  $seopress_get_current_cpt = get_post_type($post);
98
 
99
  $seopress_titles_archive_titles_option = get_option('seopress_titles_option_name');
100
- if ( ! empty($seopress_titles_archive_titles_option)) {
101
  foreach ($seopress_titles_archive_titles_option as $key => $seopress_titles_archive_titles_value) {
102
  $options[$key] = $seopress_titles_archive_titles_value;
103
  }
@@ -110,7 +114,8 @@ function seopress_titles_archive_titles_option() {
110
  ///////////////////////////////////////////////////////////////////////////////////////////////////
111
  //SEOPRESS INIT = Admin + Core + API + Translation
112
  ///////////////////////////////////////////////////////////////////////////////////////////////////
113
- function seopress_init($hook) {
 
114
  load_plugin_textdomain('wp-seopress', false, dirname(plugin_basename(__FILE__)) . '/languages/');
115
 
116
  global $pagenow;
@@ -144,7 +149,7 @@ function seopress_init($hook) {
144
  remove_action('wp_head', 'rel_canonical'); //remove default WordPress Canonical
145
 
146
  //Setup/welcome
147
- if ( ! empty($_GET['page'])) {
148
  switch ($_GET['page']) {
149
  case 'seopress-setup':
150
  include_once dirname(__FILE__) . '/inc/admin/admin-wizard.php';
@@ -172,8 +177,9 @@ add_action('plugins_loaded', 'seopress_init', 999);
172
  * @return string
173
  * @author Benjamin
174
  */
175
- if ( ! function_exists('array_key_first')) {
176
- function array_key_first(array $arr) {
 
177
  foreach ($arr as $key => $unused) {
178
  return $key;
179
  }
@@ -188,8 +194,9 @@ if ( ! function_exists('array_key_first')) {
188
  * @return string
189
  * @author Benjamin
190
  */
191
- if ( ! function_exists('array_key_last')) {
192
- function array_key_last(array $arr) {
 
193
  end($arr);
194
  $key = key($arr);
195
 
@@ -200,7 +207,8 @@ if ( ! function_exists('array_key_last')) {
200
  ///////////////////////////////////////////////////////////////////////////////////////////////////
201
  //Loads dynamic variables for titles, metas, schemas...
202
  ///////////////////////////////////////////////////////////////////////////////////////////////////
203
- function seopress_dyn_variables_init($variables) {
 
204
  $variables = include dirname(__FILE__) . '/inc/functions/variables/dynamic-variables.php';
205
 
206
  return $variables;
@@ -211,12 +219,13 @@ add_filter('seopress_dyn_variables_fn', 'seopress_dyn_variables_init');
211
  //Loads the JS/CSS in admin
212
  ///////////////////////////////////////////////////////////////////////////////////////////////////
213
  //SEOPRESS Options page
214
- function seopress_add_admin_options_scripts($hook) {
 
215
  $prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
216
  wp_register_style('seopress-admin', plugins_url('assets/css/seopress' . $prefix . '.css', __FILE__), [], SEOPRESS_VERSION);
217
  wp_enqueue_style('seopress-admin');
218
 
219
- if ( ! isset($_GET['page'])) {
220
  return;
221
  }
222
  if ('seopress-network-option' === $_GET['page']) {
@@ -388,7 +397,8 @@ function seopress_add_admin_options_scripts($hook) {
388
  add_action('admin_enqueue_scripts', 'seopress_add_admin_options_scripts', 10, 1);
389
 
390
  //SEOPRESS Admin bar
391
- function seopress_admin_bar_css() {
 
392
  $prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
393
  if (is_user_logged_in() && function_exists('seopress_advanced_appearance_adminbar_option') && '1' != seopress_advanced_appearance_adminbar_option()) {
394
  if (is_admin_bar_showing()) {
@@ -400,7 +410,8 @@ function seopress_admin_bar_css() {
400
  add_action('init', 'seopress_admin_bar_css', 12, 1);
401
 
402
  //Quick Edit
403
- function seopress_add_admin_options_scripts_quick_edit() {
 
404
  $prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
405
  wp_enqueue_script('seopress-quick-edit', plugins_url('assets/js/seopress-quick-edit' . $prefix . '.js', __FILE__), ['jquery', 'inline-edit-post'], SEOPRESS_VERSION, true);
406
  }
@@ -410,8 +421,9 @@ add_action('admin_print_scripts-edit.php', 'seopress_add_admin_options_scripts_q
410
  //Admin Body Class
411
  ///////////////////////////////////////////////////////////////////////////////////////////////////
412
  add_filter('admin_body_class', 'seopress_admin_body_class', 100);
413
- function seopress_admin_body_class($classes) {
414
- if ( ! isset($_GET['page'])) {
 
415
  return $classes;
416
  }
417
  $_pages = [
@@ -451,7 +463,8 @@ remove_filter('wp_robots', 'wp_robots_max_image_preview_large');
451
  * @since 4.6
452
  * @todo use wp_robots API
453
  */
454
- function seopress_robots_wc_pages($robots) {
 
455
  include_once ABSPATH . 'wp-admin/includes/plugin.php';
456
  if (is_plugin_active('woocommerce/woocommerce.php')) {
457
  if (function_exists('wc_get_page_id')) {
@@ -476,7 +489,8 @@ add_filter('wp_robots', 'seopress_robots_wc_pages', 20);
476
  //3rd plugins compatibility
477
  ///////////////////////////////////////////////////////////////////////////////////////////////////
478
  //Jetpack
479
- function seopress_compatibility_jetpack() {
 
480
  if (function_exists('is_plugin_active')) {
481
  if (is_plugin_active('jetpack/jetpack.php') && ! is_admin()) {
482
  add_filter('jetpack_enable_open_graph', '__return_false');
@@ -491,7 +505,8 @@ add_action('wp_head', 'seopress_compatibility_jetpack', 0);
491
  *
492
  * @since 3.8.1
493
  */
494
- function seopress_compatibility_woocommerce() {
 
495
  if (function_exists('is_plugin_active')) {
496
  if (is_plugin_active('woocommerce/woocommerce.php') && ! is_admin()) {
497
  remove_action('wp_head', 'wc_page_noindex');
@@ -511,7 +526,8 @@ add_action('wp_head', 'seopress_compatibility_woocommerce', 0);
511
  * @param mixed $orig_scheme
512
  * @param mixed $blog_id
513
  */
514
- function seopress_remove_wpml_home_url_filter($home_url, $url, $path, $orig_scheme, $blog_id) {
 
515
  return $url;
516
  }
517
 
@@ -521,7 +537,8 @@ function seopress_remove_wpml_home_url_filter($home_url, $url, $path, $orig_sche
521
  * @since 4.2
522
  */
523
  add_action('do_meta_boxes', 'seopress_remove_metaboxes', 10);
524
- function seopress_remove_metaboxes() {
 
525
  //Oxygen Builder
526
  remove_meta_box('ct_views_cpt', 'seopress_404', 'normal');
527
  remove_meta_box('ct_views_cpt', 'seopress_schemas', 'normal');
@@ -531,7 +548,8 @@ function seopress_remove_metaboxes() {
531
  ///////////////////////////////////////////////////////////////////////////////////////////////////
532
  //Credits footer
533
  ///////////////////////////////////////////////////////////////////////////////////////////////////
534
- function seopress_custom_credits_footer() {
 
535
  $html = '<span id="seopress-footer-credits">
536
  <span class="dashicons dashicons-wordpress"></span>
537
  ' . __("You like SEOPress? Don't forget to rate it 5 stars!", 'wp-seopress') . '<span class="wporg-ratings rating-stars">';
@@ -573,12 +591,14 @@ if ((isset($_GET['page']) && (
573
  || 'seopress-import-export' == $_GET['page']
574
  || 'seopress-bot-batch' == $_GET['page']
575
  || 'seopress-insights' == $_GET['page']
576
- || 'seopress-license' == $_GET['page']))
 
577
  || (isset($_GET['post_type']) && (
578
- 'seopress_404' == $_GET['post_type']
579
  || 'seopress_schemas' == $_GET['post_type']
580
  || 'seopress_bot' == $_GET['post_type']
581
- || 'seopress_backlinks' == $_GET['post_type']))) {
 
582
  add_filter('admin_footer_text', 'seopress_custom_credits_footer');
583
  }
584
 
@@ -587,10 +607,11 @@ if ((isset($_GET['page']) && (
587
  ///////////////////////////////////////////////////////////////////////////////////////////////////
588
  add_filter('plugin_action_links', 'seopress_plugin_action_links', 10, 2);
589
 
590
- function seopress_plugin_action_links($links, $file) {
 
591
  static $this_plugin;
592
 
593
- if ( ! $this_plugin) {
594
  $this_plugin = plugin_basename(__FILE__);
595
  }
596
 
@@ -598,7 +619,7 @@ function seopress_plugin_action_links($links, $file) {
598
  $settings_link = '<a href="' . admin_url('admin.php?page=seopress-option') . '">' . __('Settings', 'wp-seopress') . '</a>';
599
  $website_link = '<a href="https://www.seopress.org/support/" target="_blank">' . __('Docs', 'wp-seopress') . '</a>';
600
  $wizard_link = '<a href="' . admin_url('admin.php?page=seopress-setup') . '">' . __('Configuration Wizard', 'wp-seopress') . '</a>';
601
- if ( ! is_plugin_active('wp-seopress-pro/seopress-pro.php')) {
602
  $pro_link = '<a href="https://www.seopress.org/seopress-pro/" style="color:red;font-weight:bold" target="_blank">' . __('GO PRO!', 'wp-seopress') . '</a>';
603
  array_unshift($links, $pro_link);
604
  }
@@ -628,8 +649,9 @@ function seopress_plugin_action_links($links, $file) {
628
  *
629
  * @return (array) $wp_post_types
630
  **/
631
- function seopress_get_post_types() {
632
- if ( ! function_exists('seopress_get_service')) {
 
633
  global $wp_post_types;
634
 
635
  $args = [
@@ -669,7 +691,8 @@ function seopress_get_post_types() {
669
  *
670
  * @return (array) $taxonomies
671
  **/
672
- function seopress_get_taxonomies($with_terms = false) {
 
673
  $args = [
674
  'show_ui' => true,
675
  'public' => true,
@@ -686,7 +709,7 @@ function seopress_get_taxonomies($with_terms = false) {
686
 
687
  $taxonomies = apply_filters('seopress_get_taxonomies_list', $taxonomies);
688
 
689
- if ( ! $with_terms) {
690
  return $taxonomies;
691
  }
692
 
@@ -700,7 +723,8 @@ function seopress_get_taxonomies($with_terms = false) {
700
  ///////////////////////////////////////////////////////////////////////////////////////////////////
701
  //Get all custom fields (limit: 250)
702
  ///////////////////////////////////////////////////////////////////////////////////////////////////
703
- function seopress_get_custom_fields() {
 
704
  $cf_keys = wp_cache_get('seopress_get_custom_fields');
705
 
706
  if (false === $cf_keys) {
@@ -718,7 +742,7 @@ function seopress_get_custom_fields() {
718
  if (is_plugin_active('types/wpcf.php')) {
719
  $wpcf_fields = get_option('wpcf-fields');
720
 
721
- if ( ! empty($wpcf_fields)) {
722
  foreach ($wpcf_fields as $key => $value) {
723
  $cf_keys[] = $value['meta_key'];
724
  }
@@ -739,7 +763,8 @@ function seopress_get_custom_fields() {
739
  ///////////////////////////////////////////////////////////////////////////////////////////////////
740
  //Check SSL for schema.org
741
  ///////////////////////////////////////////////////////////////////////////////////////////////////
742
- function seopress_check_ssl() {
 
743
  if (is_ssl()) {
744
  return 'https://';
745
  } else {
@@ -754,7 +779,8 @@ function seopress_check_ssl() {
754
  *
755
  * @return (string) $ip
756
  **/
757
- function seopress_get_ip_address() {
 
758
  foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'] as $key) {
759
  if (true === array_key_exists($key, $_SERVER)) {
760
  foreach (explode(',', $_SERVER[$key]) as $ip) {
@@ -782,9 +808,10 @@ function seopress_get_ip_address() {
782
  *
783
  * @author Benjamin
784
  */
785
- function seopress_get_toggle_option($feature) {
 
786
  $seopress_get_toggle_option = get_option('seopress_toggle');
787
- if ( ! empty($seopress_get_toggle_option)) {
788
  foreach ($seopress_get_toggle_option as $key => $seopress_get_toggle_value) {
789
  $options[$key] = $seopress_get_toggle_value;
790
  if (isset($seopress_get_toggle_option['toggle-' . $feature])) {
@@ -798,9 +825,10 @@ function seopress_get_toggle_option($feature) {
798
  /**
799
  * @since 3.8
800
  */
801
- function seopress_get_toggle_titles_option() {
 
802
  $seopress_get_toggle_titles_option = get_option('seopress_toggle');
803
- if ( ! empty($seopress_get_toggle_titles_option)) {
804
  foreach ($seopress_get_toggle_titles_option as $key => $seopress_get_toggle_titles_value) {
805
  $options[$key] = $seopress_get_toggle_titles_value;
806
  }
@@ -813,9 +841,10 @@ function seopress_get_toggle_titles_option() {
813
  /**
814
  * @since 3.8
815
  */
816
- function seopress_get_toggle_social_option() {
 
817
  $seopress_get_toggle_social_option = get_option('seopress_toggle');
818
- if ( ! empty($seopress_get_toggle_social_option)) {
819
  foreach ($seopress_get_toggle_social_option as $key => $seopress_get_toggle_social_value) {
820
  $options[$key] = $seopress_get_toggle_social_value;
821
  }
@@ -828,9 +857,10 @@ function seopress_get_toggle_social_option() {
828
  /**
829
  * @since 3.8
830
  */
831
- function seopress_get_toggle_xml_sitemap_option() {
 
832
  $seopress_get_toggle_xml_sitemap_option = get_option('seopress_toggle');
833
- if ( ! empty($seopress_get_toggle_xml_sitemap_option)) {
834
  foreach ($seopress_get_toggle_xml_sitemap_option as $key => $seopress_get_toggle_xml_sitemap_value) {
835
  $options[$key] = $seopress_get_toggle_xml_sitemap_value;
836
  }
@@ -843,9 +873,10 @@ function seopress_get_toggle_xml_sitemap_option() {
843
  /**
844
  * @since 3.8
845
  */
846
- function seopress_get_toggle_google_analytics_option() {
 
847
  $seopress_get_toggle_google_analytics_option = get_option('seopress_toggle');
848
- if ( ! empty($seopress_get_toggle_google_analytics_option)) {
849
  foreach ($seopress_get_toggle_google_analytics_option as $key => $seopress_get_toggle_google_analytics_value) {
850
  $options[$key] = $seopress_get_toggle_google_analytics_value;
851
  }
@@ -858,9 +889,10 @@ function seopress_get_toggle_google_analytics_option() {
858
  /**
859
  * @since 3.8
860
  */
861
- function seopress_get_toggle_advanced_option() {
 
862
  $seopress_get_toggle_advanced_option = get_option('seopress_toggle');
863
- if ( ! empty($seopress_get_toggle_advanced_option)) {
864
  foreach ($seopress_get_toggle_advanced_option as $key => $seopress_get_toggle_advanced_value) {
865
  $options[$key] = $seopress_get_toggle_advanced_value;
866
  }
@@ -877,8 +909,9 @@ function seopress_get_toggle_advanced_option() {
877
  /**
878
  * @deprecated 4.3.0
879
  */
880
- function seopress_xml_sitemap_general_enable_option() {
881
- if ( ! function_exists('seopress_get_service')) {
 
882
  return '1';
883
  }
884
 
@@ -888,8 +921,9 @@ function seopress_xml_sitemap_general_enable_option() {
888
  /**
889
  * @deprecated 4.3.0
890
  */
891
- function seopress_xml_sitemap_post_types_list_option() {
892
- if ( ! function_exists('seopress_get_service')) {
 
893
  return '';
894
  }
895
 
@@ -899,8 +933,9 @@ function seopress_xml_sitemap_post_types_list_option() {
899
  /**
900
  * @deprecated 4.3.0
901
  */
902
- function seopress_xml_sitemap_taxonomies_list_option() {
903
- if ( ! function_exists('seopress_get_service')) {
 
904
  return '';
905
  }
906
 
@@ -910,8 +945,9 @@ function seopress_xml_sitemap_taxonomies_list_option() {
910
  /**
911
  * @deprecated 4.3.0
912
  */
913
- function seopress_xml_sitemap_author_enable_option() {
914
- if ( ! function_exists('seopress_get_service')) {
 
915
  return '';
916
  }
917
 
@@ -921,8 +957,9 @@ function seopress_xml_sitemap_author_enable_option() {
921
  /**
922
  * @deprecated 4.3.0
923
  */
924
- function seopress_xml_sitemap_img_enable_option() {
925
- if ( ! function_exists('seopress_get_service')) {
 
926
  return '';
927
  }
928
 
@@ -931,8 +968,9 @@ function seopress_xml_sitemap_img_enable_option() {
931
 
932
  //Rewrite Rules for XML Sitemap
933
  if ('1' == seopress_xml_sitemap_general_enable_option() && '1' == seopress_get_toggle_option('xml-sitemap')) {
934
- function seopress_sitemaps_headers() {
935
- if ( ! function_exists('seopress_get_service')) {
 
936
  return;
937
  }
938
 
@@ -944,7 +982,8 @@ if ('1' == seopress_xml_sitemap_general_enable_option() && '1' == seopress_get_t
944
  add_filter('request', 'seopress_wpml_block_secondary_languages');
945
  }
946
 
947
- function seopress_wpml_block_secondary_languages($q) {
 
948
  $current_language = apply_filters('wpml_current_language', false);
949
  $default_language = apply_filters('wpml_default_language', false);
950
  if ($current_language !== $default_language) {
@@ -959,7 +998,8 @@ if ('1' == seopress_xml_sitemap_general_enable_option() && '1' == seopress_get_t
959
  }
960
  }
961
 
962
- function seopress_disable_qm($allcaps, $caps, $args) {
 
963
  $allcaps['view_query_monitor'] = false;
964
 
965
  return $allcaps;
@@ -967,7 +1007,8 @@ function seopress_disable_qm($allcaps, $caps, $args) {
967
  ///////////////////////////////////////////////////////////////////////////////////////////////////
968
  // Remove Admin Bar with Content Analysis
969
  ///////////////////////////////////////////////////////////////////////////////////////////////////
970
- function seopress_clean_content_analysis() {
 
971
  if (current_user_can('edit_posts')) {
972
  if (isset($_GET['no_admin_bar']) && '1' === $_GET['no_admin_bar']) {
973
  //Remove admin bar
@@ -991,7 +1032,8 @@ add_action('plugins_loaded', 'seopress_clean_content_analysis');
991
  ///////////////////////////////////////////////////////////////////////////////////////////////////
992
  // Test abolute URLs (return true if absolute)
993
  ///////////////////////////////////////////////////////////////////////////////////////////////////
994
- function seopress_is_absolute($url) {
 
995
  $pattern = "%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu";
996
 
997
  return (bool) preg_match($pattern, $url);
@@ -1000,7 +1042,8 @@ function seopress_is_absolute($url) {
1000
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1001
  // Manage localized links
1002
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1003
- function seopress_get_locale() {
 
1004
  switch (get_user_locale(get_current_user_id())) {
1005
  case 'fr_FR':
1006
  case 'fr_BE':
@@ -1031,7 +1074,8 @@ function seopress_get_locale() {
1031
  *
1032
  * @author Benjamin
1033
  */
1034
- function seopress_tooltip($tooltip_title, $tooltip_desc, $tooltip_code) {
 
1035
  $html =
1036
  '<button type="button" class="sp-tooltip"><span class="dashicons dashicons-editor-help"></span>
1037
  <span class="sp-tooltiptext" role="tooltip" tabindex="0">
@@ -1056,7 +1100,8 @@ function seopress_tooltip($tooltip_title, $tooltip_desc, $tooltip_code) {
1056
  *
1057
  * @author Benjamin
1058
  */
1059
- function seopress_tooltip_alt($tooltip_anchor, $tooltip_desc) {
 
1060
  $html =
1061
  '<button type="button" class="sp-tooltip alt">' . $tooltip_anchor . '
1062
  <span class="sp-tooltiptext" role="tooltip" tabindex="0">
@@ -1078,7 +1123,8 @@ function seopress_tooltip_alt($tooltip_anchor, $tooltip_desc) {
1078
  *
1079
  * @author Benjamin
1080
  */
1081
- function seopress_remove_utf8_bom($text) {
 
1082
  $bom = pack('H*', 'EFBBBF');
1083
  $text = preg_replace("/^$bom/", '', $text);
1084
 
@@ -1096,8 +1142,9 @@ function seopress_remove_utf8_bom($text) {
1096
  *
1097
  * @author Benjamin
1098
  */
1099
- function seopress_notification($args) {
1100
- if ( ! empty($args)) {
 
1101
  $id = isset($args['id']) ? $args['id'] : null;
1102
  $title = isset($args['title']) ? $args['title'] : null;
1103
  $desc = isset($args['desc']) ? $args['desc'] : null;
@@ -1107,7 +1154,7 @@ function seopress_notification($args) {
1107
  $icon = isset($args['icon']) ? $args['icon'] : null;
1108
 
1109
  $class = '';
1110
- if ( ! empty($impact)) {
1111
  $class .= ' impact';
1112
  $class .= ' ' . key($impact);
1113
  }
@@ -1118,11 +1165,11 @@ function seopress_notification($args) {
1118
 
1119
  $html = '<div id="' . $id . '-alert" class="seopress-alert">';
1120
 
1121
- if ( ! empty($impact)) {
1122
  $html .= '<span class="screen-reader-text">' . reset($impact) . '</span>';
1123
  }
1124
 
1125
- if ( ! empty($icon)) {
1126
  $html .= '<span class="dashicons ' . $icon . '"></span>';
1127
  } else {
1128
  $html .= '<span class="dashicons dashicons-info"></span>';
@@ -1145,10 +1192,10 @@ function seopress_notification($args) {
1145
  $target = ' target="_blank"';
1146
  }
1147
 
1148
- if ( ! empty($link) || true === $deleteable) {
1149
  $html .= '<div class="notice-right">';
1150
 
1151
- if ( ! empty($link)) {
1152
  $html .= '<a class="button-primary"' . $href . $target . '>' . $link['title'] . '</a>';
1153
  }
1154
  if (true === $deleteable) {
@@ -1173,9 +1220,10 @@ function seopress_notification($args) {
1173
  *
1174
  * @return (string)
1175
  **/
1176
- function seopress_capability($cap, $context = '') {
 
1177
  $newcap = apply_filters('seopress_capability', $cap, $context);
1178
- if ( ! current_user_can($newcap)) {
1179
  return $cap;
1180
  }
1181
 
@@ -1191,8 +1239,9 @@ function seopress_capability($cap, $context = '') {
1191
  *
1192
  * @return (bool)
1193
  **/
1194
- function is_seopress_page() {
1195
- if ( ! is_admin() && ( ! isset($_REQUEST['page']) || ! isset($_REQUEST['post_type']))) {
 
1196
  return false;
1197
  }
1198
 
@@ -1211,7 +1260,8 @@ function is_seopress_page() {
1211
  * @return (bool)
1212
  **/
1213
  add_action('in_admin_header', 'seopress_remove_other_notices');
1214
- function seopress_remove_other_notices() {
 
1215
  if (is_seopress_page()) {
1216
  remove_all_actions('network_admin_notices');
1217
  remove_all_actions('admin_notices');
@@ -1233,7 +1283,8 @@ function seopress_remove_other_notices() {
1233
  *
1234
  * @return (bool)
1235
  **/
1236
- function seopress_admin_notices() {
 
1237
  do_action('seopress_admin_notices');
1238
  }
1239
 
@@ -1246,7 +1297,8 @@ function seopress_admin_notices() {
1246
  *
1247
  * @return (bool)
1248
  **/
1249
- function seopress_get_days() {
 
1250
  $start_of_week = (int) get_option('start_of_week');
1251
 
1252
  return array_map(
@@ -1276,7 +1328,8 @@ function seopress_get_days() {
1276
  *
1277
  * @param mixed $key
1278
  **/
1279
- function seopress_if_key_exists(array $arr, $key) {
 
1280
  // is in base array?
1281
  if (array_key_exists($key, $arr)) {
1282
  return true;
@@ -1303,11 +1356,12 @@ function seopress_if_key_exists(array $arr, $key) {
1303
  *
1304
  * @return null
1305
  **/
1306
- function seopress_get_oxygen_content() {
 
1307
  if (is_plugin_active('oxygen/functions.php') && function_exists('ct_template_output')) {
1308
  $seopress_get_the_content = ct_template_output();
1309
 
1310
- if ( ! $seopress_get_the_content) {
1311
  //Get post content
1312
  $seopress_get_the_content = apply_filters('the_content', get_post_field('post_content', get_the_ID()));
1313
  }
@@ -1330,7 +1384,7 @@ function seopress_get_oxygen_content() {
1330
  //Words Counter
1331
  $data['words_counter'] = preg_match_all("/\p{L}[\p{L}\p{Mn}\p{Pd}'\x{2019}]*/u", $seopress_get_the_content, $matches);
1332
 
1333
- if ( ! empty($matches[0])) {
1334
  $words_counter_unique = count(array_unique($matches[0]));
1335
  } else {
1336
  $words_counter_unique = '0';
@@ -1351,58 +1405,60 @@ function seopress_get_oxygen_content() {
1351
  * @author Benjamin Denis
1352
  *
1353
  **/
1354
- function seopress_wizard_follow_us() {
 
1355
  ?>
1356
- <li class="seopress-wizard-additional-steps">
1357
- <div class="seopress-wizard-next-step-description">
1358
- <p class="next-step-heading"><?php esc_html_e('Follow us:', 'wp-seopress'); ?></p>
1359
- </div>
1360
- <div class="seopress-wizard-next-step-action step">
1361
- <ul class="recommended-step">
1362
- <li class="recommended-item">
1363
- <a href="https://www.facebook.com/seopresspro/" target="_blank">
1364
- <span class="dashicons dashicons-facebook"></span>
1365
- <?php _e('Like our Facebook page', 'wp-seopress'); ?>
1366
- </a>
1367
- </li>
1368
- <li class="recommended-item">
1369
- <a href="https://www.facebook.com/groups/seopress/" target="_blank">
1370
- <span class="dashicons dashicons-facebook"></span>
1371
- <?php _e('Join our Facebook Community group', 'wp-seopress'); ?>
1372
- </a>
1373
- </li>
1374
- <li class="recommended-item">
1375
- <a href="https://www.youtube.com/seopress" target="_blank">
1376
- <span class="dashicons dashicons-video-alt3"></span>
1377
- <?php _e('Watch our guided tour videos to learn more about SEOPress', 'wp-seopress'); ?>
1378
- </a>
1379
- </li>
1380
- <li class="recommended-item">
1381
- <?php
 
1382
  if (function_exists('seopress_get_locale') && 'fr' == seopress_get_locale()) {
1383
  $link = 'https://www.seopress.org/fr/blog/category/tutoriels/?utm_source=plugin&utm_medium=wizard&utm_campaign=seopress';
1384
  } else {
1385
  $link = 'https://www.seopress.org/blog/how-to/?utm_source=plugin&utm_medium=wizard&utm_campaign=seopress';
1386
  } ?>
1387
- <a href="<?php echo $link; ?>" target="_blank">
1388
- <span class="dashicons dashicons-format-aside"></span>
1389
- <?php _e('Read our blog posts about SEO concepts, tutorials and more', 'wp-seopress'); ?>
1390
- </a>
1391
- </li>
1392
- <li class="recommended-item">
1393
- <a href="https://twitter.com/wp_seopress" target="_blank">
1394
- <span class="dashicons dashicons-twitter"></span>
1395
- <?php _e('Follow us on Twitter', 'wp-seopress'); ?>
1396
- </a>
1397
- </li>
1398
- <li class="recommended-item">
1399
- <a href="https://www.instagram.com/wp_seopress/" target="_blank">
1400
- <span class="dashicons dashicons-instagram"></span>
1401
- <?php _e('The off side of SEOPress', 'wp-seopress'); ?>
1402
- </a>
1403
- </li>
1404
- </ul>
1405
- </div>
1406
- </li>
1407
- <?php
1408
  }
4
  Plugin URI: https://www.seopress.org/
5
  Description: One of the best SEO plugins for WordPress.
6
  Author: SEOPress
7
+ Version: 4.7.0.2
8
  Author URI: https://www.seopress.org/
9
  License: GPLv2
10
  Text Domain: wp-seopress
28
  */
29
 
30
  // To prevent calling the plugin directly
31
+ if (! function_exists('add_action')) {
32
  echo 'Please don&rsquo;t call the plugin directly. Thanks :)';
33
  exit;
34
  }
36
  ///////////////////////////////////////////////////////////////////////////////////////////////////
37
  //Hooks activation
38
  ///////////////////////////////////////////////////////////////////////////////////////////////////
39
+ function seopress_activation()
40
+ {
41
  add_option('seopress_activated', 'yes');
42
  flush_rewrite_rules(false);
43
  do_action('seopress_activation');
44
  }
45
  register_activation_hook(__FILE__, 'seopress_activation');
46
 
47
+ function seopress_deactivation()
48
+ {
49
  deactivate_plugins(['wp-seopress-pro/seopress-pro.php', 'wp-seopress-insights/seopress-insights.php']);
50
 
51
  delete_option('seopress_activated');
57
  ///////////////////////////////////////////////////////////////////////////////////////////////////
58
  //Define
59
  ///////////////////////////////////////////////////////////////////////////////////////////////////
60
+ define('SEOPRESS_VERSION', '4.7.0.2');
61
  define('SEOPRESS_AUTHOR', 'Benjamin Denis');
62
  define('SEOPRESS_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
63
  define('SEOPRESS_TEMPLATE_DIR', SEOPRESS_PLUGIN_DIR_PATH . 'templates');
78
  ]);
79
  }
80
 
81
+ function seopress_titles_single_cpt_enable_option($cpt)
82
+ {
83
  $current_cpt = null;
84
  $seopress_titles_single_enable_option = get_option('seopress_titles_option_name');
85
+ if (! empty($seopress_titles_single_enable_option)) {
86
  foreach ($seopress_titles_single_enable_option as $key => $seopress_titles_single_enable_value) {
87
  $options[$key] = $seopress_titles_single_enable_value;
88
  if (isset($seopress_titles_single_enable_option['seopress_titles_single_titles'][$cpt]['enable'])) {
95
  }
96
 
97
  //Archive CPT Titles
98
+ function seopress_titles_archive_titles_option()
99
+ {
100
  global $post;
101
  $seopress_get_current_cpt = get_post_type($post);
102
 
103
  $seopress_titles_archive_titles_option = get_option('seopress_titles_option_name');
104
+ if (! empty($seopress_titles_archive_titles_option)) {
105
  foreach ($seopress_titles_archive_titles_option as $key => $seopress_titles_archive_titles_value) {
106
  $options[$key] = $seopress_titles_archive_titles_value;
107
  }
114
  ///////////////////////////////////////////////////////////////////////////////////////////////////
115
  //SEOPRESS INIT = Admin + Core + API + Translation
116
  ///////////////////////////////////////////////////////////////////////////////////////////////////
117
+ function seopress_init($hook)
118
+ {
119
  load_plugin_textdomain('wp-seopress', false, dirname(plugin_basename(__FILE__)) . '/languages/');
120
 
121
  global $pagenow;
149
  remove_action('wp_head', 'rel_canonical'); //remove default WordPress Canonical
150
 
151
  //Setup/welcome
152
+ if (! empty($_GET['page'])) {
153
  switch ($_GET['page']) {
154
  case 'seopress-setup':
155
  include_once dirname(__FILE__) . '/inc/admin/admin-wizard.php';
177
  * @return string
178
  * @author Benjamin
179
  */
180
+ if (! function_exists('array_key_first')) {
181
+ function array_key_first(array $arr)
182
+ {
183
  foreach ($arr as $key => $unused) {
184
  return $key;
185
  }
194
  * @return string
195
  * @author Benjamin
196
  */
197
+ if (! function_exists('array_key_last')) {
198
+ function array_key_last(array $arr)
199
+ {
200
  end($arr);
201
  $key = key($arr);
202
 
207
  ///////////////////////////////////////////////////////////////////////////////////////////////////
208
  //Loads dynamic variables for titles, metas, schemas...
209
  ///////////////////////////////////////////////////////////////////////////////////////////////////
210
+ function seopress_dyn_variables_init($variables)
211
+ {
212
  $variables = include dirname(__FILE__) . '/inc/functions/variables/dynamic-variables.php';
213
 
214
  return $variables;
219
  //Loads the JS/CSS in admin
220
  ///////////////////////////////////////////////////////////////////////////////////////////////////
221
  //SEOPRESS Options page
222
+ function seopress_add_admin_options_scripts($hook)
223
+ {
224
  $prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
225
  wp_register_style('seopress-admin', plugins_url('assets/css/seopress' . $prefix . '.css', __FILE__), [], SEOPRESS_VERSION);
226
  wp_enqueue_style('seopress-admin');
227
 
228
+ if (! isset($_GET['page'])) {
229
  return;
230
  }
231
  if ('seopress-network-option' === $_GET['page']) {
397
  add_action('admin_enqueue_scripts', 'seopress_add_admin_options_scripts', 10, 1);
398
 
399
  //SEOPRESS Admin bar
400
+ function seopress_admin_bar_css()
401
+ {
402
  $prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
403
  if (is_user_logged_in() && function_exists('seopress_advanced_appearance_adminbar_option') && '1' != seopress_advanced_appearance_adminbar_option()) {
404
  if (is_admin_bar_showing()) {
410
  add_action('init', 'seopress_admin_bar_css', 12, 1);
411
 
412
  //Quick Edit
413
+ function seopress_add_admin_options_scripts_quick_edit()
414
+ {
415
  $prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
416
  wp_enqueue_script('seopress-quick-edit', plugins_url('assets/js/seopress-quick-edit' . $prefix . '.js', __FILE__), ['jquery', 'inline-edit-post'], SEOPRESS_VERSION, true);
417
  }
421
  //Admin Body Class
422
  ///////////////////////////////////////////////////////////////////////////////////////////////////
423
  add_filter('admin_body_class', 'seopress_admin_body_class', 100);
424
+ function seopress_admin_body_class($classes)
425
+ {
426
+ if (! isset($_GET['page'])) {
427
  return $classes;
428
  }
429
  $_pages = [
463
  * @since 4.6
464
  * @todo use wp_robots API
465
  */
466
+ function seopress_robots_wc_pages($robots)
467
+ {
468
  include_once ABSPATH . 'wp-admin/includes/plugin.php';
469
  if (is_plugin_active('woocommerce/woocommerce.php')) {
470
  if (function_exists('wc_get_page_id')) {
489
  //3rd plugins compatibility
490
  ///////////////////////////////////////////////////////////////////////////////////////////////////
491
  //Jetpack
492
+ function seopress_compatibility_jetpack()
493
+ {
494
  if (function_exists('is_plugin_active')) {
495
  if (is_plugin_active('jetpack/jetpack.php') && ! is_admin()) {
496
  add_filter('jetpack_enable_open_graph', '__return_false');
505
  *
506
  * @since 3.8.1
507
  */
508
+ function seopress_compatibility_woocommerce()
509
+ {
510
  if (function_exists('is_plugin_active')) {
511
  if (is_plugin_active('woocommerce/woocommerce.php') && ! is_admin()) {
512
  remove_action('wp_head', 'wc_page_noindex');
526
  * @param mixed $orig_scheme
527
  * @param mixed $blog_id
528
  */
529
+ function seopress_remove_wpml_home_url_filter($home_url, $url, $path, $orig_scheme, $blog_id)
530
+ {
531
  return $url;
532
  }
533
 
537
  * @since 4.2
538
  */
539
  add_action('do_meta_boxes', 'seopress_remove_metaboxes', 10);
540
+ function seopress_remove_metaboxes()
541
+ {
542
  //Oxygen Builder
543
  remove_meta_box('ct_views_cpt', 'seopress_404', 'normal');
544
  remove_meta_box('ct_views_cpt', 'seopress_schemas', 'normal');
548
  ///////////////////////////////////////////////////////////////////////////////////////////////////
549
  //Credits footer
550
  ///////////////////////////////////////////////////////////////////////////////////////////////////
551
+ function seopress_custom_credits_footer()
552
+ {
553
  $html = '<span id="seopress-footer-credits">
554
  <span class="dashicons dashicons-wordpress"></span>
555
  ' . __("You like SEOPress? Don't forget to rate it 5 stars!", 'wp-seopress') . '<span class="wporg-ratings rating-stars">';
591
  || 'seopress-import-export' == $_GET['page']
592
  || 'seopress-bot-batch' == $_GET['page']
593
  || 'seopress-insights' == $_GET['page']
594
+ || 'seopress-license' == $_GET['page']
595
+ ))
596
  || (isset($_GET['post_type']) && (
597
+ 'seopress_404' == $_GET['post_type']
598
  || 'seopress_schemas' == $_GET['post_type']
599
  || 'seopress_bot' == $_GET['post_type']
600
+ || 'seopress_backlinks' == $_GET['post_type']
601
+ ))) {
602
  add_filter('admin_footer_text', 'seopress_custom_credits_footer');
603
  }
604
 
607
  ///////////////////////////////////////////////////////////////////////////////////////////////////
608
  add_filter('plugin_action_links', 'seopress_plugin_action_links', 10, 2);
609
 
610
+ function seopress_plugin_action_links($links, $file)
611
+ {
612
  static $this_plugin;
613
 
614
+ if (! $this_plugin) {
615
  $this_plugin = plugin_basename(__FILE__);
616
  }
617
 
619
  $settings_link = '<a href="' . admin_url('admin.php?page=seopress-option') . '">' . __('Settings', 'wp-seopress') . '</a>';
620
  $website_link = '<a href="https://www.seopress.org/support/" target="_blank">' . __('Docs', 'wp-seopress') . '</a>';
621
  $wizard_link = '<a href="' . admin_url('admin.php?page=seopress-setup') . '">' . __('Configuration Wizard', 'wp-seopress') . '</a>';
622
+ if (! is_plugin_active('wp-seopress-pro/seopress-pro.php')) {
623
  $pro_link = '<a href="https://www.seopress.org/seopress-pro/" style="color:red;font-weight:bold" target="_blank">' . __('GO PRO!', 'wp-seopress') . '</a>';
624
  array_unshift($links, $pro_link);
625
  }
649
  *
650
  * @return (array) $wp_post_types
651
  **/
652
+ function seopress_get_post_types()
653
+ {
654
+ if (! function_exists('seopress_get_service')) {
655
  global $wp_post_types;
656
 
657
  $args = [
691
  *
692
  * @return (array) $taxonomies
693
  **/
694
+ function seopress_get_taxonomies($with_terms = false)
695
+ {
696
  $args = [
697
  'show_ui' => true,
698
  'public' => true,
709
 
710
  $taxonomies = apply_filters('seopress_get_taxonomies_list', $taxonomies);
711
 
712
+ if (! $with_terms) {
713
  return $taxonomies;
714
  }
715
 
723
  ///////////////////////////////////////////////////////////////////////////////////////////////////
724
  //Get all custom fields (limit: 250)
725
  ///////////////////////////////////////////////////////////////////////////////////////////////////
726
+ function seopress_get_custom_fields()
727
+ {
728
  $cf_keys = wp_cache_get('seopress_get_custom_fields');
729
 
730
  if (false === $cf_keys) {
742
  if (is_plugin_active('types/wpcf.php')) {
743
  $wpcf_fields = get_option('wpcf-fields');
744
 
745
+ if (! empty($wpcf_fields)) {
746
  foreach ($wpcf_fields as $key => $value) {
747
  $cf_keys[] = $value['meta_key'];
748
  }
763
  ///////////////////////////////////////////////////////////////////////////////////////////////////
764
  //Check SSL for schema.org
765
  ///////////////////////////////////////////////////////////////////////////////////////////////////
766
+ function seopress_check_ssl()
767
+ {
768
  if (is_ssl()) {
769
  return 'https://';
770
  } else {
779
  *
780
  * @return (string) $ip
781
  **/
782
+ function seopress_get_ip_address()
783
+ {
784
  foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'] as $key) {
785
  if (true === array_key_exists($key, $_SERVER)) {
786
  foreach (explode(',', $_SERVER[$key]) as $ip) {
808
  *
809
  * @author Benjamin
810
  */
811
+ function seopress_get_toggle_option($feature)
812
+ {
813
  $seopress_get_toggle_option = get_option('seopress_toggle');
814
+ if (! empty($seopress_get_toggle_option)) {
815
  foreach ($seopress_get_toggle_option as $key => $seopress_get_toggle_value) {
816
  $options[$key] = $seopress_get_toggle_value;
817
  if (isset($seopress_get_toggle_option['toggle-' . $feature])) {
825
  /**
826
  * @since 3.8
827
  */
828
+ function seopress_get_toggle_titles_option()
829
+ {
830
  $seopress_get_toggle_titles_option = get_option('seopress_toggle');
831
+ if (! empty($seopress_get_toggle_titles_option)) {
832
  foreach ($seopress_get_toggle_titles_option as $key => $seopress_get_toggle_titles_value) {
833
  $options[$key] = $seopress_get_toggle_titles_value;
834
  }
841
  /**
842
  * @since 3.8
843
  */
844
+ function seopress_get_toggle_social_option()
845
+ {
846
  $seopress_get_toggle_social_option = get_option('seopress_toggle');
847
+ if (! empty($seopress_get_toggle_social_option)) {
848
  foreach ($seopress_get_toggle_social_option as $key => $seopress_get_toggle_social_value) {
849
  $options[$key] = $seopress_get_toggle_social_value;
850
  }
857
  /**
858
  * @since 3.8
859
  */
860
+ function seopress_get_toggle_xml_sitemap_option()
861
+ {
862
  $seopress_get_toggle_xml_sitemap_option = get_option('seopress_toggle');
863
+ if (! empty($seopress_get_toggle_xml_sitemap_option)) {
864
  foreach ($seopress_get_toggle_xml_sitemap_option as $key => $seopress_get_toggle_xml_sitemap_value) {
865
  $options[$key] = $seopress_get_toggle_xml_sitemap_value;
866
  }
873
  /**
874
  * @since 3.8
875
  */
876
+ function seopress_get_toggle_google_analytics_option()
877
+ {
878
  $seopress_get_toggle_google_analytics_option = get_option('seopress_toggle');
879
+ if (! empty($seopress_get_toggle_google_analytics_option)) {
880
  foreach ($seopress_get_toggle_google_analytics_option as $key => $seopress_get_toggle_google_analytics_value) {
881
  $options[$key] = $seopress_get_toggle_google_analytics_value;
882
  }
889
  /**
890
  * @since 3.8
891
  */
892
+ function seopress_get_toggle_advanced_option()
893
+ {
894
  $seopress_get_toggle_advanced_option = get_option('seopress_toggle');
895
+ if (! empty($seopress_get_toggle_advanced_option)) {
896
  foreach ($seopress_get_toggle_advanced_option as $key => $seopress_get_toggle_advanced_value) {
897
  $options[$key] = $seopress_get_toggle_advanced_value;
898
  }
909
  /**
910
  * @deprecated 4.3.0
911
  */
912
+ function seopress_xml_sitemap_general_enable_option()
913
+ {
914
+ if (! function_exists('seopress_get_service')) {
915
  return '1';
916
  }
917
 
921
  /**
922
  * @deprecated 4.3.0
923
  */
924
+ function seopress_xml_sitemap_post_types_list_option()
925
+ {
926
+ if (! function_exists('seopress_get_service')) {
927
  return '';
928
  }
929
 
933
  /**
934
  * @deprecated 4.3.0
935
  */
936
+ function seopress_xml_sitemap_taxonomies_list_option()
937
+ {
938
+ if (! function_exists('seopress_get_service')) {
939
  return '';
940
  }
941
 
945
  /**
946
  * @deprecated 4.3.0
947
  */
948
+ function seopress_xml_sitemap_author_enable_option()
949
+ {
950
+ if (! function_exists('seopress_get_service')) {
951
  return '';
952
  }
953
 
957
  /**
958
  * @deprecated 4.3.0
959
  */
960
+ function seopress_xml_sitemap_img_enable_option()
961
+ {
962
+ if (! function_exists('seopress_get_service')) {
963
  return '';
964
  }
965
 
968
 
969
  //Rewrite Rules for XML Sitemap
970
  if ('1' == seopress_xml_sitemap_general_enable_option() && '1' == seopress_get_toggle_option('xml-sitemap')) {
971
+ function seopress_sitemaps_headers()
972
+ {
973
+ if (! function_exists('seopress_get_service')) {
974
  return;
975
  }
976
 
982
  add_filter('request', 'seopress_wpml_block_secondary_languages');
983
  }
984
 
985
+ function seopress_wpml_block_secondary_languages($q)
986
+ {
987
  $current_language = apply_filters('wpml_current_language', false);
988
  $default_language = apply_filters('wpml_default_language', false);
989
  if ($current_language !== $default_language) {
998
  }
999
  }
1000
 
1001
+ function seopress_disable_qm($allcaps, $caps, $args)
1002
+ {
1003
  $allcaps['view_query_monitor'] = false;
1004
 
1005
  return $allcaps;
1007
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1008
  // Remove Admin Bar with Content Analysis
1009
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1010
+ function seopress_clean_content_analysis()
1011
+ {
1012
  if (current_user_can('edit_posts')) {
1013
  if (isset($_GET['no_admin_bar']) && '1' === $_GET['no_admin_bar']) {
1014
  //Remove admin bar
1032
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1033
  // Test abolute URLs (return true if absolute)
1034
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1035
+ function seopress_is_absolute($url)
1036
+ {
1037
  $pattern = "%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu";
1038
 
1039
  return (bool) preg_match($pattern, $url);
1042
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1043
  // Manage localized links
1044
  ///////////////////////////////////////////////////////////////////////////////////////////////////
1045
+ function seopress_get_locale()
1046
+ {
1047
  switch (get_user_locale(get_current_user_id())) {
1048
  case 'fr_FR':
1049
  case 'fr_BE':
1074
  *
1075
  * @author Benjamin
1076
  */
1077
+ function seopress_tooltip($tooltip_title, $tooltip_desc, $tooltip_code)
1078
+ {
1079
  $html =
1080
  '<button type="button" class="sp-tooltip"><span class="dashicons dashicons-editor-help"></span>
1081
  <span class="sp-tooltiptext" role="tooltip" tabindex="0">
1100
  *
1101
  * @author Benjamin
1102
  */
1103
+ function seopress_tooltip_alt($tooltip_anchor, $tooltip_desc)
1104
+ {
1105
  $html =
1106
  '<button type="button" class="sp-tooltip alt">' . $tooltip_anchor . '
1107
  <span class="sp-tooltiptext" role="tooltip" tabindex="0">
1123
  *
1124
  * @author Benjamin
1125
  */
1126
+ function seopress_remove_utf8_bom($text)
1127
+ {
1128
  $bom = pack('H*', 'EFBBBF');
1129
  $text = preg_replace("/^$bom/", '', $text);
1130
 
1142
  *
1143
  * @author Benjamin
1144
  */
1145
+ function seopress_notification($args)
1146
+ {
1147
+ if (! empty($args)) {
1148
  $id = isset($args['id']) ? $args['id'] : null;
1149
  $title = isset($args['title']) ? $args['title'] : null;
1150
  $desc = isset($args['desc']) ? $args['desc'] : null;
1154
  $icon = isset($args['icon']) ? $args['icon'] : null;
1155
 
1156
  $class = '';
1157
+ if (! empty($impact)) {
1158
  $class .= ' impact';
1159
  $class .= ' ' . key($impact);
1160
  }
1165
 
1166
  $html = '<div id="' . $id . '-alert" class="seopress-alert">';
1167
 
1168
+ if (! empty($impact)) {
1169
  $html .= '<span class="screen-reader-text">' . reset($impact) . '</span>';
1170
  }
1171
 
1172
+ if (! empty($icon)) {
1173
  $html .= '<span class="dashicons ' . $icon . '"></span>';
1174
  } else {
1175
  $html .= '<span class="dashicons dashicons-info"></span>';
1192
  $target = ' target="_blank"';
1193
  }
1194
 
1195
+ if (! empty($link) || true === $deleteable) {
1196
  $html .= '<div class="notice-right">';
1197
 
1198
+ if (! empty($link)) {
1199
  $html .= '<a class="button-primary"' . $href . $target . '>' . $link['title'] . '</a>';
1200
  }
1201
  if (true === $deleteable) {
1220
  *
1221
  * @return (string)
1222
  **/
1223
+ function seopress_capability($cap, $context = '')
1224
+ {
1225
  $newcap = apply_filters('seopress_capability', $cap, $context);
1226
+ if (! current_user_can($newcap)) {
1227
  return $cap;
1228
  }
1229
 
1239
  *
1240
  * @return (bool)
1241
  **/
1242
+ function is_seopress_page()
1243
+ {
1244
+ if (! is_admin() && (! isset($_REQUEST['page']) || ! isset($_REQUEST['post_type']))) {
1245
  return false;
1246
  }
1247
 
1260
  * @return (bool)
1261
  **/
1262
  add_action('in_admin_header', 'seopress_remove_other_notices');
1263
+ function seopress_remove_other_notices()
1264
+ {
1265
  if (is_seopress_page()) {
1266
  remove_all_actions('network_admin_notices');
1267
  remove_all_actions('admin_notices');
1283
  *
1284
  * @return (bool)
1285
  **/
1286
+ function seopress_admin_notices()
1287
+ {
1288
  do_action('seopress_admin_notices');
1289
  }
1290
 
1297
  *
1298
  * @return (bool)
1299
  **/
1300
+ function seopress_get_days()
1301
+ {
1302
  $start_of_week = (int) get_option('start_of_week');
1303
 
1304
  return array_map(
1328
  *
1329
  * @param mixed $key
1330
  **/
1331
+ function seopress_if_key_exists(array $arr, $key)
1332
+ {
1333
  // is in base array?
1334
  if (array_key_exists($key, $arr)) {
1335
  return true;
1356
  *
1357
  * @return null
1358
  **/
1359
+ function seopress_get_oxygen_content()
1360
+ {
1361
  if (is_plugin_active('oxygen/functions.php') && function_exists('ct_template_output')) {
1362
  $seopress_get_the_content = ct_template_output();
1363
 
1364
+ if (! $seopress_get_the_content) {
1365
  //Get post content
1366
  $seopress_get_the_content = apply_filters('the_content', get_post_field('post_content', get_the_ID()));
1367
  }
1384
  //Words Counter
1385
  $data['words_counter'] = preg_match_all("/\p{L}[\p{L}\p{Mn}\p{Pd}'\x{2019}]*/u", $seopress_get_the_content, $matches);
1386
 
1387
+ if (! empty($matches[0])) {
1388
  $words_counter_unique = count(array_unique($matches[0]));
1389
  } else {
1390
  $words_counter_unique = '0';
1405
  * @author Benjamin Denis
1406
  *
1407
  **/
1408
+ function seopress_wizard_follow_us()
1409
+ {
1410
  ?>
1411
+ <li class="seopress-wizard-additional-steps">
1412
+ <div class="seopress-wizard-next-step-description">
1413
+ <p class="next-step-heading"><?php esc_html_e('Follow us:', 'wp-seopress'); ?>
1414
+ </p>
1415
+ </div>
1416
+ <div class="seopress-wizard-next-step-action step">
1417
+ <ul class="recommended-step">
1418
+ <li class="recommended-item">
1419
+ <a href="https://www.facebook.com/seopresspro/" target="_blank">
1420
+ <span class="dashicons dashicons-facebook"></span>
1421
+ <?php _e('Like our Facebook page', 'wp-seopress'); ?>
1422
+ </a>
1423
+ </li>
1424
+ <li class="recommended-item">
1425
+ <a href="https://www.facebook.com/groups/seopress/" target="_blank">
1426
+ <span class="dashicons dashicons-facebook"></span>
1427
+ <?php _e('Join our Facebook Community group', 'wp-seopress'); ?>
1428
+ </a>
1429
+ </li>
1430
+ <li class="recommended-item">
1431
+ <a href="https://www.youtube.com/seopress" target="_blank">
1432
+ <span class="dashicons dashicons-video-alt3"></span>
1433
+ <?php _e('Watch our guided tour videos to learn more about SEOPress', 'wp-seopress'); ?>
1434
+ </a>
1435
+ </li>
1436
+ <li class="recommended-item">
1437
+ <?php
1438
  if (function_exists('seopress_get_locale') && 'fr' == seopress_get_locale()) {
1439
  $link = 'https://www.seopress.org/fr/blog/category/tutoriels/?utm_source=plugin&utm_medium=wizard&utm_campaign=seopress';
1440
  } else {
1441
  $link = 'https://www.seopress.org/blog/how-to/?utm_source=plugin&utm_medium=wizard&utm_campaign=seopress';
1442
  } ?>
1443
+ <a href="<?php echo $link; ?>" target="_blank">
1444
+ <span class="dashicons dashicons-format-aside"></span>
1445
+ <?php _e('Read our blog posts about SEO concepts, tutorials and more', 'wp-seopress'); ?>
1446
+ </a>
1447
+ </li>
1448
+ <li class="recommended-item">
1449
+ <a href="https://twitter.com/wp_seopress" target="_blank">
1450
+ <span class="dashicons dashicons-twitter"></span>
1451
+ <?php _e('Follow us on Twitter', 'wp-seopress'); ?>
1452
+ </a>
1453
+ </li>
1454
+ <li class="recommended-item">
1455
+ <a href="https://www.instagram.com/wp_seopress/" target="_blank">
1456
+ <span class="dashicons dashicons-instagram"></span>
1457
+ <?php _e('The off side of SEOPress', 'wp-seopress'); ?>
1458
+ </a>
1459
+ </li>
1460
+ </ul>
1461
+ </div>
1462
+ </li>
1463
+ <?php
1464
  }