labels->singular_name : ucfirst( $type );
};
$monthwrap_name = function ( $event ) {
$name = (string) ( $event['name'] ?? '' );
if ( 'core_updated' === $event['type'] ) {
return __( 'WordPress', 'monthwrap' );
}
if ( in_array( $event['type'], array( 'theme_updated', 'theme_installed', 'theme_removed' ), true ) ) {
/* translators: %s: theme name. */
return sprintf( __( '%s theme', 'monthwrap' ), $name );
}
if ( 'server_updated' === $event['type'] ) {
/* translators: %s: server software, e.g. PHP. */
return sprintf( __( '%s, on the server', 'monthwrap' ), $name );
}
return $name;
};
$monthwrap_published = wp_list_filter( $report['sections']['content'], array( 'type' => 'post_published' ) );
$monthwrap_updated = wp_list_filter( $report['sections']['content'], array( 'type' => 'post_published' ), 'NOT' );
$monthwrap_changes = array_values(
array_filter(
$report['sections']['maintenance'],
function ( $event ) {
return ! in_array( $event['type'], Monthwrap_Report::UPDATE_TYPES, true );
}
)
);
// Side by side when the lists are short; one under the other when they'd run over a page.
$monthwrap_pair = count( $report['sections']['content'] ) <= 16 && count( $report['sections']['maintenance'] ) <= 16;
$monthwrap_three = count( $report['leads_by_form'] ) <= 6 && count( $monthwrap_site ) <= 6;
// One square per day of the period: backed up, failed, nothing, or still to come.
$monthwrap_days = array();
$monthwrap_today = wp_date( 'Y-m-d' );
for ( $monthwrap_d = $report['period']['start']; $monthwrap_d < $report['period']['end']; $monthwrap_d = $monthwrap_d->modify( '+1 day' ) ) {
$monthwrap_key = $monthwrap_d->format( 'Y-m-d' );
$monthwrap_days[] = $monthwrap_backup['days'][ $monthwrap_key ] ?? ( $monthwrap_key > $monthwrap_today ? 'later' : 'none' );
}
$monthwrap_square = array(
'ok' => $monthwrap_color,
'failed' => '#b94e5e',
'none' => '#dfe2ea',
'later' => '#f1f2f6',
);
$monthwrap_backup_text = array();
if ( $monthwrap_backup['tools'] ) {
/* translators: %s: backup plugins, e.g. UpdraftPlus. */
$monthwrap_backup_text[] = sprintf( __( 'Backed up with %s.', 'monthwrap' ), wp_sprintf( '%l', $monthwrap_backup['tools'] ) );
}
if ( 1 === $monthwrap_backup['failed'] ) {
/* translators: %s: a date, e.g. 13 October. */
$monthwrap_backup_text[] = sprintf( __( 'The backup on %s failed.', 'monthwrap' ), $monthwrap_day( $monthwrap_backup['last_failed'], 'long' ) );
} elseif ( $monthwrap_backup['failed'] ) {
/* translators: 1: number of failed backups, 2: a date, e.g. 13 October. */
$monthwrap_backup_text[] = sprintf( __( '%1$s backups failed, the latest on %2$s.', 'monthwrap' ), number_format_i18n( $monthwrap_backup['failed'] ), $monthwrap_day( $monthwrap_backup['last_failed'], 'long' ) );
}
if ( $monthwrap_backup['last_ok'] ) {
/* translators: 1: a date, e.g. 25 October, 2: a time. */
$monthwrap_backup_text[] = sprintf( __( 'Latest backup: %1$s, %2$s.', 'monthwrap' ), $monthwrap_day( $monthwrap_backup['last_ok'], 'long' ), wp_date( get_option( 'time_format' ), strtotime( (string) $monthwrap_backup['last_ok']['occurred_at'] ) ) );
}
$monthwrap_numbers = array(
array( $monthwrap_totals['published'] + $monthwrap_totals['updated'], '', __( 'Content work', 'monthwrap' ), $report['notes']['content'] ),
array( $monthwrap_totals['updates'], '', __( 'Software updates', 'monthwrap' ), $report['notes']['updates'] ),
array( $monthwrap_backup['ok'], $monthwrap_backup['failed'] ? sprintf( /* translators: %s: all backups, including failed ones. */ __( 'of %s', 'monthwrap' ), number_format_i18n( $monthwrap_backup['ok'] + $monthwrap_backup['failed'] ) ) : '', __( 'Backups', 'monthwrap' ), $report['notes']['backups'] ),
array( $monthwrap_totals['leads'], '', __( 'Leads from forms', 'monthwrap' ), $report['notes']['leads'] ),
);
/* translators: 1: agency name, 2: site name, 3: period. */
$monthwrap_footer = $monthwrap_agency ? sprintf( __( 'Prepared by %1$s for %2$s, %3$s', 'monthwrap' ), $monthwrap_agency, $report['site']['name'], $report['period']['label'] ) : sprintf( /* translators: 1: site name, 2: period. */ __( '%1$s, %2$s', 'monthwrap' ), $report['site']['name'], $report['period']['label'] );
?>
>
$monthwrap_list ) : ?>
| getTimestamp(), 'short' ) ); ?> |
getTimestamp() - 1, 'short' ) ); ?> |
__( 'Backed up', 'monthwrap' ),
'failed' => __( 'Failed', 'monthwrap' ),
'none' => __( 'No backup', 'monthwrap' ),
);
$monthwrap_lead = 'first';
foreach ( $monthwrap_keys as $monthwrap_state => $monthwrap_label ) {
if ( in_array( $monthwrap_state, $monthwrap_days, true ) ) {
echo '' . esc_html( $monthwrap_label );
$monthwrap_lead = '';
}
}
?>
$monthwrap_count ) : ?>