<?php
/* Gutenberg support functions
------------------------------------------------------------------------------- */

// Theme init
if (!function_exists('healthcoach_gutenberg_theme_setup')) {
    add_action( 'healthcoach_action_before_init_theme', 'healthcoach_gutenberg_theme_setup', 1 );
    function healthcoach_gutenberg_theme_setup() {
        if (is_admin()) {
            add_filter( 'healthcoach_filter_required_plugins', 'healthcoach_gutenberg_required_plugins' );
        }
    }
}

// Check if Instagram Widget installed and activated
if ( !function_exists( 'healthcoach_exists_gutenberg' ) ) {
    function healthcoach_exists_gutenberg() {
        return function_exists( 'the_gutenberg_project' ) && function_exists( 'register_block_type' );
    }
}

// Filter to add in the required plugins list
if ( !function_exists( 'healthcoach_gutenberg_required_plugins' ) ) {
    
    function healthcoach_gutenberg_required_plugins($list=array()) {
        if (in_array('gutenberg', (array)healthcoach_storage_get('required_plugins')))
            $list[] = array(
                'name'         => esc_html__('Gutenberg', 'healthcoach'),
                'slug'         => 'gutenberg',
                'required'     => false
            );
        return $list;
    }
}
?>