<?php
/**
 * Easy Digital Downloads integration.
 *
 * @package MenuVerse
 */

namespace WPXero\MenuVerse\Compat;

defined( 'ABSPATH' ) || exit;

/**
 * Lets a search button narrow itself to the shop's downloads.
 *
 * There is nothing to hook. EDD stores its products in an ordinary post type,
 * so scoping a search to them is one extra field on the form MenuVerse already
 * renders — this class exists so the dashboard can say why the option is
 * unavailable when EDD is not installed, rather than hiding it.
 */
class Edd implements Integration {

	/**
	 * Post type EDD stores its products in.
	 *
	 * @var string
	 */
	const POST_TYPE = 'download';

	/**
	 * Returns the integration identifier.
	 *
	 * @return string
	 */
	public static function id() {
		return 'edd';
	}

	/**
	 * Returns the translated plugin name.
	 *
	 * @return string
	 */
	public static function label() {
		return __( 'Easy Digital Downloads', 'menuverse' );
	}

	/**
	 * Tells whether Easy Digital Downloads is active.
	 *
	 * EDD renamed its main class between major versions, so the post type it
	 * registers is the steadier test — and it is the only thing this
	 * integration goes on to use.
	 *
	 * @return bool
	 */
	public static function is_active() {
		return class_exists( 'Easy_Digital_Downloads' ) || class_exists( 'EDD_Requirements_Check' );
	}
}
