本文整理汇总了PHP中wp_max_upload_size函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_max_upload_size函数的具体用法?PHP wp_max_upload_size怎么用?PHP wp_max_upload_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_max_upload_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ac_gallery_get_upload_meta_data
function ac_gallery_get_upload_meta_data()
{
$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' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.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' => __('Allowed Files', 'alleycat'), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array('_ajax_nonce' => wp_create_nonce('photo-upload'), 'action' => 'photo_gallery_upload'));
// Get the data values
$plupload_init = apply_filters('plupload_init', $plupload_init);
return $plupload_init;
}
示例2: __construct
/**
* Construct Upload parameters.
*
* @since 2.3.0
* @since 2.4.0 Add the $upload_dir_filter_args argument to the $arguments array
*
* @param array|string $args {
* @type int $original_max_filesize Maximum file size in kilobytes. Defaults to php.ini settings.
* @type array $allowed_mime_types List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ).
* Defaults to WordPress allowed mime types.
* @type string $base_dir Component's upload base directory. Defaults to WordPress 'uploads'.
* @type string $action The upload action used when uploading a file, $_POST['action'] must be set
* and its value must equal $action {@link wp_handle_upload()} (required).
* @type string $file_input The name attribute used in the file input. (required).
* @type array $upload_error_strings A list of specific error messages (optional).
* @type array $required_wp_files The list of required WordPress core files. Default: array( 'file' ).
* @type int $upload_dir_filter_args 1 to receive the original Upload dir array in the Upload dir filter, 0 otherwise.
* Defaults to 0 (optional).
* }
*/
public function __construct($args = '')
{
// Upload action and the file input name are required parameters.
if (empty($args['action']) || empty($args['file_input'])) {
return false;
}
// Sanitize the action ID and the file input name.
$this->action = sanitize_key($args['action']);
$this->file_input = sanitize_key($args['file_input']);
/**
* Max file size defaults to php ini settings or, in the case of
* a multisite config, the root site fileupload_maxk option
*/
$this->default_args['original_max_filesize'] = (int) wp_max_upload_size();
$params = bp_parse_args($args, $this->default_args, $this->action . '_upload_params');
foreach ($params as $key => $param) {
if ('upload_error_strings' === $key) {
$this->{$key} = $this->set_upload_error_strings($param);
// Sanitize the base dir.
} elseif ('base_dir' === $key) {
$this->{$key} = sanitize_title($param);
// Sanitize the upload dir filter arg to pass.
} elseif ('upload_dir_filter_args' === $key) {
$this->{$key} = (int) $param;
// Action & File input are already set and sanitized.
} elseif ('action' !== $key && 'file_input' !== $key) {
$this->{$key} = $param;
}
}
// Set the path/url and base dir for uploads.
$this->set_upload_dir();
}
示例3: displayForm
/**
* @param $action
* @param null $submitText
*/
public function displayForm($action, $submitText = null)
{
$bytes = wp_max_upload_size();
$size = size_format($bytes);
$upload_dir = IfwPsn_Wp_Proxy_Blog::getUploadDir();
if ($submitText == null) {
$submitText = __('Upload', 'ifw');
}
if (!empty($upload_dir['error'])) {
?>
<div class="error"><p><?php
_e('Before you can upload your import file, you will need to fix the following error:');
?>
</p>
<p><strong><?php
echo $upload_dir['error'];
?>
</strong></p></div><?php
} else {
$allowedExtensions = $this->getMimeTypes() != null ? implode(',', array_unique(array_keys($this->getMimeTypes()))) : null;
$label = sprintf('Choose a file from your computer (Maximum size: %s%s)', $size, $allowedExtensions !== null ? ', ' . __('allowed extensions: ') . $allowedExtensions : '');
?>
<form enctype="multipart/form-data" id="<?php
echo $this->_id;
?>
-upload-form" method="post" class="wp-upload-form" action="<?php
echo esc_url($action);
?>
">
<?php
echo wp_nonce_field($this->_getNonceName());
?>
<p>
<label for="upload-<?php
echo $this->_id;
?>
"><?php
echo $label;
?>
</label>
<input type="file" id="upload-<?php
echo $this->_id;
?>
" name="<?php
echo $this->_id;
?>
" size="25" />
<input type="hidden" name="action" value="upload" />
<input type="hidden" name="max_file_size" value="<?php
echo $bytes;
?>
" />
</p>
<?php
submit_button($submitText, 'button');
?>
</form>
<?php
}
}
示例4: test_sync_callable_whitelist
public function test_sync_callable_whitelist()
{
// $this->setSyncClientDefaults();
$callables = array('wp_max_upload_size' => wp_max_upload_size(), 'is_main_network' => Jetpack::is_multi_network(), 'is_multi_site' => is_multisite(), 'main_network_site' => Jetpack_Sync_Functions::main_network_site_url(), 'single_user_site' => Jetpack::is_single_user_site(), 'updates' => Jetpack::get_updates(), 'home_url' => Jetpack_Sync_Functions::home_url(), 'site_url' => Jetpack_Sync_Functions::site_url(), 'has_file_system_write_access' => Jetpack_Sync_Functions::file_system_write_access(), 'is_version_controlled' => Jetpack_Sync_Functions::is_version_controlled(), 'taxonomies' => Jetpack_Sync_Functions::get_taxonomies(), 'post_types' => Jetpack_Sync_Functions::get_post_types(), 'post_type_features' => Jetpack_Sync_Functions::get_post_type_features(), 'rest_api_allowed_post_types' => Jetpack_Sync_Functions::rest_api_allowed_post_types(), 'rest_api_allowed_public_metadata' => Jetpack_Sync_Functions::rest_api_allowed_public_metadata(), 'sso_is_two_step_required' => Jetpack_SSO_Helpers::is_two_step_required(), 'sso_should_hide_login_form' => Jetpack_SSO_Helpers::should_hide_login_form(), 'sso_match_by_email' => Jetpack_SSO_Helpers::match_by_email(), 'sso_new_user_override' => Jetpack_SSO_Helpers::new_user_override(), 'sso_bypass_default_login_form' => Jetpack_SSO_Helpers::bypass_login_forward_wpcom(), 'wp_version' => Jetpack_Sync_Functions::wp_version(), 'get_plugins' => Jetpack_Sync_Functions::get_plugins(), 'active_modules' => Jetpack::get_active_modules(), 'hosting_provider' => Jetpack_Sync_Functions::get_hosting_provider(), 'locale' => get_locale(), 'site_icon_url' => Jetpack_Sync_Functions::site_icon_url());
if (is_multisite()) {
$callables['network_name'] = Jetpack::network_name();
$callables['network_allow_new_registrations'] = Jetpack::network_allow_new_registrations();
$callables['network_add_new_users'] = Jetpack::network_add_new_users();
$callables['network_site_upload_space'] = Jetpack::network_site_upload_space();
$callables['network_upload_file_types'] = Jetpack::network_upload_file_types();
$callables['network_enable_administration_menus'] = Jetpack::network_enable_administration_menus();
}
$this->sender->do_sync();
foreach ($callables as $name => $value) {
// TODO: figure out why _sometimes_ the 'support' value of
// the post_types value is being removed from the output
if ($name === 'post_types') {
continue;
}
$this->assertCallableIsSynced($name, $value);
}
$whitelist_keys = array_keys($this->callable_module->get_callable_whitelist());
$callables_keys = array_keys($callables);
// Are we testing all the callables in the defaults?
$whitelist_and_callable_keys_difference = array_diff($whitelist_keys, $callables_keys);
$this->assertTrue(empty($whitelist_and_callable_keys_difference), 'Some whitelisted options don\'t have a test: ' . print_r($whitelist_and_callable_keys_difference, 1));
// Are there any duplicate keys?
$unique_whitelist = array_unique($whitelist_keys);
$this->assertEquals(count($unique_whitelist), count($whitelist_keys), 'The duplicate keys are: ' . print_r(array_diff_key($whitelist_keys, array_unique($whitelist_keys)), 1));
}
示例5: respond_to_get_remote_media_info
/**
* Return information about remote site for use in media migration
*
* @return bool|null
*/
public function respond_to_get_remote_media_info()
{
add_filter('wpmdb_before_response', array($this, 'scramble'));
$key_rules = array('action' => 'key', 'remote_state_id' => 'key', 'intent' => 'key', 'sig' => 'string');
$this->set_post_data($key_rules, 'remote_state_id');
$filtered_post = $this->filter_post_elements($this->state_data, array('action', 'remote_state_id', 'intent'));
if (!$this->verify_signature($filtered_post, $this->settings['key'])) {
$return = array('wpmdb_error' => 1, 'body' => $this->invalid_content_verification_error . ' (#100mf)');
$this->log_error($return['body'], $filtered_post);
$result = $this->end_ajax(serialize($return));
return $result;
}
if (defined('UPLOADBLOGSDIR')) {
$upload_url = home_url(UPLOADBLOGSDIR);
} else {
$upload_dir = wp_upload_dir();
$upload_url = $upload_dir['baseurl'];
if (is_multisite()) {
// Remove multisite postfix
$upload_url = preg_replace('/\\/sites\\/(\\d)+$/', '', $upload_url);
}
}
$return['remote_total_attachments'] = $this->get_local_attachments_count();
$return['remote_uploads_url'] = $upload_url;
$return['blogs'] = serialize($this->get_blogs());
$return['remote_max_upload_size'] = wp_max_upload_size();
$result = $this->end_ajax(serialize($return));
return $result;
}
示例6: iced_mocha_import_form
/**
* This file manages the theme settings uploading and import operations.
* Uses the theme page to create a new form for uplaoding the settings
* Uses WP_Filesystem
*/
function iced_mocha_import_form()
{
$bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
$size = wp_convert_bytes_to_hr($bytes);
$upload_dir = wp_upload_dir();
if (!empty($upload_dir['error'])) {
?>
<div class="error"><p><?php
_e('Before you can upload your import file, you will need to fix the following error:', 'iced_mocha');
?>
</p>
<p><strong><?php
echo $upload_dir['error'];
?>
</strong></p></div><?php
} else {
?>
<div class="wrap">
<div style="width:400px;display:block;margin-left:30px;">
<div id="icon-tools" class="icon32"><br></div>
<h2><?php
echo __('Import Iced Mocha Options', 'iced_mocha');
?>
</h2>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="">
<p><?php
_e('Hi! This is where you import the Iced Mocha Theme settings.<i> Please remember that this is still an experimental feature.</i>', 'iced_mocha');
?>
</p>
<p>
<label for="upload"><strong><?php
_e('Just choose a file from your computer:', 'iced_mocha');
?>
</strong><i>(iced_mocha-settings.txt)</i></label>
<input type="file" id="upload" name="import" size="25" />
<span style="font-size:10px;">(<?php
printf(__('Maximum size: %s', 'iced_mocha'), $size);
?>
)</span>
<input type="hidden" name="action" value="save" />
<input type="hidden" name="max_file_size" value="<?php
echo $bytes;
?>
" />
<?php
wp_nonce_field('iced_mocha-import', 'iced_mocha-import');
?>
<input type="hidden" name="iced_mocha_import_confirmed" value="true" />
</p>
<input type="submit" class="button" value="<?php
_e('And import!', 'iced_mocha');
?>
" />
</form>
</div>
</div> <!-- end wrap -->
<?php
}
}
示例7: get_max_upload
function get_max_upload()
{
if (function_exists('wp_max_upload_size')) {
return wp_max_upload_size();
} else {
return ini_get('upload_max_filesize') . 'b';
}
}
示例8: get_maximum_upload_file_size_bytes
/**
* Returns the maximum upload file size in bytes
*
* @param string $size Human readable size
*
* @return int Maximum upload file size
*/
public function get_maximum_upload_file_size_bytes($size)
{
$converter_utility = $this->_registry->get('size.converter');
$maximum_size = $converter_utility->convert_hr_to_bytes($size);
if ($maximum_size <= 0 || $maximum_size > wp_max_upload_size()) {
$maximum_size = wp_max_upload_size();
}
return $maximum_size;
}
示例9: admin_enqueue_scripts
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
// Enqueue same scripts and styles as for file field
parent::admin_enqueue_scripts();
wp_enqueue_style('rwmb-plupload-image', RWMB_CSS_URL . 'plupload-image.css', array('wp-admin'), RWMB_VER);
wp_enqueue_script('rwmb-plupload-image', RWMB_JS_URL . 'plupload-image.js', array('jquery-ui-sortable', 'wp-ajax-response', 'plupload-all'), RWMB_VER, true);
wp_localize_script('rwmb-plupload-image', 'RWMB', array('url' => RWMB_URL));
wp_localize_script('rwmb-plupload-image', 'rwmb_plupload_defaults', array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.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' => _x('Allowed Image Files', 'image upload', 'rwmb'), 'extensions' => 'jpg,jpeg,gif,png')), 'multipart' => true, 'urlstream_upload' => true));
}
示例10: initScripts
public function initScripts($page)
{
if (!$this->enqueueCheck($page)) {
return;
}
wp_enqueue_script('wpforms-plupload-setup', $this->getBaseUrl() . '/assets/js/plupload-setup.min.js', array('jquery', 'plupload-all'), false, true);
wp_enqueue_style('wpforms-plupload', $this->getBaseUrl() . '/assets/css/plupload.css');
self::$params[$this->attributes['id']] = array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => $this->attributes['browse_button'], 'container' => $this->attributes['container'], 'drop_element' => $this->attributes['drop_element'], 'file_data_name' => $this->attributes['file_data_name'], 'preview_thumb_id' => $this->attributes['preview_thumb_id'], 'multiple_queues' => false, 'max_file_size' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.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' => __('Allowed Files', 'wpforms'), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array('_ajax_nonce' => wp_create_nonce($this->attributes['ajax_action']), 'action' => $this->attributes['ajax_action']));
}
示例11: get_plupload_options
function get_plupload_options()
{
$retval = array();
$retval['runtimes'] = 'gears,browserplus,html5,flash,silverlight,html4';
$retval['max_file_size'] = strval(round((int) wp_max_upload_size() / 1024)) . 'kb';
$retval['filters'] = $this->object->get_plupload_filters();
$retval['flash_swf_url'] = includes_url('js/plupload/plupload.flash.swf');
$retval['silverlight_xap_url'] = includes_url('js/plupload/plupload.silverlight.xap');
$retval['debug'] = TRUE;
return $retval;
}
示例12: wp_limit
public function wp_limit()
{
$output = wp_max_upload_size();
$output = round($output);
$output = $output / 1000000;
//convert to megabytes
$output = round($output);
$output = $output * 1000;
// convert to kilobytes
return $output;
}
示例13: inner_custom_box
public function inner_custom_box($post)
{
$gallery = get_post_meta($post->ID, 'wpsimplegallery_gallery', true);
wp_nonce_field(basename(__FILE__), 'wpsimplegallery_gallery_nonce');
$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;
}
$upload_action_url = admin_url('async-upload.php');
$post_params = array("post_id" => $post->ID, "_wpnonce" => wp_create_nonce('media-form'), "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' => 'wpsg-plupload-browse-button', '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', THEMEDOMAIN), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => $post_params);
?>
<script type="text/javascript">
var POST_ID = <?php
echo $post->ID;
?>
;
var WPSGwpUploaderInit = <?php
echo json_encode($plupload_init);
?>
;
</script>
<span class="spinner" id="wpsimplegallyer_spinner"></span>
<div id="wpsimplegallery_container">
<ul id="wpsimplegallery_thumbs" class="clearfix"><?php
$gallery = is_string($gallery) ? @unserialize($gallery) : $gallery;
if (is_array($gallery) && count($gallery) > 0) {
foreach ($gallery as $id) {
echo $this->admin_thumb($id);
}
}
?>
</ul>
</div>
<input id="wpsimplegallery_upload_button" data-uploader_title="Upload Image" data-uploader_button_text="Select" style="margin-bottom:8px" class="primary_button button" type="button" value="<?php
echo __('Upload Image', 'wpsimplegallery');
?>
" rel="" />
<input id="wpsimplegallery_delete_all_button" class="button secondary_button" type="button" style="margin-bottom:8px" value="<?php
echo __('Delete All Images', 'wpsimplegallery');
?>
" rel="" />
<?php
}
示例14: hf_load_custom_script
function hf_load_custom_script()
{
global $post;
global $page;
$show_frontendpost = zl_option('show_frontendpost');
if (is_user_logged_in() && !is_singular() && $show_frontendpost == 1) {
wp_enqueue_script('rw-uploader', get_template_directory_uri() . '/lib/js/pl.uploader.js', array('jquery'), '1.0.0', true);
$plupload_init = array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'plupload-browse-button', 'container' => 'gallery', 'drop_element' => 'rw-drag-drop', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.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' => zl_option('lang_allowedfiles', __('Allowed Files', 'zatolab')), 'extensions' => 'jpg,gif,png')), 'multipart' => true, 'urlstream_upload' => true, 'multi_selection' => false, 'multipart_params' => array('_ajax_nonce' => '', 'action' => 'photo_gallery_upload', 'imgid' => 0));
$plupload_init = apply_filters('rw_uploader_init', $plupload_init);
wp_localize_script('rw-uploader', 'rwUploaderInit', $plupload_init);
}
}
示例15: franz_import_form
/**
* This file manages the theme settings uploading and import operations.
* Uses WP_Filesystem
*/
function franz_import_form()
{
$bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
$size = size_format($bytes, 2);
$upload_dir = wp_upload_dir();
if (!empty($upload_dir['error'])) {
?>
<div class="error"><p><?php
_e('Before you can upload your import file, you will need to fix the following error:', 'franz-josef');
?>
</p>
<p><strong><?php
echo $upload_dir['error'];
?>
</strong></p></div><?php
} else {
?>
<div class="wrap">
<div id="icon-tools" class="icon32"><br></div>
<h2><?php
echo __('Import Franz Josef Options', 'franz-josef');
?>
</h2>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="" onsubmit="return franzCheckFile(this);">
<p>
<label for="upload"><?php
_e('Choose a file from your computer:', 'franz-josef');
?>
</label> (<?php
printf(__('Maximum size: %s', 'franz-josef'), $size);
?>
)
<input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="max_file_size" value="<?php
echo $bytes;
?>
" />
<?php
wp_nonce_field('franz-import', 'franz-import');
?>
<input type="hidden" name="franz_import_confirmed" value="true" />
</p>
<button type="submit" class="button"><i class="fa fa-upload" style="font-size:16px;margin-right:5px;"></i> <?php
_e('Upload file and import', 'franz-josef');
?>
</button>
</form>
</div> <!-- end wrap -->
<?php
}
}