<?php
/**
 * Bootstrap file for the shortcodes used in the free version of plugin
 *
 * @package Flexible_FAQs
 */

namespace WPGO_Plugins\Flexible_Faqs;

/**
 * Bootstrap class for the free shortcodes.
 */
class Shortcodes {

	/**
	 * Common root paths/directories.
	 *
	 * @var $module_roots
	 */
	protected $module_roots;

	/**
	 * Main class constructor.
	 *
	 * @param Array $module_roots Root plugin path/dir.
	 * @param Array $custom_plugin_data Plugin data.
	 */
	public function __construct( $module_roots, $custom_plugin_data, $utilities_fw ) {

		$this->module_roots       = $module_roots;
		$this->custom_plugin_data = $custom_plugin_data;
		$this->utilities_fw       = $utilities_fw;

		$this->load_shortcodes();

		// Allow shortcodes to be used in widgets (the callbacks are WordPress core functions).
		add_filter( 'widget_text', 'shortcode_unautop' );
		add_filter( 'widget_text', 'do_shortcode' );
	}

	/**
	 * Load shortcodes.
	 */
	public function load_shortcodes() {

		$root = $this->module_roots['dir'];

		// [flexible-faqs] shortcode.
		require_once $root . 'classes/shortcodes/class-faq-shortcode.php';
		FAQ_Shortcode::create_instance( $this->module_roots, $this->custom_plugin_data, $this->utilities_fw );
	}

} /* End class definition */
