| @@ -10,31 +10,41 @@ | ||
| 10 | 10 | class Astra extends AbstractCompatibilityBase { |
| 11 | 11 | protected $header_hook = 'astra_header'; |
| 12 | 12 | protected $footer_hook = 'astra_footer'; |
| 13 | 13 | protected $before_footer_hook = 'astra_footer_before'; |
| 14 | + protected $enabled_header; | |
| 15 | + protected $enabled_before_footer; | |
| 16 | + protected $enabled_footer; | |
| 14 | 17 | |
| 15 | 18 | public function init() { |
| 19 | + $this->enabled_header = $this->enabled_header(); | |
| 16 | 20 | // Header |
| 17 | - if ( $this->enabled_header() ) { | |
| 21 | + if ( $this->enabled_header ) { | |
| 18 | 22 | add_action( 'template_redirect', [ $this, 'astra_setup_header' ], 10 ); |
| 19 | 23 | add_action( $this->header_hook, [ $this, 'render_header' ] ); |
| 20 | 24 | } |
| 21 | 25 | |
| 22 | 26 | // Footer |
| 23 | - $enabled_footer = $this->enabled_footer(); | |
| 24 | - $enabled_before_footer = $this->enabled_before_footer(); | |
| 25 | - if ( $enabled_footer || $enabled_before_footer ) { | |
| 27 | + $this->enabled_footer = $this->enabled_footer(); | |
| 28 | + $this->enabled_before_footer = $this->enabled_before_footer(); | |
| 29 | + | |
| 30 | + if ( $this->enabled_footer || $this->enabled_before_footer ) { | |
| 26 | 31 | add_action( 'template_redirect', [ $this, 'astra_setup_footer' ], 10 ); |
| 27 | 32 | } |
| 28 | 33 | |
| 29 | - if ( $this->enabled_before_footer() ) { | |
| 34 | + if ( $this->enabled_before_footer ) { | |
| 30 | 35 | add_action( $this->before_footer_hook, [ $this, 'render_before_footer' ] ); |
| 31 | 36 | } |
| 32 | 37 | |
| 33 | - if ( $this->enabled_footer() ) { | |
| 38 | + if ( $this->enabled_footer ) { | |
| 34 | 39 | add_action( $this->footer_hook, [ $this, 'render_footer' ] ); |
| 35 | 40 | } |
| 36 | 41 | |
| 42 | + do_action('ablocks_theme_builder_after_dispatch', [ | |
| 43 | + 'header' => $this->enabled_header, | |
| 44 | + 'before_footer' => $this->enabled_before_footer, | |
| 45 | + 'footer' => $this->enabled_footer, | |
| 46 | + ]); | |
| 37 | 47 | } |
| 38 | 48 | |
| 39 | 49 | public function astra_setup_header() { |
| 40 | 50 | remove_action( 'astra_header', 'astra_header_markup' ); |
| @@ -54,15 +64,18 @@ | ||
| 54 | 64 | } |
| 55 | 65 | } |
| 56 | 66 | |
| 57 | 67 | public function render_header() { |
| 68 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 58 | 69 | echo $this->get_rendered_block_content_by_id( $this->get_settings( 'header' ) ); |
| 59 | 70 | } |
| 60 | 71 | |
| 61 | 72 | public function render_footer() { |
| 73 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 62 | 74 | echo $this->get_rendered_block_content_by_id( $this->get_settings( 'footer' ) ); |
| 63 | 75 | } |
| 64 | 76 | |
| 65 | 77 | public function render_before_footer() { |
| 78 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 66 | 79 | echo $this->get_rendered_block_content_by_id( $this->get_settings( 'before-footer' ) ); |
| 67 | 80 | } |
| 68 | 81 | } |