<?php
/* Elegro Crypto Payment support functions
------------------------------------------------------------------------------- */


// Theme init
if (!function_exists('healthcoach_elegro_payment_theme_setup')) {
    add_action( 'healthcoach_action_before_init_theme', 'healthcoach_elegro_payment_theme_setup' );
    function healthcoach_elegro_payment_theme_setup() {
        if (healthcoach_exists_elegro_payment()) {
            add_action( 'healthcoach_action_add_styles', 						'healthcoach_elegro_payment_frontend_scripts' );
        }

        if (is_admin()) {
            add_filter( 'healthcoach_filter_required_plugins',				'healthcoach_elegro_payment_required_plugins' );
        }
    }
}

// Check if RevSlider installed and activated
if ( !function_exists( 'healthcoach_exists_elegro_payment' ) ) {
    function healthcoach_exists_elegro_payment() {
        return class_exists( 'WC_Elegro_Payment' );
    }
}

// Filter to add in the required plugins list
if ( !function_exists( 'healthcoach_elegro_payment_required_plugins' ) ) {
    
    function healthcoach_elegro_payment_required_plugins($list=array()) {
        $list[] = array(
            'name' 		=> 'Elegro Crypto Payment',
            'slug' 		=> 'elegro-payment',
            'required' 	=> false
        );

        return $list;
    }
}

// Enqueue custom styles
if ( !function_exists( 'healthcoach_elegro_payment_frontend_scripts' ) ) {
    
    function healthcoach_elegro_payment_frontend_scripts() {
        if (file_exists(healthcoach_get_file_dir('css/plugin.elegro-payment.css')))
            wp_enqueue_style( 'healthcoach-plugin-elegro-payment',  healthcoach_get_file_url('css/plugin.elegro-payment.css'), array(), null );
    }
}
