Ticket #6813: press-this_7-9-5pm.diff
| File press-this_7-9-5pm.diff, 16.0 kB (added by noel, 5 months ago) |
|---|
-
press-this.php
old new 1 1 <?php 2 2 require_once('admin.php'); 3 3 4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' ) ); ?>4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' ) ); 5 5 6 <?php7 8 6 function preg_quote2($string) { 9 7 return str_replace('/', '\/', preg_quote($string)); 10 8 } 9 function aposfix($text) { 10 $translation_table[chr(34)] = '"'; 11 $translation_table[chr(38)] = '&'; 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)); 14 } 11 15 function press_it() { 12 16 // define some basic variables 13 17 $quick['post_status'] = $_REQUEST['post_status']; … … 30 34 $content = $_REQUEST['content']; 31 35 32 36 foreach($_REQUEST['photo_src'] as $key => $image) { 33 #quote for matching37 // escape quote for matching 34 38 $quoted = preg_quote2($image); 35 39 36 40 // see if files exist in content - we don't want to upload non-used selected files. … … 50 54 $content .= $_REQUEST['content']; 51 55 break; 52 56 } 53 #set the post_content57 // set the post_content 54 58 $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content)); 55 59 56 #error handling for $post60 // error handling for $post 57 61 if ( is_wp_error($post_ID)) { 58 62 wp_die($id); 59 63 wp_delete_post($post_ID); 60 #error handling for media_sideload64 // error handling for media_sideload 61 65 } elseif ( is_wp_error($upload)) { 62 66 wp_die($upload); 63 67 wp_delete_post($post_ID); … … 68 72 return $post_ID; 69 73 } 70 74 71 #For submitted posts.75 // For submitted posts. 72 76 if ( 'post' == $_REQUEST['action'] ) { 73 77 check_admin_referer('press-this'); $post_ID = press_it(); ?> 74 75 78 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 76 79 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 77 80 <head> … … 88 91 do_action('admin_head'); 89 92 ?> 90 93 </head> 91 <body class="press-this"> 92 93 <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> 94 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> 95 96 <div id="footer"> 96 97 <p><?php 97 98 do_action('in_admin_footer', ''); … … 99 100 echo __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>'); 100 101 ?></p> 101 102 </div> 102 <?php do_action('admin_footer', ''); ?> 103 103 <?php do_action('admin_footer', ''); ?> 104 104 </body> 105 105 </html> 106 106 <?php die; 107 107 } 108 108 109 110 function aposfix($text) {111 $translation_table[chr(34)] = '"';112 $translation_table[chr(38)] = '&';113 $translation_table[chr(39)] = ''';114 return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table));115 }116 117 109 // Ajax Requests 118 110 $title = wp_specialchars(aposfix(stripslashes($_GET['t']))); 119 111 … … 178 170 179 171 if($_REQUEST['ajax'] == 'photo_images') { 180 172 function get_images_from_uri($uri) { 181 if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com'))173 if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com') ) 182 174 return "'".$uri."'"; 183 175 184 176 $content = wp_remote_fopen($uri); … … 211 203 } 212 204 213 205 if($_REQUEST['ajax'] == 'photo_js') { ?> 214 215 216 206 // gather images and load some default JS 217 218 207 var last = null 219 208 var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; 220 209 var my_src = eval( … … 257 246 if(length == 0) length = 1; 258 247 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>'); 259 248 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>'); 260 append_editor( '<img src="' + img +'" alt="' + desc + '" />');249 append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" /></p>'); 261 250 } 262 251 tinyMCE.activeEditor.resizeToContent(); 263 252 return false; … … 277 266 tb_init('a.thickbox, area.thickbox, input.thickbox'); 278 267 }); 279 268 280 <?php die; } 269 <?php die; 270 } 281 271 282 272 if($_REQUEST['ajax'] == 'photo') { ?> 283 273 <div class="photolist"></div> … … 287 277 <div class="titlewrap"> 288 278 <div id="img_container"></div> 289 279 </div> 290 <?php die; } 280 <?php die; 281 } 291 282 ?> 292 283 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 293 284 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> … … 377 368 } 378 369 379 370 function set_editor(text) { 380 381 371 if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); 382 372 if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 383 373 } … … 399 389 set_editor("<?php echo $selection; ?>"); 400 390 <?php } else { ?> 401 391 set_editor("<a href='<?php echo $url ?>'><?php echo $title; ?></a>"); 402 <? } ?>392 <?php } ?> 403 393 return false; 404 394 break; 405 395 case 'quote' : … … 411 401 case 'video' : 412 402 set_menu('video'); 413 403 set_title('<?php _e('Caption') ?>'); 414 415 404 jQuery('#extra_fields').show(); 416 405 jQuery('body').addClass('video_split'); 417 406 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() { 418 407 <?php 419 408 if ( preg_match("/youtube\.com\/watch/i", $url) ) { 420 list($domain, $video_id) = split("v=", $url); 421 $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>'; ?> 409 list($domain, $video_id) = split("v=", $url); 410 $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 412 } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { 413 list($domain, $video_id) = split(".com/", $url); 414 $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>'; 422 415 423 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { 424 425 list($domain, $video_id) = split(".com/", $url); 426 $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>'; 427 428 if ( trim($selection) == '' ) 429 $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>'; 416 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 430 419 } else { 431 420 $content = $selection; 432 } ?> 421 } 422 423 ?> 433 424 jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>'); 434 425 435 426 set_editor("<?php echo $title; ?>"); … … 443 434 set_editor("<?php echo $selection; ?>"); 444 435 <?php } else { ?> 445 436 set_editor("<a href='<?php echo $url ?>'><?php echo $title; ?></a>"); 446 <? } ?>437 <?php } ?> 447 438 jQuery('#extra_fields').show(); 448 439 jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>'); 449 440 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']).'/?ajax=photo&u='.attribute_escape($url); ?>'); … … 468 459 tab_name = tab_name[0]; 469 460 show(tab_name); 470 461 }); 471 472 462 // Set default tabs 473 463 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> 474 464 show('video'); … … 478 468 show('photo'); 479 469 <?php } ?> 480 470 }); 481 471 482 472 </script> 483 473 </head> 484 474 <body class="press-this"> … … 537 527 </div> 538 528 </form> 539 529 </body> 540 </html> 530 </html> -
css/press-this.css
old new 88 88 cursor: pointer; 89 89 } 90 90 91 /* Header */ 91 92 #wphead { 92 93 border-top: none; 94 height: 2em; 95 padding-top: 8px; 93 96 } 94 97 95 98 .button { 96 font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;97 padding: 3px 5px;98 font-size: 12px;99 line-height: 1.5em;100 border-width: 1px;101 border-style: solid;102 -moz-border-radius: 3px;103 -khtml-border-radius: 3px;104 -webkit-border-radius: 3px;105 border-radius: 3px;106 cursor: pointer;107 margin-left: 5px;108 text-decoration: none;99 font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; 100 padding: 3px 5px; 101 font-size: 12px; 102 line-height: 1.5em; 103 border-width: 1px; 104 border-style: solid; 105 -moz-border-radius: 3px; 106 -khtml-border-radius: 3px; 107 -webkit-border-radius: 3px; 108 border-radius: 3px; 109 cursor: pointer; 110 margin-left: 5px; 111 text-decoration: none; 109 112 } 110 113 111 114 .howto { 112 font-size: 11px; 115 font-size: 11px; 116 font-style: italic; 117 display: block; 113 118 } 114 #newtag { width: 60%; padding: 3px; }115 119 116 #wphead {117 height: 2em;118 padding-top: 8px;119 }120 121 120 #wphead #viewsite { 122 121 position: absolute; 123 122 margin-top: 12px; … … 132 131 } 133 132 134 133 #wphead #viewsite a { 135 font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, 136 sans-serif; 134 font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; 137 135 padding: 3px 4px; 138 136 display: block; 139 137 letter-spacing: normal; … … 173 171 color: #333333; 174 172 } 175 173 176 .titlewrap { 177 border-style: solid; 178 border-width: 1px; 179 padding: 2px 3px; 180 border-color: #CCCCCC; 181 } 174 /* Editor/Main Column */ 182 175 183 176 div#container { 184 177 margin: 0; 185 178 min-width: 500px; 186 179 } 187 180 181 div#container form { 182 margin: 0px; 183 padding: 0px; 184 } 185 188 186 div#posting { 189 187 padding-left: 16px; 190 188 position: absolute; … … 192 190 width: 66%; 193 191 } 194 192 193 #post_title { 194 width: 99%; 195 } 196 197 .titlewrap { 198 border-style: solid; 199 border-width: 1px; 200 padding: 2px 3px; 201 border-color: #CCCCCC; 202 } 203 195 204 div#posting h2 { 196 205 margin: .5em 0 .25em 0; 197 206 font-size: 12px; … … 199 208 background: ; 200 209 } 201 210 202 div#container form { 203 margin: 0px; 204 padding: 0px; 211 .editor-container { 212 border-width: 1px; 213 border-color: #ccc; 214 border-style: solid; 215 margin-bottom: 1em; 205 216 } 206 217 218 /* Photo Styles */ 219 220 #photo_directions { 221 margin-top: .25em; 222 display: block; 223 position: relative; 224 } 225 226 #photo_directions span { 227 display: block; 228 position: absolute; 229 top: 0; 230 right: 3px; 231 } 232 233 #photo_saving { 234 margin-bottom: 8px; 235 } 236 237 #img_container { 238 background-color: #fff; 239 overflow: auto; 240 height: 100px; 241 } 242 243 #img_container a { 244 display: block; 245 width: 79px; 246 height: 79px; 247 float: left; 248 } 249 250 #img_container img { 251 width: 75px; 252 height: 75px; 253 border: 0px; 254 padding: 2px; 255 background-color: #f4f4f4; 256 cursor: pointer; 257 } 258 #img_container a, #img_container a:link, #img_container a:visited { 259 border: 2px solid #ccc; 260 margin: 0 4px 4px 0; 261 } 262 #img_container a:hover, #img_container a:active { 263 border: 2px solid #000; 264 } 265 266 /* Submit Column */ 267 207 268 div#categories { 208 269 font-size: 85%; 209 270 position: absolute; … … 216 277 div#categories h2 { 217 278 color: #333; 218 279 font-size: 12px; 219 margin: .5em 0 01em;280 margin: .5em 0 .5em 1em; 220 281 padding: 0; 221 282 } 222 283 223 284 #categories-all { 224 285 overflow: auto; 225 padding: 1em;286 padding: 0 1em 1em 1em; 226 287 height: 15em; 227 288 } 228 289 … … 232 293 margin: 0; 233 294 } 234 295 235 .editor-container {236 border-width: 1px;237 border-color: #ccc;238 border-style: solid;239 margin-bottom: 1em;240 }241 242 296 #tagsdiv #newtag { 297 padding: 3px; 243 298 margin-right: 5px; 244 width: 16em; 299 width: 16em; 245 300 } 246 301 302 #jaxtag { 303 clear: both; 304 padding-left: 1em; 305 } 306 247 307 #tagchecklist { 248 308 padding-left: 1em; 249 309 margin-bottom: 1em; … … 278 338 overflow: hidden; 279 339 position: absolute; 280 340 } 281 282 .howto {283 font-style: italic;284 display: block;285 }286 287 #post_title {288 width: 99%;289 }290 291 #img_container {292 background-color: #fff;293 overflow: auto;294 height: 100px;295 }296 297 #img_container a {298 display: block;299 width: 79px;300 height: 79px;301 float: left;302 }303 #img_container img {304 width: 75px;305 height: 75px;306 border: 0px;307 padding: 2px;308 background-color: #f4f4f4;309 cursor: pointer;310 }311 #img_container a, #img_container a:link, #img_container a:visited {312 border: 2px solid #ccc;313 margin: 0 4px 4px 0;314 }315 #img_container a:hover, #img_container a:active {316 border: 2px solid #000;317 }318 341 .submit { 319 342 -moz-border-radius-bottomleft: 3px; 320 343 -khtml-border-bottom-left-radius: 3px; … … 363 386 border-top-right-radius: 3px; 364 387 } 365 388 366 .hidden { 367 display: none; 368 } 369 389 /* Video Styles */ 370 390 .video_split #extra_fields { 371 391 width: 27%; 372 392 height: 300px; … … 383 403 float: right; 384 404 } 385 405 386 #jaxtag {387 clear: both;388 padding-left: 1em;389 }390 391 406 .ac_results { 392 407 padding: 0; 393 408 margin: 0; … … 413 428 text-decoration: underline; 414 429 } 415 430 416 417 431 .photolist { 418 display: none;432 display: none; 419 433 } 420 434 421 435 #extra_fields small { 422 display: block;423 margin-top: .5em;424 padding-bottom: .25em;436 display: block; 437 margin-top: .5em; 438 padding-bottom: .25em; 425 439 } 426 440 427 441 #TB_ajaxContent #options { 428 position: absolute;429 top: 20px;430 right: 25px;431 padding: 5px;442 position: absolute; 443 top: 20px; 444 right: 25px; 445 padding: 5px; 432 446 } 433 447 #TB_ajaxContent h3 { 434 margin-bottom: .25em;448 margin-bottom: .25em; 435 449 } 436 450 437 451 .updated { … … 461 475 padding-bottom: 2px; 462 476 } 463 477 464 #photo_directions {465 margin-top: .25em;466 display: block;467 position: relative;468 }469 #photo_directions span {470 display: block;471 position: absolute;472 top: 0;473 right: 3px;474 }475 #photo_saving {476 margin-bottom: 8px;477 }478 479 478 #post_status { 480 479 margin-left: 10px; 481 480 margin-bottom: 1em; 482 481 display: block; 483 482 } 484 483 484 /* Footer */ 485 485 486 #footer { 486 487 height: 65px; 487 488 display: block; … … 506 507 text-decoration: underline; 507 508 } 508 509 510 511 /* Utility Classes */ 509 512 .centered { 510 513 text-align: center; 511 514 } 515 516 .hidden { 517 display: none; 518 }
