<?php
/**
 * Read more link.
 *
 * @package Kutby
 * @since   2.9.0
 */

declare(strict_types=1);

namespace Kutby\Cards\Parts;

use Kutby\Cards\Contracts\CardPartInterface;
use Kutby\Cards\Support\CardContext;

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

/**
 * Class ReadMore
 */
final class ReadMore implements CardPartInterface {

	/**
	 * {@inheritdoc}
	 */
	public static function render( CardContext $ctx, array $args = array() ): void {
		if ( ! $ctx->bool( 'show_read_more' ) ) {
			return;
		}

		$label = isset( $args['label'] ) ? (string) $args['label'] : 'اقرأ المزيد';
		?>
		<a class="kutby-card__readmore" href="<?php echo esc_url( get_permalink( $ctx->post() ) ); ?>">
			<?php echo esc_html( $label ); ?>
			<span class="kutby-sr-only">: <?php echo esc_html( get_the_title( $ctx->post() ) ); ?></span>
		</a>
		<?php
	}
}
