<?php
/* Essential Grid support functions
------------------------------------------------------------------------------- */

// Theme init
if (!function_exists('writer_ancora_essgrids_theme_setup')) {
	add_action( 'writer_ancora_action_before_init_theme', 'writer_ancora_essgrids_theme_setup', 1 );
	function writer_ancora_essgrids_theme_setup() {
		if (is_admin()) {
			add_filter( 'writer_ancora_filter_required_plugins',				'writer_ancora_essgrids_required_plugins' );
		}
	}
}


// Check if Ess. Grid installed and activated
if ( !function_exists( 'writer_ancora_exists_essgrids' ) ) {
	function writer_ancora_exists_essgrids() {
		return defined( 'ESG_PLUGIN_PATH' ) || defined( 'EG_PLUGIN_PATH' );
	}
}

// Filter to add in the required plugins list
if ( !function_exists( 'writer_ancora_essgrids_required_plugins' ) ) {
	function writer_ancora_essgrids_required_plugins($list=array()) {
		if (in_array('essgrids', writer_ancora_storage_get('required_plugins'))) {
			$path = writer_ancora_get_file_dir('plugins/install/essential-grid.zip');
			if (file_exists($path)) {
				$list[] = array(
					'name' 		=> esc_html__('Essential Grid', 'writer-ancora'),
					'slug' 		=> 'essential-grid',
					'version'   => '3.0.12',
					'source'	=> $path,
					'required' 	=> false
					);
			}
		}
		return $list;
	}
}
?>