| 1 | Index: wp-includes/js/media-views.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/media-views.js (revision 23060) |
|---|
| 4 | +++ wp-includes/js/media-views.js (working copy) |
|---|
| 5 | @@ -1558,6 +1558,10 @@ |
|---|
| 6 | multiple: options.multiple ? 'reset' : false, |
|---|
| 7 | editable: true, |
|---|
| 8 | |
|---|
| 9 | + // If the user isn't allowed to edit fields, |
|---|
| 10 | + // can they still edit it locally? |
|---|
| 11 | + allowLocalEdits: true, |
|---|
| 12 | + |
|---|
| 13 | // Show the attachment display settings. |
|---|
| 14 | displaySettings: true, |
|---|
| 15 | // Update user settings when users adjust the |
|---|
| 16 | @@ -2816,6 +2820,9 @@ |
|---|
| 17 | options.can.save = !! options.nonces.update; |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | + if ( this.controller.state().get('allowLocalEdits') ) |
|---|
| 21 | + options.allowLocalEdits = true; |
|---|
| 22 | + |
|---|
| 23 | this.views.detach(); |
|---|
| 24 | this.$el.html( this.template( options ) ); |
|---|
| 25 | |
|---|
| 26 | Index: wp-includes/media.php |
|---|
| 27 | =================================================================== |
|---|
| 28 | --- wp-includes/media.php (revision 23061) |
|---|
| 29 | +++ wp-includes/media.php (working copy) |
|---|
| 30 | @@ -1658,10 +1658,12 @@ |
|---|
| 31 | <a class="check" href="#" title="<?php _e('Deselect'); ?>"><div class="media-modal-icon"></div></a> |
|---|
| 32 | <# } #> |
|---|
| 33 | </div> |
|---|
| 34 | - <# if ( data.describe ) { #> |
|---|
| 35 | + <# |
|---|
| 36 | + var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; |
|---|
| 37 | + if ( data.describe ) { #> |
|---|
| 38 | <# if ( 'image' === data.type ) { #> |
|---|
| 39 | <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption" |
|---|
| 40 | - placeholder="<?php esc_attr_e('Describe this image…'); ?>" /> |
|---|
| 41 | + placeholder="<?php esc_attr_e('Describe this image…'); ?>" {{ maybeReadOnly }} /> |
|---|
| 42 | <# } else { #> |
|---|
| 43 | <input type="text" value="{{ data.title }}" class="describe" data-setting="title" |
|---|
| 44 | <# if ( 'video' === data.type ) { #> |
|---|
| 45 | @@ -1670,7 +1672,7 @@ |
|---|
| 46 | placeholder="<?php esc_attr_e('Describe this audio file…'); ?>" |
|---|
| 47 | <# } else { #> |
|---|
| 48 | placeholder="<?php esc_attr_e('Describe this media file…'); ?>" |
|---|
| 49 | - <# } #> /> |
|---|
| 50 | + <# } #> {{ maybeReadOnly }} /> |
|---|
| 51 | <# } #> |
|---|
| 52 | <# } #> |
|---|
| 53 | </script> |
|---|
| 54 | @@ -1713,25 +1715,27 @@ |
|---|
| 55 | </div> |
|---|
| 56 | </div> |
|---|
| 57 | |
|---|
| 58 | - <# if ( 'image' === data.type ) { #> |
|---|
| 59 | + <# |
|---|
| 60 | + var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; |
|---|
| 61 | + if ( 'image' === data.type ) { #> |
|---|
| 62 | <label class="setting" data-setting="title"> |
|---|
| 63 | <span><?php _e('Title'); ?></span> |
|---|
| 64 | - <input type="text" value="{{ data.title }}" /> |
|---|
| 65 | + <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> |
|---|
| 66 | </label> |
|---|
| 67 | <label class="setting" data-setting="caption"> |
|---|
| 68 | <span><?php _e('Caption'); ?></span> |
|---|
| 69 | - <textarea |
|---|
| 70 | + <textarea {{ maybeReadOnly }} |
|---|
| 71 | placeholder="<?php esc_attr_e('Describe this image…'); ?>" |
|---|
| 72 | >{{ data.caption }}</textarea> |
|---|
| 73 | </label> |
|---|
| 74 | <label class="setting" data-setting="alt"> |
|---|
| 75 | <span><?php _e('Alt Text'); ?></span> |
|---|
| 76 | - <input type="text" value="{{ data.alt }}" /> |
|---|
| 77 | + <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> |
|---|
| 78 | </label> |
|---|
| 79 | <# } else { #> |
|---|
| 80 | <label class="setting" data-setting="title"> |
|---|
| 81 | <span><?php _e('Title'); ?></span> |
|---|
| 82 | - <input type="text" value="{{ data.title }}" |
|---|
| 83 | + <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} |
|---|
| 84 | <# if ( 'video' === data.type ) { #> |
|---|
| 85 | placeholder="<?php esc_attr_e('Describe this video…'); ?>" |
|---|
| 86 | <# } else if ( 'audio' === data.type ) { #> |
|---|
| 87 | Index: wp-admin/includes/media.php |
|---|
| 88 | =================================================================== |
|---|
| 89 | --- wp-admin/includes/media.php (revision 23060) |
|---|
| 90 | +++ wp-admin/includes/media.php (working copy) |
|---|
| 91 | @@ -1290,6 +1290,8 @@ |
|---|
| 92 | 'description' => false, |
|---|
| 93 | ); |
|---|
| 94 | |
|---|
| 95 | + $user_can_edit = current_user_can( 'edit_post', $attachment_id ); |
|---|
| 96 | + |
|---|
| 97 | $args = wp_parse_args( $args, $default_args ); |
|---|
| 98 | $args = apply_filters( 'get_media_item_args', $args ); |
|---|
| 99 | |
|---|
| 100 | @@ -1314,6 +1316,7 @@ |
|---|
| 101 | foreach ( $terms as $term ) |
|---|
| 102 | $values[] = $term->slug; |
|---|
| 103 | $t['value'] = join(', ', $values); |
|---|
| 104 | + $t['taxonomy'] = true; |
|---|
| 105 | |
|---|
| 106 | $form_fields[$taxonomy] = $t; |
|---|
| 107 | } |
|---|
| 108 | @@ -1363,6 +1366,7 @@ |
|---|
| 109 | continue; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | + $readonly = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : ''; |
|---|
| 113 | $required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : ''; |
|---|
| 114 | $aria_required = $field['required'] ? " aria-required='true' " : ''; |
|---|
| 115 | $class = 'compat-field-' . $id; |
|---|
| 116 | @@ -1381,7 +1385,7 @@ |
|---|
| 117 | } |
|---|
| 118 | $item .= "<textarea id='$id_attr' name='$name' $aria_required>" . $field['value'] . '</textarea>'; |
|---|
| 119 | } else { |
|---|
| 120 | - $item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />"; |
|---|
| 121 | + $item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly $aria_required />"; |
|---|
| 122 | } |
|---|
| 123 | if ( !empty( $field['helps'] ) ) |
|---|
| 124 | $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; |
|---|