当前位置: 首页>>代码示例>>PHP>>正文


PHP size_format函数代码示例

本文整理汇总了PHP中size_format函数的典型用法代码示例。如果您正苦于以下问题:PHP size_format函数的具体用法?PHP size_format怎么用?PHP size_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了size_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: job_run

 public function job_run(BackWPup_Job $job_object)
 {
     global $wpdb;
     $job_object->substeps_todo = 1;
     $job_object->log(sprintf(__('%d. Trying to generate a file with installed widget names …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
     //build filename
     if (empty($job_object->temp['widgetlistfile'])) {
         $job_object->temp['widgetlistfile'] = $job_object->generate_filename($job_object->job['widgetlistfile'], 'sql') . $job_object->job['widgetlistfilecompression'];
     }
     $handle = fopen($job_object->temp['widgetlistfile'], 'w');
     if ($handle) {
         $query = "SELECT * FROM {$wpdb->options} WHERE option_name LIKE 'widget_%'";
         $rows = $wpdb->get_results($query);
         $header = '';
         foreach ($rows as $row) {
             $header .= "INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES" . "('" . esc_sql($row->option_name) . "', '" . esc_sql($row->option_value) . "', '" . esc_sql($row->autoload) . "')" . "ON DUPLICATE KEY UPDATE option_value = '" . esc_sql($row->option_value) . "';\n";
         }
         $query = "SELECT * FROM {$wpdb->options} WHERE option_name = 'sidebars_widgets'";
         $rows = $wpdb->get_results($query);
         foreach ($rows as $row) {
             $header .= "INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES" . "('" . esc_sql($row->option_name) . "', '" . esc_sql($row->option_value) . "', '" . esc_sql($row->autoload) . "')" . "ON DUPLICATE KEY UPDATE option_value = '" . esc_sql($row->option_value) . "';\n";
         }
         fwrite($handle, $header);
         fclose($handle);
     } else {
         $job_object->log(__('Can not open target file for writing.', 'backwpup'), E_USER_ERROR);
         return FALSE;
     }
     if ($job_object->temp['widgetlistfile']) {
         $job_object->additional_files_to_backup[] = $job_object->temp['widgetlistfile'];
         $job_object->log(sprintf(__('Added widget list file "%1$s" with %2$s to backup file list.', 'backwpup'), $job_object->temp['widgetlistfile'], size_format($job_object->temp['widgetlistfile']), 2));
     }
     $job_object->substeps_done = 1;
     return TRUE;
 }
开发者ID:rufas-hajdu,项目名称:backwpup-widget,代码行数:35,代码来源:class-jobtype-wpwidget.php

示例2: log

 function log($text, $level = self::ERROR)
 {
     if ($this->level < $level) {
         return;
     }
     $time = date('d-m-Y H:i:s ');
     switch ($level) {
         case self::FATAL:
             $time .= '- FATAL';
             break;
         case self::ERROR:
             $time .= '- ERROR';
             break;
         case self::INFO:
             $time .= '- INFO ';
             break;
         case self::DEBUG:
             $time .= '- DEBUG';
             break;
     }
     if (is_array($text) || is_object($text)) {
         $text = print_r($text, true);
     }
     // The "logs" dir is created on Newsletter constructor.
     $res = @file_put_contents($this->file, $time . ' - ' . size_format(memory_get_usage(), 1) . ' - ' . $text . "\n", FILE_APPEND | FILE_TEXT);
     if ($res === false) {
         $this->level = self::NONE;
     }
 }
开发者ID:lenguyenitc,项目名称:donations,代码行数:29,代码来源:logger.php

示例3: field

    /**
     * Output the email form field
     *
     * @access  public
     */
    public function field()
    {
        ?>

	<label>

            <?php 
        _e('Email notification', 'hmbkp');
        ?>

            <input type="email" name="<?php 
        echo esc_attr($this->get_field_name('email'));
        ?>
" value="<?php 
        echo esc_attr($this->get_field_value('email'));
        ?>
" />

            <p class="description"><?php 
        printf(__('Receive a notification email when a backup completes, if the backup is small enough (&lt; %s) then it will be attached to the email. Separate multiple email address\'s with a comma.', 'hmbkp'), '<code>' . size_format(hmbkp_get_max_attachment_size()) . '</code>');
        ?>
</p>

        </label>

	<?php 
    }
开发者ID:shahadat014,项目名称:geleyi,代码行数:32,代码来源:class-email.php

示例4: mantra_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 mantra_import_form()
{
    $bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
    $size = size_format($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:', 'mantra');
        ?>
</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 Mantra Theme Options', 'mantra');
        ?>
</h2>    
        <form enctype="multipart/form-data" id="import-upload-form" method="post" action="">
        	<p><?php 
        _e('Hi! This is where you import the  Mantra settings.<i> Please remember that this is still an experimental feature.</i>', 'mantra');
        ?>
</p>
            <p>
                <label for="upload"><strong><?php 
        _e('Just choose a file from your computer:', 'mantra');
        ?>
 </strong><i>(mantra-settings.txt)</i></label> 
		       <input type="file" id="upload" name="import" size="25"  />
				<span style="font-size:10px;">(<?php 
        printf(__('Maximum size: %s', 'mantra'), $size);
        ?>
 )</span>
                <input type="hidden" name="action" value="save" />
                <input type="hidden" name="max_file_size" value="<?php 
        echo $bytes;
        ?>
" />
                <?php 
        wp_nonce_field('mantra-import', 'mantra-import');
        ?>
                <input type="hidden" name="mantra_import_confirmed" value="true" />
            </p>
            <input type="submit" class="button" value="<?php 
        _e('And import!', 'mantra');
        ?>
" />            
        </form>
	</div>
    </div> <!-- end wrap -->
    <?php 
    }
}
开发者ID:JustManG,项目名称:Kursovaya,代码行数:65,代码来源:admin-functions.php

示例5: export

	public function export() {
		// Set progress
		Ai1wm_Status::set( array( 'message' => __( 'Renaming exported file...', AI1WM_PLUGIN_NAME ) ) );

		// Close achive file
		$archive = new Ai1wm_Compressor( $this->storage()->archive() );

		// Append EOF block
		$archive->close( true );

		// Rename archive file
		if ( rename( $this->storage()->archive(), $this->storage()->backup() ) ) {

			// Set progress
			Ai1wm_Status::set(
				array(
					'type'    => 'download',
					'message' => sprintf(
						__(
							'<a href="%s/%s" class="ai1wm-button-green ai1wm-emphasize">' .
							'<span>Download %s</span>' .
							'<em>Size: %s</em>' .
							'</a>',
							AI1WM_PLUGIN_NAME
						),
						AI1WM_BACKUPS_URL,
						basename( $this->storage()->backup() ),
						parse_url( home_url(), PHP_URL_HOST ),
						size_format( filesize( $this->storage()->backup() ) )
					)
				),
				$this->storage()->status() // status.log file
			);
		}
	}
开发者ID:universitytimes,项目名称:site,代码行数:35,代码来源:class-ai1wm-export-file.php

示例6: 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 
        }
    }
开发者ID:jasmun,项目名称:Noco100,代码行数:64,代码来源:Upload.php

示例7: ep4wpe_settings_page_callback

function ep4wpe_settings_page_callback()
{
    global $s;
    $state = ep4wpe\ep_is_activated() ? __('ACTIVE') : __('INACTIVE');
    $title = __('WP Engine Search Settings');
    $statement = sprintf(__('ElasticPress is %s'), $state);
    echo "<div class=\"wrap\"><h2>{$title}</h2><p>{$statement}</p>";
    if (array_key_exists('ep_index', $_GET) && 'true' === $_GET['ep_index']) {
        ep4wpe\ep_index_all();
        sleep(1);
    }
    $stats_map = ep4wpe\ep_stats();
    $index_button_label = 'Index site';
    $content = '';
    if (isset($stats_map)) {
        $index_button_label = 'Re-index site';
        $doc_count = $stats_map['total']['docs']['count'];
        $docs_size = size_format($stats_map['total']['store']['size_in_bytes'], 2);
        $button_url = admin_url('options-general.php?page=ep4wpe-plugin&ep_index=true');
        $content .= "<div>Search index contains {$doc_count} documents, utilizing {$docs_size} of disk space</div>";
    }
    $content .= "<div><a href=\"{$button_url}\" class=\"button secondary-button btn\">{$index_button_label}</a></div>";
    $content .= "<form method=\"post\" action=\"options.php\">";
    echo $content;
    settings_fields($s['settings_group']);
    do_settings_sections($s['settings_menu_slug']);
    submit_button();
    echo "</form></div>";
}
开发者ID:ryanshoover,项目名称:wpe-search,代码行数:29,代码来源:options.php

示例8: __construct

 /**
  * The constuctor
  *
  * @since 2.4.0
  */
 public function __construct()
 {
     // Allowed cover image types & upload size
     $allowed_types = bp_attachments_get_allowed_types('cover_image');
     $max_upload_file_size = bp_attachments_get_max_upload_file_size('cover_image');
     parent::__construct(array('action' => 'bp_cover_image_upload', 'file_input' => 'file', 'original_max_filesize' => $max_upload_file_size, 'base_dir' => bp_attachments_uploads_dir_get('dir'), 'required_wp_files' => array('file', 'image'), 'upload_error_strings' => array(11 => sprintf(__('That image is too big. Please upload one smaller than %s', 'buddypress'), size_format($max_upload_file_size)), 12 => sprintf(_n('Please upload only this file type: %s.', 'Please upload only these file types: %s.', count($allowed_types), 'buddypress'), self::get_cover_image_types($allowed_types)))));
 }
开发者ID:mawilliamson,项目名称:wordpress,代码行数:12,代码来源:class-bp-attachment-cover-image.php

示例9: cherry_video_meta

/**
 * Retrieve formatted video metadata.
 *
 * @author Justin Tadlock <justin@justintadlock.com>
 * @author Cherry Team <support@cherryframework.com>
 * @since  4.0.0
 * @param  int   $post_id  Attachment ID.
 * @param  array $metadata The attachment metadata.
 * @return array           Video metadata.
 */
function cherry_video_meta($post_id, $metadata)
{
    // Get ID3 keys (labels for metadata).
    $id3_keys = wp_get_attachment_id3_keys($post_id);
    $items = array();
    // File size.
    if (!empty($metadata['filesize'])) {
        $items['filesize'] = array(size_format(strip_tags($metadata['filesize']), 2), $id3_keys['filesize']);
    }
    // Mime type.
    if (!empty($metadata['mime_type'])) {
        $items['mime_type'] = array(esc_html($metadata['mime_type']), $id3_keys['mime_type']);
    }
    // Formated length of time the video file runs.
    if (!empty($metadata['length_formatted'])) {
        $items['length_formatted'] = array(esc_html($metadata['length_formatted']), $id3_keys['length_formatted']);
    }
    // Dimensions (width x height in pixels).
    if (!empty($metadata['width']) && !empty($metadata['height'])) {
        // Translators: Media dimensions - 1 is width and 2 is height.
        $items['dimensions'] = array(sprintf(__('%1$s &#215; %2$s', 'cherry'), number_format_i18n(absint($metadata['width'])), number_format_i18n(absint($metadata['height']))), __('Dimensions', 'cherry'));
    }
    /**
     * Filter video metadata.
     *
     * @since 4.0.0
     * @param array $items Metadata.
     */
    return apply_filters('cherry_video_meta', $items);
}
开发者ID:xav335,项目名称:sfnettoyage,代码行数:40,代码来源:template-media.php

示例10: ajax_csv_export

 public function ajax_csv_export()
 {
     $error = '';
     try {
         if (!isset($_REQUEST['state'])) {
             $export = new WPBDP_CSVExporter(array_merge($_REQUEST['settings'], array()));
         } else {
             $export = WPBDP_CSVExporter::from_state(unserialize(base64_decode($_REQUEST['state'])));
             if (isset($_REQUEST['cleanup']) && $_REQUEST['cleanup'] == 1) {
                 $export->cleanup();
             } else {
                 $export->advance();
             }
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
     $state = !$error ? $export->get_state() : null;
     $response = array();
     $response['error'] = $error;
     $response['state'] = $state ? base64_encode(serialize($state)) : null;
     $response['count'] = $state ? count($state['listings']) : 0;
     $response['exported'] = $state ? $state['exported'] : 0;
     $response['filesize'] = $state ? size_format($state['filesize']) : 0;
     $response['isDone'] = $state ? $state['done'] : false;
     $response['fileurl'] = $state ? $state['done'] ? $export->get_file_url() : '' : '';
     $response['filename'] = $state ? $state['done'] ? basename($export->get_file_url()) : '' : '';
     echo json_encode($response);
     die;
 }
开发者ID:Nedick,项目名称:stzagora-website,代码行数:30,代码来源:csv-export.php

示例11: attachments_get_filesize_formatted

/**
 * Returns a formatted filesize
 *
 * @param string $path Path to file on disk
 * @return string $formatted formatted filesize
 * @author Jonathan Christopher
 */
function attachments_get_filesize_formatted($path = NULL)
{
    $formatted = '0 bytes';
    if (file_exists($path)) {
        $formatted = size_format(@filesize($path));
    }
    return $formatted;
}
开发者ID:relsi,项目名称:attachments,代码行数:15,代码来源:get-attachments.php

示例12: hmbkp_get_backup_row

/**
 * Displays a row in the manage backups table
 *
 * @param string                 $file
 * @param HMBKP_Scheduled_Backup $schedule
 */
function hmbkp_get_backup_row($file, HMBKP_Scheduled_Backup $schedule)
{
    $encoded_file = urlencode(base64_encode($file));
    $offset = get_option('gmt_offset') * 3600;
    ?>

	<tr class="hmbkp_manage_backups_row">

		<th scope="row">
			<?php 
    echo esc_html(date_i18n(get_option('date_format') . ' - ' . get_option('time_format'), @filemtime($file) + $offset));
    ?>
		</th>

		<td class="code">
			<?php 
    echo esc_html(size_format(@filesize($file)));
    ?>
		</td>

		<td><?php 
    echo esc_html(hmbkp_human_get_type($file, $schedule));
    ?>
</td>

		<td>

			<?php 
    if (hmbkp_is_path_accessible(hmbkp_path())) {
        ?>

				<a href="<?php 
        echo esc_url(wp_nonce_url(add_query_arg(array('hmbkp_backup_archive' => $encoded_file, 'hmbkp_schedule_id' => $schedule->get_id(), 'action' => 'hmbkp_request_download_backup'), admin_url('admin-post.php')), 'hmbkp_download_backup', 'hmbkp_download_backup_nonce'));
        ?>
" class="download-action"><?php 
        _e('Download', 'hmbkp');
        ?>
</a> |
			<?php 
    }
    ?>

			<a href="<?php 
    echo esc_url(wp_nonce_url(add_query_arg(array('hmbkp_backup_archive' => $encoded_file, 'hmbkp_schedule_id' => $schedule->get_id(), 'action' => 'hmbkp_request_delete_backup'), admin_url('admin-post.php')), 'hmbkp_delete_backup', 'hmbkp_delete_backup_nonce'));
    ?>
" class="delete-action"><?php 
    _e('Delete', 'hmbkp');
    ?>
</a>

		</td>

	</tr>

<?php 
}
开发者ID:leewillis77,项目名称:backupwordpress,代码行数:62,代码来源:interface.php

示例13: check

 public function check()
 {
     $this->actual_limit = $this->ini_to_num(WP_MEMORY_LIMIT);
     $this->value = WP_MEMORY_LIMIT;
     $this->ok = $this->actual_limit >= $this->wanted_limit;
     // add extra info if not ok
     if (!$this->ok) {
         $this->info = sprintf(__('We recommend setting memory to at least %s. See: <a href="%s">Increasing memory allocated to PHP</a>', 'lambda-admin-td'), size_format($this->wanted_limit), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP') . '</span>';
     }
 }
开发者ID:ntngiri,项目名称:Wordpress-dhaba,代码行数:10,代码来源:OxygennaWPMemoryCheck.php

示例14: fastfood_exif_details

/**
 * Return the metadata of an image (if any)
 * 
 * @param	none
 * @return	array	Array containing the metadata, each one is an array of 'label','original','readable'
 */
function fastfood_exif_details()
{
    $m = wp_get_attachment_metadata();
    // convert the shutter speed retrieve from database to fraction
    if ($m['image_meta']['shutter_speed'] && 1 / $m['image_meta']['shutter_speed'] > 1) {
        if (number_format(1 / $m['image_meta']['shutter_speed'], 1) == 1.3 or number_format(1 / $m['image_meta']['shutter_speed'], 1) == 1.5 or number_format(1 / $m['image_meta']['shutter_speed'], 1) == 1.6 or number_format(1 / $m['image_meta']['shutter_speed'], 1) == 2.5) {
            $shutter_speed = "1/" . number_format(1 / $m['image_meta']['shutter_speed'], 1, '.', '');
        } else {
            $shutter_speed = "1/" . number_format(1 / $m['image_meta']['shutter_speed'], 0, '.', '');
        }
    }
    $uploaddir = wp_upload_dir();
    $imagesize = size_format(filesize($uploaddir['basedir'] . '/' . $m['file']));
    // array( LABEL, ORIGINAL_VALUE, READABLE_VALUE )
    if ($imagesize) {
        $image_meta['filesize'] = array('label' => __('File Size', 'fastfood'), 'original' => $imagesize, 'readable' => $imagesize);
    }
    if ($m['width']) {
        $image_meta['width'] = array('label' => __('Width', 'fastfood'), 'original' => $m['width'], 'readable' => $m['width'] . 'px');
    }
    if ($m['height']) {
        $image_meta['height'] = array('label' => __('Height', 'fastfood'), 'original' => $m['height'], 'readable' => $m['height'] . 'px');
    }
    if ($m['image_meta']['created_timestamp']) {
        $image_meta['created_timestamp'] = array('label' => __('Date Taken', 'fastfood'), 'original' => $m['image_meta']['created_timestamp'], 'readable' => date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $m['image_meta']['created_timestamp']));
    }
    if ($m['image_meta']['copyright']) {
        $image_meta['copyright'] = array('label' => __('Copyright', 'fastfood'), 'original' => $m['image_meta']['copyright'], 'readable' => $m['image_meta']['copyright']);
    }
    if ($m['image_meta']['credit']) {
        $image_meta['credit'] = array('label' => __('Credit', 'fastfood'), 'original' => $m['image_meta']['credit'], 'readable' => $m['image_meta']['credit']);
    }
    if ($m['image_meta']['title']) {
        $image_meta['title'] = array('label' => __('Title', 'fastfood'), 'original' => $m['image_meta']['title'], 'readable' => $m['image_meta']['title']);
    }
    if ($m['image_meta']['caption']) {
        $image_meta['caption'] = array('label' => __('Caption', 'fastfood'), 'original' => $m['image_meta']['caption'], 'readable' => $m['image_meta']['caption']);
    }
    if ($m['image_meta']['camera']) {
        $image_meta['camera'] = array('label' => __('Camera', 'fastfood'), 'original' => $m['image_meta']['camera'], 'readable' => $m['image_meta']['camera']);
    }
    if ($m['image_meta']['focal_length']) {
        $image_meta['focal_length'] = array('label' => __('Focal Length', 'fastfood'), 'original' => $m['image_meta']['focal_length'], 'readable' => $m['image_meta']['focal_length'] . 'mm');
    }
    if ($m['image_meta']['aperture']) {
        $image_meta['aperture'] = array('label' => __('Aperture', 'fastfood'), 'original' => $m['image_meta']['aperture'], 'readable' => 'f/' . $m['image_meta']['aperture']);
    }
    if ($m['image_meta']['iso']) {
        $image_meta['iso'] = array('label' => __('ISO', 'fastfood'), 'original' => $m['image_meta']['iso'], 'readable' => $m['image_meta']['iso']);
    }
    if ($m['image_meta']['shutter_speed']) {
        $image_meta['shutter_speed'] = array('label' => __('Shutter Speed', 'fastfood'), 'original' => $m['image_meta']['shutter_speed'], 'readable' => sprintf(__('%s seconds', 'fastfood'), $shutter_speed));
    }
    return apply_filters('fastfood_exif_details', $image_meta);
}
开发者ID:TwoBeers,项目名称:fastfood,代码行数:61,代码来源:formats-functions.php

示例15: AfterExecute

 protected function AfterExecute()
 {
     $this->exec_info['Time'] = microtime(true) - $this->exec_info['_Time'];
     $this->exec_info['Mem'] = memory_get_usage() - $this->exec_info['_Mem'];
     if ($this->exec_info['Time'] < 0.001) {
         $this->exec_info['Time'] = number_format($this->exec_info['Time'] * 1000, 3) . 'ms';
     } else {
         $this->exec_info['Time'] = number_format($this->exec_info['Time'], 3) . 's';
     }
     $this->exec_info['Mem'] = size_format($this->exec_info['Mem']);
     $this->exec_info['Queries'] = get_num_queries();
 }
开发者ID:klebercarvalho,项目名称:demo,代码行数:12,代码来源:Sandbox.php


注:本文中的size_format函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。