<?php
/**
 * Add WooThemes Framework compatibility to GravityView, including registering scripts and styles to GravityView no-conflict list
 *
 * @file      class-gravityview-theme-hooks-woothemes.php
 * @package   GravityKit\GravityView\Integration
 * @license   GPL2+
 * @author    GravityKit <hello@gravitykit.com>
 * @link      http://www.gravitykit.com
 * @copyright Copyright 2015, Katz Web Services, Inc.
 *
 * @since 1.15.2
 */

namespace GravityKit\GravityView\Integration;

use function gravityview;

/**
 * @inheritDoc
 */
class WooThemes extends AbstractPluginHooks {

	/**
	 * @inheritDoc
	 * @since 1.15.2
	 */
	protected $script_handles = [
		'woo-shortcodes',
		'woo-custom-fields',
		'woo-medialibrary-uploader',
		'jquery-masked-input',
		'woo-upload',
		'woo-datepicker',
		'woo-colourpicker',
		'woo-typography',
		'woo-masked-input',
		'woo-chosen',
		'woo-chosen-rtl',
		'woo-chosen-loader',
		'woo-image-selector',
		'woo-range-selector',
	];

	/**
	 * @inheritDoc
	 * @since 1.15.2
	 */
	protected $style_handles = [
		'woo-menu',
		'wf-admin',
		'woothemes-fields',
		'woo-fields',
		'woo-chosen',
		'woothemes-chosen',
	];

	/**
	 * @inheritDoc
	 * @since 1.15.2
	 */
	protected $function_name = 'woo_version';

	/**
	 * @inheritDoc
	 * @since 1.15.2
	 */
	function add_hooks() {

		parent::add_hooks();

		add_action( 'admin_menu', [ $this, 'remove_meta_box' ], 11 );
	}

	/**
	 * Remove the WooThemes metabox on new page
	 *
	 * @since 1.15.2
	 */
	function remove_meta_box() {
		global $pagenow;

		$gv_page = gravityview()->request->is_admin( '', 'single' );

		// New View or Edit View page
		if ( $gv_page && 'post-new.php' === $pagenow ) {
			remove_meta_box( 'woothemes-settings', 'gravityview', 'normal' );
		}
	}
}
