<?php
namespace MASCOTCOREEDUCACION\Shortcodes;

use MASCOTCOREEDUCACION\Shortcodes\Lib;
use MASCOTCOREEDUCACION\Shortcodes\BeforeAfterSlider\SC_Before_After_Slider;
use MASCOTCOREEDUCACION\Shortcodes\Blockquote\SC_Blockquote;
use MASCOTCOREEDUCACION\Shortcodes\Blog\SC_Blog;
use MASCOTCOREEDUCACION\Shortcodes\Button\SC_Button;
use MASCOTCOREEDUCACION\Shortcodes\CallToAction\SC_Call_To_Action;
use MASCOTCOREEDUCACION\Shortcodes\CharitableCampaigns\SC_Charitable_Campaigns;
use MASCOTCOREEDUCACION\Shortcodes\CharitableCampaignCustom\SC_Charitable_Campaign_Custom;
use MASCOTCOREEDUCACION\Shortcodes\CountdownTimer\SC_Countdown_Timer;
use MASCOTCOREEDUCACION\Shortcodes\CustomColumnsHolder\SC_Custom_Columns_Holder;
use MASCOTCOREEDUCACION\Shortcodes\CustomColumnsHolderItem\SC_Custom_Columns_Holder_Item;
use MASCOTCOREEDUCACION\Shortcodes\FunFactCounter\SC_FunFact_Counter;
use MASCOTCOREEDUCACION\Shortcodes\Dropcaps\SC_Dropcaps;
use MASCOTCOREEDUCACION\Shortcodes\GiveCampaigns\SC_Give_Campaigns;
use MASCOTCOREEDUCACION\Shortcodes\GiveSingleFormCustom\SC_Give_Single_Form_Custom;
use MASCOTCOREEDUCACION\Shortcodes\GoogleMap\SC_Google_Map;
use MASCOTCOREEDUCACION\Shortcodes\IconBox\SC_Icon_Box;
use MASCOTCOREEDUCACION\Shortcodes\LearnPressListCourses\SC_LearnPress_List_Courses;
use MASCOTCOREEDUCACION\Shortcodes\OpeningHours\SC_Opening_Hours;
use MASCOTCOREEDUCACION\Shortcodes\OpeningHoursCompressed\SC_Opening_Hours_Compressed;
use MASCOTCOREEDUCACION\Shortcodes\PaypalDonation\SC_Paypal_Donation;
use MASCOTCOREEDUCACION\Shortcodes\PieChart\SC_Pie_Chart;
use MASCOTCOREEDUCACION\Shortcodes\PricingTable\SC_PricingTable;
use MASCOTCOREEDUCACION\Shortcodes\ProgressBar\SC_Progress_Bar;
use MASCOTCOREEDUCACION\Shortcodes\SectionTitle\SC_Section_Title;
use MASCOTCOREEDUCACION\Shortcodes\SocialList\SC_Social_List;
use MASCOTCOREEDUCACION\Shortcodes\TribeEvents\SC_Tribe_Events;
use MASCOTCOREEDUCACION\Shortcodes\VideoPopup\SC_Video_Popup;
use MASCOTCOREEDUCACION\Shortcodes\UnorderedList\SC_Unordered_List;
use MASCOTCOREEDUCACION\Shortcodes\WCProducts\SC_WC_Products;
use MASCOTCOREEDUCACION\Shortcodes\WorkingStepsHolder\SC_Working_Steps_Holder;
use MASCOTCOREEDUCACION\Shortcodes\WorkingStepsHolderItem\SC_Working_Steps_Holder_Item;

/**
 * class Loader_Shortcodes
 * @package MASCOTCOREEDUCACION\Shortcodes;
 */
class Loader_Shortcodes {
	/**
	 * @var Singleton The reference to *Singleton* instance of this class
	 */
	private static $instance;

	/**
	 * @var array
	 */
	private $allShortCodes = array();
	
	/**
	 * Returns the *Singleton* instance of this class.
	 *
	 * @return Singleton The *Singleton* instance.
	 */
	public static function get_instance()
	{
		if (null === static::$instance) {
			static::$instance = new static();
		}
		
		return static::$instance;
	}

	/**
	 * Protected constructor to prevent creating a new instance of the
	 * *Singleton* via the `new` operator from outside of this class.
	 */
	protected function __construct()
	{
	}

	/**
	 * Private clone method to prevent cloning of the instance of the
	 * *Singleton* instance.
	 *
	 * @return void
	 */
	private function __clone()
	{
	}

	/**
	 * Private unserialize method to prevent unserializing of the *Singleton*
	 * instance.
	 *
	 * @return void
	 */
	private function __wakeup()
	{
	}


	/**
	 * Adds new SC to SC array
	 */
	private function addNewShortCode(Lib\Mascot_Core_Educacion_Interface_Shortcodes $newShortCode) {
		if(!array_key_exists($newShortCode->getShortCodeBase(), $this->allShortCodes)) {
			$this->allShortCodes[$newShortCode->getShortCodeBase()] = $newShortCode;
		}
	}

	/**
	 * List of all SCs to register
	 */
	private function available_shortcodes() {
		$this->addNewShortCode(new SC_Before_After_Slider());
		$this->addNewShortCode(new SC_Blockquote());
		$this->addNewShortCode(new SC_Blog());
		$this->addNewShortCode(new SC_Button());
		$this->addNewShortCode(new SC_Call_To_Action());
		$this->addNewShortCode(new SC_Charitable_Campaigns());
		$this->addNewShortCode(new SC_Charitable_Campaign_Custom());
		$this->addNewShortCode(new SC_Countdown_Timer());
		$this->addNewShortCode(new SC_Custom_Columns_Holder());
		$this->addNewShortCode(new SC_Custom_Columns_Holder_Item());
		$this->addNewShortCode(new SC_Dropcaps());
		$this->addNewShortCode(new SC_FunFact_Counter());
		$this->addNewShortCode(new SC_Give_Campaigns());
		$this->addNewShortCode(new SC_Give_Single_Form_Custom());
		$this->addNewShortCode(new SC_Google_Map());
		$this->addNewShortCode(new SC_Icon_Box());
		$this->addNewShortCode(new SC_LearnPress_List_Courses());
		$this->addNewShortCode(new SC_Opening_Hours());
		$this->addNewShortCode(new SC_Opening_Hours_Compressed());
		$this->addNewShortCode(new SC_Paypal_Donation());
		$this->addNewShortCode(new SC_Pie_Chart());
		$this->addNewShortCode(new SC_PricingTable());
		$this->addNewShortCode(new SC_Progress_Bar());
		$this->addNewShortCode(new SC_Section_Title());
		$this->addNewShortCode(new SC_Social_List());
		$this->addNewShortCode(new SC_Tribe_Events());
		$this->addNewShortCode(new SC_Unordered_List());
		$this->addNewShortCode(new SC_Video_Popup());
		$this->addNewShortCode(new SC_WC_Products());
		$this->addNewShortCode(new SC_Working_Steps_Holder());
		$this->addNewShortCode(new SC_Working_Steps_Holder_Item());
	}


	/**
	 * Calls available_shortcodes method, loops through each SC in array and add it through add_shortcode
	 */
	public function load() {
		$this->available_shortcodes();
		foreach ($this->allShortCodes as $eachShortCode) {
			add_shortcode($eachShortCode->getShortCodeBase(), array($eachShortCode, 'render'));
		}
	}
}

//Create instance of Loader_Shortcodes
$scloader = Loader_Shortcodes::get_instance();
$scloader->load();