<?php
/* The GDPR Framework support functions
------------------------------------------------------------------------------- */

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

// Check if Instagram Widget installed and activated
if ( !function_exists( 'writer_ancora_exists_gdpr_compliance' ) ) {
    function writer_ancora_exists_gdpr_compliance() {
        return defined( 'WP_GDPR_C_SLUG' );
    }
}

// Filter to add in the required plugins list
if ( !function_exists( 'writer_ancora_gdpr_compliance_required_plugins' ) ) {
    function writer_ancora_gdpr_compliance_required_plugins($list=array()) {
        if (in_array('gdpr-compliance', (array)writer_ancora_storage_get('required_plugins')))
            $list[] = array(
                'name'         => esc_html__('WP GDPR Compliance', 'writer-ancora'),
                'slug'         => 'wp-gdpr-compliance',
                'required'     => false
            );
        return $list;
    }
}