<?php
/* Instagram Widget support functions
------------------------------------------------------------------------------- */

// Theme init
if (!function_exists('seohub_instagram_widget_theme_setup')) {
	add_action( 'seohub_action_before_init_theme', 'seohub_instagram_widget_theme_setup', 1 );
	function seohub_instagram_widget_theme_setup() {
		if (is_admin()) {
			add_filter( 'seohub_filter_importer_required_plugins',		'seohub_instagram_widget_importer_required_plugins' );
			add_filter( 'seohub_filter_required_plugins',					'seohub_instagram_widget_required_plugins' );
		}
	}
}

// Check if Instagram Widget installed and activated
if ( !function_exists( 'seohub_exists_instagram_widget' ) ) {
	function seohub_exists_instagram_widget() {
		return seohub_widget_is_active('wp-instagram-widget/wp-instagram-widget');
	}
}

// Filter to add in the required plugins list
if ( !function_exists( 'seohub_instagram_widget_required_plugins' ) ) {
	//add_filter('seohub_filter_required_plugins',	'seohub_instagram_widget_required_plugins');
	function seohub_instagram_widget_required_plugins($list=array()) {
	    global $SEOHUB_GLOBALS;
		if (in_array('instagram_widget', $SEOHUB_GLOBALS['required_plugins']))
			$list[] = array(
					'name' 		=> 'Instagram Widget',
					'slug' 		=> 'wp-instagram-widget',
					'required' 	=> false
				);
		return $list;
	}
}



// One-click import support
//------------------------------------------------------------------------

// Check Instagram Widget in the required plugins
if ( !function_exists( 'seohub_instagram_widget_importer_required_plugins' ) ) {
	//add_filter( 'seohub_filter_importer_required_plugins',	'seohub_instagram_widget_importer_required_plugins' );
	function seohub_instagram_widget_importer_required_plugins($not_installed='') {
	    global $SEOHUB_GLOBALS;
		if (in_array('instagram_widget', $SEOHUB_GLOBALS['required_plugins']) && !seohub_exists_instagram_widget() )
			$not_installed .= '<br>WP Instagram Widget';
		return $not_installed;
	}
}
?>