SEOPress - Version 4.3.0.2

Version Description

(19/01/2021) = * FIX Analytics tracking code if no UA-XXX set * FIX Conflict Google Analytics with UpdraftPlus (PRO)

Download this release

Release Info

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

Code changes from version 4.3.0.1 to 4.3.0.2

assets/img/help/google-knowledge-graph-social.png ADDED
Binary file
inc/admin/admin-metaboxes-content-analysis-form.php CHANGED
File without changes
inc/admin/admin-metaboxes-get-content-analysis.php ADDED
@@ -0,0 +1,740 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined( 'ABSPATH' ) or die( 'Please don&rsquo;t call the plugin directly. Thanks :)' );
3
+
4
+ //Analyzes
5
+ $analyzes = array(
6
+ 'schemas'=> array(
7
+ 'title' => __('Structured data types','wp-seopress'),
8
+ 'impact' => 'good',
9
+ 'desc' => NULL
10
+ ),
11
+ 'old_post'=> array(
12
+ 'title' => __('Last modified date','wp-seopress'),
13
+ 'impact' => 'good',
14
+ 'desc' => NULL
15
+ ),
16
+ 'words_counter'=> array(
17
+ 'title' => __('Words counter','wp-seopress'),
18
+ 'impact' => 'good',
19
+ 'desc' => NULL
20
+ ),
21
+ 'keywords_density'=> array(
22
+ 'title' => __('Keywords density','wp-seopress'),
23
+ 'impact' => NULL,
24
+ 'desc' => NULL
25
+ ),
26
+ 'keywords_permalink'=> array(
27
+ 'title' => __('Keywords in permalink','wp-seopress'),
28
+ 'impact' => NULL,
29
+ 'desc' => NULL
30
+ ),
31
+ 'headings'=> array(
32
+ 'title' => __('Headings','wp-seopress'),
33
+ 'impact' => 'good',
34
+ 'desc' => NULL
35
+ ),
36
+ 'meta_title'=> array(
37
+ 'title' => __('Meta title','wp-seopress'),
38
+ 'impact' => NULL,
39
+ 'desc' => NULL
40
+ ),
41
+ 'meta_desc'=> array(
42
+ 'title' => __('Meta description','wp-seopress'),
43
+ 'impact' => NULL,
44
+ 'desc' => NULL
45
+ ),
46
+ 'social'=> array(
47
+ 'title' => __('Social meta tags','wp-seopress'),
48
+ 'impact' => 'good',
49
+ 'desc' => NULL
50
+ ),
51
+ 'robots'=> array(
52
+ 'title' => __('Meta robots','wp-seopress'),
53
+ 'impact' => 'good',
54
+ 'desc' => NULL
55
+ ),
56
+ 'img_alt'=> array(
57
+ 'title' => __('Alternative texts of images','wp-seopress'),
58
+ 'impact' => 'good',
59
+ 'desc' => NULL
60
+ ),
61
+ 'nofollow_links'=> array(
62
+ 'title' => __('NoFollow Links','wp-seopress'),
63
+ 'impact' => 'good',
64
+ 'desc' => NULL
65
+ ),
66
+ 'outbound_links'=> array(
67
+ 'title' => __('Outbound Links','wp-seopress'),
68
+ 'impact' => 'good',
69
+ 'desc' => NULL
70
+ ),
71
+ );
72
+
73
+ //Schemas
74
+ if (!empty($seopress_analysis_data['json']) || isset($seopress_analysis_data['json'])) {
75
+ $desc = '<p>'.__('We found these schemas in the source code of this page:','wp-seopress').'</p>';
76
+
77
+ $desc .= '<ul>';
78
+ $json_ld = array_filter($seopress_analysis_data['json']);
79
+ foreach(array_count_values($json_ld) as $key => $value) {
80
+ $html = NULL;
81
+ if ($value > 1) {
82
+ $html = '<span class="impact high">'.__('duplicated schema - x','wp-seopress').$value.'</span>';
83
+ $analyzes['schemas']['impact'] = 'high';
84
+ }
85
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$key.$html.'</li>';
86
+ }
87
+ $desc .= '</ul>';
88
+ $analyzes['schemas']['desc'] = $desc;
89
+ } else {
90
+ $analyzes['schemas']['impact'] = 'medium';
91
+ $analyzes['schemas']['desc'] = '<p>'.__('No schemas found in the source code of this page.','wp-seopress').'</p>';
92
+ }
93
+
94
+ //Old post
95
+ $desc = NULL;
96
+ if( strtotime( $post->post_modified ) < strtotime('-365 days') ) {
97
+ $analyzes['old_post']['impact'] = 'medium';
98
+ $desc = '<p><span class="dashicons dashicons-no-alt"></span>'.__('This post is a little old!','wp-seopress').'</p>';
99
+ } else {
100
+ $desc = '<p><span class="dashicons dashicons-yes"></span>'.__('The last modified date of this article is less than 1 year. Cool!','wp-seopress').'</p>';
101
+ }
102
+ $desc .= '<p>'.__('Search engines love fresh content. Regularly update your articles without having to rewrite your content entirely and give them a boost in search rankings. We takes care of the technical part.','wp-seopress').'</p>';
103
+ $analyzes['old_post']['desc'] = $desc;
104
+
105
+ //Word counters
106
+ $desc = NULL;
107
+ if (isset($seopress_analysis_data['words_counter']) || isset($seopress_analysis_data['words_counter_unique'])) {
108
+ $desc = '<p>'.__('Words counter is not a direct ranking factor. But, your content must be as qualitative as possible, with relevant and unique information. To fulfill these conditions, your article requires a minimum of paragraphs, so words.','wp-seopress').'</p>
109
+ <ul>
110
+ <li>'.$seopress_analysis_data['words_counter'].' '.__('words found.','wp-seopress').'</li>
111
+ <li>'.$seopress_analysis_data['words_counter_unique'].' '.__('unique words found.','wp-seopress').'</li>';
112
+
113
+ if ($seopress_analysis_data['words_counter'] >= 299) {
114
+ $desc .= '<li><span class="dashicons dashicons-yes"></span>'.__('Your content is composed of more than 300 words, which is the minimum for a post.','wp-seopress').'</li>';
115
+ } else {
116
+ $desc .= '<li><span class="dashicons dashicons-no-alt"></span>'.__('Your content is too short. Add a few more paragraphs!','wp-seopress').'</li>';
117
+ $analyzes['words_counter']['impact'] = 'medium';
118
+ }
119
+ $desc .= '</ul>';
120
+
121
+ $analyzes['words_counter']['desc'] = $desc;
122
+ } else {
123
+ $analyzes['words_counter']['desc'] = '<p><span class="dashicons dashicons-no-alt"></span>'.__('No content? Add a few more paragraphs!','wp-seopress').'</p>';
124
+ $analyzes['words_counter']['impact'] = 'high';
125
+ }
126
+
127
+ //Keywords density
128
+ if (!empty($seopress_analysis_data['kws_density']['matches']) && isset($seopress_analysis_data['words_counter'])) {
129
+ $target_kws_density = $seopress_analysis_data['kws_density']['matches'];
130
+
131
+ $desc = '<ul>';
132
+ foreach ($target_kws_density as $key => $value) {
133
+ foreach ($value as $_key => $_value) {
134
+ $kw_count = count($_value);
135
+ }
136
+ $kw_name = $key;
137
+ $kw_density = round($kw_count/$seopress_analysis_data['words_counter']*100, 2);
138
+ /* translators: %s target keyword %d count target keyword %s keyword density in % */
139
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.sprintf(esc_html__('%s was found %d times in your content, a keyword density of %s%%','wp-seopress'), $kw_name, $kw_count, $kw_density).'</li>';
140
+ }
141
+ $desc .= '</ul>';
142
+ $desc .= '<p class="description">'.__('Learn more about <a href="https://www.youtube.com/watch?v=Rk4qgQdp2UA" target="_blank">keywords stuffing</a>.','wp-seopress').'</p>';
143
+ $analyzes['keywords_density']['impact'] = 'good';
144
+ $analyzes['keywords_density']['desc'] = $desc;
145
+ } else {
146
+ $analyzes['keywords_density']['desc'] = '<p>'.__('We were unable to calculate the density of your keywords. You probably haven‘t added any content or your target keywords were not find in your post content.','wp-seopress').'</p>';
147
+ $analyzes['keywords_density']['impact'] = 'high';
148
+ }
149
+
150
+ //Keywords in permalink
151
+ if (!empty($seopress_analysis_data['kws_permalink']['matches'])) {
152
+ $desc = '<p><span class="dashicons dashicons-yes"></span>'.__('Cool, one of your target keyword is used in your permalink.','wp-seopress').'</p>';
153
+
154
+ $target_kws_permalink = $seopress_analysis_data['kws_permalink']['matches'];
155
+
156
+ $desc .= '<ul>';
157
+ foreach ($target_kws_permalink as $key => $value) {
158
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$key.'</li>';
159
+ }
160
+ $desc .= '</ul>';
161
+ $analyzes['keywords_permalink']['desc'] = $desc;
162
+ $analyzes['keywords_permalink']['impact'] = 'good';
163
+ } else {
164
+ global $post;
165
+ if (get_option( 'page_on_front' ) == $post->ID) {
166
+ $analyzes['keywords_permalink']['desc'] = '<p><span class="dashicons dashicons-yes"></span>'.__('This is your homepage. This check doesn\'t apply here because there is no slug.','wp-seopress').'</p>';
167
+ $analyzes['keywords_permalink']['impact'] = 'good';
168
+ } else {
169
+ $analyzes['keywords_permalink']['desc'] = '<p><span class="dashicons dashicons-no-alt"></span>'.__('You should add one of your target keyword in your permalink.','wp-seopress').'</p>';
170
+ $analyzes['keywords_permalink']['impact'] = 'medium';
171
+ }
172
+ }
173
+
174
+
175
+ //Headings
176
+ //H1
177
+ $desc = NULL;
178
+ if (!empty($seopress_analysis_data['h1']['matches'])) {
179
+ $desc .= '<h4>'.__('H1 (Heading 1)','wp-seopress').'</h4>';
180
+
181
+ $count = $seopress_analysis_data['h1']['nomatches']['count'];
182
+
183
+ $target_kws_h1 = $seopress_analysis_data['h1']['matches'];
184
+
185
+ $all_h1 = $seopress_analysis_data['h1']['values'];
186
+
187
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('Target keywords were found in Heading 1 (H1).','wp-seopress').'</p>';
188
+
189
+ $desc .= '<ul>';
190
+
191
+ foreach ($target_kws_h1 as $key => $value) {
192
+ foreach ($value as $_key => $_value) {
193
+ $kw_count = count($value);
194
+ }
195
+ $kw_name = $key;
196
+ /* translators: %s target keyword %d count target keyword */
197
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.sprintf(esc_html__('%s was found %d times.','wp-seopress'), $kw_name, $kw_count).'</li>';
198
+ }
199
+
200
+ $desc .= '</ul>';
201
+ if ($count > 1) {
202
+ /* translators: %d: count heading 1 */
203
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d Heading 1 (H1) in your content.','wp-seopress'), $count).'</p>';
204
+ $desc .= '<p>'.__('You should not use more than one H1 heading in your post content. The rule is simple: only one H1 for each web page. It is better for both SEO and accessibility. Below, the list:','wp-seopress').'</p>';
205
+ $analyzes['headings']['impact'] = 'high';
206
+ }
207
+
208
+ if (!empty($all_h1)) {
209
+ $desc .= '<ul>';
210
+ foreach($all_h1 as $h1) {
211
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$h1.'</li>';
212
+ }
213
+ $desc .= '</ul>';
214
+ }
215
+ }
216
+
217
+ //H2
218
+ $desc .= '<h4>'.__('H2 (Heading 2)','wp-seopress').'</h4>';
219
+ if (!empty($seopress_analysis_data['h2']['matches'])) {
220
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('Target keywords were found in Heading 2 (H2).','wp-seopress').'</p>';
221
+ $desc .= '<ul>';
222
+ $target_kws_h2 = $seopress_analysis_data['h2']['matches'];
223
+ foreach ($target_kws_h2 as $key => $value) {
224
+ foreach ($value as $_key => $_value) {
225
+ $kw_count = count($value);
226
+ }
227
+ $kw_name = $key;
228
+ /* translators: %s target keyword %d count target keyword */
229
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.sprintf(esc_html__('%s was found %d times.','wp-seopress'), $kw_name, $kw_count).'</li>';
230
+ }
231
+ $desc .= '</ul>';
232
+ } else {
233
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('None of your target keywords were found in Heading 2 (H2).','wp-seopress').'</p>';
234
+ if ($analyzes['headings']['impact'] != 'high') {
235
+ $analyzes['headings']['impact'] = 'medium';
236
+ }
237
+ }
238
+
239
+ //H3
240
+ $desc .= '<h4>'.__('H3 (Heading 3)','wp-seopress').'</h4>';
241
+ if (!empty($seopress_analysis_data['h3']['matches'])) {
242
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('Target keywords were found in Heading 3 (H3).','wp-seopress').'</p>';
243
+ $desc .= '<ul>';
244
+ $target_kws_h3 = $seopress_analysis_data['h3']['matches'];
245
+ foreach ($target_kws_h3 as $key => $value) {
246
+ foreach ($value as $_key => $_value) {
247
+ $kw_count = count($value);
248
+ }
249
+ $kw_name = $key;
250
+ /* translators: %s target keyword %d count target keyword */
251
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.sprintf(esc_html__('%s was found %d times.','wp-seopress'), $kw_name, $kw_count).'</li>';
252
+ }
253
+ $desc .= '</ul>';
254
+ } else {
255
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('None of your target keywords were found in Heading 3 (H3).','wp-seopress').'</p>';
256
+ if ($analyzes['headings']['impact'] != 'high') {
257
+ $analyzes['headings']['impact'] = 'medium';
258
+ }
259
+ }
260
+ $analyzes['headings']['desc'] = $desc;
261
+
262
+ //Meta Title
263
+ if ($seopress_titles_title !='') {
264
+ $desc = NULL;
265
+ if (!empty($seopress_analysis_data['meta_title']['matches'])) {
266
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('Target keywords were found in the Meta Title.','wp-seopress').'</p>';
267
+ $desc .= '<ul>';
268
+ $target_kws_title = $seopress_analysis_data['meta_title']['matches'];
269
+ foreach ($target_kws_title as $key => $value) {
270
+ foreach ($value as $_key => $_value) {
271
+ $kw_count = count($_value);
272
+ }
273
+ $kw_name = $key;
274
+ /* translators: %s target keyword %d count target keyword */
275
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.sprintf(esc_html__('%s was found %d times.','wp-seopress'), $kw_name, $kw_count).'</li>';
276
+ }
277
+ $desc .= '</ul>';
278
+ $analyzes['meta_title']['impact'] = 'good';
279
+ } else {
280
+ $analyzes['meta_title']['impact'] = 'medium';
281
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('None of your target keywords were found in the Meta Title.','wp-seopress').'</p>';
282
+ }
283
+
284
+ if (mb_strlen($seopress_titles_title) > 65 ) {
285
+ $analyzes['meta_title']['impact'] = 'medium';
286
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your custom title is too long.','wp-seopress').'</p>';
287
+ } else {
288
+ $analyzes['meta_title']['impact'] = 'good';
289
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('The length of your title is correct','wp-seopress').'</p>';
290
+ }
291
+ $analyzes['meta_title']['desc'] = $desc;
292
+ } else {
293
+ $analyzes['meta_title']['impact'] = 'medium';
294
+ $analyzes['meta_title']['desc'] = '<p><span class="dashicons dashicons-no-alt"></span>'.__('No custom title is set for this post. If the global meta title suits you, you can ignore this recommendation.','wp-seopress').'</p>';
295
+ }
296
+
297
+ //Meta description
298
+ if ($seopress_titles_desc !='') {
299
+ $desc = NULL;
300
+ if (!empty($seopress_analysis_data['meta_description']['matches'])) {
301
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('Target keywords were found in the Meta description.','wp-seopress').'</p>';
302
+ $desc .= '<ul>';
303
+ $target_kws_desc = $seopress_analysis_data['meta_description']['matches'];
304
+ foreach ($target_kws_desc as $key => $value) {
305
+ foreach ($value as $_key => $_value) {
306
+ $kw_count = count($_value);
307
+ }
308
+ $kw_name = $key;
309
+ /* translators: %s target keyword %d count target keyword */
310
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.sprintf(esc_html__('%s was found %d times.','wp-seopress'), $kw_name, $kw_count).'</li>';
311
+ }
312
+ $desc .= '</ul>';
313
+ $analyzes['meta_desc']['impact'] = 'good';
314
+ } else {
315
+ $analyzes['meta_desc']['impact'] = 'medium';
316
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('None of your target keywords were found in the Meta description.','wp-seopress').'</p>';
317
+ }
318
+
319
+ if (mb_strlen($seopress_titles_desc) > 160 ) {
320
+ $analyzes['meta_desc']['impact'] = 'medium';
321
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('You custom meta description is too long.','wp-seopress').'</p>';
322
+ } else {
323
+ $analyzes['meta_desc']['impact'] = 'good';
324
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('The length of your meta description is correct','wp-seopress').'</p>';
325
+ }
326
+ $analyzes['meta_desc']['desc'] = $desc;
327
+ } else {
328
+ $analyzes['meta_desc']['impact'] = 'medium';
329
+ $analyzes['meta_desc']['desc'] = '<p><span class="dashicons dashicons-no-alt"></span>'.__('No custom meta description is set for this post. If the global meta description suits you, you can ignore this recommendation.','wp-seopress').'</p>';
330
+ }
331
+
332
+ //Social tags
333
+ //og:title
334
+ $desc = NULL;
335
+
336
+ $desc .= '<h4>'.__('Open Graph Title','wp-seopress').'</h4>';
337
+
338
+ if (!empty($seopress_analysis_data['og_title']['count'])) {
339
+ $count = $seopress_analysis_data['og_title']['count'];
340
+
341
+ $all_og_title = $seopress_analysis_data['og_title']['values'];
342
+
343
+ if ($count > 1) {
344
+ $analyzes['social']['impact'] = 'high';
345
+ /* translators: %d count Open Graph Title */
346
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d og:title in your content.','wp-seopress'), $count).'</p>';
347
+ $desc .= '<p>'.__('You should not use more than one og:title in your post content to avoid conflicts when sharing on social networks. Facebook will take the last og:title tag from your source code. Below, the list:','wp-seopress').'</p>';
348
+ } elseif(empty($all_og_title[0])) { //If og:title empty
349
+ $analyzes['social']['impact'] = 'high';
350
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Title tag is empty!','wp-seopress').'</p>';
351
+ } else {
352
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found an Open Graph Title tag in your source code.','wp-seopress').'</p>';
353
+ }
354
+
355
+ if (!empty($all_og_title)) {
356
+ $desc .= '<ul>';
357
+ foreach($all_og_title as $og_title) {
358
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$og_title.'</li>';
359
+ }
360
+ $desc .= '</ul>';
361
+ }
362
+ } else {
363
+ $analyzes['social']['impact'] = 'high';
364
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Title is missing!','wp-seopress').'</p>';
365
+ }
366
+
367
+ //og:description
368
+ $desc .= '<h4>'.__('Open Graph Description','wp-seopress').'</h4>';
369
+
370
+ if (!empty($seopress_analysis_data['og_desc']['count'])) {
371
+
372
+ $count = $seopress_analysis_data['og_desc']['count'];
373
+
374
+ $all_og_desc = isset($seopress_analysis_data['og_desc']['values']) ? $seopress_analysis_data['og_desc']['values'] : [];
375
+
376
+ if ($count > 1) {
377
+ $analyzes['social']['impact'] = 'high';
378
+ /* translators: %d count Open Graph Description */
379
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d og:description in your content.','wp-seopress'), $count).'</p>';
380
+ $desc .= '<p>'.__('You should not use more than one og:description in your post content to avoid conflicts when sharing on social networks. Facebook will take the last og:description tag from your source code. Below, the list:','wp-seopress').'</p>';
381
+ } elseif(empty($all_og_desc[0])) { //If og:description empty
382
+ $analyzes['social']['impact'] = 'high';
383
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Description tag is empty!','wp-seopress').'</p>';
384
+ } else {
385
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found an Open Graph Description tag in your source code.','wp-seopress').'</p>';
386
+ }
387
+
388
+ if (!empty($all_og_desc)) {
389
+ $desc .= '<ul>';
390
+ foreach($all_og_desc as $og_desc) {
391
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$og_desc.'</li>';
392
+ }
393
+ $desc .= '</ul>';
394
+ }
395
+ } else {
396
+ $analyzes['social']['impact'] = 'high';
397
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Description is missing!','wp-seopress').'</p>';
398
+ }
399
+
400
+ //og:image
401
+ $desc .= '<h4>'.__('Open Graph Image','wp-seopress').'</h4>';
402
+
403
+ if (!empty($seopress_analysis_data['og_img']['count'])) {
404
+
405
+ $count = $seopress_analysis_data['og_img']['count'];
406
+
407
+ $all_og_img = isset($seopress_analysis_data['og_img']['values']) ? $seopress_analysis_data['og_img']['values'] : [];
408
+
409
+ if ($count > 0 && !empty($all_og_img[0])) {
410
+ /* translators: %d count Open Graph Image */
411
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.sprintf(esc_html__('We found %d og:image in your content.','wp-seopress'), $count).'</p>';
412
+ }
413
+
414
+ //If og:image empty
415
+ if ($count > 0 && empty($all_og_img[0])) {
416
+ $analyzes['social']['impact'] = 'high';
417
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Image tag is empty!','wp-seopress').'</p>';
418
+ }
419
+
420
+ if (!empty($all_og_img)) {
421
+ $desc .= '<ul>';
422
+ foreach($all_og_img as $og_img) {
423
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$og_img.'</li>';
424
+ }
425
+ $desc .= '</ul>';
426
+ }
427
+ } else {
428
+ $analyzes['social']['impact'] = 'high';
429
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Image is missing!','wp-seopress').'</p>';
430
+ }
431
+
432
+ //og:url
433
+ $desc .= '<h4>'.__('Open Graph URL','wp-seopress').'</h4>';
434
+
435
+ if (!empty($seopress_analysis_data['og_url']['count'])) {
436
+
437
+ $count = $seopress_analysis_data['og_url']['count'];
438
+
439
+ $all_og_url = $seopress_analysis_data['og_url']['values'];
440
+
441
+ if ($count > 1) {
442
+ $analyzes['social']['impact'] = 'high';
443
+ /* translators: %d count Open Graph URL */
444
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d og:url in your content.','wp-seopress'), $count).'</p>';
445
+ $desc .= '<p>'.__('You should not use more than one og:url in your post content to avoid conflicts when sharing on social networks. Facebook will take the last og:url tag from your source code. Below, the list:','wp-seopress').'</p>';
446
+ } elseif(empty($all_og_url[0])) { //If og:url empty
447
+ $analyzes['social']['impact'] = 'high';
448
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph URL tag is empty!','wp-seopress').'</p>';
449
+ } else {
450
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found an Open Graph URL tag in your source code.','wp-seopress').'</p>';
451
+ }
452
+
453
+ if (!empty($all_og_url)) {
454
+ $desc .= '<ul>';
455
+ foreach($all_og_url as $og_url) {
456
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$og_url.'</li>';
457
+ }
458
+ $desc .= '</ul>';
459
+ }
460
+ } else {
461
+ $analyzes['social']['impact'] = 'high';
462
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph URL is missing!','wp-seopress').'</p>';
463
+ }
464
+
465
+ //og:site_name
466
+ $desc .= '<h4>'.__('Open Graph Site Name','wp-seopress').'</h4>';
467
+
468
+ if (!empty($seopress_analysis_data['og_site_name']['count'])) {
469
+
470
+ $count = $seopress_analysis_data['og_site_name']['count'];
471
+
472
+ $all_og_site_name = $seopress_analysis_data['og_site_name']['values'];
473
+
474
+ if ($count > 1) {
475
+ $analyzes['social']['impact'] = 'high';
476
+ /* translators: %d count Open Graph site name */
477
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d og:site_name in your content.','wp-seopress'), $count).'</p>';
478
+ $desc .= '<p>'.__('You should not use more than one og:site_name in your post content to avoid conflicts when sharing on social networks. Facebook will take the last og:site_name tag from your source code. Below, the list:','wp-seopress').'</p>';
479
+ } elseif(empty($all_og_site_name[0])) { //If og:site_name empty
480
+ $analyzes['social']['impact'] = 'high';
481
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Site Name tag is empty!','wp-seopress').'</p>';
482
+ } else {
483
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found an Open Graph Site Name tag in your source code.','wp-seopress').'</p>';
484
+ }
485
+
486
+ if (!empty($all_og_site_name)) {
487
+ $desc .= '<ul>';
488
+ foreach($all_og_site_name as $og_site_name) {
489
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$og_site_name.'</li>';
490
+ }
491
+ $desc .= '</ul>';
492
+ }
493
+ } else {
494
+ $analyzes['social']['impact'] = 'high';
495
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Open Graph Site Name is missing!','wp-seopress').'</p>';
496
+ }
497
+
498
+ //twitter:title
499
+ $desc .= '<h4>'.__('Twitter Title','wp-seopress').'</h4>';
500
+
501
+ if (!empty($seopress_analysis_data['tw_title']['count'])) {
502
+
503
+ $count = $seopress_analysis_data['tw_title']['count'];
504
+
505
+ $all_tw_title = $seopress_analysis_data['tw_title']['values'];
506
+
507
+ if ($count > 1) {
508
+ $analyzes['social']['impact'] = 'high';
509
+ /* translators: %d count Twitter Title */
510
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d twitter:title in your content.','wp-seopress'), $count).'</p>';
511
+ $desc .= '<p>'.__('You should not use more than one twitter:title in your post content to avoid conflicts when sharing on social networks. Twitter will take the last twitter:title tag from your source code. Below, the list:','wp-seopress').'</p>';
512
+ } elseif(empty($all_tw_title[0])) { //If twitter:title empty
513
+ $analyzes['social']['impact'] = 'high';
514
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Twitter Title tag is empty!','wp-seopress').'</p>';
515
+ } else {
516
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found a Twitter Title tag in your source code.','wp-seopress').'</p>';
517
+ }
518
+
519
+ if (!empty($all_tw_title)) {
520
+ $desc .= '<ul>';
521
+ foreach($all_tw_title as $tw_title) {
522
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$tw_title.'</li>';
523
+ }
524
+ $desc .= '</ul>';
525
+ }
526
+ } else {
527
+ $analyzes['social']['impact'] = 'high';
528
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Twitter Title is missing!','wp-seopress').'</p>';
529
+ }
530
+
531
+ //twitter:description
532
+ $desc .= '<h4>'.__('Twitter Description','wp-seopress').'</h4>';
533
+
534
+ if (!empty($seopress_analysis_data['tw_desc']['count'])) {
535
+
536
+ $count = $seopress_analysis_data['tw_desc']['count'];
537
+
538
+ $all_tw_desc = isset($seopress_analysis_data['tw_desc']['values']) ? $seopress_analysis_data['tw_desc']['values'] : [];
539
+
540
+ if ($count > 1) {
541
+ $analyzes['social']['impact'] = 'high';
542
+ /* translators: %d count Twitter Description */
543
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %d twitter:description in your content.','wp-seopress'), $count).'</p>';
544
+ $desc .= '<p>'.__('You should not use more than one twitter:description in your post content to avoid conflicts when sharing on social networks. Twitter will take the last twitter:description tag from your source code. Below, the list:','wp-seopress').'</p>';
545
+ } elseif(empty($all_tw_desc[0])) { //If twitter:description empty
546
+ $analyzes['social']['impact'] = 'high';
547
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Twitter Description tag is empty!','wp-seopress').'</p>';
548
+ } else {
549
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found a Twitter Description tag in your source code.','wp-seopress').'</p>';
550
+ }
551
+
552
+ if (!empty($all_tw_desc)) {
553
+ $desc .= '<ul>';
554
+ foreach($all_tw_desc as $tw_desc) {
555
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$tw_desc.'</li>';
556
+ }
557
+ $desc .= '</ul>';
558
+ }
559
+ } else {
560
+ $analyzes['social']['impact'] = 'high';
561
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Twitter Description is missing!','wp-seopress').'</p>';
562
+ }
563
+
564
+ //twitter:image
565
+ $desc .= '<h4>'.__('Twitter Image','wp-seopress').'</h4>';
566
+
567
+ if (!empty($seopress_analysis_data['tw_img']['count'])) {
568
+
569
+ $count = $seopress_analysis_data['tw_img']['count'];
570
+
571
+ $all_tw_img = isset($seopress_analysis_data['tw_img']['values']) ? $seopress_analysis_data['tw_img']['values'] : [];
572
+
573
+ if ($count > 0 && !empty($all_tw_img[0])) {
574
+ /* translators: %d count Twitter Image */
575
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.sprintf(esc_html__('We found %d twitter:image in your content.','wp-seopress'), $count).'</p>';
576
+ }
577
+
578
+ //If twitter:image:src empty
579
+ if ($count > 0 && empty($all_tw_img[0])) {
580
+ $analyzes['social']['impact'] = 'high';
581
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Twitter Image tag is empty!','wp-seopress').'</p>';
582
+ }
583
+
584
+ if (!empty($all_tw_img)) {
585
+ $desc .= '<ul>';
586
+ foreach($all_tw_img as $tw_img) {
587
+ $desc .= '<li><span class="dashicons dashicons-minus"></span>'.$tw_img.'</li>';
588
+ }
589
+ $desc .= '</ul>';
590
+ }
591
+ } else {
592
+ $analyzes['social']['impact'] = 'high';
593
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('Your Twitter Image is missing!','wp-seopress').'</p>';
594
+ }
595
+ $analyzes['social']['desc'] = $desc;
596
+
597
+ //Robots
598
+ $desc = NULL;
599
+ if (!empty($seopress_analysis_data['meta_robots'])) {
600
+
601
+ $meta_robots = $seopress_analysis_data['meta_robots'];
602
+
603
+ if (count($seopress_analysis_data['meta_robots']) > 1) {
604
+ $analyzes['robots']['impact'] = 'high';
605
+
606
+ $count_meta_robots = count($seopress_analysis_data['meta_robots']);
607
+
608
+ /* translators: %d count meta robots tag */
609
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.sprintf(esc_html__('We found %s meta robots in your page. There is probably something wrong with your theme!','wp-seopress'), $count_meta_robots).'</p>';
610
+ }
611
+
612
+ if (preg_match('/noindex/', json_encode($meta_robots))) {
613
+ $analyzes['robots']['impact'] = 'high';
614
+ $desc .= '<p data-robots="noindex"><span class="dashicons dashicons-no-alt"></span>'.__('noindex is on! Search engines can\'t index this page.','wp-seopress').'</p>';
615
+ } else {
616
+ $desc .= '<p data-robots="index"><span class="dashicons dashicons-yes"></span>'.__('noindex is off. Search engines will index this page.','wp-seopress').'</p>';
617
+ }
618
+
619
+ if (preg_match('/nofollow/', json_encode($meta_robots))) {
620
+ $analyzes['robots']['impact'] = 'high';
621
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('nofollow is on! Search engines can\'t follow your links on this page.','wp-seopress').'</p>';
622
+ } else {
623
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('nofollow is off. Search engines will follow links on this page.','wp-seopress').'</p>';
624
+ }
625
+
626
+ if (preg_match('/noarchive/', json_encode($meta_robots))) {
627
+ if ($analyzes['robots']['impact'] != 'high') {
628
+ $analyzes['robots']['impact'] = 'medium';
629
+ }
630
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('noarchive is on! Search engines will not cache your page.','wp-seopress').'</p>';
631
+ } else {
632
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('noarchive is off. Search engines will probably cache your page.','wp-seopress').'</p>';
633
+ }
634
+
635
+ if (preg_match('/nosnippet/', json_encode($meta_robots))) {
636
+ if ($analyzes['robots']['impact'] != 'high') {
637
+ $analyzes['robots']['impact'] = 'medium';
638
+ }
639
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('nosnippet is on! Search engines will not display a snippet of this page in search results.','wp-seopress').'</p>';
640
+ } else {
641
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('nosnippet is off. Search engines will display a snippet of this page in search results.','wp-seopress').'</p>';
642
+ }
643
+ } else {
644
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('We found no meta robots on this page. It means, your page is index,follow. Search engines will index it, and follow links. ','wp-seopress').'</p>';
645
+ }
646
+
647
+ //Meta Google
648
+ if (!empty($seopress_analysis_data['meta_google'])) {
649
+ $meta_google = $seopress_analysis_data['meta_google'];
650
+
651
+ if (preg_match('/noimageindex/', json_encode($meta_google))) {
652
+ $analyzes['robots']['impact'] = 'high';
653
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('noimageindex is on! Google will not index your images on this page (but if someone makes a direct link to one of your image in this page, it will be indexed).','wp-seopress').'</p>';
654
+ } else {
655
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('noimageindex is off. Google will index the images on this page.','wp-seopress').'</p>';
656
+ }
657
+
658
+ if (preg_match('/nositelinkssearchbox/', json_encode($meta_google))) {
659
+ if ($analyzes['robots']['impact'] != 'high') {
660
+ $analyzes['robots']['impact'] = 'medium';
661
+ }
662
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('nositelinkssearchbox is on! Google will not display a sitelinks searchbox in search results.','wp-seopress').'</p>';
663
+ } else {
664
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('nositelinkssearchbox is off. Google will probably display a sitelinks searchbox in search results.','wp-seopress').'</p>';
665
+ }
666
+ } else {
667
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('noimageindex is off. Google will index the images on this page.','wp-seopress').'</p>';
668
+
669
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('nositelinkssearchbox is off. Google will probably display a sitelinks searchbox in search results.','wp-seopress').'</p>';
670
+ }
671
+
672
+ $analyzes['robots']['desc'] = $desc;
673
+
674
+ //Img alt
675
+ if (!empty($seopress_analysis_data['img'])) {
676
+ $images = isset($seopress_analysis_data['img']['images']) ? $seopress_analysis_data['img']['images'] : NULL;
677
+
678
+ $desc = '<div class="wrap-analysis-img">';
679
+
680
+ if (!empty($images)) {
681
+ $analyzes['img_alt']['impact'] = 'high';
682
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('No alternative text found for these images. Alt tags are important for both SEO and accessibility. Edit your images using the media library or your favorite page builder and fill in alternative text fields.','wp-seopress').'</p>';
683
+
684
+ //Standard images & galleries
685
+ if (!empty($images)) {
686
+ $desc .= '<ul class="attachments">';
687
+ foreach($images as $img) {
688
+ $desc .= '<li class="attachment"><img src="'.$img.'"/></li>';
689
+ }
690
+ $desc .= '</ul>';
691
+ }
692
+ } else {
693
+ $desc .= '<p><span class="dashicons dashicons-yes"></span>'.__('All alternative tags are filled in. Good work!','wp-seopress').'</p>';
694
+ }
695
+ $desc .= '</div>';
696
+
697
+ $analyzes['img_alt']['desc'] = $desc;
698
+ } else {
699
+ $analyzes['img_alt']['impact'] = 'medium';
700
+ $analyzes['img_alt']['desc'] = '<p><span class="dashicons dashicons-no-alt"></span>'.__('We could not find any image in your content. Content with media is a plus for your SEO.','wp-seopress').'</p>';
701
+ }
702
+
703
+ //Nofollow links
704
+ if (!empty($seopress_analysis_data['nofollow_links'])) {
705
+ $count = count($seopress_analysis_data['nofollow_links']);
706
+
707
+ /* translators: %d count nofollow attributes */
708
+ $desc = '<p>'.sprintf( esc_html__( 'We found %d links with nofollow attribute in your page. Do not overuse nofollow attribute in links. Below, the list:', 'wp-seopress' ), $count ).'</p>';
709
+ $desc .= '<ul>';
710
+ foreach ($seopress_analysis_data['nofollow_links'] as $links) {
711
+ foreach ($links as $href => $link) {
712
+ $desc .= '<li><span class="dashicons dashicons-minus"></span><a href="'.$href.'" target="_blank">'.$link.'</a><span class="dashicons dashicons-external"></span></li>';
713
+ }
714
+ }
715
+ $desc .= '</ul>';
716
+ $analyzes['nofollow_links']['impact'] = 'low';
717
+ $analyzes['nofollow_links']['desc'] = $desc;
718
+ } else {
719
+ $analyzes['nofollow_links']['desc'] = '<p><span class="dashicons dashicons-yes"></span>'.__('This page doesn\'t have any nofollow links.','wp-seopress').'</p>';
720
+ }
721
+
722
+ //Outbound links
723
+ $desc = '<p>'.__('Internet is built on the principle of hyperlink. It is therefore perfectly normal to make links between different websites. However, avoid making links to low quality sites, SPAM... If you are not sure about the quality of a site, add the attribute "nofollow" to your link.').'</p>';
724
+ if (!empty($seopress_analysis_data['outbound_links'])) {
725
+ $count = count($seopress_analysis_data['outbound_links']);
726
+
727
+ /* translators: %d count outbound links */
728
+ $desc .= '<p>'.sprintf( __('We found %s outbound links in your page. Below, the list:', 'wp-seopress'), $count ).'</p>';
729
+ $desc .= '<ul>';
730
+ foreach ($seopress_analysis_data['outbound_links'] as $links) {
731
+ foreach ($links as $href => $link) {
732
+ $desc .= '<li><span class="dashicons dashicons-minus"></span><a href="'.$href.'" target="_blank">'.$link.'</a><span class="dashicons dashicons-external"></span></li>';
733
+ }
734
+ }
735
+ $desc .= '</ul>';
736
+ } else {
737
+ $analyzes['outbound_links']['impact'] = 'medium';
738
+ $desc .= '<p><span class="dashicons dashicons-no-alt"></span>'.__('This page doesn\'t have any outbound links.','wp-seopress').'</p>';
739
+ }
740
+ $analyzes['outbound_links']['desc'] = $desc;
inc/admin/admin-metaboxes-render-content-analysis.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined( 'ABSPATH' ) or die( 'Please don&rsquo;t call the plugin directly. Thanks :)' );
3
+
4
+ $html = '<div id="seopress-analysis-tabs">
5
+ <div id="seopress-analysis-tabs-1">';
6
+ $html .= '<div class="analysis-score">';
7
+ $impact = array_unique(array_values(wp_list_pluck($analyzes, 'impact')));
8
+ $svg = '<svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
9
+ <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
10
+ <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0" style="stroke-dashoffset: 101.788px;"></circle>
11
+ </svg>';
12
+ $tooltip = seopress_tooltip(__('Content analysis','wp-seopress'), __('<strong>Should be improved:</strong> red or orange dots <br> <strong>Good:</strong> yellow or green dots','wp-seopress'), '');
13
+
14
+ if (!empty($impact)) {
15
+ if (in_array('medium', $impact) || in_array('high', $impact)) {
16
+ $html .= '<p class="notgood">'.$svg.'<span>'.__('Should be improved','wp-seopress').$tooltip.'</span></p>';
17
+ $score = false;
18
+ } else {
19
+ $html .= '<p class="good">'.$svg.'<span>'.__('Good','wp-seopress').$tooltip.'</span></p>';
20
+ $score = true;
21
+ }
22
+ } else {
23
+ $score = false;
24
+ }
25
+
26
+ if (!empty($seopress_analysis_data)) {
27
+ $seopress_analysis_data['score'] = $score;
28
+ update_post_meta(get_the_ID(), '_seopress_analysis_data', $seopress_analysis_data);
29
+ }
30
+ $html .= '<span><a href="#" id="expand-all">'.__('Expand','wp-seopress').'</a> / <a href="#" id="close-all">'.__('Close','wp-seopress').'</a></span>
31
+ </div>';
32
+
33
+ if(!empty($analyzes)) {
34
+ $order = [
35
+ '1' => 'high',
36
+ '2' => 'medium',
37
+ '3' => 'low',
38
+ '4' => 'good'
39
+ ];
40
+
41
+ usort($analyzes, function ($a, $b) use ($order) {
42
+ $pos_a = array_search($a['impact'], $order);
43
+ $pos_b = array_search($b['impact'], $order);
44
+ return $pos_a - $pos_b;
45
+ });
46
+
47
+ foreach($analyzes as $key => $value) {
48
+ $html .= '<div class="gr-analysis">';
49
+ if (isset($value['title'])) {
50
+ $html .= '<div class="gr-analysis-title">
51
+ <h3>
52
+ <button type="button" aria-expanded="true" class="btn-toggle">';
53
+ if (isset($value['impact'])) {
54
+ $html .= '<span class="impact '.$value['impact'].'" aria-hidden="true"></span>';
55
+ }
56
+ $html .= '<span class="sp-arrow" aria-hidden="true"></span>
57
+ '.$value['title'].'
58
+ </button>
59
+ </h3>
60
+ </div>';
61
+ }
62
+ if (isset($value['desc'])) {
63
+ $html .= '<div class="gr-analysis-content">'. $value['desc'] .'</div>';
64
+ }
65
+ $html .= '</div>';
66
+ }
67
+ }
68
+ $html .= '</div>
69
+ </div>
70
+ </div>';
inc/functions/options-google-analytics-checkout.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined( 'ABSPATH' ) or die( 'Please don&rsquo;t call the plugin directly. Thanks :)' );
3
+
4
+ //Google Analytics E-commerce
5
+ //=================================================================================================
6
+ //Measuring an Addition from Cart
7
+ function seopress_google_analytics_js2($cart_item_key, $product_id, $quantity) {
8
+ if (seopress_google_analytics_ecommerce_enable_option() =='1') {
9
+
10
+ $seopress_google_analytics_html = "ga('require', 'ec');";
11
+ $seopress_google_analytics_html .= "\n";
12
+
13
+ //If WC enabled
14
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
15
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
16
+ $product = wc_get_product($product_id);
17
+
18
+ $product_cat = get_the_terms($product_id, 'product_cat');
19
+
20
+ $seopress_google_analytics_html = "
21
+ ga('ec:addProduct', {
22
+ 'id': ".$product_id.",
23
+ 'name': '".$product->get_name()."',";
24
+
25
+ if ($product_cat !='') {
26
+ $seopress_google_analytics_html .= "
27
+ 'category': '".$product_cat[0]->name."',";
28
+ }
29
+
30
+ if ($product->get_price() !='') {
31
+ $seopress_google_analytics_html .= "
32
+ 'price': '".$product->get_price()."',";
33
+ }
34
+
35
+ if ($quantity !='') {
36
+ $seopress_google_analytics_html .= "
37
+ 'quantity': ".$quantity;
38
+ }
39
+ $seopress_google_analytics_html .= "
40
+ });
41
+ ";
42
+ $seopress_google_analytics_html .= "\n";
43
+
44
+ $seopress_google_analytics_html .= "ga('ec:setAction', 'add');";
45
+ $seopress_google_analytics_html .= "\n";
46
+
47
+ $seopress_google_analytics_html .= "ga('send', 'event', 'UX', 'click', 'add to cart');";
48
+ $seopress_google_analytics_html .= "\n";
49
+
50
+ $seopress_google_analytics_html .= "\n";
51
+
52
+ if (seopress_google_analytics_enable_option() =='1' && seopress_google_analytics_ua_option() !='') {
53
+ if (is_user_logged_in()) {
54
+ global $wp_roles;
55
+
56
+ //Get current user role
57
+ if(isset(wp_get_current_user()->roles[0])) {
58
+ $seopress_user_role = wp_get_current_user()->roles[0];
59
+ //If current user role matchs values from SEOPress GA settings then apply
60
+ if (function_exists('seopress_google_analytics_roles_option') && seopress_google_analytics_roles_option() !='') {
61
+ if( array_key_exists( $seopress_user_role, seopress_google_analytics_roles_option())) {
62
+ //do nothing
63
+ } else {
64
+ if (function_exists('wc_enqueue_js')) {
65
+ wc_enqueue_js($seopress_google_analytics_html);
66
+ }
67
+ }
68
+ } else {
69
+ if (function_exists('wc_enqueue_js')) {
70
+ wc_enqueue_js($seopress_google_analytics_html);
71
+ }
72
+ }
73
+ }
74
+ } else {
75
+ if (function_exists('wc_enqueue_js')) {
76
+ wc_enqueue_js($seopress_google_analytics_html);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ add_action('woocommerce_add_to_cart', 'seopress_google_analytics_js2', 20, 3);
84
+
85
+
inc/functions/options-google-analytics-order.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined( 'ABSPATH' ) or die( 'Please don&rsquo;t call the plugin directly. Thanks :)' );
3
+
4
+ //Google Analytics E-commerce
5
+ //=================================================================================================
6
+ function seopress_google_analytics_order_received() {
7
+ $seopress_google_analytics_html ='';
8
+ global $woocommerce;
9
+ foreach( WC()->cart->get_cart() as $cart_item ){
10
+
11
+ $product = wc_get_product($cart_item['product_id']);
12
+ $product_cat = get_the_terms($cart_item['product_id'], 'product_cat');
13
+
14
+ $seopress_google_analytics_html .= "
15
+ ga('ec:addProduct', {
16
+ 'id': '".$cart_item['product_id']."',
17
+ 'name': '".$product->get_name()."',";
18
+
19
+ if ($product_cat !='') {
20
+ $seopress_google_analytics_html .= "
21
+ 'category': '".$product_cat[0]->name."',";
22
+ }
23
+
24
+ if ($product->get_price() !='') {
25
+ $seopress_google_analytics_html .= "
26
+ 'price': '".$product->get_price()."',";
27
+ }
28
+
29
+ if ($cart_item['quantity'] !='') {
30
+ $seopress_google_analytics_html .= "
31
+ 'quantity': ".$cart_item['quantity'];
32
+ }
33
+ $seopress_google_analytics_html .= "
34
+ });
35
+ ";
36
+ }
37
+
38
+ $seopress_google_analytics_html .= "\n";
39
+
40
+ $seopress_google_analytics_html .= "
41
+ ga('ec:setAction', 'purchase', {
42
+ 'id': 'daf9276a-3fa2-45a3-a591-495154662f7f',
43
+ 'revenue': ".$woocommerce->cart->get_cart_total().",
44
+ 'tax': 5,
45
+ 'shipping': 5
46
+ });
47
+ ";
48
+
49
+ $seopress_google_analytics_html .= "\n";
50
+
51
+ if (function_exists('wc_enqueue_js')) {
52
+ wc_enqueue_js($seopress_google_analytics_html);
53
+ }
54
+ }
55
+ add_action('woocommerce_checkout_order_processed', 'seopress_google_analytics_order_received');
inc/functions/options-google-analytics.php CHANGED
@@ -754,10 +754,17 @@ function seopress_google_analytics_js($echo) {
754
  //Init
755
  $seopress_google_analytics_config = [];
756
  $seopress_google_analytics_event = [];
 
 
 
 
 
 
 
757
 
758
  $seopress_google_analytics_html = "\n";
759
  $seopress_google_analytics_html .=
760
- "<script async src='https://www.googletagmanager.com/gtag/js?id=" . seopress_google_analytics_ua_option() . "'></script>
761
  <script>
762
  window.dataLayer = window.dataLayer || [];
763
  function gtag(){dataLayer.push(arguments);}";
754
  //Init
755
  $seopress_google_analytics_config = [];
756
  $seopress_google_analytics_event = [];
757
+
758
+ $g_id = '';
759
+ if ('' != seopress_google_analytics_ga4_option()) {
760
+ $g_id = seopress_google_analytics_ga4_option();
761
+ } elseif ('' != seopress_google_analytics_ua_option()) {
762
+ $g_id = seopress_google_analytics_ua_option();
763
+ }
764
 
765
  $seopress_google_analytics_html = "\n";
766
  $seopress_google_analytics_html .=
767
+ "<script async src='https://www.googletagmanager.com/gtag/js?id=" . $g_id . "'></script>
768
  <script>
769
  window.dataLayer = window.dataLayer || [];
770
  function gtag(){dataLayer.push(arguments);}";
languages/wp-seopress-pt_BR.mo ADDED
Binary file
languages/wp-seopress-pt_BR.po ADDED
@@ -0,0 +1,3493 @@