| 1 |
<?php |
| 2 |
|
| 3 |
namespace HelloPlus\Modules\TemplateParts\Documents; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* class Header |
| 11 |
**/ |
| 12 |
class Ehp_Header extends Ehp_Document_Base { |
| 13 |
const LOCATION = 'header'; |
| 14 |
|
| 15 |
public static function get_template_hook(): string { |
| 16 |
return 'get_header'; |
| 17 |
} |
| 18 |
|
| 19 |
public static function get_type(): string { |
| 20 |
return 'ehp-header'; |
| 21 |
} |
| 22 |
|
| 23 |
public static function get_title(): string { |
| 24 |
return esc_html__( 'Hello+ Header', 'hello-plus' ); |
| 25 |
} |
| 26 |
|
| 27 |
public static function get_plural_title(): string { |
| 28 |
return esc_html__( 'Hello+ Headers', 'hello-plus' ); |
| 29 |
} |
| 30 |
|
| 31 |
protected static function get_site_editor_icon(): string { |
| 32 |
return 'eicon-header'; |
| 33 |
} |
| 34 |
|
| 35 |
public static function get_template( $name, $args ): void { |
| 36 |
require static::get_templates_path() . 'header.php'; |
| 37 |
|
| 38 |
$templates = []; |
| 39 |
$name = (string) $name; |
| 40 |
if ( '' !== $name ) { |
| 41 |
$templates[] = "header-{$name}.php"; |
| 42 |
} |
| 43 |
|
| 44 |
$templates[] = 'header.php'; |
| 45 |
|
| 46 |
// Avoid running wp_head hooks again |
| 47 |
remove_all_actions( 'wp_head' ); |
| 48 |
ob_start(); |
| 49 |
// It causes a `require_once` so, in the get_header itself it will not be required again. |
| 50 |
locate_template( $templates, true ); |
| 51 |
ob_get_clean(); |
| 52 |
} |
| 53 |
} |
| 54 |
|