<?php

namespace Barn2\Plugin\Password_Protected_Categories;

use Barn2\Plugin\Password_Protected_Categories\Dependencies\Lib\Registerable;
use Barn2\Plugin\Password_Protected_Categories\Dependencies\Lib\Service\Premium_Service;

/**
 * The class implements the category login shortcode.
 *
 * @package   Barn2\password-protected-categories
 * @author    Barn2 Plugins <support@barn2.co.uk>
 * @license   GPL-3.0
 * @copyright Barn2 Media Ltd
 */
class Login_Shortcode implements Premium_Service, Registerable {

	const SHORTCODE = 'category_login';

	public function register() {
		// Register shortcode
		\add_shortcode( self::SHORTCODE, [ $this, 'login_shortcode' ] );
	}

	public function login_shortcode( $atts = [] ) {
		$atts = \shortcode_atts(
			[
				'heading' => PPC_Util::get_login_page_title(),
				'show_heading' => false,
				'message' => PPC_Util::get_login_form_message(),
				'label' => PPC_Util::get_login_form_label(),
				'button_text' => PPC_Util::get_login_form_button_text(),
			],
			$atts,
			self::SHORTCODE
		);

		$password_form = new Password_Form();
		return $password_form->get_password_form( $atts );
	}

}
