SEO Friendly Images - Version 2.7.1

Version Description

  • Minor issues fixed (thanks Dewey Bushaw)
Download this release

Release Info

Developer freediver
Plugin Icon 128x128 SEO Friendly Images
Version 2.7.1
Comparing to
See all releases

Code changes from version 2.7.0 to 2.7.1

Files changed (2) hide show
  1. readme.txt +3 -0
  2. seo-friendly-images.php +270 -345
readme.txt CHANGED
@@ -23,6 +23,9 @@ If you like what I do in WordPress, you will also like [ManageWP](http://managew
23
 
24
  == Changelog ==
25
 
 
 
 
26
  = 2.7.0 =
27
  * Introduced the <a href="http://www.prelovac.com/products/seo-friendly-images">premium version</a>
28
 
23
 
24
  == Changelog ==
25
 
26
+ = 2.7.1 =
27
+ * Minor issues fixed (thanks Dewey Bushaw)
28
+
29
  = 2.7.0 =
30
  * Introduced the <a href="http://www.prelovac.com/products/seo-friendly-images">premium version</a>
31
 
seo-friendly-images.php CHANGED
@@ -1,345 +1,270 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: SEO Friendly Images
5
- Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/seo-friendly-images
6
- Description: Automatically adds alt and title attributes to all your images. Improves traffic from search results and makes them W3C/xHTML valid as well.
7
- Version: 2.7.0
8
- Author: Vladimir Prelovac
9
- Author URI: http://www.prelovac.com/vladimir
10
-
11
- To-Do:
12
- - localization (done in premium version)
13
- - integration module with google xml sitempas to support images sitemap (done in premium version)
14
-
15
-
16
- Copyright 2008 Vladimir Prelovac vprelovac@gmail.com
17
-
18
- */
19
-
20
- $seo_friendly_images_localversion="2.6";
21
- $sfi_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
22
- function seo_friendly_images_add_pages()
23
- {
24
- add_options_page('SEO Friendly Images options', 'SEO Friendly Images', 'manage_options', __FILE__, 'seo_friendly_images_options_page');
25
-
26
- }
27
-
28
-
29
- function seo_friendly_images_admin_notice() {
30
-
31
- echo '<div class="updated" style="text-align: center;"><p style="font-size:13px">Get the paid version of <a target="_blank" href="http://www.prelovac.com/products/seo-friendly-images">SEO Friendly Images</a> with more features and support. <a target="_blank" href="http://www.prelovac.com/products/seo-friendly-images">Click to learn what is new</a></p><p style="text-align:right"><a href="options-general.php?page=seo-image/seo-friendly-images.php&notice=1">hide</a></p></div>';
32
-
33
- }
34
-
35
- // Options Page
36
- function seo_friendly_images_options_page()
37
- {
38
-
39
- global $seo_friendly_images_localversion;
40
-
41
- $status=seo_friendly_images_getinfo();
42
-
43
- $theVersion = $status[1];
44
- $theMessage = $status[3];
45
-
46
- if( (version_compare(strval($theVersion), strval($seo_friendly_images_localversion), '>') == 1) )
47
- {
48
- $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
49
- _e('<div id="message" class="updated fade"><p>' . $msg . '</p></div>');
50
- }
51
-
52
- // If form was submitted
53
- if (isset($_POST['submitted']))
54
- {
55
- $alt_text=(!isset($_POST['alttext'])? '': $_POST['alttext']);
56
- $title_text=(!isset($_POST['titletext'])? '': $_POST['titletext']);
57
- $override=(!isset($_POST['override'])? 'off': 'on');
58
- $override_title=(!isset($_POST['override_title'])? 'off': 'on');
59
- update_option('seo_friendly_images_alt', $alt_text);
60
- update_option('seo_friendly_images_title', $title_text );
61
- update_option('seo_friendly_images_override', $override );
62
- update_option('seo_friendly_images_override_title', $override_title );
63
-
64
- $msg_status = 'SEO Friendly Images options saved.';
65
-
66
- // Show message
67
- _e('<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>');
68
-
69
- }
70
-
71
- if (isset($_GET['notice']))
72
- {
73
- if ($_GET['notice']==1)
74
- {
75
-
76
- update_option('seo_friendly_images_notice', 1);
77
- }
78
- }
79
-
80
- // Fetch code from DB
81
- $alt_text = get_option('seo_friendly_images_alt');
82
- $title_text = get_option('seo_friendly_images_title');
83
- $override =( get_option('seo_friendly_images_override')=='on' ) ? "checked":"";
84
- $override_title =( get_option('seo_friendly_images_override_title')=='on' ) ? "checked":"";
85
-
86
- global $sfi_plugin_url;
87
- $imgpath=$sfi_plugin_url.'/i';
88
- $actionurl=$_SERVER['REQUEST_URI'];
89
- // Configuration Page
90
-
91
-
92
- echo <<<END
93
- <div class="wrap" >
94
- <h2>SEO Friendly Images $seo_friendly_images_localversion</h2>
95
-
96
- <div id="poststuff" style="margin-top:10px;">
97
-
98
- <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
99
- <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=2&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BFriendly%2BImages"></iframe>
100
- </div>
101
- </div>
102
-
103
- <div id="mainblock" style="width:710px">
104
-
105
- <div class="dbx-content">
106
- <form name="sfiform" action="$action_url" method="post">
107
- <input type="hidden" name="submitted" value="1" />
108
- <h2>General Options</h2>
109
-
110
- <p>SEO Friendly Images automatically adds alt and title attributes to all your images in all your posts specified by parameters below.</p>
111
- <p>You can enter any text in the field including two special tags:</p>
112
- <ul>
113
- <li>%title - replaces post title</li>
114
- <li>%name - replaces image file name (without extension)</li>
115
- <li>%category - replaces post category</li>
116
- <li>%tags - replaces post tags</li>
117
- </ul>
118
-
119
-
120
-
121
- <h4>Images options</h4>
122
-
123
-
124
- <div>
125
- <label for="alt_text"><b>ALT</b> attribute (example: %name %title)</label><br>
126
- <input style="border:1px solid #D1D1D1; width:165px;" id="alt_text" name="alttext" value="$alt_text"/>
127
- </div><br>
128
-
129
- <div>
130
- <label for="title_text"><b>TITLE</b> attribute (example: %name photo)</label><br>
131
- <input style="border:1px solid #D1D1D1; width:165px;" id="title_text" name="titletext" value="$title_text"/>
132
- </div>
133
-
134
- <br />
135
- <div><input id="check1" type="checkbox" name="override" $override />
136
- <label for="check1">Override default Wordpress image alt tag (recommended)</label></div>
137
- <br />
138
- <div><input id="check2" type="checkbox" name="override_title" $override_title />
139
- <label for="check2">Override default Wordpress image title</label></div>
140
-
141
-
142
- <br/><br /><p>Example:<br />
143
- In a post titled Car Pictures there is a picture named Ferrari.jpg<br /><br />
144
- Setting alt attribute to "%name %title" will produce alt="Ferrari Car Pictures"<br />
145
- Setting title attribute to "%name photo" will produce title="Ferrari photo"</p>
146
-
147
- <div class="submit"><input type="submit" name="Submit" value="Update options" /></div>
148
- </form>
149
- </div>
150
-
151
- <br/><br/><h3>&nbsp;</h3>
152
- </div>
153
-
154
- </div>
155
-
156
- <h5>Another fine WordPress plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
157
- </div>
158
- END;
159
-
160
- }
161
-
162
- // Add Options Page
163
- add_action('admin_menu', 'seo_friendly_images_add_pages');
164
-
165
-
166
- function remove_extension($name) {
167
- return preg_replace('/(.+)\..*$/', '$1', $name);
168
- }
169
-
170
- function seo_friendly_images_process($matches) {
171
-
172
- global $post;
173
-
174
-
175
- $title = $post->post_title;
176
-
177
- $alttext_rep = get_option('seo_friendly_images_alt');
178
- $titletext_rep = get_option('seo_friendly_images_title');
179
- $override= get_option('seo_friendly_images_override');
180
- $override_title= get_option('seo_friendly_images_override_title');
181
-
182
- # take care of unsusal endings
183
- $matches[0]=preg_replace('|([\'"])[/ ]*$|', '\1 /', $matches[0]);
184
-
185
-
186
- ### Normalize spacing around attributes.
187
- $matches[0] = preg_replace('/\s*=\s*/', '=', substr($matches[0],0,strlen($matches[0])-2));
188
- ### Get source.
189
-
190
- preg_match('/src\s*=\s*([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/', $matches[0], $source);
191
-
192
-
193
- $saved=$source[2];
194
-
195
- ### Swap with file's base name.
196
- preg_match('%[^/]+(?=\.[a-z]{3}\z)%', $source[2], $source);
197
- ### Separate URL by attributes.
198
- $pieces = preg_split('/(\w+=)/', $matches[0], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
199
- ### Add missing pieces.
200
-
201
-
202
- $postcats=get_the_category();
203
- $cats="";
204
- if ($postcats) {
205
- foreach($postcats as $cat) {
206
- $cats = $cat->slug. ' '. $cats;
207
- }
208
- }
209
-
210
- $posttags = get_the_tags();
211
-
212
- $tags="";
213
- if ($posttags) {
214
- foreach($posttags as $tag) {
215
- $tags = $tag->name . ' ' . $tags;
216
- }
217
- }
218
-
219
-
220
-
221
- if (!in_array('title=', $pieces) || $override_title=="on") {
222
- $titletext_rep=str_replace("%title", $post->post_title, $titletext_rep);
223
- $titletext_rep=str_replace("%name", $source[0], $titletext_rep);
224
- $titletext_rep=str_replace("%category", $cats, $titletext_rep);
225
- $titletext_rep=str_replace("%tags", $tags, $titletext_rep);
226
-
227
-
228
- $titletext_rep=str_replace('"', '', $titletext_rep);
229
- $titletext_rep=str_replace("'", "", $titletext_rep);
230
-
231
- $titletext_rep=str_replace("_", " ", $titletext_rep);
232
- $titletext_rep=str_replace("-", " ", $titletext_rep);
233
- //$titletext_rep=ucwords(strtolower($titletext_rep));
234
- if (!in_array('title=', $pieces)) {
235
- array_push($pieces, ' title="' . $titletext_rep . '"');
236
- }
237
- else
238
- {
239
- $key=array_search('title=',$pieces);
240
- $pieces[$key+1]='"'.$titletext_rep.'" ';
241
- }
242
- }
243
-
244
-
245
- if (!in_array('alt=', $pieces) || $override=="on" ) {
246
- $alttext_rep=str_replace("%title", $post->post_title, $alttext_rep);
247
- $alttext_rep=str_replace("%name", $source[0], $alttext_rep);
248
- $alttext_rep=str_replace("%category", $cats, $alttext_rep);
249
- $alttext_rep=str_replace("%tags", $tags, $alttext_rep);
250
- $alttext_rep=str_replace("\"", "", $alttext_rep);
251
- $alttext_rep=str_replace("'", "", $alttext_rep);
252
-
253
- $alttext_rep=(str_replace("-", " ", $alttext_rep));
254
- $alttext_rep=(str_replace("_", " ", $alttext_rep));
255
-
256
-
257
- if (!in_array('alt=', $pieces)) {
258
- array_push($pieces, ' alt="' . $alttext_rep . '"');
259
- }
260
- else
261
- {
262
- $key=array_search('alt=',$pieces);
263
- $pieces[$key+1]='"'.$alttext_rep.'" ';
264
- }
265
- }
266
-
267
-
268
- return implode('', $pieces).' /';
269
- }
270
-
271
- function seo_friendly_images($content) {
272
- return preg_replace_callback('/<img[^>]+/', 'seo_friendly_images_process', $content);
273
- }
274
-
275
-
276
- add_filter('the_content', 'seo_friendly_images', 100);
277
-
278
- //add_action( 'after_plugin_row', 'seo_friendly_images_check_plugin_version' );
279
-
280
- function seo_friendly_images_getinfo()
281
- {
282
- $checkfile = "http://svn.wp-plugins.org/seo-image/trunk/seo-friendly-images.chk";
283
-
284
- $status=array();
285
- return $status;
286
- $vcheck = wp_remote_fopen($checkfile);
287
-
288
- if($vcheck)
289
- {
290
- $version = $seo_friendly_images_localversion;
291
-
292
- $status = explode('@', $vcheck);
293
- return $status;
294
- }
295
- }
296
-
297
- function seo_friendly_images_check_plugin_version($plugin)
298
- {
299
- global $plugindir, $seo_friendly_images_localversion;
300
-
301
- if( strpos($plugin,'seo-friendly-images.php')!==false )
302
- {
303
-
304
-
305
- $status=seo_friendly_images_getinfo();
306
-
307
- $theVersion = $status[1];
308
- $theMessage = $status[3];
309
-
310
- if( (version_compare(strval($theVersion), strval($seo_friendly_images_localversion), '>') == 1) )
311
- {
312
- $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
313
- echo '<td colspan="5" class="plugin-update" style="line-height:1.2em;">'.$msg.'</td>';
314
- } else {
315
- return;
316
- }
317
-
318
- }
319
- }
320
-
321
-
322
-
323
- function seo_friendly_images_install(){
324
- if(!get_option('seo_friendly_images_alt')){
325
- add_option('seo_friendly_images_alt', '%name %title');
326
- }
327
- if(!get_option('seo_friendly_images_title')){
328
- add_option('seo_friendly_images_title', '%title');
329
- }
330
- if(get_option('seo_friendly_images_override' == '') || !get_option('seo_friendly_images_override')){
331
- add_option('seo_friendly_images_override', 'on');
332
- }
333
- if(get_option('seo_friendly_images_override_title' == '') || !get_option('seo_friendly_images_override_title')){
334
- add_option('seo_friendly_images_override_title', 'off');
335
- }
336
-
337
- if (!get_option('seo_friendly_images_notice'))
338
- add_action('admin_notices', 'seo_friendly_images_admin_notice');
339
-
340
- }
341
-
342
-
343
- add_action( 'plugins_loaded', 'seo_friendly_images_install' );
344
-
345
- ?>
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: SEO Friendly Images
5
+ Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/seo-friendly-images
6
+ Description: Automatically adds alt and title attributes to all your images. Improves traffic from search results and makes them W3C/xHTML valid as well.
7
+ Version: 2.7.1
8
+ Author: Vladimir Prelovac
9
+ Author URI: http://www.prelovac.com/vladimir
10
+
11
+ To-Do:
12
+ - localization (done in premium version)
13
+ - integration module with google xml sitempas to support images sitemap (done in premium version)
14
+
15
+ Copyright 2008 Vladimir Prelovac vprelovac@gmail.com
16
+
17
+ */
18
+ $seo_friendly_images_localversion="2.6";
19
+ $sfi_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
20
+ function seo_friendly_images_add_pages() {
21
+ add_options_page('SEO Friendly Images options', 'SEO Friendly Images', 'manage_options', __FILE__, 'seo_friendly_images_options_page');
22
+ }
23
+ function seo_friendly_images_admin_notice() {
24
+ echo '<div class="updated" style="text-align: center;"><p style="font-size:13px">Get the paid version of <a target="_blank" href="http://www.prelovac.com/products/seo-friendly-images">SEO Friendly Images</a> with more features and support. <a target="_blank" href="http://www.prelovac.com/products/seo-friendly-images">Click to learn what is new</a></p><p style="text-align:right"><a href="options-general.php?page=seo-image/seo-friendly-images.php&notice=1">hide</a></p></div>';
25
+ }
26
+
27
+ // Options Page
28
+ function seo_friendly_images_options_page() {
29
+ global $seo_friendly_images_localversion;
30
+
31
+ $status=seo_friendly_images_getinfo();
32
+ $theVersion = ( isset($status[1]) ? $status[1] : '');
33
+ $theMessage = ( isset($status[3]) ? $status[3] : '');
34
+
35
+ if( (version_compare(strval($theVersion), strval($seo_friendly_images_localversion), '>') == 1) ) {
36
+ $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br/>'.$theMessage;
37
+ _e('<div id="message" class="updated fade"><p>' . $msg . '</p></div>');
38
+ }
39
+
40
+ // If form was submitted
41
+ if (isset($_POST['submitted'])) {
42
+ $alt_text=(!isset($_POST['alttext'])? '': $_POST['alttext']);
43
+ $title_text=(!isset($_POST['titletext'])? '': $_POST['titletext']);
44
+ $override=(!isset($_POST['override'])? 'off': 'on');
45
+ $override_title=(!isset($_POST['override_title'])? 'off': 'on');
46
+ update_option('seo_friendly_images_alt', $alt_text);
47
+ update_option('seo_friendly_images_title', $title_text );
48
+ update_option('seo_friendly_images_override', $override );
49
+ update_option('seo_friendly_images_override_title', $override_title );
50
+
51
+ $msg_status = 'SEO Friendly Images options saved.';
52
+
53
+ // Show message
54
+ _e('<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>');
55
+ }
56
+
57
+ if (isset($_GET['notice'])) {
58
+ if ($_GET['notice']==1) {
59
+ update_option('seo_friendly_images_notice', 1);
60
+ }
61
+ }
62
+
63
+ // Fetch code from DB
64
+ $alt_text = get_option('seo_friendly_images_alt');
65
+ $title_text = get_option('seo_friendly_images_title');
66
+ $override =( get_option('seo_friendly_images_override')=='on' ) ? "checked":"";
67
+ $override_title =( get_option('seo_friendly_images_override_title')=='on' ) ? "checked":"";
68
+
69
+ global $sfi_plugin_url;
70
+ $imgpath=$sfi_plugin_url.'/i';
71
+ $action_url=$_SERVER['REQUEST_URI'];
72
+
73
+ // Configuration Page
74
+ echo <<<END
75
+ <div class="wrap">
76
+ <h2>SEO Friendly Images $seo_friendly_images_localversion</h2>
77
+ <div id="poststuff" style="margin-top:10px;">
78
+ <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
79
+ <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=2&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BFriendly%2BImages"></iframe>
80
+ </div>
81
+ </div>
82
+ <div id="mainblock" style="width:710px">
83
+ <form name="sfiform" action="$action_url" method="post">
84
+ <div class="dbx-content">
85
+ <input type="hidden" name="submitted" value="1" />
86
+ <h2>General Options</h2>
87
+ <p>SEO Friendly Images automatically adds alt and title attributes to all your images in all your posts specified by parameters below.</p>
88
+ <p>You can enter any text in the field including two special tags:</p>
89
+ <ul>
90
+ <li>%title - replaces post title</li>
91
+ <li>%name - replaces image file name (without extension)</li>
92
+ <li>%category - replaces post category</li>
93
+ <li>%tags - replaces post tags</li>
94
+ </ul>
95
+ <h4>Images options</h4>
96
+ <div>
97
+ <label for="alt_text"><b>ALT</b> attribute (example: %name %title)</label><br>
98
+ <input style="border:1px solid #D1D1D1;width:165px;" id="alt_text" name="alttext" value="$alt_text"/>
99
+ </div>
100
+ <br>
101
+ <div>
102
+ <label for="title_text"><b>TITLE</b> attribute (example: %name photo)</label><br>
103
+ <input style="border:1px solid #D1D1D1;width:165px;" id="title_text" name="titletext" value="$title_text"/>
104
+ </div>
105
+ <br/>
106
+ <div>
107
+ <input id="check1" type="checkbox" name="override" $override />
108
+ <label for="check1">Override default Wordpress image alt tag (recommended)</label>
109
+ </div>
110
+ <br/>
111
+ <div>
112
+ <input id="check2" type="checkbox" name="override_title" $override_title />
113
+ <label for="check2">Override default Wordpress image title</label>
114
+ </div>
115
+ <br/><br/>
116
+ <p>
117
+ Example:<br/>
118
+ In a post titled Car Pictures there is a picture named Ferrari.jpg<br/><br/>
119
+ Setting alt attribute to "%name %title" will produce alt="Ferrari Car Pictures"<br/>
120
+ Setting title attribute to "%name photo" will produce title="Ferrari photo"
121
+ </p>
122
+ <div class="submit"><input type="submit" name="Submit" value="Update options" /></div>
123
+ </div>
124
+ </form>
125
+ <br/><br/><h3>&nbsp;</h3>
126
+ </div>
127
+ </div>
128
+ <h5>Another fine WordPress plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
129
+ END;
130
+ }
131
+
132
+ // Add Options Page
133
+ add_action('admin_menu', 'seo_friendly_images_add_pages');
134
+
135
+ function remove_extension($name) {
136
+ return preg_replace('/(.+)\..*$/', '$1', $name);
137
+ }
138
+ function seo_friendly_images_process($matches) {
139
+ global $post;
140
+ $title = $post->post_title;
141
+ $alttext_rep = get_option('seo_friendly_images_alt');
142
+ $titletext_rep = get_option('seo_friendly_images_title');
143
+ $override= get_option('seo_friendly_images_override');
144
+ $override_title= get_option('seo_friendly_images_override_title');
145
+
146
+ # take care of unsusal endings
147
+ $matches[0]=preg_replace('|([\'"])[/ ]*$|', '\1 /', $matches[0]);
148
+
149
+ ### Normalize spacing around attributes.
150
+ $matches[0] = preg_replace('/\s*=\s*/', '=', substr($matches[0],0,strlen($matches[0])-2));
151
+ ### Get source.
152
+
153
+ preg_match('/src\s*=\s*([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/', $matches[0], $source);
154
+
155
+ $saved=$source[2];
156
+
157
+ ### Swap with file's base name.
158
+ preg_match('%[^/]+(?=\.[a-z]{3}\z)%', $source[2], $source);
159
+ ### Separate URL by attributes.
160
+ $pieces = preg_split('/(\w+=)/', $matches[0], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
161
+ ### Add missing pieces.
162
+
163
+ $postcats=get_the_category();
164
+ $cats="";
165
+ if ($postcats) {
166
+ foreach($postcats as $cat) {
167
+ $cats = $cat->slug. ' '. $cats;
168
+ }
169
+ }
170
+
171
+ $posttags = get_the_tags();
172
+
173
+ $tags="";
174
+ if ($posttags) {
175
+ foreach($posttags as $tag) {
176
+ $tags = $tag->name . ' ' . $tags;
177
+ }
178
+ }
179
+
180
+ if (!in_array('title=', $pieces) || $override_title=="on") {
181
+ $titletext_rep=str_replace("%title", $post->post_title, $titletext_rep);
182
+ $titletext_rep=str_replace("%name", $source[0], $titletext_rep);
183
+ $titletext_rep=str_replace("%category", $cats, $titletext_rep);
184
+ $titletext_rep=str_replace("%tags", $tags, $titletext_rep);
185
+
186
+ $titletext_rep=str_replace('"', '', $titletext_rep);
187
+ $titletext_rep=str_replace("'", "", $titletext_rep);
188
+
189
+ $titletext_rep=str_replace("_", " ", $titletext_rep);
190
+ $titletext_rep=str_replace("-", " ", $titletext_rep);
191
+ //$titletext_rep=ucwords(strtolower($titletext_rep));
192
+ if (!in_array('title=', $pieces)) {
193
+ array_push($pieces, ' title="' . $titletext_rep . '"');
194
+ } else {
195
+ $key=array_search('title=',$pieces);
196
+ $pieces[$key+1]='"'.$titletext_rep.'" ';
197
+ }
198
+ }
199
+
200
+ if (!in_array('alt=', $pieces) || $override=="on" ) {
201
+ $alttext_rep=str_replace("%title", $post->post_title, $alttext_rep);
202
+ $alttext_rep=str_replace("%name", $source[0], $alttext_rep);
203
+ $alttext_rep=str_replace("%category", $cats, $alttext_rep);
204
+ $alttext_rep=str_replace("%tags", $tags, $alttext_rep);
205
+ $alttext_rep=str_replace("\"", "", $alttext_rep);
206
+ $alttext_rep=str_replace("'", "", $alttext_rep);
207
+ $alttext_rep=(str_replace("-", " ", $alttext_rep));
208
+ $alttext_rep=(str_replace("_", " ", $alttext_rep));
209
+
210
+ if (!in_array('alt=', $pieces)) {
211
+ array_push($pieces, ' alt="' . $alttext_rep . '"');
212
+ } else {
213
+ $key=array_search('alt=',$pieces);
214
+ $pieces[$key+1]='"'.$alttext_rep.'" ';
215
+ }
216
+ }
217
+ return implode('', $pieces).' /';
218
+ }
219
+ function seo_friendly_images($content) {
220
+ return preg_replace_callback('/<img[^>]+/', 'seo_friendly_images_process', $content);
221
+ }
222
+ add_filter('the_content', 'seo_friendly_images', 100);
223
+ //add_action( 'after_plugin_row', 'seo_friendly_images_check_plugin_version' );
224
+
225
+ function seo_friendly_images_getinfo() {
226
+ $checkfile = "http://svn.wp-plugins.org/seo-image/trunk/seo-friendly-images.chk";
227
+ $status=array();
228
+ return $status;
229
+ $vcheck = wp_remote_fopen($checkfile);
230
+
231
+ if($vcheck) {
232
+ $version = $seo_friendly_images_localversion;
233
+ $status = explode('@', $vcheck);
234
+ return $status;
235
+ }
236
+ }
237
+ function seo_friendly_images_check_plugin_version($plugin) {
238
+ global $plugindir, $seo_friendly_images_localversion;
239
+
240
+ if( strpos($plugin,'seo-friendly-images.php')!==false ) {
241
+ $status=seo_friendly_images_getinfo();
242
+ $theVersion = $status[1];
243
+ $theMessage = $status[3];
244
+
245
+ if( (version_compare(strval($theVersion), strval($seo_friendly_images_localversion), '>') == 1) ) {
246
+ $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br/>'.$theMessage;
247
+ echo '<td colspan="5" class="plugin-update" style="line-height:1.2em;">'.$msg.'</td>';
248
+ } else {
249
+ return;
250
+ }
251
+ }
252
+ }
253
+ function seo_friendly_images_install() {
254
+ if(!get_option('seo_friendly_images_alt')) {
255
+ add_option('seo_friendly_images_alt', '%name %title');
256
+ }
257
+ if(!get_option('seo_friendly_images_title')) {
258
+ add_option('seo_friendly_images_title', '%title');
259
+ }
260
+ if(get_option('seo_friendly_images_override' == '') || !get_option('seo_friendly_images_override')) {
261
+ add_option('seo_friendly_images_override', 'on');
262
+ }
263
+ if(get_option('seo_friendly_images_override_title' == '') || !get_option('seo_friendly_images_override_title')) {
264
+ add_option('seo_friendly_images_override_title', 'off');
265
+ }
266
+ if (!get_option('seo_friendly_images_notice'))
267
+ add_action('admin_notices', 'seo_friendly_images_admin_notice');
268
+ }
269
+
270
+ add_action( 'plugins_loaded', 'seo_friendly_images_install' );