<?php
/**
 * weLaunch Options Object Extension Class
 *
 * @class weLaunch_Core
 * @version 4.0.0
 * @package weLaunch Framework
 */

defined( 'ABSPATH' ) || exit;

// Don't duplicate me!
if ( ! class_exists( 'weLaunch_Extension_Options_Object', false ) ) {


	/**
	 * Main weLaunchFramework options_object extension class
	 *
	 * @since       3.1.6
	 */
	class weLaunch_Extension_Options_Object extends weLaunch_Extension_Abstract {

		/**
		 * Ext version.
		 *
		 * @var string
		 */
		public static $version = '4.0';

		/**
		 * Set the name of the field.  Ideally, this will also be your extension's name.
		 * Please use underscores and NOT dashes.
		 *
		 * @var string
		 */
		private $field_name = 'my_extension';

		/**
		 * Is field bit.
		 *
		 * @var bool
		 */
		public $is_field = false;

		/**
		 * Class Constructor. Defines the args for the extions class
		 *
		 * @since       1.0.0
		 * @access      public
		 *
		 * @param       array $parent weLaunch object.
		 *
		 * @return      void
		 */
		public function __construct( $parent ) {
			parent::__construct( $parent, __FILE__ );

			$this->add_field( $this->field_name );
			$this->is_field = weLaunch_Helpers::is_field_in_use( $parent, $this->field_name );

			if ( ! $this->is_field && $this->parent->args['dev_mode'] && $this->parent->args['show_options_object'] ) {
				$this->add_section();
			}
		}

		/**
		 * Add sectio to panel.
		 */
		public function add_section() {
			$this->parent->sections[] = array(
				'id'         => 'options-object',
				'title'      => esc_html__( 'Options Object', 'welaunch-framework' ),
				'heading'    => '',
				'icon'       => 'el el-info-circle',
				'customizer' => false,
				'fields'     => array(
					array(
						'id'    => 'welaunch_options_object',
						'type'  => 'options_object',
						'title' => '',
					),
				),
			);
		}
	}

	if ( ! class_exists( 'weLaunchFramework_Extension_options_object' ) ) {
		class_alias( 'weLaunch_Extension_Options_Object', 'weLaunchFramework_Extension_options_object' );
	}
}
