Ticket #6813: pess-this-selection-fix.patch
| File pess-this-selection-fix.patch, 17.7 kB (added by azaozz, 5 months ago) |
|---|
-
wp-admin/css/press-this.css
old new 231 231 } 232 232 233 233 #photo_saving { 234 margin-bottom: 8px; 234 margin: 0 8px 8px; 235 vertical-align: middle; 235 236 } 236 237 237 238 #img_container { … … 302 303 #jaxtag { 303 304 clear: both; 304 305 padding-left: 1em; 306 margin: 0; 305 307 } 306 308 307 309 #tagchecklist { … … 348 350 -webkit-border-bottom-right-radius: 3px; 349 351 border-bottom-right-radius: 3px; 350 352 margin: 0; 351 padding: 0;353 padding: 10px; 352 354 } 353 355 .submitbox { 354 356 width: 100%; … … 363 365 .submitbox .submit input { 364 366 border: none; 365 367 text-align: left; 366 padding: 12px 10px 10px 10px;368 padding: 6px 4px; 367 369 font-size: 12px; 368 margin: 10px; 369 370 margin: 2px; 370 371 -moz-border-radius: 3px; 371 372 -khtml-border-radius: 3px; 372 373 -webkit-border-radius: 3px; -
wp-admin/press-this.php
old new 10 10 $translation_table[chr(34)] = '"'; 11 11 $translation_table[chr(38)] = '&'; 12 12 $translation_table[chr(39)] = '''; 13 return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table)); 13 return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table)); 14 14 } 15 15 function press_it() { 16 16 // define some basic variables 17 $quick['post_status'] = $_REQUEST['post_status'];17 $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft'; 18 18 $quick['post_category'] = $_REQUEST['post_category']; 19 19 $quick['tags_input'] = $_REQUEST['tags_input']; 20 20 $quick['post_title'] = $_REQUEST['post_title']; 21 21 $quick['post_content'] = ''; 22 22 23 $posted = str_replace('<br />', "\n", str_replace('<p>', '', $_REQUEST['content'])); 24 $posted = str_replace('</p>', "\n\n", $posted); 25 23 26 // insert the post with nothing in it, to get an ID 24 27 $post_ID = wp_insert_post($quick, true); 25 28 26 29 $content = ''; 27 30 switch ( $_REQUEST['post_type'] ) { 28 31 case 'text': 29 32 case 'quote': 30 $content .= $ _REQUEST['content'];33 $content .= $posted; 31 34 break; 32 35 33 36 case 'photo': 34 $content = $ _REQUEST['content'];35 36 foreach( $_REQUEST['photo_src'] as $key => $image) {37 $content = $posted; 38 39 foreach( (array) $_REQUEST['photo_src'] as $key => $image) { 37 40 // escape quote for matching 38 41 $quoted = preg_quote2($image); 39 42 40 43 // see if files exist in content - we don't want to upload non-used selected files. 41 preg_match('/'.$quoted.'/', $_REQUEST['content'], $matches[0]);42 if( $matches[0]) {44 // preg_match('/'.$quoted.'/', $posted, $matches); 45 if( strpos($posted, $quoted) !== false ) { 43 46 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 44 47 // Replace the POSTED content <img> with correct uploaded ones. 45 48 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 46 49 } 47 50 } 48 51 49 52 break; 50 53 51 54 case "video": 52 55 if($_REQUEST['embed_code']) 53 56 $content .= $_REQUEST['embed_code']."\n\n"; 54 $content .= $ _REQUEST['content'];55 break; 57 $content .= $posted; 58 break; 56 59 } 57 60 // set the post_content 58 $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content));61 $quick['post_content'] = preg_replace("/\n\n+/", "\n\n", $content); 59 62 60 63 // error handling for $post 61 64 if ( is_wp_error($post_ID)) { … … 65 68 } elseif ( is_wp_error($upload)) { 66 69 wp_die($upload); 67 70 wp_delete_post($post_ID); 68 } else { 71 } else { 69 72 $quick['ID'] = $post_ID; 70 73 wp_update_post($quick); 71 74 } … … 91 94 do_action('admin_head'); 92 95 ?> 93 96 </head> 94 <body class="press-this"> 95 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div> 97 <body class="press-this"> 98 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div> 96 99 <div id="footer"> 97 100 <p><?php 98 101 do_action('in_admin_footer', ''); … … 100 103 echo __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>'); 101 104 ?></p> 102 105 </div> 103 <?php do_action('admin_footer', ''); ?> 106 <?php do_action('admin_footer', ''); ?> 104 107 </body> 105 108 </html> 106 109 <?php die; … … 109 112 // Ajax Requests 110 113 $title = wp_specialchars(aposfix(stripslashes($_GET['t']))); 111 114 112 $selection = str_replace("\n", "<br />", aposfix( stripslashes($_GET['s']) ) ); 115 $selection = trim( aposfix( stripslashes($_GET['s']) ) ); 116 if ( ! empty($selection) ) { 117 $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection); 118 $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>'; 119 } 120 113 121 $url = clean_url($_GET['u']); 114 122 $image = $_GET['i']; 115 123 … … 118 126 jQuery('.cancel').click(function() { 119 127 tb_remove(); 120 128 }); 121 129 122 130 jQuery('.select').click(function() { 123 131 image_selector(); 124 132 }); … … 127 135 <div class="titlewrap"> 128 136 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 129 137 </div> 130 138 131 139 <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" /> 132 140 <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p> 133 141 134 142 <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p> 135 143 <?php die; 136 144 } … … 140 148 jQuery('.cancel').click(function() { 141 149 tb_remove(); 142 150 }); 143 151 144 152 jQuery('.select').click(function() { 145 153 image_selector(); 146 154 }); … … 149 157 <div class="titlewrap"> 150 158 <input id="this_photo" name="this_photo" class="text" onkeypress="if(event.keyCode==13) image_selector();" /> 151 159 </div> 152 153 160 161 154 162 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 155 163 <div class="titlewrap"> 156 164 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 157 165 </div> 158 166 159 167 <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p> 160 168 <?php die; 161 169 } … … 175 183 176 184 $content = wp_remote_fopen($uri); 177 185 if ( false === $content ) return ''; 178 186 179 187 $host = parse_url($uri); 180 188 181 189 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))(\2)([^>\/]*)\/*>/is'; 182 190 preg_match_all($pattern, $content, $matches); 183 191 184 192 if ( empty($matches[1]) ) return ''; 185 193 186 194 $sources = array(); 187 195 foreach ($matches[3] as $src) { 188 196 if(strpos($src, 'http') === false) … … 190 198 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 191 199 else 192 200 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 193 201 194 202 $sources[] = clean_url($src); 195 203 } 196 204 return "'" . implode("','", $sources) . "'"; 197 205 } 198 206 199 207 $url = urldecode($url); 200 208 $url = str_replace(' ', '%20', $url); 201 209 echo 'new Array('.get_images_from_uri($url).')'; 202 die; 210 die; 203 211 } 204 212 205 213 if($_REQUEST['ajax'] == 'photo_js') { ?> … … 216 224 dataType : "script" 217 225 }).responseText 218 226 ); 219 227 220 228 for (i = 0; i < my_src.length; i++) { 221 229 img = new Image(); 222 230 img.src = my_src[i]; … … 227 235 skip = true; 228 236 aspect = img.width / img.height; 229 237 scale = (aspect > 1) ? (75 / img.width) : (75 / img.height); 230 238 231 239 w = img.width; 232 240 h = img.height; 233 241 234 242 if (scale < 1) { 235 243 w = parseInt(img.width * scale); 236 244 h = parseInt(img.height * scale); … … 239 247 } 240 248 if (!skip) strtoappend += '<a href="?ajax=thickbox&i=' + img.src + '&u=<?php echo $url; ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; 241 249 } 242 250 243 251 function pick(img, desc) { 244 252 if (img) { 245 253 length = jQuery('.photolist input').length; … … 251 259 tinyMCE.activeEditor.resizeToContent(); 252 260 return false; 253 261 } 254 262 255 263 function image_selector() { 256 264 tb_remove(); 257 265 desc = jQuery('#this_photo_description').val(); … … 259 267 pick(src, desc); 260 268 return false; 261 269 } 262 270 263 271 jQuery(document).ready(function() { 264 272 jQuery('#img_container').html(strtoappend); 265 273 jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500'); 266 274 tb_init('a.thickbox, area.thickbox, input.thickbox'); 267 275 }); 268 276 269 277 <?php die; 270 278 } 271 279 … … 309 317 sl.markDone(base + '/themes/advanced/langs/' + ln + '.js'); 310 318 sl.markDone(base + '/themes/advanced/langs/' + ln + '_dlg.js'); 311 319 })(); 312 320 313 321 tinyMCE.init({ 314 322 mode: "textareas", 315 323 editor_selector: "mceEditor", … … 330 338 remove_script_host : false, 331 339 convert_urls : false, 332 340 apply_source_formatting : false, 333 remove_linebreaks : false,341 remove_linebreaks : true, 334 342 accessibility_focus : false, 335 343 tab_focus : ":next", 336 344 plugins : "safari,inlinepopups", … … 345 353 346 354 // add the quickadd form 347 355 jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="submit" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" onclick="return false;" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); 348 356 349 357 jQuery('#tagadd').click( tag_flush_to_text ); 350 358 jQuery('#newtag').focus(function() { 351 359 if ( this.value == postL10n.addTag ) … … 359 367 // auto-save tags on post save/publish 360 368 jQuery('#publish').click( tag_save_on_publish ); 361 369 jQuery('#save-post').click( tag_save_on_publish ); 362 370 363 371 function set_menu(type) { 364 372 jQuery('#text_button').removeClass('ui-tabs-selected'); 365 373 jQuery('#menu li').removeClass('ui-tabs-selected'); 366 374 jQuery('#' + type + '_button').addClass('ui-tabs-selected'); 367 375 jQuery("#post_type").val(type); 368 376 } 369 377 370 378 function set_editor(text) { 371 if (tinyMCE.activeEditor) tinyMCE.activeEditor.setContent('');372 if (tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text);379 if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>'; 380 if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text); 373 381 } 374 382 375 383 function append_editor(text) { 376 if (tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text);384 if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceInsertContent', false, text); 377 385 } 378 386 379 387 function set_title(title) { jQuery("#content_type").text(title); } 380 388 381 389 function show(tab_name) { … … 386 394 set_menu('text'); 387 395 set_title('<?php _e('Post') ?>'); 388 396 <?php if ($selection) { ?> 389 set_editor( "<?php echo $selection; ?>");397 set_editor('<?php echo $selection; ?>'); 390 398 <?php } else { ?> 391 set_editor( "<a href='<?php echo $url ?>'><?php echo $title; ?></a>");399 set_editor('<p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>'); 392 400 <?php } ?> 393 401 return false; 394 402 break; 395 403 case 'quote' : 396 404 set_menu('quote'); 397 405 set_title('<?php _e('Quote') ?>'); 398 set_editor( "<blockquote><p><?php echo $selection; ?> </p><p><cite><a href='<?php echo $url; ?>'><?php echo $title; ?> </a> </cite> </p></blockquote>");406 set_editor('<blockquote><?php echo $selection; ?> <p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?> </a> </cite> </p></blockquote>'); 399 407 return false; 400 408 break; 401 409 case 'video' : … … 405 413 jQuery('body').addClass('video_split'); 406 414 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() { 407 415 <?php 416 $content = ''; 408 417 if ( preg_match("/youtube\.com\/watch/i", $url) ) { 409 418 list($domain, $video_id) = split("v=", $url); 410 419 $content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>'; 411 420 412 421 } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { 413 422 list($domain, $video_id) = split(".com/", $url); 414 423 $content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /> <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>'; 415 424 416 425 if ( trim($selection) == '' ) 417 $selection = '< a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a>';418 419 } else {426 $selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>'; 427 428 } elseif ( strpos( $selection, '<object' ) !== false ) { 420 429 $content = $selection; 421 430 } 422 423 431 ?> 424 432 jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>'); 425 426 set_editor( "<?php echo $title; ?>");433 434 set_editor('<?php echo $title; ?>'); 427 435 }); 428 436 return false; 429 437 break; … … 431 439 set_menu('photo'); 432 440 set_title('<?php _e('Post') ?>'); 433 441 <?php if ($selection) { ?> 434 set_editor( "<?php echo $selection; ?>");442 set_editor('<?php echo $selection; ?>'); 435 443 <?php } else { ?> 436 set_editor( "<a href='<?php echo $url ?>'><?php echo $title; ?></a>");444 set_editor('<p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>'); 437 445 <?php } ?> 438 446 jQuery('#extra_fields').show(); 439 447 jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>'); … … 452 460 break; 453 461 } 454 462 } 455 463 456 464 jQuery(document).ready(function() { 457 465 jQuery('#menu li').click(function (){ 458 466 tab_name = this.id.split('_'); … … 491 499 <div class="titlewrap"> 492 500 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 493 501 </div> 494 502 495 503 <div id="extra_fields" style="display: none"></div> 496 504 497 505 <div class="editor_area"> 498 506 <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2> 499 507 <div class="editor-container"> … … 516 524 <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> 517 525 <div id="tagchecklist"></div> 518 526 </div> 519 <div id="post_status"> 520 <input type="radio" name="post_status" value="publish" checked="checked" id="published" /> <label for="published"><?php _e('Published'); ?></label> 521 <input type="radio" name="post_status" value="draft" id="unpublished" /> <label for="unpublished"><?php _e('Unpublished'); ?></label> 522 </div> 527 523 528 <p class="submit"> 524 <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 529 <input type="submit" name="draft" value="<?php _e('Save') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 530 <input type="submit" name="publish" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 525 531 <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 526 532 </p> 533 </div> 527 534 </div> 528 535 </form> 529 536 </body> -
wp-includes/script-loader.php
old new 229 229 $styles->add( 'dashboard', '/wp-admin/css/dashboard.css' ); 230 230 $styles->add( 'install', '/wp-admin/css/install.css', array(), '20080708' ); 231 231 $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css' ); 232 $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '200807 04' );232 $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20080710' ); 233 233 $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20080613' ); 234 234 $styles->add( 'login', '/wp-admin/css/login.css' ); 235 235
