<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$problems = array();
$actions = array();

$days = breadcrumbspress_settings()->get_last_tracked_days();
$days = $days === false ? 15 : absint( $days );

$_class   = $days < 4 ? 'd4p-badge-ok' : ( $days > 14 ? 'd4p-badge-error' : 'd4p-badge-purple' );
$_icon    = $days < 4 ? 'd4p-ui-check-square' : ( $days > 14 ? 'd4p-ui-clear' : 'd4p-ui-warning' );
$_badge   = $days < 4 ? __( 'OK', 'breadcrumbspress' ) : ( $days > 14 ? __( 'Error', 'breadcrumbspress' ) : __( 'Problem', 'breadcrumbspress' ) );
$_message = $days < 4 ? __( 'Everything appears to be in order.', 'breadcrumbspress' ) : ( $days > 14 ? __( 'Breadcrumbs are not displaying on your website.', 'breadcrumbspress' ) : __( 'Breadcrumbs have not been displayed for days.', 'breadcrumbspress' ) );

if ( empty( $problems ) || $days >= 4 ) {
	$problems[] = '<span class="d4p-card-badge ' . $_class . '"><i class="d4p-icon ' . $_icon . ' d4p-icon-fw"></i>' . $_badge . '</span><div class="d4p-status-message">' . $_message . '</div>';
}

?>

<div class="d4p-group d4p-dashboard-card d4p-card-double d4p-dashboard-status">
    <h3><?php esc_html_e( 'Plugin Status', 'breadcrumbspress' ); ?></h3>
    <div class="d4p-group-inner">
        <div>
			<?php echo join( '</div><div>', $problems ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
        </div>
    </div>
	<?php if ( ! empty( $actions ) ) { ?>
        <div class="d4p-group-footer">
			<?php echo join( '', $actions ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
        </div>
	<?php } ?>
</div>