<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
<?php
/**
 * Compatibility with Elementor Header Footer plugin.
 *
 * @package Solace\Compatibility
 */

namespace Solace\Compatibility;

/**
 * Class Header_Footer_Elementor
 *
 * @package Solace\Compatibility
 */
class Header_Footer_Elementor {

	/**
	 * Check if plugin is installed.
	 */
	private function should_load() {
		if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
			return false;
		}
		if ( ! class_exists( 'Header_Footer_Elementor', false ) ) {
			return false;
		}

		return true;
	}

	/**
	 * Init function.
	 */
	public function init() {
		if ( ! $this->should_load() ) {
			return;
		}

		$this->add_theme_builder_hooks();
	}

	/**
	 * Replace theme hooks with the one from the plugin.
	 */
	private function add_theme_builder_hooks() {
		add_action( 'solace_do_header', array( $this, 'do_header' ), 0 );
		add_action( 'solace_do_footer', array( $this, 'do_footer' ), 0 );
	}

	/**
	 * Replace Header hooks.
	 */
	public function do_header() {
		if ( ! hfe_header_enabled() ) {
			return;
		}
		hfe_render_header();
		remove_all_actions( 'solace_do_top_bar' );
		remove_all_actions( 'solace_do_header' );
	}

	/**
	 * Replace Footer hooks.
	 */
	public function do_footer() {
		if ( ! hfe_footer_enabled() ) {
			return;
		}
		hfe_render_footer();
		remove_all_actions( 'solace_do_footer' );
	}
}
