PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-includes/media-template.php

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