Example #1
0
/**
 * Get the human readable backup type in.
 *
 * @access public
 * @param string                 $type
 * @param Scheduled_Backup $schedule (default: null)
 * @return string
 */
function human_get_type($type, Scheduled_Backup $schedule = null)
{
    if (strpos($type, 'complete') !== false) {
        return __('Database and Files', 'backupwordpress');
    }
    if (strpos($type, 'file') !== false) {
        return __('Files', 'backupwordpress');
    }
    if (strpos($type, 'database') !== false) {
        return __('Database', 'backupwordpress');
    }
    if (!is_null($schedule)) {
        return human_get_type($schedule->get_type());
    }
    return __('Legacy', 'backupwordpress');
}
<?php

namespace HM\BackUpWordPress;

$filesize = get_site_size_text($schedule);
// Backup Type
$type = strtolower(human_get_type($schedule->get_type()));
// Backup Time
$day = date_i18n('l', $schedule->get_next_occurrence(false));
// Next Backup
$next_backup = 'title="' . esc_attr(sprintf(__('The next backup will be on %1$s at %2$s %3$s', 'backupwordpress'), date_i18n(get_option('date_format'), $schedule->get_next_occurrence(false)), date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false)), date_i18n('T', $schedule->get_next_occurrence(false)))) . '"';
// Backup status
$status = new Backup_Status($schedule->get_id());
// Backup Re-occurrence
switch ($schedule->get_reoccurrence()) {
    case 'hourly':
        $reoccurrence = date_i18n('i', $schedule->get_next_occurrence(false)) === '00' ? '<span ' . $next_backup . '>' . __('hourly on the hour', 'backupwordpress') . '</span>' : sprintf(__('hourly at %s minutes past the hour', 'backupwordpress'), '<span ' . $next_backup . '>' . intval(date_i18n('i', $schedule->get_next_occurrence(false)))) . '</span>';
        break;
    case 'daily':
        $reoccurrence = sprintf(__('daily at %s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'twicedaily':
        $times[] = date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false));
        $times[] = date_i18n(get_option('time_format'), strtotime('+ 12 hours', $schedule->get_next_occurrence(false)));
        sort($times);
        $reoccurrence = sprintf(__('every 12 hours at %1$s &amp; %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(reset($times)) . '</span>', '<span>' . esc_html(end($times))) . '</span>';
        break;
    case 'weekly':
        $reoccurrence = sprintf(__('weekly on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html($day) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'fortnightly':