Ticket #21329: 21329.5.diff
| File 21329.5.diff, 7.1 KB (added by , 14 years ago) |
|---|
-
wp-admin/includes/media.php
7 7 */ 8 8 9 9 /** 10 * {@internal Missing Short Description}}10 * Defines media tabs to be used in thickbox 11 11 * 12 12 * @since 2.5.0 13 13 * 14 * @return unknown 14 * @uses apply_filters() calls media_upload_tabs 15 * 16 * @return an associative array of tab names in the form of type=>name 15 17 */ 16 18 function media_upload_tabs() { 17 19 $_default_tabs = array( … … 25 27 } 26 28 27 29 /** 28 * {@internal Missing Short Description}} 30 * Added to media_upload_tabs filter to define the gallery tab 31 * checks for attachments and removes gallery tab if the current post has none. 29 32 * 30 33 * @since 2.5.0 31 34 * 32 * @param unknown_type$tabs33 * @return unknown35 * @param array $tabs 36 * @return an associative array of tab names in the form of type=>name 34 37 */ 35 38 function update_gallery_tab($tabs) { 36 39 global $wpdb; … … 57 60 add_filter('media_upload_tabs', 'update_gallery_tab'); 58 61 59 62 /** 60 * {@internal Missing Short Description}}63 * Echoes the thickbox media upload tabs to the screen 61 64 * 62 65 * @since 2.5.0 63 66 */ … … 65 68 global $redir_tab; 66 69 $tabs = media_upload_tabs(); 67 70 $default = 'type'; 68 71 $html = ''; 72 69 73 if ( !empty($tabs) ) { 70 echo"<ul id='sidemenu'>\n";74 $html = "<ul id='sidemenu'>\n"; 71 75 if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) 72 76 $current = $redir_tab; 73 77 elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) … … 83 87 84 88 $href = add_query_arg(array('tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false)); 85 89 $link = "<a href='" . esc_url($href) . "'$class>$text</a>"; 86 echo"\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n";90 $html .= "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n"; 87 91 } 88 echo"</ul>\n";92 $html .= "</ul>\n"; 89 93 } 94 echo $html; 90 95 } 91 96 92 97 /** 93 * {@internal Missing Short Description}}98 * Creates the html for an image as it is added to the editor 94 99 * 95 100 * @since 2.5.0 96 101 * 102 * @uses apply_filters() calls image_send_to_editor 97 103 * @param unknown_type $id 98 104 * @param unknown_type $alt 99 105 * @param unknown_type $title … … 101 107 * @param unknown_type $url 102 108 * @param unknown_type $rel 103 109 * @param unknown_type $size 104 * @return unknown110 * @return string - the html for an image tag 105 111 */ 106 112 function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') { 107 113 … … 118 124 } 119 125 120 126 /** 121 * {@internal Missing Short Description}}127 * Wraps an image in the caption code 122 128 * 123 129 * @since 2.6.0 124 130 * … … 170 176 } 171 177 172 178 /** 173 * {@internal Missing Short Description}}179 * Echoes the javascript used to send html back to the editor 174 180 * 175 181 * @since 2.5.0 176 182 * 177 * @param unknown_type$html183 * @param string $html 178 184 */ 179 185 function media_send_to_editor($html) { 180 186 ?> … … 189 195 } 190 196 191 197 /** 192 * {@internal Missing Short Description}}193 *194 198 * This handles the file upload POST itself, creating the attachment post. 195 199 * 196 200 * @since 2.5.0 … … 260 264 * 261 265 * @since 2.6.0 262 266 * 267 * @uses wp_handle_sideload 268 * @uses wp_read_image_metadata 269 * @uses wp_insert_attachment 270 * @uses wp_update_attachment_metadata 271 * @uses wp_generate_attachment_metadata 263 272 * @param array $file_array Array similar to a {@link $_FILES} upload array 264 273 * @param int $post_id The post ID the media is associated with 265 274 * @param string $desc Description of the sideloaded file … … 312 321 } 313 322 314 323 /** 315 * {@internal Missing Short Description}}324 * Generates html for the iframe used in the thickbox window for uploads 316 325 * 317 326 * Wrap iframe content (produced by $content_func) in a doctype, html head/body 318 327 * etc any additional function args will be passed to content_func. … … 373 382 } 374 383 375 384 /** 376 * {@internal Missing Short Description}} 385 * Echoes the html for media upload buttons 386 * added to the action call for 'media_buttons' 377 387 * 378 388 * @since 2.5.0 379 389 */ … … 386 396 } 387 397 add_action( 'media_buttons', 'media_buttons' ); 388 398 399 /** 400 * Determine url of the upload thickbox to be used in the media_buttons() link 401 * 402 * @uses apply_filters() calls $type . '_upload_iframe_src' 403 * @param string $type 404 * @param int $post_id 405 * @param string $tab 406 * @since unknown 407 */ 389 408 function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { 390 409 global $post_ID; 391 410 … … 565 584 566 585 if ( isset($_POST['save']) ) { 567 586 $errors['upload_notice'] = __('Saved.'); 568 return media_upload _gallery();587 return media_upload('gallery'); 569 588 } 570 589 571 590 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) { … … 625 644 } 626 645 627 646 /** 628 * {@internal Missing Short Description}} 647 * Returns wp_iframe with the proper upload form for media uploads 648 * added to the media_upload filter in media-upload.php 629 649 * 630 * @since 2.5.0650 * @since 3.5.0 631 651 * 632 * @return unknown652 * @return HTML from the wp_iframe function 633 653 */ 634 function media_upload _gallery() {654 function media_upload() { 635 655 $errors = array(); 636 637 if ( !empty($_POST) ) { 656 $current_filter = current_filter(); 657 $type = str_replace( 'media_upload_' , '' , $current_filter ); 658 659 if ( !empty($_POST) || empty($type) ) { 638 660 $return = media_upload_form_handler(); 639 640 661 if ( is_string($return) ) 641 662 return $return; 642 663 if ( is_array($return) ) … … 644 665 } 645 666 646 667 wp_enqueue_script('admin-gallery'); 647 return wp_iframe( 'media_upload_gallery_form', $errors ); 668 669 switch($type) { 670 case 'library' : 671 $return = 'media_upload_library_form'; 672 break; 673 case 'gallery' : 674 $return = 'media_upload_gallery_form'; 675 break; 676 default : 677 $return = 'wp_media_upload_handler'; 678 break; 679 } 680 return wp_iframe( $return , $errors ); 648 681 } 649 682 650 683 /** … … 654 687 * 655 688 * @return unknown 656 689 */ 690 function media_upload_gallery() { 691 media_upload( 'gallery' ); 692 } 693 694 /** 695 * {@internal Missing Short Description}} 696 * 697 * @since 2.5.0 698 * 699 * @return unknown 700 */ 657 701 function media_upload_library() { 658 $errors = array(); 659 if ( !empty($_POST) ) { 660 $return = media_upload_form_handler(); 661 662 if ( is_string($return) ) 663 return $return; 664 if ( is_array($return) ) 665 $errors = $return; 666 } 667 668 return wp_iframe( 'media_upload_library_form', $errors ); 702 media_upload( 'library' ); 669 703 } 670 704 671 705 /** … … 2100 2134 add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); 2101 2135 add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); 2102 2136 2103 add_action( 'media_upload_image', ' wp_media_upload_handler' );2104 add_action( 'media_upload_audio', ' wp_media_upload_handler' );2105 add_action( 'media_upload_video', ' wp_media_upload_handler' );2106 add_action( 'media_upload_file', ' wp_media_upload_handler' );2137 add_action( 'media_upload_image', 'media_upload' ); 2138 add_action( 'media_upload_audio', 'media_upload' ); 2139 add_action( 'media_upload_video', 'media_upload' ); 2140 add_action( 'media_upload_file', 'media_upload' ); 2107 2141 2108 add_filter( 'media_upload_gallery', 'media_upload _gallery' );2109 add_filter( 'media_upload_library', 'media_upload _library' );2142 add_filter( 'media_upload_gallery', 'media_upload' ); 2143 add_filter( 'media_upload_library', 'media_upload' );