X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/00dbffaf1593b0ac719d98f00839221a9ca52133..refs/tags/wordpress-4.7-scripts:/wp-admin/includes/media.php?ds=sidebyside diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index a8751f12..ede25b3d 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); + /** + * Filters 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 ); } /** @@ -29,6 +36,8 @@ function media_upload_tabs() { * * @since 2.5.0 * + * @global wpdb $wpdb WordPress database abstraction object. + * * @param array $tabs * @return array $tabs with gallery if post has image attachment */ @@ -54,12 +63,13 @@ function update_gallery_tab($tabs) { return $tabs; } -add_filter('media_upload_tabs', 'update_gallery_tab'); /** - * {@internal Missing Short Description}} + * Outputs the legacy media upload tabs UI. * * @since 2.5.0 + * + * @global string $redir_tab */ function the_media_upload_tabs() { global $redir_tab; @@ -68,12 +78,14 @@ function the_media_upload_tabs() { if ( !empty($tabs) ) { echo "
$image_edit_button @@ -1154,7 +1469,7 @@ function get_media_item( $attachment_id, $args = null ) { |
" . __('File name:') . " $filename " . __('File type:') . " $post->post_mime_type -" . __('Upload date:') . " " . mysql2date( get_option('date_format'), $post->post_date ). ' '; +" . __('Upload date:') . " " . mysql2date( __( 'F j, Y' ), $post->post_date ). ' '; if ( !empty( $media_dims ) ) $item .= "" . __('Dimensions:') . " $media_dims \n"; @@ -1163,8 +1478,9 @@ function get_media_item( $attachment_id, $args = null ) { $item .= " | |
" . sprintf( __( 'Required fields are marked %s' ), '*' ) . " | ||
$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()
- $item .= "';
+ // Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit().
+ $item .= "';
} else {
- $item .= "";
+ $item .= "";
}
if ( !empty( $field['helps'] ) )
$item .= " " . join( " \n", array_unique( (array) $field['helps'] ) ) . ' '; @@ -1281,6 +1608,13 @@ function get_media_item( $attachment_id, $args = null ) { return $item; } +/** + * @since 3.5.0 + * + * @param int $attachment_id + * @param array $args + * @return array + */ function get_compat_media_markup( $attachment_id, $args = null ) { $post = get_post( $attachment_id ); @@ -1292,6 +1626,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(); @@ -1322,24 +1658,26 @@ function get_compat_media_markup( $attachment_id, $args = null ) { } // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default - // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) + // 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(); @@ -1368,25 +1706,26 @@ function get_compat_media_markup( $attachment_id, $args = null ) { } $readonly = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : ''; - $required = $field['required'] ? '*' : ''; - $aria_required = $field['required'] ? " aria-required='true' " : ''; + $required = $field['required'] ? '*' : ''; + $required_attr = $field['required'] ? ' required' : ''; + $aria_required = $field['required'] ? " aria-required='true'" : ''; $class = 'compat-field-' . $id; $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 .= "';
+ $item .= "';
} else {
- $item .= "";
+ $item .= "";
}
if ( !empty( $field['helps'] ) )
$item .= " " . join( " \n", array_unique( (array) $field['helps'] ) ) . ' '; @@ -1410,8 +1749,12 @@ function get_compat_media_markup( $attachment_id, $args = null ) { if ( !empty( $form_fields['_final'] ) ) $item .= "\t\t |
{$form_fields['_final']} |
' . + sprintf( __( 'Required fields are marked %s' ), '*' ) . '
+' . __('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.') . '
'; + 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; } @@ -1461,18 +1810,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; } ?> @@ -1490,44 +1830,70 @@ function media_upload_form( $errors = null ) { ?>