Ticket #6813: press-this-noel-6-16-08.diff
| File press-this-noel-6-16-08.diff, 7.9 kB (added by noel, 6 months ago) |
|---|
-
wp-admin/press-this.php
old new 6 6 <?php 7 7 function press_it() { 8 8 #define some basic variables 9 $quick['post_status'] = 'publish';9 $quick['post_status'] = $_REQUEST['post_status']; 10 10 $quick['post_category'] = $_REQUEST['post_category']; 11 11 $quick['tags_input'] = $_REQUEST['tags_input']; 12 12 $quick['post_title'] = $_REQUEST['post_title']; … … 42 42 break; 43 43 } 44 44 # set the post_content 45 $quick['post_content'] = $content;45 $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content)); 46 46 47 47 #error handling for $post 48 48 if ( is_wp_error($post_ID) ) { … … 57 57 return $post_ID; 58 58 } 59 59 60 61 function category_div() { ?>62 <div id="categories">63 <div class="submitbox" id="submitpost">64 <div id="previewview"></div>65 <div class="inside">66 <h2><?php _e('Categories') ?></h2>67 <div id="categories-all">68 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">69 <?php wp_category_checklist() ?>70 </ul>71 </div>72 <h2><?php _e('Tags') ?></h2>73 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p>74 <div id="tagchecklist"></div>75 76 </div>77 <p class="submit">78 <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/>79 <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/>80 </p>81 </div>82 <?php }83 84 60 # For submitted posts. 85 61 if ( 'post' == $_REQUEST['action'] ) { 86 62 check_admin_referer('press-this'); $post_ID = press_it(); ?> … … 110 86 111 87 // Ajax Requests 112 88 $title = wp_specialchars(stripslashes($_GET['t'])); 113 $selection = trim( wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s']))));114 $url = $_GET['u'];89 $selection = trim(str_replace('\\n', "<br />", wp_specialchars(js_escape($_GET['s'])))); 90 $url = clean_url($_GET['u']); 115 91 $image = $_GET['i']; 116 92 if($_REQUEST['ajax'] == 'thickbox') { ?> 117 93 <script type="text/javascript" charset="utf-8"> … … 130 106 jQuery('.select').click(function() { 131 107 image_selector(); 132 108 }); 133 134 109 </script> 135 110 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 136 111 <div class="titlewrap"> … … 154 129 } 155 130 156 131 if($_REQUEST['ajax'] == 'photo_images') { 157 error_log('photo images');158 132 function get_images_from_uri($uri) { 159 133 if(preg_match('/\.(jpg|png|gif)/', $uri)) 160 134 return "'".$uri."'"; 161 135 162 136 $content = wp_remote_fopen($uri); 163 $host = parse_url($uri);164 165 137 if ( false === $content ) return ''; 166 138 139 $host = parse_url($uri); 140 167 141 $pattern = '/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is'; 168 142 preg_match_all($pattern, $content, $matches); 169 if ( empty($matches[1]) ) { error_log('empty'); return ''; }; 143 144 if ( empty($matches[1]) ) return ''; 145 170 146 $sources = array(); 171 172 147 foreach ($matches[3] as $src) { 173 error_log($src); 174 #if ( false !== strpos($src, '&') ) continue; 175 if(strpos($src, 'http') === false) { 176 if(strpos($src, '../') === false && strpos($src, './') === false) { 177 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 178 } else { 179 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 180 } 181 } 182 183 $sources[] = $src; 148 if(strpos($src, 'http') === false) 149 if(strpos($src, '../') === false && strpos($src, './') === false) 150 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 151 else 152 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 153 154 $sources[] = $src; 184 155 } 185 156 return "'" . implode("','", $sources) . "'"; 186 157 } … … 226 197 if (img.width && img.height) { 227 198 if (img.width * img.height < 2500) skip = true; 228 199 aspect = img.width / img.height; 229 if (aspect > 1) { // Image is wide 230 scale = 75 / img.width; 231 } else { // Image is tall or square 232 scale = 75 / img.height; 233 } 200 scale = (aspect > 1) ? (75 / img.width) : (75 / img.height); 201 234 202 if (scale < 1) { 235 203 w = parseInt(img.width * scale); 236 204 h = parseInt(img.height * scale); … … 252 220 <?php die; } 253 221 254 222 if($_REQUEST['ajax'] == 'photo') { ?> 255 256 223 <div class="photolist"></div> 257 258 224 <small><?php _e('Click images to select:') ?></small> 259 225 <div class="titlewrap"> 260 226 <div id="img_container"></div> 261 227 </div> 262 228 <?php die; } 263 264 229 ?> 265 230 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 266 231 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> … … 317 282 accessibility_focus : false, 318 283 tab_focus : ":next", 319 284 plugins : "safari,inlinepopups", 320 entities : "38,amp,60,lt,62,gt" 285 entities : "38,amp,60,lt,62,gt", 286 force_p_newlines : true 321 287 }); 322 288 <?php } ?> 323 289 … … 349 315 jQuery("#post_type").val(type); 350 316 } 351 317 function set_editor(text) { 318 352 319 if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); 353 320 if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 354 321 } … … 369 336 jQuery('#content_type').show(); 370 337 set_menu('text'); 371 338 set_title('<?php _e('Text') ?>'); 372 <?php if($selection) { ?> 373 set_editor('<?php echo '<p><a href="'.$url.'">'.$selection.'</a> </p> '; ?>'); 374 <?php } else { ?> 375 set_editor('<?php echo '<p><a href="'.$url.'">'.$title.'</a> </p> '; ?>'); 376 <?php } ?> 339 377 340 return false; 378 341 break; 379 342 case 'quote' : … … 499 462 </div> 500 463 501 464 </div> 502 <?php category_div(); ?> 465 <div id="categories"> 466 <div class="submitbox" id="submitpost"> 467 <div id="previewview"></div> 468 <div class="inside"> 469 <h2><?php _e('Categories') ?></h2> 470 <div id="categories-all"> 471 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 472 <?php wp_category_checklist() ?> 473 </ul> 474 </div> 475 <h2><?php _e('Tags') ?></h2> 476 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 477 <div id="tagchecklist"></div> 478 </div> 479 <label for="post_status" id="post_status"><input type="radio" name="post_status" value="publish" checked="checked" id="published" />Published <input type="radio" name="post_status" value="draft" id="unpubplished" /> Unpublished</label> 480 481 <p class="submit"> 482 <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 483 <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 484 </p> 485 </div> 486 487 503 488 </form> 504 489 505 490 </body> -
wp-admin/css/press-this.css
old new 111 111 .howto { 112 112 font-size: 11px; 113 113 } 114 #newtag { padding: 3px; }114 #newtag { width: 60%; padding: 3px; } 115 115 116 116 #wphead { 117 117 height: 2em; … … 451 451 } 452 452 #photo_saving { 453 453 margin-bottom: 8px; 454 } 455 456 #post_status { 457 margin-left: 10px; 458 margin-bottom: 1em; 459 display: block; 454 460 }
