class-hfe-astra-compat.php
86 lines
| 1 | <?php |
| 2 | /** |
| 3 | * HFE_Astra_Compat setup |
| 4 | * |
| 5 | * @package header-footer-elementor |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Astra theme compatibility. |
| 10 | */ |
| 11 | class HFE_Astra_Compat { |
| 12 | |
| 13 | /** |
| 14 | * Instance of HFE_Astra_Compat. |
| 15 | * |
| 16 | * @var HFE_Astra_Compat |
| 17 | */ |
| 18 | private static $instance; |
| 19 | |
| 20 | /** |
| 21 | * Initiator |
| 22 | * |
| 23 | * @return HFE_Astra_Compat |
| 24 | */ |
| 25 | public static function instance() { |
| 26 | if ( ! isset( self::$instance ) ) { |
| 27 | self::$instance = new HFE_Astra_Compat(); |
| 28 | |
| 29 | add_action( 'wp', [ self::$instance, 'hooks' ] ); |
| 30 | } |
| 31 | |
| 32 | return self::$instance; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Run all the Actions / Filters. |
| 37 | * |
| 38 | * @return void |
| 39 | */ |
| 40 | public function hooks() { |
| 41 | if ( hfe_header_enabled() ) { |
| 42 | add_action( 'template_redirect', [ $this, 'astra_setup_header' ], 10 ); |
| 43 | add_action( 'astra_header', 'hfe_render_header' ); |
| 44 | } |
| 45 | |
| 46 | if ( hfe_footer_enabled() ) { |
| 47 | add_action( 'template_redirect', [ $this, 'astra_setup_footer' ], 10 ); |
| 48 | add_action( 'astra_footer', 'hfe_render_footer' ); |
| 49 | } |
| 50 | |
| 51 | if ( hfe_is_before_footer_enabled() ) { |
| 52 | add_action( 'astra_footer_before', 'hfe_render_before_footer' ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Disable header from the theme. |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | public function astra_setup_header() { |
| 62 | remove_action( 'astra_header', 'astra_header_markup' ); |
| 63 | |
| 64 | // Remove the new header builder action. |
| 65 | if ( class_exists( 'Astra_Builder_Helper' ) && Astra_Builder_Helper::$is_header_footer_builder_active ) { |
| 66 | remove_action( 'astra_header', [ Astra_Builder_Header::get_instance(), 'prepare_header_builder_markup' ] ); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Disable footer from the theme. |
| 72 | * |
| 73 | * @return void |
| 74 | */ |
| 75 | public function astra_setup_footer() { |
| 76 | remove_action( 'astra_footer', 'astra_footer_markup' ); |
| 77 | |
| 78 | // Remove the new footer builder action. |
| 79 | if ( class_exists( 'Astra_Builder_Helper' ) && Astra_Builder_Helper::$is_header_footer_builder_active ) { |
| 80 | remove_action( 'astra_footer', [ Astra_Builder_Footer::get_instance(), 'footer_markup' ] ); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | HFE_Astra_Compat::instance(); |
| 86 |