public function prepare_items() { if (!is_null($this->total_items)) { return; } $this->total_items = count($this->_archives); $this->set_pagination_args(array('total_items' => $this->total_items, 'per_page' => $this->items_pre_page)); /** * @var FW_Extension_Backups $backups */ $backups = fw_ext('backups'); /** * Prepare items for output */ foreach ($this->_archives as $filename => $archive) { $time = get_date_from_gmt(gmdate('Y-m-d H:i:s', $archive['time']), get_option('date_format') . ' ' . get_option('time_format')); $filename_hash = md5($filename); $details = array(); $details[] = $archive['full'] ? __('Full Backup', 'fw') : __('Content Backup', 'fw'); if (function_exists('fw_human_bytes')) { $details[] = fw_human_bytes(filesize($archive['path'])); } $details[] = fw_html_tag('a', array('href' => $backups->get_download_link($filename), 'target' => '_blank', 'id' => 'download-' . $filename_hash, 'data-download-file' => $filename), esc_html__('Download', 'fw')); $details[] = fw_html_tag('a', array('href' => '#', 'onclick' => 'return false;', 'id' => 'delete-' . $filename_hash, 'data-delete-file' => $filename, 'data-confirm' => __("Warning! \n" . "You are about to delete a backup, it will be lost forever. \n" . "Are you sure?", 'fw')), esc_html__('Delete', 'fw')); $this->items[] = array('cb' => fw_html_tag('input', array('type' => 'radio', 'name' => 'archive', 'value' => $filename, 'id' => 'archive-' . $filename_hash)), 'details' => '<div>' . $time . '</div>' . '<div>' . implode(' | ', $details) . '</div>'); } }
/** * Debug information * <?php add_action('admin_footer', function(){ FW_Cache::stats(); }); * @since 2.4.17 */ public static function stats() { echo '<div style="z-index: 10000; position: relative; background: #fff; padding: 15px;">'; echo '<p>'; echo '<strong>Cache Hits:</strong> ' . self::$hits . '<br />'; echo '<strong>Cache Misses:</strong> ' . self::$misses . '<br />'; echo '<strong>Cache Freed:</strong> ' . self::$freed . '<br />'; echo '<strong>PHP Memory Peak Usage:</strong> ' . fw_human_bytes(memory_get_peak_usage(false)) . '<br />'; echo '</p>'; echo '<ul>'; foreach (self::$cache as $group => $cache) { echo "<li><strong>Group:</strong> {$group} - ( " . number_format(strlen(serialize($cache)) / KB_IN_BYTES, 2) . 'k )</li>'; } echo '</ul>'; echo '</div>'; }