Current File : /var/www/kurt6690.2978.w2868/site96340/wp-content/themes/hopeui/inc/Custom_Header/Component.php |
<?php
/**
* HopeUI\Utility\Custom_Header\Component class
*
* @package hopeui
*/
namespace HopeUI\Utility\Custom_Header;
use HopeUI\Utility\Component_Interface;
use function add_action;
use function add_theme_support;
use function apply_filters;
use function get_header_textcolor;
use function get_theme_support;
use function display_header_text;
/**
* Class for adding custom header support.
*
* @link https://developer.wordpress.org/themes/functionality/custom-headers/
*/
class Component implements Component_Interface {
/**
* Gets the unique identifier for the theme component.
*
* @return string Component slug.
*/
public function get_slug() : string {
return 'custom_header';
}
/**
* Adds the action and filter hooks to integrate with WordPress.
*/
public function initialize() {
add_action( 'after_setup_theme', array( $this, 'action_add_custom_header_support' ) );
}
/**
* Adds support for the Custom Logo feature.
*/
public function action_add_custom_header_support() {
add_theme_support(
'custom-header',
apply_filters(
'hopeui_custom_header_args',
array(
'default-image' => '',
'default-text-color' => '000000',
'width' => 1600,
'height' => 250,
'flex-height' => true,
'wp-head-callback' => array( $this, 'wp_head_callback' ),
)
)
);
}
/**
* Outputs extra styles for the custom header, if necessary.
*/
public function wp_head_callback() {
$header_text_color = get_header_textcolor();
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
return;
}
if ( ! display_header_text() ) {
echo '<style>.site-title, .site-description { position: absolute; clip: rect(1px, 1px, 1px, 1px); }</style>';
return;
}
echo '<style>.site-title a, .site-description { color: #' . esc_attr( $header_text_color ) . '; }</style>';
}
}