Changeset 8303 for trunk/wp-admin/press-this.php
- Timestamp:
- 07/09/2008 09:39:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/press-this.php
r8302 r8303 2 2 require_once('admin.php'); 3 3 4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' )); ?> 5 6 <?php 4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' ) ); 7 5 8 6 function preg_quote2($string) { 9 7 return str_replace('/', '\/', preg_quote($string)); 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)); 10 14 } 11 15 function press_it() { … … 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 … … 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); … … 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(); ?>> … … 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 … … 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 }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 107 } 116 108 … … 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 … … 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 = ""; … … 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(); … … 278 267 }); 279 268 280 <?php die; } 269 <?php die; 270 } 281 271 282 272 if($_REQUEST['ajax'] == 'photo') { ?> … … 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"> … … 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); … … 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; … … 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'); … … 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 … … 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>'); … … 469 460 show(tab_name); 470 461 }); 471 472 462 // Set default tabs 473 463 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> … … 479 469 <?php } ?> 480 470 }); 481 471 482 472 </script> 483 473 </head>
Note: See TracChangeset
for help on using the changeset viewer.