<?php
/* Mail Chimp support functions
------------------------------------------------------------------------------- */

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

// Check if Instagram Feedinstalled and activated
if ( !function_exists( 'writer_ancora_exists_mailchimp' ) ) {
    function writer_ancora_exists_mailchimp() {
        return function_exists('mc4wp_load_plugin');
    }
}

// Filter to add in the required plugins list
if ( !function_exists( 'writer_ancora_mailchimp_required_plugins' ) ) {
    function writer_ancora_mailchimp_required_plugins($list=array()) {
        if (in_array('mailchimp', writer_ancora_storage_get('required_plugins')))
            $list[] = array(
                'name' 		=> esc_html__('MailChimp for WP', 'writer-ancora'),
                'slug' 		=> 'mailchimp-for-wp',
                'required' 	=> false
            );
        return $list;
    }
}
?>
