Changeset 6974
- Timestamp:
- 02/22/2008 05:53:47 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/media.css
r6952 r6974 110 110 } 111 111 112 .media-upload-form fieldset#image-size label { 112 #flash-upload-ui, .insert-gallery { 113 display: none; 114 } 115 116 tr.image-size label { 113 117 display: inline; 114 118 margin: 0 1em 0 0; 115 119 } 116 120 tr.image-size td.field { 121 text-align: center; 122 } 117 123 .pinkynail { 118 124 max-width: 40px; … … 188 194 width: 460px; 189 195 } 190 .describea.delete {196 a.delete { 191 197 display: block; 192 198 text-align: center; 193 line-height: 24px;194 width: 100%;199 width: 100%; 200 color: #246; 195 201 } 196 202 .describe-toggle-on, .describe-toggle-off { -
trunk/wp-admin/edit-attachment-rows.php
r6910 r6974 47 47 case 'media': 48 48 ?> 49 <td><strong><a href="# TODO: upload.php?action=edit&post=<?php the_ID(); ?>"><?php the_title(); ?></a></strong> 49 <td><strong><a href="# TODO: upload.php?action=edit&post=<?php the_ID(); ?>"><?php the_title(); ?></a></strong><br /> 50 <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', $post->guid)); ?> 51 <?php do_action('manage_media_media_column', $post->ID); ?> 52 </td> 50 53 <?php 51 // TODO52 54 break; 53 55 54 56 case 'desc': 55 57 ?> 56 <td><?php has_excerpt() ? the_excerpt() : null; ?></td>58 <td><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td> 57 59 <?php 58 // TODO59 60 break; 60 61 … … 93 94 <td><a href="<?php the_permalink(); ?>"><?php _e('Permalink'); ?></a></td> 94 95 <?php 95 // TODO96 96 break; 97 97 98 98 default: 99 99 ?> 100 <td><?php do_action('manage_ posts_custom_column', $column_name, $id); ?></td>100 <td><?php do_action('manage_media_custom_column', $column_name, $id); ?></td> 101 101 <?php 102 102 break; -
trunk/wp-admin/includes/media.php
r6952 r6974 36 36 } 37 37 38 function image_upload_callback() {39 $tabs = image_upload_tabs();40 if ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) && is_callable($_GET['tab']) )41 return $_GET['tab']();42 elseif ( is_callable($first = array_shift(array_keys($tabs))) )43 return $first();44 else45 return image_upload_handler();46 }47 48 add_action('media_upload_image', 'image_upload_callback');49 50 function image_upload_form( $action_url, $values = array(), $error = null ) {51 $action_url = attribute_escape( $action_url );52 $image_alt = attribute_escape( @$values['image-alt'] );53 $image_url = attribute_escape( @$values['image-url'] );54 $image_title = attribute_escape( @$values['image-title'] );55 $image_align = @$values['image-url'];56 $post_id = $_GET['post_id'];57 58 ?>59 <div id="media-upload-header">60 <h3><?php _e('Add Image') ?></h3>61 <?php the_image_upload_tabs(); ?>62 </div>63 <div id="media-upload-error">64 <?php if ($error) {65 echo $error->get_error_message();66 } ?>67 </div>68 <script type="text/javascript">69 <!--70 71 jQuery(document).ready(function(){72 var swfu = new SWFUpload({73 upload_url : "<?php echo get_option('siteurl').'/wp-admin/async-upload.php'; ?>",74 flash_url : "<?php echo get_option('siteurl').'/wp-includes/js/swfupload/swfupload_f9.swf'; ?>",75 file_post_name: "async-upload",76 swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available77 degraded_element_id : "html-upload-ui", // when swfupload is unavailable78 //file_types : "*.jpg;*.gif;*.png",79 file_size_limit : "<?php echo wp_max_upload_size(); ?> B",80 post_params : {81 "post_id" : "<?php echo $post_id; ?>",82 "auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>",83 "type" : "image",84 },85 swfupload_loaded_handler : uploadLoadedImage,86 upload_progress_handler : uploadProgressImage,87 upload_success_handler : uploadSuccessImage,88 upload_error_handler: uploadError,89 file_queued_handler : fileQueuedImage,90 file_queue_error_handler : fileQueueError,91 file_dialog_complete_handler : fileDialogComplete,92 93 custom_settings : {94 progressTarget : "flash-upload-ui",95 cancelButtonId : "btnCancel2"96 },97 98 debug: false,99 100 });101 102 document.getElementById("flash-browse-button").onclick = function () { swfu.selectFile(); };103 });104 //-->105 </script>106 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($action_url); ?>" id="image-upload" class="media-upload-form">107 <p id="flash-upload-ui">108 <label for="flash-browse-button"><?php _e('Choose image'); ?></label>109 <input id="flash-browse-button" type="button" value="<?php _e('Browse'); ?>" />110 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label></p>111 <p id="html-upload-ui"><label for="image-file"><?php _e('Choose image'); ?></label>112 <input type="file" name="image-file" id="image-file" />113 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label></p>114 <p><label for="image-alt" class="required"><?php _e('<alt> (required)'); ?></label>115 <input type="text" name="image-alt" id="image-alt" />116 <label for="image-alt" class="form-help"><?php _e('e.g., The Mona Lisa'); ?></label></p>117 <p><label for="image-url"><?php _e('URL'); ?></label>118 <input type="text" name="image-url" id="image-url" />119 <label for="image-url" class="form-help"><?php _e('e.g., http://www.wordpress.org/'); ?></label></p>120 <p><label for="image-title"><?php _e('<title>'); ?></label>121 <input type="text" name="image-title" id="image-title" />122 <label for="image-url" class="form-help"><?php _e('e.g., The Mona Lisa, one of many paintings in the Louvre'); ?></label></p>123 <fieldset id="image-align">124 <legend><?php _e('Alignment'); ?></legend>125 <input type="radio" name="image-align" id="image-align-none" value="none" <?php if ($image_align == 'none' || !$image_align) echo ' checked="checked"'; ?>/>126 <label for="image-align-none" id="image-align-none-label"><?php _e('None'); ?></label>127 <input type="radio" name="image-align" id="image-align-left" value="left" <?php if ($image_align == 'left') echo ' checked="checked"'; ?>/>128 <label for="image-align-left" id="image-align-left-label"><?php _e('Left'); ?></label>129 <input type="radio" name="image-align" id="image-align-center" value="center" <?php if ($image_align == 'center') echo ' checked="checked"'; ?>/>130 <label for="image-align-center" id="image-align-center-label"><?php _e('Center'); ?></label>131 <input type="radio" name="image-align" id="image-align-right" value="right" <?php if ($image_align == 'right') echo ' checked="checked"'; ?>/>132 <label for="image-align-right" id="image-align-right-label"><?php _e('Right'); ?></label>133 </fieldset>134 <fieldset id="image-size">135 <legend><?php _e('Size'); ?></legend>136 <input type="radio" name="image-size" id="image-size-thumb" value="thumb" <?php if ($image_size == 'thumb') echo ' checked="checked"'; ?>/>137 <label for="image-size-thumb" id="image-size-thumb-label"><?php _e('Thumbnail'); ?></label>138 <input type="radio" name="image-size" id="image-size-medium" value="medium" <?php if ($image_size == 'medium' || !$image_size) echo ' checked="checked"'; ?>/>139 <label for="image-size-medium" id="image-size-medium-label"><?php _e('Medium'); ?></label>140 <input type="radio" name="image-size" id="image-size-full" value="full" <?php if ($image_size == 'full') echo ' checked="checked"'; ?>/>141 <label for="image-size-full" id="image-size-full-label"><?php _e('Full size'); ?></label>142 </fieldset>143 <p>144 <button name="image-add" id="image-add" class="button-ok" value="1"><?php _e('Add Image'); ?></button>145 <a href="#" onClick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a>146 </p>147 <input type="hidden" name="post_id" value="<?php echo attribute_escape($post_id); ?>" />148 <?php wp_nonce_field( 'inlineuploading' ); ?>149 </form>150 <?php151 }152 153 function image_upload_handler() {154 155 if ( !current_user_can('upload_files') ) {156 return new wp_error( 'upload_not_allowed', __('You are not allowed to upload files.') );157 }158 159 if ( empty($_POST['image-add']) ) {160 // no button click, we're just displaying the form161 wp_iframe( 'image_upload_form', get_option('siteurl') . '/wp-admin/media-upload.php?type=image' );162 }163 else {164 // Add Image button was clicked165 check_admin_referer('inlineuploading');166 167 // if the async flash uploader was used, the attachment has already been inserted and its ID is passed in post.168 // otherwise this is a regular form post and we still have to handle the upload and create the attachment.169 if ( !empty($_POST['attachment_id']) ) {170 $id = intval($_POST['attachment_id']);171 // store the title and alt into the attachment post172 wp_update_post(array(173 'ID' => $id,174 'post_title' => $_POST['image-title'],175 'post_content' => $_POST['image-alt'],176 ));177 }178 else {179 $id = image_upload_post();180 }181 182 // if the input was invalid, redisplay the form with its current values183 if ( is_wp_error($id) )184 wp_iframe( 'image_upload_form', get_option('siteurl') . '/wp-admin/media-upload.php?type=image', $_POST, $id );185 else {186 media_send_to_editor(get_image_send_to_editor($id, $_POST['image-alt'], $_POST['image-title'], $_POST['image-align'], $_POST['image-url'], true, $_POST['image-size']));187 }188 }189 }190 191 // this returns html to include in the single image upload form when the async flash upload has finished192 // i.e. show a thumb of the image, and include the attachment id as a hidden input193 function async_image_callback($id) {194 $thumb_url = wp_get_attachment_thumb_url($id);195 if ( empty($thumb_url) )196 $thumb_url = wp_mime_type_icon($id);197 198 if ($thumb_url) {199 $out = '<p><input type="hidden" name="attachment_id" id="attachment_id" value="'.intval($id).'" />'200 . '<img src="'.wp_get_attachment_thumb_url($id).'" class="pinkynail" /> '201 . basename(wp_get_attachment_url($id)).'</p>';202 }203 else {204 $out = '<p><input type="hidden" name="attachment_id" id="attachment_id" value="'.intval($id).'" />'205 . basename(wp_get_attachment_url($id)).'</p>';206 }207 208 $post = get_post($id);209 $title = addslashes($post->post_title);210 $alt = addslashes($post->post_content);211 212 // populate the input fields with post data (which in turn comes from exif/iptc)213 $out .= <<<EOF214 <script type="text/javascript">215 <!--216 jQuery('#image-alt').val('{$alt}').attr('disabled', false);217 jQuery('#image-title').val('{$title}').attr('disabled', false);218 jQuery('#image-url').attr('disabled', false);219 jQuery('#image-add').attr('disabled', false);220 -->221 </script>222 EOF;223 224 return $out;225 }226 227 add_filter('async_upload_image', 'async_image_callback');228 229 230 38 function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { 231 39 … … 253 61 <?php 254 62 exit; 255 }256 257 // this handles the file upload POST itself, validating input and inserting the file if it's valid258 function image_upload_post() {259 if ( empty($_FILES['image-file']['name']) )260 return new wp_error( 'image_file_required', __('Please choose an image file to upload') );261 if ( empty($_POST['image-alt']) )262 return new wp_error( 'image_alt_required', __('Please enter an <alt> description') );263 264 $overrides = array('test_form'=>false);265 $file = wp_handle_upload($_FILES['image-file'], $overrides);266 267 if ( isset($file['error']) )268 return new wp_error( 'upload_error', $file['error'] );269 270 $url = $file['url'];271 $type = $file['type'];272 $file = $file['file'];273 274 $post_title = trim($_POST['image-title']);275 $post_content = trim($_POST['image-alt']);276 $post_parent = intval($_POST['parent_post_id']);277 278 // Construct the attachment array279 $attachment = array(280 'post_title' => $post_title,281 'post_content' => $post_content,282 'post_type' => 'attachment',283 'post_parent' => $post_parent,284 'post_mime_type' => $type,285 'guid' => $url286 );287 288 // Save the data289 $id = wp_insert_attachment($attachment, $file, $post_parent);290 if ( !is_wp_error($id) )291 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );292 293 return $id;294 63 } 295 64 … … 372 141 } 373 142 374 function media_buttons() { // just a placeholder for now143 function media_buttons() { 375 144 global $post_ID, $temp_ID; 376 145 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 377 $image_upload_iframe_src = wp_nonce_url("media-upload.php?type=image&post_id=$uploading_iframe_ID", 'inlineuploading'); 378 $image_upload_iframe_src = apply_filters('image_upload_iframe_src', $image_upload_iframe_src); 379 $multimedia_upload_iframe_src = wp_nonce_url("media-upload.php?type=multimedia&post_id=$uploading_iframe_ID", 'inlineuploading'); 146 $multimedia_upload_iframe_src = "media-upload.php?type=multimedia&post_id=$uploading_iframe_ID"; 380 147 $multimedia_upload_iframe_src = apply_filters('multimedia_upload_iframe_src', $multimedia_upload_iframe_src); 381 $out = <<<EOF 382 383 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=550&width=480" class="thickbox"><img src='images/media-button-image.gif' alt='' /></a> 384 <a href="{$multimedia_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox"><img src='images/media-button-gallery.gif' alt='' /></a> 385 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox"><img src='images/media-button-video.gif' alt='' /></a> 386 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox"><img src='images/media-button-music.gif' alt='' /></a> 387 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox"><img src='images/media-button-other.gif' alt='' /></a> 388 389 390 EOF; 391 echo $out; 148 echo "<a href='$multimedia_upload_iframe_src&TB_iframe=true&height=500&width=640' class='button thickbox'>" . __('Add media'). '</a>'; 392 149 } 393 150 add_action( 'media_buttons', 'media_buttons' ); … … 523 280 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 524 281 $form_fields['post_title']['required'] = true; 525 $form_fields['post_excerpt']['label'] = __('Alternate Text'); 526 $form_fields['post_content']['label'] = __('Description'); 527 528 if ( strlen(trim($post->post_excerpt)) == 0 ) 529 $form_fields['post_excerpt']['helps'][] = __('Alternate Text helps people who can not see the image.'); 282 $form_fields['post_excerpt']['label'] = __('Description'); 283 $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"'); 284 285 $form_fields['post_content']['label'] = __('Long Description'); 286 287 $thumb = wp_get_attachment_thumb_url(); 530 288 531 289 $form_fields['_send']['url'] = array( … … 548 306 <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n", 549 307 ); 308 $form_fields['_send']['image-size'] = array( 309 'label' => __('Size'), 310 'input' => 'html', 311 'html' => " 312 " . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumb' /> 313 <label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label> 314 " : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' /> 315 <label for='image-size-medium-$post->ID'>" . __('Medium') . "</label> 316 <input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' /> 317 <label for='image-size-full-$post->ID'>" . __('Full size') . "</label>", 318 ); 550 319 } 551 320 return $form_fields; … … 582 351 $align = 'none'; 583 352 584 return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel); 353 if ( !empty($attachment['image-size']) ) 354 $size = $attachment['image-size']; 355 else 356 $size = 'medium'; 357 358 return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); 585 359 } 586 360 … … 604 378 ), 605 379 'post_excerpt' => array( 606 'label' => __(' Excerpt'),380 'label' => __('Description'), 607 381 'value' => $edit_post->post_excerpt, 608 382 ), 609 383 'post_content' => array( 610 'label' => __(' Description'),384 'label' => __('Long description'), 611 385 'value' => $edit_post->post_content, 612 386 'input' => 'textarea', … … 638 412 // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) 639 413 $form_fields = array_merge_recursive($form_fields, (array) $errors); 640 414 641 415 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); 642 416 … … 645 419 646 420 function get_multimedia_item( $attachment_id, $errors = null, $send = true ) { 647 $thumb_url = wp_get_attachment_thumb_url( $attachment_id ); 648 if ( empty($thumb_url) ) 649 $thumb_url = wp_mime_type_icon( $attachment_id ); 650 if ( empty($thumb_url) && ( $post =& get_post( $attachment_id ) ) && substr($post->post_mime_type, 0, 5) == 'image' ) 651 $thumb_url = wp_get_attachment_url( $attachment_id ); 421 $thumb_url = array_shift(get_attachment_icon_src( $attachment_id )); 652 422 653 423 $title_label = __('Title'); … … 655 425 $tags_label = __('Tags'); 656 426 657 $toggle_on = __(' Describe');658 $toggle_off = __(' Describe «');427 $toggle_on = __('Show'); 428 $toggle_off = __('Hide'); 659 429 660 430 $post = get_post($attachment_id); … … 698 468 699 469 if ( empty($form_fields['save']) && empty($form_fields['_send']) ) { 700 $form_fields['save'] = array('tr' => "\t\t<tr class='submit'><td colspan='2' class='del'><a id='del[$attachment_id]' class='delete ' href='$delete_href'>$delete</a></td><td class='savesend'>$save$send</td></tr>\n");470 $form_fields['save'] = array('tr' => "\t\t<tr class='submit'><td colspan='2' class='del'><a id='del[$attachment_id]' class='delete button' href='$delete_href'>$delete</a></td><td class='savesend'>$save$send</td></tr>\n"); 701 471 } elseif ( empty($form_fields['save']) ) { 702 472 $form_fields['save'] = array('tr' => "\t\t<tr class='submit'><td></td><td></td><td class='savesend'>$save</td></tr>\n"); 703 473 foreach ( $form_fields['_send'] as $id => $field ) 704 474 $form_fields[$id] = $field; 705 $form_fields['send'] = array('tr' => "\t\t<tr class='submit'><td colspan='2' class='del'><a id='del[$attachment_id]' class='delete ' href='$delete_href'>$delete</a></td><td class='savesend'>$send</td>");475 $form_fields['send'] = array('tr' => "\t\t<tr class='submit'><td colspan='2' class='del'><a id='del[$attachment_id]' class='delete button' href='$delete_href'>$delete</a></td><td class='savesend'>$send</td>"); 706 476 } 707 477 … … 774 544 ?> 775 545 <div id="media-upload-header"> 776 <h3><?php _e('Add Images'); ?></h3> 546 <h3><?php _e('Add Media'); ?></h3> 547 <?php the_image_upload_tabs(); ?> 777 548 </div> 778 <div id="media-upload-error"> 549 550 <div id="media-upload-error"> 779 551 <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?> 780 552 <?php echo $errors['upload_error']->get_error_message(); ?> 781 553 <?php } ?> 782 554 </div> 783 555 <script type="text/javascript"> 784 556 <!-- … … 796 568 swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available 797 569 degraded_element_id : "html-upload-ui", // when swfupload is unavailable 798 swfupload_loaded_handler : uploadLoadedMultimedia, 799 //upload_start_handler : uploadStart, 800 upload_progress_handler : uploadProgressMultimedia, 801 //upload_error_handler : uploadError, 802 upload_success_handler : uploadSuccessMultimedia, 803 upload_complete_handler : uploadCompleteMultimedia, 570 swfupload_loaded_handler : uploadLoaded, 804 571 file_dialog_start_handler : fileDialogStart, 805 file_queued_handler : fileQueuedMultimedia, 572 file_queued_handler : fileQueued, 573 upload_start_handler : uploadStart, 574 upload_progress_handler : uploadProgress, 575 upload_error_handler : uploadError, 576 upload_success_handler : uploadSuccess, 577 upload_complete_handler : uploadComplete, 806 578 file_queue_error_handler : fileQueueError, 807 579 file_dialog_complete_handler : fileDialogComplete, … … 811 583 $("#flash-browse-button").bind( "click", function(){swfu.selectFiles();}); 812 584 var preloaded = $(".multimedia-item.preloaded"); 813 if ( preloaded ) {585 if ( preloaded.length > 0 ) { 814 586 jQuery('#insert-multimedia').attr('disabled', ''); 815 preloaded.each(function(){uploadSuccessMultimedia({id:this.id.replace(/[^0-9]/g, '')},'');}); 816 } 817 $("a.delete").bind('click',function(){$.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/del/,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});$(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){$(this).remove();});return false;}); 587 preloaded.each(function(){uploadSuccess({id:this.id.replace(/[^0-9]/g, '')},'');}); 588 } 818 589 }); 819 590 //--> 820 591 </script> 821 <p id="flash-upload-ui" style="display:none">822 <input id="flash-browse-button" type="button" value="<?php _e('Choose Files'); ?>" />823 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label>824 </p>825 592 826 593 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form"> 594 595 <div id="flash-upload-ui"> 596 <p><input id="flash-browse-button" type="button" value="<?php _e('Choose files to upload'); ?>" class="button" /></p> 597 <p><?php _e('As each upload completes, you can add titles and descriptions below.'); ?></p> 598 </div> 827 599 828 600 <div id="html-upload-ui"> … … 839 611 </div> 840 612 841 842 843 613 <div id="multimedia-items"> 844 614 … … 848 618 849 619 <p class="submit"> 850 <a href="#" onClick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a> 851 <input type="submit" class="submit" id="insert-multimedia" name="insert-multimedia" value="<?php _e('Insert gallery into post'); ?>" disabled="disabled" /> 620 <input type="submit" class="submit insert-gallery" name="insert-multimedia" value="<?php _e('Insert gallery into post'); ?>" /> 852 621 </p> 853 622 … … 863 632 add_filter('media_upload_multimedia', 'multimedia_upload_handler'); 864 633 634 865 635 // Any 'attachment' taxonomy will be included in the description input form for the multi uploader 866 636 // Example: 637 /* 867 638 register_taxonomy( 868 //869 639 'image_people', 870 640 'attachment:image', 871 641 array( 872 642 'label' => __('People'), 873 'template' => __('People: %s'), 643 'template' => __('People: %l'), 644 'helps' => __('Left to right, top to bottom.'), 874 645 'sort' => true, 875 646 'args' => array( … … 878 649 ) 879 650 ); 651 */ 652 /* 653 register_taxonomy('movie_director', 'attachment:video', array('label'=>__('Directors'), 'template'=>__('Directed by %l.'))); 654 register_taxonomy('movie_producer', 'attachment:video', array('label'=>__('Producers'), 'template'=>__('Produced by %l.'))); 655 register_taxonomy('movie_screenwriter', 'attachment:video', array('label'=>__('Screenwriter'), 'template'=>__('Screenplay by %l.'))); 656 register_taxonomy('movie_actor', 'attachment:video', array('label'=>__('Cast'), 'template'=>array(__('Cast: %l.'))); 657 register_taxonomy('movie_crew', 'attachment:video', array('label'=>__('Crew'), 'template'=>array(__('Crew: %l.'))); 658 */ 880 659 881 660 ?> -
trunk/wp-includes/default-filters.php
r6789 r6974 126 126 add_filter('single_post_title', 'wptexturize'); 127 127 128 add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2); 129 128 130 // RSS filters 129 131 add_filter('the_title_rss', 'strip_tags'); -
trunk/wp-includes/formatting.php
r6767 r6974 1278 1278 } 1279 1279 1280 /** 1281 * wp_sprintf() - sprintf() with filters 1282 */ 1283 function wp_sprintf( $pattern ) { 1284 $args = func_get_args( ); 1285 $len = strlen($pattern); 1286 $start = 0; 1287 $result = ''; 1288 $arg_index = 0; 1289 while ( $len > $start ) { 1290 // Last character: append and break 1291 if ( strlen($pattern) - 1 == $start ) { 1292 $result .= substr($pattern, -1); 1293 break; 1294 } 1295 1296 // Literal %: append and continue 1297 if ( substr($pattern, $start, 2) == '%%' ) { 1298 $start += 2; 1299 $result .= '%'; 1300 continue; 1301 } 1302 1303 // Get fragment before next % 1304 $end = strpos($pattern, '%', $start + 1); 1305 if ( false === $end ) 1306 $end = $len; 1307 $fragment = substr($pattern, $start, $end - $start); 1308 1309 // Fragment has a specifier 1310 if ( $pattern{$start} == '%' ) { 1311 // Find numbered arguments or take the next one in order 1312 if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) { 1313 $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : ''; 1314 $fragment = str_replace("%{$matches[1]}$", '%', $fragment); 1315 } else { 1316 ++$arg_index; 1317 $arg = isset($args[$arg_index]) ? $args[$arg_index] : ''; 1318 } 1319 1320 // Apply filters OR sprintf 1321 $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); 1322 if ( $_fragment != $fragment ) 1323 $fragment = $_fragment; 1324 else 1325 $fragment = sprintf($fragment, strval($arg) ); 1326 } 1327 1328 // Append to result and move to next fragment 1329 $result .= $fragment; 1330 $start = $end; 1331 } 1332 return $result; 1333 } 1334 1335 /** 1336 * wp_sprintf_l - List specifier %l for wp_sprintf 1337 * 1338 * @param unknown_type $pattern 1339 * @param unknown_type $args 1340 * @return unknown 1341 */ 1342 function wp_sprintf_l($pattern, $args) { 1343 // Not a match 1344 if ( substr($pattern, 0, 2) != '%l' ) 1345 return $pattern; 1346 1347 // Nothing to work with 1348 if ( empty($args) ) 1349 return ''; 1350 1351 // Translate and filter the delimiter set (avoid ampersands and entities here) 1352 $l = apply_filters('wp_sprintf_l', array( 1353 'between' => _c(', |between list items'), 1354 'between_last_two' => _c(', and |between last two list items'), 1355 'between_only_two' => _c(' and |between only two list items'), 1356 )); 1357 1358 $args = (array) $args; 1359 $result = array_shift($args); 1360 if ( count($args) == 1 ) 1361 $result .= $l['between_two'] . array_shift($args); 1362 // Loop when more than two args 1363 while ( count($args) ) { 1364 $arg = array_shift($args); 1365 if ( $i == 1 ) 1366 $result .= $l['between_last_two'] . $arg; 1367 else 1368 $result .= $l['between'] . $arg; 1369 } 1370 return $result . substr($pattern, 2); 1371 } 1372 1280 1373 ?> -
trunk/wp-includes/general-template.php
r6930 r6974 942 942 if ( $media_buttons ) { ?> 943 943 <div id="media-buttons"> 944 <?php _e('Add media:'); ?> 945 <?php do_action( 'media_buttons'); ?> 944 <?php do_action( 'media_buttons' ); ?> 946 945 </div> 947 946 <?php } ?> -
trunk/wp-includes/js/swfupload/handlers.js
r6876 r6974 1 function uploadLoadedMultimedia() { 2 jQuery("#html-upload-ui").empty(); 1 function uploadLoaded() { 2 jQuery("#html-upload-ui").remove(); 3 jQuery("#flash-upload-ui").show(); 3 4 } 4 5 … … 8 9 9 10 // progress and success handlers for multimedia multi uploads 10 function fileQueued Multimedia(fileObj) {11 function fileQueued(fileObj) { 11 12 // Create a progress bar containing the filename 12 13 jQuery('#multimedia-items').append('<div id="multimedia-item-' + fileObj.id + '" class="multimedia-item"><span class="filename original">' + fileObj.name + '</span><div class="progress"><div class="bar"></div></div></div>'); … … 16 17 } 17 18 18 function uploadProgressMultimedia(fileObj, bytesDone, bytesTotal) { 19 function uploadStart(fileObj) { return true; } 20 21 function uploadProgress(fileObj, bytesDone, bytesTotal) { 19 22 // Lengthen the progress bar 20 23 jQuery('#multimedia-item-' + fileObj.id + ' .bar').width(620*bytesDone/bytesTotal); 21 24 } 22 25 23 function uploadSuccess Multimedia(fileObj, serverData) {26 function uploadSuccess(fileObj, serverData) { 24 27 // if async-upload returned an error message, place it in the multimedia item div and return 25 28 if ( serverData.match('media-upload-error') ) { … … 35 38 36 39 // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename 37 jQuery('#multimedia-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail ').prependTo('#multimedia-item-' + fileObj.id);40 jQuery('#multimedia-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#multimedia-item-' + fileObj.id); 38 41 39 42 // Replace the original filename with the new (unique) one assigned during upload … … 47 50 48 51 // Bind AJAX to the new Delete button 49 jQuery('#multimedia-item-' + fileObj.id + ' a.delete').bind('click',function(){jQuery.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/[^0-9]/g,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});jQuery(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){jQuery(this).remove(); });return false;});52 jQuery('#multimedia-item-' + fileObj.id + ' a.delete').bind('click',function(){jQuery.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/[^0-9]/g,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});jQuery(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){jQuery(this).remove();if(jQuery('.multimedia-item').length==0)jQuery('.insert-gallery').hide();});return false;}); 50 53 51 54 // Open this item if it says to start open … … 54 57 .slideToggle(500) 55 58 .parent().eq(0).children('.toggle').toggle(); 59 60 jQuery('.insert-gallery').show(); 56 61 } 57 62 58 function uploadComplete Multimedia(fileObj) {63 function uploadComplete(fileObj) { 59 64 // If no more uploads queued, enable the submit button 60 65 if ( swfu.getStats().files_queued == 0 ) … … 62 67 } 63 68 64 65 // progress and success handlers for single image upload66 67 function uploadLoadedImage() {68 jQuery('#image-alt').attr('disabled', true);69 jQuery('#image-url').attr('disabled', true);70 jQuery('#image-title').attr('disabled', true);71 jQuery('#image-add').attr('disabled', true);72 }73 74 function fileQueuedImage(fileObj) {75 jQuery('#flash-upload-ui').append('<div id="image-progress"><p class="filename">' + fileObj.name + '</p><div class="progress"><div class="bar"></div></div></div>');76 }77 78 function uploadProgressImage(fileObj, bytesDone, bytesTotal) {79 jQuery('#image-progress .bar').width(450*bytesDone/bytesTotal);80 }81 82 function uploadSuccessImage(fileObj, serverData) {83 if ( serverData.match('media-upload-error') ) {84 jQuery('#media-upload-error').replaceWith(serverData);85 jQuery('#image-progress').replaceWith('');86 }87 else {88 jQuery('#media-upload-error').replaceWith('');89 jQuery('#flash-upload-ui').replaceWith(serverData);90 }91 }92 69 93 70 // wp-specific error handlers … … 122 99 } 123 100 124 function fileQueued(fileObj) {125 try {126 var txtFileName = document.getElementById("txtFileName");127 txtFileName.value = fileObj.name;128 } catch (e) { }129 130 }131 132 101 function fileDialogComplete(num_files_queued) { 133 102 try { … … 140 109 } 141 110 142 function uploadProgress(fileObj, bytesLoaded, bytesTotal) { 111 function uploadError(fileObj, error_code, message) { 112 alert(message);return; 113 // first the file specific error 114 if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) { 115 wpFileError(fileObj, swfuploadL10n.missing_upload_url); 116 } 117 else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) { 118 wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded); 119 } 120 else { 121 wpFileError(fileObj, swfuploadL10n.default_error); 122 } 143 123 144 try { 145 var percent = Math.ceil((bytesLoaded / bytesTotal) * 100) 146 147 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file 148 var progress = new FileProgress(fileObj, this.customSettings.progress_target); 149 progress.SetProgress(percent); 150 progress.SetStatus("Uploading..."); 151 } catch (e) { } 124 // now the general upload status 125 if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) { 126 wpQueueError(swfuploadL10n.http_error); 127 } 128 else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) { 129 wpQueueError(swfuploadL10n.upload_failed); 130 } 131 else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) { 132 wpQueueError(swfuploadL10n.io_error); 133 } 134 else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) { 135 wpQueueError(swfuploadL10n.security_error); 136 } 137 else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) { 138 wpQueueError(swfuploadL10n.security_error); 139 } 152 140 } 153 154 function uploadSuccess(fileObj, server_data) {155 try {156 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file157 var progress = new FileProgress(fileObj, this.customSettings.progress_target);158 progress.SetComplete();159 progress.SetStatus("Complete.");160 progress.ToggleCancel(false);161 162 if (server_data === " ") {163 this.customSettings.upload_successful = false;164 } else {165 this.customSettings.upload_successful = true;166 document.getElementById("hidFileID").value = server_data;167 }168 169 } catch (e) { }170 }171 172 function uploadComplete(fileObj) {173 try {174 if (this.customSettings.upload_successful) {175 document.getElementById("btnBrowse").disabled = "true";176 uploadDone();177 } else {178 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file179 var progress = new FileProgress(fileObj, this.customSettings.progress_target);180 progress.SetError();181 progress.SetStatus("File rejected");182 progress.ToggleCancel(false);183 184 var txtFileName = document.getElementById("txtFileName");185 txtFileName.value = "";186 //validateForm();187 188 alert("There was a problem with the upload.\nThe server did not accept it.");189 }190 } catch (e) { }191 }192 193 function uploadError(fileObj, error_code, message) {194 195 // first the file specific error196 if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {197 wpFileError(fileObj, swfuploadL10n.missing_upload_url);198 }199 else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) {200 wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded);201 }202 else {203 wpFileError(fileObj, swfuploadL10n.default_error);204 }205 206 // not sure if this is needed207 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file208 var progress = new FileProgress(fileObj, this.customSettings.progress_target);209 progress.SetError();210 progress.ToggleCancel(false);211 212 // now the general upload status213 if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) {214 wpQueueError(swfuploadL10n.http_error);215 }216 else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) {217 wpQueueError(swfuploadL10n.upload_failed);218 }219 else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) {220 wpQueueError(swfuploadL10n.io_error);221 }222 else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) {223 wpQueueError(swfuploadL10n.security_error);224 }225 else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) {226 wpQueueError(swfuploadL10n.security_error);227 }228 }229 230 231 /* ********************************************************232 * Utility for displaying the file upload information233 * This is not part of SWFUpload, just part of the demo234 * ******************************************************** */235 function FileProgress(fileObj, target_id) {236 this.file_progress_id = fileObj.id;237 238 this.fileProgressElement = document.getElementById(this.file_progress_id);239 if (!this.fileProgressElement) {240 this.fileProgressElement = document.createElement("div");241 this.fileProgressElement.className = "progressContainer";242 this.fileProgressElement.id = this.file_progress_id;243 244 var progressCancel = document.createElement("a");245 progressCancel.className = "progressCancel";246 progressCancel.href = "#";247 progressCancel.style.visibility = "hidden";248 progressCancel.appendChild(document.createTextNode(" "));249 250 var progressText = document.createElement("div");251 progressText.className = "progressName";252 progressText.appendChild(document.createTextNode(fileObj.name));253 254 var progressBar = document.createElement("div");255 progressBar.className = "progressBarInProgress";256 257 var progressStatus = document.createElement("div");258 progressStatus.className = "progressBarStatus";259 progressStatus.innerHTML = " ";260 261 this.fileProgressElement.appendChild(progressCancel);262 this.fileProgressElement.appendChild(progressText);263 this.fileProgressElement.appendChild(progressStatus);264 this.fileProgressElement.appendChild(progressBar);265 266 document.getElementById(target_id).appendChild(this.fileProgressElement);267 268 }269 270 }271 FileProgress.prototype.SetStart = function() {272 this.fileProgressElement.className = "progressContainer";273 this.fileProgressElement.childNodes[3].className = "progressBarInProgress";274 this.fileProgressElement.childNodes[3].style.width = "";275 }276 277 FileProgress.prototype.SetProgress = function(percentage) {278 this.fileProgressElement.className = "progressContainer green";279 this.fileProgressElement.childNodes[3].className = "progressBarInProgress";280 this.fileProgressElement.childNodes[3].style.width = percentage + "%";281 }282 FileProgress.prototype.SetComplete = function() {283 this.fileProgressElement.className = "progressContainer blue";284 this.fileProgressElement.childNodes[3].className = "progressBarComplete";285 this.fileProgressElement.childNodes[3].style.width = "";286 287 288 }289 FileProgress.prototype.SetError = function() {290 this.fileProgressElement.className = "progressContainer red";291 this.fileProgressElement.childNodes[3].className = "progressBarError";292 this.fileProgressElement.childNodes[3].style.width = "";293 }294 FileProgress.prototype.SetCancelled = function() {295 this.fileProgressElement.className = "progressContainer";296 this.fileProgressElement.childNodes[3].className = "progressBarError";297 this.fileProgressElement.childNodes[3].style.width = "";298 }299 FileProgress.prototype.SetStatus = function(status) {300 this.fileProgressElement.childNodes[2].innerHTML = status;301 }302 303 FileProgress.prototype.ToggleCancel = function(show, upload_obj) {304 this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";305 if (upload_obj) {306 var file_id = this.file_progress_id;307 this.fileProgressElement.childNodes[0].onclick = function() { upload_obj.cancelUpload(file_id); return false; };308 }309 } -
trunk/wp-includes/media.php
r6952 r6974 86 86 $hwstring = image_hwstring($width, $height); 87 87 88 $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="align-'.attribute_escape($align).' size-'.attribute_escape($size).' attachment wp-att-'.attribute_escape($id).'" />';88 $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="align-'.attribute_escape($align).' size-'.attribute_escape($size).' attachment wp-att-'.attribute_escape($id).'" />'; 89 89 90 90 $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); -
trunk/wp-includes/post-template.php
r6876 r6974 363 363 // 364 364 365 function the_attachment_link($id = 0, $fullsize = false, $max_dims = false ) {366 echo get_the_attachment_link($id, $fullsize, $max_dims );365 function the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { 366 echo get_the_attachment_link($id, $fullsize, $max_dims, $permalink); 367 367 } 368 368 -
trunk/wp-includes/post.php
r6951 r6974 2303 2303 function wp_mime_type_icon( $mime = 0 ) { 2304 2304 $post_id = 0; 2305 if ( is_numeric($mime) ) { 2306 $mime = (int) $mime; 2307 if ( !$post =& get_post( $mime ) ) 2308 return false; 2309 $post_id = (int) $post->ID; 2310 $mime = $post->post_mime_type; 2311 } 2312 2313 if ( empty($mime) ) 2314 return false; 2315 2316 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); 2317 $icon_dir_uri = apply_filters( 'icon_dir_uri', get_template_directory_uri() . '/images' ); 2318 2319 $types = array( 2320 substr($mime, 0, strpos($mime, '/')), 2321 substr($mime, strpos($mime, '/') + 1), 2322 str_replace('/', '_', $mime) 2323 ); 2324 2325 $exts = array('jpg', 'gif', 'png'); 2326 2327 $src = false; 2328 2329 foreach ( $types as $type ) { 2330 foreach ( $exts as $ext ) { 2331 $src_file = "$icon_dir/$type.$ext"; 2332 if ( file_exists($src_file) ) { 2333 $src = "$icon_dir_uri/$type.$ext"; 2334 break 2; 2305 2306 $icon = wp_cache_get('mime_type_icon'); 2307 2308 if ( empty($icon) ) { 2309 if ( is_numeric($mime) ) { 2310 $mime = (int) $mime; 2311 if ( !$post =& get_post( $mime ) ) 2312 return false; 2313 $post_id = (int) $post->ID; 2314 $mime = $post->post_mime_type; 2315 $ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid); 2316 } 2317 2318 $types = array(); 2319 2320 if ( !empty($ext) ) 2321 $types[] = $ext; 2322 2323 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); 2324 $icon_dir_uri = apply_filters( 'icon_dir_uri', get_template_directory_uri() . '/images' ); 2325 $image_dir = apply_filters( 'image_dir', ABSPATH . WPINC . '/images' ); 2326 $image_dir_uri = apply_filters( 'image_dir', get_option('siteurl') . '/' . WPINC . '/images' ); 2327 $dirs = array($icon_dir => $icon_dir_uri, $image_dir => $image_dir_uri); 2328 2329 2330 if ( ! empty($mime) ) { 2331 $types[] = substr($mime, 0, strpos($mime, '/')); 2332 $types[] = substr($mime, strpos($mime, '/') + 1); 2333 $types[] = str_replace('/', '_', $mime); 2334 } 2335 2336 $types[] = 'default'; 2337 2338 $exts = array('png', 'gif', 'jpg'); 2339 2340 foreach ( $types as $type ) { 2341 foreach ( $exts as $ext ) { 2342 foreach ( $dirs as $dir => $uri ) { 2343 $src_file = "$dir/$type.$ext"; 2344 if ( file_exists($src_file) ) { 2345 $icon = "$uri/$type.$ext"; 2346 break 3; 2347 } 2348 } 2335 2349 } 2336 2350 } 2337 2351 } 2338 2352 2339 return apply_filters( 'wp_mime_type_icon', $ src, $mime, $post_id ); // Last arg is 0 if function pass mime type.2353 return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type. 2340 2354 } 2341 2355 -
trunk/wp-includes/script-loader.php
r6971 r6974 95 95 $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2'); 96 96 $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2'); 97 $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-200802 16');97 $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080220'); 98 98 // these error messages came from the sample swfupload js, they might need changing. 99 99 $this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
Note: See TracChangeset
for help on using the changeset viewer.