本文整理汇总了PHP中wp_convert_hr_to_bytes函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_convert_hr_to_bytes函数的具体用法?PHP wp_convert_hr_to_bytes怎么用?PHP wp_convert_hr_to_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_convert_hr_to_bytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_upload
function check_upload($errors)
{
$mime = get_allowed_mime_types();
$size_limit = (int) wp_convert_hr_to_bytes(fep_get_option('attachment_size', '4MB'));
$fields = (int) fep_get_option('attachment_no', 4);
for ($i = 0; $i < $fields; $i++) {
$tmp_name = isset($_FILES['fep_upload']['tmp_name'][$i]) ? basename($_FILES['fep_upload']['tmp_name'][$i]) : '';
$file_name = isset($_FILES['fep_upload']['name'][$i]) ? basename($_FILES['fep_upload']['name'][$i]) : '';
//if file is uploaded
if ($tmp_name) {
$attach_type = wp_check_filetype($file_name);
$attach_size = $_FILES['fep_upload']['size'][$i];
//check file size
if ($attach_size > $size_limit) {
$errors->add('AttachmentSize', sprintf(__("Attachment (%s) file is too big", 'fep'), $file_name));
}
//check file type
if (!in_array($attach_type['type'], $mime)) {
$errors->add('AttachmentType', sprintf(__("Invalid attachment file type.Allowed Types are (%s)", 'fep'), implode(',', $mime)));
}
}
// if $filename
}
// endfor
//return $errors;
}
示例2: init_tabs
protected function init_tabs()
{
$this->tabs->add('info', __('System Info', APP_TD));
$this->tabs->add('cron', __('Cron Jobs', APP_TD));
$current_theme = wp_get_theme();
if (is_child_theme()) {
$current_theme = wp_get_theme($current_theme->Template);
}
$this->tab_sections['info']['theme'] = array('title' => __('Theme Info', APP_TD), 'fields' => array(array('title' => __('Theme Name', APP_TD), 'type' => 'text', 'name' => array('system_info', 'theme_name'), 'extra' => array('style' => 'display: none;'), 'desc' => $current_theme->Name), array('title' => __('Theme Version', APP_TD), 'type' => 'text', 'name' => array('system_info', 'theme_version'), 'extra' => array('style' => 'display: none;'), 'desc' => $current_theme->Version)));
$this->tab_sections['info']['wp'] = array('title' => __('WordPress Info', APP_TD), 'fields' => array(array('title' => __('Home URL', APP_TD), 'type' => 'text', 'name' => array('system_info', 'home_url'), 'extra' => array('style' => 'display: none;'), 'desc' => home_url()), array('title' => __('Site URL', APP_TD), 'type' => 'text', 'name' => array('system_info', 'site_url'), 'extra' => array('style' => 'display: none;'), 'desc' => site_url()), array('title' => __('Theme Path', APP_TD), 'type' => 'text', 'name' => array('system_info', 'theme_path'), 'extra' => array('style' => 'display: none;'), 'desc' => get_template_directory_uri()), array('title' => __('WP Version', APP_TD), 'type' => 'text', 'name' => array('system_info', 'wp_version'), 'extra' => array('style' => 'display: none;'), 'desc' => is_multisite() ? get_bloginfo('version') . ' - ' . __('Multisite', APP_TD) : get_bloginfo('version')), array('title' => __('WP Memory Limit', APP_TD), 'type' => 'text', 'name' => array('system_info', 'wp_memory_limit'), 'extra' => array('style' => 'display: none;'), 'desc' => size_format(wp_convert_hr_to_bytes(WP_MEMORY_LIMIT))), array('title' => __('WP Max Upload Size', APP_TD), 'type' => 'text', 'name' => array('system_info', 'wp_max_upload_size'), 'extra' => array('style' => 'display: none;'), 'desc' => size_format(wp_max_upload_size())), array('title' => __('WP Debug Mode', APP_TD), 'type' => 'text', 'name' => array('system_info', 'wp_debug_mode'), 'extra' => array('style' => 'display: none;'), 'desc' => defined('WP_DEBUG') && WP_DEBUG ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('Force SSL Admin', APP_TD), 'type' => 'text', 'name' => array('system_info', 'force_ssl_admin'), 'extra' => array('style' => 'display: none;'), 'desc' => defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('Child Theme', APP_TD), 'type' => 'text', 'name' => array('system_info', 'child_theme'), 'extra' => array('style' => 'display: none;'), 'desc' => is_child_theme() ? __('Yes', APP_TD) : __('No', APP_TD))));
$this->tab_sections['info']['server'] = array('title' => __('Server Info', APP_TD), 'fields' => array(array('title' => __('Server Software', APP_TD), 'type' => 'text', 'name' => array('system_info', 'server_software'), 'extra' => array('style' => 'display: none;'), 'desc' => $_SERVER['SERVER_SOFTWARE']), array('title' => __('PHP Version', APP_TD), 'type' => 'text', 'name' => array('system_info', 'php_version'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('phpversion') ? phpversion() : __('Function phpversion() is not available.', APP_TD)), array('title' => __('MySQL Version', APP_TD), 'type' => 'text', 'name' => array('system_info', 'mysql_version'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('mysql_get_server_info') ? mysql_get_server_info() : __('Function mysql_get_server_info() is not available.', APP_TD)), array('title' => __('PHP Post Max Size', APP_TD), 'type' => 'text', 'name' => array('system_info', 'post_max_size'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('ini_get') ? size_format(wp_convert_hr_to_bytes(ini_get('post_max_size'))) : __('Function ini_get() is not available.', APP_TD)), array('title' => __('PHP Max Input Vars', APP_TD), 'type' => 'text', 'name' => array('system_info', 'max_input_vars'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('ini_get') ? ini_get('max_input_vars') : __('Function ini_get() is not available.', APP_TD)), array('title' => __('PHP Time Limit', APP_TD), 'type' => 'text', 'name' => array('system_info', 'max_execution_time'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('ini_get') ? ini_get('max_execution_time') : __('Function ini_get() is not available.', APP_TD)), array('title' => __('Upload Max Filesize', APP_TD), 'type' => 'text', 'name' => array('system_info', 'upload_max_filesize'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('ini_get') ? size_format(wp_convert_hr_to_bytes(ini_get('upload_max_filesize'))) : __('Function ini_get() is not available.', APP_TD)), array('title' => __('Display Errors', APP_TD), 'type' => 'text', 'name' => array('system_info', 'display_errors'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('ini_get') ? ini_get('display_errors') ? __('Yes', APP_TD) : __('No', APP_TD) : __('Function ini_get() is not available.', APP_TD)), array('title' => __('SUHOSIN Installed', APP_TD), 'type' => 'text', 'name' => array('system_info', 'suhosin'), 'extra' => array('style' => 'display: none;'), 'desc' => extension_loaded('suhosin') ? __('Yes', APP_TD) : __('No', APP_TD))));
$this->tab_sections['info']['image'] = array('title' => __('Image Support', APP_TD), 'fields' => array(array('title' => __('GD Library Installed', APP_TD), 'type' => 'text', 'name' => array('system_info', 'gd_library'), 'extra' => array('style' => 'display: none;'), 'desc' => extension_loaded('gd') && function_exists('gd_info') ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('Image Upload Path', APP_TD), 'type' => 'text', 'name' => array('system_info', 'wp_upload_path'), 'extra' => array('style' => 'display: none;'), 'desc' => ($uploads = wp_upload_dir()) ? $uploads['url'] : '')));
$this->tab_sections['info']['other'] = array('title' => __('Other Checks', APP_TD), 'fields' => array(array('title' => __('JSON Decode', APP_TD), 'type' => 'text', 'name' => array('system_info', 'json_decode'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('json_decode') ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('cURL Enabled', APP_TD), 'type' => 'text', 'name' => array('system_info', 'curl'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('curl_init') ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('fsockopen Enabled', APP_TD), 'type' => 'text', 'name' => array('system_info', 'fsockopen'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('fsockopen') ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('OpenSSL Enabled', APP_TD), 'type' => 'text', 'name' => array('system_info', 'openssl_open'), 'extra' => array('style' => 'display: none;'), 'desc' => function_exists('openssl_open') ? __('Yes', APP_TD) : __('No', APP_TD)), array('title' => __('WP Remote Post', APP_TD), 'type' => 'text', 'name' => array('system_info', 'wp_remote_post'), 'extra' => array('style' => 'display: none;'), 'desc' => $this->test_wp_remote_post() ? __('wp_remote_post() test was successful.', APP_TD) : __('wp_remote_post() test failed.', APP_TD))));
$this->tab_sections['info']['plugins'] = array('title' => __('Plugins', APP_TD), 'fields' => array(array('title' => __('Installed Plugins', APP_TD), 'type' => 'text', 'name' => array('system_info', 'installed_plugins'), 'extra' => array('style' => 'display: none;'), 'desc' => $this->get_installed_plugins())));
$this->tab_sections['cron']['info'] = array('title' => __('Cron Jobs', APP_TD), 'fields' => $this->cronjob_fields(), 'renderer' => array($this, 'render_cronjob_fields'));
}
示例3: cn_upload_size_limit
/**
* Callback for the `upload_size_limit` filter.
*
* Add to set WP core constants in case they do not exist.
*
* @link http://connections-pro.com/support/topic/images-wont-upload-maximum-upload-size/
*
* @access private
* @since 8.2.21
*
* @param int $bytes
*
* @return int An integer byte value.
*/
function cn_upload_size_limit($bytes)
{
if (!defined('KB_IN_BYTES')) {
define('KB_IN_BYTES', 1024);
}
if (!defined('MB_IN_BYTES')) {
define('MB_IN_BYTES', 1024 * KB_IN_BYTES);
}
if (!defined('GB_IN_BYTES')) {
define('GB_IN_BYTES', 1024 * MB_IN_BYTES);
}
if (!defined('TB_IN_BYTES')) {
define('TB_IN_BYTES', 1024 * GB_IN_BYTES);
}
$u_bytes = wp_convert_hr_to_bytes(ini_get('upload_max_filesize'));
$p_bytes = wp_convert_hr_to_bytes(ini_get('post_max_size'));
return 0 < $bytes ? $bytes : min($u_bytes, $p_bytes);
}
示例4: wp_max_upload_size
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function wp_max_upload_size()
{
$u_bytes = wp_convert_hr_to_bytes(ini_get('upload_max_filesize'));
$p_bytes = wp_convert_hr_to_bytes(ini_get('post_max_size'));
$bytes = apply_filters('upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes);
return $bytes;
}
示例5: get_max_upload_size
/**
* Returns max upload size in bytes, defaults to 25M if no limits set.
*
* @return int
*/
public function get_max_upload_size()
{
$bytes = wp_max_upload_size();
if (1 > (int) $bytes) {
$p_bytes = wp_convert_hr_to_bytes(ini_get('post_max_size'));
$u_bytes = wp_convert_hr_to_bytes(ini_get('upload_max_filesize'));
// If HHVM bug not returning either value, try its own settings.
// If HHVM not involved, will drop through to default value.
if (empty($p_bytes) && empty($u_bytes)) {
$p_bytes = wp_convert_hr_to_bytes(ini_get('hhvm.server.max_post_size'));
$u_bytes = wp_convert_hr_to_bytes(ini_get('hhvm.server.upload.upload_max_file_size'));
$bytes = min($p_bytes, $u_bytes);
if (0 < (int) $bytes) {
return $bytes;
}
}
if (0 < (int) $p_bytes) {
$bytes = $p_bytes;
} elseif (0 < (int) $u_bytes) {
$bytes = $u_bytes;
} else {
$bytes = wp_convert_hr_to_bytes('25M');
}
}
return $bytes;
}
示例6: ob_clean
ob_clean();
ob_end_clean();
$dashboard_required_array['rs-version-information'] = array('order' => 20, 'content' => $dbc);
ob_start();
?>
<!-- Requirements & Recommendations -->
<div class="rs-dash-widget">
<?php
$dir = wp_upload_dir();
$mem_limit = ini_get('memory_limit');
$mem_limit_byte = wp_convert_hr_to_bytes($mem_limit);
$upload_max_filesize = ini_get('upload_max_filesize');
$upload_max_filesize_byte = wp_convert_hr_to_bytes($upload_max_filesize);
$post_max_size = ini_get('post_max_size');
$post_max_size_byte = wp_convert_hr_to_bytes($post_max_size);
$writeable_boolean = wp_is_writable($dir['basedir'] . '/');
$can_connect = get_option('revslider-connection', false);
$mem_limit_byte_boolean = $mem_limit_byte < 268435456;
$upload_max_filesize_byte_boolean = $upload_max_filesize_byte < 33554432;
$post_max_size_byte_boolean = $post_max_size_byte < 33554432;
$dash_rr_status = $writeable_boolean == true && $can_connect == true && $mem_limit_byte_boolean == false && $upload_max_filesize_byte_boolean == false && $post_max_size_byte_boolean == false ? "rs-status-green-wrap" : "rs-status-red-wrap";
?>
<div class="rs-dash-title-wrap <?php
echo $dash_rr_status;
?>
">
<div class="rs-dash-title"><?php
_e("System Requirements", 'revslider');
?>
示例7: wp_import_upload_form
function wp_import_upload_form($action)
{
$u_bytes = wp_convert_hr_to_bytes(ini_get('upload_max_filesize'));
$p_bytes = wp_convert_hr_to_bytes(ini_get('post_max_size'));
$bytes = apply_filters('import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes);
$size = wp_convert_bytes_to_hr($bytes);
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php
echo attribute_escape($action);
?>
">
<p>
<?php
wp_nonce_field('import-upload');
?>
<label for="upload"><?php
_e('Choose a file from your computer:');
?>
</label> (<?php
printf(__('Maximum size: %s'), $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;
?>
" />
</p>
<p class="submit">
<input type="submit" value="<?php
_e('Upload file and import »');
?>
" />
</p>
</form>
<?php
}
示例8: hmbkp_get_max_attachment_size
/**
* Get the max email attachment filesize
*
* Can be overridden by defining HMBKP_ATTACHMENT_MAX_FILESIZE
*
* return int the filesize
*/
function hmbkp_get_max_attachment_size()
{
$max_size = '10mb';
if (defined('HMBKP_ATTACHMENT_MAX_FILESIZE') && wp_convert_hr_to_bytes(HMBKP_ATTACHMENT_MAX_FILESIZE)) {
$max_size = HMBKP_ATTACHMENT_MAX_FILESIZE;
}
return wp_convert_hr_to_bytes($max_size);
}
示例9: wp_initial_constants
/**
* Defines initial WordPress constants
*
* @see wp_debug_mode()
*
* @since 3.0.0
*
* @global int $blog_id
*/
function wp_initial_constants()
{
global $blog_id;
/**#@+
* Constants for expressing human-readable data sizes in their respective number of bytes.
*
* @since 4.4.0
*/
define('KB_IN_BYTES', 1024);
define('MB_IN_BYTES', 1024 * KB_IN_BYTES);
define('GB_IN_BYTES', 1024 * MB_IN_BYTES);
define('TB_IN_BYTES', 1024 * GB_IN_BYTES);
/**#@-*/
$current_limit = @ini_get('memory_limit');
$current_limit_int = wp_convert_hr_to_bytes($current_limit);
// Define memory limits.
if (!defined('WP_MEMORY_LIMIT')) {
if (false === wp_is_ini_value_changeable('memory_limit')) {
define('WP_MEMORY_LIMIT', $current_limit);
} elseif (is_multisite()) {
define('WP_MEMORY_LIMIT', '64M');
} else {
define('WP_MEMORY_LIMIT', '40M');
}
}
if (!defined('WP_MAX_MEMORY_LIMIT')) {
if (false === wp_is_ini_value_changeable('memory_limit')) {
define('WP_MAX_MEMORY_LIMIT', $current_limit);
} elseif (-1 === $current_limit_int || $current_limit_int > 268435456) {
define('WP_MAX_MEMORY_LIMIT', $current_limit);
} else {
define('WP_MAX_MEMORY_LIMIT', '256M');
}
}
// Set memory limits.
$wp_limit_int = wp_convert_hr_to_bytes(WP_MEMORY_LIMIT);
if (-1 !== $current_limit_int && (-1 === $wp_limit_int || $wp_limit_int > $current_limit_int)) {
@ini_set('memory_limit', WP_MEMORY_LIMIT);
}
if (!isset($blog_id)) {
$blog_id = 1;
}
if (!defined('WP_CONTENT_DIR')) {
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
}
// no trailing slash, full paths only - WP_CONTENT_URL is defined further down
// Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
if (!defined('WP_DEBUG')) {
define('WP_DEBUG', false);
}
// Add define('WP_DEBUG_DISPLAY', null); to wp-config.php use the globally configured setting for
// display_errors and not force errors to be displayed. Use false to force display_errors off.
if (!defined('WP_DEBUG_DISPLAY')) {
define('WP_DEBUG_DISPLAY', true);
}
// Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log.
if (!defined('WP_DEBUG_LOG')) {
define('WP_DEBUG_LOG', false);
}
if (!defined('WP_CACHE')) {
define('WP_CACHE', false);
}
// Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified,
// non-concatenated scripts and stylesheets.
if (!defined('SCRIPT_DEBUG')) {
if (!empty($GLOBALS['wp_version'])) {
$develop_src = false !== strpos($GLOBALS['wp_version'], '-src');
} else {
$develop_src = false;
}
define('SCRIPT_DEBUG', $develop_src);
}
/**
* Private
*/
if (!defined('MEDIA_TRASH')) {
define('MEDIA_TRASH', false);
}
if (!defined('SHORTINIT')) {
define('SHORTINIT', false);
}
// Constants for features added to WP that should short-circuit their plugin implementations
define('WP_FEATURE_BETTER_PASSWORDS', true);
/**#@+
* Constants for expressing human-readable intervals
* in their respective number of seconds.
*
* Please note that these values are approximate and are provided for convenience.
* For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
* YEAR_IN_SECONDS does not take leap years into account.
*
//.........这里部分代码省略.........
示例10: _ex
<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>
</div>
<?php
$slimit = get_option('__wpdm_max_upload_size', 0);
if ($slimit > 0) {
$slimit = wp_convert_hr_to_bytes($slimit . 'M');
} else {
$slimit = wp_max_upload_size();
}
$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' => $slimit . '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'), 'extensions' => get_option('__wpdm_allowed_file_types', '*'))), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array('_ajax_nonce' => wp_create_nonce('frontend-file-upload'), 'action' => 'wpdm_frontend_file_upload'));
// we should probably not apply this filter, plugins may expect wp's media uploader...
$plupload_init = apply_filters('plupload_init', $plupload_init);
?>
<script type="text/javascript">
jQuery(document).ready(function($){
// create the uploader and pass the config from above
var uploader = new plupload.Uploader(<?php
echo json_encode($plupload_init);
示例11: getEnvironmentRows
/**
* Return environment data
* @return array
*/
protected function getEnvironmentRows()
{
if (!isset($this->environment)) {
global $wpdb, $wp_version;
$items['home_url'] = array('status' => 'ok', 'label' => __('Home URL', 'optimizepress'), 'message' => home_url());
$items['site_url'] = array('status' => 'ok', 'label' => __('Site URL', 'optimizepress'), 'message' => site_url());
if (version_compare($wp_version, '3.5', '<')) {
$items['wp_version'] = array('status' => 'warning', 'label' => __('WP Version', 'optimizepress'), 'message' => sprintf(__('Your WordPress version (%s) is lower than recommended (%s).', 'optimizepress'), $wp_version, '3.5'));
} else {
$items['wp_version'] = array('status' => 'ok', 'label' => __('WP Version', 'optimizepress'), 'message' => $wp_version);
}
$items['wp_multisite'] = array('status' => 'ok', 'label' => __('WP Multisite Enabled', 'optimizepress'), 'message' => is_multisite() ? __('Yes', 'optimizepress') : __('No', 'optimizepress'));
// Server settings
$items['web_server'] = array('status' => 'ok', 'label' => __('Web Server', 'optimizepress'), 'message' => esc_html($_SERVER['SERVER_SOFTWARE']));
if (version_compare(PHP_VERSION, '5.3', '<')) {
$items['php_version'] = array('label' => __('PHP Version', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your PHP version (%s) is lower than recommended (%s).', 'optimizepress'), PHP_VERSION, '5.3'));
} else {
$items['php_version'] = array('label' => __('PHP Version', 'optimizepress'), 'status' => 'ok', 'message' => PHP_VERSION);
}
if (version_compare($wpdb->db_version(), '5.0', '<')) {
$items['mysql_version'] = array('label' => __('MySQL Version', 'optimizepress'), 'status' => 'error', 'message' => sprintf(__('Your MySQL version (%s) is lower than required (%s).', 'optimizepress'), $wpdb->db_version(), '5.0'));
} else {
$items['mysql_version'] = array('label' => __('MySQL Version', 'optimizepress'), 'status' => 'ok', 'message' => $wpdb->db_version());
}
$items['suhosin_installed'] = array('label' => __('Suhosin Installed', 'optimizepress'), 'status' => 'ok', 'message' => extension_loaded('suhosin') ? __('Yes', 'optimizepress') : __('No', 'optimizepress'));
$inputVars = ini_get('max_input_vars');
if ($inputVars < 3000) {
$items['input_vars'] = array('label' => __('Max Input Vars', 'optimizepress'), 'status' => 'info', 'message' => sprintf(__('Your "max_input_vars" setting is set to %s. If you plan to have pages with a large number of elements on it, you should raise this setting to at least %s.', 'optimizepress'), $inputVars ?: 1000, 3000));
} else {
$items['input_vars'] = array('label' => __('Max Input Vars', 'optimizepress'), 'status' => 'ok', 'message' => $inputVars);
}
$executionTime = ini_get('max_execution_time');
if ($executionTime < 60) {
$items['execution_time'] = array('label' => __('Max Execution Time', 'optimizepress'), 'status' => 'info', 'message' => sprintf(__('Your "max_execution_time" setting (%s) is lower than recommended (%s).', 'optimizepress'), $executionTime ?: 30, 60));
} else {
$items['execution_time'] = array('label' => __('Max. Execution Time', 'optimizepress'), 'status' => 'ok', 'message' => $executionTime);
}
// $postMaxSize = wp_convert_hr_to_bytes(ini_get('post_max_size')) / 1024 / 1024;
// if ($postMaxSize < 32) {
// $items['post_size'] = array(
// 'label' => __('PHP POST Max Size', 'optimizepress'),
// 'status' => 'ok',
// 'message' => sprintf(__('Your PHP POST max size (%sMB) is lower than recommended (%sMB).', 'optimizepress'), $postMaxSize, 32),
// );
// } else {
// $items['post_size'] = array(
// 'label' => __('PHP POST Max Size', 'optimizepress'),
// 'status' => 'ok',
// 'message' => $postMaxSize . 'MB',
// );
// }
$memoryLimit = wp_convert_hr_to_bytes(ini_get('memory_limit')) / 1024 / 1024;
if ($memoryLimit < 64) {
$items['memory'] = array('label' => __('PHP Memory Limit', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your PHP memory limit (%sMB) is lower than recommended (%sMB)', 'optimizepress'), $memoryLimit, 64));
} else {
$items['memory'] = array('label' => __('PHP Memory Limit', 'optimizepress'), 'status' => 'ok', 'message' => $memoryLimit . 'MB');
}
// WordPress settings
$wpMemoryLimit = wp_convert_hr_to_bytes(WP_MEMORY_LIMIT) / 1024 / 1024;
if ($wpMemoryLimit < 64) {
$items['wp_memory'] = array('label' => __('WP Memory Limit', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your WP memory limit (%sMB) is lower than recommended (%sMB)', 'optimizepress'), $wpMemoryLimit, 64));
} else {
$items['wp_memory'] = array('label' => __('WP Memory Limit', 'optimizepress'), 'status' => 'ok', 'message' => $wpMemoryLimit . 'MB');
}
$uploadLimit = wp_max_upload_size() / 1024 / 1024;
if ($uploadLimit < 32) {
$items['upload_limit'] = array('label' => __('WP Max Upload Size', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your WP upload limit (%sMB) is lower than recommended (%sMB).', 'optimizepress'), $uploadLimit, 32));
} else {
$items['upload_limit'] = array('label' => __('WP Max Upload Size', 'optimizepress'), 'status' => 'ok', 'message' => $uploadLimit . 'MB');
}
// Transfer protocols (curl, streams)
$availableProtocols = $disabledProtocols = array();
foreach (array('exthttp' => 'PHP HTTP Extension', 'curl' => 'cURL', 'streams' => 'PHP Streams', 'fopen' => 'PHP fopen()', 'fsockopen' => 'PHP fsockopen()') as $transport => $label) {
$class = "WP_Http_{$transport}";
if (!class_exists($class)) {
continue;
}
$class = new $class();
$useable = $class->test();
if ($useable) {
$availableProtocols[] = $label;
} else {
$disabledProtocols[] = $label;
}
}
if (count($availableProtocols) === 0) {
$availableProtocols[] = 'none';
}
if (count($disabledProtocols) === 0) {
$disabledProtocols[] = 'none';
}
$items['transfer'] = array('label' => __('WP Transport Protocols', 'optimizepress'), 'status' => 'info', 'message' => sprintf(__('Available transport protocols: %s.<br /> Disabled transfer protocols: %s.', 'optimizepress'), implode(', ', $availableProtocols), implode(', ', $disabledProtocols)));
if ('' === ($permalinkStructure = get_option('permalink_structure', ''))) {
$items['permalink'] = array('label' => __('Permalink Structure', 'optimizepress'), 'status' => 'error', 'message' => sprintf(__('Permalink structure must not be set to "default" for OptimizePress to work correctly. Please change the <a href="%s">setting</a>.', 'optimizepress'), admin_url('options-permalink.php')));
} else {
$items['permalink'] = array('label' => __('Permalink Structure', 'optimizepress'), 'status' => 'ok', 'message' => __('Permalink structure is in order.', 'optimizepress'));
//.........这里部分代码省略.........
示例12: wp_convert_hr_to_bytes
<div class="znfb-col-6">
<h3 class="zn-lead-title" >Kallyas is now installed and almost ready to be used!</h3>
<div class="zn-lead-text ">
<p class="zn-lead-text--larger">This basic quick setup wizard will just configure a few basic settings to get started. <br>It's completely optional and shouldn't take longer than five minutes.</p>
</div>
</div>
<div class="znfb-col-6">
<h3>Server status:</h3>
<div class="zn-server-status-wrapper">
<div class="zn-server-status-row">
<?php
$message = '';
$icon = 'dashicons-yes';
$color_class = 'zn-system-status-ok';
$memory = wp_convert_hr_to_bytes(ini_get('memory_limit'));
if ($memory < 64000000) {
$icon = 'dashicons-warning';
$color_class = 'zn-system-status-notok';
$message = ' - We recommend setting memory to at least <strong>64MB</strong>. <br /> To import the main demo sample data, <strong>256MB</strong> of memory limit is required. <br /> Please define memory limit in <strong>wp-config.php</strong> file. To learn how, see: <a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">Increasing memory allocated to PHP.</a>';
}
?>
<div class="zn-server-status-column zn-server-status-column-name">WP memory limit</div>
<div class="zn-server-status-column"><span class="zn-server-status-column-icon dashicons-before <?php
echo $icon;
?>
" title="The maximum amount of memory (RAM) that your site can use at one time."></span></div>
<div class="zn-server-status-column zn-server-status-column-value <?php
echo $color_class;
?>
示例13: wp_convert_hr_to_bytes
<div style="display: none" id="doifdEditUploadForm">
<form id="doifd_admin_edit_download_form" method="post" action="" enctype="multipart/form-data" style="width: 40%;">
<fieldset>
<input type="hidden" name="doifd_download_id" id="doifd_download_id" value="" />
<input type="hidden" name="doifd_download_name" id="doifd_download_name" value="" />
<input type="hidden" name="doifd_download_file_name" id="doifd_download_file_name" value="" />
<input type="hidden" name="max_upload_size" id="max_upload_size" value="<?php
$max_size = wp_convert_hr_to_bytes(ini_get('upload_max_filesize'));
echo $max_size;
?>
"/>
<input type="hidden" name="_wpnonce" id="_wpnonce" value="<?php
$doifd_lab_edit_download_form_nonce = wp_create_nonce('doifd-edit-download-nonce');
echo $doifd_lab_edit_download_form_nonce;
?>
"/>
<input type="hidden" name="type" id="type" value="0" >
<?php
// $call = new DoifdAdminFilters();
// $output = $call->doifd_additional_admin_fields ();
// echo $output;
?>
<div>
<label id="doifd_labelName" for="name"><?php
_e('Download Name', $this->plugin_slug);
?>
示例14: my_upload_size_limit
function my_upload_size_limit($limit)
{
return wp_convert_hr_to_bytes('1000M');
}
示例15: wp_max_upload_size
/**
* Determines the maximum upload size allowed in php.ini.
*
* @since 2.5.0
*
* @return int Allowed upload size.
*/
function wp_max_upload_size()
{
$u_bytes = wp_convert_hr_to_bytes(ini_get('upload_max_filesize'));
$p_bytes = wp_convert_hr_to_bytes(ini_get('post_max_size'));
/**
* Filter the maximum upload size allowed in php.ini.
*
* @since 2.5.0
*
* @param int $size Max upload size limit in bytes.
* @param int $u_bytes Maximum upload filesize in bytes.
* @param int $p_bytes Maximum size of POST data in bytes.
*/
return apply_filters('upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes);
}