<?php

defined('ABSPATH') || die;
define('HAPPY_ADDONS_VERSION', '2.25.0');
define('HAPPY_ADDONS__FILE__', __FILE__);
define('HAPPY_ADDONS_DIR_PATH', plugin_dir_path(HAPPY_ADDONS__FILE__));
define('HAPPY_ADDONS_DIR_URL', plugin_dir_url(HAPPY_ADDONS__FILE__));
define('HAPPY_ADDONS_ASSETS', trailingslashit(HAPPY_ADDONS_DIR_URL . 'assets'));
define('HAPPY_ADDONS_REDIRECTION_FLAG', 'happyaddons_do_activation_direct');
define('HAPPY_ADDONS_MINIMUM_ELEMENTOR_VERSION', '2.9.0');
define('HAPPY_ADDONS_MINIMUM_PHP_VERSION', '5.4');
function ha_let_the_journey_begin()
{
    require HAPPY_ADDONS_DIR_PATH . 'inc/functions.php';
    if (version_compare(PHP_VERSION, HAPPY_ADDONS_MINIMUM_PHP_VERSION, '<')) {
        add_action('admin_notices', 'ha_required_php_version_missing_notice');
        return;
    }
    if (!did_action('elementor/loaded')) {
        add_action('admin_notices', 'ha_elementor_missing_notice');
        return;
    }
    if (!version_compare(ELEMENTOR_VERSION, HAPPY_ADDONS_MINIMUM_ELEMENTOR_VERSION, '>=')) {
        add_action('admin_notices', 'ha_required_elementor_version_missing_notice');
        return;
    }
    require HAPPY_ADDONS_DIR_PATH . 'base.php';
    \Happy_Addons\Elementor\Base::instance();
}
add_action('plugins_loaded', 'ha_let_the_journey_begin');
function ha_required_php_version_missing_notice()
{
    $notice = sprintf(esc_html__('"%1$s" requires "%2$s" version %3$s or greater.', 'happy-elementor-addons'), '<strong>' . esc_html__('Happy Elementor Addons', 'happy-elementor-addons') . '</strong>', '<strong>' . esc_html__('PHP', 'happy-elementor-addons') . '</strong>', HAPPY_ADDONS_MINIMUM_PHP_VERSION);
    printf('<div class="notice notice-warning is-dismissible"><p style="padding: 13px 0">%1$s</p></div>', $notice);
}
function ha_elementor_missing_notice()
{
    if (file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
        $notice_title = __('Activate Elementor', 'happy-elementor-addons');
        $notice_url = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
    } else {
        $notice_title = __('Install Elementor', 'happy-elementor-addons');
        $notice_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
    }
    $notice = ha_kses_intermediate(sprintf(__('%1$s requires %2$s to be installed and activated to function properly. %3$s', 'happy-elementor-addons'), '<strong>' . __('Happy Elementor Addons', 'happy-elementor-addons') . '</strong>', '<strong>' . __('Elementor', 'happy-elementor-addons') . '</strong>', '<a href="' . esc_url($notice_url) . '">' . $notice_title . '</a>'));
    printf('<div class="notice notice-warning is-dismissible"><p style="padding: 13px 0">%1$s</p></div>', $notice);
}
function ha_required_elementor_version_missing_notice()
{
    $notice = sprintf(esc_html__('"%1$s" requires "%2$s" version %3$s or greater.', 'happy-elementor-addons'), '<strong>' . esc_html__('Happy Elementor Addons', 'happy-elementor-addons') . '</strong>', '<strong>' . esc_html__('Elementor', 'happy-elementor-addons') . '</strong>', HAPPY_ADDONS_MINIMUM_ELEMENTOR_VERSION);
    printf('<div class="notice notice-warning is-dismissible"><p style="padding: 13px 0">%1$s</p></div>', $notice);
}
function ha_register_activation_hook()
{
    add_option(HAPPY_ADDONS_REDIRECTION_FLAG, true);
}
register_activation_hook(HAPPY_ADDONS__FILE__, 'ha_register_activation_hook');