PB SEO Friendly Images - Version 2.1.0

Version Description

  • Improved support for old PHP versions
  • Code optimization and improvements
  • Better WooCommerce support

=

Download this release

Release Info

Developer PascalBajorat
Plugin Icon 128x128 PB SEO Friendly Images
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.1 to 2.1.0

img/primusnote.png ADDED
Binary file
inc/pbSettingsFramework.php CHANGED
@@ -8,7 +8,7 @@ if ( !class_exists('WP') ) {
8
  if( ! class_exists('pbSettingsFramework') ):
9
  class pbSettingsFramework
10
  {
11
- const version = '1.1.0';
12
  static $textDomain = false;
13
  static $page = false;
14
  static $section = false;
@@ -22,11 +22,11 @@ if( ! class_exists('pbSettingsFramework') ):
22
  */
23
  public function __construct($args=array())
24
  {
25
- self::$textDomain = $args['text-domain'] || 'pbSettingsFramework';
26
- self::$page = $args['page'];
27
- self::$section = $args['section'];
28
- self::$optionGroup = $args['option-group'];
29
- self::$args = $args;
30
  }
31
 
32
  /**
@@ -36,11 +36,11 @@ if( ! class_exists('pbSettingsFramework') ):
36
  */
37
  public static function registerSetting($setting)
38
  {
39
- if( ! isset(self::$args['option-group']) ) {
40
  die(__FUNCTION__.': $args[\'option-group\'] not set!');
41
  }
42
 
43
- return register_setting(self::$args['option-group'], $setting);
44
  }
45
 
46
  /**
@@ -56,7 +56,7 @@ if( ! class_exists('pbSettingsFramework') ):
56
  $id,
57
  $title,
58
  $callback,
59
- self::$args['page']
60
  );
61
  }
62
 
@@ -72,19 +72,19 @@ if( ! class_exists('pbSettingsFramework') ):
72
  public static function addSettingsField($id, $title, $args, $callback=array(__CLASS__, 'fieldsHTML'), $register_setting=true)
73
  {
74
  if( $register_setting )
75
- register_setting( self::$args['option-group'], $id, 'esc_attr' );
76
 
77
 
78
  add_settings_field(
79
  $id,
80
  '<label for="'.$id.'">'.$title.'</label>',
81
  $callback,
82
- self::$page,
83
- self::$section,
84
  array_merge_recursive(
85
  array(
86
  'id' => $id,
87
- 'section' => self::$section
88
  ),
89
 
90
  $args
@@ -118,16 +118,16 @@ if( ! class_exists('pbSettingsFramework') ):
118
  $option = get_option($args['id']);
119
  $html = '';
120
 
121
- if( self::getArrayKey('type', $args) == 'text' ) {
122
 
123
  if ( empty( $option ) ) {
124
- $val = self::getArrayKey('default', $args);
125
  } else {
126
  $val = $option;
127
  }
128
- $html = '<input type="text" id="' . $args['id'] . '" name="' . $args['id'] . '" class="regular-text" value="' . $val . '" '.((self::getArrayKey('disabled', $args))?'disabled="disabled"':'').' />';
129
 
130
- $desc = self::getArrayKey('desc', $args);
131
 
132
  if ( ! empty( $desc ) ) {
133
  $html .= '<p class="description">' . $desc . '</p>';
@@ -136,29 +136,29 @@ if( ! class_exists('pbSettingsFramework') ):
136
  } elseif( $args['type'] == 'checkbox' ) {
137
 
138
  if( $option === false ){
139
- $val = self::getArrayKey('default', $args);
140
  }else{
141
  $val = $option;
142
  }
143
- $html = '<input type="checkbox" id="'.$args['id'].'" name="'.$args['id'].'" value="1" '.((self::getArrayKey('disabled', $args))?'disabled="disabled"':'').' '.checked(1, $val, false).'/>';
144
 
145
- $html .= '<label for="'.$args['id'].'"> '. self::getArrayKey('desc', $args) .'</label>';
146
 
147
  } elseif( $args['type'] == 'select' ) {
148
 
149
  if ( empty( $option ) ) {
150
- $val = self::getArrayKey('default', $args);
151
  } else {
152
  $val = $option;
153
  }
154
 
155
  $html = '<select id="'.$args['id'].'" name="'.$args['id'].'">';
156
  foreach ($args['select'] as $name => $value ) {
157
- $html .= '<option value="'.$name.'" '.(($val==$name)?'selected="selected"':'').' '.((self::getArrayKey('disabled', $args))?'disabled="disabled"':'').'>'.esc_html($value).'</option>';
158
  }
159
  $html .= '</select>';
160
 
161
- $desc = self::getArrayKey('desc', $args);
162
 
163
  if ( ! empty( $desc ) ) {
164
  $html .= '<p class="description">' . $desc . '</p>';
8
  if( ! class_exists('pbSettingsFramework') ):
9
  class pbSettingsFramework
10
  {
11
+ const version = '1.2.0';
12
  static $textDomain = false;
13
  static $page = false;
14
  static $section = false;
22
  */
23
  public function __construct($args=array())
24
  {
25
+ pbSettingsFramework::$textDomain = $args['text-domain'] || 'pbSettingsFramework';
26
+ pbSettingsFramework::$page = $args['page'];
27
+ pbSettingsFramework::$section = $args['section'];
28
+ pbSettingsFramework::$optionGroup = $args['option-group'];
29
+ pbSettingsFramework::$args = $args;
30
  }
31
 
32
  /**
36
  */
37
  public static function registerSetting($setting)
38
  {
39
+ if( ! isset(pbSettingsFramework::$args['option-group']) ) {
40
  die(__FUNCTION__.': $args[\'option-group\'] not set!');
41
  }
42
 
43
+ return register_setting(pbSettingsFramework::$args['option-group'], $setting);
44
  }
45
 
46
  /**
56
  $id,
57
  $title,
58
  $callback,
59
+ pbSettingsFramework::$args['page']
60
  );
61
  }
62
 
72
  public static function addSettingsField($id, $title, $args, $callback=array(__CLASS__, 'fieldsHTML'), $register_setting=true)
73
  {
74
  if( $register_setting )
75
+ register_setting( pbSettingsFramework::$args['option-group'], $id, 'esc_attr' );
76
 
77
 
78
  add_settings_field(
79
  $id,
80
  '<label for="'.$id.'">'.$title.'</label>',
81
  $callback,
82
+ pbSettingsFramework::$page,
83
+ pbSettingsFramework::$section,
84
  array_merge_recursive(
85
  array(
86
  'id' => $id,
87
+ 'section' => pbSettingsFramework::$section
88
  ),
89
 
90
  $args
118
  $option = get_option($args['id']);
119
  $html = '';
120
 
121
+ if( pbSettingsFramework::getArrayKey('type', $args) == 'text' ) {
122
 
123
  if ( empty( $option ) ) {
124
+ $val = pbSettingsFramework::getArrayKey('default', $args);
125
  } else {
126
  $val = $option;
127
  }
128
+ $html = '<input type="text" id="' . $args['id'] . '" name="' . $args['id'] . '" class="regular-text" value="' . $val . '" '.((pbSettingsFramework::getArrayKey('disabled', $args))?'disabled="disabled"':'').' />';
129
 
130
+ $desc = pbSettingsFramework::getArrayKey('desc', $args);
131
 
132
  if ( ! empty( $desc ) ) {
133
  $html .= '<p class="description">' . $desc . '</p>';
136
  } elseif( $args['type'] == 'checkbox' ) {
137
 
138
  if( $option === false ){
139
+ $val = pbSettingsFramework::getArrayKey('default', $args);
140
  }else{
141
  $val = $option;
142
  }
143
+ $html = '<input type="checkbox" id="'.$args['id'].'" name="'.$args['id'].'" value="1" '.((pbSettingsFramework::getArrayKey('disabled', $args))?'disabled="disabled"':'').' '.checked(1, $val, false).'/>';
144
 
145
+ $html .= '<label for="'.$args['id'].'"> '. pbSettingsFramework::getArrayKey('desc', $args) .'</label>';
146
 
147
  } elseif( $args['type'] == 'select' ) {
148
 
149
  if ( empty( $option ) ) {
150
+ $val = pbSettingsFramework::getArrayKey('default', $args);
151
  } else {
152
  $val = $option;
153
  }
154
 
155
  $html = '<select id="'.$args['id'].'" name="'.$args['id'].'">';
156
  foreach ($args['select'] as $name => $value ) {
157
+ $html .= '<option value="'.$name.'" '.(($val==$name)?'selected="selected"':'').' '.((pbSettingsFramework::getArrayKey('disabled', $args))?'disabled="disabled"':'').'>'.esc_html($value).'</option>';
158
  }
159
  $html .= '</select>';
160
 
161
+ $desc = pbSettingsFramework::getArrayKey('desc', $args);
162
 
163
  if ( ! empty( $desc ) ) {
164
  $html .= '<p class="description">' . $desc . '</p>';
inc/settings.php CHANGED
@@ -15,11 +15,11 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
15
  add_action('admin_menu', array(__CLASS__, 'optionsPageMenu'));
16
  add_action('admin_init', array(__CLASS__, 'initSettings'));
17
 
18
- add_filter('plugin_action_links_'.parent::$basename, array(__CLASS__, 'settingsLink'));
19
 
20
  $showUpgradeBanner = get_option('pbsfi_upgrade_notice');
21
 
22
- if( $showUpgradeBanner != self::$verMajor && self::getArrayKey('page', $_GET) != 'pb-seo-friendly-images' ) {
23
  add_action( 'admin_notices', array(__CLASS__, 'adminUpgradeNotice') );
24
  }
25
  }
@@ -72,13 +72,13 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
72
  )
73
  );
74
 
75
- if( ! self::$proVersion ) {
76
  $data = array_merge(
77
  $data,
78
  array(
79
  sprintf(
80
  '<a href="%s" style="color: #e00; font-weight: bold;" target="_blank">%s</a>',
81
- self::$proURL,
82
  __('Get Pro Version', 'pb-seo-friendly-images')
83
  )
84
  )
@@ -90,7 +90,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
90
 
91
  public static function initSettings()
92
  {
93
- self::$settings = new pbSettingsFramework(array(
94
  'text-domain' => 'pb-seo-friendly-images',
95
  'page' => 'pb-seo-friendly-images',
96
  'section' => 'pb-seo-friendly-images',
@@ -100,7 +100,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
100
  // register a new setting for "wporg" page
101
  register_setting('pb-seo-friendly-images', 'pbsfi_options');
102
 
103
- self::$settings->addSettingsSection(
104
  'pb-seo-friendly-images',
105
  __('Image "alt" and "title" Settings', 'pb-seo-friendly-images'),
106
  function(){
@@ -116,18 +116,18 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
116
 
117
  echo '</div> <!-- .pb-section-wrap -->';
118
 
119
- if( ! self::$proVersion ) {
120
  echo '<div class="pb-custom-message info"><p>';
121
  echo sprintf(
122
  __('Please consider upgrading to <a href="%s" target="_blank">PB SEO Friendly Images Pro</a> if you want to use more features and support the development of this plugin.', 'pb-seo-friendly-images'),
123
- self::$proURL
124
  );
125
- echo '</p><a href="'.self::$proURL2.'" class="pb-btn" target="_blank">'.__('Upgrade now', 'pb-seo-friendly-images').'</a></div>';
126
  }
127
  }
128
  );
129
 
130
- self::$settings->addSettingsField(
131
  'pbsfi_optimize_img',
132
  __('optimize images', 'pb-seo-friendly-images'),
133
  array(
@@ -142,7 +142,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
142
  )
143
  );
144
 
145
- self::$settings->addSettingsField(
146
  'pbsfi_sync_method',
147
  __('sync method', 'pb-seo-friendly-images'),
148
  array(
@@ -160,7 +160,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
160
  )
161
  );
162
 
163
- self::$settings->addSettingsField(
164
  'pbsfi_override_alt',
165
  __('override "alt"', 'pb-seo-friendly-images'),
166
  array(
@@ -170,7 +170,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
170
  )
171
  );
172
 
173
- self::$settings->addSettingsField(
174
  'pbsfi_override_title',
175
  __('override "title"', 'pb-seo-friendly-images'),
176
  array(
@@ -191,7 +191,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
191
  '<code>%media_caption</code> - '.__('replaces attachment caption (could be empty if not set)', 'pb-seo-friendly-images').'<br />'.
192
  '<code>%media_description</code> - '.__('replaces attachment description (could be empty if not set)', 'pb-seo-friendly-images');
193
 
194
- self::$settings->addSettingsField(
195
  'pbsfi_alt_scheme',
196
  __('alt scheme', 'pb-seo-friendly-images'),
197
  array(
@@ -201,7 +201,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
201
  )
202
  );
203
 
204
- self::$settings->addSettingsField(
205
  'pbsfi_title_scheme',
206
  __('title scheme', 'pb-seo-friendly-images'),
207
  array(
@@ -214,14 +214,14 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
214
  /**
215
  * Section Pro
216
  */
217
- self::$settings = new pbSettingsFramework(array(
218
  'text-domain' => 'pb-seo-friendly-images',
219
  'page' => 'pb-seo-friendly-images',
220
  'section' => 'pb-seo-friendly-images-pro',
221
  'option-group' => 'pb-seo-friendly-images'
222
  ));
223
 
224
- self::$settings->addSettingsSection(
225
  'pb-seo-friendly-images-pro',
226
  '',
227
  function(){
@@ -235,72 +235,72 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
235
  echo '<p>'.__('If enabled the lazy load will be added automatically to images in your post or page content and also to post thumbnails.', 'pb-seo-friendly-images').'</p>';
236
  echo '</div>';
237
 
238
- if( ! self::$proVersion ) {
239
  echo '<div class="pb-custom-message info"><p>';
240
  echo sprintf(
241
  __('Please consider upgrading to <a href="%s" target="_blank">PB SEO Friendly Images Pro</a> if you want to use this feature.', 'pb-seo-friendly-images'),
242
- self::$proURL
243
  );
244
- echo '</p><a href="'.self::$proURL2.'" class="pb-btn" target="_blank">'.__('Upgrade now', 'pb-seo-friendly-images').'</a></div>';
245
  }
246
  }
247
  );
248
 
249
- self::$settings->addSettingsField(
250
  'pbsfi_enable_lazyload',
251
  __('enable lazy load', 'pb-seo-friendly-images'),
252
  array(
253
  'type' => 'checkbox',
254
  'default' => true,
255
  'desc' => __('enable lazy load and boost up your site speed', 'pb-seo-friendly-images'),
256
- 'disabled' => ((self::$proVersion)?false:true)
257
  )
258
  );
259
 
260
- self::$settings->addSettingsField(
261
  'pbsfi_enable_lazyload_acf',
262
  __('enable lazy load for acf', 'pb-seo-friendly-images'),
263
  array(
264
  'type' => 'checkbox',
265
  'default' => true,
266
  'desc' => __('enable lazy load for AdvancedCustomFields', 'pb-seo-friendly-images'),
267
- 'disabled' => ((self::$proVersion)?false:true)
268
  )
269
  );
270
 
271
- self::$settings->addSettingsField(
272
  'pbsfi_enable_lazyload_styles',
273
  __('lazy load default styles', 'pb-seo-friendly-images'),
274
  array(
275
  'type' => 'checkbox',
276
  'default' => false,
277
  'desc' => __('enable lazy load default styles', 'pb-seo-friendly-images'),
278
- 'disabled' => ((self::$proVersion)?false:true)
279
  )
280
  );
281
 
282
- self::$settings->addSettingsField(
283
  'pbsfi_lazyload_threshold',
284
  __('threshold', 'pb-seo-friendly-images'),
285
  array(
286
  'type' => 'text',
287
  'default' => '0',
288
  'desc' => __('By default, images are only loaded when the user scrolls to them and they became visible on the screen (default value for this field <code>0</code>). If you want your images to load earlier than that, lets say 200px then you need to type in <code>200</code>.', 'pb-seo-friendly-images'),
289
- 'disabled' => ((self::$proVersion)?false:true)
290
  )
291
  );
292
 
293
  /**
294
  * Section Pro 2
295
  */
296
- self::$settings = new pbSettingsFramework(array(
297
  'text-domain' => 'pb-seo-friendly-images',
298
  'page' => 'pb-seo-friendly-images',
299
  'section' => 'pb-seo-friendly-images-pro2',
300
  'option-group' => 'pb-seo-friendly-images'
301
  ));
302
 
303
- self::$settings->addSettingsSection(
304
  'pb-seo-friendly-images-pro2',
305
  '',
306
  function(){
@@ -317,25 +317,36 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
317
  }
318
  );
319
 
320
- self::$settings->addSettingsField(
 
 
 
 
 
 
 
 
 
 
 
321
  'pbsfi_link_title',
322
  __('set title for links', 'pb-seo-friendly-images'),
323
  array(
324
  'type' => 'checkbox',
325
  'default' => false,
326
  'desc' => __('Use the power of PB SEO Friendly Images also for seo friendly links. This will set the title depending on the link text and only if there is no existing title', 'pb-seo-friendly-images'),
327
- 'disabled' => ((self::$proVersion)?false:true)
328
  )
329
  );
330
 
331
- self::$settings->addSettingsField(
332
  'pbsfi_disable_srcset',
333
  __('disable srcset', 'pb-seo-friendly-images'),
334
  array(
335
  'type' => 'checkbox',
336
  'default' => false,
337
  'desc' => __('disable srcset attribute and responsive images in WordPress if you don\'t need them', 'pb-seo-friendly-images'),
338
- 'disabled' => ((self::$proVersion)?false:true)
339
  )
340
  );
341
  }
@@ -358,7 +369,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
358
  return;
359
  }
360
 
361
- update_option( 'pbsfi_upgrade_notice', self::$verMajor, false );
362
  ?>
363
  <div class="wrap pb-wp-app-wrapper">
364
  <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
@@ -378,7 +389,7 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
378
  <div class="pb-plugin-box">
379
  <h4>
380
  <span class="icon">
381
- <img src="<?php echo plugins_url( 'img/mailcrypt.png', constant('pbsfi_file') ); ?>" >
382
  </span>
383
  <span class="text"><?php _e('MailCrypt - AntiSpam Email Encryption', 'pb-seo-friendly-images') ?></span>
384
  </h4>
@@ -388,11 +399,24 @@ if( !class_exists('pbSEOFriendlyImagesSettings') ):
388
  </div>
389
  </div>
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  <div class="pb-support-box">
392
  <h4><?php _e('Support', 'pb-seo-friendly-images') ?></h4>
393
  <p><?php _e('Do you need some help with this plugin? I am here to help you. Get in touch:', 'pb-seo-friendly-images') ?></p>
394
 
395
- <?php if( ! self::$proVersion ): ?>
396
  <p><a href="https://wordpress.org/support/plugin/pb-seo-friendly-images" class="button" target="_blank"><?php _e('Support Forum', 'pb-seo-friendly-images') ?></a></p>
397
  <?php else: ?>
398
  <p><a href="https://codecanyon.net/item/seo-friendly-images-pro-for-wordpress/19296704/support?ref=Pascal-Bajorat" class="button" target="_blank"><?php _e('Contact Support', 'pb-seo-friendly-images') ?></a></p>
15
  add_action('admin_menu', array(__CLASS__, 'optionsPageMenu'));
16
  add_action('admin_init', array(__CLASS__, 'initSettings'));
17
 
18
+ add_filter('plugin_action_links_'.pbSEOFriendlyImages::$basename, array(__CLASS__, 'settingsLink'));
19
 
20
  $showUpgradeBanner = get_option('pbsfi_upgrade_notice');
21
 
22
+ if( $showUpgradeBanner != pbSEOFriendlyImages::$verMajor && pbSEOFriendlyImages::getArrayKey('page', $_GET) != 'pb-seo-friendly-images' ) {
23
  add_action( 'admin_notices', array(__CLASS__, 'adminUpgradeNotice') );
24
  }
25
  }
72
  )
73
  );
74
 
75
+ if( ! pbSEOFriendlyImages::$proVersion ) {
76
  $data = array_merge(
77
  $data,
78
  array(
79
  sprintf(
80
  '<a href="%s" style="color: #e00; font-weight: bold;" target="_blank">%s</a>',
81
+ pbSEOFriendlyImages::$proURL,
82
  __('Get Pro Version', 'pb-seo-friendly-images')
83
  )
84
  )
90
 
91
  public static function initSettings()
92
  {
93
+ pbSEOFriendlyImagesSettings::$settings = new pbSettingsFramework(array(
94
  'text-domain' => 'pb-seo-friendly-images',
95
  'page' => 'pb-seo-friendly-images',
96
  'section' => 'pb-seo-friendly-images',
100
  // register a new setting for "wporg" page
101
  register_setting('pb-seo-friendly-images', 'pbsfi_options');
102
 
103
+ pbSEOFriendlyImagesSettings::$settings->addSettingsSection(
104
  'pb-seo-friendly-images',
105
  __('Image "alt" and "title" Settings', 'pb-seo-friendly-images'),
106
  function(){
116
 
117
  echo '</div> <!-- .pb-section-wrap -->';
118
 
119
+ if( ! pbSEOFriendlyImages::$proVersion ) {
120
  echo '<div class="pb-custom-message info"><p>';
121
  echo sprintf(
122
  __('Please consider upgrading to <a href="%s" target="_blank">PB SEO Friendly Images Pro</a> if you want to use more features and support the development of this plugin.', 'pb-seo-friendly-images'),
123
+ pbSEOFriendlyImages::$proURL
124
  );
125
+ echo '</p><a href="'.pbSEOFriendlyImages::$proURL2.'" class="pb-btn" target="_blank">'.__('Upgrade now', 'pb-seo-friendly-images').'</a></div>';
126
  }
127
  }
128
  );
129
 
130
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
131
  'pbsfi_optimize_img',
132
  __('optimize images', 'pb-seo-friendly-images'),
133
  array(
142
  )
143
  );
144
 
145
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
146
  'pbsfi_sync_method',
147
  __('sync method', 'pb-seo-friendly-images'),
148
  array(
160
  )
161
  );
162
 
163
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
164
  'pbsfi_override_alt',
165
  __('override "alt"', 'pb-seo-friendly-images'),
166
  array(
170
  )
171
  );
172
 
173
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
174
  'pbsfi_override_title',
175
  __('override "title"', 'pb-seo-friendly-images'),
176
  array(
191
  '<code>%media_caption</code> - '.__('replaces attachment caption (could be empty if not set)', 'pb-seo-friendly-images').'<br />'.
192
  '<code>%media_description</code> - '.__('replaces attachment description (could be empty if not set)', 'pb-seo-friendly-images');
193
 
194
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
195
  'pbsfi_alt_scheme',
196
  __('alt scheme', 'pb-seo-friendly-images'),
197
  array(
201
  )
202
  );
203
 
204
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
205
  'pbsfi_title_scheme',
206
  __('title scheme', 'pb-seo-friendly-images'),
207
  array(
214
  /**
215
  * Section Pro
216
  */
217
+ pbSEOFriendlyImagesSettings::$settings = new pbSettingsFramework(array(
218
  'text-domain' => 'pb-seo-friendly-images',
219
  'page' => 'pb-seo-friendly-images',
220
  'section' => 'pb-seo-friendly-images-pro',
221
  'option-group' => 'pb-seo-friendly-images'
222
  ));
223
 
224
+ pbSEOFriendlyImagesSettings::$settings->addSettingsSection(
225
  'pb-seo-friendly-images-pro',
226
  '',
227
  function(){
235
  echo '<p>'.__('If enabled the lazy load will be added automatically to images in your post or page content and also to post thumbnails.', 'pb-seo-friendly-images').'</p>';
236
  echo '</div>';
237
 
238
+ if( ! pbSEOFriendlyImages::$proVersion ) {
239
  echo '<div class="pb-custom-message info"><p>';
240
  echo sprintf(
241
  __('Please consider upgrading to <a href="%s" target="_blank">PB SEO Friendly Images Pro</a> if you want to use this feature.', 'pb-seo-friendly-images'),
242
+ pbSEOFriendlyImages::$proURL
243
  );
244
+ echo '</p><a href="'.pbSEOFriendlyImages::$proURL2.'" class="pb-btn" target="_blank">'.__('Upgrade now', 'pb-seo-friendly-images').'</a></div>';
245
  }
246
  }
247
  );
248
 
249
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
250
  'pbsfi_enable_lazyload',
251
  __('enable lazy load', 'pb-seo-friendly-images'),
252
  array(
253
  'type' => 'checkbox',
254
  'default' => true,
255
  'desc' => __('enable lazy load and boost up your site speed', 'pb-seo-friendly-images'),
256
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
257
  )
258
  );
259
 
260
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
261
  'pbsfi_enable_lazyload_acf',
262
  __('enable lazy load for acf', 'pb-seo-friendly-images'),
263
  array(
264
  'type' => 'checkbox',
265
  'default' => true,
266
  'desc' => __('enable lazy load for AdvancedCustomFields', 'pb-seo-friendly-images'),
267
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
268
  )
269
  );
270
 
271
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
272
  'pbsfi_enable_lazyload_styles',
273
  __('lazy load default styles', 'pb-seo-friendly-images'),
274
  array(
275
  'type' => 'checkbox',
276
  'default' => false,
277
  'desc' => __('enable lazy load default styles', 'pb-seo-friendly-images'),
278
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
279
  )
280
  );
281
 
282
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
283
  'pbsfi_lazyload_threshold',
284
  __('threshold', 'pb-seo-friendly-images'),
285
  array(
286
  'type' => 'text',
287
  'default' => '0',
288
  'desc' => __('By default, images are only loaded when the user scrolls to them and they became visible on the screen (default value for this field <code>0</code>). If you want your images to load earlier than that, lets say 200px then you need to type in <code>200</code>.', 'pb-seo-friendly-images'),
289
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
290
  )
291
  );
292
 
293
  /**
294
  * Section Pro 2
295
  */
296
+ pbSEOFriendlyImagesSettings::$settings = new pbSettingsFramework(array(
297
  'text-domain' => 'pb-seo-friendly-images',
298
  'page' => 'pb-seo-friendly-images',
299
  'section' => 'pb-seo-friendly-images-pro2',
300
  'option-group' => 'pb-seo-friendly-images'
301
  ));
302
 
303
+ pbSEOFriendlyImagesSettings::$settings->addSettingsSection(
304
  'pb-seo-friendly-images-pro2',
305
  '',
306
  function(){
317
  }
318
  );
319
 
320
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
321
+ 'pbsfi_wc_title',
322
+ __('WooCommerce', 'pb-seo-friendly-images'),
323
+ array(
324
+ 'type' => 'checkbox',
325
+ 'default' => false,
326
+ 'desc' => __('Use the product name as alt and title for WooCommerce product images', 'pb-seo-friendly-images'),
327
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
328
+ )
329
+ );
330
+
331
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
332
  'pbsfi_link_title',
333
  __('set title for links', 'pb-seo-friendly-images'),
334
  array(
335
  'type' => 'checkbox',
336
  'default' => false,
337
  'desc' => __('Use the power of PB SEO Friendly Images also for seo friendly links. This will set the title depending on the link text and only if there is no existing title', 'pb-seo-friendly-images'),
338
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
339
  )
340
  );
341
 
342
+ pbSEOFriendlyImagesSettings::$settings->addSettingsField(
343
  'pbsfi_disable_srcset',
344
  __('disable srcset', 'pb-seo-friendly-images'),
345
  array(
346
  'type' => 'checkbox',
347
  'default' => false,
348
  'desc' => __('disable srcset attribute and responsive images in WordPress if you don\'t need them', 'pb-seo-friendly-images'),
349
+ 'disabled' => ((pbSEOFriendlyImages::$proVersion)?false:true)
350
  )
351
  );
352
  }
369
  return;
370
  }
371
 
372
+ update_option( 'pbsfi_upgrade_notice', pbSEOFriendlyImages::$verMajor, false );
373
  ?>
374
  <div class="wrap pb-wp-app-wrapper">
375
  <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
389
  <div class="pb-plugin-box">
390
  <h4>
391
  <span class="icon">
392
+ <img src="<?php echo plugins_url( 'img/mailcrypt.png', constant('pbsfi_file') ); ?>" alt="<?php _e('MailCrypt - AntiSpam Email Encryption', 'pb-seo-friendly-images') ?>" />
393
  </span>
394
  <span class="text"><?php _e('MailCrypt - AntiSpam Email Encryption', 'pb-seo-friendly-images') ?></span>
395
  </h4>
399
  </div>
400
  </div>
401
 
402
+ <div class="pb-plugin-box">
403
+ <h4>
404
+ <span class="icon">
405
+ <img src="<?php echo plugins_url( 'img/primusnote.png', constant('pbsfi_file') ); ?>" alt="<?php _e('PrimusNote', 'pb-seo-friendly-images') ?>" />
406
+ </span>
407
+ <span class="text"><?php _e('PrimusNote', 'pb-seo-friendly-images') ?><br /><?php _e('Project Management', 'pb-seo-friendly-images') ?></span>
408
+ </h4>
409
+ <div class="desc">
410
+ <p><?php _e('PrimusNote is a Project Management and Team Collaboration software based on WordPress.', 'pb-seo-friendly-images') ?></p>
411
+ <p><a href="https://goo.gl/D9P49K" target="_blank" class="button"><?php _e('Install Plugin', 'pb-seo-friendly-images') ?></a></p>
412
+ </div>
413
+ </div>
414
+
415
  <div class="pb-support-box">
416
  <h4><?php _e('Support', 'pb-seo-friendly-images') ?></h4>
417
  <p><?php _e('Do you need some help with this plugin? I am here to help you. Get in touch:', 'pb-seo-friendly-images') ?></p>
418
 
419
+ <?php if( ! pbSEOFriendlyImages::$proVersion ): ?>
420
  <p><a href="https://wordpress.org/support/plugin/pb-seo-friendly-images" class="button" target="_blank"><?php _e('Support Forum', 'pb-seo-friendly-images') ?></a></p>
421
  <?php else: ?>
422
  <p><a href="https://codecanyon.net/item/seo-friendly-images-pro-for-wordpress/19296704/support?ref=Pascal-Bajorat" class="button" target="_blank"><?php _e('Contact Support', 'pb-seo-friendly-images') ?></a></p>
lang/pb-seo-friendly-images-de_DE.mo CHANGED
Binary file
lang/pb-seo-friendly-images-de_DE.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: PB SEO Friendly Images\n"
4
- "POT-Creation-Date: 2017-03-13 22:46+0100\n"
5
- "PO-Revision-Date: 2017-03-13 22:46+0100\n"
6
  "Last-Translator: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
7
  "Language-Team: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
8
  "Language: de\n"
@@ -356,10 +356,19 @@ msgid "Additional features"
356
  msgstr "Zusatzfunktionen"
357
 
358
  #: inc/settings.php:322
 
 
 
 
 
 
 
 
 
359
  msgid "set title for links"
360
  msgstr "Title für Links setzen"
361
 
362
- #: inc/settings.php:326
363
  msgid ""
364
  "Use the power of PB SEO Friendly Images also for seo friendly links. This "
365
  "will set the title depending on the link text and only if there is no "
@@ -369,11 +378,11 @@ msgstr ""
369
  "Links. Das Tool wird nicht vergebene Linktitel automatisch auf Basis der "
370
  "Linktexte oder enthaltener Bilder setzen"
371
 
372
- #: inc/settings.php:333
373
  msgid "disable srcset"
374
  msgstr "srcset ausschalten"
375
 
376
- #: inc/settings.php:337
377
  msgid ""
378
  "disable srcset attribute and responsive images in WordPress if you don't "
379
  "need them"
@@ -382,23 +391,23 @@ msgstr ""
382
  "diese nicht benötigst"
383
 
384
  #. Plugin Name of the plugin/theme
385
- #: inc/settings.php:347
386
  msgid "PB SEO Friendly Images"
387
  msgstr "PB SEO Friendly Images"
388
 
389
- #: inc/settings.php:348
390
  msgid "SEO Friendly Images"
391
  msgstr "SEO Friendly Images"
392
 
393
- #: inc/settings.php:377
394
  msgid "Plugins & Support"
395
  msgstr "Plugins & Support"
396
 
397
- #: inc/settings.php:383
398
  msgid "MailCrypt - AntiSpam Email Encryption"
399
  msgstr "MailCrypt - E-Mail Verschlüsselung"
400
 
401
- #: inc/settings.php:386
402
  msgid ""
403
  "This Plugin provides a Shortcode to encrypt email addresses / links and "
404
  "protect them against spam."
@@ -406,26 +415,42 @@ msgstr ""
406
  "Dieses Plugin stellt einen Shortcode und Funktionen für die E-Mail "
407
  "Verschlüsselung zur Verfügung und schützt gegen Spam."
408
 
409
- #: inc/settings.php:387
410
  msgid "Install Plugin"
411
  msgstr "Plugin installieren"
412
 
413
- #: inc/settings.php:392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  msgid "Support"
415
  msgstr "Support"
416
 
417
- #: inc/settings.php:393
418
  msgid ""
419
  "Do you need some help with this plugin? I am here to help you. Get in touch:"
420
  msgstr ""
421
  "Benötigst du Unterstützung mit diesem Plugin? Ich bin am zu helfen, schreib "
422
  "mir einfach:"
423
 
424
- #: inc/settings.php:396
425
  msgid "Support Forum"
426
  msgstr "Support Forum"
427
 
428
- #: inc/settings.php:398
429
  msgid "Contact Support"
430
  msgstr "Support kontaktieren"
431
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: PB SEO Friendly Images\n"
4
+ "POT-Creation-Date: 2017-04-21 17:01+0200\n"
5
+ "PO-Revision-Date: 2017-04-21 17:03+0200\n"
6
  "Last-Translator: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
7
  "Language-Team: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
8
  "Language: de\n"
356
  msgstr "Zusatzfunktionen"
357
 
358
  #: inc/settings.php:322
359
+ msgid "WooCommerce"
360
+ msgstr "WooCommerce"
361
+
362
+ #: inc/settings.php:326
363
+ msgid "Use the product name as alt and title for WooCommerce product images"
364
+ msgstr ""
365
+ "Verwende den Produktnamen als alt und title für WooCommerce Produktbilder."
366
+
367
+ #: inc/settings.php:333
368
  msgid "set title for links"
369
  msgstr "Title für Links setzen"
370
 
371
+ #: inc/settings.php:337
372
  msgid ""
373
  "Use the power of PB SEO Friendly Images also for seo friendly links. This "
374
  "will set the title depending on the link text and only if there is no "
378
  "Links. Das Tool wird nicht vergebene Linktitel automatisch auf Basis der "
379
  "Linktexte oder enthaltener Bilder setzen"
380
 
381
+ #: inc/settings.php:344
382
  msgid "disable srcset"
383
  msgstr "srcset ausschalten"
384
 
385
+ #: inc/settings.php:348
386
  msgid ""
387
  "disable srcset attribute and responsive images in WordPress if you don't "
388
  "need them"
391
  "diese nicht benötigst"
392
 
393
  #. Plugin Name of the plugin/theme
394
+ #: inc/settings.php:358
395
  msgid "PB SEO Friendly Images"
396
  msgstr "PB SEO Friendly Images"
397
 
398
+ #: inc/settings.php:359
399
  msgid "SEO Friendly Images"
400
  msgstr "SEO Friendly Images"
401
 
402
+ #: inc/settings.php:388
403
  msgid "Plugins & Support"
404
  msgstr "Plugins & Support"
405
 
406
+ #: inc/settings.php:392 inc/settings.php:394
407
  msgid "MailCrypt - AntiSpam Email Encryption"
408
  msgstr "MailCrypt - E-Mail Verschlüsselung"
409
 
410
+ #: inc/settings.php:397
411
  msgid ""
412
  "This Plugin provides a Shortcode to encrypt email addresses / links and "
413
  "protect them against spam."
415
  "Dieses Plugin stellt einen Shortcode und Funktionen für die E-Mail "
416
  "Verschlüsselung zur Verfügung und schützt gegen Spam."
417
 
418
+ #: inc/settings.php:398 inc/settings.php:411
419
  msgid "Install Plugin"
420
  msgstr "Plugin installieren"
421
 
422
+ #: inc/settings.php:405 inc/settings.php:407
423
+ msgid "PrimusNote"
424
+ msgstr "PrimusNote"
425
+
426
+ #: inc/settings.php:407
427
+ msgid "Project Management"
428
+ msgstr "Projekt-Management"
429
+
430
+ #: inc/settings.php:410
431
+ msgid ""
432
+ "PrimusNote is a Project Management and Team Collaboration software based on "
433
+ "WordPress."
434
+ msgstr ""
435
+ "PrimusNote ist eine Projekt-Management und Team-Kollaborations-Software auf "
436
+ "WordPress Basis."
437
+
438
+ #: inc/settings.php:416
439
  msgid "Support"
440
  msgstr "Support"
441
 
442
+ #: inc/settings.php:417
443
  msgid ""
444
  "Do you need some help with this plugin? I am here to help you. Get in touch:"
445
  msgstr ""
446
  "Benötigst du Unterstützung mit diesem Plugin? Ich bin am zu helfen, schreib "
447
  "mir einfach:"
448
 
449
+ #: inc/settings.php:420
450
  msgid "Support Forum"
451
  msgstr "Support Forum"
452
 
453
+ #: inc/settings.php:422
454
  msgid "Contact Support"
455
  msgstr "Support kontaktieren"
456
 
lang/pb-seo-friendly-images.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: PB SEO Friendly Images Pro\n"
6
- "POT-Creation-Date: 2017-03-13 22:47+0100\n"
7
  "PO-Revision-Date: 2016-12-23 22:36+0100\n"
8
  "Last-Translator: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
9
  "Language-Team: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
@@ -302,66 +302,88 @@ msgid "Additional features"
302
  msgstr ""
303
 
304
  #: inc/settings.php:322
305
- msgid "set title for links"
306
  msgstr ""
307
 
308
  #: inc/settings.php:326
 
 
 
 
 
 
 
 
309
  msgid ""
310
  "Use the power of PB SEO Friendly Images also for seo friendly links. This will "
311
  "set the title depending on the link text and only if there is no existing title"
312
  msgstr ""
313
 
314
- #: inc/settings.php:333
315
  msgid "disable srcset"
316
  msgstr ""
317
 
318
- #: inc/settings.php:337
319
  msgid ""
320
  "disable srcset attribute and responsive images in WordPress if you don't need "
321
  "them"
322
  msgstr ""
323
 
324
  #. Plugin Name of the plugin/theme
325
- #: inc/settings.php:347
326
  msgid "PB SEO Friendly Images"
327
  msgstr ""
328
 
329
- #: inc/settings.php:348
330
  msgid "SEO Friendly Images"
331
  msgstr ""
332
 
333
- #: inc/settings.php:377
334
  msgid "Plugins & Support"
335
  msgstr ""
336
 
337
- #: inc/settings.php:383
338
  msgid "MailCrypt - AntiSpam Email Encryption"
339
  msgstr ""
340
 
341
- #: inc/settings.php:386
342
  msgid ""
343
  "This Plugin provides a Shortcode to encrypt email addresses / links and protect "
344
  "them against spam."
345
  msgstr ""
346
 
347
- #: inc/settings.php:387
348
  msgid "Install Plugin"
349
  msgstr ""
350
 
351
- #: inc/settings.php:392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  msgid "Support"
353
  msgstr ""
354
 
355
- #: inc/settings.php:393
356
  msgid ""
357
  "Do you need some help with this plugin? I am here to help you. Get in touch:"
358
  msgstr ""
359
 
360
- #: inc/settings.php:396
361
  msgid "Support Forum"
362
  msgstr ""
363
 
364
- #: inc/settings.php:398
365
  msgid "Contact Support"
366
  msgstr ""
367
 
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: PB SEO Friendly Images Pro\n"
6
+ "POT-Creation-Date: 2017-04-21 17:01+0200\n"
7
  "PO-Revision-Date: 2016-12-23 22:36+0100\n"
8
  "Last-Translator: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
9
  "Language-Team: Pascal Bajorat <pascal@pascal-bajorat.com>\n"
302
  msgstr ""
303
 
304
  #: inc/settings.php:322
305
+ msgid "WooCommerce"
306
  msgstr ""
307
 
308
  #: inc/settings.php:326
309
+ msgid "Use the product name as alt and title for WooCommerce product images"
310
+ msgstr ""
311
+
312
+ #: inc/settings.php:333
313
+ msgid "set title for links"
314
+ msgstr ""
315
+
316
+ #: inc/settings.php:337
317
  msgid ""
318
  "Use the power of PB SEO Friendly Images also for seo friendly links. This will "
319
  "set the title depending on the link text and only if there is no existing title"
320
  msgstr ""
321
 
322
+ #: inc/settings.php:344
323
  msgid "disable srcset"
324
  msgstr ""
325
 
326
+ #: inc/settings.php:348
327
  msgid ""
328
  "disable srcset attribute and responsive images in WordPress if you don't need "
329
  "them"
330
  msgstr ""
331
 
332
  #. Plugin Name of the plugin/theme
333
+ #: inc/settings.php:358
334
  msgid "PB SEO Friendly Images"
335
  msgstr ""
336
 
337
+ #: inc/settings.php:359
338
  msgid "SEO Friendly Images"
339
  msgstr ""
340
 
341
+ #: inc/settings.php:388
342
  msgid "Plugins & Support"
343
  msgstr ""
344
 
345
+ #: inc/settings.php:392 inc/settings.php:394
346
  msgid "MailCrypt - AntiSpam Email Encryption"
347
  msgstr ""
348
 
349
+ #: inc/settings.php:397
350
  msgid ""
351
  "This Plugin provides a Shortcode to encrypt email addresses / links and protect "
352
  "them against spam."
353
  msgstr ""
354
 
355
+ #: inc/settings.php:398 inc/settings.php:411
356
  msgid "Install Plugin"
357
  msgstr ""
358
 
359
+ #: inc/settings.php:405 inc/settings.php:407
360
+ msgid "PrimusNote"
361
+ msgstr ""
362
+
363
+ #: inc/settings.php:407
364
+ msgid "Project Management"
365
+ msgstr ""
366
+
367
+ #: inc/settings.php:410
368
+ msgid ""
369
+ "PrimusNote is a Project Management and Team Collaboration software based on "
370
+ "WordPress."
371
+ msgstr ""
372
+
373
+ #: inc/settings.php:416
374
  msgid "Support"
375
  msgstr ""
376
 
377
+ #: inc/settings.php:417
378
  msgid ""
379
  "Do you need some help with this plugin? I am here to help you. Get in touch:"
380
  msgstr ""
381
 
382
+ #: inc/settings.php:420
383
  msgid "Support Forum"
384
  msgstr ""
385
 
386
+ #: inc/settings.php:422
387
  msgid "Contact Support"
388
  msgstr ""
389
 
pb-seo-friendly-images.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: PB SEO Friendly Images
4
  Plugin URI: https://wordpress.org/extend/plugins/pb-seo-friendly-images/
5
  Description: This plugin is a full-featured solution for SEO friendly images. Optimize "alt" and "title" attributes for all images and post thumbnails. This plugin helps you to improve your traffic from search engines.
6
- Version: 2.0.1
7
  Author: Pascal Bajorat
8
  Author URI: https://www.pascal-bajorat.com
9
  Text Domain: pb-seo-friendly-images
@@ -38,10 +38,8 @@ if( !class_exists('pbSEOFriendlyImages') ):
38
 
39
  class pbSEOFriendlyImages
40
  {
41
- public static $pluginData = false;
42
- public static $verMajor = '2.0';
43
- public static $verMinor = '1';
44
-
45
 
46
  public static $basename = false;
47
  public static $userSettings = array();
@@ -55,23 +53,23 @@ if( !class_exists('pbSEOFriendlyImages') ):
55
  */
56
  public static function init()
57
  {
58
- self::$basename = plugin_basename(__FILE__);
59
 
60
  // Pro Version file check
61
  if( file_exists(pbsfi_plugin_pro_path) ) {
62
- self::$proVersion = true;
63
  }
64
 
65
  /*
66
  * Language file
67
  */
68
- load_plugin_textdomain('pb-seo-friendly-images', false, dirname(self::$basename).DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR);
69
 
70
  /*
71
  * Get settings and defaults
72
  */
73
  if( ! is_admin() ) {
74
- self::$userSettings = array(
75
  'optimize_img' => get_option('pbsfi_optimize_img', 'all'),
76
  'sync_method' => get_option('pbsfi_sync_method', 'both'),
77
  'override_alt' => get_option('pbsfi_override_alt', false),
@@ -82,17 +80,18 @@ if( !class_exists('pbSEOFriendlyImages') ):
82
  'enable_lazyload_acf' => get_option('pbsfi_enable_lazyload_acf', true),
83
  'enable_lazyload_styles' => get_option('pbsfi_enable_lazyload_styles', false),
84
  'lazyload_threshold' => get_option('pbsfi_lazyload_threshold', false),
 
85
  'disable_srcset' => get_option('pbsfi_disable_srcset', false),
86
  'link_title' => get_option('pbsfi_link_title', false)
87
  );
88
 
89
  // process post thumbnails
90
- if( self::$userSettings['optimize_img'] == 'all' || self::$userSettings['optimize_img'] == 'thumbs' ) {
91
  add_filter( 'wp_get_attachment_image_attributes', array(__CLASS__, 'addImgTitlePostThumbnail'), 10, 2 );
92
  }
93
 
94
  // process post images
95
- if( self::$userSettings['optimize_img'] == 'all' || self::$userSettings['optimize_img'] == 'post' ) {
96
  add_filter( 'the_content', array(__CLASS__, 'prepareContentImages'), 999, 1 );
97
 
98
  /*
@@ -104,6 +103,11 @@ if( !class_exists('pbSEOFriendlyImages') ):
104
  //add_filter('acf_load_value-text', array(__CLASS__, 'encrypt_mails_in_content'), 20);
105
  add_filter('acf_load_value-textarea', array(__CLASS__, 'prepareContentImages'), 20);
106
  add_filter('acf_load_value-wysiwyg', array(__CLASS__, 'prepareContentImages'), 20);
 
 
 
 
 
107
  }
108
  } else {
109
  add_action( 'admin_enqueue_scripts', function(){
@@ -111,7 +115,7 @@ if( !class_exists('pbSEOFriendlyImages') ):
111
  'pbsfi-admin-css',
112
  plugins_url(dirname(pbSEOFriendlyImages::$basename)).'/css/admin.css',
113
  false,
114
- self::$verMajor.'.'.self::$verMinor
115
  );
116
  wp_enqueue_style( 'pbsfi-admin-css' );
117
  } );
@@ -249,14 +253,14 @@ if( !class_exists('pbSEOFriendlyImages') ):
249
  $src = $data_src;
250
  }
251
 
252
- $imageID = self::getImageID($src);
253
 
254
  /**
255
  * Override Area
256
  */
257
- if( self::$userSettings['override_alt'] ) {
258
- $alt = trim(self::convertReplacements(
259
- self::$userSettings['alt_scheme'],
260
  $src,
261
  $imageID
262
  ));
@@ -266,10 +270,10 @@ if( !class_exists('pbSEOFriendlyImages') ):
266
  $alt = trim($tag->getAttribute('alt'));
267
  }
268
 
269
- if( self::$userSettings['override_title'] ) {
270
 
271
- $title = trim(self::convertReplacements(
272
- self::$userSettings['title_scheme'],
273
  $src,
274
  $imageID
275
  ));
@@ -282,12 +286,12 @@ if( !class_exists('pbSEOFriendlyImages') ):
282
  /**
283
  * Check attributes
284
  */
285
- if( !empty($alt) && empty($title) && (self::$userSettings['sync_method'] == 'both' || self::$userSettings['sync_method'] == 'alt' ) ) {
286
 
287
  $tag->setAttribute('title', $alt);
288
  $title = $alt;
289
 
290
- } else if( empty($alt) && !empty($title) && (self::$userSettings['sync_method'] == 'both' || self::$userSettings['sync_method'] == 'title' ) ) {
291
 
292
  $tag->setAttribute('alt', $title);
293
  $alt = $title;
@@ -298,8 +302,8 @@ if( !class_exists('pbSEOFriendlyImages') ):
298
  * set if empty after sync
299
  */
300
  if( empty($alt) ) {
301
- $alt = trim(self::convertReplacements(
302
- self::$userSettings['alt_scheme'],
303
  $src,
304
  $imageID
305
  ));
@@ -308,8 +312,8 @@ if( !class_exists('pbSEOFriendlyImages') ):
308
  }
309
 
310
  if( empty($title) ) {
311
- $title = trim(self::convertReplacements(
312
- self::$userSettings['title_scheme'],
313
  $src,
314
  $imageID
315
  ));
@@ -321,6 +325,33 @@ if( !class_exists('pbSEOFriendlyImages') ):
321
  return preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $document->saveHTML()));
322
  }
323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  /**
325
  * Add image title and alt to post thumbnails
326
  *
@@ -332,23 +363,23 @@ if( !class_exists('pbSEOFriendlyImages') ):
332
  {
333
  if( empty($attr['alt']) ) {
334
 
335
- $attr['title'] = trim(self::convertReplacements(
336
- self::$userSettings['title_scheme'],
337
  $attr['src']
338
  ));
339
 
340
- $attr['alt'] = trim(self::convertReplacements(
341
- self::$userSettings['alt_scheme'],
342
  $attr['src']
343
  ));
344
 
345
  } else {
346
 
347
- if( self::$userSettings['sync_method'] == 'both' || self::$userSettings['sync_method'] == 'alt' ) {
348
  $attr['title'] = trim( strip_tags($attachment->post_title) );
349
  } else {
350
- $attr['title'] = trim(self::convertReplacements(
351
- self::$userSettings['title_scheme'],
352
  $attr['src']
353
  ));
354
  }
@@ -376,7 +407,7 @@ if( !class_exists('pbSEOFriendlyImages') ):
376
  $attachment = $wpdb->get_col($sql);
377
 
378
 
379
- if( is_numeric( self::getArrayKey(0, $attachment) ) ) {
380
  return (int) $attachment[0];
381
  }
382
 
3
  Plugin Name: PB SEO Friendly Images
4
  Plugin URI: https://wordpress.org/extend/plugins/pb-seo-friendly-images/
5
  Description: This plugin is a full-featured solution for SEO friendly images. Optimize "alt" and "title" attributes for all images and post thumbnails. This plugin helps you to improve your traffic from search engines.
6
+ Version: 2.1.0
7
  Author: Pascal Bajorat
8
  Author URI: https://www.pascal-bajorat.com
9
  Text Domain: pb-seo-friendly-images
38
 
39
  class pbSEOFriendlyImages
40
  {
41
+ public static $verMajor = '2.1';
42
+ public static $verMinor = '0';
 
 
43
 
44
  public static $basename = false;
45
  public static $userSettings = array();
53
  */
54
  public static function init()
55
  {
56
+ pbSEOFriendlyImages::$basename = plugin_basename(__FILE__);
57
 
58
  // Pro Version file check
59
  if( file_exists(pbsfi_plugin_pro_path) ) {
60
+ pbSEOFriendlyImages::$proVersion = true;
61
  }
62
 
63
  /*
64
  * Language file
65
  */
66
+ load_plugin_textdomain('pb-seo-friendly-images', false, dirname(pbSEOFriendlyImages::$basename).DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR);
67
 
68
  /*
69
  * Get settings and defaults
70
  */
71
  if( ! is_admin() ) {
72
+ pbSEOFriendlyImages::$userSettings = array(
73
  'optimize_img' => get_option('pbsfi_optimize_img', 'all'),
74
  'sync_method' => get_option('pbsfi_sync_method', 'both'),
75
  'override_alt' => get_option('pbsfi_override_alt', false),
80
  'enable_lazyload_acf' => get_option('pbsfi_enable_lazyload_acf', true),
81
  'enable_lazyload_styles' => get_option('pbsfi_enable_lazyload_styles', false),
82
  'lazyload_threshold' => get_option('pbsfi_lazyload_threshold', false),
83
+ 'wc_title' => get_option('pbsfi_wc_title', false),
84
  'disable_srcset' => get_option('pbsfi_disable_srcset', false),
85
  'link_title' => get_option('pbsfi_link_title', false)
86
  );
87
 
88
  // process post thumbnails
89
+ if( pbSEOFriendlyImages::$userSettings['optimize_img'] == 'all' || pbSEOFriendlyImages::$userSettings['optimize_img'] == 'thumbs' ) {
90
  add_filter( 'wp_get_attachment_image_attributes', array(__CLASS__, 'addImgTitlePostThumbnail'), 10, 2 );
91
  }
92
 
93
  // process post images
94
+ if( pbSEOFriendlyImages::$userSettings['optimize_img'] == 'all' || pbSEOFriendlyImages::$userSettings['optimize_img'] == 'post' ) {
95
  add_filter( 'the_content', array(__CLASS__, 'prepareContentImages'), 999, 1 );
96
 
97
  /*
103
  //add_filter('acf_load_value-text', array(__CLASS__, 'encrypt_mails_in_content'), 20);
104
  add_filter('acf_load_value-textarea', array(__CLASS__, 'prepareContentImages'), 20);
105
  add_filter('acf_load_value-wysiwyg', array(__CLASS__, 'prepareContentImages'), 20);
106
+
107
+ // Woocommerce
108
+ if( pbSEOFriendlyImages::$userSettings['wc_title'] && pbSEOFriendlyImages::$proVersion ) {
109
+ add_filter('wp_get_attachment_image_attributes', array(__CLASS__, 'prepareContentImagesAttributes'), 20, 2);
110
+ }
111
  }
112
  } else {
113
  add_action( 'admin_enqueue_scripts', function(){
115
  'pbsfi-admin-css',
116
  plugins_url(dirname(pbSEOFriendlyImages::$basename)).'/css/admin.css',
117
  false,
118
+ pbSEOFriendlyImages::$verMajor.'.'.pbSEOFriendlyImages::$verMinor
119
  );
120
  wp_enqueue_style( 'pbsfi-admin-css' );
121
  } );
253
  $src = $data_src;
254
  }
255
 
256
+ $imageID = pbSEOFriendlyImages::getImageID($src);
257
 
258
  /**
259
  * Override Area
260
  */
261
+ if( pbSEOFriendlyImages::$userSettings['override_alt'] ) {
262
+ $alt = trim(pbSEOFriendlyImages::convertReplacements(
263
+ pbSEOFriendlyImages::$userSettings['alt_scheme'],
264
  $src,
265
  $imageID
266
  ));
270
  $alt = trim($tag->getAttribute('alt'));
271
  }
272
 
273
+ if( pbSEOFriendlyImages::$userSettings['override_title'] ) {
274
 
275
+ $title = trim(pbSEOFriendlyImages::convertReplacements(
276
+ pbSEOFriendlyImages::$userSettings['title_scheme'],
277
  $src,
278
  $imageID
279
  ));
286
  /**
287
  * Check attributes
288
  */
289
+ if( !empty($alt) && empty($title) && (pbSEOFriendlyImages::$userSettings['sync_method'] == 'both' || pbSEOFriendlyImages::$userSettings['sync_method'] == 'alt' ) ) {
290
 
291
  $tag->setAttribute('title', $alt);
292
  $title = $alt;
293
 
294
+ } else if( empty($alt) && !empty($title) && (pbSEOFriendlyImages::$userSettings['sync_method'] == 'both' || pbSEOFriendlyImages::$userSettings['sync_method'] == 'title' ) ) {
295
 
296
  $tag->setAttribute('alt', $title);
297
  $alt = $title;
302
  * set if empty after sync
303
  */
304
  if( empty($alt) ) {
305
+ $alt = trim(pbSEOFriendlyImages::convertReplacements(
306
+ pbSEOFriendlyImages::$userSettings['alt_scheme'],
307
  $src,
308
  $imageID
309
  ));
312
  }
313
 
314
  if( empty($title) ) {
315
+ $title = trim(pbSEOFriendlyImages::convertReplacements(
316
+ pbSEOFriendlyImages::$userSettings['title_scheme'],
317
  $src,
318
  $imageID
319
  ));
325
  return preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $document->saveHTML()));
326
  }
327
 
328
+ /**
329
+ * Prepare WooCommerce Products
330
+ *
331
+ * @param $attr
332
+ * @param $attachment
333
+ * @return mixed
334
+ */
335
+ public static function prepareContentImagesAttributes( $attr, $attachment )
336
+ {
337
+ // Get post parent
338
+ $parent = get_post_field( 'post_parent', $attachment);
339
+
340
+ // Get post type to check if it's product
341
+ $type = get_post_field( 'post_type', $parent);
342
+ if( $type != 'product' ){
343
+ return $attr;
344
+ }
345
+
346
+ /// Get title
347
+ $title = get_post_field( 'post_title', $parent);
348
+
349
+ $attr['alt'] = $title;
350
+ $attr['title'] = $title;
351
+
352
+ return $attr;
353
+ }
354
+
355
  /**
356
  * Add image title and alt to post thumbnails
357
  *
363
  {
364
  if( empty($attr['alt']) ) {
365
 
366
+ $attr['title'] = trim(pbSEOFriendlyImages::convertReplacements(
367
+ pbSEOFriendlyImages::$userSettings['title_scheme'],
368
  $attr['src']
369
  ));
370
 
371
+ $attr['alt'] = trim(pbSEOFriendlyImages::convertReplacements(
372
+ pbSEOFriendlyImages::$userSettings['alt_scheme'],
373
  $attr['src']
374
  ));
375
 
376
  } else {
377
 
378
+ if( pbSEOFriendlyImages::$userSettings['sync_method'] == 'both' || pbSEOFriendlyImages::$userSettings['sync_method'] == 'alt' ) {
379
  $attr['title'] = trim( strip_tags($attachment->post_title) );
380
  } else {
381
+ $attr['title'] = trim(pbSEOFriendlyImages::convertReplacements(
382
+ pbSEOFriendlyImages::$userSettings['title_scheme'],
383
  $attr['src']
384
  ));
385
  }
407
  $attachment = $wpdb->get_col($sql);
408
 
409
 
410
+ if( is_numeric( pbSEOFriendlyImages::getArrayKey(0, $attachment) ) ) {
411
  return (int) $attachment[0];
412
  }
413
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: pascalbajorat
3
  Donate link: https://www.pascal-bajorat.com/spenden/
4
  Tags: seo, images, Post, admin, google, attachment, optimize, photo, picture, image, media, photos, pictures, alt, title
5
  Requires at least: 3.0
6
- Tested up to: 4.7.3
7
- Stable tag: 2.0.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -77,6 +77,11 @@ If you have any questions or problems, you can ask me: [Pascal Bajorat - Webdesi
77
  = 2.0.1 =
78
  * CSS Version Bugfix
79
 
 
 
 
 
 
80
  == License ==
81
 
82
  GNU General Public License v.3 - http://www.gnu.org/licenses/gpl-3.0.html
3
  Donate link: https://www.pascal-bajorat.com/spenden/
4
  Tags: seo, images, Post, admin, google, attachment, optimize, photo, picture, image, media, photos, pictures, alt, title
5
  Requires at least: 3.0
6
+ Tested up to: 4.7.4
7
+ Stable tag: 2.1.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
77
  = 2.0.1 =
78
  * CSS Version Bugfix
79
 
80
+ = 2.1.0 =
81
+ * Improved support for old PHP versions
82
+ * Code optimization and improvements
83
+ * Better WooCommerce support
84
+
85
  == License ==
86
 
87
  GNU General Public License v.3 - http://www.gnu.org/licenses/gpl-3.0.html