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

// Theme init
if (!function_exists('healthcoach_instagram_widget_by_wpzoom_theme_setup')) {
    add_action( 'healthcoach_action_before_init_theme', 'healthcoach_instagram_widget_by_wpzoom_theme_setup', 1 );
    function healthcoach_instagram_widget_by_wpzoom_theme_setup() {
        if (healthcoach_exists_instagram_widget_by_wpzoom()) {
            add_action( 'healthcoach_action_add_styles', 						'healthcoach_instagram_widget_by_wpzoom_frontend_scripts' );
        }
        if (is_admin()) {
            add_filter( 'healthcoach_filter_required_plugins', 'healthcoach_instagram_widget_by_wpzoom_required_plugins' );
        }
    }
}

// Check if Instagram Widget installed and activated
if ( !function_exists( 'healthcoach_exists_instagram_widget_by_wpzoom' ) ) {
    function healthcoach_exists_instagram_widget_by_wpzoom() {
        return function_exists('zoom_instagram_widget_register');
    }
}


// Filter to add in the required plugins list
if ( !function_exists( 'healthcoach_instagram_widget_by_wpzoom_required_plugins' ) ) {
    
    function healthcoach_instagram_widget_by_wpzoom_required_plugins($list=array()) {
        if (in_array('instagram-widget-by-wpzoom', healthcoach_storage_get('required_plugins')))
            $list[] = array(
            'name'        => 'Instagram Widget by WPZOOM',
            'slug'        => 'instagram-widget-by-wpzoom',
            'required'     => false
        );
        return $list;
    }
}

// Enqueue custom styles
if ( !function_exists( 'healthcoach_instagram_widget_by_wpzoom_frontend_scripts' ) ) {
    
    function healthcoach_instagram_widget_by_wpzoom_frontend_scripts() {
        if (file_exists(healthcoach_get_file_dir('css/plugin.instagram-widget-by-wpzoom.css')))
            wp_enqueue_style( 'healthcoach-plugin-instagram-widget-by-wpzoom',  healthcoach_get_file_url('css/plugin.instagram-widget-by-wpzoom.css'), array(), null );
    }
}

?>