X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/72836ec95a52eacbda4dc5aa296b7dd6de08bd3b..88550bc3400cc7c035ff590ecb007c7938041ded:/wp-admin/includes/media.php diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index e2f78d63..7fa4dd8f 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -21,7 +21,14 @@ function media_upload_tabs() { 'library' => __('Media Library') ); - return apply_filters('media_upload_tabs', $_default_tabs); + /** + * Filter the available tabs in the legacy (pre-3.5.0) media popup. + * + * @since 2.5.0 + * + * @param array $_default_tabs An array of media tabs. + */ + return apply_filters( 'media_upload_tabs', $_default_tabs ); } /** @@ -68,12 +75,14 @@ function the_media_upload_tabs() { if ( !empty($tabs) ) { echo "
$image_edit_button @@ -1224,8 +1439,11 @@ function get_media_item( $attachment_id, $args = null ) { 'extra_rows' => array(), ); - if ( $send ) - $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); + if ( $r['send'] ) { + $r['send'] = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); + } + + $delete = empty( $r['delete'] ) ? '' : $r['delete']; if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { if ( !EMPTY_TRASH_DAYS ) { $delete = "" . __( 'Delete Permanently' ) . ''; @@ -1245,19 +1463,20 @@ function get_media_item( $attachment_id, $args = null ) { $thumbnail = ''; $calling_post_id = 0; - if ( isset( $_GET['post_id'] ) ) + if ( isset( $_GET['post_id'] ) ) { $calling_post_id = absint( $_GET['post_id'] ); - elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set + } elseif ( isset( $_POST ) && count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set $calling_post_id = $post->post_parent; + } if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" ); $thumbnail = "" . esc_html__( "Use as featured image" ) . ""; } - if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) - $form_fields['buttons'] = array( 'tr' => "\t\t | ||
$send $thumbnail $delete | ||
" . $r['send'] . " $thumbnail $delete | ||
\n\t\t\t | "; + $item .= "\t\t | |
---|---|---|
\n\t\t\t | "; if ( !empty( $field[ $field['input'] ] ) ) $item .= $field[ $field['input'] ]; elseif ( $field['input'] == 'textarea' ) { if ( 'post_content' == $id && user_can_richedit() ) { - // sanitize_post() skips the post_content when user_can_richedit + // Sanitize_post() skips the post_content when user_can_richedit. $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); } - // post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit() + // Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit(). $item .= "'; } else { $item .= ""; @@ -1343,6 +1562,8 @@ function get_compat_media_markup( $attachment_id, $args = null ) { $user_can_edit = current_user_can( 'edit_post', $attachment_id ); $args = wp_parse_args( $args, $default_args ); + + /** This filter is documented in wp-admin/includes/media.php */ $args = apply_filters( 'get_media_item_args', $args ); $form_fields = array(); @@ -1376,21 +1597,23 @@ function get_compat_media_markup( $attachment_id, $args = null ) { // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) $form_fields = array_merge_recursive($form_fields, (array) $args['errors'] ); + /** This filter is documented in wp-admin/includes/media.php */ $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); + /** This filter is documented in wp-admin/includes/media.php */ $media_meta = apply_filters( 'media_meta', '', $post ); $defaults = array( 'input' => 'text', - 'required' => false, - 'value' => '', - 'extra_rows' => array(), - 'show_in_edit' => true, - 'show_in_modal' => true, + 'required' => false, + 'value' => '', + 'extra_rows' => array(), + 'show_in_edit' => true, + 'show_in_modal' => true, ); $hidden_fields = array(); @@ -1425,14 +1648,14 @@ function get_compat_media_markup( $attachment_id, $args = null ) { $class .= $field['required'] ? ' form-required' : ''; $item .= "\t\t | |
"; + $item .= "\t\t\t | "; $item .= " | \n\t\t\t";
if ( !empty( $field[ $field['input'] ] ) )
$item .= $field[ $field['input'] ];
elseif ( $field['input'] == 'textarea' ) {
if ( 'post_content' == $id && user_can_richedit() ) {
- // sanitize_post() skips the post_content when user_can_richedit
+ // sanitize_post() skips the post_content when user_can_richedit.
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
}
$item .= "';
@@ -1497,13 +1720,13 @@ function media_upload_header() {
*
* @since 2.5.0
*
- * @param unknown_type $errors
+ * @param array $errors
*/
function media_upload_form( $errors = null ) {
global $type, $tab, $is_IE, $is_opera;
if ( ! _device_can_upload() ) {
- echo ' ' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the native app for your device instead.'), 'http://wordpress.org/mobile/' ) . ' '; + echo '' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the native app for your device instead.'), 'https://apps.wordpress.org/' ) . ' '; return; } @@ -1512,18 +1735,9 @@ function media_upload_form( $errors = null ) { $_type = isset($type) ? $type : ''; $_tab = isset($tab) ? $tab : ''; - $upload_size_unit = $max_upload_size = wp_max_upload_size(); - $sizes = array( 'KB', 'MB', 'GB' ); - - for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) { - $upload_size_unit /= 1024; - } - - if ( $u < 0 ) { - $upload_size_unit = 0; - $u = 0; - } else { - $upload_size_unit = (int) $upload_size_unit; + $max_upload_size = wp_max_upload_size(); + if ( ! $max_upload_size ) { + $max_upload_size = 0; } ?> @@ -1541,44 +1755,70 @@ function media_upload_form( $errors = null ) { ?> $post_id, - "_wpnonce" => wp_create_nonce('media-form'), - "type" => $_type, - "tab" => $_tab, - "short" => "1", + "post_id" => $post_id, + "_wpnonce" => wp_create_nonce('media-form'), + "type" => $_type, + "tab" => $_tab, + "short" => "1", ); -$post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params' +/** + * Filter the media upload post parameters. + * + * @since 3.1.0 As 'swfupload_post_params' + * @since 3.3.0 + * + * @param array $post_params An array of media upload parameters used by Plupload. + */ +$post_params = apply_filters( 'upload_post_params', $post_params ); $plupload_init = array( - 'runtimes' => 'html5,silverlight,flash,html4', - 'browse_button' => 'plupload-browse-button', - 'container' => 'plupload-upload-ui', - 'drop_element' => 'drag-drop-area', - 'file_data_name' => 'async-upload', - 'multiple_queues' => true, - 'max_file_size' => $max_upload_size . 'b', - 'url' => $upload_action_url, - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), - 'filters' => array( array('title' => __( 'Allowed Files' ), 'extensions' => '*') ), - 'multipart' => true, - 'urlstream_upload' => true, - 'multipart_params' => $post_params + 'runtimes' => 'html5,flash,silverlight,html4', + 'browse_button' => 'plupload-browse-button', + 'container' => 'plupload-upload-ui', + 'drop_element' => 'drag-drop-area', + 'file_data_name' => 'async-upload', + 'url' => $upload_action_url, + 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), + 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ), + 'filters' => array( + 'max_file_size' => $max_upload_size . 'b', + ), + 'multipart_params' => $post_params, ); -// Multi-file uploading doesn't currently work in iOS Safari, -// single-file allows the built-in camera to be used as source for images -if ( wp_is_mobile() ) +// Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos +// when enabled. See #29602. +if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && + strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { + $plupload_init['multi_selection'] = false; +} +/** + * Filter the default Plupload settings. + * + * @since 3.3.0 + * + * @param array $plupload_init An array of default settings used by Plupload. + */ $plupload_init = apply_filters( 'plupload_init', $plupload_init ); ?> @@ -1594,11 +1834,18 @@ if( !$large_size_w ) $large_size_w = 1024; ?> var resize_height = , resize_width = , -wpUploaderInit = ; +wpUploaderInit = ;
-
+
-
+
100 * 1024 * 1024 ) { ?>
-
-/g, '>');
-
+
if ( f.caption.value ) {
caption = f.caption.value.replace(/\r\n|\r/g, '\n');
caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
@@ -1818,7 +2103,16 @@ jQuery(document).ready( function($) {
@@ -1606,11 +1853,25 @@ wpUploaderInit = ;
-
+
@@ -1872,7 +2165,7 @@ jQuery(function($){
|