WP init
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Support all themes.
|
||||
*
|
||||
* @package header-footer-elementor
|
||||
*/
|
||||
|
||||
namespace HFE\Themes;
|
||||
|
||||
/**
|
||||
* Global theme compatibility.
|
||||
*/
|
||||
class Global_Theme_Compatibility {
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp', [ $this, 'hooks' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the Actions / Filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
// phpcs:ignore
|
||||
public function hooks(): void {
|
||||
if ( hfe_header_enabled() ) {
|
||||
// Replace header.php.
|
||||
add_action( 'get_header', [ $this, 'option_override_header' ] );
|
||||
|
||||
add_action( 'wp_body_open', [ 'Header_Footer_Elementor', 'get_header_content' ] );
|
||||
add_action( 'hfe_fallback_header', [ 'Header_Footer_Elementor', 'get_header_content' ] );
|
||||
}
|
||||
|
||||
if ( hfe_is_before_footer_enabled() ) {
|
||||
add_action( 'wp_footer', [ 'Header_Footer_Elementor', 'get_before_footer_content' ], 20 );
|
||||
}
|
||||
|
||||
if ( hfe_footer_enabled() ) {
|
||||
add_action( 'wp_footer', [ 'Header_Footer_Elementor', 'get_footer_content' ], 50 );
|
||||
}
|
||||
|
||||
if ( hfe_header_enabled() || hfe_footer_enabled() ) {
|
||||
add_action( 'wp_enqueue_scripts', [ $this, 'force_fullwidth' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force full width CSS for the header.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* // phpcs:ignore
|
||||
* @return void
|
||||
*/
|
||||
// phpcs:ignore
|
||||
public function force_fullwidth(): void {
|
||||
$css = '
|
||||
.force-stretched-header {
|
||||
width: 100vw;
|
||||
position: relative;
|
||||
margin-left: -50vw;
|
||||
left: 50%;
|
||||
}';
|
||||
|
||||
if ( true === hfe_header_enabled() ) {
|
||||
$css .= 'header#masthead {
|
||||
display: none;
|
||||
}';
|
||||
}
|
||||
|
||||
if ( true === hfe_footer_enabled() ) {
|
||||
$css .= 'footer#colophon {
|
||||
display: none;
|
||||
}';
|
||||
}
|
||||
|
||||
wp_add_inline_style( 'hfe-style', $css );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function overriding the header in the wp_body_open way.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* // phpcs:ignore
|
||||
* @return void
|
||||
*/
|
||||
// phpcs:ignore
|
||||
public function option_override_header(): void {
|
||||
$templates = [];
|
||||
$templates[] = 'header.php';
|
||||
locate_template( $templates, true );
|
||||
|
||||
if ( ! did_action( 'wp_body_open' ) ) {
|
||||
echo '<div class="force-stretched-header">';
|
||||
do_action( 'hfe_fallback_header' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
new Global_Theme_Compatibility();
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* HFE_Default_Compat setup
|
||||
*
|
||||
* @package header-footer-elementor
|
||||
*/
|
||||
|
||||
namespace HFE\Themes;
|
||||
|
||||
/**
|
||||
* Astra theme compatibility.
|
||||
*/
|
||||
class HFE_Default_Compat {
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp', [ $this, 'hooks' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the Actions / Filters.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* // phpcs:ignore
|
||||
*/
|
||||
// phpcs:ignore
|
||||
public function hooks(): void {
|
||||
if ( hfe_header_enabled() ) {
|
||||
// Replace header.php template.
|
||||
add_action( 'get_header', [ $this, 'override_header' ] );
|
||||
|
||||
// Display HFE's header in the replaced header.
|
||||
add_action( 'hfe_header', 'hfe_render_header' );
|
||||
}
|
||||
|
||||
if ( hfe_footer_enabled() || hfe_is_before_footer_enabled() ) {
|
||||
// Replace footer.php template.
|
||||
add_action( 'get_footer', [ $this, 'override_footer' ] );
|
||||
}
|
||||
|
||||
if ( hfe_footer_enabled() ) {
|
||||
// Display HFE's footer in the replaced header.
|
||||
add_action( 'hfe_footer', 'hfe_render_footer' );
|
||||
}
|
||||
|
||||
if ( hfe_is_before_footer_enabled() ) {
|
||||
add_action( 'hfe_footer_before', [ 'Header_Footer_Elementor', 'get_before_footer_content' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for overriding the header in the elmentor way.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* // phpcs:ignore
|
||||
* @return void
|
||||
*/
|
||||
// phpcs:ignore
|
||||
public function override_header(): void {
|
||||
require HFE_DIR . 'themes/default/hfe-header.php';
|
||||
$templates = [];
|
||||
$templates[] = 'header.php';
|
||||
// Avoid running wp_head hooks again.
|
||||
remove_all_actions( 'wp_head' );
|
||||
ob_start();
|
||||
locate_template( $templates, true );
|
||||
ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for overriding the footer in the elmentor way.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* // phpcs:ignore
|
||||
*/
|
||||
// phpcs:ignore
|
||||
public function override_footer(): void {
|
||||
require HFE_DIR . 'themes/default/hfe-footer.php';
|
||||
$templates = [];
|
||||
$templates[] = 'footer.php';
|
||||
// Avoid running wp_footer hooks again.
|
||||
remove_all_actions( 'wp_footer' );
|
||||
ob_start();
|
||||
locate_template( $templates, true );
|
||||
ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
new HFE_Default_Compat();
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Footer file in case of the elementor way
|
||||
*
|
||||
* @package header-footer-elementor
|
||||
* @since 1.2.0
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<?php do_action( 'hfe_footer_before' ); ?>
|
||||
<?php do_action( 'hfe_footer' ); ?>
|
||||
</div><!-- #page -->
|
||||
<?php wp_footer(); ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Header file in case of the elementor way
|
||||
*
|
||||
* @package header-footer-elementor
|
||||
* @since 1.2.0
|
||||
*/
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
||||
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
|
||||
<body <?php body_class(); ?>>
|
||||
<?php do_action( 'wp_body_open' ); ?>
|
||||
<div id="page" class="hfeed site">
|
||||
|
||||
<?php do_action( 'hfe_header' ); ?>
|
||||
Reference in New Issue
Block a user