__( 'Optimized', 'pixelkeep' ),
'already_optimal' => __( 'Already optimal', 'pixelkeep' ),
'pending' => __( 'Pending', 'pixelkeep' ),
'skipped' => __( 'Skipped', 'pixelkeep' ),
'failed' => __( 'Failed', 'pixelkeep' ),
'restored' => __( 'Restored', 'pixelkeep' ),
'' => __( 'Not optimized', 'pixelkeep' ),
);
return $labels[ $status ] ?? $labels[''];
}
/**
* Returns a status pill.
*
* @param string $status Status.
* @param string $code Error or skip code, shown as a tooltip and to screen readers.
* @return string Safe HTML.
*/
public static function status_pill( string $status, string $code = '' ): string {
$message = '' !== $code ? ErrorCodes::message( $code ) : '';
return sprintf(
'%2$s%4$s',
esc_attr( '' === $status ? 'none' : $status ),
esc_html( self::status_label( $status ) ),
'' !== $message ? ' title="' . esc_attr( $message ) . '"' : '',
'' !== $message ? '' . esc_html( $message ) . '' : ''
);
}
/**
* Formats a stored UTC date in the site's format.
*
* @param string $mysql_utc MySQL UTC datetime.
* @return string
*/
public static function date( string $mysql_utc ): string {
if ( '' === $mysql_utc ) {
return '';
}
$timestamp = strtotime( $mysql_utc . ' UTC' );
return false === $timestamp ? '' : wp_date( (string) get_option( 'date_format' ) . ' ' . (string) get_option( 'time_format' ), $timestamp );
}
}