<?php

/**
 * Theme Plugins installation
 */

/**
 * Plugin recomendations
 **/
require_once(get_template_directory() . '/inc/tgmpa/class-tgm-plugin-activation.php');

if (!function_exists('cookandmeal_register_required_plugins')) :
    function cookandmeal_register_required_plugins() {

        /**
         * Array of plugin arrays. Required keys are name and slug.
         */
        $plugins = array(
            array(
                'name'                  => esc_html__('CookAndMeal Custom Metaboxes', 'cookandmeal'),
                'slug'                  => 'cmb2',
                'required'              => true,
            ),
            array(
                'name'                  => esc_html__('CookAndMeal Theme Settings (Kirki Customizer Framework)', 'cookandmeal'),
                'slug'                  => 'kirki',
                'required'              => true,
            ),
            array(
                'name'                  => esc_html__('CookAndMeal Theme Addons', 'cookandmeal'),
                'slug'                  => 'cookandmeal-theme-addons',
                'source'                => get_template_directory() . '/inc/plugins/cookandmeal-theme-addons.zip',
                'required'              => true,
                'version'               => '1.0',
            ),
            array(
                'name'                  => esc_html__('Revolution Slider', 'cookandmeal'),
                'slug'                  => 'revslider',
                'source'                => get_template_directory() . '/inc/plugins/revslider.zip',
                'required'              => false,
                'version'               => '6.7.34',
            ),
            array(
                'name'                  => esc_html__('Envato Market - Automatic theme updates', 'cookandmeal'),
                'slug'                  => 'envato-market',
                'source'                => get_template_directory() . '/inc/plugins/envato-market.zip',
                'required'              => false,
                'version'               => '2.0.6',
            ),
            array(
                'name'                  => esc_html__('CookAndMeal Page Navigation', 'cookandmeal'),
                'slug'                  => 'wp-pagenavi',
                'required'              => false,
            ),
            array(
                'name'                  => esc_html__('CookAndMeal Translation Manager', 'cookandmeal'),
                'slug'                  => 'loco-translate',
                'required'              => false,
            ),
            array(
                'name'                  => esc_html__('Instagram Feed', 'cookandmeal'),
                'slug'                  => 'instagram-feed',
                'required'              => false,
            ),
            array(
                'name'                  => esc_html__('MailChimp for WordPress', 'cookandmeal'),
                'slug'                  => 'mailchimp-for-wp',
                'required'              => false,
            ),
            array(
                'name'                  => esc_html__('WordPress LightBox', 'cookandmeal'),
                'slug'                  => 'responsive-lightbox',
                'required'              => false
            ),
            array(
                'name'                  => esc_html__('Contact Form 7', 'cookandmeal'),
                'slug'                  => 'contact-form-7',
                'required'              => false,
            ),
            array(
                'name'                  => esc_html__('Regenerate Thumbnails', 'cookandmeal'),
                'slug'                  => 'regenerate-thumbnails',
                'required'              => false,
            )

        );

        // Add Gutenberg for old WordPress versions
        if (version_compare(get_bloginfo('version'), '5.0', "<")) {
            $plugins[] = array(
                'name'                  => esc_html__('Gutenberg - Advanced WordPress Content Editor', 'cookandmeal'),
                'slug'                  => 'gutenberg',
                'required'              => false,
            );
        }

        /**
         * Array of configuration settings.
         */
        $config = array(
            'domain'            => 'cookandmeal',
            'default_path'      => '',
            'menu'              => 'install-required-plugins',
            'has_notices'       => true,
            'dismissable'  => true,
            'is_automatic'      => false,
            'message'           => ''
        );

        tgmpa($plugins, $config);
    }
endif;
add_action('tgmpa_register', 'cookandmeal_register_required_plugins');
