SEO Friendly Images - Version 2.7.2

Version Description

  • Fixed incompatiblity with mapping plugin Leaflet Maps Marker
Download this release

Release Info

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

Code changes from version 2.7.1 to 2.7.2

Files changed (2) hide show
  1. readme.txt +3 -0
  2. seo-friendly-images.php +269 -269
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.1 =
27
  * Minor issues fixed (thanks Dewey Bushaw)
28
 
23
 
24
  == Changelog ==
25
 
26
+ = 2.7.2 =
27
+ * Fixed incompatiblity with mapping plugin [Leaflet Maps Marker](http://www.mapsmarker.com)
28
+
29
  = 2.7.1 =
30
  * Minor issues fixed (thanks Dewey Bushaw)
31
 
seo-friendly-images.php CHANGED
@@ -1,270 +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.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' );
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.2
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' );