PB SEO Friendly Images - Version 1.0.0

Version Description

Download this release

Release Info

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

Version 1.0.0

inc/pbSettingsFramework.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: pascalbajorat
5
+ * Date: 13.12.16
6
+ * Time: 12:48
7
+ */
8
+
9
+ if( ! class_exists('pbSettingsFramework') ):
10
+ class pbSettingsFramework
11
+ {
12
+ const version = '1.0.0';
13
+ static $textDomain = false;
14
+ static $page = false;
15
+ static $section = false;
16
+ static $optionGroup = false;
17
+ static $args = [];
18
+
19
+ public function __construct($args=[])
20
+ {
21
+ self::$textDomain = $args['text-domain'] || 'pbSettingsFramework';
22
+ self::$page = $args['page'];
23
+ self::$section = $args['section'];
24
+ self::$optionGroup = $args['option-group'];
25
+ self::$args = $args;
26
+ }
27
+
28
+ public static function registerSetting($setting)
29
+ {
30
+ if( empty(self::$args['option-group']) ) {
31
+ die(__FUNCTION__.': $args[\'option-group\'] not set!');
32
+ }
33
+
34
+ return register_setting(self::$args['option-group'], $setting);
35
+ }
36
+
37
+ public static function addSettingsSection($id, $title, $callback)
38
+ {
39
+ add_settings_section(
40
+ $id,
41
+ $title,
42
+ $callback,
43
+ self::$args['page']
44
+ );
45
+ }
46
+
47
+ public static function addSettingsField($id, $title, $args, $callback=array(__CLASS__, 'fieldsHTML'), $register_setting=true)
48
+ {
49
+ if( $register_setting )
50
+ register_setting( self::$args['option-group'], $id, 'esc_attr' );
51
+
52
+
53
+ add_settings_field(
54
+ $id,
55
+ '<label for="'.$id.'">'.$title.'</label>',
56
+ $callback,
57
+ self::$page,
58
+ self::$section,
59
+ array_merge_recursive(
60
+ array(
61
+ 'id' => $id,
62
+ 'section' => self::$section
63
+ ),
64
+
65
+ $args
66
+ )
67
+ );
68
+ }
69
+
70
+ public static function fieldsHTML( $args )
71
+ {
72
+ $option = get_option($args['id']);
73
+ $html = '';
74
+
75
+ if( $args['type'] == 'text' ) {
76
+
77
+ if ( empty( $option ) ) {
78
+ $val = $args['default'];
79
+ } else {
80
+ $val = $option;
81
+ }
82
+ $html = '<input type="text" id="' . $args['id'] . '" name="' . $args['id'] . '" class="regular-text" value="' . $val . '" />';
83
+ if ( ! empty( $args['desc'] ) ) {
84
+ $html .= '<p class="description">' . $args['desc'] . '</p>';
85
+ }
86
+
87
+ } elseif( $args['type'] == 'checkbox' ) {
88
+
89
+ if( $option === false ){
90
+ $val = $args['default'];
91
+ }else{
92
+ $val = $option;
93
+ }
94
+ $html = '<input type="checkbox" id="'.$args['id'].'" name="'.$args['id'].'" value="1" '.checked(1, $val, false).'/>';
95
+ $html .= '<label for="'.$args['id'].'"> '.$args['desc'].'</label>';
96
+
97
+ } elseif( $args['type'] == 'select' ) {
98
+
99
+ if ( empty( $option ) ) {
100
+ $val = $args['default'];
101
+ } else {
102
+ $val = $option;
103
+ }
104
+
105
+ $html = '<select id="'.$args['id'].'" name="'.$args['id'].'">';
106
+ foreach ($args['select'] as $name => $value ) {
107
+ $html .= '<option value="'.$name.'" '.(($val==$name)?'selected="selected"':'').'>'.esc_html($value).'</option>';
108
+ }
109
+ $html .= '</select>';
110
+
111
+ if ( ! empty( $args['desc'] ) ) {
112
+ $html .= '<p class="description">' . $args['desc'] . '</p>';
113
+ }
114
+
115
+ }
116
+
117
+ echo $html;
118
+ }
119
+ }
120
+ endif; //class_exists
inc/settings.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Security-Check */
3
+ if ( !class_exists('WP') ) {
4
+ die();
5
+ }
6
+
7
+ if( !class_exists('pbSEOFriendlyImagesSettings') ):
8
+
9
+ class pbSEOFriendlyImagesSettings extends pbSEOFriendlyImages
10
+ {
11
+ static $settings = false;
12
+
13
+ function addSettings()
14
+ {
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
+
21
+ public static function settingsLink( $data )
22
+ {
23
+ if( ! current_user_can('manage_options') ) {
24
+ return $data;
25
+ }
26
+
27
+ return array_merge(
28
+ $data,
29
+ array(
30
+ sprintf(
31
+ '<a href="%s">%s</a>',
32
+ add_query_arg(
33
+ array(),
34
+ admin_url('options-general.php?page=pb-seo-friendly-images')
35
+ ),
36
+ __('Settings', 'pb-seo-friendly-images')
37
+ )
38
+ )
39
+ );
40
+ }
41
+
42
+ public static function initSettings()
43
+ {
44
+ self::$settings = new pbSettingsFramework(array(
45
+ 'text-domain' => 'pb-seo-friendly-images',
46
+ 'page' => 'pb-seo-friendly-images',
47
+ 'section' => 'pb-seo-friendly-images',
48
+ 'option-group' => 'pb-seo-friendly-images'
49
+ ));
50
+
51
+ // register a new setting for "wporg" page
52
+ register_setting('pb-seo-friendly-images', 'pbsfi_options');
53
+
54
+ self::$settings->addSettingsSection(
55
+ 'pb-seo-friendly-images',
56
+ __('Image »alt« and »title« Settings', 'pb-seo-friendly-images'),
57
+ function(){
58
+ echo '<p>'.__('PB SEO Friendly Images automatically adds »alt« and »title« attributes to all images and post thumbnails in your posts. The default options are a good starting point for the optimization and basically fine for most websites.', 'pb-seo-friendly-images').'</p>';
59
+ echo '<p><strong>'.__('Override feature', 'pb-seo-friendly-images').':</strong> '.__('If you enable the override this means that a possible sync and also hand picked »alt« / »title« attributes will be overwritten with the selected scheme. If you have good hand picked »alt« or »title« attributes in your images I can\'t recommend to use the override. Automatic sync between »alt« and »title« will do it\'s best for you.', 'pb-seo-friendly-images').'</p>';
60
+
61
+ echo '<p>'.sprintf(
62
+ __('PB SEO Friendly Images is a free WordPress Plugin by <a href="%s" target="_blank">Pascal Bajorat</a> and made with %s in Berlin, Germany.<br />If you like it and maybe want to <a href="%s" target="_blank">buy me a cup of coffee or a beer</a> I would appreciate that very much.', 'pb-seo-friendly-images'),
63
+ 'https://www.pascal-bajorat.com',
64
+ '<span style="color: #f00;">&#9829;</span>',
65
+ 'https://www.pascal-bajorat.com/spenden/'
66
+ ).'</p>';
67
+ }
68
+ );
69
+
70
+ self::$settings->addSettingsField(
71
+ 'pbsfi_optimize_img',
72
+ __('optimize images', 'pb-seo-friendly-images'),
73
+ array(
74
+ 'type' => 'select',
75
+ 'default' => 'all',
76
+ 'select' => array(
77
+ 'all' => __('post thumbnails and images in post content', 'pb-seo-friendly-images').' ('.__('recommended', 'pb-seo-friendly-images').')',
78
+ 'thumbs' => __('only post thumbnails', 'pb-seo-friendly-images'),
79
+ 'post' => __('only images in post content', 'pb-seo-friendly-images'),
80
+ ),
81
+ 'desc' => __('which images should be optimized', 'pb-seo-friendly-images'),
82
+ )
83
+ );
84
+
85
+ self::$settings->addSettingsField(
86
+ 'pbsfi_sync_method',
87
+ __('sync method', 'pb-seo-friendly-images'),
88
+ array(
89
+ 'type' => 'select',
90
+ 'default' => 'both',
91
+ 'select' => array(
92
+ 'both' => __('alt <=> title', 'pb-seo-friendly-images').' ('.__('recommended', 'pb-seo-friendly-images').')',
93
+ 'alt' => __('alt => title', 'pb-seo-friendly-images'),
94
+ 'title' => __('alt <= title', 'pb-seo-friendly-images'),
95
+ ),
96
+ 'desc' => __('select sync method for »alt« and »title« attribute.', 'pb-seo-friendly-images').'<br />'.
97
+ __('<code>alt <=> title</code> - if one attribute is set use it also for the other one', 'pb-seo-friendly-images').'<br />'.
98
+ __('<code>alt => title</code> - if »alt« is set use it for the title attribute', 'pb-seo-friendly-images').'<br />'.
99
+ __('<code>alt <= title</code> - if »title« is set use it for the alt attribute', 'pb-seo-friendly-images')
100
+ )
101
+ );
102
+
103
+ self::$settings->addSettingsField(
104
+ 'pbsfi_override_alt',
105
+ __('override »alt«', 'pb-seo-friendly-images'),
106
+ array(
107
+ 'type' => 'checkbox',
108
+ 'default' => '',
109
+ 'desc' => __('override existing image alt attributes', 'pb-seo-friendly-images')
110
+ )
111
+ );
112
+
113
+ self::$settings->addSettingsField(
114
+ 'pbsfi_override_title',
115
+ __('override »title«', 'pb-seo-friendly-images'),
116
+ array(
117
+ 'type' => 'checkbox',
118
+ 'default' => '',
119
+ 'desc' => __('override existing image title attributes', 'pb-seo-friendly-images')
120
+ )
121
+ );
122
+
123
+ $placeholder = __('possible variables:', 'pb-seo-friendly-images').'<br />'.
124
+ '<code>%title</code> - '.__('replaces post title', 'pb-seo-friendly-images').'<br />'.
125
+ '<code>%desc</code> - '.__('replaces post excerpt', 'pb-seo-friendly-images').'<br />'.
126
+ '<code>%name</code> - '.__('replaces image filename (without extension)', 'pb-seo-friendly-images').'<br />'.
127
+ '<code>%category</code> - '.__('replaces post category', 'pb-seo-friendly-images').'<br />'.
128
+ '<code>%tags</code> - '.__('replaces post tags', 'pb-seo-friendly-images');
129
+
130
+ self::$settings->addSettingsField(
131
+ 'pbsfi_alt_scheme',
132
+ __('alt scheme', 'pb-seo-friendly-images'),
133
+ array(
134
+ 'type' => 'text',
135
+ 'default' => '%name - %title',
136
+ 'desc' => __('default', 'pb-seo-friendly-images').': <code>%name - %title</code><br />'.$placeholder
137
+ )
138
+ );
139
+
140
+ self::$settings->addSettingsField(
141
+ 'pbsfi_title_scheme',
142
+ __('title scheme', 'pb-seo-friendly-images'),
143
+ array(
144
+ 'type' => 'text',
145
+ 'default' => '%title',
146
+ 'desc' => __('default', 'pb-seo-friendly-images').': <code>%title</code><br />'.$placeholder
147
+ )
148
+ );
149
+ }
150
+
151
+ public static function optionsPageMenu()
152
+ {
153
+ add_submenu_page(
154
+ 'options-general.php',
155
+ __('PB SEO Friendly Images', 'pb-seo-friendly-images'),
156
+ __('SEO Friendly Images', 'pb-seo-friendly-images'),
157
+ 'manage_options',
158
+ 'pb-seo-friendly-images',
159
+ array(__CLASS__, 'optionsPage')
160
+ );
161
+ }
162
+
163
+ function optionsPage()
164
+ {
165
+ if (!current_user_can('manage_options')) {
166
+ return;
167
+ }
168
+ ?>
169
+ <div class="wrap">
170
+ <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
171
+ <form action="<?php echo admin_url('options.php') ?>" method="post" target="_self">
172
+ <?php
173
+ settings_fields('pb-seo-friendly-images');
174
+ do_settings_sections('pb-seo-friendly-images');
175
+ submit_button();
176
+ ?>
177
+ </form>
178
+ </div>
179
+ <?php
180
+ }
181
+
182
+
183
+ }
184
+
185
+ endif; // class_exists
lang/pb-seo-friendly-images-de_DE.mo ADDED
Binary file
lang/pb-seo-friendly-images-de_DE.po ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: PB SEO Friendly Images\n"
4
+ "POT-Creation-Date: 2016-12-13 19:54+0100\n"
5
+ "PO-Revision-Date: 2016-12-13 20:53+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"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.11\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-WPHeader: pb-seo-friendly-images.php\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
22
+
23
+ #: inc/settings.php:37
24
+ msgid "Settings"
25
+ msgstr "Einstellungen"
26
+
27
+ #: inc/settings.php:57
28
+ msgid "Image »alt« and »title« Settings"
29
+ msgstr "Bilder »alt« und »title« Einstellungen"
30
+
31
+ #: inc/settings.php:59
32
+ msgid ""
33
+ "PB SEO Friendly Images automatically adds »alt« and »title« attributes to "
34
+ "all images and post thumbnails in your posts. The default options are a good "
35
+ "starting point for the optimization and basically fine for most websites."
36
+ msgstr ""
37
+ "PB SEO Friendly Images verwaltet automatisch die »alt« und »title« Attribute "
38
+ "deiner Post-Thumbnails sowie aller Bilder innerhalb deiner Seiten und "
39
+ "Artikel. Die Standard-Einstellungen sind eine gute erste Grundlage und "
40
+ "werden für die meisten Webseiten gut funktionieren, ohne das Änderungen "
41
+ "notwendig sind."
42
+
43
+ #: inc/settings.php:60
44
+ msgid "Override feature"
45
+ msgstr "Override-Funktion"
46
+
47
+ #: inc/settings.php:60
48
+ msgid ""
49
+ "If you enable the override this means that a possible sync and also hand "
50
+ "picked »alt« / »title« attributes will be overwritten with the selected "
51
+ "scheme. If you have good hand picked »alt« or »title« attributes in your "
52
+ "images I can't recommend to use the override. Automatic sync between »alt« "
53
+ "and »title« will do it's best for you."
54
+ msgstr ""
55
+ "Wenn du die Override (überschreiben) Funktion verwendest, werden alle "
56
+ "manuellen »alt« und/oder »title« Attribute durch das gewählte Schema "
57
+ "überschrieben. Wenn du bereits manuelle Attribute für deine Bilder gesetzt "
58
+ "hast, solltest du einfach die Sync Funktion ihren Job machen lassen und "
59
+ "keine Überschreibung erzwingen."
60
+
61
+ #: inc/settings.php:63
62
+ #, php-format
63
+ msgid ""
64
+ "PB SEO Friendly Images is a free WordPress Plugin by <a href=\"%s\" target="
65
+ "\"_blank\">Pascal Bajorat</a> and made with %s in Berlin, Germany.<br />If "
66
+ "you like it and maybe want to <a href=\"%s\" target=\"_blank\">buy me a cup "
67
+ "of coffee or a beer</a> I would appreciate that very much."
68
+ msgstr ""
69
+ "PB SEO Friendly Images ist ein kostenloses WordPress Plugin von <a href=\"%s"
70
+ "\" target=\"_blank\">Pascal Bajorat</a> und wurde mit viel %s in Berlin "
71
+ "entwickelt.<br />Wenn du das Plugin magst würde ich mich freuen, <a href=\"%s"
72
+ "\" target=\"_blank\">wenn du mich mit einer kleinen Spende virtuell auf "
73
+ "einen Kaffee oder Bier einlädst</a>."
74
+
75
+ #: inc/settings.php:73
76
+ msgid "optimize images"
77
+ msgstr "Bilder optimieren"
78
+
79
+ #: inc/settings.php:78
80
+ msgid "post thumbnails and images in post content"
81
+ msgstr "Thumbnails und Bilder innerhalb der Posts"
82
+
83
+ #: inc/settings.php:78 inc/settings.php:93
84
+ msgid "recommended"
85
+ msgstr "empfohlen"
86
+
87
+ #: inc/settings.php:79
88
+ msgid "only post thumbnails"
89
+ msgstr "Nur Postthumbnails"
90
+
91
+ #: inc/settings.php:80
92
+ msgid "only images in post content"
93
+ msgstr "Nur Bilder im Post-Inhalt"
94
+
95
+ #: inc/settings.php:82
96
+ msgid "which images should be optimized"
97
+ msgstr "Welche Bilder sollen optimiert werden."
98
+
99
+ #: inc/settings.php:88
100
+ msgid "sync method"
101
+ msgstr "Synchronisierungsmethode"
102
+
103
+ #: inc/settings.php:93
104
+ msgid "alt <=> title"
105
+ msgstr "alt <=> title"
106
+
107
+ #: inc/settings.php:94
108
+ msgid "alt => title"
109
+ msgstr "alt => title"
110
+
111
+ #: inc/settings.php:95
112
+ msgid "alt <= title"
113
+ msgstr "alt => title"
114
+
115
+ #: inc/settings.php:97
116
+ msgid "select sync method for »alt« and »title« attribute."
117
+ msgstr "Wähle die Synchronisierungsmethode für »alt« und »title« Attribute."
118
+
119
+ #: inc/settings.php:98
120
+ msgid ""
121
+ "<code>alt <=> title</code> - if one attribute is set use it also for the "
122
+ "other one"
123
+ msgstr ""
124
+ "<code>alt <=> title</code> - Wenn ein Attribut gesetzt ist, wird dieses auch "
125
+ "auf das andere übertragen"
126
+
127
+ #: inc/settings.php:99
128
+ msgid ""
129
+ "<code>alt => title</code> - if »alt« is set use it for the title attribute"
130
+ msgstr ""
131
+ "<code>alt => title</code> - Wenn »alt« gesetzt ist, wird der Wert ebenfalls "
132
+ "für »title« gesetzt"
133
+
134
+ #: inc/settings.php:100
135
+ msgid ""
136
+ "<code>alt <= title</code> - if »title« is set use it for the alt attribute"
137
+ msgstr ""
138
+ "<code>alt <= title</code> - Wenn »title« gesetzt ist, wird der Wert "
139
+ "ebenfalls für »alt« gesetzt"
140
+
141
+ #: inc/settings.php:106
142
+ msgid "override »alt«"
143
+ msgstr "»alt« überschreiben"
144
+
145
+ #: inc/settings.php:110
146
+ msgid "override existing image alt attributes"
147
+ msgstr "Überschreibt bestehende »alt« Attribute"
148
+
149
+ #: inc/settings.php:116
150
+ msgid "override »title«"
151
+ msgstr "»title« überschreiben"
152
+
153
+ #: inc/settings.php:120
154
+ msgid "override existing image title attributes"
155
+ msgstr "Überschreibt bestehende »title« Attribute"
156
+
157
+ #: inc/settings.php:124
158
+ msgid "possible variables:"
159
+ msgstr "Mögliche Variablen:"
160
+
161
+ #: inc/settings.php:125
162
+ msgid "replaces post title"
163
+ msgstr "Wird ersetzt durch Artikeltitel"
164
+
165
+ #: inc/settings.php:126
166
+ msgid "replaces post excerpt"
167
+ msgstr "Wird ersetzt durch den Artikelauszug"
168
+
169
+ #: inc/settings.php:127
170
+ msgid "replaces image filename (without extension)"
171
+ msgstr "Wird ersetzt mit dem Dateinamen (ohne Dateiendung)"
172
+
173
+ #: inc/settings.php:128
174
+ msgid "replaces post category"
175
+ msgstr "Wird ersetzt durch die Artikelkategorien"
176
+
177
+ #: inc/settings.php:129
178
+ msgid "replaces post tags"
179
+ msgstr "Wird ersetzt durch die Artikel-Tags"
180
+
181
+ #: inc/settings.php:133
182
+ msgid "alt scheme"
183
+ msgstr "Schema alt-Attribut"
184
+
185
+ #: inc/settings.php:137 inc/settings.php:147
186
+ msgid "default"
187
+ msgstr "Standard"
188
+
189
+ #: inc/settings.php:143
190
+ msgid "title scheme"
191
+ msgstr "Schema title-Attribut"
192
+
193
+ #. Plugin Name of the plugin/theme
194
+ #: inc/settings.php:156
195
+ msgid "PB SEO Friendly Images"
196
+ msgstr "PB SEO Friendly Images"
197
+
198
+ #: inc/settings.php:157
199
+ msgid "SEO Friendly Images"
200
+ msgstr "PB SEO Friendly Images"
201
+
202
+ #. Plugin URI of the plugin/theme
203
+ msgid "http://wordpress.org/extend/plugins/pb-seo-friendly-images/"
204
+ msgstr "http://wordpress.org/extend/plugins/pb-seo-friendly-images/"
205
+
206
+ #. Description of the plugin/theme
207
+ msgid ""
208
+ "This plugin is a full featured solution for SEO friendly images. You can "
209
+ "optimize »alt« and »title« attributes for all images and post thumbnails. "
210
+ "This plugin helps you to improve traffic from search engines."
211
+ msgstr ""
212
+ "Dieses Plugin ist eine komplette Lösung für SEO freundliche Bilder. Du "
213
+ "kannst automatisch »alt« und »title« Attribute für alle Bilder und Post-"
214
+ "Thumbnails optimieren. Das Plugin hilft durch die Optimierung der Bilder für "
215
+ "höheren Traffic über Suchmaschinen."
216
+
217
+ #. Author of the plugin/theme
218
+ msgid "Pascal Bajorat"
219
+ msgstr "Pascal Bajorat"
220
+
221
+ #. Author URI of the plugin/theme
222
+ msgid "http://www.pascal-bajorat.com"
223
+ msgstr "http://www.pascal-bajorat.com"
pb-seo-friendly-images.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: PB SEO Friendly Images
4
+ Plugin URI: http://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 traffic from search engines.
6
+ Version: 1.0.0
7
+ Author: Pascal Bajorat
8
+ Author URI: http://www.pascal-bajorat.com
9
+ Text Domain: pb-seo-friendly-images
10
+ Domain Path: /lang
11
+ License: GNU General Public License v.3
12
+
13
+ Copyright (c) 2017 by Pascal Bajorat.
14
+ */
15
+
16
+ /* Security-Check */
17
+ if ( !class_exists('WP') ) {
18
+ die();
19
+ }
20
+
21
+ require_once 'inc/pbSettingsFramework.php';
22
+
23
+ if( !class_exists('pbSEOFriendlyImages') ):
24
+
25
+ class pbSEOFriendlyImages
26
+ {
27
+
28
+ static $basename = false;
29
+ static $userSettings = array();
30
+
31
+ /**
32
+ * Init function
33
+ */
34
+ public static function init()
35
+ {
36
+ self::$basename = plugin_basename(__FILE__);
37
+
38
+ /*
39
+ * Language file
40
+ */
41
+ load_plugin_textdomain('pb-seo-friendly-images', false, dirname(self::$basename).'/lang/');
42
+
43
+ /**
44
+ * Get settings and defaults
45
+ */
46
+ if( ! is_admin() ) {
47
+ self::$userSettings = array(
48
+ 'optimize_img' => get_option('pbsfi_optimize_img', 'all'),
49
+ 'sync_method' => get_option('pbsfi_sync_method', 'both'),
50
+ 'override_alt' => get_option('pbsfi_override_alt', false),
51
+ 'override_title' => get_option('pbsfi_override_title', false),
52
+ 'alt_scheme' => get_option('pbsfi_alt_scheme', '%name - %title'),
53
+ 'title_scheme' => get_option('pbsfi_title_scheme', '%title')
54
+ );
55
+ }
56
+
57
+ // process post thumbnails
58
+ if( self::$userSettings['optimize_img'] == 'all' || self::$userSettings['optimize_img'] == 'thumbs' ) {
59
+ add_filter( 'wp_get_attachment_image_attributes', array(__CLASS__, 'addImgTitlePostThumbnail'), 10, 2 );
60
+ }
61
+
62
+ // process post images
63
+ if( self::$userSettings['optimize_img'] == 'all' || self::$userSettings['optimize_img'] == 'post' ) {
64
+ add_filter( 'the_content', array(__CLASS__, 'prepareContentImages'), 999, 1 );
65
+ }
66
+
67
+ //add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );
68
+ //remove_filter( 'the_content','wp_make_content_images_responsive' );
69
+ }
70
+
71
+ /**
72
+ * Scheme replacements / variables
73
+ *
74
+ * @param string $content scheme
75
+ * @param bool|string $src image url
76
+ * @return string
77
+ */
78
+ public static function convertReplacements( $content, $src=false )
79
+ {
80
+ global $post;
81
+
82
+ $cats = '';
83
+ if ( strrpos( $content, '%category' ) !== false ) {
84
+ $categories = get_the_category();
85
+
86
+ if ( $categories ) {
87
+ $i = 0;
88
+ foreach ( $categories as $cat ) {
89
+ if ( $i == 0 ) {
90
+ $cats = $cat->slug . $cats;
91
+ } else {
92
+ $cats = $cat->slug . ' ' . $cats;
93
+ }
94
+ ++$i;
95
+ }
96
+ }
97
+ }
98
+
99
+ $tags = '';
100
+ if ( strrpos( $content, '%tags' ) !== false ) {
101
+ $posttags = get_the_tags();
102
+
103
+ if ( $posttags ) {
104
+ $i = 0;
105
+ foreach ( $posttags as $tag ) {
106
+ if ( $i == 0 ) {
107
+ $tags = $tag->name . $tags;
108
+ } else {
109
+ $tags = $tag->name . ' ' . $tags;
110
+ }
111
+ ++$i;
112
+ }
113
+ }
114
+ }
115
+
116
+ if( $src ) {
117
+ $info = @pathinfo($src);
118
+ $src = @basename($src,'.'.$info['extension']);
119
+
120
+ $src = str_replace('-', ' ', $src);
121
+ $src = str_replace('_', ' ', $src);
122
+ } else {
123
+ $src = '';
124
+ }
125
+
126
+ $content = str_replace('%name', $src, $content );
127
+ $content = str_replace('%title', $post->post_title, $content );
128
+ $content = str_replace('%category', $cats, $content );
129
+ $content = str_replace('%tags', $tags, $content );
130
+ $content = str_replace('%desc', $post->post_excerpt, $content);
131
+
132
+ return $content;
133
+ }
134
+
135
+ /**
136
+ * Process post images
137
+ *
138
+ * @param string $content
139
+ * @return string
140
+ */
141
+ public static function prepareContentImages( $content )
142
+ {
143
+ if( empty($content) || !class_exists('DOMDocument') )
144
+ return $content;
145
+
146
+ $charset = DB_CHARSET || 'utf-8';
147
+
148
+ $document = new DOMDocument();
149
+ @$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
150
+ @$document->loadHTML($content);
151
+
152
+ if( !$document )
153
+ return $content;
154
+
155
+ $imgTags = $document->getElementsByTagName('img');
156
+
157
+ if( ! $imgTags->length )
158
+ return $content;
159
+
160
+ foreach ($imgTags as $tag) {
161
+ $src = trim($tag->getAttribute('src'));
162
+
163
+ /**
164
+ * Override Area
165
+ */
166
+ if( self::$userSettings['override_alt'] ) {
167
+
168
+ $alt = trim(self::convertReplacements(
169
+ self::$userSettings['alt_scheme'],
170
+ $src
171
+ ));
172
+
173
+ $tag->setAttribute('alt', $alt);
174
+ } else {
175
+ $alt = trim($tag->getAttribute('alt'));
176
+ }
177
+
178
+ if( self::$userSettings['override_title'] ) {
179
+
180
+ $title = trim(self::convertReplacements(
181
+ self::$userSettings['title_scheme'],
182
+ $src
183
+ ));
184
+
185
+ $tag->setAttribute('title', $title);
186
+ } else {
187
+ $title = trim($tag->getAttribute('title'));
188
+ }
189
+
190
+ /**
191
+ * Check attributes
192
+ */
193
+ if( !empty($alt) && empty($title) && (self::$userSettings['sync_method'] == 'both' || self::$userSettings['sync_method'] == 'alt' ) ) {
194
+
195
+ $tag->setAttribute('title', $alt);
196
+ $title = $alt;
197
+
198
+ } else if( empty($alt) && !empty($title) && (self::$userSettings['sync_method'] == 'both' || self::$userSettings['sync_method'] == 'title' ) ) {
199
+
200
+ $tag->setAttribute('alt', $title);
201
+ $alt = $title;
202
+
203
+ }
204
+
205
+ /**
206
+ * set if empty after sync
207
+ */
208
+ if( empty($alt) ) {
209
+ $alt = trim(self::convertReplacements(
210
+ self::$userSettings['alt_scheme'],
211
+ $src
212
+ ));
213
+
214
+ $tag->setAttribute('alt', $alt);
215
+ }
216
+
217
+ if( empty($title) ) {
218
+ $title = trim(self::convertReplacements(
219
+ self::$userSettings['title_scheme'],
220
+ $src
221
+ ));
222
+
223
+ $tag->setAttribute('title', $title);
224
+ }
225
+ }
226
+
227
+ return $document->saveHTML();
228
+ }
229
+
230
+ /**
231
+ * Add image title and alt to post thumbnails
232
+ *
233
+ * @param $attr
234
+ * @param null $attachment
235
+ * @return mixed
236
+ */
237
+ public static function addImgTitlePostThumbnail( $attr, $attachment = null )
238
+ {
239
+ if( empty($attr['alt']) ) {
240
+
241
+ $attr['title'] = trim(self::convertReplacements(
242
+ self::$userSettings['title_scheme'],
243
+ $attr['src']
244
+ ));
245
+
246
+ $attr['alt'] = trim(self::convertReplacements(
247
+ self::$userSettings['alt_scheme'],
248
+ $attr['src']
249
+ ));
250
+
251
+ } else {
252
+
253
+ if( self::$userSettings['sync_method'] == 'both' || self::$userSettings['sync_method'] == 'alt' ) {
254
+ $attr['title'] = trim( strip_tags($attachment->post_title) );
255
+ } else {
256
+ $attr['title'] = trim(self::convertReplacements(
257
+ self::$userSettings['title_scheme'],
258
+ $attr['src']
259
+ ));
260
+ }
261
+
262
+ }
263
+
264
+ return $attr;
265
+ }
266
+
267
+ /**
268
+ * Uninstall PB SEO Friendly Images
269
+ */
270
+ public static function uninstall()
271
+ {
272
+ /* Global */
273
+ /** @var object $wpdb */
274
+ global $wpdb;
275
+
276
+ /* Remove settings */
277
+ //delete_option();
278
+
279
+ /* Clean DB */
280
+ $wpdb->query("OPTIMIZE TABLE `" .$wpdb->options. "`");
281
+ }
282
+ }
283
+
284
+ endif; // class_exists
285
+
286
+ require_once 'inc/settings.php';
287
+
288
+ add_action(
289
+ 'plugins_loaded',
290
+ array(
291
+ 'pbSEOFriendlyImages',
292
+ 'init'
293
+ )
294
+ );
295
+
296
+ add_action(
297
+ 'plugins_loaded',
298
+ array(
299
+ 'pbSEOFriendlyImagesSettings',
300
+ 'addSettings'
301
+ )
302
+ );
303
+
304
+ register_uninstall_hook(
305
+ __FILE__,
306
+ array(
307
+ 'pbSEOFriendlyImages',
308
+ 'uninstall'
309
+ )
310
+ );
readme.txt ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === PB SEO Friendly Images ===
2
+ Contributors: pascalbajorat
3
+ Donate link: http://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
7
+ Stable tag: 1.0.0
8
+ License: GPLv3
9
+ License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
+
11
+ This plugin is a full-featured solution for SEO friendly images. Optimize »alt« and »title« attributes for all images and improve SEO traffic.
12
+
13
+ == Description ==
14
+
15
+ PB SEO Friendly Images is a free WordPress plugin that helps you to automatically optimize all »alt« and »title« attributes of images in your posts. »alt« and also »title« attributes are important for a website-ranking in search engines. »alt« attributes are also required to get a W3C valid website.
16
+
17
+ > #### Features of PB SEO Friendly Images
18
+ > - **Sync:** You can sync existing »alt« to »title« and vice versa
19
+ > - **Override:** You can override existing »alt« and »title« attributes with a custom scheme
20
+ > - **Scheme:** Set up a scheme for your »alt« and »title« to flexible define and optimize your content
21
+ > - **For all images:** The plugin works great with images in posts an post thumbnails aswell
22
+ > - **SEO Proved:** Default settings of the plugins are proved by a SEO consultant
23
+
24
+ The idea to this plugin based on a similar WordPress plugin "SEO Friendly Images" by Vladimir Prelovac. This plugin version has more settings, possibilities to configure your »alt« / »title« attributes and it’s actively maintained. There is also a sync function, that automatically use existing »alt« as »title« and vice versa if one of the values exist. This is really important, if you have already optimized some of your images.
25
+
26
+ If you have any questions or problems, you can ask me: [Pascal Bajorat - Webdesigner and WordPress Developer from Berlin](https://www.pascal-bajorat.com/ "Pascal Bajorat - Webdesigner and WordPress Developer from Berlin")
27
+
28
+ == Installation ==
29
+
30
+ 1. Upload the full directory to /wp-content/plugins/
31
+ 2. Activate the plugin over "Plugins > Installed Plugins" in your WordPress Backend
32
+ 3. Go to "Settings" and "SEO Friendly Images" to configure the plugin
33
+
34
+ == Screenshots ==
35
+
36
+ 1. Plugin Settings
37
+
38
+ == Changelog ==
39
+
40
+ = 1.0 =
41
+ * Initial release.
42
+
43
+ == License ==
44
+
45
+ GNU General Public License v.3 - http://www.gnu.org/licenses/gpl-3.0.html