File: /home/centuryt/public_html/wp-content/themes/emoza-woocommerce/inc/classes/class-emoza-topbar.php
<?php
/**
* Header class class
*
* @package Emoza
*/
if ( !class_exists( 'Emoza_Top_Bar' ) ) :
Class Emoza_Top_Bar {
/**
* Instance
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
add_action( 'emoza_header', array( $this, 'topbar_markup' ), 5 );
}
/**
* Desktop header markup
*/
public function topbar_markup() {
$enable = get_theme_mod( 'enable_top_bar', 0 );
if ( !$enable ) {
return;
}
$container = get_theme_mod( 'topbar_container', 'container-fluid' );
$visibility = get_theme_mod( 'topbar_visibility', 'desktop-only' );
$delimiter = get_theme_mod( 'topbar_delimiter', 'none' );
?>
<div class="top-bar visibility-<?php echo esc_attr( $visibility ); ?>">
<div class="<?php echo esc_attr( $container ); ?>">
<div class="top-bar-inner">
<div class="row valign">
<div class="col header-elements delimiter-<?php echo esc_attr( $delimiter ); ?>">
<?php $this->render_components( 'left' ); ?>
</div>
<div class="col header-elements delimiter-<?php echo esc_attr( $delimiter ); ?>">
<?php $this->render_components( 'right' ); ?>
</div>
</div>
</div>
</div>
</div>
<?php
}
/**
* Render header components
*/
public function render_components( $location ) {
$defaults = emoza_get_default_topbar_components();
$components = get_theme_mod( 'topbar_components_' . $location, $defaults[$location] );
foreach ( $components as $component ) {
call_user_func( array( $this, $component ) );
}
}
/**
* Contact info
*/
public function contact_info() {
$email = get_theme_mod( 'topbar_contact_mail', esc_html__( 'office@example.org', 'emoza-woocommerce' ) );
$phone = get_theme_mod( 'topbar_contact_phone', esc_html__( '111222333', 'emoza-woocommerce' ) );
?>
<div class="header-item top-bar-contact">
<?php if ( $email ) : ?>
<a href="mailto:<?php echo esc_attr( antispambot( $email ) ); ?>"><i class="ws-svg-icon"><?php emoza_get_svg_icon( 'icon-mail', true ); ?></i><?php echo esc_html( antispambot( $email ) ); ?></a>
<?php endif; ?>
<?php if ( $phone ) : ?>
<a href="tel:<?php echo esc_attr( $phone ); ?>"><i class="ws-svg-icon"><?php emoza_get_svg_icon( 'icon-phone', true ); ?></i><?php echo esc_html( $phone ); ?></a>
<?php endif; ?>
</div>
<?php
}
/**
* Text
*/
public function text() {
$text = get_theme_mod( 'topbar_text', esc_html__( 'Your text here', 'emoza-woocommerce' ) );
?>
<div class="header-item">
<?php echo wp_kses_post( $text ); ?>
</div>
<?php
}
/**
* Social
*/
public function social() {
echo '<div class="header-item">';
emoza_social_profile( 'social_profiles_topbar' );
echo '</div>';
}
/**
* Secondary menu
*/
public function secondary_nav() {
if ( function_exists('max_mega_menu_is_enabled') && max_mega_menu_is_enabled( 'secondary' ) ) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'secondary') ); ?>
<?php else: ?>
<nav class="header-item secondary-navigation">
<?php
wp_nav_menu( array(
'theme_location'=> 'secondary',
'menu_id' => 'secondary',
'fallback_cb' => false,
'depth' => 1
) );
?>
</nav>
<?php endif;
}
}
/**
* Initialize class
*/
Emoza_Top_Bar::get_instance();
endif;