]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/media-template.php
WordPress 3.8.2-scripts
[autoinstalls/wordpress.git] / wp-includes / media-template.php
1 <?php
2 /**
3  * WordPress media templates.
4  *
5  * @package WordPress
6  * @subpackage Media
7  * @since 3.5.0
8  */
9
10 /**
11  * Prints the templates used in the media manager.
12  *
13  * @since 3.5.0
14  */
15 function wp_print_media_templates() {
16         global $is_IE;
17         $class = 'media-modal wp-core-ui';
18         if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false )
19                 $class .= ' ie7';
20         ?>
21         <script type="text/html" id="tmpl-media-frame">
22                 <div class="media-frame-menu"></div>
23                 <div class="media-frame-title"></div>
24                 <div class="media-frame-router"></div>
25                 <div class="media-frame-content"></div>
26                 <div class="media-frame-toolbar"></div>
27                 <div class="media-frame-uploader"></div>
28         </script>
29
30         <script type="text/html" id="tmpl-media-modal">
31                 <div class="<?php echo $class; ?>">
32                         <a class="media-modal-close" href="#" title="<?php esc_attr_e('Close'); ?>"><span class="media-modal-icon"></span></a>
33                         <div class="media-modal-content"></div>
34                 </div>
35                 <div class="media-modal-backdrop"></div>
36         </script>
37
38         <script type="text/html" id="tmpl-uploader-window">
39                 <div class="uploader-window-content">
40                         <h3><?php _e( 'Drop files to upload' ); ?></h3>
41                 </div>
42         </script>
43
44         <script type="text/html" id="tmpl-uploader-inline">
45                 <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #>
46                 <div class="uploader-inline-content {{ messageClass }}">
47                 <# if ( data.message ) { #>
48                         <h3 class="upload-message">{{ data.message }}</h3>
49                 <# } #>
50                 <?php if ( ! _device_can_upload() ) : ?>
51                         <h3 class="upload-instructions"><?php printf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'http://wordpress.org/mobile/' ); ?></h3>
52                 <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
53                         <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3>
54                         <?php
55                         /** This action is documented in wp-admin/includes/media.php */
56                         do_action( 'upload_ui_over_quota' ); ?>
57
58                 <?php else : ?>
59                         <div class="upload-ui">
60                                 <h3 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3>
61                                 <a href="#" class="browser button button-hero"><?php _e( 'Select Files' ); ?></a>
62                         </div>
63
64                         <div class="upload-inline-status"></div>
65
66                         <div class="post-upload-ui">
67                                 <?php
68                                 /** This action is documented in wp-admin/includes/media.php */
69                                 do_action( 'pre-upload-ui' );
70                                 /** This action is documented in wp-admin/includes/media.php */
71                                 do_action( 'pre-plupload-upload-ui' );
72
73                                 if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) {
74                                         /** This action is documented in wp-admin/includes/media.php */
75                                         do_action( 'post-plupload-upload-ui' );
76                                         add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
77                                 } else {
78                                         /** This action is documented in wp-admin/includes/media.php */
79                                         do_action( 'post-plupload-upload-ui' );
80                                 }
81
82                                 $upload_size_unit = $max_upload_size = wp_max_upload_size();
83                                 $byte_sizes = array( 'KB', 'MB', 'GB' );
84
85                                 for ( $u = -1; $upload_size_unit > 1024 && $u < count( $byte_sizes ) - 1; $u++ ) {
86                                         $upload_size_unit /= 1024;
87                                 }
88
89                                 if ( $u < 0 ) {
90                                         $upload_size_unit = 0;
91                                         $u = 0;
92                                 } else {
93                                         $upload_size_unit = (int) $upload_size_unit;
94                                 }
95
96                                 ?>
97
98                                 <p class="max-upload-size"><?php
99                                         printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
100                                 ?></p>
101
102                                 <?php if ( ( $GLOBALS['is_IE'] || $GLOBALS['is_opera']) && $max_upload_size > 100 * 1024 * 1024 ) :
103                                         $browser_uploader = admin_url( 'media-new.php?browser-uploader&post_id=' ) . '{{ data.postId }}';
104                                         ?>
105                                         <p class="big-file-warning"><?php printf( __( 'Your browser has some limitations uploading large files with the multi-file uploader. Please use the <a href="%1$s" target="%2$s">browser uploader</a> for files over 100MB.' ),
106                                                 $browser_uploader, '_blank' ); ?></p>
107                                 <?php endif; ?>
108
109                                 <?php
110                                 /** This action is documented in wp-admin/includes/media.php */
111                                 do_action( 'post-upload-ui' ); ?>
112                         </div>
113                 <?php endif; ?>
114                 </div>
115         </script>
116
117         <script type="text/html" id="tmpl-uploader-status">
118                 <h3><?php _e( 'Uploading' ); ?></h3>
119                 <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?></a>
120
121                 <div class="media-progress-bar"><div></div></div>
122                 <div class="upload-details">
123                         <span class="upload-count">
124                                 <span class="upload-index"></span> / <span class="upload-total"></span>
125                         </span>
126                         <span class="upload-detail-separator">&ndash;</span>
127                         <span class="upload-filename"></span>
128                 </div>
129                 <div class="upload-errors"></div>
130         </script>
131
132         <script type="text/html" id="tmpl-uploader-status-error">
133                 <span class="upload-error-label"><?php _e('Error'); ?></span>
134                 <span class="upload-error-filename">{{{ data.filename }}}</span>
135                 <span class="upload-error-message">{{ data.message }}</span>
136         </script>
137
138         <script type="text/html" id="tmpl-attachment">
139                 <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
140                         <# if ( data.uploading ) { #>
141                                 <div class="media-progress-bar"><div></div></div>
142                         <# } else if ( 'image' === data.type ) { #>
143                                 <div class="thumbnail">
144                                         <div class="centered">
145                                                 <img src="{{ data.size.url }}" draggable="false" />
146                                         </div>
147                                 </div>
148                         <# } else { #>
149                                 <img src="{{ data.icon }}" class="icon" draggable="false" />
150                                 <div class="filename">
151                                         <div>{{ data.filename }}</div>
152                                 </div>
153                         <# } #>
154
155                         <# if ( data.buttons.close ) { #>
156                                 <a class="close media-modal-icon" href="#" title="<?php _e('Remove'); ?>"></a>
157                         <# } #>
158
159                         <# if ( data.buttons.check ) { #>
160                                 <a class="check" href="#" title="<?php _e('Deselect'); ?>"><div class="media-modal-icon"></div></a>
161                         <# } #>
162                 </div>
163                 <#
164                 var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
165                 if ( data.describe ) { #>
166                         <# if ( 'image' === data.type ) { #>
167                                 <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
168                                         placeholder="<?php esc_attr_e('Caption this image&hellip;'); ?>" {{ maybeReadOnly }} />
169                         <# } else { #>
170                                 <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
171                                         <# if ( 'video' === data.type ) { #>
172                                                 placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
173                                         <# } else if ( 'audio' === data.type ) { #>
174                                                 placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
175                                         <# } else { #>
176                                                 placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
177                                         <# } #> {{ maybeReadOnly }} />
178                         <# } #>
179                 <# } #>
180         </script>
181
182         <script type="text/html" id="tmpl-attachment-details">
183                 <h3>
184                         <?php _e('Attachment Details'); ?>
185
186                         <span class="settings-save-status">
187                                 <span class="spinner"></span>
188                                 <span class="saved"><?php esc_html_e('Saved.'); ?></span>
189                         </span>
190                 </h3>
191                 <div class="attachment-info">
192                         <div class="thumbnail">
193                                 <# if ( data.uploading ) { #>
194                                         <div class="media-progress-bar"><div></div></div>
195                                 <# } else if ( 'image' === data.type ) { #>
196                                         <img src="{{ data.size.url }}" draggable="false" />
197                                 <# } else { #>
198                                         <img src="{{ data.icon }}" class="icon" draggable="false" />
199                                 <# } #>
200                         </div>
201                         <div class="details">
202                                 <div class="filename">{{ data.filename }}</div>
203                                 <div class="uploaded">{{ data.dateFormatted }}</div>
204
205                                 <# if ( 'image' === data.type && ! data.uploading ) { #>
206                                         <# if ( data.width && data.height ) { #>
207                                                 <div class="dimensions">{{ data.width }} &times; {{ data.height }}</div>
208                                         <# } #>
209
210                                         <# if ( data.can.save ) { #>
211                                                 <a class="edit-attachment" href="{{ data.editLink }}&amp;image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
212                                                 <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a>
213                                         <# } #>
214                                 <# } #>
215
216                                 <# if ( data.fileLength ) { #>
217                                         <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div>
218                                 <# } #>
219
220                                 <# if ( ! data.uploading && data.can.remove ) { #>
221                                         <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a>
222                                 <# } #>
223
224                                 <div class="compat-meta">
225                                         <# if ( data.compat && data.compat.meta ) { #>
226                                                 {{{ data.compat.meta }}}
227                                         <# } #>
228                                 </div>
229                         </div>
230                 </div>
231
232                 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
233                         <label class="setting" data-setting="title">
234                                 <span><?php _e('Title'); ?></span>
235                                 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
236                         </label>
237                         <label class="setting" data-setting="caption">
238                                 <span><?php _e('Caption'); ?></span>
239                                 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
240                         </label>
241                 <# if ( 'image' === data.type ) { #>
242                         <label class="setting" data-setting="alt">
243                                 <span><?php _e('Alt Text'); ?></span>
244                                 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
245                         </label>
246                 <# } #>
247                         <label class="setting" data-setting="description">
248                                 <span><?php _e('Description'); ?></span>
249                                 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea>
250                         </label>
251         </script>
252
253         <script type="text/html" id="tmpl-media-selection">
254                 <div class="selection-info">
255                         <span class="count"></span>
256                         <# if ( data.editable ) { #>
257                                 <a class="edit-selection" href="#"><?php _e('Edit'); ?></a>
258                         <# } #>
259                         <# if ( data.clearable ) { #>
260                                 <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
261                         <# } #>
262                 </div>
263                 <div class="selection-view"></div>
264         </script>
265
266         <script type="text/html" id="tmpl-attachment-display-settings">
267                 <h3><?php _e('Attachment Display Settings'); ?></h3>
268
269                 <# if ( 'image' === data.type ) { #>
270                         <label class="setting">
271                                 <span><?php _e('Alignment'); ?></span>
272                                 <select class="alignment"
273                                         data-setting="align"
274                                         <# if ( data.userSettings ) { #>
275                                                 data-user-setting="align"
276                                         <# } #>>
277
278                                         <option value="left">
279                                                 <?php esc_attr_e('Left'); ?>
280                                         </option>
281                                         <option value="center">
282                                                 <?php esc_attr_e('Center'); ?>
283                                         </option>
284                                         <option value="right">
285                                                 <?php esc_attr_e('Right'); ?>
286                                         </option>
287                                         <option value="none" selected>
288                                                 <?php esc_attr_e('None'); ?>
289                                         </option>
290                                 </select>
291                         </label>
292                 <# } #>
293
294                 <div class="setting">
295                         <label>
296                                 <# if ( data.model.canEmbed ) { #>
297                                         <span><?php _e('Embed or Link'); ?></span>
298                                 <# } else { #>
299                                         <span><?php _e('Link To'); ?></span>
300                                 <# } #>
301
302                                 <select class="link-to"
303                                         data-setting="link"
304                                         <# if ( data.userSettings && ! data.model.canEmbed ) { #>
305                                                 data-user-setting="urlbutton"
306                                         <# } #>>
307
308                                 <# if ( data.model.canEmbed ) { #>
309                                         <option value="embed" selected>
310                                                 <?php esc_attr_e('Embed Media Player'); ?>
311                                         </option>
312                                         <option value="file">
313                                 <# } else { #>
314                                         <option value="file" selected>
315                                 <# } #>
316                                         <# if ( data.model.canEmbed ) { #>
317                                                 <?php esc_attr_e('Link to Media File'); ?>
318                                         <# } else { #>
319                                                 <?php esc_attr_e('Media File'); ?>
320                                         <# } #>
321                                         </option>
322                                         <option value="post">
323                                         <# if ( data.model.canEmbed ) { #>
324                                                 <?php esc_attr_e('Link to Attachment Page'); ?>
325                                         <# } else { #>
326                                                 <?php esc_attr_e('Attachment Page'); ?>
327                                         <# } #>
328                                         </option>
329                                 <# if ( 'image' === data.type ) { #>
330                                         <option value="custom">
331                                                 <?php esc_attr_e('Custom URL'); ?>
332                                         </option>
333                                         <option value="none">
334                                                 <?php esc_attr_e('None'); ?>
335                                         </option>
336                                 <# } #>
337                                 </select>
338                         </label>
339                         <input type="text" class="link-to-custom" data-setting="linkUrl" />
340                 </div>
341
342                 <# if ( 'undefined' !== typeof data.sizes ) { #>
343                         <label class="setting">
344                                 <span><?php _e('Size'); ?></span>
345                                 <select class="size" name="size"
346                                         data-setting="size"
347                                         <# if ( data.userSettings ) { #>
348                                                 data-user-setting="imgsize"
349                                         <# } #>>
350                                         <?php
351                                         /** This filter is documented in wp-admin/includes/media.php */
352                                         $sizes = apply_filters( 'image_size_names_choose', array(
353                                                 'thumbnail' => __('Thumbnail'),
354                                                 'medium'    => __('Medium'),
355                                                 'large'     => __('Large'),
356                                                 'full'      => __('Full Size'),
357                                         ) );
358
359                                         foreach ( $sizes as $value => $name ) : ?>
360                                                 <#
361                                                 var size = data.sizes['<?php echo esc_js( $value ); ?>'];
362                                                 if ( size ) { #>
363                                                         <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>
364                                                                 <?php echo esc_html( $name ); ?> &ndash; {{ size.width }} &times; {{ size.height }}
365                                                         </option>
366                                                 <# } #>
367                                         <?php endforeach; ?>
368                                 </select>
369                         </label>
370                 <# } #>
371         </script>
372
373         <script type="text/html" id="tmpl-gallery-settings">
374                 <h3><?php _e('Gallery Settings'); ?></h3>
375
376                 <label class="setting">
377                         <span><?php _e('Link To'); ?></span>
378                         <select class="link-to"
379                                 data-setting="link"
380                                 <# if ( data.userSettings ) { #>
381                                         data-user-setting="urlbutton"
382                                 <# } #>>
383
384                                 <option value="post" selected>
385                                         <?php esc_attr_e('Attachment Page'); ?>
386                                 </option>
387                                 <option value="file">
388                                         <?php esc_attr_e('Media File'); ?>
389                                 </option>
390                                 <option value="none">
391                                         <?php esc_attr_e('None'); ?>
392                                 </option>
393                         </select>
394                 </label>
395
396                 <label class="setting">
397                         <span><?php _e('Columns'); ?></span>
398                         <select class="columns" name="columns"
399                                 data-setting="columns">
400                                 <?php for ( $i = 1; $i <= 9; $i++ ) : ?>
401                                         <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, 3 ); ?>>
402                                                 <?php echo esc_html( $i ); ?>
403                                         </option>
404                                 <?php endfor; ?>
405                         </select>
406                 </label>
407
408                 <label class="setting">
409                         <span><?php _e( 'Random Order' ); ?></span>
410                         <input type="checkbox" data-setting="_orderbyRandom" />
411                 </label>
412         </script>
413
414         <script type="text/html" id="tmpl-embed-link-settings">
415                 <label class="setting">
416                         <span><?php _e('Title'); ?></span>
417                         <input type="text" class="alignment" data-setting="title" />
418                 </label>
419         </script>
420
421         <script type="text/html" id="tmpl-embed-image-settings">
422                 <div class="thumbnail">
423                         <img src="{{ data.model.url }}" draggable="false" />
424                 </div>
425
426                 <?php
427                 /** This filter is documented in wp-admin/includes/media.php */
428                 if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
429                         <label class="setting caption">
430                                 <span><?php _e('Caption'); ?></span>
431                                 <textarea data-setting="caption" />
432                         </label>
433                 <?php endif; ?>
434
435                 <label class="setting alt-text">
436                         <span><?php _e('Alt Text'); ?></span>
437                         <input type="text" data-setting="alt" />
438                 </label>
439
440                 <div class="setting align">
441                         <span><?php _e('Align'); ?></span>
442                         <div class="button-group button-large" data-setting="align">
443                                 <button class="button" value="left">
444                                         <?php esc_attr_e('Left'); ?>
445                                 </button>
446                                 <button class="button" value="center">
447                                         <?php esc_attr_e('Center'); ?>
448                                 </button>
449                                 <button class="button" value="right">
450                                         <?php esc_attr_e('Right'); ?>
451                                 </button>
452                                 <button class="button active" value="none">
453                                         <?php esc_attr_e('None'); ?>
454                                 </button>
455                         </div>
456                 </div>
457
458                 <div class="setting link-to">
459                         <span><?php _e('Link To'); ?></span>
460                         <div class="button-group button-large" data-setting="link">
461                                 <button class="button" value="file">
462                                         <?php esc_attr_e('Image URL'); ?>
463                                 </button>
464                                 <button class="button" value="custom">
465                                         <?php esc_attr_e('Custom URL'); ?>
466                                 </button>
467                                 <button class="button active" value="none">
468                                         <?php esc_attr_e('None'); ?>
469                                 </button>
470                         </div>
471                         <input type="text" class="link-to-custom" data-setting="linkUrl" />
472                 </div>
473         </script>
474
475         <script type="text/html" id="tmpl-attachments-css">
476                 <style type="text/css" id="{{ data.id }}-css">
477                         #{{ data.id }} {
478                                 padding: 0 {{ data.gutter }}px;
479                         }
480
481                         #{{ data.id }} .attachment {
482                                 margin: {{ data.gutter }}px;
483                                 width: {{ data.edge }}px;
484                         }
485
486                         #{{ data.id }} .attachment-preview,
487                         #{{ data.id }} .attachment-preview .thumbnail {
488                                 width: {{ data.edge }}px;
489                                 height: {{ data.edge }}px;
490                         }
491
492                         #{{ data.id }} .portrait .thumbnail img {
493                                 max-width: {{ data.edge }}px;
494                                 height: auto;
495                         }
496
497                         #{{ data.id }} .landscape .thumbnail img {
498                                 width: auto;
499                                 max-height: {{ data.edge }}px;
500                         }
501                 </style>
502         </script>
503         <?php
504
505         /**
506          * Prints the media manager custom media templates.
507          *
508          * @since 3.5.0
509          */
510         do_action( 'print_media_templates' );
511 }