PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
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 / abstract-compatibility-base.php

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

90 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocksThemeBuilder;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocksThemeBuilder\Traits\RenderContent;
9
10 abstract class AbstractCompatibilityBase {
11 use RenderContent;
12 protected $theme;
13 protected $header_hook = 'ablocks/templates/theme_builder/header';
14 protected $footer_hook = 'ablocks/templates/theme_builder/footer';
15 protected $before_footer_hook = 'ablocks/templates/theme_builder/footer';
16
17 public function __construct( $theme ) {
18 $this->theme = $theme;
19 }
20
21 public function init() {
22 // Header
23 if ( $this->enabled_header() ) {
24 add_action( 'get_header', [ $this, 'header_template' ] );
25 add_action( $this->header_hook, [ $this, 'render_header' ] );
26 }
27
28 // Footer
29 $enabled_footer = $this->enabled_footer();
30 $enabled_before_footer = $this->enabled_before_footer();
31 if ( $enabled_footer || $enabled_before_footer ) {
32 add_action( 'get_footer', [ $this, 'footer_template' ] );
33 }
34 // Before Footer
35 if ( $enabled_before_footer ) {
36 add_action( $this->before_footer_hook, [ $this, 'render_before_footer' ], 5 );
37 }
38 if ( $enabled_footer ) {
39 add_action( $this->footer_hook, [ $this, 'render_footer' ] );
40 }
41
42 }
43
44 public function enabled_header() {
45 return $this->get_settings( 'header' );
46 }
47
48 public function enabled_footer() {
49 return $this->get_settings( 'footer' );
50 }
51
52 public function enabled_before_footer() {
53 return $this->get_settings( 'before-footer' );
54 }
55
56 public function get_settings( $type ) {
57 return Helper::get_template_id( $type );
58 }
59
60 public function header_template() {
61 require ABLOCKS_ROOT_DIR_PATH . $this->get_template_path( 'header.php' );
62 $templates = [];
63 $templates[] = 'header.php';
64 // Avoid running wp_head hooks again.
65 remove_all_actions( 'wp_head' );
66 ob_start();
67 locate_template( $templates, true );
68 ob_get_clean();
69 }
70 public function footer_template() {
71 require ABLOCKS_ROOT_DIR_PATH . $this->get_template_path( 'footer.php' );
72 $templates = [];
73 $templates[] = 'footer.php';
74 // Avoid running wp_footer hooks again.
75 remove_all_actions( 'wp_footer' );
76 ob_start();
77 locate_template( $templates, true );
78 ob_get_clean();
79 }
80
81 public function get_template_path( $suffix ) {
82 $prefix = ! empty( $this->theme ) ? "{$this->theme}-" : '';
83 return "templates/theme-builder/{$prefix}{$suffix}";
84 }
85 // To be overridden by specific themes
86 abstract public function render_header();
87 abstract public function render_footer();
88 abstract public function render_before_footer();
89 }
90