<!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
/**
 * PWA Plugin compatibility.
 *
 * @package Solace\Compatibility
 */

namespace Solace\Compatibility;

/**
 * Class PWA
 */
class PWA {

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

		return true;
	}

	/**
	 * Decide if class should run.
	 */
	private function should_load() {
		return defined( 'PWA_VERSION' ) && function_exists( 'wp_service_worker_error_details_template' ) && function_exists( 'pwa_get_header' ) && function_exists( 'wp_service_worker_error_message_placeholder' ) && function_exists( 'pwa_get_footer' );
	}

	/**
	 * Load hooks.
	 */
	private function load_hooks() {
		add_action( 'solace_do_offline', array( $this, 'offline_default_template' ) );
		add_action( 'solace_do_server_error', array( $this, 'server_error_default_template' ) );
	}

	/**
	 * Load offline default template.
	 */
	public function offline_default_template() {
		?>
		<main>
			<h1><?php esc_html_e( 'Oops! It looks like you&#8217;re offline.', 'solace' ); ?></h1>
			<?php wp_service_worker_error_message_placeholder(); ?>
		</main>
		<?php
	}

	/**
	 * Load server error template.
	 */
	public function server_error_default_template() {

		?>
		<main>
			<h1><?php esc_html_e( 'Oops! Something went wrong.', 'solace' ); ?></h1>
			<?php wp_service_worker_error_message_placeholder(); ?>
			<?php wp_service_worker_error_details_template(); ?>
		</main>
		<?php
	}
}
