Changeset 8067
- Timestamp:
- 06/10/2008 04:13:06 PM (17 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/press-this.css
r8062 r8067 357 357 float: left; 358 358 } 359 359 360 #embed_code { 360 361 border: 0; … … 395 396 text-decoration: underline; 396 397 } 398 399 400 .photolist { 401 display: none; 402 } 403 404 #extra_fields small { 405 display: block; 406 margin-top: .5em; 407 padding-bottom: .25em; 408 } 409 410 #TB_ajaxContent #options { 411 position: absolute; 412 top: 20px; 413 right: 25px; 414 background: white; 415 padding: 5px; 416 } 417 #TB_ajaxContent h3 { 418 margin-bottom: .25em; 419 } 420 421 .updated { 422 margin: 0; 423 margin-left: 15px; 424 margin-right: 15px; 425 padding: 0; 426 max-width: 980px; 427 border-width: 1px; 428 border-style: solid; 429 padding: 0 0.6em; 430 max-width: 950px; 431 margin-top: 1em; 432 margin-bottom: 1em; 433 } 434 435 .updated p, .error p { 436 margin: 0.6em 0; 437 } 438 439 .updated a, .error a { 440 text-decoration: underline; 441 } 442 443 .updated a { 444 text-decoration: none; 445 padding-bottom: 2px; 446 } -
trunk/wp-admin/includes/media.php
r8048 r8067 117 117 118 118 119 function media_sideload_image($file, $post_id ) {119 function media_sideload_image($file, $post_id, $desc = null) { 120 120 121 121 if (!empty($file) ) { … … 124 124 $file_array['name'] = basename($file); 125 125 $file_array['tmp_name'] = download_url($file); 126 $desc = @$desc; 126 127 127 $sideload = media_handle_sideload($file_array, $post_id );128 $sideload = media_handle_sideload($file_array, $post_id, $desc); 128 129 129 130 $id = $sideload['id']; … … 142 143 143 144 $src = "http://$src"; 144 /*$alt = attribute_escape($_POST['insertonly']['alt']); 145 if ( isset($_POST['insertonly']['align']) ) { 146 $align = attribute_escape($_POST['insertonly']['align']); 147 $class = " class='align$align'"; 148 } */ 145 $alt = @$desc; 146 149 147 if ( !empty($src) ) 150 $html = "<img src='$src' alt='$alt' $class/>";148 $html = "<img src='$src' alt='$alt' />"; 151 149 return $html; 152 150 153 151 } 154 152 155 function media_handle_sideload($file_array, $post_id, $ post_data = array()) {153 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { 156 154 $overrides = array('test_form'=>false); 157 155 $file = wp_handle_sideload($file_array, $overrides); … … 173 171 $content = $image_meta['caption']; 174 172 } 173 174 $title = @$desc; 175 175 176 176 // Construct the attachment array -
trunk/wp-admin/press-this.php
r8059 r8067 6 6 <?php 7 7 function press_it() { 8 $quick['post_status'] = 'publish'; 9 $quick['post_category'] = $_REQUEST['post_category']; 10 $quick['tags_input'] = $_REQUEST['tags_input']; 11 $quick['post_title'] = $_REQUEST['post_title']; 12 $quick['post_content'] = ''; 13 14 // insert the post with nothing in it, to get an ID 15 $post_ID = wp_insert_post($quick, true); 16 17 $content = ''; 18 switch ( $_REQUEST['post_type'] ) { 19 case 'text': 20 $content .= $_REQUEST['content']; 21 22 case 'quote': 23 $content .= $_REQUEST['content']; 24 break; 25 26 case 'photo': 27 if ($_REQUEST['photo_link']) 28 $content .= '<a href="' . $_REQUEST['photo_link'] . '">'; 29 30 $content .= media_sideload_image($_REQUEST['photo_src'], $post_ID); 31 32 if ($_REQUEST['photo_link']) 33 $content .= '</a>'; 34 35 if ($_REQUEST['content']) 36 $content .= $content . "\n\n".$_REQUEST['content']; 37 38 break; 39 case "video": 40 if($_REQUEST['embed_code']) 41 $content .= $_REQUEST['embed_code']."\n\n"; 42 $content .= $_REQUEST['content']; 43 break; 8 #define some basic variables 9 $quick['post_status'] = 'publish'; 10 $quick['post_category'] = $_REQUEST['post_category']; 11 $quick['tags_input'] = $_REQUEST['tags_input']; 12 $quick['post_title'] = $_REQUEST['post_title']; 13 $quick['post_content'] = ''; 14 15 # insert the post with nothing in it, to get an ID 16 $post_ID = wp_insert_post($quick, true); 17 18 $content = ''; 19 switch ( $_REQUEST['post_type'] ) { 20 case 'text': 21 case 'quote': 22 $content .= $_REQUEST['content']; 23 break; 24 25 case 'photo': 26 foreach($_REQUEST['photo_src'] as $key => $data) { 27 #quote for matching 28 $quoted = str_replace('/', '\/', preg_quote($data)); 29 30 # see if files exist in content - we don't want to upload non-used selected files. 31 preg_match('/'.$quoted.'/', $_REQUEST['content'], $matches[0]); 32 if($matches[0]) 33 media_sideload_image($data, $post_ID, $_REQUEST['photo_description'][$key]); 34 } 35 $content = $_REQUEST['content']; 36 break; 37 38 case "video": 39 if($_REQUEST['embed_code']) 40 $content .= $_REQUEST['embed_code']."\n\n"; 41 $content .= $_REQUEST['content']; 42 break; 44 43 } 45 44 # set the post_content 46 45 $quick['post_content'] = $content; 47 46 47 #error handling for $post 48 48 if ( is_wp_error($post_ID) ) { 49 49 wp_die($id); 50 50 wp_delete_post($post_ID); 51 } else { 51 52 #error handling for media_sideload 53 } else { 52 54 $quick['ID'] = $post_ID; 53 55 wp_update_post($quick); … … 56 58 } 57 59 58 60 function tag_div() { ?> 59 61 <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> 60 62 <div id="tagchecklist"></div> 61 <?php 62 } 63 64 function category_div() { 65 ?> 63 <?php } 64 65 function category_div() { ?> 66 66 <div id="categories"> 67 67 <div class="submitbox" id="submitpost"> … … 79 79 </p> 80 80 </div> 81 <?php 82 } 83 84 // For posts submitted 81 <?php } 82 83 # For submitted posts. 85 84 if ( 'post' == $_REQUEST['action'] ) { 86 85 check_admin_referer('press-this'); $post_ID = press_it(); ?> 87 <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> 86 87 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 88 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 89 <head> 90 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 91 <title><?php _e('Press This') ?></title> 92 <?php 93 add_thickbox(); 94 wp_enqueue_style('press-this'); 95 wp_enqueue_style( 'colors' ); 96 wp_enqueue_script('post'); 97 98 do_action('admin_print_styles'); 99 do_action('admin_print_scripts'); 100 do_action('admin_head'); 101 ?> 102 </head> 103 <body class="press-this"> 104 <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();">Close Window</a></p></div> 105 </body> 106 </html> 88 107 <?php die; 89 108 } … … 93 112 $selection = trim(wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s'])))); 94 113 $url = $_GET['u']; 114 $image = $_GET['i']; 115 if($_REQUEST['ajax'] == 'thickbox') { ?> 116 <script type="text/javascript" charset="utf-8"> 117 jQuery('.cancel').click(function() { 118 tb_remove(); 119 }); 120 121 function image_selector() { 122 desc = jQuery('#this_photo_description').val(); 123 src = jQuery('#this_photo').val(); 124 pick(src, desc); 125 tb_remove(); 126 return false; 127 } 128 129 jQuery('.select').click(function() { 130 image_selector(); 131 }); 132 133 </script> 134 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 135 <div class="titlewrap"> 136 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 137 </div> 138 139 <p><input type="hidden" name="this_photo" value="<?php echo $image; ?>" id="this_photo" /> 140 <a href="#" class="select" rel="<?php echo $image; ?>"><img src="<?php echo $image; ?>" width="475" alt="Click to insert." title="Click to insert." /></a></p> 141 142 <p id="options"><a href="#" class="select" rel="<?php echo $image; ?>">Insert Image</a> | <a href="#" class="cancel">Cancel</a></p> 143 <?php die; 144 } 145 95 146 96 147 if($_REQUEST['ajax'] == 'video') { ?> … … 138 189 139 190 var last = null 140 function pick(img) { 141 142 if (last) last.style.backgroundColor = '#f4f4f4'; 143 if (img) { 144 jQuery('#photo_src').val(img.src); 145 img.style.backgroundColor = '#44f'; 146 } 147 last = img; 148 149 /*noel's code to select more than one image.... 150 jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + 151 '<div class="titlewrap">' + 152 '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + 153 '</div>');*/ 154 191 192 function pick(img, desc) { 193 if (img) { 194 length = jQuery('.photolist input').length; 195 if(length == 0) length = 1; 196 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>'); 197 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>'); 198 append_editor('<img src="' + img +'" alt="' + desc + '" />'); } 155 199 return false; 156 200 } 157 201 158 jQuery('.remove').click(function() {159 jQuery(this).remove;160 });161 162 163 202 var my_src, img, img_tag, aspect, w, h, skip, i, strtoappend = ""; 164 203 165 var my_src = eval(204 var my_src = eval( 166 205 jQuery.ajax({ 167 206 type: "GET", … … 170 209 async : false, 171 210 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>", 172 dataType : "script"173 }).responseText);211 dataType : "script" 212 }).responseText); 174 213 175 214 for (i = 0; i < my_src.length; i++) { 176 215 img = new Image(); 177 216 img.src = my_src[i]; 178 img_attr = 'id="img' + i + '" onclick="pick(this);"';217 img_attr = 'id="img' + i; 179 218 skip = false; 180 219 … … 197 236 } 198 237 199 if (!skip) strtoappend += '<a href=" ' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';238 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>'; 200 239 201 240 } … … 208 247 209 248 if($_REQUEST['ajax'] == 'photo') { ?> 210 <h2><?php _e('Photo URL') ?></h2>211 <div class="titlewrap">212 <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/>213 </div>214 249 215 250 <div class="photolist"></div> 216 217 <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?>218 <div class="titlewrap">219 <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/>220 </div>221 251 222 252 <small><?php _e('Click images to select:') ?></small> … … 265 295 theme : "advanced", 266 296 theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink", 267 extended_valid_elements : "object[width|height],param[name|value],embed[src|type|wmode|width|height], a[name|href|target|title|onclick], img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",268 297 theme_advanced_buttons2 : "", 269 298 theme_advanced_buttons3 : "", … … 279 308 convert_urls : false, 280 309 apply_source_formatting : false, 281 remove_linebreaks : true,310 remove_linebreaks : false, 282 311 accessibility_focus : false, 283 312 tab_focus : ":next", … … 316 345 function set_editor(text) { 317 346 if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); 347 if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 348 } 349 function append_editor(text) { 318 350 if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 319 351 } … … 332 364 set_menu('text'); 333 365 set_title('<?php _e('Text') ?>'); 334 set_editor( '<?php echo $selection; ?>');366 set_editor("<?php echo $selection; ?>"); 335 367 return false; 336 368 break; … … 341 373 set_menu('quote'); 342 374 set_title('<?php _e('Quote') ?>'); 343 set_editor( '<blockquote><p><?php echo $selection; ?> </p><p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?></a></cite> </p></blockquote>');375 set_editor("<blockquote><p><?php echo $selection; ?> </p><p><cite><a href='<?php echo ''; ?>'><?php echo ''; ?></a></cite> </p></blockquote>"); 344 376 345 377 return false; … … 373 405 } ?> 374 406 jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>'); 375 set_editor( '<?php echo $title; ?>');407 set_editor("<?php echo $title; ?>"); 376 408 377 409 }); … … 384 416 reset_height(); 385 417 set_menu('photo'); 386 set_title('Caption'); 387 set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>'); 388 418 set_title('Post'); 419 <?php if($selection) { ?> 420 set_editor("<?php echo $selection; ?>"); 421 <?php } else { ?> 422 set_editor('') 423 <?php } ?> 389 424 jQuery('#extra_fields').show(); 390 425 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']).'/?ajax=photo&u='.attribute_escape($url); ?>'); … … 399 434 } 400 435 }); 436 401 437 return false; 402 438 break; … … 445 481 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 446 482 </div> 447 483 448 484 <div id="extra_fields" style="display: none"></div> 449 485 <div class="editor_area">
Note: See TracChangeset
for help on using the changeset viewer.