/** * Render the uploader shortcode and attach the uploader panel * * @param type $attr */ static function pre_render($attr) { $allow_upload = apply_filters('rtmedia_allow_uploader_view', true, 'uploader_shortcode'); if ($allow_upload) { global $post; global $rtmedia_query; if (!$rtmedia_query) { $rtmedia_query = new RTMediaQuery(); } if (!isset($attr['is_up_shortcode']) || $attr['is_up_shortcode'] !== false) { $rtmedia_query->is_upload_shortcode = true; // set is_upload_shortcode in rtmedia query as true } else { $rtmedia_query->is_upload_shortcode = false; // set is_upload_shortcode in rtmedia query as true } if (isset($attr['media_type'])) { global $rtmedia; $allowed_media_type = $rtmedia->allowed_types; if (isset($allowed_media_type[$attr['media_type']])) { wp_localize_script('rtmedia-backbone', "rtmedia_upload_type_filter", $allowed_media_type[$attr['media_type']]['extn']); } } if (isset($attr) && !empty($attr)) { if (!is_array($attr)) { $attr = array(); } if (!isset($attr["context_id"]) && isset($post->ID)) { $attr["context_id"] = $post->ID; } if (!isset($attr["context"]) && isset($post->post_type)) { $attr["context"] = $post->post_type; } } $attr = apply_filters('rtmedia_media_uploader_attributes', $attr); if (self::display_allowed() || isset($attr['allow_anonymous']) && $attr['allow_anonymous'] === true) { if (!_device_can_upload()) { echo '<p>' . __('The web browser on your device cannot be used to upload files.', 'rtmedia') . '</p>'; return; } ob_start(); self::$add_sc_script = true; RTMediaUploadTemplate::render($attr); self::$uploader_displayed = true; return ob_get_clean(); } } else { echo "<div class='rtmedia-upload-not-allowed'>" . apply_filters('rtmedia_upload_not_allowed_message', __('You are not allowed to upload/attach media.', 'rtmedia'), 'uploader_shortcode') . "</div>"; } }
/** * Get the BuddyPress Plupload settings. * * @since 2.3.0 * * @return array list of BuddyPress Plupload settings. */ function bp_attachments_get_plupload_default_settings() { $max_upload_size = wp_max_upload_size(); if (!$max_upload_size) { $max_upload_size = 0; } $defaults = array('runtimes' => 'html5,flash,silverlight,html4', 'file_data_name' => 'file', 'multipart_params' => array('action' => 'bp_upload_attachment', '_wpnonce' => wp_create_nonce('bp-uploader')), 'url' => admin_url('admin-ajax.php', 'relative'), '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' => true, 'urlstream_upload' => true); // WordPress is not allowing multi selection for iOs 7 device.. See #29602. if (wp_is_mobile() && strpos($_SERVER['HTTP_USER_AGENT'], 'OS 7_') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'like Mac OS X') !== false) { $defaults['multi_selection'] = false; } $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload()), 'limitExceeded' => is_multisite() && !is_upload_space_available()); /** * Filter the BuddyPress Plupload default settings. * * @since 2.3.0 * * @param array $params Default Plupload parameters array. */ return apply_filters('bp_attachments_get_plupload_default_settings', $settings); }
/** * Prints the templates used in the media manager. * * @since 3.5.0 */ function wp_print_media_templates() { global $is_IE; $class = 'media-modal wp-core-ui'; if ($is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false) { $class .= ' ie7'; } ?> <script type="text/html" id="tmpl-media-frame"> <div class="media-frame-menu"></div> <div class="media-frame-title"></div> <div class="media-frame-router"></div> <div class="media-frame-content"></div> <div class="media-frame-toolbar"></div> <div class="media-frame-uploader"></div> </script> <script type="text/html" id="tmpl-media-modal"> <div class="<?php echo $class; ?> "> <a class="media-modal-close" href="#" title="<?php esc_attr_e('Close'); ?> "><span class="media-modal-icon"></span></a> <div class="media-modal-content"></div> </div> <div class="media-modal-backdrop"></div> </script> <script type="text/html" id="tmpl-uploader-window"> <div class="uploader-window-content"> <h3><?php _e('Drop files to upload'); ?> </h3> </div> </script> <script type="text/html" id="tmpl-uploader-inline"> <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> <div class="uploader-inline-content {{ messageClass }}"> <# if ( data.message ) { #> <h3 class="upload-message">{{ data.message }}</h3> <# } #> <?php if (!_device_can_upload()) { ?> <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> <?php } elseif (is_multisite() && !is_upload_space_available()) { ?> <h3 class="upload-instructions"><?php _e('Upload Limit Exceeded'); ?> </h3> <?php do_action('upload_ui_over_quota'); ?> <?php } else { ?> <div class="upload-ui"> <h3 class="upload-instructions drop-instructions"><?php _e('Drop files anywhere to upload'); ?> </h3> <a href="#" class="browser button button-hero"><?php _e('Select Files'); ?> </a> </div> <div class="upload-inline-status"></div> <div class="post-upload-ui"> <?php do_action('pre-upload-ui'); do_action('pre-plupload-upload-ui'); if (10 === remove_action('post-plupload-upload-ui', 'media_upload_flash_bypass')) { do_action('post-plupload-upload-ui'); add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); } else { do_action('post-plupload-upload-ui'); } $upload_size_unit = $max_upload_size = wp_max_upload_size(); $byte_sizes = array('KB', 'MB', 'GB'); for ($u = -1; $upload_size_unit > 1024 && $u < count($byte_sizes) - 1; $u++) { $upload_size_unit /= 1024; } if ($u < 0) { $upload_size_unit = 0; $u = 0; } else { $upload_size_unit = (int) $upload_size_unit; } ?> <p class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($upload_size_unit), esc_html($byte_sizes[$u])); ?> </p> <?php if (($GLOBALS['is_IE'] || $GLOBALS['is_opera']) && $max_upload_size > 100 * 1024 * 1024) { $browser_uploader = admin_url('media-new.php?browser-uploader&post_id=') . '{{ data.postId }}'; ?> <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.'), $browser_uploader, '_blank'); ?> </p> <?php } ?> <?php do_action('post-upload-ui'); ?> </div> <?php } ?> </div> </script> <script type="text/html" id="tmpl-uploader-status"> <h3><?php _e('Uploading'); ?> </h3> <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?> </a> <div class="media-progress-bar"><div></div></div> <div class="upload-details"> <span class="upload-count"> <span class="upload-index"></span> / <span class="upload-total"></span> </span> <span class="upload-detail-separator">–</span> <span class="upload-filename"></span> </div> <div class="upload-errors"></div> </script> <script type="text/html" id="tmpl-uploader-status-error"> <span class="upload-error-label"><?php _e('Error'); ?> </span> <span class="upload-error-filename">{{{ data.filename }}}</span> <span class="upload-error-message">{{ data.message }}</span> </script> <script type="text/html" id="tmpl-attachment"> <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type ) { #> <div class="thumbnail"> <div class="centered"> <img src="{{ data.size.url }}" draggable="false" /> </div> </div> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <div class="filename"> <div>{{ data.filename }}</div> </div> <# } #> <# if ( data.buttons.close ) { #> <a class="close media-modal-icon" href="#" title="<?php _e('Remove'); ?> "></a> <# } #> <# if ( data.buttons.check ) { #> <a class="check" href="#" title="<?php _e('Deselect'); ?> "><div class="media-modal-icon"></div></a> <# } #> </div> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; if ( data.describe ) { #> <# if ( 'image' === data.type ) { #> <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption" placeholder="<?php esc_attr_e('Caption this image…'); ?> " {{ maybeReadOnly }} /> <# } else { #> <input type="text" value="{{ data.title }}" class="describe" data-setting="title" <# if ( 'video' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this video…'); ?> " <# } else if ( 'audio' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this audio file…'); ?> " <# } else { #> placeholder="<?php esc_attr_e('Describe this media file…'); ?> " <# } #> {{ maybeReadOnly }} /> <# } #> <# } #> </script> <script type="text/html" id="tmpl-attachment-details"> <h3> <?php _e('Attachment Details'); ?> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?> </span> </span> </h3> <div class="attachment-info"> <div class="thumbnail"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type ) { #> <img src="{{ data.size.url }}" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="details"> <div class="filename">{{ data.filename }}</div> <div class="uploaded">{{ data.dateFormatted }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions">{{ data.width }} × {{ data.height }}</div> <# } #> <# if ( data.can.save ) { #> <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e('Edit Image'); ?> </a> <a class="refresh-attachment" href="#"><?php _e('Refresh'); ?> </a> <# } #> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> <a class="delete-attachment" href="#"><?php _e('Delete Permanently'); ?> </a> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> </div> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <label class="setting" data-setting="title"> <span><?php _e('Title'); ?> </span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <label class="setting" data-setting="caption"> <span><?php _e('Caption'); ?> </span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span><?php _e('Alt Text'); ?> </span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span><?php _e('Description'); ?> </span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> </script> <script type="text/html" id="tmpl-media-selection"> <div class="selection-info"> <span class="count"></span> <# if ( data.editable ) { #> <a class="edit-selection" href="#"><?php _e('Edit'); ?> </a> <# } #> <# if ( data.clearable ) { #> <a class="clear-selection" href="#"><?php _e('Clear'); ?> </a> <# } #> </div> <div class="selection-view"></div> </script> <script type="text/html" id="tmpl-attachment-display-settings"> <h3><?php _e('Attachment Display Settings'); ?> </h3> <# if ( 'image' === data.type ) { #> <label class="setting"> <span><?php _e('Alignment'); ?> </span> <select class="alignment" data-setting="align" <# if ( data.userSettings ) { #> data-user-setting="align" <# } #>> <option value="left"> <?php esc_attr_e('Left'); ?> </option> <option value="center"> <?php esc_attr_e('Center'); ?> </option> <option value="right"> <?php esc_attr_e('Right'); ?> </option> <option value="none" selected> <?php esc_attr_e('None'); ?> </option> </select> </label> <# } #> <div class="setting"> <label> <span><?php _e('Link To'); ?> </span> <select class="link-to" data-setting="link" <# if ( data.userSettings ) { #> data-user-setting="urlbutton" <# } #>> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="file" selected> <?php esc_attr_e('Media File'); ?> </option> <option value="post"> <?php esc_attr_e('Attachment Page'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> </label> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <# if ( 'undefined' !== typeof data.sizes ) { #> <label class="setting"> <span><?php _e('Size'); ?> </span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php $sizes = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'))); foreach ($sizes as $value => $name) { ?> <# var size = data.sizes['<?php echo esc_js($value); ?> ']; if ( size ) { #> <option value="<?php echo esc_attr($value); ?> " <?php selected($value, 'full'); ?> > <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php } ?> </select> </label> <# } #> </script> <script type="text/html" id="tmpl-gallery-settings"> <h3><?php _e('Gallery Settings'); ?> </h3> <label class="setting"> <span><?php _e('Link To'); ?> </span> <select class="link-to" data-setting="link" <# if ( data.userSettings ) { #> data-user-setting="urlbutton" <# } #>> <option value="post" selected> <?php esc_attr_e('Attachment Page'); ?> </option> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> </select> </label> <label class="setting"> <span><?php _e('Columns'); ?> </span> <select class="columns" name="columns" data-setting="columns"> <?php for ($i = 1; $i <= 9; $i++) { ?> <option value="<?php echo esc_attr($i); ?> " <?php selected($i, 3); ?> > <?php echo esc_html($i); ?> </option> <?php } ?> </select> </label> <label class="setting"> <span><?php _e('Random Order'); ?> </span> <input type="checkbox" data-setting="_orderbyRandom" /> </label> </script> <script type="text/html" id="tmpl-embed-link-settings"> <label class="setting"> <span><?php _e('Title'); ?> </span> <input type="text" class="alignment" data-setting="title" /> </label> </script> <script type="text/html" id="tmpl-embed-image-settings"> <div class="thumbnail"> <img src="{{ data.model.url }}" draggable="false" /> </div> <?php if (!apply_filters('disable_captions', '')) { ?> <label class="setting caption"> <span><?php _e('Caption'); ?> </span> <textarea data-setting="caption" /> </label> <?php } ?> <label class="setting alt-text"> <span><?php _e('Alt Text'); ?> </span> <input type="text" data-setting="alt" /> </label> <div class="setting align"> <span><?php _e('Align'); ?> </span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <div class="setting link-to"> <span><?php _e('Link To'); ?> </span> <div class="button-group button-large" data-setting="link"> <button class="button" value="file"> <?php esc_attr_e('Image URL'); ?> </button> <button class="button" value="custom"> <?php esc_attr_e('Custom URL'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> </script> <script type="text/html" id="tmpl-attachments-css"> <style type="text/css" id="{{ data.id }}-css"> #{{ data.id }} { padding: 0 {{ data.gutter }}px; } #{{ data.id }} .attachment { margin: {{ data.gutter }}px; width: {{ data.edge }}px; } #{{ data.id }} .attachment-preview, #{{ data.id }} .attachment-preview .thumbnail { width: {{ data.edge }}px; height: {{ data.edge }}px; } #{{ data.id }} .portrait .thumbnail img { max-width: {{ data.edge }}px; height: auto; } #{{ data.id }} .landscape .thumbnail img { width: auto; max-height: {{ data.edge }}px; } </style> </script> <?php do_action('print_media_templates'); }
/** * @since 3.4.0 */ public function tab_upload_new() { if (!_device_can_upload()) { echo '<p>' . sprintf(__('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://apps.wordpress.org/') . '</p>'; } else { ?> <div class="upload-dropzone"> <?php _e('Drop a file here or <a href="#" class="upload">select a file</a>.'); ?> </div> <div class="upload-fallback"> <span class="button-secondary"><?php _e('Select File'); ?> </span> </div> <?php } }
/** * Flag if the device can upload images. * * @since 1.0.0 * * @return bool True if it can, false otherwise. */ public function device_can_upload() { // Why is this method internal? It is quite useful. return _device_can_upload(); }
/** * Sets up some default Plupload settings so we can upload meda theme-side * * @global type $wp_scripts */ private static function add_default_plupload_settings() { global $wp_scripts; $defaults = array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => self::max_upload_size() . 'b', 'url' => admin_url('admin-ajax.php', 'relative'), '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', 'liveblog'), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array('action' => 'upload-attachment', '_wpnonce' => wp_create_nonce('media-form'))); $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload())); $script = 'var _wpPluploadSettings = ' . json_encode($settings) . ';'; $data = $wp_scripts->get_data('wp-plupload', 'data'); if (!empty($data)) { $script = "{$data}\n{$script}"; } $wp_scripts->add_data('wp-plupload', 'data', $script); }
/** * Prints the templates used in the media manager. * * @since 3.5.0 * * @global bool $is_IE */ function wp_print_media_templates() { global $is_IE; $class = 'media-modal wp-core-ui'; if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) $class .= ' ie7'; ?> <!--[if lte IE 8]> <style> .attachment:focus { outline: #1e8cbe solid; } .selected.attachment { outline: #1e8cbe solid; } </style> <![endif]--> <script type="text/html" id="tmpl-media-frame"> <div class="media-frame-menu"></div> <div class="media-frame-title"></div> <div class="media-frame-router"></div> <div class="media-frame-content"></div> <div class="media-frame-toolbar"></div> <div class="media-frame-uploader"></div> </script> <script type="text/html" id="tmpl-media-modal"> <div class="<?php echo $class; ?>"> <a class="media-modal-close" href="#"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></a> <div class="media-modal-content"></div> </div> <div class="media-modal-backdrop"></div> </script> <script type="text/html" id="tmpl-uploader-window"> <div class="uploader-window-content"> <h3><?php _e( 'Drop files to upload' ); ?></h3> </div> </script> <script type="text/html" id="tmpl-uploader-editor"> <div class="uploader-editor-content"> <div class="uploader-editor-title"><?php _e( 'Drop files to upload' ); ?></div> </div> </script> <script type="text/html" id="tmpl-uploader-inline"> <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> <# if ( data.canClose ) { #> <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button> <# } #> <div class="uploader-inline-content {{ messageClass }}"> <# if ( data.message ) { #> <h3 class="upload-message">{{ data.message }}</h3> <# } #> <?php if ( ! _device_can_upload() ) : ?> <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.'), 'https://apps.wordpress.org/' ); ?></h3> <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?> <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3> <?php /** This action is documented in wp-admin/includes/media.php */ do_action( 'upload_ui_over_quota' ); ?> <?php else : ?> <div class="upload-ui"> <h3 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3> <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> <button type="button" class="browser button button-hero"><?php _e( 'Select Files' ); ?></button> </div> <div class="upload-inline-status"></div> <div class="post-upload-ui"> <?php /** This action is documented in wp-admin/includes/media.php */ do_action( 'pre-upload-ui' ); /** This action is documented in wp-admin/includes/media.php */ do_action( 'pre-plupload-upload-ui' ); if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) { /** This action is documented in wp-admin/includes/media.php */ do_action( 'post-plupload-upload-ui' ); add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); } else { /** This action is documented in wp-admin/includes/media.php */ do_action( 'post-plupload-upload-ui' ); } $max_upload_size = wp_max_upload_size(); if ( ! $max_upload_size ) { $max_upload_size = 0; } ?> <p class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></p> <# if ( data.suggestedWidth && data.suggestedHeight ) { #> <p class="suggested-dimensions"> <?php _e( 'Suggested image dimensions:' ); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}} </p> <# } #> <?php /** This action is documented in wp-admin/includes/media.php */ do_action( 'post-upload-ui' ); ?> </div> <?php endif; ?> </div> </script> <script type="text/html" id="tmpl-media-library-view-switcher"> <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list"> <span class="screen-reader-text"><?php _e( 'List View' ); ?></span> </a> <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current"> <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span> </a> </script> <script type="text/html" id="tmpl-uploader-status"> <h3><?php _e( 'Uploading' ); ?></h3> <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?></a> <div class="media-progress-bar"><div></div></div> <div class="upload-details"> <span class="upload-count"> <span class="upload-index"></span> / <span class="upload-total"></span> </span> <span class="upload-detail-separator">–</span> <span class="upload-filename"></span> </div> <div class="upload-errors"></div> </script> <script type="text/html" id="tmpl-uploader-status-error"> <span class="upload-error-filename">{{{ data.filename }}}</span> <span class="upload-error-message">{{ data.message }}</span> </script> <script type="text/html" id="tmpl-edit-attachment-frame"> <div class="edit-media-header"> <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button> <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button> </div> <div class="media-frame-title"></div> <div class="media-frame-content"></div> </script> <script type="text/html" id="tmpl-attachment-details-two-column"> <div class="attachment-media-view {{ data.orientation }}"> <div class="thumbnail thumbnail-{{ data.type }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type && data.sizes && data.sizes.large ) { #> <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" /> <# } else if ( 'image' === data.type && data.sizes && data.sizes.full ) { #> <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" /> <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #> <img class="details-image" src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> <# if ( 'audio' === data.type ) { #> <div class="wp-media-wrapper"> <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none"> <source type="{{ data.mime }}" src="{{ data.url }}"/> </audio> </div> <# } else if ( 'video' === data.type ) { var w_rule = h_rule = ''; if ( data.width ) { w_rule = 'width: ' + data.width + 'px;'; } else if ( wp.media.view.settings.contentWidth ) { w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;'; } if ( data.height ) { h_rule = 'height: ' + data.height + 'px;'; } #> <div style="{{ w_rule }}{{ h_rule }}" class="wp-media-wrapper wp-video"> <video controls="controls" class="wp-video-shortcode" preload="metadata" <# if ( data.width ) { #>width="{{ data.width }}"<# } #> <# if ( data.height ) { #>height="{{ data.height }}"<# } #> <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>> <source type="{{ data.mime }}" src="{{ data.url }}"/> </video> </div> <# } #> <div class="attachment-actions"> <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #> <button type="button" class="button edit-attachment"><?php _e( 'Edit Image' ); ?></button> <# } #> </div> </div> </div> <div class="attachment-info"> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?></span> </span> <div class="details"> <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div> <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div> <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div> <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} × {{ data.height }}</div> <# } #> <# } #> <# if ( data.fileLength ) { #> <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div> <# } #> <# if ( 'audio' === data.type && data.meta.bitrate ) { #> <div class="bitrate"> <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s <# if ( data.meta.bitrate_mode ) { #> {{ ' ' + data.meta.bitrate_mode.toUpperCase() }} <# } #> </div> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> <div class="settings"> <label class="setting" data-setting="url"> <span class="name"><?php _e('URL'); ?></span> <input type="text" value="{{ data.url }}" readonly /> </label> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> <label class="setting" data-setting="title"> <span class="name"><?php _e('Title'); ?></span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <?php endif; ?> <# if ( 'audio' === data.type ) { #> <?php foreach ( array( 'artist' => __( 'Artist' ), 'album' => __( 'Album' ), ) as $key => $label ) : ?> <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>"> <span class="name"><?php echo $label ?></span> <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" /> </label> <?php endforeach; ?> <# } #> <label class="setting" data-setting="caption"> <span class="name"><?php _e( 'Caption' ); ?></span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span class="name"><?php _e( 'Alt Text' ); ?></span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span class="name"><?php _e('Description'); ?></span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> <label class="setting"> <span class="name"><?php _e( 'Uploaded By' ); ?></span> <span class="value">{{ data.authorName }}</span> </label> <# if ( data.uploadedToTitle ) { #> <label class="setting"> <span class="name"><?php _e( 'Uploaded To' ); ?></span> <# if ( data.uploadedToLink ) { #> <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span> <# } else { #> <span class="value">{{ data.uploadedToTitle }}</span> <# } #> </label> <# } #> <div class="attachment-compat"></div> </div> <div class="actions"> <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a> <# if ( data.can.save ) { #> | <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> | <?php if ( MEDIA_TRASH ): ?> <# if ( 'trash' === data.status ) { #> <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a> <# } else { #> <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a> <# } #> <?php else: ?> <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a> <?php endif; ?> <# } #> </div> </div> </script> <script type="text/html" id="tmpl-attachment"> <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> <div class="thumbnail"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div> <# } else if ( 'image' === data.type && data.sizes ) { #> <div class="centered"> <img src="{{ data.size.url }}" draggable="false" alt="" /> </div> <# } else { #> <div class="centered"> <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #> <img src="{{ data.image.src }}" class="thumbnail" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="filename"> <div>{{ data.filename }}</div> </div> <# } #> </div> <# if ( data.buttons.close ) { #> <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a> <# } #> </div> <# if ( data.buttons.check ) { #> <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a> <# } #> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; if ( data.describe ) { if ( 'image' === data.type ) { #> <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption" placeholder="<?php esc_attr_e('Caption this image…'); ?>" {{ maybeReadOnly }} /> <# } else { #> <input type="text" value="{{ data.title }}" class="describe" data-setting="title" <# if ( 'video' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this video…'); ?>" <# } else if ( 'audio' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this audio file…'); ?>" <# } else { #> placeholder="<?php esc_attr_e('Describe this media file…'); ?>" <# } #> {{ maybeReadOnly }} /> <# } } #> </script> <script type="text/html" id="tmpl-attachment-details"> <h3> <?php _e('Attachment Details'); ?> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?></span> </span> </h3> <div class="attachment-info"> <div class="thumbnail thumbnail-{{ data.type }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type && data.sizes ) { #> <img src="{{ data.size.url }}" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="details"> <div class="filename">{{ data.filename }}</div> <div class="uploaded">{{ data.dateFormatted }}</div> <div class="file-size">{{ data.filesizeHumanReadable }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions">{{ data.width }} × {{ data.height }}</div> <# } #> <# if ( data.can.save && data.sizes ) { #> <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a> <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a> <# } #> <# } #> <# if ( data.fileLength ) { #> <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> <?php if ( MEDIA_TRASH ): ?> <# if ( 'trash' === data.status ) { #> <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a> <# } else { #> <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a> <# } #> <?php else: ?> <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a> <?php endif; ?> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> </div> <label class="setting" data-setting="url"> <span class="name"><?php _e('URL'); ?></span> <input type="text" value="{{ data.url }}" readonly /> </label> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> <label class="setting" data-setting="title"> <span class="name"><?php _e('Title'); ?></span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <?php endif; ?> <# if ( 'audio' === data.type ) { #> <?php foreach ( array( 'artist' => __( 'Artist' ), 'album' => __( 'Album' ), ) as $key => $label ) : ?> <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>"> <span class="name"><?php echo $label ?></span> <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" /> </label> <?php endforeach; ?> <# } #> <label class="setting" data-setting="caption"> <span class="name"><?php _e('Caption'); ?></span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span class="name"><?php _e('Alt Text'); ?></span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span class="name"><?php _e('Description'); ?></span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> </script> <script type="text/html" id="tmpl-media-selection"> <div class="selection-info"> <span class="count"></span> <# if ( data.editable ) { #> <a class="edit-selection" href="#"><?php _e( 'Edit Selection' ); ?></a> <# } #> <# if ( data.clearable ) { #> <a class="clear-selection" href="#"><?php _e('Clear'); ?></a> <# } #> </div> <div class="selection-view"></div> </script> <script type="text/html" id="tmpl-attachment-display-settings"> <h3><?php _e('Attachment Display Settings'); ?></h3> <# if ( 'image' === data.type ) { #> <label class="setting"> <span><?php _e('Alignment'); ?></span> <select class="alignment" data-setting="align" <# if ( data.userSettings ) { #> data-user-setting="align" <# } #>> <option value="left"> <?php esc_attr_e('Left'); ?> </option> <option value="center"> <?php esc_attr_e('Center'); ?> </option> <option value="right"> <?php esc_attr_e('Right'); ?> </option> <option value="none" selected> <?php esc_attr_e('None'); ?> </option> </select> </label> <# } #> <div class="setting"> <label> <# if ( data.model.canEmbed ) { #> <span><?php _e('Embed or Link'); ?></span> <# } else { #> <span><?php _e('Link To'); ?></span> <# } #> <select class="link-to" data-setting="link" <# if ( data.userSettings && ! data.model.canEmbed ) { #> data-user-setting="urlbutton" <# } #>> <# if ( data.model.canEmbed ) { #> <option value="embed" selected> <?php esc_attr_e('Embed Media Player'); ?> </option> <option value="file"> <# } else { #> <option value="file" selected> <# } #> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Media File'); ?> <# } else { #> <?php esc_attr_e('Media File'); ?> <# } #> </option> <option value="post"> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Attachment Page'); ?> <# } else { #> <?php esc_attr_e('Attachment Page'); ?> <# } #> </option> <# if ( 'image' === data.type ) { #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> <# } #> </select> </label> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <# if ( 'undefined' !== typeof data.sizes ) { #> <label class="setting"> <span><?php _e('Size'); ?></span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'), ) ); foreach ( $sizes as $value => $name ) : ?> <# var size = data.sizes['<?php echo esc_js( $value ); ?>']; if ( size ) { #> <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>> <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php endforeach; ?> </select> </label> <# } #> </script> <script type="text/html" id="tmpl-gallery-settings"> <h3><?php _e('Gallery Settings'); ?></h3> <label class="setting"> <span><?php _e('Link To'); ?></span> <select class="link-to" data-setting="link" <# if ( data.userSettings ) { #> data-user-setting="urlbutton" <# } #>> <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_attr_e('Attachment Page'); ?> </option> <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_attr_e('Media File'); ?> </option> <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_attr_e('None'); ?> </option> </select> </label> <label class="setting"> <span><?php _e('Columns'); ?></span> <select class="columns" name="columns" data-setting="columns"> <?php for ( $i = 1; $i <= 9; $i++ ) : ?> <option value="<?php echo esc_attr( $i ); ?>" <# if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# } #>> <?php echo esc_html( $i ); ?> </option> <?php endfor; ?> </select> </label> <label class="setting"> <span><?php _e( 'Random Order' ); ?></span> <input type="checkbox" data-setting="_orderbyRandom" /> </label> <label class="setting size"> <span><?php _e( 'Size' ); ?></span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #> > <?php // This filter is documented in wp-admin/includes/media.php $size_names = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __( 'Thumbnail' ), 'medium' => __( 'Medium' ), 'large' => __( 'Large' ), 'full' => __( 'Full Size' ), ) ); foreach ( $size_names as $size => $label ) : ?> <option value="<?php echo esc_attr( $size ); ?>"> <?php echo esc_html( $label ); ?> </option> <?php endforeach; ?> </select> </label> </script> <script type="text/html" id="tmpl-playlist-settings"> <h3><?php _e( 'Playlist Settings' ); ?></h3> <# var emptyModel = _.isEmpty( data.model ), isVideo = 'video' === data.controller.get('library').props.get('type'); #> <label class="setting"> <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <# if ( isVideo ) { #> <span><?php _e( 'Show Video List' ); ?></span> <# } else { #> <span><?php _e( 'Show Tracklist' ); ?></span> <# } #> </label> <# if ( ! isVideo ) { #> <label class="setting"> <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span> </label> <# } #> <label class="setting"> <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e( 'Show Images' ); ?></span> </label> </script> <script type="text/html" id="tmpl-embed-link-settings"> <label class="setting link-text"> <span><?php _e( 'Link Text' ); ?></span> <input type="text" class="alignment" data-setting="linkText" /> </label> <div class="embed-container" style="display: none;"> <div class="embed-preview"></div> </div> </script> <script type="text/html" id="tmpl-embed-image-settings"> <div class="thumbnail"> <img src="{{ data.model.url }}" draggable="false" /> </div> <?php /** This filter is documented in wp-admin/includes/media.php */ if ( ! apply_filters( 'disable_captions', '' ) ) : ?> <label class="setting caption"> <span><?php _e('Caption'); ?></span> <textarea data-setting="caption" /> </label> <?php endif; ?> <label class="setting alt-text"> <span><?php _e('Alt Text'); ?></span> <input type="text" data-setting="alt" /> </label> <div class="setting align"> <span><?php _e('Align'); ?></span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <div class="setting link-to"> <span><?php _e('Link To'); ?></span> <div class="button-group button-large" data-setting="link"> <button class="button" value="file"> <?php esc_attr_e('Image URL'); ?> </button> <button class="button" value="custom"> <?php esc_attr_e('Custom URL'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> </script> <script type="text/html" id="tmpl-image-details"> <div class="media-embed"> <div class="embed-media-settings"> <div class="column-image"> <div class="image"> <img src="{{ data.model.url }}" draggable="false" /> <# if ( data.attachment && window.imageEdit ) { #> <div class="actions"> <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" /> <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" /> </div> <# } #> </div> </div> <div class="column-settings"> <?php /** This filter is documented in wp-admin/includes/media.php */ if ( ! apply_filters( 'disable_captions', '' ) ) : ?> <label class="setting caption"> <span><?php _e('Caption'); ?></span> <textarea data-setting="caption">{{ data.model.caption }}</textarea> </label> <?php endif; ?> <label class="setting alt-text"> <span><?php _e('Alternative Text'); ?></span> <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> </label> <h3><?php _e( 'Display Settings' ); ?></h3> <div class="setting align"> <span><?php _e('Align'); ?></span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <# if ( data.attachment ) { #> <# if ( 'undefined' !== typeof data.attachment.sizes ) { #> <label class="setting size"> <span><?php _e('Size'); ?></span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'), ) ); foreach ( $sizes as $value => $name ) : ?> <# var size = data.sizes['<?php echo esc_js( $value ); ?>']; if ( size ) { #> <option value="<?php echo esc_attr( $value ); ?>"> <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php endforeach; ?> <option value="<?php echo esc_attr( 'custom' ); ?>"> <?php _e( 'Custom Size' ); ?> </option> </select> </label> <# } #> <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> <label><span><?php _e( 'Width' ); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> </div> <# } #> <div class="setting link-to"> <span><?php _e('Link To'); ?></span> <select data-setting="link"> <# if ( data.attachment ) { #> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> <option value="post"> <?php esc_attr_e('Attachment Page'); ?> </option> <# } else { #> <option value="file"> <?php esc_attr_e('Image URL'); ?> </option> <# } #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <div class="advanced-section"> <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3> <div class="advanced-settings hidden"> <div class="advanced-image"> <label class="setting title-text"> <span><?php _e('Image Title Attribute'); ?></span> <input type="text" data-setting="title" value="{{ data.model.title }}" /> </label> <label class="setting extra-classes"> <span><?php _e('Image CSS Class'); ?></span> <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" /> </label> </div> <div class="advanced-link"> <div class="setting link-target"> <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e( 'Open link in a new window/tab' ); ?></label> </div> <label class="setting link-rel"> <span><?php _e('Link Rel'); ?></span> <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" /> </label> <label class="setting link-class-name"> <span><?php _e('Link CSS Class'); ?></span> <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" /> </label> </div> </div> </div> </div> </div> </div> </script> <script type="text/html" id="tmpl-image-editor"> <div id="media-head-{{ data.id }}"></div> <div id="image-editor-{{ data.id }}"></div> </script> <script type="text/html" id="tmpl-audio-details"> <# var ext, html5types = { mp3: wp.media.view.settings.embedMimes.mp3, ogg: wp.media.view.settings.embedMimes.ogg }; #> <?php $audio_types = wp_get_audio_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-audio-settings"> <?php wp_underscore_audio_template() ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php foreach ( $audio_types as $type ): ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) { delete html5types.<?php echo $type ?>; } #> <label class="setting"> <span><?php echo strtoupper( $type ) ?></span> <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php endforeach ?> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <div class="setting preload"> <span><?php _e( 'Preload' ); ?></span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button> <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button> <button class="button active" value="none"><?php _e( 'None' ); ?></button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e( 'Autoplay' ); ?></span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e( 'Loop' ); ?></span> </label> </div> </div> </script> <script type="text/html" id="tmpl-video-details"> <# var ext, html5types = { mp4: wp.media.view.settings.embedMimes.mp4, ogv: wp.media.view.settings.embedMimes.ogv, webm: wp.media.view.settings.embedMimes.webm }; #> <?php $video_types = wp_get_video_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-video-settings"> <div class="wp-video-holder"> <# var w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, h = ! data.model.height ? 360 : data.model.height; if ( data.model.width && w !== data.model.width ) { h = Math.ceil( ( h * w ) / data.model.width ); } #> <?php wp_underscore_video_template() ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php foreach ( $video_types as $type ): ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) { delete html5types.<?php echo $type ?>; } #> <label class="setting"> <span><?php echo strtoupper( $type ) ?></span> <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php endforeach ?> </div> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <# if ( ! _.isEmpty( data.model.poster ) ) { #> <label class="setting"> <span><?php _e( 'Poster Image' ); ?></span> <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <div class="setting preload"> <span><?php _e( 'Preload' ); ?></span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button> <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button> <button class="button active" value="none"><?php _e( 'None' ); ?></button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e( 'Autoplay' ); ?></span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e( 'Loop' ); ?></span> </label> <label class="setting" data-setting="content"> <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span> <# var content = ''; if ( ! _.isEmpty( data.model.content ) ) { var tracks = jQuery( data.model.content ).filter( 'track' ); _.each( tracks.toArray(), function (track) { content += track.outerHTML; #> <p> <input class="content-track" type="text" value="{{ track.outerHTML }}" /> <a class="remove-setting remove-track"><?php _e( 'Remove' ); ?></a> </p> <# } ); #> <# } else { #> <em><?php _e( 'There are no associated subtitles.' ); ?></em> <# } #> <textarea class="hidden content-setting">{{ content }}</textarea> </label> </div> </div> </script> <script type="text/html" id="tmpl-editor-gallery"> <# if ( data.attachments.length ) { #> <div class="gallery gallery-columns-{{ data.columns }}"> <# _.each( data.attachments, function( attachment, index ) { #> <dl class="gallery-item"> <dt class="gallery-icon"> <# if ( attachment.thumbnail ) { #> <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" /> <# } else { #> <img src="{{ attachment.url }}" /> <# } #> </dt> <# if ( attachment.caption ) { #> <dd class="wp-caption-text gallery-caption"> {{ attachment.caption }} </dd> <# } #> </dl> <# if ( index % data.columns === data.columns - 1 ) { #> <br style="clear: both;"> <# } #> <# } ); #> </div> <# } else { #> <div class="wpview-error"> <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p> </div> <# } #> </script> <script type="text/html" id="tmpl-crop-content"> <img class="crop-image" src="{{ data.url }}"> <div class="upload-errors"></div> </script> <?php /** * Fires when the custom Backbone media templates are printed. * * @since 3.5.0 */ do_action( 'print_media_templates' ); }
/** * Prints default plupload arguments. * * @since 3.4.0 */ function wp_plupload_default_settings() { $wp_scripts = wp_scripts(); $data = $wp_scripts->get_data('wp-plupload', 'data'); if ($data && false !== strpos($data, '_wpPluploadSettings')) { return; } $max_upload_size = wp_max_upload_size(); $defaults = array('runtimes' => 'html5,flash,silverlight,html4', 'file_data_name' => 'async-upload', 'url' => admin_url('async-upload.php', 'relative'), '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')); // 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) { $defaults['multi_selection'] = false; } /** * Filter the Plupload default settings. * * @since 3.4.0 * * @param array $defaults Default Plupload settings array. */ $defaults = apply_filters('plupload_default_settings', $defaults); $params = array('action' => 'upload-attachment'); /** * Filter the Plupload default parameters. * * @since 3.4.0 * * @param array $params Default Plupload parameters array. */ $params = apply_filters('plupload_default_params', $params); $params['_wpnonce'] = wp_create_nonce('media-form'); $defaults['multipart_params'] = $params; $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload()), 'limitExceeded' => is_multisite() && !is_upload_space_available()); $script = 'var _wpPluploadSettings = ' . wp_json_encode($settings) . ';'; if ($data) { $script = "{$data}\n{$script}"; } $wp_scripts->add_data('wp-plupload', 'data', $script); }
public function media_upload_form($errors = null) { global $type, $tab, $pagenow, $is_IE, $is_opera; if (function_exists('_device_can_upload') && !_device_can_upload()) { echo '<p>' . __('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.') . '</p>'; return; } $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; } ?> <div id="media-upload-notice"><?php if (isset($errors['upload_notice'])) { echo $errors['upload_notice']; } ?> </div> <div id="media-upload-error"><?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { echo $errors['upload_error']->get_error_message(); } ?> </div> <?php if (is_multisite() && !is_upload_space_available()) { return; } $post_params = array("action" => "mymail_import_subscribers_upload_handler", "_wpnonce" => wp_create_nonce('mymail_nonce')); $upload_action_url = admin_url('admin-ajax.php'); $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' => __('Comma-separated values (CSV)', 'mymail'), 'extensions' => 'csv')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => $post_params, 'multi_selection' => false); ?> <script type="text/javascript"> var wpUploaderInit = <?php echo json_encode($plupload_init); ?> ; </script> <div id="plupload-upload-ui" class="hide-if-no-js"> <div id="drag-drop-area"> <div class="drag-drop-inside"> <p class="drag-drop-info"><?php _e('Drop your list here', 'mymail'); ?> </p> <p><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?> </p> <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select File', 'mymail'); ?> " class="button" /></p> </div> </div> </div> <div id="html-upload-ui" class="hide-if-js"> <p id="async-upload-wrap"> <label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?> </label> <input type="file" name="async-upload" id="async-upload" /> <?php submit_button(__('Upload'), 'button', 'html-upload', false); ?> <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?> </a> </p> <div class="clear"></div> </div> <p class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($upload_size_unit), esc_html($sizes[$u])); ?> <?php _e('Split your lists into max 50.000 subscribers each', 'mymail'); ?> </p> <?php if (($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024) { ?> <span class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?> </span> <?php } }
/** * Prints the templates used in the media manager. * * @since 3.5.0 */ function wp_print_media_templates() { global $is_IE; $class = 'media-modal wp-core-ui'; if ($is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false) { $class .= ' ie7'; } ?> <script type="text/html" id="tmpl-media-frame"> <div class="media-frame-menu"></div> <div class="media-frame-title"></div> <div class="media-frame-router"></div> <div class="media-frame-content"></div> <div class="media-frame-toolbar"></div> <div class="media-frame-uploader"></div> </script> <script type="text/html" id="tmpl-media-modal"> <div class="<?php echo $class; ?> "> <a class="media-modal-close" href="#" title="<?php esc_attr_e('Close'); ?> "><span class="media-modal-icon"></span></a> <div class="media-modal-content"></div> </div> <div class="media-modal-backdrop"></div> </script> <script type="text/html" id="tmpl-uploader-window"> <div class="uploader-window-content"> <h3><?php _e('Drop files to upload'); ?> </h3> </div> </script> <script type="text/html" id="tmpl-uploader-editor"> <div class="uploader-editor-content"> <div class="uploader-editor-title"><?php _e('Drop files to upload'); ?> </div> </div> </script> <script type="text/html" id="tmpl-uploader-inline"> <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> <div class="uploader-inline-content {{ messageClass }}"> <# if ( data.message ) { #> <h3 class="upload-message">{{ data.message }}</h3> <# } #> <?php if (!_device_can_upload()) { ?> <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.'), 'https://wordpress.org/mobile/'); ?> </h3> <?php } elseif (is_multisite() && !is_upload_space_available()) { ?> <h3 class="upload-instructions"><?php _e('Upload Limit Exceeded'); ?> </h3> <?php /** This action is documented in wp-admin/includes/media.php */ do_action('upload_ui_over_quota'); ?> <?php } else { ?> <div class="upload-ui"> <h3 class="upload-instructions drop-instructions"><?php _e('Drop files anywhere to upload'); ?> </h3> <a href="#" class="browser button button-hero"><?php _e('Select Files'); ?> </a> </div> <div class="upload-inline-status"></div> <div class="post-upload-ui"> <?php /** This action is documented in wp-admin/includes/media.php */ do_action('pre-upload-ui'); /** This action is documented in wp-admin/includes/media.php */ do_action('pre-plupload-upload-ui'); if (10 === remove_action('post-plupload-upload-ui', 'media_upload_flash_bypass')) { /** This action is documented in wp-admin/includes/media.php */ do_action('post-plupload-upload-ui'); add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); } else { /** This action is documented in wp-admin/includes/media.php */ do_action('post-plupload-upload-ui'); } $upload_size_unit = $max_upload_size = wp_max_upload_size(); $byte_sizes = array('KB', 'MB', 'GB'); for ($u = -1; $upload_size_unit > 1024 && $u < count($byte_sizes) - 1; $u++) { $upload_size_unit /= 1024; } if ($u < 0) { $upload_size_unit = 0; $u = 0; } else { $upload_size_unit = (int) $upload_size_unit; } ?> <p class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($upload_size_unit), esc_html($byte_sizes[$u])); ?> </p> <# if ( data.suggestedWidth && data.suggestedHeight ) { #> <p class="suggested-dimensions"> <?php _e('Suggested image dimensions:'); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}} </p> <# } #> <?php /** This action is documented in wp-admin/includes/media.php */ do_action('post-upload-ui'); ?> </div> <?php } ?> </div> </script> <script type="text/html" id="tmpl-uploader-status"> <h3><?php _e('Uploading'); ?> </h3> <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?> </a> <div class="media-progress-bar"><div></div></div> <div class="upload-details"> <span class="upload-count"> <span class="upload-index"></span> / <span class="upload-total"></span> </span> <span class="upload-detail-separator">–</span> <span class="upload-filename"></span> </div> <div class="upload-errors"></div> </script> <script type="text/html" id="tmpl-uploader-status-error"> <span class="upload-error-label"><?php _e('Error'); ?> </span> <span class="upload-error-filename">{{{ data.filename }}}</span> <span class="upload-error-message">{{ data.message }}</span> </script> <script type="text/html" id="tmpl-attachment"> <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type ) { #> <div class="thumbnail"> <div class="centered"> <img src="{{ data.size.url }}" draggable="false" /> </div> </div> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <div class="filename"> <div>{{ data.filename }}</div> </div> <# } #> <# if ( data.buttons.close ) { #> <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?> "></a> <# } #> <# if ( data.buttons.check ) { #> <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?> "><div class="media-modal-icon"></div></a> <# } #> </div> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; if ( data.describe ) { #> <# if ( 'image' === data.type ) { #> <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption" placeholder="<?php esc_attr_e('Caption this image…'); ?> " {{ maybeReadOnly }} /> <# } else { #> <input type="text" value="{{ data.title }}" class="describe" data-setting="title" <# if ( 'video' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this video…'); ?> " <# } else if ( 'audio' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this audio file…'); ?> " <# } else { #> placeholder="<?php esc_attr_e('Describe this media file…'); ?> " <# } #> {{ maybeReadOnly }} /> <# } #> <# } #> </script> <script type="text/html" id="tmpl-attachment-details"> <h3> <?php _e('Attachment Details'); ?> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?> </span> </span> </h3> <div class="attachment-info"> <div class="thumbnail"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type ) { #> <img src="{{ data.size.url }}" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="details"> <div class="filename">{{ data.filename }}</div> <div class="uploaded">{{ data.dateFormatted }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions">{{ data.width }} × {{ data.height }}</div> <# } #> <# if ( data.can.save ) { #> <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e('Edit Image'); ?> </a> <a class="refresh-attachment" href="#"><?php _e('Refresh'); ?> </a> <# } #> <# } #> <# if ( data.fileLength ) { #> <div class="file-length"><?php _e('Length:'); ?> {{ data.fileLength }}</div> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> <?php if (MEDIA_TRASH) { ?> <a class="trash-attachment" href="#"><?php _e('Trash'); ?> </a> <?php } else { ?> <a class="delete-attachment" href="#"><?php _e('Delete Permanently'); ?> </a> <?php } ?> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> </div> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <label class="setting" data-setting="title"> <span><?php _e('Title'); ?> </span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <label class="setting" data-setting="caption"> <span><?php _e('Caption'); ?> </span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span><?php _e('Alt Text'); ?> </span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span><?php _e('Description'); ?> </span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> </script> <script type="text/html" id="tmpl-media-selection"> <div class="selection-info"> <span class="count"></span> <# if ( data.editable ) { #> <a class="edit-selection" href="#"><?php _e('Edit'); ?> </a> <# } #> <# if ( data.clearable ) { #> <a class="clear-selection" href="#"><?php _e('Clear'); ?> </a> <# } #> </div> <div class="selection-view"></div> </script> <script type="text/html" id="tmpl-attachment-display-settings"> <h3><?php _e('Attachment Display Settings'); ?> </h3> <# if ( 'image' === data.type ) { #> <label class="setting"> <span><?php _e('Alignment'); ?> </span> <select class="alignment" data-setting="align" <# if ( data.userSettings ) { #> data-user-setting="align" <# } #>> <option value="left"> <?php esc_attr_e('Left'); ?> </option> <option value="center"> <?php esc_attr_e('Center'); ?> </option> <option value="right"> <?php esc_attr_e('Right'); ?> </option> <option value="none" selected> <?php esc_attr_e('None'); ?> </option> </select> </label> <# } #> <div class="setting"> <label> <# if ( data.model.canEmbed ) { #> <span><?php _e('Embed or Link'); ?> </span> <# } else { #> <span><?php _e('Link To'); ?> </span> <# } #> <select class="link-to" data-setting="link" <# if ( data.userSettings && ! data.model.canEmbed ) { #> data-user-setting="urlbutton" <# } #>> <# if ( data.model.canEmbed ) { #> <option value="embed" selected> <?php esc_attr_e('Embed Media Player'); ?> </option> <option value="file"> <# } else { #> <option value="file" selected> <# } #> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Media File'); ?> <# } else { #> <?php esc_attr_e('Media File'); ?> <# } #> </option> <option value="post"> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Attachment Page'); ?> <# } else { #> <?php esc_attr_e('Attachment Page'); ?> <# } #> </option> <# if ( 'image' === data.type ) { #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> <# } #> </select> </label> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <# if ( 'undefined' !== typeof data.sizes ) { #> <label class="setting"> <span><?php _e('Size'); ?> </span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'))); foreach ($sizes as $value => $name) { ?> <# var size = data.sizes['<?php echo esc_js($value); ?> ']; if ( size ) { #> <option value="<?php echo esc_attr($value); ?> " <?php selected($value, 'full'); ?> > <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php } ?> </select> </label> <# } #> </script> <script type="text/html" id="tmpl-gallery-settings"> <h3><?php _e('Gallery Settings'); ?> </h3> <label class="setting"> <span><?php _e('Link To'); ?> </span> <select class="link-to" data-setting="link" <# if ( data.userSettings ) { #> data-user-setting="urlbutton" <# } #>> <option value="post" selected> <?php esc_attr_e('Attachment Page'); ?> </option> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> </label> <label class="setting"> <span><?php _e('Columns'); ?> </span> <select class="columns" name="columns" data-setting="columns"> <?php for ($i = 1; $i <= 9; $i++) { ?> <option value="<?php echo esc_attr($i); ?> " <?php selected($i, 3); ?> > <?php echo esc_html($i); ?> </option> <?php } ?> </select> </label> <label class="setting"> <span><?php _e('Random Order'); ?> </span> <input type="checkbox" data-setting="_orderbyRandom" /> </label> </script> <script type="text/html" id="tmpl-playlist-settings"> <h3><?php _e('Playlist Settings'); ?> </h3> <# var emptyModel = _.isEmpty( data.model ), isVideo = 'video' === data.controller.get('library').props.get('type'); #> <label class="setting"> <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <# if ( isVideo ) { #> <span><?php _e('Show Video List'); ?> </span> <# } else { #> <span><?php _e('Show Tracklist'); ?> </span> <# } #> </label> <# if ( ! isVideo ) { #> <label class="setting"> <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e('Show Artist Name in Tracklist'); ?> </span> </label> <# } #> <label class="setting"> <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e('Show Images'); ?> </span> </label> </script> <script type="text/html" id="tmpl-embed-link-settings"> <label class="setting"> <span><?php _e('Title'); ?> </span> <input type="text" class="alignment" data-setting="title" /> </label> </script> <script type="text/html" id="tmpl-embed-image-settings"> <div class="thumbnail"> <img src="{{ data.model.url }}" draggable="false" /> </div> <?php /** This filter is documented in wp-admin/includes/media.php */ if (!apply_filters('disable_captions', '')) { ?> <label class="setting caption"> <span><?php _e('Caption'); ?> </span> <textarea data-setting="caption" /> </label> <?php } ?> <label class="setting alt-text"> <span><?php _e('Alt Text'); ?> </span> <input type="text" data-setting="alt" /> </label> <div class="setting align"> <span><?php _e('Align'); ?> </span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <div class="setting link-to"> <span><?php _e('Link To'); ?> </span> <div class="button-group button-large" data-setting="link"> <button class="button" value="file"> <?php esc_attr_e('Image URL'); ?> </button> <button class="button" value="custom"> <?php esc_attr_e('Custom URL'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> </script> <script type="text/html" id="tmpl-attachments-css"> <style type="text/css" id="{{ data.id }}-css"> #{{ data.id }} { padding: 0 {{ data.gutter }}px; } #{{ data.id }} .attachment { margin: {{ data.gutter }}px; width: {{ data.edge }}px; } #{{ data.id }} .attachment-preview, #{{ data.id }} .attachment-preview .thumbnail { width: {{ data.edge }}px; height: {{ data.edge }}px; } #{{ data.id }} .portrait .thumbnail img { max-width: {{ data.edge }}px; height: auto; } #{{ data.id }} .landscape .thumbnail img { width: auto; max-height: {{ data.edge }}px; } </style> </script> <script type="text/html" id="tmpl-image-details"> <div class="media-embed"> <div class="embed-media-settings"> <div class="column-image"> <div class="image"> <img src="{{ data.model.url }}" draggable="false" /> <# if ( data.attachment && window.imageEdit ) { #> <div class="actions"> <input type="button" class="edit-attachment button" value="<?php esc_attr_e('Edit Original'); ?> " /> <input type="button" class="replace-attachment button" value="<?php esc_attr_e('Replace'); ?> " /> </div> <# } #> </div> </div> <div class="column-settings"> <?php /** This filter is documented in wp-admin/includes/media.php */ if (!apply_filters('disable_captions', '')) { ?> <label class="setting caption"> <span><?php _e('Caption'); ?> </span> <textarea data-setting="caption">{{ data.model.caption }}</textarea> </label> <?php } ?> <label class="setting alt-text"> <span><?php _e('Alternative Text'); ?> </span> <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> </label> <h3><?php _e('Display Settings'); ?> </h3> <div class="setting align"> <span><?php _e('Align'); ?> </span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <# if ( data.attachment ) { #> <# if ( 'undefined' !== typeof data.attachment.sizes ) { #> <label class="setting size"> <span><?php _e('Size'); ?> </span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'))); foreach ($sizes as $value => $name) { ?> <# var size = data.sizes['<?php echo esc_js($value); ?> ']; if ( size ) { #> <option value="<?php echo esc_attr($value); ?> "> <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php } ?> <option value="<?php echo esc_attr('custom'); ?> "> <?php _e('Custom Size'); ?> </option> </select> </label> <# } #> <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> <label><span><?php _e('Width'); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e('Height'); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> </div> <# } #> <div class="setting link-to"> <span><?php _e('Link To'); ?> </span> <select data-setting="link"> <# if ( data.attachment ) { #> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> <option value="post"> <?php esc_attr_e('Attachment Page'); ?> </option> <# } else { #> <option value="file"> <?php esc_attr_e('Image URL'); ?> </option> <# } #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <div class="advanced-section"> <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?> </a></h3> <div class="advanced-settings hidden"> <div class="advanced-image"> <label class="setting title-text"> <span><?php _e('Image Title Attribute'); ?> </span> <input type="text" data-setting="title" value="{{ data.model.title }}" /> </label> <label class="setting extra-classes"> <span><?php _e('Image CSS Class'); ?> </span> <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" /> </label> </div> <div class="advanced-link"> <div class="setting link-target"> <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e('Open link in a new window/tab'); ?> </label> </div> <label class="setting link-rel"> <span><?php _e('Link Rel'); ?> </span> <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" /> </label> <label class="setting link-class-name"> <span><?php _e('Link CSS Class'); ?> </span> <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" /> </label> </div> </div> </div> </div> </div> </div> </script> <script type="text/html" id="tmpl-image-editor"> <div id="media-head-{{ data.id }}"></div> <div id="image-editor-{{ data.id }}"></div> </script> <script type="text/html" id="tmpl-audio-details"> <# var ext, html5types = { mp3: wp.media.view.settings.embedMimes.mp3, ogg: wp.media.view.settings.embedMimes.ogg }; #> <?php $audio_types = wp_get_audio_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-audio-settings"> <?php wp_underscore_audio_template(); ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php foreach ($audio_types as $type) { ?> <# if ( ! _.isEmpty( data.model.<?php echo $type; ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type; ?> ) ) { delete html5types.<?php echo $type; ?> ; } #> <label class="setting"> <span><?php echo strtoupper($type); ?> </span> <input type="text" disabled="disabled" data-setting="<?php echo $type; ?> " value="{{ data.model.<?php echo $type; ?> }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php } ?> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e('Add alternate sources for maximum HTML5 playback:'); ?> </span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <div class="setting preload"> <span><?php _e('Preload'); ?> </span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex('Auto', 'auto preload'); ?> </button> <button class="button" value="metadata"><?php _e('Metadata'); ?> </button> <button class="button active" value="none"><?php _e('None'); ?> </button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e('Autoplay'); ?> </span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e('Loop'); ?> </span> </label> </div> </div> </script> <script type="text/html" id="tmpl-video-details"> <# var ext, html5types = { mp4: wp.media.view.settings.embedMimes.mp4, ogv: wp.media.view.settings.embedMimes.ogv, webm: wp.media.view.settings.embedMimes.webm }; #> <?php $video_types = wp_get_video_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-video-settings"> <div class="wp-video-holder"> <# var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/); w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, h = ! data.model.height ? 360 : data.model.height; if ( data.model.width && w !== data.model.width ) { h = Math.ceil( ( h * w ) / data.model.width ); } #> <?php wp_underscore_video_template(); ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php foreach ($video_types as $type) { ?> <# if ( ! _.isEmpty( data.model.<?php echo $type; ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type; ?> ) ) { delete html5types.<?php echo $type; ?> ; } #> <label class="setting"> <span><?php echo strtoupper($type); ?> </span> <input type="text" disabled="disabled" data-setting="<?php echo $type; ?> " value="{{ data.model.<?php echo $type; ?> }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php } ?> </div> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e('Add alternate sources for maximum HTML5 playback:'); ?> </span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <# if ( ! _.isEmpty( data.model.poster ) ) { #> <label class="setting"> <span><?php _e('Poster Image'); ?> </span> <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <div class="setting preload"> <span><?php _e('Preload'); ?> </span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex('Auto', 'auto preload'); ?> </button> <button class="button" value="metadata"><?php _e('Metadata'); ?> </button> <button class="button active" value="none"><?php _e('None'); ?> </button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e('Autoplay'); ?> </span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e('Loop'); ?> </span> </label> <label class="setting" data-setting="content"> <span><?php _e('Tracks (subtitles, captions, descriptions, chapters, or metadata)'); ?> </span> <# var content = ''; if ( ! _.isEmpty( data.model.content ) ) { var tracks = jQuery( data.model.content ).filter( 'track' ); _.each( tracks.toArray(), function (track) { content += track.outerHTML; #> <p> <input class="content-track" type="text" value="{{ track.outerHTML }}" /> <a class="remove-setting remove-track"><?php _e('Remove'); ?> </a> </p> <# } ); #> <# } else { #> <em><?php _e('There are no associated subtitles.'); ?> </em> <# } #> <textarea class="hidden content-setting">{{ content }}</textarea> </label> </div> </div> </script> <script type="text/html" id="tmpl-editor-gallery"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div><div class="dashicons dashicons-no-alt remove"></div> </div> <# if ( data.attachments ) { #> <div class="gallery gallery-columns-{{ data.columns }}"> <# _.each( data.attachments, function( attachment, index ) { #> <dl class="gallery-item"> <dt class="gallery-icon"> <# if ( attachment.thumbnail ) { #> <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" /> <# } else { #> <img src="{{ attachment.url }}" /> <# } #> </dt> <dd class="wp-caption-text gallery-caption"> {{ attachment.caption }} </dd> </dl> <# if ( index % data.columns === data.columns - 1 ) { #> <br style="clear: both;"> <# } #> <# } ); #> </div> <# } else { #> <div class="wpview-error"> <div class="dashicons dashicons-format-gallery"></div><p><?php _e('No items found.'); ?> </p> </div> <# } #> </script> <script type="text/html" id="tmpl-editor-audio"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-no-alt remove"></div> </div> <?php wp_underscore_audio_template(); ?> <div class="wpview-overlay"></div> </script> <script type="text/html" id="tmpl-editor-video"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-no-alt remove"></div> </div> <?php wp_underscore_video_template(); ?> <div class="wpview-overlay"></div> </script> <?php wp_underscore_playlist_templates(); ?> <script type="text/html" id="tmpl-editor-playlist"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-no-alt remove"></div> </div> <# if ( data.tracks ) { #> <div class="wp-playlist wp-{{ data.type }}-playlist wp-playlist-{{ data.style }}"> <# if ( 'audio' === data.type ){ #> <div class="wp-playlist-current-item"></div> <# } #> <{{ data.type }} controls="controls" preload="none" <# if ( data.width ) { #> width="{{ data.width }}"<# } #><# if ( data.height ) { #> height="{{ data.height }}"<# } #>></{{ data.type }}> <div class="wp-playlist-next"></div> <div class="wp-playlist-prev"></div> </div> <div class="wpview-overlay"></div> <# } else { #> <div class="wpview-error"> <div class="dashicons dashicons-video-alt3"></div><p><?php _e('No items found.'); ?> </p> </div> <# } #> </script> <script type="text/html" id="tmpl-crop-content"> <img class="crop-image" src="{{ data.url }}"> <div class="upload-errors"></div> </script> <?php /** * Fires when the custom Backbone media templates are printed. * * @since 3.5.0 */ do_action('print_media_templates'); }
public function Init($cotainer_id, $browser_btn_id = '', $error_el_id = null, $drop_el_id = null) { if (empty($drop_el_id)) { $drop_el_id = $cotainer_id; } if (empty($browser_btn_id)) { $browser_btn_id = $cotainer_id . '-btn'; echo '<input type="button" value="Select Files" id="' . $browser_btn_id . '" style="display:none;" />'; } $max_upload_size = WPFB_Core::GetMaxUlSize(); if (is_admin()) { self::PrintScripts(); } $plupload_init = array('runtimes' => 'html5,gears,silverlight,flash,html4', 'browse_button' => $browser_btn_id, 'container' => $cotainer_id, 'drop_element' => $drop_el_id, 'file_data_name' => 'async-upload', 'multiple_queues' => $this->multi, 'max_file_size' => $max_upload_size . 'b', 'url' => WPFB_Core::PluginUrl('wpfb-async-upload.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => $this->images_only ? __('Images') : __('Allowed Files'), 'extensions' => $this->images_only ? 'jpg,gif,png,bmp' : '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array_merge($this->GetAjaxAuthData(), $this->post_params)); $jss = md5(uniqid()); ?> <script type="text/javascript"> init_<?php echo $jss; ?> = (function() { if('undefined' == typeof plupload) { setTimeout(init_<?php echo $jss; ?> , 100); return; } var uploader = new plupload.Uploader(<?php echo json_encode($plupload_init); ?> ); uploader.bind('Init', function(up) { var uploaddiv = jQuery('#<?php echo $cotainer_id; ?> '); var dropdiv = jQuery('#<?php echo $drop_el_id; ?> '); uploaddiv.data('uploader', up); if ( !jQuery(document.body).hasClass('mobile') ) { dropdiv.addClass('drag-drop'); dropdiv.bind('dragover', function(e){ dropdiv.addClass('drag-over'); }) .bind('dragleave', function(e){ dropdiv.removeClass('drag-over'); }) .bind('drop', function(e){ dropdiv.removeClass('drag-over'); }); } else { dropdiv.removeClass('drag-drop'); //dropdiv.hide(); } // if ( up.runtime == 'html4' ) // jQuery('.upload-flash-bypass').hide(); }); uploader.init(); var mobile = <?php echo (int) wp_is_mobile(); ?> ; var supported = <?php echo (int) (!wp_is_mobile() || function_exists('_device_can_upload') && _device_can_upload()); ?> ; var supports_dragdrop = uploader.features.dragdrop && !mobile; // Generate drag/drop helper classes. (function( dropzone, supported ) { var timer, active; if ( ! dropzone ) return; dropzone.toggleClass( 'supports-drag-drop', !! supported ); if ( ! supported ) return dropzone.unbind('.wp-uploader'); // 'dragenter' doesn't fire correctly, // simulate it with a limited 'dragover' dropzone.bind( 'dragover.wp-uploader', function(){ if ( timer ) clearTimeout( timer ); if ( active ) return; dropzone.trigger('dropzone:enter').addClass('drag-over'); active = true; }); dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){ // Using an instant timer prevents the drag-over class from // being quickly removed and re-added when elements inside the // dropzone are repositioned. // // See http://core.trac.wordpress.org/ticket/21705 timer = setTimeout( function() { active = false; dropzone.trigger('dropzone:leave').removeClass('drag-over'); }, 0 ); }); }( jQuery('#<?php echo $drop_el_id; ?> '), supports_dragdrop )); uploader.bind('FilesAdded', function(up, files) { var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); <?php if (!empty($error_el_id)) { ?> jQuery('#<?php echo $error_el_id; ?> ').html('');<?php } ?> <?php if (!empty($this->js_files_queued)) { echo $this->js_files_queued . '(up, files)'; } ?> plupload.each(files, function(file){ if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' ) wpfbPlUploadSizeError( up, file, true ); else { file.dom_id = '<?php echo $cotainer_id; ?> -ul'+file.id; <?php echo $this->js_file_queued; ?> (up, file); } }); up.refresh(); up.start(); }); uploader.bind('BeforeUpload', function(up, file) { // something }); uploader.bind('UploadFile', function(up, file) { wpfbPlFileUploading(up, file); }); uploader.bind('UploadProgress', function(up, file) { var item = jQuery('#'+file.dom_id); jQuery('.bar', item).width( (200 * file.loaded) / file.size ); jQuery('.percent', item).html( file.percent + '%' ); <?php if (!empty($this->js_upload_progress)) { echo $this->js_upload_progress . '(file);'; } ?> }); uploader.bind('Error', function(up, err) { wpfbPlUploadError(err.file, err.code, err.message, up); up.refresh(); }); uploader.bind('FileUploaded', function(up, file, response) { // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag var serverData = response.response.replace(/^<pre>(.+)<\/pre>$/, '$1'); if ( serverData.match('media-upload-error') || serverData.match('error-div') ) { wpfbPlFileError(file, serverData); return; } serverData = jQuery.parseJSON(serverData); <?php echo $this->js_upload_success; ?> (file, serverData); }); uploader.bind('UploadComplete', function(up, files) { //uploadComplete(); }); function wpfbPlFileUploading(up, file) { var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); if ( max > hundredmb && file.size > hundredmb ) { setTimeout(function(){ var done; if ( file.status < 3 && file.loaded == 0 ) { // not uploading wpfbPlFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>')); up.stop(); // stops the whole queue up.removeFile(file); up.start(); // restart the queue } }, 10000); // wait for 10 sec. for the file to start uploading } } /* function uploadProgress(up, file) { var item = jQuery('#media-item-' + file.id); jQuery('.bar', item).width( (200 * file.loaded) / file.size ); jQuery('.percent', item).html( file.percent + '%' ); }*/ function wpfbPlUploadSizeError( up, file, over100mb ) { var message; if ( over100mb ) message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'); else message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name); <?php echo $this->js_file_error; ?> (message,file); up.removeFile(file); } function wpfbPlUploadError(fileObj, errorCode, message, uploader) { var hundredmb = 100 * 1024 * 1024, max; switch (errorCode) { case plupload.FAILED: wpfbPlFileError(fileObj, pluploadL10n.upload_failed); break; case plupload.FILE_EXTENSION_ERROR: wpfbPlFileError(fileObj, pluploadL10n.invalid_filetype); break; case plupload.FILE_SIZE_ERROR: wpfbPlUploadSizeError(uploader, fileObj); break; case plupload.IMAGE_FORMAT_ERROR: wpfbPlFileError(fileObj, pluploadL10n.not_an_image); break; case plupload.IMAGE_MEMORY_ERROR: wpfbPlFileError(fileObj, pluploadL10n.image_memory_exceeded); break; case plupload.IMAGE_DIMENSIONS_ERROR: wpfbPlFileError(fileObj, pluploadL10n.image_dimensions_exceeded); break; case plupload.GENERIC_ERROR: wpfbPlQueueError(pluploadL10n.upload_failed); break; case plupload.IO_ERROR: max = parseInt(uploader.settings.max_file_size, 10); if ( max > hundredmb && fileObj.size > hundredmb ) wpfbPlFileError(fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>')); else wpfbPlQueueError(pluploadL10n.io_error); break; case plupload.HTTP_ERROR: wpfbPlQueueError(pluploadL10n.http_error); break; case plupload.INIT_ERROR: //jQuery('.media-upload-form').addClass('html-uploader'); // TODO: on init failure break; case plupload.SECURITY_ERROR: wpfbPlQueueError(pluploadL10n.security_error); break; /* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED: case plupload.UPLOAD_ERROR.FILE_CANCELLED: jQuery('#media-item-' + fileObj.id).remove(); break;*/ default: wpfbPlFileError(fileObj, pluploadL10n.default_error); } } function wpfbPlFileError(fileObj, message) { var item = jQuery('#' + fileObj.dom_id); jQuery('.error', item).show().html(message); <?php if (!empty($this->js_file_error)) { ?> <?php echo $this->js_file_error; ?> (message,fileObj); <?php } ?> } // generic error message function wpfbPlQueueError(message) { <?php if (!empty($error_el_id)) { ?> jQuery('#<?php echo $error_el_id; ?> ').show().html( '<div class="error"><p>' + message + '</p></div>' ); <?php } else { ?> alert(message); <?php } ?> } }); init_<?php echo $jss; ?> (); </script> <?php }
public function Init($cotainer_id, $browser_btn_id, $drop_el_id, $error_el_id) { $max_upload_size = WPFB_Core::GetMaxUlSize(); wp_print_scripts('plupload-all'); wp_print_scripts('wp-plupload'); $plupload_init = array('runtimes' => 'html5,gears,silverlight,flash,html4', 'browse_button' => $browser_btn_id, 'container' => $cotainer_id, 'drop_element' => $drop_el_id, 'file_data_name' => 'async-upload', 'multiple_queues' => $this->multi, 'max_file_size' => $max_upload_size . 'b', 'url' => WPFB_PLUGIN_URI . 'wpfb-async-upload.php', 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => $this->images_only ? __('Images') : __('Allowed Files'), 'extensions' => $this->images_only ? 'jpg,gif,png,bmp' : '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array_merge($this->GetAjaxAuthData(), $this->post_params)); ?> <script type="text/javascript"> (function() { var uploader = new plupload.Uploader(<?php echo json_encode($plupload_init); ?> ); uploader.bind('Init', function(up) { //var uploaddiv = jQuery('#<?php echo $cotainer_id; ?> '); var dropdiv = jQuery('#<?php echo $drop_el_id; ?> '); if ( !jQuery(document.body).hasClass('mobile') ) { dropdiv.addClass('drag-drop'); dropdiv.bind('dragover', function(e){ dropdiv.addClass('drag-over'); }).bind('dragleave, drop', function(){ dropdiv.removeClass('drag-over'); }); } else { dropdiv.removeClass('drag-drop'); dropdiv.hide(); } // if ( up.runtime == 'html4' ) // jQuery('.upload-flash-bypass').hide(); }); uploader.init(); var mobile = <?php echo (int) wp_is_mobile(); ?> ; var supported = <?php echo (int) (!wp_is_mobile() || function_exists('_device_can_upload') && _device_can_upload()); ?> ; var supports_dragdrop = uploader.features.dragdrop && !mobile; // Generate drag/drop helper classes. (function( dropzone, supported ) { var timer, active; if ( ! dropzone ) return; dropzone.toggleClass( 'supports-drag-drop', !! supported ); if ( ! supported ) return dropzone.unbind('.wp-uploader'); // 'dragenter' doesn't fire correctly, // simulate it with a limited 'dragover' dropzone.bind( 'dragover.wp-uploader', function(){ if ( timer ) clearTimeout( timer ); if ( active ) return; dropzone.trigger('dropzone:enter').addClass('drag-over'); active = true; }); dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){ // Using an instant timer prevents the drag-over class from // being quickly removed and re-added when elements inside the // dropzone are repositioned. // // See http://core.trac.wordpress.org/ticket/21705 timer = setTimeout( function() { active = false; dropzone.trigger('dropzone:leave').removeClass('drag-over'); }, 0 ); }); }( jQuery('#<?php echo $drop_el_id; ?> '), supports_dragdrop )); uploader.bind('FilesAdded', function(up, files) { var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); jQuery('#<?php echo $error_el_id; ?> ').html(''); <?php if (!empty($this->js_files_queued)) { echo $this->js_files_queued . '(up, files)'; } ?> plupload.each(files, function(file){ if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' ) wpfbPlUploadSizeError( up, file, true ); else <?php echo $this->js_file_queued; ?> (up, file); }); up.refresh(); up.start(); }); uploader.bind('BeforeUpload', function(up, file) { // something }); uploader.bind('UploadFile', function(up, file) { wpfbPlFileUploading(up, file); }); uploader.bind('UploadProgress', function(up, file) { <?php echo $this->js_upload_progress; ?> (file); }); uploader.bind('Error', function(up, err) { wpfbPlUploadError(err.file, err.code, err.message, up); up.refresh(); }); uploader.bind('FileUploaded', function(up, file, response) { // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag var serverData = response.response.replace(/^<pre>(.+)<\/pre>$/, '$1'); if ( serverData.match('media-upload-error') || serverData.match('error-div') ) { wpfbPlFileError(file, serverData); return; } serverData = jQuery.parseJSON(serverData); <?php echo $this->js_upload_success; ?> (file, serverData); }); uploader.bind('UploadComplete', function(up, files) { //uploadComplete(); }); })(); // EXTERNAL /* function fileQueued(fileObj) { // Create a progress bar containing the filename jQuery('#<?php echo $this->prefix; ?> files').append('<div id="<?php echo $this->prefix; ?> file-' + fileObj.id + '" class="media-item child-of-' + postid + '"><div class="progress"><div class="percent">0%</div><div class="bar"></div></div><div class="filename original"> ' + fileObj.name + '</div></div>'); jQuery('#file-upload-progress').show().html('<div class="progress"><div class="percent">0%</div><div class="bar" style="width: 30px"></div></div><div class="filename original"> ' + fileObj.name + '</div>'); jQuery('.progress', '#file-upload-progress').show(); jQuery('.filename', '#file-upload-progress').show(); jQuery("#media-upload-error").empty(); jQuery('.upload-flash-bypass').hide(); jQuery('#file-submit').prop('disabled', true); jQuery('#cancel-upload').show().prop('disabled', false); // delete already uploaded temp file if(jQuery('#file_flash_upload').val() != '0') { var postdata = <?php echo json_encode($this->GetAjaxAuthData()); ?> ; postdata.delupload = jQuery('#file_flash_upload').val(); jQuery.ajax({type: 'POST', async: true, url:"<?php echo esc_attr(WPFB_PLUGIN_URI . 'wpfb-async-upload.php'); ?> ", data: postdata, success: (function(data){}) }); jQuery('#file_flash_upload').val(0); } } */ function wpfbPlFileUploading(up, file) { var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); if ( max > hundredmb && file.size > hundredmb ) { setTimeout(function(){ var done; if ( file.status < 3 && file.loaded == 0 ) { // not uploading wpfbPlFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>')); up.stop(); // stops the whole queue up.removeFile(file); up.start(); // restart the queue } }, 10000); // wait for 10 sec. for the file to start uploading } } /* function uploadProgress(up, file) { var item = jQuery('#media-item-' + file.id); jQuery('.bar', item).width( (200 * file.loaded) / file.size ); jQuery('.percent', item).html( file.percent + '%' ); }*/ function wpfbPlUploadSizeError( up, file, over100mb ) { var message; if ( over100mb ) message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'); else message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name); <?php echo $this->js_file_error; ?> (message,file); up.removeFile(file); } function wpfbPlUploadError(fileObj, errorCode, message, uploader) { var hundredmb = 100 * 1024 * 1024, max; switch (errorCode) { case plupload.FAILED: wpfbPlFileError(fileObj, pluploadL10n.upload_failed); break; case plupload.FILE_EXTENSION_ERROR: wpfbPlFileError(fileObj, pluploadL10n.invalid_filetype); break; case plupload.FILE_SIZE_ERROR: wpfbPlUploadSizeError(uploader, fileObj); break; case plupload.IMAGE_FORMAT_ERROR: wpfbPlFileError(fileObj, pluploadL10n.not_an_image); break; case plupload.IMAGE_MEMORY_ERROR: wpfbPlFileError(fileObj, pluploadL10n.image_memory_exceeded); break; case plupload.IMAGE_DIMENSIONS_ERROR: wpfbPlFileError(fileObj, pluploadL10n.image_dimensions_exceeded); break; case plupload.GENERIC_ERROR: wpfbPlQueueError(pluploadL10n.upload_failed); break; case plupload.IO_ERROR: max = parseInt(uploader.settings.max_file_size, 10); if ( max > hundredmb && fileObj.size > hundredmb ) wpfbPlFileError(fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>')); else wpfbPlQueueError(pluploadL10n.io_error); break; case plupload.HTTP_ERROR: wpfbPlQueueError(pluploadL10n.http_error); break; case plupload.INIT_ERROR: //jQuery('.media-upload-form').addClass('html-uploader'); // TODO: on init failure break; case plupload.SECURITY_ERROR: wpfbPlQueueError(pluploadL10n.security_error); break; /* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED: case plupload.UPLOAD_ERROR.FILE_CANCELLED: jQuery('#media-item-' + fileObj.id).remove(); break;*/ default: wpfbPlFileError(fileObj, pluploadL10n.default_error); } } /* function uploadSuccess(fileObj, serverData) { var item = jQuery('#media-item-' + fileObj.id); // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag serverData = serverData.replace(/^<pre>(\d+)<\/pre>$/, '$1'); // if async-upload returned an error message, place it in the media item div and return if ( serverData.match(/media-upload-error|error-div/) ) { item.html(serverData); return; } else { jQuery('.percent', item).html( pluploadL10n.crunching ); } prepareMediaItem(fileObj, serverData); updateMediaForm(); // Increment the counter. if ( post_id && item.hasClass('child-of-' + post_id) ) jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1); } */ function wpfbPlFileError(fileObj, message) { <?php echo $this->js_file_error; ?> (message,fileObj); } // generic error message function wpfbPlQueueError(message) { jQuery('#<?php echo $error_el_id; ?> ').show().html( '<div class="error"><p>' + message + '</p></div>' ); } </script> <?php }
/** * Finally output the uploader * * @global $type, $tab, $pagenow, $is_IE, $is_opera * @return string the output */ public function display() { global $type, $tab, $pagenow, $is_IE, $is_opera; ?> <form enctype="multipart/form-data" method="post" action="" class="media-upload-form type-form validate standard-form" id="file-form"> <?php if (!_device_can_upload()) { echo '<p>' . __('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.', 'buddydrive') . '</p>'; return; } $upload_size_unit = $max_upload_size = buddydrive_max_upload_size(true); $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; } ?> <div id="media-upload-notice"><?php if (isset($errors['upload_notice'])) { echo $errors['upload_notice']; } ?> </div> <div id="media-upload-error"><?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { echo $errors['upload_error']->get_error_message(); } ?> </div> <div id="buddydrive-first-step" class="buddydrive-step"> <label for="buddyfile-desc"><?php _e('Describe your file', 'buddydrive'); ?> </label> <textarea placeholder="<?php _e('140 characters to do so', 'buddydrive'); ?> " maxlength="140" id="buddyfile-desc"></textarea> <p class="buddydrive-action"><a href="#" class="next-step button"><?php _e('Next Step', 'buddydrive'); ?> </a></p> </div> <?php if (has_action('buddydrive_uploader_custom_fields')) { ?> <div id="buddydrive-custom-step-new" class="buddydrive-step hide"> <?php do_action('buddydrive_uploader_custom_fields'); ?> <p class="buddydrive-action"><a href="#" class="next-step button"><?php _e('Next Step', 'buddydrive'); ?> </a></p> </div> <?php } ?> <div id="buddydrive-second-step" class="buddydrive-step hide"> <label for="buddydrive-sharing-options"><?php _e('Define your sharing options', 'buddydrive'); ?> </label> <?php buddydrive_select_sharing_options(); ?> <div id="buddydrive-sharing-details"></div> <input type="hidden" id="buddydrive-sharing-settings" value="private"> <p class="buddydrive-action"><a href="#" class="next-step button"><?php _e('Next Step', 'buddydrive'); ?> </a></p> </div> <?php if (is_multisite() && !is_upload_space_available()) { do_action('upload_ui_over_quota'); return; } $buddydrive_params = array('action' => 'buddydrive_upload', '_wpnonce' => wp_create_nonce('buddydrive-form')); $buddydrive_params = apply_filters('buddydrive_upload_post_params', $buddydrive_params); // hook change! old name: 'swfupload_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' => 'buddyfile-upload', 'multi_selection' => false, 'url' => admin_url('admin-ajax.php', 'relative'), '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' => '*', 'max_file_size' => $max_upload_size . 'b')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => $buddydrive_params); $plupload_init = apply_filters('buddydrive_plupload_init', $plupload_init); ?> <script type="text/javascript"> var wpUploaderInit = <?php echo json_encode($plupload_init); ?> ; </script> <div id="buddydrive-third-step" class="buddydrive-step hide"> <label for="plupload-browse-buttons"><?php _e('Upload your file!', 'buddydrive'); ?> </label> <div id="plupload-upload-ui" class="hide-if-no-js"> <div id="drag-drop-area"> <div class="drag-drop-inside"> <p class="drag-drop-info"><?php _e('Drop your file here', 'buddydrive'); ?> </p> <p><?php _ex('or', 'Uploader: Drop your file here - or - Select your File', 'buddydrive'); ?> </p> <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select your File', 'buddydrive'); ?> " class="button" /></p> </div> </div> </div> <p><span class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.', 'buddydrive'), esc_html($upload_size_unit), esc_html($sizes[$u])); ?> </span></p> <p class="buddydrive-action"><a href="#" class="cancel-step button"><?php _e('Cancel', 'buddydrive'); ?> </a></p> </div> </form> <?php }
/** * {@internal Missing Short Description}} * * @since 2.5.0 * * @param unknown_type $errors */ function media_upload_form($errors = null) { global $type, $tab, $pagenow, $is_IE, $is_opera; if (!_device_can_upload()) { echo '<p>' . __('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.') . '</p>'; return; } $upload_action_url = admin_url('async-upload.php'); $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; $_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; } ?> <div id="media-upload-notice"><?php if (isset($errors['upload_notice'])) { echo $errors['upload_notice']; } ?> </div> <div id="media-upload-error"><?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { echo $errors['upload_error']->get_error_message(); } ?> </div> <?php if (is_multisite() && !is_upload_space_available()) { do_action('upload_ui_over_quota'); return; } do_action('pre-upload-ui'); $post_params = array("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' $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); // 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()) { $plupload_init['multi_selection'] = false; } $plupload_init = apply_filters('plupload_init', $plupload_init); ?> <script type="text/javascript"> <?php // Verify size is an int. If not return default value. $large_size_h = absint(get_option('large_size_h')); if (!$large_size_h) { $large_size_h = 1024; } $large_size_w = absint(get_option('large_size_w')); if (!$large_size_w) { $large_size_w = 1024; } ?> var resize_height = <?php echo $large_size_h; ?> , resize_width = <?php echo $large_size_w; ?> , wpUploaderInit = <?php echo json_encode($plupload_init); ?> ; </script> <div id="plupload-upload-ui" class="hide-if-no-js"> <?php do_action('pre-plupload-upload-ui'); // hook change, old name: 'pre-flash-upload-ui' ?> <div id="drag-drop-area"> <div class="drag-drop-inside"> <p class="drag-drop-info"><?php _e('Drop files here'); ?> </p> <p><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?> </p> <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?> " class="button" /></p> </div> </div> <?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?> </div> <div id="html-upload-ui" class="hide-if-js"> <?php do_action('pre-html-upload-ui'); ?> <p id="async-upload-wrap"> <label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?> </label> <input type="file" name="async-upload" id="async-upload" /> <?php submit_button(__('Upload'), 'button', 'html-upload', false); ?> <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?> </a> </p> <div class="clear"></div> <?php do_action('post-html-upload-ui'); ?> </div> <span class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($upload_size_unit), esc_html($sizes[$u])); ?> </span> <?php if (($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024) { ?> <span class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?> </span> <?php } do_action('post-upload-ui'); }
/** * Prints default plupload arguments. * * @since 3.4.0 */ function wp_plupload_default_settings() { global $wp_scripts; $data = $wp_scripts->get_data('wp-plupload', 'data'); if ($data && false !== strpos($data, '_wpPluploadSettings')) { return; } $max_upload_size = wp_max_upload_size(); $defaults = array('runtimes' => 'html5,flash,silverlight,html4', 'file_data_name' => 'async-upload', 'url' => admin_url('async-upload.php', 'relative'), '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')); /** * Filter the Plupload default settings. * * @since 3.4.0 * * @param array $defaults Default Plupload settings array. */ $defaults = apply_filters('plupload_default_settings', $defaults); $params = array('action' => 'upload-attachment'); /** * Filter the Plupload default parameters. * * @since 3.4.0 * * @param array $params Default Plupload parameters array. */ $params = apply_filters('plupload_default_params', $params); $params['_wpnonce'] = wp_create_nonce('media-form'); $defaults['multipart_params'] = $params; $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload()), 'limitExceeded' => is_multisite() && !is_upload_space_available()); $script = 'var _wpPluploadSettings = ' . json_encode($settings) . ';'; if ($data) { $script = "{$data}\n{$script}"; } $wp_scripts->add_data('wp-plupload', 'data', $script); }
/** * @dataProvider data_device_can_upload */ function test_device_can_upload($user_agent, $expected) { $_SERVER['HTTP_USER_AGENT'] = $user_agent; $actual = _device_can_upload(); unset($_SERVER['HTTP_USER_AGENT']); $this->assertEquals($expected, $actual); }
<?php /** * BuddyPress Uploader templates. * * This template is used to create the BuddyPress Uploader Backbone views. * * @since 2.3.0 * * @package BuddyPress * @subpackage bp-attachments */ ?> <script type="text/html" id="tmpl-upload-window"> <?php if (!_device_can_upload()) { ?> <h3 class="upload-instructions"><?php esc_html_e('The web browser on your device cannot be used to upload files.', 'buddypress'); ?> </h3> <?php } elseif (is_multisite() && !is_upload_space_available()) { ?> <h3 class="upload-instructions"><?php esc_html_e('Upload Limit Exceeded', 'buddypress'); ?> </h3> <?php } else { ?>
break; default: $up_url = admin_url('async-upload.php', 'relative'); break; } $defaults = array('runtimes' => 'html5,flash,silverlight,html4', 'file_data_name' => 'async-upload', 'url' => $up_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')); /** * Filter the Plupload default settings. * * @since 3.4.0 * * @param array $defaults Default Plupload settings array. */ $defaults = apply_filters('plupload_default_settings', $defaults); $params = array('action' => 'upload-attachment'); /** * Filter the Plupload default parameters. * * @since 3.4.0 * * @param array $params Default Plupload parameters array. */ $params = apply_filters('plupload_default_params', $params); $params['_wpnonce'] = wp_create_nonce('media-form'); $defaults['multipart_params'] = $params; $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload()), 'limitExceeded' => is_multisite() && !is_upload_space_available()); $script = 'var _wpPluploadSettings = ' . json_encode($settings) . ';'; if ($data) { $script = "{$data}\n{$script}"; } $wp_scripts->add_data('wp-plupload', 'data', $script);
/** * Prints default plupload arguments. * * @since 3.4.0 */ function wp_plupload_default_settings() { global $wp_scripts; $data = $wp_scripts->get_data('wp-plupload', 'data'); if ($data && false !== strpos($data, '_wpPluploadSettings')) { return; } $max_upload_size = wp_max_upload_size(); $defaults = array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => $max_upload_size . 'b', 'url' => admin_url('async-upload.php', 'relative'), '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); // 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()) { $defaults['multi_selection'] = false; } $defaults = apply_filters('plupload_default_settings', $defaults); $params = array('action' => 'upload-attachment'); $params = apply_filters('plupload_default_params', $params); $params['_wpnonce'] = wp_create_nonce('media-form'); $defaults['multipart_params'] = $params; $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload()), 'limitExceeded' => is_multisite() && !is_upload_space_available()); $script = 'var _wpPluploadSettings = ' . json_encode($settings) . ';'; if ($data) { $script = "{$data}\n{$script}"; } $wp_scripts->add_data('wp-plupload', 'data', $script); }
/** * {@internal Missing Short Description}} * * @since 2.5.0 * * @param unknown_type $errors */ function media_upload_form($errors = null) { global $type, $tab, $is_IE, $is_opera; if (!_device_can_upload()) { echo '<p>' . sprintf(__('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.'), 'https://apps.wordpress.org/') . '</p>'; return; } $upload_action_url = admin_url('async-upload.php'); $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; $_type = isset($type) ? $type : ''; $_tab = isset($tab) ? $tab : ''; $max_upload_size = wp_max_upload_size(); if (!$max_upload_size) { $max_upload_size = 0; } ?> <div id="media-upload-notice"><?php if (isset($errors['upload_notice'])) { echo $errors['upload_notice']; } ?> </div> <div id="media-upload-error"><?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { echo $errors['upload_error']->get_error_message(); } ?> </div> <?php if (is_multisite() && !is_upload_space_available()) { /** * Fires when an upload will exceed the defined upload space quota for a network site. * * @since 3.5.0 */ do_action('upload_ui_over_quota'); return; } /** * Fires just before the legacy (pre-3.5.0) upload interface is loaded. * * @since 2.6.0 */ do_action('pre-upload-ui'); $post_params = array("post_id" => $post_id, "_wpnonce" => wp_create_nonce('media-form'), "type" => $_type, "tab" => $_tab, "short" => "1"); /** * 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,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); // Currently only iOS Safari supports multiple files uploading but has a bug that prevents uploading of videos // when enabled. See #29602. if (wp_is_mobile()) { $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); ?> <script type="text/javascript"> <?php // Verify size is an int. If not return default value. $large_size_h = absint(get_option('large_size_h')); if (!$large_size_h) { $large_size_h = 1024; } $large_size_w = absint(get_option('large_size_w')); if (!$large_size_w) { $large_size_w = 1024; } ?> var resize_height = <?php echo $large_size_h; ?> , resize_width = <?php echo $large_size_w; ?> , wpUploaderInit = <?php echo json_encode($plupload_init); ?> ; </script> <div id="plupload-upload-ui" class="hide-if-no-js"> <?php /** * Fires before the upload interface loads. * * @since 2.6.0 As 'pre-flash-upload-ui' * @since 3.3.0 */ do_action('pre-plupload-upload-ui'); ?> <div id="drag-drop-area"> <div class="drag-drop-inside"> <p class="drag-drop-info"><?php _e('Drop files here'); ?> </p> <p><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?> </p> <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?> " class="button" /></p> </div> </div> <?php /** * Fires after the upload interface loads. * * @since 2.6.0 As 'post-flash-upload-ui' * @since 3.3.0 */ do_action('post-plupload-upload-ui'); ?> </div> <div id="html-upload-ui" class="hide-if-js"> <?php /** * Fires before the upload button in the media upload interface. * * @since 2.6.0 */ do_action('pre-html-upload-ui'); ?> <p id="async-upload-wrap"> <label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?> </label> <input type="file" name="async-upload" id="async-upload" /> <?php submit_button(__('Upload'), 'button', 'html-upload', false); ?> <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?> </a> </p> <div class="clear"></div> <?php /** * Fires after the upload button in the media upload interface. * * @since 2.6.0 */ do_action('post-html-upload-ui'); ?> </div> <p class="max-upload-size"><?php printf(__('Maximum upload file size: %s.'), esc_html(size_format($max_upload_size))); ?> </p> <?php /** * Fires on the post upload UI screen. * * Legacy (pre-3.5.0) media workflow hook. * * @since 2.6.0 */ do_action('post-upload-ui'); }
/** * Prints default plupload arguments. * * @since 3.4.0 */ function wp_plupload_default_settings() { global $wp_scripts; $max_upload_size = wp_max_upload_size(); $defaults = array( 'runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', // key passed to $_FILE. 'multiple_queues' => true, 'max_file_size' => $max_upload_size . 'b', 'url' => admin_url( 'admin-ajax.php', 'relative' ), '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, ); $defaults = apply_filters( 'plupload_default_settings', $defaults ); $params = array( 'action' => 'upload-attachment', ); $params = apply_filters( 'plupload_default_params', $params ); $params['_wpnonce'] = wp_create_nonce( 'media-form' ); $defaults['multipart_params'] = $params; $settings = array( 'defaults' => $defaults, 'browser' => array( 'mobile' => wp_is_mobile(), 'supported' => _device_can_upload(), ), ); $script = 'var _wpPluploadSettings = ' . json_encode( $settings ) . ';'; $data = $wp_scripts->get_data( 'wp-plupload', 'data' ); if ( $data ) $script = "$data\n$script"; $wp_scripts->add_data( 'wp-plupload', 'data', $script ); }