Changeset 710036
- Timestamp:
- 05/08/2013 06:34:26 PM (13 years ago)
- Location:
- transparent-image-watermark-plugin/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (3 diffs)
-
transparent-watermark-loader.php (modified) (1 diff)
-
transparent-watermark-plugin.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
transparent-image-watermark-plugin/trunk/readme.txt
r709903 r710036 5 5 Requires at least: 3.3 6 6 Tested up to: 3.5.1 7 Stable tag: 2.3. 97 Stable tag: 2.3.10 8 8 Donate link: http://MyWebsiteAdvisor.com/donations/ 9 9 … … 20 20 The watermark preview feature allows for easy testing of the plugin settings. 21 21 The watermark size is controlled as a percentage of the target image, 50% means the watermark will be half the width of the target image. 22 Watermarks are now removable with the new backup system, any images watermarked while the new backup system is enabled are able to be restored to the original image. 22 23 23 24 … … 203 204 == Changelog == 204 205 206 = 2.3.10 = 207 * more improvements to the edit-media page, condensed form to display better on the insert media sidebar 208 * fixed typos in readme 209 205 210 206 211 = 2.3.9 = 207 212 * fixed issue causing error message when deleting non-watermarked image. 208 213 * fixed ereg_replace depricated message 209 * updated the edit media page to display the image size names, ra hter than the image dimensions214 * updated the edit media page to display the image size names, rather than the image dimensions 210 215 211 216 -
transparent-image-watermark-plugin/trunk/transparent-watermark-loader.php
r709903 r710036 4 4 Plugin URI: http://MyWebsiteAdvisor.com/tools/wordpress-plugins/transparent-image-watermark/ 5 5 Description: Add transparent PNG image watermark to your uploaded images. 6 Version: 2.3. 96 Version: 2.3.10 7 7 Author: MyWebsiteAdvisor 8 8 Author URI: http://MyWebsiteAdvisor.com -
transparent-image-watermark-plugin/trunk/transparent-watermark-plugin.php
r709903 r710036 6 6 7 7 //plugin version number 8 private $version = "2.3. 9";8 private $version = "2.3.10"; 9 9 10 10 private $debug = false; … … 79 79 80 80 add_filter('attachment_fields_to_edit', array(&$this, 'attachment_field_add_watermark'), 10, 2); 81 82 81 83 82 } 84 83 … … 118 117 119 118 120 public function add_watermark_js(){ 121 122 wp_enqueue_script('transparent-watermark-script', $this->plugin_url . "watermark.js"); 123 124 } 125 126 127 128 129 130 function delete_attachment_watermark_backups($attachment_id){ 131 132 $bk_meta = get_post_meta($attachment_id, '_watermark_backups', true); 133 134 if(isset($bk_meta) && is_array($bk_meta)){ 135 foreach($bk_meta as $key => $info){ 136 @unlink( $info['bk_path'] ); 137 } 138 } 139 140 } 141 142 143 144 145 function revert_watermarks(){ 146 147 check_ajax_referer( 'revert-watermarks', 'security' ); 148 149 $attachment_id = $_POST['post_id']; 150 151 $bk_meta = get_post_meta($attachment_id, '_watermark_backups', true); 152 153 foreach($bk_meta as $key => $info){ 154 155 @unlink( $info['original_path'] ); 156 copy( $info['bk_path'] , $info['original_path'] ); 157 @unlink( $info['bk_path'] ); 158 echo "Removed Watermark: " . $info['original_path'] . "\r\n"; 159 160 } 161 162 delete_post_meta($attachment_id, '_watermark_backups'); 163 164 die(); 165 166 } 119 167 120 168 121 … … 1112 1065 public function attachment_field_add_watermark($form_fields, $post){ 1113 1066 if ($post->post_mime_type == 'image/jpeg' || $post->post_mime_type == 'image/gif' || $post->post_mime_type == 'image/png') { 1114 1115 1067 1116 1068 $form_js = "<style> 1117 1069 #watermark_preview { … … 1134 1086 1135 1087 </style>"; 1136 1137 /** 1138 1139 $attachment_info = wp_get_attachment_metadata($post->ID); 1140 1141 $bk_meta = get_post_meta($post->ID, '_watermark_backups', true); 1142 1143 $sizes = array(); 1144 1145 foreach($attachment_info['sizes'] as $size){ 1146 1147 $sizes[$size['width']] = $size; 1148 1149 1150 } 1151 1152 //$sizes = array_unique($sizes); 1153 krsort($sizes); 1154 1155 1156 1157 $upload_dir = wp_upload_dir(); 1158 1159 $url_info = parse_url($post->guid); 1160 $url_info['path'] = str_replace("/wp-content/uploads/", "/", $url_info['path']); 1161 1162 $filepath = $upload_dir['basedir'] . $url_info['path']; 1163 1164 1165 1166 $path_info = pathinfo($url_info['path']); 1167 1168 $base_filename = $path_info['basename']; 1169 $base_path = str_replace($base_filename, "", $post->guid); 1170 1171 1172 1173 $url_info = parse_url($post->guid); 1174 $url_info['path'] = ereg_replace("/wp-content/uploads/", "/", $url_info['path']); 1175 1176 $path_info = pathinfo($post->guid); 1177 $url_base = $path_info['dirname']."/".$path_info['filename'] . "." . $path_info['extension']; 1178 $filepath = ABSPATH . str_replace(get_option('siteurl'), "", $url_base); 1179 $filepath = str_replace("//", "/", $filepath); 1180 **/ 1181 1088 1182 1089 1183 1090 … … 1226 1133 1227 1134 $checked = ""; 1135 $disabled = ""; 1228 1136 1229 1137 if(isset($bk_meta) && is_array($bk_meta)){ … … 1231 1139 if($bk['original_path'] == $file_path){ 1232 1140 $checked = 'checked="checked" '; 1141 $disabled = 'disabled="disabled" '; 1233 1142 } 1234 1143 } 1235 1144 } 1236 1145 1237 $form_html = "<p><input type='checkbox' name='attachment_size[]' value='".$post->guid."' style='width:auto;' ".$checked." class='attachment_sizes'> Original";1146 $form_html = "<p><input type='checkbox' name='attachment_size[]' value='".$post->guid."' style='width:auto;' ".$checked." " . $disabled . " class='attachment_sizes'> Original"; 1238 1147 $form_html .= " <a class='watermark_preview' href='".$post->guid."?". $time ."' title='$base_filename Preview' target='_blank'>" . $base_filename . "</a></p>"; 1239 1148 $form_html .= $form_js; … … 1253 1162 1254 1163 $checked = ""; 1164 $disabled = ""; 1255 1165 1256 1166 if( isset($bk_meta) && is_array($bk_meta) ){ … … 1258 1168 if($bk['original_path'] == $current_filepath){ 1259 1169 $checked = 'checked="checked" '; 1170 $disabled = 'disabled="disabled" '; 1260 1171 } 1261 1172 } 1262 1173 } 1263 1174 1264 $form_html = "<p><input type='checkbox' name='attachment_size[]' value='".$base_path.$size['file']."' style='width:auto;' ".$checked." class='attachment_sizes'> ".$size['width'] . "x" . $size['height'];1175 $form_html = "<p><input type='checkbox' name='attachment_size[]' value='".$base_path.$size['file']."' style='width:auto;' ".$checked." " . $disabled . " class='attachment_sizes'> ".ucwords($name); 1265 1176 $form_html .= " <a class='watermark_preview' title='".$size['file']." Preview' href='".$image_link."?". $time ."' target='_blank'>" . $size['file'] . "</a></p>"; 1266 1177 … … 1403 1314 1404 1315 1316 1317 1318 1319 1320 1321 // add plugin js file 1322 public function add_watermark_js(){ 1323 1324 wp_enqueue_script('transparent-watermark-script', $this->plugin_url . "watermark.js"); 1325 1326 } 1327 1328 1329 1330 1331 // deletes backup image files when the main image attachment is deleted 1332 function delete_attachment_watermark_backups($attachment_id){ 1333 1334 $bk_meta = get_post_meta($attachment_id, '_watermark_backups', true); 1335 1336 if(isset($bk_meta) && is_array($bk_meta)){ 1337 foreach($bk_meta as $key => $info){ 1338 @unlink( $info['bk_path'] ); 1339 } 1340 } 1341 1342 } 1343 1344 1345 1346 // overwrite the watermarked copy with the backup copy 1347 function revert_watermarks(){ 1348 1349 check_ajax_referer( 'revert-watermarks', 'security' ); 1350 1351 $attachment_id = $_POST['post_id']; 1352 1353 $bk_meta = get_post_meta($attachment_id, '_watermark_backups', true); 1354 1355 foreach($bk_meta as $key => $info){ 1356 1357 @unlink( $info['original_path'] ); 1358 copy( $info['bk_path'] , $info['original_path'] ); 1359 @unlink( $info['bk_path'] ); 1360 echo "Removed Watermark: " . $info['original_path'] . "\r\n"; 1361 1362 } 1363 1364 delete_post_meta($attachment_id, '_watermark_backups'); 1365 1366 die(); 1367 1368 } 1369 1370 1371 1405 1372 1406 1373 }
Note: See TracChangeset
for help on using the changeset viewer.