class-global-theme-compatibility.php
1 year ago
class-hfe-default-compat.php
1 year ago
hfe-footer.php
5 years ago
hfe-header.php
4 years ago
class-hfe-default-compat.php
97 lines
| 1 | <?php |
| 2 | /** |
| 3 | * HFE_Default_Compat setup |
| 4 | * |
| 5 | * @package header-footer-elementor |
| 6 | */ |
| 7 | |
| 8 | namespace HFE\Themes; |
| 9 | |
| 10 | /** |
| 11 | * Astra theme compatibility. |
| 12 | */ |
| 13 | class HFE_Default_Compat { |
| 14 | |
| 15 | /** |
| 16 | * Initiator |
| 17 | */ |
| 18 | public function __construct() { |
| 19 | add_action( 'wp', [ $this, 'hooks' ] ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Run all the Actions / Filters. |
| 24 | * |
| 25 | * @return void |
| 26 | * |
| 27 | * // phpcs:ignore |
| 28 | */ |
| 29 | // phpcs:ignore |
| 30 | public function hooks(): void { |
| 31 | if ( hfe_header_enabled() ) { |
| 32 | // Replace header.php template. |
| 33 | add_action( 'get_header', [ $this, 'override_header' ] ); |
| 34 | |
| 35 | // Display HFE's header in the replaced header. |
| 36 | add_action( 'hfe_header', 'hfe_render_header' ); |
| 37 | } |
| 38 | |
| 39 | if ( hfe_footer_enabled() || hfe_is_before_footer_enabled() ) { |
| 40 | // Replace footer.php template. |
| 41 | add_action( 'get_footer', [ $this, 'override_footer' ] ); |
| 42 | } |
| 43 | |
| 44 | if ( hfe_footer_enabled() ) { |
| 45 | // Display HFE's footer in the replaced header. |
| 46 | add_action( 'hfe_footer', 'hfe_render_footer' ); |
| 47 | } |
| 48 | |
| 49 | if ( hfe_is_before_footer_enabled() ) { |
| 50 | add_action( 'hfe_footer_before', [ 'Header_Footer_Elementor', 'get_before_footer_content' ] ); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Function for overriding the header in the elmentor way. |
| 56 | * |
| 57 | * @since 1.2.0 |
| 58 | * |
| 59 | * // phpcs:ignore |
| 60 | * @return void |
| 61 | */ |
| 62 | // phpcs:ignore |
| 63 | public function override_header(): void { |
| 64 | require HFE_DIR . 'themes/default/hfe-header.php'; |
| 65 | $templates = []; |
| 66 | $templates[] = 'header.php'; |
| 67 | // Avoid running wp_head hooks again. |
| 68 | remove_all_actions( 'wp_head' ); |
| 69 | ob_start(); |
| 70 | locate_template( $templates, true ); |
| 71 | ob_get_clean(); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Function for overriding the footer in the elmentor way. |
| 76 | * |
| 77 | * @since 1.2.0 |
| 78 | * |
| 79 | * @return void |
| 80 | * |
| 81 | * // phpcs:ignore |
| 82 | */ |
| 83 | // phpcs:ignore |
| 84 | public function override_footer(): void { |
| 85 | require HFE_DIR . 'themes/default/hfe-footer.php'; |
| 86 | $templates = []; |
| 87 | $templates[] = 'footer.php'; |
| 88 | // Avoid running wp_footer hooks again. |
| 89 | remove_all_actions( 'wp_footer' ); |
| 90 | ob_start(); |
| 91 | locate_template( $templates, true ); |
| 92 | ob_get_clean(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | new HFE_Default_Compat(); |
| 97 |