SEOPress - Version 4.4.0.5

Version Description

(19/02/2021) = * FIX "Use the target keywords if not alternative text set for the image" option

Download this release

Release Info

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

Code changes from version 4.4.0.4 to 4.4.0.5

inc/functions/options-advanced.php CHANGED
@@ -1,253 +1,291 @@
1
  <?php
2
- defined( 'ABSPATH' ) or die( 'Please don&rsquo;t call the plugin directly. Thanks :)' );
 
3
 
4
  //Advanced
5
  //=================================================================================================
6
  //?replytocom
7
  function seopress_advanced_advanced_replytocom_option() {
8
- $seopress_advanced_advanced_replytocom_option = get_option("seopress_advanced_option_name");
9
- if ( ! empty ( $seopress_advanced_advanced_replytocom_option ) ) {
10
- foreach ($seopress_advanced_advanced_replytocom_option as $key => $seopress_advanced_advanced_replytocom_value)
11
- $options[$key] = $seopress_advanced_advanced_replytocom_value;
12
- if (isset($seopress_advanced_advanced_replytocom_option['seopress_advanced_advanced_replytocom'])) {
13
- return $seopress_advanced_advanced_replytocom_option['seopress_advanced_advanced_replytocom'];
14
- }
15
- }
 
16
  }
17
 
18
- if (seopress_advanced_advanced_replytocom_option() =='1') {
19
- add_filter( 'comment_reply_link', 'seopress_remove_reply_to_com');
20
  }
21
- function seopress_remove_reply_to_com( $link ) {
22
- return preg_replace( '/href=\'(.*(\?|&)replytocom=(\d+)#respond)/', 'href=\'#comment-$3', $link );
23
  }
24
 
25
  //WordPress Meta generator
26
  function seopress_advanced_advanced_wp_generator_option() {
27
- $seopress_advanced_advanced_wp_generator_option = get_option("seopress_advanced_option_name");
28
- if ( ! empty ( $seopress_advanced_advanced_wp_generator_option ) ) {
29
- foreach ($seopress_advanced_advanced_wp_generator_option as $key => $seopress_advanced_advanced_wp_generator_value)
30
- $options[$key] = $seopress_advanced_advanced_wp_generator_value;
31
- if (isset($seopress_advanced_advanced_wp_generator_option['seopress_advanced_advanced_wp_generator'])) {
32
- return $seopress_advanced_advanced_wp_generator_option['seopress_advanced_advanced_wp_generator'];
33
- }
34
- }
 
35
  }
36
 
37
- if (seopress_advanced_advanced_wp_generator_option() =='1') {
38
- remove_action('wp_head', 'wp_generator');
39
  }
40
 
41
  //Remove hentry post class
42
  function seopress_advanced_advanced_hentry_option() {
43
- $seopress_advanced_advanced_hentry_option = get_option("seopress_advanced_option_name");
44
- if ( ! empty ( $seopress_advanced_advanced_hentry_option ) ) {
45
- foreach ($seopress_advanced_advanced_hentry_option as $key => $seopress_advanced_advanced_hentry_value)
46
- $options[$key] = $seopress_advanced_advanced_hentry_value;
47
- if (isset($seopress_advanced_advanced_hentry_option['seopress_advanced_advanced_hentry'])) {
48
- return $seopress_advanced_advanced_hentry_option['seopress_advanced_advanced_hentry'];
49
- }
50
- }
51
- }
52
- if (seopress_advanced_advanced_hentry_option() =='1') {
53
- function seopress_advanced_advanced_hentry_hook( $classes ) {
54
- $classes = array_diff( $classes, array( 'hentry' ) );
55
- return $classes;
56
- }
57
- add_filter( 'post_class', 'seopress_advanced_advanced_hentry_hook' );
 
 
58
  }
59
 
60
  //WordPress Shortlink
61
  function seopress_advanced_advanced_wp_shortlink_option() {
62
- $seopress_advanced_advanced_wp_shortlink_option = get_option("seopress_advanced_option_name");
63
- if ( ! empty ( $seopress_advanced_advanced_wp_shortlink_option ) ) {
64
- foreach ($seopress_advanced_advanced_wp_shortlink_option as $key => $seopress_advanced_advanced_wp_shortlink_value)
65
- $options[$key] = $seopress_advanced_advanced_wp_shortlink_value;
66
- if (isset($seopress_advanced_advanced_wp_shortlink_option['seopress_advanced_advanced_wp_shortlink'])) {
67
- return $seopress_advanced_advanced_wp_shortlink_option['seopress_advanced_advanced_wp_shortlink'];
68
- }
69
- }
 
70
  }
71
 
72
- if (seopress_advanced_advanced_wp_shortlink_option() =='1') {
73
- remove_action('wp_head', 'wp_shortlink_wp_head');
74
  }
75
 
76
  //WordPress WLWManifest
77
  function seopress_advanced_advanced_wp_wlw_option() {
78
- $seopress_advanced_advanced_wp_wlw_option = get_option("seopress_advanced_option_name");
79
- if ( ! empty ( $seopress_advanced_advanced_wp_wlw_option ) ) {
80
- foreach ($seopress_advanced_advanced_wp_wlw_option as $key => $seopress_advanced_advanced_wp_wlw_value)
81
- $options[$key] = $seopress_advanced_advanced_wp_wlw_value;
82
- if (isset($seopress_advanced_advanced_wp_wlw_option['seopress_advanced_advanced_wp_wlw'])) {
83
- return $seopress_advanced_advanced_wp_wlw_option['seopress_advanced_advanced_wp_wlw'];
84
- }
85
- }
 
86
  }
87
 
88
- if (seopress_advanced_advanced_wp_wlw_option() =='1') {
89
- remove_action('wp_head', 'wlwmanifest_link');
90
  }
91
 
92
  //WordPress RSD
93
  function seopress_advanced_advanced_wp_rsd_option() {
94
- $seopress_advanced_advanced_wp_rsd_option = get_option("seopress_advanced_option_name");
95
- if ( ! empty ( $seopress_advanced_advanced_wp_rsd_option ) ) {
96
- foreach ($seopress_advanced_advanced_wp_rsd_option as $key => $seopress_advanced_advanced_wp_rsd_value)
97
- $options[$key] = $seopress_advanced_advanced_wp_rsd_value;
98
- if (isset($seopress_advanced_advanced_wp_rsd_option['seopress_advanced_advanced_wp_rsd'])) {
99
- return $seopress_advanced_advanced_wp_rsd_option['seopress_advanced_advanced_wp_rsd'];
100
- }
101
- }
 
102
  }
103
 
104
- if (seopress_advanced_advanced_wp_rsd_option() =='1') {
105
- remove_action('wp_head', 'rsd_link');
106
  }
107
 
108
  //Google site verification
109
  function seopress_advanced_advanced_google_option() {
110
- $seopress_advanced_advanced_google_option = get_option("seopress_advanced_option_name");
111
- if ( ! empty ( $seopress_advanced_advanced_google_option ) ) {
112
- foreach ($seopress_advanced_advanced_google_option as $key => $seopress_advanced_advanced_google_value)
113
- $options[$key] = $seopress_advanced_advanced_google_value;
114
- if (isset($seopress_advanced_advanced_google_option['seopress_advanced_advanced_google'])) {
115
- return $seopress_advanced_advanced_google_option['seopress_advanced_advanced_google'];
116
- }
117
- }
 
118
  }
119
 
120
  function seopress_advanced_advanced_google_hook() {
121
- if (seopress_advanced_advanced_google_option() !='') {
122
- $seopress_advanced_advanced_google = '<meta name="google-site-verification" content="'.seopress_advanced_advanced_google_option().'" />';
123
- $seopress_advanced_advanced_google .= "\n";
124
- echo $seopress_advanced_advanced_google;
125
- }
126
  }
127
  if (is_home() || is_front_page()) {
128
- add_action( 'wp_head', 'seopress_advanced_advanced_google_hook', 2 );
129
  }
130
 
131
  //Bing site verification
132
  function seopress_advanced_advanced_bing_option() {
133
- $seopress_advanced_advanced_bing_option = get_option("seopress_advanced_option_name");
134
- if ( ! empty ( $seopress_advanced_advanced_bing_option ) ) {
135
- foreach ($seopress_advanced_advanced_bing_option as $key => $seopress_advanced_advanced_bing_value)
136
- $options[$key] = $seopress_advanced_advanced_bing_value;
137
- if (isset($seopress_advanced_advanced_bing_option['seopress_advanced_advanced_bing'])) {
138
- return $seopress_advanced_advanced_bing_option['seopress_advanced_advanced_bing'];
139
- }
140
- }
141
- };
 
142
 
143
  function seopress_advanced_advanced_bing_hook() {
144
- if (seopress_advanced_advanced_bing_option() !='') {
145
- $seopress_advanced_advanced_bing = '<meta name="msvalidate.01" content="'.seopress_advanced_advanced_bing_option().'" />';
146
- $seopress_advanced_advanced_bing .= "\n";
147
- echo $seopress_advanced_advanced_bing;
148
- }
149
  }
150
  if (is_home() || is_front_page()) {
151
- add_action( 'wp_head', 'seopress_advanced_advanced_bing_hook', 2 );
152
  }
153
 
154
  //Pinterest site verification
155
  function seopress_advanced_advanced_pinterest_option() {
156
- $seopress_advanced_advanced_pinterest_option = get_option("seopress_advanced_option_name");
157
- if ( ! empty ( $seopress_advanced_advanced_pinterest_option ) ) {
158
- foreach ($seopress_advanced_advanced_pinterest_option as $key => $seopress_advanced_advanced_pinterest_value)
159
- $options[$key] = $seopress_advanced_advanced_pinterest_value;
160
- if (isset($seopress_advanced_advanced_pinterest_option['seopress_advanced_advanced_pinterest'])) {
161
- return $seopress_advanced_advanced_pinterest_option['seopress_advanced_advanced_pinterest'];
162
- }
163
- }
164
- };
 
165
 
166
  function seopress_advanced_advanced_pinterest_hook() {
167
- if (seopress_advanced_advanced_pinterest_option() !='') {
168
- $seopress_advanced_advanced_pinterest = '<meta name="p:domain_verify" content="'.seopress_advanced_advanced_pinterest_option().'" />';
169
- $seopress_advanced_advanced_pinterest .= "\n";
170
- echo $seopress_advanced_advanced_pinterest;
171
- }
172
  }
173
 
174
  if (is_home() || is_front_page()) {
175
- add_action( 'wp_head', 'seopress_advanced_advanced_pinterest_hook', 2 );
176
  }
177
 
178
  //Yandex site verification
179
  function seopress_advanced_advanced_yandex_option() {
180
- $seopress_advanced_advanced_yandex_option = get_option("seopress_advanced_option_name");
181
- if ( ! empty ( $seopress_advanced_advanced_yandex_option ) ) {
182
- foreach ($seopress_advanced_advanced_yandex_option as $key => $seopress_advanced_advanced_yandex_value)
183
- $options[$key] = $seopress_advanced_advanced_yandex_value;
184
- if (isset($seopress_advanced_advanced_yandex_option['seopress_advanced_advanced_yandex'])) {
185
- return $seopress_advanced_advanced_yandex_option['seopress_advanced_advanced_yandex'];
186
- }
187
- }
188
- };
 
189
 
190
  function seopress_advanced_advanced_yandex_hook() {
191
- if (seopress_advanced_advanced_yandex_option() !='') {
192
- $seopress_advanced_advanced_yandex = '<meta name="yandex-verification" content="'.seopress_advanced_advanced_yandex_option().'" />';
193
- $seopress_advanced_advanced_yandex .= "\n";
194
- echo $seopress_advanced_advanced_yandex;
195
- }
196
  }
197
 
198
  if (is_home() || is_front_page()) {
199
- add_action( 'wp_head', 'seopress_advanced_advanced_yandex_hook', 2 );
200
  }
201
 
202
  //Automatic alt text based on target kw
203
  function seopress_advanced_advanced_image_auto_alt_target_kw_option() {
204
- $seopress_advanced_advanced_image_auto_alt_target_kw_option = get_option("seopress_advanced_option_name");
205
- if ( ! empty ( $seopress_advanced_advanced_image_auto_alt_target_kw_option ) ) {
206
- foreach ($seopress_advanced_advanced_image_auto_alt_target_kw_option as $key => $seopress_advanced_advanced_image_auto_alt_target_kw_value)
207
- $options[$key] = $seopress_advanced_advanced_image_auto_alt_target_kw_value;
208
- if (isset($seopress_advanced_advanced_image_auto_alt_target_kw_option['seopress_advanced_advanced_image_auto_alt_target_kw'])) {
209
- return $seopress_advanced_advanced_image_auto_alt_target_kw_option['seopress_advanced_advanced_image_auto_alt_target_kw'];
210
- }
211
- }
212
- }
213
-
214
- if (seopress_advanced_advanced_image_auto_alt_target_kw_option() !='') {
215
- function seopress_auto_img_alt_thumb_target_kw( $atts, $attachment ) {
216
- if (!is_admin()) {
217
- if (empty($atts['alt'])) {
218
- if (get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true) !='') {
219
- $atts['alt'] = esc_html(get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true));
220
- }
221
- }
222
- }
223
- return $atts;
224
- }
225
- add_filter( 'wp_get_attachment_image_attributes', 'seopress_auto_img_alt_thumb_target_kw', 10, 2 );
226
-
227
- function seopress_auto_img_alt_target_kw($content) {
228
- if ($content =='') {
229
- return $content;
230
- }
231
-
232
- $regex = '#<img[^>]* alt=(?:\"|\')(?<alt>([^"]*))(?:\"|\')[^>]*>#mU';
233
- preg_match_all($regex, $content, $matches);
234
-
235
- $matchesAlt = $matches['alt'];
236
-
237
- if (empty($matchesAlt)) {
238
- return $content;
239
- }
240
-
241
- foreach ($matchesAlt as $key => $alt) {
242
- if (!empty($alt)) {
243
- continue;
244
- }
245
- if (get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true) !='') {
246
- $alt = htmlspecialchars(esc_html(get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true)));
247
- }
248
- }
249
-
250
- return $content;
251
- }
252
- add_filter('the_content', 'seopress_auto_img_alt_target_kw', 20, 1);
253
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
+ defined('ABSPATH') or exit('Please don&rsquo;t call the plugin directly. Thanks :)');
4
 
5
  //Advanced
6
  //=================================================================================================
7
  //?replytocom
8
  function seopress_advanced_advanced_replytocom_option() {
9
+ $seopress_advanced_advanced_replytocom_option = get_option('seopress_advanced_option_name');
10
+ if ( ! empty($seopress_advanced_advanced_replytocom_option)) {
11
+ foreach ($seopress_advanced_advanced_replytocom_option as $key => $seopress_advanced_advanced_replytocom_value) {
12
+ $options[$key] = $seopress_advanced_advanced_replytocom_value;
13
+ }
14
+ if (isset($seopress_advanced_advanced_replytocom_option['seopress_advanced_advanced_replytocom'])) {
15
+ return $seopress_advanced_advanced_replytocom_option['seopress_advanced_advanced_replytocom'];
16
+ }
17
+ }
18
  }
19
 
20
+ if ('1' == seopress_advanced_advanced_replytocom_option()) {
21
+ add_filter('comment_reply_link', 'seopress_remove_reply_to_com');
22
  }
23
+ function seopress_remove_reply_to_com($link) {
24
+ return preg_replace('/href=\'(.*(\?|&)replytocom=(\d+)#respond)/', 'href=\'#comment-$3', $link);
25
  }
26
 
27
  //WordPress Meta generator
28
  function seopress_advanced_advanced_wp_generator_option() {
29
+ $seopress_advanced_advanced_wp_generator_option = get_option('seopress_advanced_option_name');
30
+ if ( ! empty($seopress_advanced_advanced_wp_generator_option)) {
31
+ foreach ($seopress_advanced_advanced_wp_generator_option as $key => $seopress_advanced_advanced_wp_generator_value) {
32
+ $options[$key] = $seopress_advanced_advanced_wp_generator_value;
33
+ }
34
+ if (isset($seopress_advanced_advanced_wp_generator_option['seopress_advanced_advanced_wp_generator'])) {
35
+ return $seopress_advanced_advanced_wp_generator_option['seopress_advanced_advanced_wp_generator'];
36
+ }
37
+ }
38
  }
39
 
40
+ if ('1' == seopress_advanced_advanced_wp_generator_option()) {
41
+ remove_action('wp_head', 'wp_generator');
42
  }
43
 
44
  //Remove hentry post class
45
  function seopress_advanced_advanced_hentry_option() {
46
+ $seopress_advanced_advanced_hentry_option = get_option('seopress_advanced_option_name');
47
+ if ( ! empty($seopress_advanced_advanced_hentry_option)) {
48
+ foreach ($seopress_advanced_advanced_hentry_option as $key => $seopress_advanced_advanced_hentry_value) {
49
+ $options[$key] = $seopress_advanced_advanced_hentry_value;
50
+ }
51
+ if (isset($seopress_advanced_advanced_hentry_option['seopress_advanced_advanced_hentry'])) {
52
+ return $seopress_advanced_advanced_hentry_option['seopress_advanced_advanced_hentry'];
53
+ }
54
+ }
55
+ }
56
+ if ('1' == seopress_advanced_advanced_hentry_option()) {
57
+ function seopress_advanced_advanced_hentry_hook($classes) {
58
+ $classes = array_diff($classes, ['hentry']);
59
+
60
+ return $classes;
61
+ }
62
+ add_filter('post_class', 'seopress_advanced_advanced_hentry_hook');
63
  }
64
 
65
  //WordPress Shortlink
66
  function seopress_advanced_advanced_wp_shortlink_option() {
67
+ $seopress_advanced_advanced_wp_shortlink_option = get_option('seopress_advanced_option_name');
68
+ if ( ! empty($seopress_advanced_advanced_wp_shortlink_option)) {
69
+ foreach ($seopress_advanced_advanced_wp_shortlink_option as $key => $seopress_advanced_advanced_wp_shortlink_value) {
70
+ $options[$key] = $seopress_advanced_advanced_wp_shortlink_value;
71
+ }
72
+ if (isset($seopress_advanced_advanced_wp_shortlink_option['seopress_advanced_advanced_wp_shortlink'])) {
73
+ return $seopress_advanced_advanced_wp_shortlink_option['seopress_advanced_advanced_wp_shortlink'];
74
+ }
75
+ }
76
  }
77
 
78
+ if ('1' == seopress_advanced_advanced_wp_shortlink_option()) {
79
+ remove_action('wp_head', 'wp_shortlink_wp_head');
80
  }
81
 
82
  //WordPress WLWManifest
83
  function seopress_advanced_advanced_wp_wlw_option() {
84
+ $seopress_advanced_advanced_wp_wlw_option = get_option('seopress_advanced_option_name');
85
+ if ( ! empty($seopress_advanced_advanced_wp_wlw_option)) {
86
+ foreach ($seopress_advanced_advanced_wp_wlw_option as $key => $seopress_advanced_advanced_wp_wlw_value) {
87
+ $options[$key] = $seopress_advanced_advanced_wp_wlw_value;
88
+ }
89
+ if (isset($seopress_advanced_advanced_wp_wlw_option['seopress_advanced_advanced_wp_wlw'])) {
90
+ return $seopress_advanced_advanced_wp_wlw_option['seopress_advanced_advanced_wp_wlw'];
91
+ }
92
+ }
93
  }
94
 
95
+ if ('1' == seopress_advanced_advanced_wp_wlw_option()) {
96
+ remove_action('wp_head', 'wlwmanifest_link');
97
  }
98
 
99
  //WordPress RSD
100
  function seopress_advanced_advanced_wp_rsd_option() {
101
+ $seopress_advanced_advanced_wp_rsd_option = get_option('seopress_advanced_option_name');
102
+ if ( ! empty($seopress_advanced_advanced_wp_rsd_option)) {
103
+ foreach ($seopress_advanced_advanced_wp_rsd_option as $key => $seopress_advanced_advanced_wp_rsd_value) {
104
+ $options[$key] = $seopress_advanced_advanced_wp_rsd_value;
105
+ }
106
+ if (isset($seopress_advanced_advanced_wp_rsd_option['seopress_advanced_advanced_wp_rsd'])) {
107
+ return $seopress_advanced_advanced_wp_rsd_option['seopress_advanced_advanced_wp_rsd'];
108
+ }
109
+ }
110
  }
111
 
112
+ if ('1' == seopress_advanced_advanced_wp_rsd_option()) {
113
+ remove_action('wp_head', 'rsd_link');
114
  }
115
 
116
  //Google site verification
117
  function seopress_advanced_advanced_google_option() {
118
+ $seopress_advanced_advanced_google_option = get_option('seopress_advanced_option_name');
119
+ if ( ! empty($seopress_advanced_advanced_google_option)) {
120
+ foreach ($seopress_advanced_advanced_google_option as $key => $seopress_advanced_advanced_google_value) {
121
+ $options[$key] = $seopress_advanced_advanced_google_value;
122
+ }
123
+ if (isset($seopress_advanced_advanced_google_option['seopress_advanced_advanced_google'])) {
124
+ return $seopress_advanced_advanced_google_option['seopress_advanced_advanced_google'];
125
+ }
126
+ }
127
  }
128
 
129
  function seopress_advanced_advanced_google_hook() {
130
+ if ('' != seopress_advanced_advanced_google_option()) {
131
+ $seopress_advanced_advanced_google = '<meta name="google-site-verification" content="' . seopress_advanced_advanced_google_option() . '" />';
132
+ $seopress_advanced_advanced_google .= "\n";
133
+ echo $seopress_advanced_advanced_google;
134
+ }
135
  }
136
  if (is_home() || is_front_page()) {
137
+ add_action('wp_head', 'seopress_advanced_advanced_google_hook', 2);
138
  }
139
 
140
  //Bing site verification
141
  function seopress_advanced_advanced_bing_option() {
142
+ $seopress_advanced_advanced_bing_option = get_option('seopress_advanced_option_name');
143
+ if ( ! empty($seopress_advanced_advanced_bing_option)) {
144
+ foreach ($seopress_advanced_advanced_bing_option as $key => $seopress_advanced_advanced_bing_value) {
145
+ $options[$key] = $seopress_advanced_advanced_bing_value;
146
+ }
147
+ if (isset($seopress_advanced_advanced_bing_option['seopress_advanced_advanced_bing'])) {
148
+ return $seopress_advanced_advanced_bing_option['seopress_advanced_advanced_bing'];
149
+ }
150
+ }
151
+ }
152
 
153
  function seopress_advanced_advanced_bing_hook() {
154
+ if ('' != seopress_advanced_advanced_bing_option()) {
155
+ $seopress_advanced_advanced_bing = '<meta name="msvalidate.01" content="' . seopress_advanced_advanced_bing_option() . '" />';
156
+ $seopress_advanced_advanced_bing .= "\n";
157
+ echo $seopress_advanced_advanced_bing;
158
+ }
159
  }
160
  if (is_home() || is_front_page()) {
161
+ add_action('wp_head', 'seopress_advanced_advanced_bing_hook', 2);
162
  }
163
 
164
  //Pinterest site verification
165
  function seopress_advanced_advanced_pinterest_option() {
166
+ $seopress_advanced_advanced_pinterest_option = get_option('seopress_advanced_option_name');
167
+ if ( ! empty($seopress_advanced_advanced_pinterest_option)) {
168
+ foreach ($seopress_advanced_advanced_pinterest_option as $key => $seopress_advanced_advanced_pinterest_value) {
169
+ $options[$key] = $seopress_advanced_advanced_pinterest_value;
170
+ }
171
+ if (isset($seopress_advanced_advanced_pinterest_option['seopress_advanced_advanced_pinterest'])) {
172
+ return $seopress_advanced_advanced_pinterest_option['seopress_advanced_advanced_pinterest'];
173
+ }
174
+ }
175
+ }
176
 
177
  function seopress_advanced_advanced_pinterest_hook() {
178
+ if ('' != seopress_advanced_advanced_pinterest_option()) {
179
+ $seopress_advanced_advanced_pinterest = '<meta name="p:domain_verify" content="' . seopress_advanced_advanced_pinterest_option() . '" />';
180
+ $seopress_advanced_advanced_pinterest .= "\n";
181
+ echo $seopress_advanced_advanced_pinterest;
182
+ }
183
  }
184
 
185
  if (is_home() || is_front_page()) {
186
+ add_action('wp_head', 'seopress_advanced_advanced_pinterest_hook', 2);
187
  }
188
 
189
  //Yandex site verification
190
  function seopress_advanced_advanced_yandex_option() {
191
+ $seopress_advanced_advanced_yandex_option = get_option('seopress_advanced_option_name');
192
+ if ( ! empty($seopress_advanced_advanced_yandex_option)) {
193
+ foreach ($seopress_advanced_advanced_yandex_option as $key => $seopress_advanced_advanced_yandex_value) {
194
+ $options[$key] = $seopress_advanced_advanced_yandex_value;
195
+ }
196
+ if (isset($seopress_advanced_advanced_yandex_option['seopress_advanced_advanced_yandex'])) {
197
+ return $seopress_advanced_advanced_yandex_option['seopress_advanced_advanced_yandex'];
198
+ }
199
+ }
200
+ }
201
 
202
  function seopress_advanced_advanced_yandex_hook() {
203
+ if ('' != seopress_advanced_advanced_yandex_option()) {
204
+ $seopress_advanced_advanced_yandex = '<meta name="yandex-verification" content="' . seopress_advanced_advanced_yandex_option() . '" />';
205
+ $seopress_advanced_advanced_yandex .= "\n";
206
+ echo $seopress_advanced_advanced_yandex;
207
+ }
208
  }
209
 
210
  if (is_home() || is_front_page()) {
211
+ add_action('wp_head', 'seopress_advanced_advanced_yandex_hook', 2);
212
  }
213
 
214
  //Automatic alt text based on target kw
215
  function seopress_advanced_advanced_image_auto_alt_target_kw_option() {
216
+ $seopress_advanced_advanced_image_auto_alt_target_kw_option = get_option('seopress_advanced_option_name');
217
+ if ( ! empty($seopress_advanced_advanced_image_auto_alt_target_kw_option)) {
218
+ foreach ($seopress_advanced_advanced_image_auto_alt_target_kw_option as $key => $seopress_advanced_advanced_image_auto_alt_target_kw_value) {
219
+ $options[$key] = $seopress_advanced_advanced_image_auto_alt_target_kw_value;
220
+ }
221
+ if (isset($seopress_advanced_advanced_image_auto_alt_target_kw_option['seopress_advanced_advanced_image_auto_alt_target_kw'])) {
222
+ return $seopress_advanced_advanced_image_auto_alt_target_kw_option['seopress_advanced_advanced_image_auto_alt_target_kw'];
223
+ }
224
+ }
225
+ }
226
+
227
+ if ('' != seopress_advanced_advanced_image_auto_alt_target_kw_option()) {
228
+ function seopress_auto_img_alt_thumb_target_kw($atts, $attachment) {
229
+ if ( ! is_admin()) {
230
+ if (empty($atts['alt'])) {
231
+ if ('' != get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true)) {
232
+ $atts['alt'] = esc_html(get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true));
233
+ }
234
+ }
235
+ }
236
+
237
+ return $atts;
238
+ }
239
+ add_filter('wp_get_attachment_image_attributes', 'seopress_auto_img_alt_thumb_target_kw', 10, 2);
240
+
241
+ /**
242
+ * Replace alt for content no use gutenberg.
243
+ *
244
+ * @since 4.4.0.5
245
+ *
246
+ * @param string $content
247
+ *
248
+ * @return void
249
+ */
250
+ function seopress_auto_img_alt_target_kw($content) {
251
+ if (empty($content)) {
252
+ return $content;
253
+ }
254
+
255
+ $target_keyword = get_post_meta(get_the_ID(), '_seopress_analysis_target_kw', true);
256
+
257
+ if (empty($target_keyword)) {
258
+ return $content;
259
+ }
260
+
261
+ $regex = '#<img[^>]* alt=(?:\"|\')(?<alt>([^"]*))(?:\"|\')[^>]*>#mU';
262
+
263
+ preg_match_all($regex, $content, $matches);
264
+
265
+ $matchesTag = $matches[0];
266
+ $matchesAlt = $matches['alt'];
267
+
268
+ if (empty($matchesAlt)) {
269
+ return $content;
270
+ }
271
+
272
+ $regexSrc = '#<img[^>]* src=(?:\"|\')(?<src>([^"]*))(?:\"|\')[^>]*>#mU';
273
+
274
+ foreach ($matchesAlt as $key => $alt) {
275
+ if ( ! empty($alt)) {
276
+ continue;
277
+ }
278
+ $contentMatch = $matchesTag[$key];
279
+ preg_match($regexSrc, $contentMatch, $matchSrc);
280
+
281
+ $contentToReplace = str_replace('alt=""', 'alt="' . htmlspecialchars(esc_html($target_keyword)) . '"', $contentMatch);
282
+
283
+ if ($contentMatch !== $contentToReplace) {
284
+ $content = str_replace($contentMatch, $contentToReplace, $content);
285
+ }
286
+ }
287
+
288
+ return $content;
289
+ }
290
+ add_filter('the_content', 'seopress_auto_img_alt_target_kw', 20);
291
+ }
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: SEO, XML sitemap, meta title, open graph, content analysis, knowledge grap
6
  Requires at least: 4.7+
7
  Tested up to: 5.6
8
  Requires PHP: 5.6
9
- Stable tag: 4.4.0.4
10
  License: GPLv2 or later
11
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -320,6 +320,8 @@ You're theme is probably using a deprecated function to handle the title. <a hre
320
  9. Schemas metabox
321
 
322
  == Changelog ==
 
 
323
  = 4.4.0.4 (18/02/2021) =
324
  * INFO Add "View my RSS feed" button to SEO, PRO, RSS tab
325
  * INFO Improve performance for video xml sitemap
6
  Requires at least: 4.7+
7
  Tested up to: 5.6
8
  Requires PHP: 5.6
9
+ Stable tag: 4.4.0.5
10
  License: GPLv2 or later
11
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
 
320
  9. Schemas metabox
321
 
322
  == Changelog ==
323
+ = 4.4.0.5 (19/02/2021) =
324
+ * FIX "Use the target keywords if not alternative text set for the image" option
325
  = 4.4.0.4 (18/02/2021) =
326
  * INFO Add "View my RSS feed" button to SEO, PRO, RSS tab
327
  * INFO Improve performance for video xml sitemap
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.4.0.4
8
  Author URI: https://www.seopress.org/
9
  License: GPLv2
10
  Text Domain: wp-seopress
@@ -55,7 +55,7 @@ register_deactivation_hook(__FILE__, 'seopress_deactivation');
55
  ///////////////////////////////////////////////////////////////////////////////////////////////////
56
  //Define
57
  ///////////////////////////////////////////////////////////////////////////////////////////////////
58
- define('SEOPRESS_VERSION', '4.4.0.4');
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');
4
  Plugin URI: https://www.seopress.org/
5
  Description: One of the best SEO plugins for WordPress.
6
  Author: SEOPress
7
+ Version: 4.4.0.5
8
  Author URI: https://www.seopress.org/
9
  License: GPLv2
10
  Text Domain: wp-seopress
55
  ///////////////////////////////////////////////////////////////////////////////////////////////////
56
  //Define
57
  ///////////////////////////////////////////////////////////////////////////////////////////////////
58
+ define('SEOPRESS_VERSION', '4.4.0.5');
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');
vendor/composer/InstalledVersions.php CHANGED
@@ -29,7 +29,7 @@ private static $installed = array (
29
  'aliases' =>
30
  array (
31
  ),
32
- 'reference' => '923da49ddad43494367e847503093a9e645167f0',
33
  'name' => 'wp-seopress/wp-seopress',
34
  ),
35
  'versions' =>
@@ -41,7 +41,7 @@ private static $installed = array (
41
  'aliases' =>
42
  array (
43
  ),
44
- 'reference' => '923da49ddad43494367e847503093a9e645167f0',
45
  ),
46
  ),
47
  );
29
  'aliases' =>
30
  array (
31
  ),
32
+ 'reference' => 'c7c565f74fc78701b8b8b5bea63c77f2c5179fa1',
33
  'name' => 'wp-seopress/wp-seopress',
34
  ),
35
  'versions' =>
41
  'aliases' =>
42
  array (
43
  ),
44
+ 'reference' => 'c7c565f74fc78701b8b8b5bea63c77f2c5179fa1',
45
  ),
46
  ),
47
  );
vendor/composer/installed.php CHANGED
@@ -6,7 +6,7 @@
6
  'aliases' =>
7
  array (
8
  ),
9
- 'reference' => '923da49ddad43494367e847503093a9e645167f0',
10
  'name' => 'wp-seopress/wp-seopress',
11
  ),
12
  'versions' =>
@@ -18,7 +18,7 @@
18
  'aliases' =>
19
  array (
20
  ),
21
- 'reference' => '923da49ddad43494367e847503093a9e645167f0',
22
  ),
23
  ),
24
  );
6
  'aliases' =>
7
  array (
8
  ),
9
+ 'reference' => 'c7c565f74fc78701b8b8b5bea63c77f2c5179fa1',
10
  'name' => 'wp-seopress/wp-seopress',
11
  ),
12
  'versions' =>
18
  'aliases' =>
19
  array (
20
  ),
21
+ 'reference' => 'c7c565f74fc78701b8b8b5bea63c77f2c5179fa1',
22
  ),
23
  ),
24
  );