<?php
/**
 * The file that defines the core plugin class
 *
 * @since      1.0.0
 *
 * @package    captain-widgets-kit
 * @subpackage captain-widgets-kit/includes
 */

/**
 * Exit if accessed directly.
 * */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Define Captwiki_Extra_Options class for the free version.
 *
 * @since 1.0.0
 */
if ( ! class_exists( 'Captwiki_Extra_Options' ) ) {

	/**
	 * Define Captwiki_Extra_Options class for the free version
	 *
	 * @since 1.0.0
	 */
	class Captwiki_Extra_Options {

		/**
		 * Call __construct.
		 *
		 * @since 1.0.0
		 */
		public function __construct() {
			$this->captwiki_elementor_extensions();
		}

		/**
		 * Load elementor extensions.
		 *
		 * @since 1.0.0
		 */
		public function captwiki_elementor_extensions() {

			$captwiki_wp_extensions = get_option( 'captwiki_wp_extensions', array() );
			$captwiki_extensions    = isset( $captwiki_wp_extensions['extensions'] ) && is_array( $captwiki_wp_extensions['extensions'] ) ? $captwiki_wp_extensions['extensions'] : $captwiki_wp_extensions;
			$captwiki_extensions    = is_array( $captwiki_extensions ) ? $captwiki_extensions : array();

			$extension_files = array(
				'Captwiki_Duplicate_Posttype' => 'class-captwiki-duplicate-posttype.php',
				'Captwiki_Disable_Gutenberg'  => 'class-captwiki-disable-gutenberg.php',
				'Captwiki_Disable_Icons'      => 'class-captwiki-disable-icons.php',
			);

			foreach ( $extension_files as $extension => $file ) {
				if ( in_array( $extension, $captwiki_extensions, true ) ) {
					include CAPTWIKI_PATH . 'includes/wp-extra-options/' . $file;
				}
			}
		}
	}
}

new Captwiki_Extra_Options();
