astra.php
4 years ago
bbtheme.php
4 years ago
generatepress.php
4 years ago
genesis.php
4 years ago
my-listing-functions.php
4 years ago
my-listing.php
4 years ago
neve.php
4 years ago
oceanwp.php
4 years ago
theme-support.php
4 years ago
twenty-nineteen.php
4 years ago
theme-support.php
62 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Modules\Header_Footer\Theme_Hooks; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | /** |
| 7 | * Force fully replace the header footer. |
| 8 | */ |
| 9 | class Theme_Support { |
| 10 | |
| 11 | |
| 12 | /** |
| 13 | * Run all the Actions / Filters. |
| 14 | */ |
| 15 | function __construct( $template_ids ) { |
| 16 | if ( $template_ids[0] != null ) { |
| 17 | add_action( 'get_header', array( $this, 'get_header' ) ); |
| 18 | } |
| 19 | if ( $template_ids[1] != null ) { |
| 20 | add_action( 'get_footer', array( $this, 'get_footer' ) ); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public function get_header( $name ) { |
| 25 | require __DIR__ . '/../views/theme-support-header.php'; |
| 26 | |
| 27 | $templates = array(); |
| 28 | $name = (string) $name; |
| 29 | if ( '' !== $name ) { |
| 30 | $templates[] = "header-{$name}.php"; |
| 31 | } |
| 32 | |
| 33 | $templates[] = 'header.php'; |
| 34 | |
| 35 | // Avoid running wp_head hooks again |
| 36 | remove_all_actions( 'wp_head' ); |
| 37 | ob_start(); |
| 38 | // It cause a `require_once` so, in the get_header it self it will not be required again. |
| 39 | locate_template( $templates, true ); |
| 40 | ob_get_clean(); |
| 41 | } |
| 42 | |
| 43 | public function get_footer( $name ) { |
| 44 | require __DIR__ . '/../views/theme-support-footer.php'; |
| 45 | |
| 46 | $templates = array(); |
| 47 | $name = (string) $name; |
| 48 | if ( '' !== $name ) { |
| 49 | $templates[] = "footer-{$name}.php"; |
| 50 | } |
| 51 | |
| 52 | $templates[] = 'footer.php'; |
| 53 | |
| 54 | ob_start(); |
| 55 | // It cause a `require_once` so, in the get_header it self it will not be required again. |
| 56 | locate_template( $templates, true ); |
| 57 | ob_get_clean(); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | } |
| 62 |