<?php

namespace WPEventGenius\Common\SEO\Compatibility;

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

class SEOPressSEOCompatibility implements SEOCompatibilityInterface {

	/**
	 * @inheritDoc
	 */
	public function is_available() {
		return function_exists( 'seopress_display_breadcrumbs' );
	}

	/**
	 * @inheritDoc
	 */
	public function render( $post_id, array $breadcrumb_context = array() ) {
		if ( ! $this->is_available() ) {
			return '';
		}

		ob_start();
		seopress_display_breadcrumbs();
		$breadcrumbs = ob_get_clean();

		if ( ! is_string( $breadcrumbs ) ) {
			return '';
		}

		return trim( $breadcrumbs );
	}
}
