<?php

namespace IGD\Integrations\Divi;

use IGD\Enqueue;

defined( 'ABSPATH' ) || exit;

class DiviExtension extends \DiviExtension {

	/**
	 * The gettext domain for the extension's translations.
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	public $gettext_domain = 'integrate-google-drive';

	/**
	 * The extension's WP Plugin name.
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	public $name = 'igd-divi-extension';

	/**
	 * The extension's version
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	public $version = '1.0.0';

	/**
	 * \DiviExtension() constructor.
	 *
	 * @param string $name
	 * @param array $args
	 */
	public function __construct( $name = 'igd-divi-extension', $args = array() ) {

		$this->plugin_dir     = plugin_dir_path( __FILE__ );
		$this->plugin_dir_url = plugin_dir_url( $this->plugin_dir );

		parent::__construct( $name, $args );

		// Enqueue scripts when Divi builder is ready in frontend
		add_action( 'et_builder_ready', array( $this, 'enqueue_builder_scripts' ) );

	}

	public function enqueue_builder_scripts() {
		if ( ! wp_script_is( 'igd-admin', 'registered' ) ) {
			Enqueue::instance()->admin_scripts( '', false );
		}
	}


}

new DiviExtension();