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; }
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; } }
/** * 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 (< %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 }
/** * 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 } }
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 ); } }
/** * @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 } }
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>"; }
/** * 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))))); }
/** * Retrieve formatted video metadata. * * @author Justin Tadlock <*****@*****.**> * @author Cherry Team <*****@*****.**> * @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 × %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); }
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; }
/** * 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; }
/** * 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 }
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>'; } }
/** * 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); }
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(); }
/** * 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 } }
/** * Constructs instance of Document. * * @param WP_Post $attachment Attachment object used to initalize fields. * @param DG_Gallery $gallery Instance of Gallery class. */ public function __construct($attachment, $gallery) { // init general document data $this->gallery = $gallery; $this->description = wptexturize($attachment->post_content); $this->ID = $attachment->ID; $this->link = $gallery->linkToAttachmentPg() ? get_attachment_link($attachment->ID) : wp_get_attachment_url($attachment->ID); $this->title = wptexturize($attachment->post_title); $this->title_attribute = esc_attr(strip_tags($this->title)); $this->path = get_attached_file($attachment->ID); $wp_filetype = wp_check_filetype_and_ext($this->path, basename($this->path)); $this->extension = $wp_filetype['ext']; $this->size = size_format(filesize($this->path)); }
/** * Replace Wildcards * * @since 1.3 */ function dedo_search_replace_wildcards($string, $id) { // id if (strpos($string, '%id%') !== false) { $string = str_replace('%id%', $id, $string); } // url if (strpos($string, '%url%') !== false) { $value = dedo_download_link($id); $string = str_replace('%url%', $value, $string); } // title if (strpos($string, '%title%') !== false) { $value = get_the_title($id); $string = str_replace('%title%', $value, $string); } // date if (strpos($string, '%date%') !== false) { $value = get_the_date(apply_filters('dedo_shortcode_date_format', '')); $string = str_replace('%date%', $value, $string); } // filesize if (strpos($string, '%filesize%') !== false) { $value = size_format(get_post_meta($id, '_dedo_file_size', true), 1); $string = str_replace('%filesize%', $value, $string); } // downloads if (strpos($string, '%count%') !== false) { $value = number_format_i18n(get_post_meta($id, '_dedo_file_count', true)); $string = str_replace('%count%', $value, $string); } // file name if (strpos($string, '%filename%') !== false) { $value = dedo_get_file_name(get_post_meta($id, '_dedo_file_url', true)); $string = str_replace('%filename%', $value, $string); } // file extension if (strpos($string, '%ext%') !== false) { $value = strtoupper(dedo_get_file_ext(get_post_meta($id, '_dedo_file_url', true))); $string = str_replace('%ext%', $value, $string); } // file mime if (strpos($string, '%mime%') !== false) { $value = dedo_get_file_mime(get_post_meta($id, '_dedo_file_url', true)); $string = str_replace('%mime%', $value, $string); } return apply_filters('dedo_search_replace_wildcards', $string, $id); }
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')); }
function column_default($item, $column_name) { $item = apply_filters('simple-backup-output-data', $item); //unset existing filter and pagination $args = wp_parse_args(parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY)); unset($args['filter']); unset($args['paged']); $this_page = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; switch ($column_name) { case "size": return "<span title='" . number_format($item[$column_name], 0, "", ",") . " Bytes' >" . size_format($item[$column_name], 2) . "</span>"; break; default: return $item[$column_name]; } }
public function output() { $data = $this->collector->get_data(); if (empty($data['languages'])) { return; } echo '<div class="qm" id="' . esc_attr($this->collector->id()) . '">'; echo '<table cellspacing="0">'; echo '<thead>'; echo '<tr>'; echo '<th>' . esc_html__('Languages', 'query-monitor') . '</th>'; echo '<th colspan="3">' . esc_html__('Language Setting:', 'query-monitor') . ' ' . esc_html(get_locale()) . '</th>'; echo '</tr>'; echo '<tr>'; echo '<td>' . esc_html__('Text Domain', 'query-monitor') . '</td>'; echo '<td>' . esc_html__('Caller', 'query-monitor') . '</td>'; echo '<td>' . esc_html__('MO File', 'query-monitor') . '</td>'; echo '<td>' . esc_html__('Loaded', 'query-monitor') . '</td>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; foreach ($data['languages'] as $mofile) { echo '<tr>'; echo '<td>' . esc_html($mofile['domain']) . '</td>'; echo '<td class="qm-nowrap">'; echo self::output_filename($mofile['caller']['display'], $mofile['caller']['file'], $mofile['caller']['line']); // WPCS: XSS ok. echo '</td>'; echo '<td>'; echo esc_html(QM_Util::standard_dir($mofile['mofile'], '')); echo '</td>'; if ($mofile['found']) { echo '<td class="qm-nowrap">'; echo esc_html__('Found', 'query-monitor') . '<br />'; echo esc_html(size_format($mofile['found'])); echo '</td>'; } else { echo '<td class="qm-warn">'; echo esc_html__('Not Found', 'query-monitor'); echo '</td>'; } echo '</tr>'; } echo '</tbody>'; echo '</table>'; echo '</div>'; }
/** * display function. */ public function display() { // Get values we're displaying $timer_stop = timer_stop(0); $query_count = get_num_queries(); $memory_usage = round(size_format(memory_get_usage()), 2); $memory_peak_usage = round(size_format(memory_get_peak_usage()), 2); $memory_limit = round(size_format($this->let_to_num(WP_MEMORY_LIMIT)), 2); $load_times = array_filter((array) get_option($this->average_option, array())); $load_times[] = $timer_stop; // Update load times update_option($this->average_option, $load_times); // Get average if (sizeof($load_times) > 0) { $average_load_time = round(array_sum($load_times) / sizeof($load_times), 4); } // Display the info ?> <div id="wp_pls"> <ul> <li><?php printf(__('%s queries in %s seconds.', 'wp-page-load-stats'), $query_count, $timer_stop); ?> </li> <li><?php printf(__('Average load time of %s (%s runs).', 'wp-page-load-stats'), $average_load_time, sizeof($load_times)); ?> </li> <li><?php printf(__('%s out of %s MB (%s) memory used.', 'wp-page-load-stats'), $memory_usage, $memory_limit, round($memory_usage / $memory_limit, 2) * 100 . '%'); ?> </li> <li><?php printf(__('Peak memory usage %s MB.', 'wp-page-load-stats'), $memory_peak_usage); ?> </li> </ul> <div class="actions"> <a onclick="wp_pls_hide()" href="javascript:void(0);">×</a> <a class="reset" href="<?php echo add_query_arg('reset_wp_pls_stats', 1); ?> ">-</a> </div> </div> <?php }
/** * Download Post Type Column Contents * * @since 1.0 */ function dedo_download_column_contents($column_name, $post_id) { // File column if ($column_name == 'file') { $file_url = get_post_meta($post_id, '_dedo_file_url', true); $file_url = dedo_get_file_name($file_url); echo !$file_url ? '<span class="blank">--</span>' : esc_attr($file_url); } // Filesize column if ($column_name == 'filesize') { $file_size = get_post_meta($post_id, '_dedo_file_size', true); $file_size = !$file_size ? 0 : size_format($file_size, 1); echo !$file_size ? '<span class="blank">--</span>' : esc_attr($file_size); } // Shortcode column if ($column_name == 'shortcode') { echo '<code>[ddownload id="' . esc_attr($post_id) . '"]</code>'; } // Count column if ($column_name == 'downloads') { $count = get_post_meta($post_id, '_dedo_file_count', true); $count = !$count ? 0 : number_format_i18n($count); echo esc_attr($count); } // Members only column if ('members_only' == $column_name) { $file = get_post_meta($post_id, '_dedo_file_options', true); if (isset($file['members_only'])) { echo 1 == $file['members_only'] ? '<span class="true" title="' . __('Yes', 'delightful-downloads') . '"></span>' : '<span class="false" title="' . __('No', 'delightful-downloads') . '"></span>'; } else { echo '<span class="blank" title="' . __('Inherit', 'delightful-downloads') . '">--</span>'; } } // Open browser column if ('open_browser' == $column_name) { $file = get_post_meta($post_id, '_dedo_file_options', true); if (isset($file['open_browser'])) { echo 1 == $file['open_browser'] ? '<span class="true" title="' . __('Yes', 'delightful-downloads') . '"></span>' : '<span class="false" title="' . __('No', 'delightful-downloads') . '"></span>'; } else { echo '<span class="blank" title="' . __('Inherit', 'delightful-downloads') . '">--</span>'; } } }
function test_size_format() { $kb = 1024; $mb = $kb*1024; $gb = $mb*1024; $tb = $gb*1024; // test if boundaries are correct $this->assertEquals('1 GB', size_format($gb, 0)); $this->assertEquals('1 MB', size_format($mb, 0)); $this->assertEquals('1 kB', size_format($kb, 0)); // now some values around // add some bytes to make sure the result isn't 1.4999999 $this->assertEquals('1.5 TB', size_format($tb + $tb/2 + $mb, 1)); $this->assertEquals('1,023.999 GB', size_format($tb-$mb-$kb, 3)); // edge $this->assertFalse(size_format(-1)); $this->assertFalse(size_format(0)); $this->assertFalse(size_format('baba')); $this->assertFalse(size_format(array())); }
function ufl_display_attached_items_list($atts, $content = null) { extract(shortcode_atts(array('filetype' => 'pdf', 'showdesc' => 'false', 'order' => 'asc', 'orderby' => 'name', 'showasdates' => 'false', 'dateformat' => 'F j, Y', 'exclude' => '', 'outputtype' => 'list', 'limit' => '-1'), $atts)); global $post; // List of mime types $mime_types = array("pdf" => "application/pdf", "zip" => "application/zip", "docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "doc" => "application/msword", "xls" => "application/vnd.ms-excel", "xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ppt" => "application/vnd.ms-powerpoint", "pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "gif" => "image/gif", "png" => "image/png", "jpeg" => "image/jpg", "jpg" => "image/jpg", "mp3" => "audio/mpeg", "wav" => "audio/x-wav", "mpeg" => "video/mpeg", "mpg" => "video/mpeg", "mpe" => "video/mpeg", "mov" => "video/quicktime", "avi" => "video/x-msvideo"); $args = array('orderby' => $orderby, 'order' => $order, 'post_type' => 'attachment', 'numberposts' => $limit, 'post_status' => null, 'post_parent' => $post->ID, 'exclude' => $exclude); if ($filetype != "all") { $short_mime_types = explode(",", $filetype); foreach ($short_mime_types as $key => $short) { $types[] = $mime_types[$short]; } $mimes = array('post_mime_type' => $types); $args = array_merge($args, $mimes); } $attachments = get_posts($args); if ($attachments) { if ($outputtype == 'list') { // Build UL to return if items were found. $out = '<ul class="attachment-list attachment-list-' . $filetype . '">'; foreach ($attachments as $attachment) { if ($showasdates == 'true' && is_numeric(substr($attachment->post_title, -8))) { $link_text = date($dateformat, strtotime(substr($attachment->post_title, -8))); } $out .= '<li>' . wp_get_attachment_link($attachment->ID, false, false, false, $link_text) . ' <span>(' . strtoupper(array_search(get_post_mime_type($attachment->ID), $mime_types)) . ', ' . size_format(filesize(get_attached_file($attachment->ID))) . ')</span>'; if ($showdesc == 'true') { $out .= '<br><p>' . $attachment->post_content . '</p>'; } $out .= '</li>'; } $out .= '</ul>'; } elseif ($outputtype == 'single' && $limit == '1') { foreach ($attachments as $attachment) { $out = wp_get_attachment_link($attachment->ID, false, false, false, $link_text) . ' <span>(' . strtoupper(array_search(get_post_mime_type($attachment->ID), $mime_types)) . ', ' . size_format(filesize(get_attached_file($attachment->ID))) . ')</span>'; } } } else { // Return blank string if there is nothing attached. $out = ''; } return $out; }
public function get_title(array $args = array(), array $state = array()) { if (empty($state)) { return __('Downloading', 'fw'); } elseif ('download' === $state['type']) { if (!empty($state['filesize']) && $state['position']) { return sprintf(__('Downloading (%s of %s)', 'fw'), size_format($state['position']), size_format($state['filesize'])); } else { return __('Downloading', 'fw'); } } elseif ('unzip' === $state['type']) { if ($state['extracted_files']) { return sprintf(__('Archive Unzip (%d files extracted)', 'fw'), $state['extracted_files']); } else { return __('Download finished. Doing unzip', 'fw'); } } else { return __('Downloading (invalid state)', 'fw'); } }
public static function folder() { // Set folder ID $folderId = null; if ( isset( $_GET['folderId'] ) ) { $folderId = $_GET['folderId']; } // Set Gdrive client $gdrive = new ServMaskGdriveClient( get_option( 'ai1wmge_gdrive_token' ), get_option( 'ai1wmge_gdrive_ssl', true ) ); // List folder $folder = $gdrive->listFolder( null, $folderId ); // Set folder structure $response = array( 'id' => null, 'items' => array() ); // Set folder ID if ( isset( $folder['id'] ) ) { $response['id'] = $folder['id']; } // Set folder items if ( isset( $folder['items'] ) && ( $items = $folder['items'] ) ) { foreach ( $items as $item ) { $response['items'][] = array( 'id' => isset( $item['id'] ) ? $item['id'] : null, 'name' => isset( $item['title'] ) ? $item['title'] : null, 'mime' => isset( $item['mimeType'] ) ? $item['mimeType'] : null, 'size' => isset( $item['fileSize'] ) ? size_format( $item['fileSize'] ) : null, 'bytes' => isset( $item['fileSize'] ) ? $item['fileSize'] : null, 'ext' => isset( $item['fileExtension'] ) ? $item['fileExtension'] : null, ); } } echo json_encode( $response ); exit; }
/** * Output the email form field * * @access public */ public function field() { ?> <tr> <th scope="row"> <label for="<?php echo esc_attr($this->get_field_name('email')); ?> "><?php _e('Email notification', 'backupwordpress'); ?> </label> </th> <td> <input type="text" id="<?php echo esc_attr($this->get_field_name('email')); ?> " name="<?php echo esc_attr($this->get_field_name('email')); ?> " value="<?php echo esc_attr($this->get_field_value('email')); ?> " placeholder="*****@*****.**" /> <p class="description"><?php printf(__('Receive a notification email when a backup completes. If the backup is small enough (< %s), then it will be attached to the email. Separate multiple email addresses with a comma.', 'backupwordpress'), '<code>' . size_format(hmbkp_get_max_attachment_size()) . '</code>'); ?> </p> </td> </tr> <?php }
public function __construct() { global $pagenow, $EO_Errors; if (!isset($EO_Errors)) { $EO_Errors = new WP_Error(); } if (is_feed('eo-events') && eventorganiser_get_option('feed')) { $this->get_export_file(); } //If importing / exporting events make sure we a logged in and check nonces. if (is_admin() && !empty($_POST['eventorganiser_download_events']) && check_admin_referer('eventorganiser_download_events') && current_user_can('manage_options')) { //Exporting events //mmm... maybe finally a legitimate use of query_posts query_posts(array('post_type' => 'event', 'showpastevents' => true, 'group_events_by' => 'series', 'posts_per_page' => -1)); $this->get_export_file(); } elseif (is_admin() && !empty($_POST['eventorganiser_import_events']) && check_admin_referer('eventorganiser_import_events') && current_user_can('manage_options')) { //Importing events //Perform checks on file: if (in_array($_FILES["ics"]["type"], array("text/calendar", "application/octet-stream")) && $_FILES["ics"]["size"] < 2097152) { if ($_FILES["ics"]["error"] > 0) { $EO_Errors = new WP_Error('eo_error', sprintf(__("File Error encountered: %d", 'eventorganiser'), $_FILES["ics"]["error"])); } else { //Import file $this->import_file($_FILES['ics']['tmp_name']); } } elseif (!isset($_FILES) || empty($_FILES['ics']['name'])) { $EO_Errors = new WP_Error('eo_error', __("No file detected.", 'eventorganiser')); } else { $EO_Errors = new WP_Error('eo_error', __("Invalid file uploaded. The file must be a ics calendar file of type 'text/calendar', no larger than 2MB.", 'eventorganiser')); $size = size_format($_FILES["ics"]["size"], 2); $details = sprintf(__('File size: %s. File type: %s', 'eventorganiser'), $size, $_FILES["ics"]["type"]); $EO_Errors->add('eo_error', $details); } } add_action('eventorganiser_event_settings_imexport', array($this, 'get_im_export_markup')); }
public static function handle_upload($name = 'file', $action = 'bp_upload_profile_cover') { //include core files require_once ABSPATH . '/wp-admin/includes/file.php'; $max_upload_size = self::get_max_upload_size(); $max_upload_size = $max_upload_size * 1024; //convert kb to bytes $file = $_FILES; //I am not changing the domain of error messages as these are same as bp, so you should have a translation for this $uploadErrors = array(0 => __('There is no error, the file uploaded with success', 'buddypress'), 1 => __('Your image was bigger than the maximum allowed file size of: ', 'buddypress') . size_format($max_upload_size), 2 => __('Your image was bigger than the maximum allowed file size of: ', 'buddypress') . size_format($max_upload_size), 3 => __('The uploaded file was only partially uploaded', 'buddypress'), 4 => __('No file was uploaded', 'buddypress'), 6 => __('Missing a temporary folder', 'buddypress')); if (isset($file['error']) && $file['error']) { bp_core_add_message(sprintf(__('Your upload failed, please try again. Error was: %s', 'buddypress'), $uploadErrors[$file[$name]['error']]), 'error'); return false; } if (!($file[$name]['size'] < $max_upload_size)) { bp_core_add_message(sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format($max_upload_size)), 'error'); return false; } if (!empty($file[$name]['type']) && !preg_match('/(jpe?g|gif|png)$/i', $file[$name]['type']) || !preg_match('/(jpe?g|gif|png)$/i', $file[$name]['name'])) { bp_core_add_message(__('Please upload only JPG, GIF or PNG photos.', 'buddypress'), 'error'); return false; } return wp_handle_upload($file[$name], array('action' => $action, 'test_form' => FALSE)); }