File: /var/www/html/wp-content/plugins/ethnic-home-splash-control.php
<?php
/**
* Plugin Name: Ethnic Home Splash Control
* Description: Refines the homepage splash timing and hides the header while the intro is visible.
* Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'ethnic_home_splash_control_is_home' ) ) {
function ethnic_home_splash_control_is_home() {
return ! is_admin() && is_front_page();
}
}
if ( ! function_exists( 'ethnic_home_splash_control_bootstrap' ) ) {
function ethnic_home_splash_control_bootstrap() {
if ( ! ethnic_home_splash_control_is_home() ) {
return;
}
?>
<script id="ethnic-home-splash-bootstrap">
document.documentElement.classList.add('ethnic-home-splash-pending');
</script>
<?php
}
add_action( 'wp_head', 'ethnic_home_splash_control_bootstrap', 1 );
}
if ( ! function_exists( 'ethnic_home_splash_control_assets' ) ) {
function ethnic_home_splash_control_assets() {
if ( ! ethnic_home_splash_control_is_home() ) {
return;
}
$css = <<<'CSS'
html.ethnic-home-splash-pending body.page-id-1157 #site-header,
html.ethnic-home-splash-pending body.page-id-1157 .header-sticky-template,
body.page-id-1157.ethnic-home-intro-lock #site-header,
body.page-id-1157.ethnic-home-intro-lock .header-sticky-template {
display: none !important;
}
html.ethnic-home-splash-pending body.page-id-1157 .gdpr-consent-bar,
html.ethnic-home-splash-pending body.page-id-1157 .gdpr-privacy-preferences,
body.page-id-1157.ethnic-home-intro-lock .gdpr-consent-bar,
body.page-id-1157.ethnic-home-intro-lock .gdpr-privacy-preferences {
display: none !important;
}
html.ethnic-home-splash-pending body.page-id-1157 .ethnic-home-hero__intro-overlay,
body.page-id-1157 .ethnic-home-hero__intro-overlay {
position: fixed;
inset: 0;
min-height: 100vh;
z-index: 999998;
transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1), transform 300ms cubic-bezier(0.22, 1, 0.36, 1), filter 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
body.page-id-1157.admin-bar .ethnic-home-hero__intro-overlay {
top: 32px;
min-height: calc(100vh - 32px);
}
@media screen and (max-width: 782px) {
body.page-id-1157.admin-bar .ethnic-home-hero__intro-overlay {
top: 46px;
min-height: calc(100vh - 46px);
}
}
@media (prefers-reduced-motion: reduce) {
body.page-id-1157 .ethnic-home-hero__intro-overlay {
transition: none !important;
}
}
CSS;
wp_add_inline_style( 'ethnic-home-hero', $css );
$js = <<<'JS'
(function () {
var overlay = document.querySelector('[data-intro-overlay]');
if (!overlay) {
document.documentElement.classList.remove('ethnic-home-splash-pending');
return;
}
overlay.dataset.introDuration = '2700';
if (document.body) {
document.body.classList.add('ethnic-home-intro-lock');
}
document.documentElement.classList.remove('ethnic-home-splash-pending');
})();
JS;
wp_add_inline_script( 'ethnic-home-hero', $js, 'before' );
}
add_action( 'wp_enqueue_scripts', 'ethnic_home_splash_control_assets', 40 );
}
$ethnic_single_post_layout_bootstrap = __DIR__ . '/ethnic-single-post-layout/bootstrap.php';
if ( file_exists( $ethnic_single_post_layout_bootstrap ) ) {
require_once $ethnic_single_post_layout_bootstrap;
}