Changeset 7957 for trunk/wp-admin/press-this.php
- Timestamp:
- 05/20/2008 04:37:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/press-this.php
r7946 r7957 2 2 require_once('admin.php'); 3 3 4 if ( ! current_user_can('publish_posts') ) 5 wp_die( __( 'Cheatin’ uh?' )); 4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' )); 5 6 if ( 'post' == $_REQUEST['action'] ) { 7 check_admin_referer('press-this'); 8 $post_ID = press_it(); ?> 9 <script>if(confirm("<?php _e('Your post is saved. Do you want to view the post?') ?>")) {window.opener.location.replace("<?php echo get_permalink($post_ID);?>");}window.close();</script> 10 <?php 11 die; 12 } 6 13 7 14 function press_it() { … … 16 23 $content = $_REQUEST['content']; 17 24 if ($_REQUEST['content2']) 18 $content .= '<p>' . $_REQUEST['content2']; 25 $content .= '<p>' . $_REQUEST['content2']; 19 26 break; 20 27 … … 23 30 if ($_REQUEST['content2']) { 24 31 $content .= '</blockquote>'; 25 $content = $content . '<p>' . $_REQUEST['content2'] ;32 $content = $content . '<p>' . $_REQUEST['content2'].'</p>'; 26 33 } 27 34 break; … … 29 36 case 'photo': 30 37 if ($_REQUEST['photo_link']) 31 $content = '< a href="' . $_REQUEST['photo_link'] . '" target="_new">';32 33 $content .= '<img src="' . $_REQUEST['photo_src'] . '" style="float:left;padding:5px;">';38 $content = '<p><a href="' . $_REQUEST['photo_link'] . '" target="_new">'; 39 40 $content .= '<img src="' . $_REQUEST['photo_src'] . '" alt=""/>'; 34 41 35 42 if ($_REQUEST['photo_link']) 36 $content .= '</a> ';43 $content .= '</a></p>'; 37 44 38 45 if ($_REQUEST['content']) 39 $content = $content . '<br clear="all">' . $_REQUEST['content'];46 $content = $content . $_REQUEST['content']; 40 47 41 48 break; … … 44 51 $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>'; 45 52 if ($_REQUEST['content2']) 46 $content .= '< /br><p>' . $_REQUEST['content2'] . '</p>';47 break; 53 $content .= '<p>' . $_REQUEST['content2'] . '</p>'; 54 break; 48 55 } 49 56 … … 58 65 } 59 66 60 function tag_div() { 61 ?> 62 <h2><?php _e('Tags') ?></h2> 63 <div id="tagsdiv"> 67 function tag_div() { ?> 68 <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> 69 <div id="tagchecklist"></div> 70 <?php 71 } 72 73 function category_div() { 74 ?> 75 <div id="categories"> 76 <div class="submitbox" id="submitpost"> 77 <div id="previewview"> <h2><?php _e('Categories') ?></h2></div> 64 78 <div class="inside"> 65 <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> 66 <div id="tagchecklist"></div> 79 <div id="categories-all"> 80 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 81 <?php wp_category_checklist() ?> 82 </ul> 83 </div> 67 84 </div> 68 </div> 69 <?php 70 } 71 72 function category_div() { 73 ?> 74 <div id="categories"> 75 <h2><?php _e('Categories') ?></h2> 76 <div id="categories-all"> 77 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 78 <?php wp_category_checklist() ?> 79 </ul> 80 </div> 81 </div> 85 <p class="submit"> 86 <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 87 <img src="/images/bookmarklet_loader.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> 88 </p> 89 </div> 82 90 <?php 83 91 } 84 92 85 93 function get_images_from_uri($uri) { 94 86 95 $content = wp_remote_fopen($uri); 87 if ( false === $content ) 88 return ''; 96 if ( false === $content ) return ''; 89 97 90 98 $pattern = '/<img[^>]+src=[\'"]([^\'" >]+?)[\'" >]/is'; 91 99 preg_match_all($pattern, $content, $matches); 92 if ( empty($matches[1]) ) 93 return ''; 94 95 /* 96 $from_host = parse_url($uri); 97 $from_host = $from_host['host']; 98 $from_host = explode('.', $from_host); 99 $count = count($from_host); 100 $from_host = $from_host[$count - 2] . '.' . $from_host[$count - 1]; 101 */ 102 100 if ( empty($matches[1]) ) return ''; 101 103 102 $sources = array(); 104 103 foreach ($matches[1] as $src) { 105 104 if ( false !== strpos($src, '&') ) 106 105 continue; 107 108 /* 109 $img_host = parse_url($src); 110 $img_host = $img_host['host']; 111 if ( false === strpos($img_host, $from_host) ) 112 continue; 113 */ 114 106 107 $host = parse_url($_GET['u'], PHP_URL_HOST); 108 109 if (strpos($src, 'http://') === false) { 110 $src = 'http://'.str_replace('//','/', $host.'/'.$src); 111 } 112 115 113 $sources[] = $src; 116 114 } … … 118 116 } 119 117 120 function press_this_js_init() { 121 if ( user_can_richedit() ) { 122 $language = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); 123 ?> 118 function press_this_js_init() { ?> 119 <?php if ( user_can_richedit() ) { 120 $language = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); 121 // Add TinyMCE languages 122 @include_once( dirname(__FILE__).'/../wp-includes/js/tinymce/langs/wp-langs.php' ); 123 if ( isset($strings) ) echo $strings; ?> 124 (function() { 125 var base = tinymce.baseURL, sl = tinymce.ScriptLoader, ln = "<?php echo $language; ?>"; 126 127 sl.markDone(base + '/langs/' + ln + '.js'); 128 sl.markDone(base + '/themes/advanced/langs/' + ln + '.js'); 129 sl.markDone(base + '/themes/advanced/langs/' + ln + '_dlg.js'); 130 })(); 131 124 132 tinyMCE.init({ 125 133 mode: "textareas", … … 148 156 }); 149 157 <?php } ?> 158 150 159 jQuery('#tags-input').hide(); 160 151 161 tag_update_quickclicks(); 162 152 163 // add the quickadd form 153 164 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="button" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); 165 154 166 jQuery('#tagadd').click( tag_flush_to_text ); 155 167 jQuery('#newtag').focus(function() { … … 171 183 $title = wp_specialchars(stripslashes($_GET['t'])); 172 184 $selection = wp_specialchars(stripslashes($_GET['s'])); 173 $url = clean_url($_GET['u']); 185 $url = clean_url($_GET['u']); 174 186 175 187 if ( empty($_GET['tab']) ) { … … 179 191 <head> 180 192 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 181 <title><?php _e('Quick Post') ?></title> 182 193 <title><?php _e('Press This') ?></title> 183 194 <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js"></script> 184 185 195 <?php 186 196 wp_enqueue_script('jquery-ui-tabs'); 187 197 wp_enqueue_script('thickbox'); 188 198 wp_enqueue_script('post'); 189 do_action('admin_print_scripts'); do_action('admin_head'); 199 do_action('admin_print_scripts'); 200 do_action('admin_head'); 190 201 wp_admin_css('css/press-this'); 191 202 wp_admin_css( 'css/colors' ); 192 203 ?> 193 204 <script type="text/javascript"> 194 <?php if ( user_can_richedit() ) {195 $language = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) );196 // Add TinyMCE languages197 @include_once( dirname(__FILE__).'/../wp-includes/js/tinymce/langs/wp-langs.php' );198 if ( isset($strings) ) echo $strings;199 ?>200 201 (function() {202 var base = tinymce.baseURL, sl = tinymce.ScriptLoader, ln = "<?php echo $language; ?>";203 204 sl.markDone(base + '/langs/' + ln + '.js');205 sl.markDone(base + '/themes/advanced/langs/' + ln + '.js');206 sl.markDone(base + '/themes/advanced/langs/' + ln + '_dlg.js');207 })();208 209 tinyMCE.init({210 mode: "textareas",211 editor_selector: "mceEditor",212 language : "<?php echo $language; ?>",213 width: "100%",214 theme : "advanced",215 theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink",216 theme_advanced_buttons2 : "",217 theme_advanced_buttons3 : "",218 theme_advanced_toolbar_location : "top",219 theme_advanced_toolbar_align : "left",220 theme_advanced_statusbar_location : "bottom",221 theme_advanced_resizing : true,222 theme_advanced_resize_horizontal : false,223 skin : "wp_theme",224 dialog_type : "modal",225 relative_urls : false,226 remove_script_host : false,227 convert_urls : false,228 apply_source_formatting : false,229 remove_linebreaks : true,230 accessibility_focus : false,231 tab_focus : ":next",232 plugins : "safari,inlinepopups"233 });234 <?php } ?>235 205 236 206 jQuery(document).ready(function() { 237 <?php if ( preg_match("/youtube\.com\/watch/i", $ _GET['u']) ) { ?>207 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> 238 208 jQuery('#container > ul').tabs({ selected: 3 }); 239 <?php } elseif ( preg_match("/flickr\.com/i", $ _GET['u']) ) { ?>209 <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> 240 210 jQuery('#container > ul').tabs({ selected: 1 }); 241 211 <?php } else { ?> … … 247 217 </head> 248 218 <body> 249 250 <?php 251 if ( 'post' == $_REQUEST['action'] ) { 252 check_admin_referer('press-this'); 253 $post_ID = press_it(); 254 ?> 255 <script>if(confirm("<?php _e('Your post is saved. Do you want to view the post?') ?>")) {window.opener.location.replace("<?php echo get_permalink($post_ID);?>");}window.close();</script> 256 </body></html> 257 <?php 258 die; 259 } 260 ?> 219 <div id="wphead"> 220 <h1><span id="viewsite"><a href="<?php echo get_option('home'); ?>/">Visit: <?php bloginfo('name'); ?></a></span></h1> 221 </div> 261 222 <div id="container"> 262 223 <ul> 263 <li><a href="<?php echo clean_url(add_query_arg('tab', 'text', stripslashes($_SERVER['REQUEST_URI']))) ?>">< span><?php _e('Text/Link') ?></span></a></li>264 <li><a href="<?php echo clean_url(add_query_arg('tab', 'photo', stripslashes($_SERVER['REQUEST_URI']))) ?>">< span><?php _e('Photo') ?></span></a></li>265 <li><a href="<?php echo clean_url(add_query_arg('tab', 'quote', stripslashes($_SERVER['REQUEST_URI']))) ?>">< span><?php _e('Quote') ?></span></a></li>266 <li><a href="<?php echo clean_url(add_query_arg('tab', 'video', stripslashes($_SERVER['REQUEST_URI']))) ?>">< span><?php _e('Video') ?></span></a></li>224 <li><a href="<?php echo clean_url(add_query_arg('tab', 'text', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Text') ?></a></li> 225 <li><a href="<?php echo clean_url(add_query_arg('tab', 'photo', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Photo') ?></a></li> 226 <li><a href="<?php echo clean_url(add_query_arg('tab', 'quote', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Quote') ?></a></li> 227 <li><a href="<?php echo clean_url(add_query_arg('tab', 'video', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Video') ?></a></li> 267 228 </ul> 229 268 230 </div> 269 270 231 </body> 271 232 </html> 272 <?php 273 exit; 274 } elseif ( 'photo' == $_GET['tab'] ) { 275 ?> 233 <?php exit; } elseif ( 'photo' == $_GET['tab'] ) { ?> 276 234 <script type="text/javascript"> 277 235 <?php press_this_js_init(); ?> … … 286 244 return false; 287 245 } 246 288 247 jQuery(document).ready(function() { 289 248 var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; … … 318 277 } 319 278 } 279 320 280 jQuery('#img_container').html(strtoappend); 321 281 … … 323 283 }); 324 284 </script> 325 326 285 <form action="press-this.php?action=post" method="post" id="photo_form"> 327 286 <?php wp_nonce_field('press-this') ?> … … 329 288 <input type="hidden" name="post_type" value="photo"/> 330 289 <div id="posting"> 331 <h2><?php _e('Post Title') ?></h2> 290 291 <h2><?php _e('Title') ?></h2> 292 <div class="titlewrap"> 332 293 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 333 294 </div> 295 296 <h2><?php _e('Photo URL') ?></h2> 297 <div class="titlewrap"> 298 <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> 299 </div> 300 301 <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?> 302 <div class="titlewrap"> 303 <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/> 304 </div> 305 306 <small>Click images to select:</small> 307 <div class="titlewrap"> 308 <div id="img_container"> 309 </div> 310 </div> 311 312 334 313 <h2><?php _e('Caption') ?></h2> 335 314 <div class="editor-container"> 336 <textarea name="content" id="photo_post_two" style="height:130px;width:100%;" class="mceEditor"><?php echo $selection;?> 337 <br><a href="<?php echo $url;?>"><?php echo $title;?></a></textarea> 338 </div> 339 340 <h2><?php _e('Photo URL') ?></h2> 341 <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> 342 343 <style type="text/css"> 344 #img_container img { 345 width: 75px; 346 height: 75px; 347 padding: 2px; 348 background-color: #f4f4f4; 349 margin-right: 7px; 350 margin-bottom: 7px; 351 cursor: pointer; 352 } 353 </style> 354 <div id="img_container" style="border:solid 1px #ccc; background-color:#f4f4f4; padding:5px; width:370px; margin-top:10px; overflow:auto; height:100px;"> 355 </div> 356 357 <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?> 358 <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/> 315 <textarea name="content" id="photo_post_two" style="" class="mceEditor"><?php echo $selection;?> 316 <a href="<?php echo attribute_escape($url);?>"><?php echo $title;?></a></textarea> 317 </div> 359 318 360 319 <?php tag_div(); ?> 361 362 <div> 363 <input type="submit" value="<?php _e('Create Photo') ?>" style="margin-top:15px;" onclick="document.getElementById('photo_saving').style.display = '';"/> 364 365 <a href="#" onclick="if (confirm('<?php _e('Are you sure?') ?>')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel') ?></a> 366 <img src="/images/bookmarklet_loader.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> 367 </div> 320 368 321 </div> 369 <?php category_div() ?>322 <?php category_div() ?> 370 323 </form> 371 324 <?php … … 382 335 <input type="hidden" name="post_type" value="regular"/> 383 336 <div id="posting"> 384 <h2><?php _e('Post Title') ?></h2> 337 <h2><?php _e('Title') ?></h2> 338 <div class="titlewrap"> 385 339 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 386 340 </div> 341 387 342 <h2><?php _e('Post') ?></h2> 388 343 <div class="editor-container"> 389 <textarea name="content" id="regular_post_two" style="height:170px;width:100%;" class="mceEditor"><?php echo $selection;?> <br><a href="<?php echo $url;?>"><?php echo $title;?></a></textarea>390 </div> 344 <textarea name="content" id="regular_post_two" style="height:170px;width:100%;" class="mceEditor"><?php echo $selection;?><a href="<?php echo $url;?>"><?php echo $title;?></a></textarea> 345 </div> 391 346 392 347 <?php tag_div(); ?> 393 394 <div> 395 <input type="submit" value="<?php _e('Create Post') ?>" style="margin-top:15px;" onclick="document.getElementById('regular_saving').style.display = '';"/> 396 <a href="#" onclick="if (confirm('<?php _e('Are you sure?') ?>')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel') ?></a> 397 <img src="/images/bookmarklet_loader.gif" alt="" id="regular_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> 398 </div> 348 399 349 </div> 400 350 <?php category_div() ?> … … 413 363 <input type="hidden" name="post_type" value="quote"/> 414 364 <div id="posting"> 415 <h2><?php _e('Post Title') ?></h2> 365 <h2><?php _e('Title') ?></h2> 366 <div class="titlewrap"> 416 367 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape(sprintf(__('Quote by %s'), $title)); ?>"/> 417 368 </div> 369 418 370 <h2><?php _e('Quote') ?></h2> 419 371 <div class="editor-container"> … … 423 375 <h2><?php _e('Source <span class="optional">(optional)</span>') ?></h2> 424 376 <div class="editor-container"> 425 <textarea name="content2" id="quote_post_two" style="height:130px;width:100%;" class="mceEditor">< br><a href="<?php echo $url;?>"><?php echo $title;?></a></textarea>377 <textarea name="content2" id="quote_post_two" style="height:130px;width:100%;" class="mceEditor"><cite><a href="<?php echo $url;?>"><?php echo $title;?></a></cite></textarea> 426 378 </div> 427 379 428 380 <?php tag_div(); ?> 429 430 <div>431 <input type="submit" value="<?php echo attribute_escape(__('Create Quote')) ?>" style="margin-top:15px;" onclick="document.getElementById('quote_saving').style.display = '';"/> 432 <a href="#" onclick="if (confirm('<?php _e('Are you sure?') ?>')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel') ?></a> 433 <img src="/images/bookmarklet_loader.gif" alt="" id="quote_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/>434 </div>435 381 </div> 436 382 <?php category_div() ?> … … 449 395 <input type="hidden" name="post_type" value="video"/> 450 396 <div id="posting"> 451 <h2><?php _e('Post Title') ?></h2> 397 398 <h2><?php _e('Video Title') ?></h2> 399 <div class="titlewrap"> 452 400 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 453 454 <?php 401 </div> 402 <?php 455 403 if ( preg_match("/youtube\.com\/watch/i", $url) ) { 456 404 list($domain, $video_id) = split("v=", $url); 457 405 ?> 458 406 <input type="hidden" name="content" value="<?php echo attribute_escape($url); ?>" /> 459 <img src="http://img.youtube.com/vi/<?php echo $video_id; ?>/default.jpg" align="right" style="border:solid 1px #aaa;" width="130" height="97"/> <br clear="all" />407 <img src="http://img.youtube.com/vi/<?php echo $video_id; ?>/default.jpg" align="right" style="border:solid 1px #aaa;" width="130" height="97"/> 460 408 <?php } else { ?> 409 461 410 <h2><?php _e('Embed Code') ?></h2> 462 411 <textarea name="content" id="video_post_one" style="height:80px;width:100%;"></textarea> … … 466 415 467 416 <div class="editor-container"> 468 <textarea name="content2" id="video_post_two" style="height:130px;width:100%;" class="mceEditor"><?php echo $selection; ?><br><a href="<?php echo $url;?>"><?php echo $title;?></a></textarea>417 <textarea name="content2" id="video_post_two" style="height:130px;width:100%;" class="mceEditor"><?php echo $selection; ?> <a href="<?php echo $url; ?>"><?php echo $title;?></a></textarea> 469 418 </div> 470 419 471 420 <?php tag_div(); ?> 472 473 <div>474 <input type="submit" value="<?php _e('Create Video') ?>" style="margin-top:15px;" onclick="document.getElementById('video_saving').style.display = '';"/> 475 <a href="#" onclick="if (confirm('<?php _e('Are you sure?') ?>')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel'); ?></a> 476 <img src="/images/bookmarklet_loader.gif" alt="" id="video_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/>477 </div>478 421 </div> 479 422 <?php category_div() ?> … … 482 425 exit; 483 426 } 484 ?> 427 ?>
Note: See TracChangeset
for help on using the changeset viewer.