Version Description
- Minor issues fixed (thanks Dewey Bushaw)
Download this release
Release Info
| Developer | freediver |
| Plugin | |
| Version | 2.7.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.7.0 to 2.7.1
- readme.txt +3 -0
- 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.
|
| 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 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
{
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
<
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
<
|
| 112 |
-
<
|
| 113 |
-
<
|
| 114 |
-
|
| 115 |
-
<
|
| 116 |
-
<
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
<
|
| 126 |
-
|
| 127 |
-
</div
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
}
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
$
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
}
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 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¬ice=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> </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' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
