本文整理汇总了PHP中_device_can_upload函数的典型用法代码示例。如果您正苦于以下问题:PHP _device_can_upload函数的具体用法?PHP _device_can_upload怎么用?PHP _device_can_upload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_device_can_upload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pre_render
/**
* 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>";
}
}
示例2: bp_attachments_get_plupload_default_settings
/**
* 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);
}
示例3: wp_print_media_templates
/**
* 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;
}
//.........这里部分代码省略.........
示例4: tab_upload_new
/**
* @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
}
}
示例5: device_can_upload
/**
* 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();
}
示例6: add_default_plupload_settings
/**
* 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);
}
示例7: wp_print_media_templates
/**
* 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;
}
?>
//.........这里部分代码省略.........
示例8: wp_plupload_default_settings
/**
* 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);
}
示例9: media_upload_form
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
//.........这里部分代码省略.........
示例10: wp_print_media_templates
/**
* 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 */
//.........这里部分代码省略.........
示例11: Init
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
//.........这里部分代码省略.........
示例12: Init
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;
?>
//.........这里部分代码省略.........
示例13: display
/**
* 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;
//.........这里部分代码省略.........
示例14: media_upload_form
/**
* {@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');
?>
//.........这里部分代码省略.........
示例15: wp_plupload_default_settings
/**
* 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);
}