<?php
/**
 * The template to display entry excerpt.
 *
 * This template can be overridden by copying it to
 * your-child-theme/views/entry/excerpt.php.
 *
 * @param array $args
 *
 * @package MadeByAura\Prime
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime;

use MadeByAura\Prime\Helpers\Markup;

defined( 'ABSPATH' ) || die();

// Merge incoming `$args` with defaults.
$args = array_replace_recursive(
	[
		'words' => 32,
		'class' => '',
	],
	$args,
);

// Set variables.
$excerpt = get_the_excerpt();

// If there is no excerpt, get the first X words from the content.
if ( ! has_excerpt() || ! $excerpt ) {
	$excerpt = wp_trim_words( get_the_content(), $args['words'] );
}

// Set CSS classes.
$classes[] = $args['class'];
$classes[] = 'aura-entry-excerpt';
?>

<div class="<?php Markup::echo_classes( $classes ); ?>">
	<?php echo wp_kses_post( $excerpt ); ?>
</div>
