PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / addons / theme-builder / compatibility / astra.php

astra.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.0, at addons/theme-builder/compatibility/astra.php

82 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocksThemeBuilder\Compatibility;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocksThemeBuilder\AbstractCompatibilityBase;
9
10 class Astra extends AbstractCompatibilityBase {
11 protected $header_hook = 'astra_header';
12 protected $footer_hook = 'astra_footer';
13 protected $before_footer_hook = 'astra_footer_before';
14 protected $enabled_header;
15 protected $enabled_before_footer;
16 protected $enabled_footer;
17
18 public function init() {
19 $this->enabled_header = $this->enabled_header();
20 // Header
21 if ( $this->enabled_header ) {
22 add_action( 'template_redirect', [ $this, 'astra_setup_header' ], 10 );
23 add_action( $this->header_hook, [ $this, 'render_header' ] );
24 }
25
26 // 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 ) {
31 add_action( 'template_redirect', [ $this, 'astra_setup_footer' ], 10 );
32 }
33
34 if ( $this->enabled_before_footer ) {
35 add_action( $this->before_footer_hook, [ $this, 'render_before_footer' ] );
36 }
37
38 if ( $this->enabled_footer ) {
39 add_action( $this->footer_hook, [ $this, 'render_footer' ] );
40 }
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 ]);
47 }
48
49 public function astra_setup_header() {
50 remove_action( 'astra_header', 'astra_header_markup' );
51
52 // Remove the new header builder action.
53 if ( class_exists( 'Astra_Builder_Helper' ) && \Astra_Builder_Helper::$is_header_footer_builder_active ) {
54 remove_action( 'astra_header', [ \Astra_Builder_Header::get_instance(), 'prepare_header_builder_markup' ] );
55 }
56 }
57
58 public function astra_setup_footer() {
59 remove_action( 'astra_footer', 'astra_footer_markup' );
60
61 // Remove the new footer builder action.
62 if ( class_exists( 'Astra_Builder_Helper' ) && \Astra_Builder_Helper::$is_header_footer_builder_active ) {
63 remove_action( 'astra_footer', [ \Astra_Builder_Footer::get_instance(), 'footer_markup' ] );
64 }
65 }
66
67 public function render_header() {
68 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
69 echo $this->get_rendered_block_content_by_id( $this->get_settings( 'header' ) );
70 }
71
72 public function render_footer() {
73 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
74 echo $this->get_rendered_block_content_by_id( $this->get_settings( 'footer' ) );
75 }
76
77 public function render_before_footer() {
78 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
79 echo $this->get_rendered_block_content_by_id( $this->get_settings( 'before-footer' ) );
80 }
81 }
82