File: /mnt/data/dreamsrent-wp-demo/wp-content/themes/dreamsrent/templates/header/header-normal.php
<!DOCTYPE html>
<html <?php language_attributes(); ?> >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
<link rel="profile" href="//gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<?php
// Check if Redux Framework is active
if (in_array('redux-framework/redux-framework.php', apply_filters('active_plugins', get_option('active_plugins')))) {
// Get main and mobile logos using Redux Framework
$main_logo = dreamsrent_fl_framework_getoptions('frontend_logo');
$main_logo_url = isset($main_logo) && $main_logo != '' ? $main_logo['url'] : '';
$mobile_logo = dreamsrent_fl_framework_getoptions('small_logo');
$mobile_logo_url = isset($mobile_logo) && $mobile_logo != '' ? $mobile_logo['url'] : '';
} else {
// Fallback to default logos if Redux Framework is not active
$main_logo_url = get_template_directory_uri() . '/assets/images/logo.svg';
$mobile_logo_url = get_template_directory_uri() . '/assets/images/logo-small.png';
}
?>
<header class="header">
<div class="container-fluid">
<nav class="navbar navbar-expand-lg header-nav">
<div class="navbar-header">
<!-- Mobile Menu Button -->
<a id="mobile_btn" href="javascript:void(0);">
<span class="bar-icon">
<span></span>
<span></span>
<span></span>
</span>
</a>
<!-- Main Logo -->
<div class="navbar-brand logo">
<a href="<?php echo esc_url(home_url('/')); ?>" class="navbar-brand logo">
<img src="<?php echo esc_url($main_logo_url); ?>" class="img-fluid" alt="<?php echo get_bloginfo('name');?>">
</a>
</div>
<!-- Mobile Logo -->
<div class="navbar-brand logo-small">
<a href="<?php echo esc_url(home_url('/')); ?>" class="navbar-brand logo-small">
<img src="<?php echo esc_url($mobile_logo_url); ?>" class="img-fluid" alt="<?php echo get_bloginfo('name');?>">
</a>
</div>
</div>
<!-- Main Menu -->
<div class="main-menu-wrapper">
<?php
global $dreamsrent_theme_options;
ob_start();
?>
<?php
?>
<div class="menu-header">
<a href="<?php echo esc_url(home_url('/')); ?>" class="menu-logo">
<img src="<?php echo esc_url($main_logo_url); ?>" class="img-fluid" alt="<?php echo get_bloginfo('name');?>">
</a>
<a id="menu_close" class="menu-close" href="javascript:void(0);"> <i class="fas fa-times"></i></a>
</div>
<div class="collapse navbar-collapse" id="mainmenu">
<?php
if ( has_nav_menu( 'primary' ) ) {
wp_nav_menu(array(
'menu' => '',
'theme_location' => 'primary',
'depth' => 3,
'container' => '',
'container_class' => '',
'container_id' => '',
'menu_class' => 'navbar-nav main-nav',
'fallback_cb' => 'dreamsrent_wp_bootstrap_navwalker::fallback',
'walker' => new dreamsrent_wp_bootstrap_navwalker()
)); } else {
wp_nav_menu( array(
'menu_id' => 'primary',
'menu_class' => 'navbar-nav main-nav',
'fallback_cb' => 'dreamsrent_wp_bootstrap_navwalker::fallback',
'walker' => new dreamsrent_wp_bootstrap_navwalker()
) );
}
?>
</div>
<?php
if(in_array('redux-framework/redux-framework.php', apply_filters('active_plugins', get_option('active_plugins'))))
{
$booking_options = dreamsrent_fl_framework_getoptions('booking_options');
if($booking_options==true) {
?>
<?php if (is_user_logged_in()) { ?>
<?php } else { ?>
<?php
if (class_exists('Dreams_Core_Template_Loader')) :
$template_loader = new Dreams_Core_Template_Loader;
$template_loader->get_template_part('account/logged-section-mobile');
endif;
?>
<?php } } } ?>
</div>
<?php
if(in_array('redux-framework/redux-framework.php', apply_filters('active_plugins', get_option('active_plugins'))))
{
?>
<?php $booking_options = dreamsrent_fl_framework_getoptions('booking_options');
if($booking_options==true) { ?>
<!-- Additional Header Menu -->
<ul class="nav header-navbar-rht">
<?php if (is_user_logged_in()) { ?>
<!-- Notifications -->
<li class="nav-item dropdown logged-item noti-nav noti-wrapper">
<a href="#" id="notification-bell" class="dropdown-toggle nav-link" data-bs-toggle="dropdown">
<span class="bell-icon">
<img src="<?php echo esc_url(get_template_directory_uri());?>/assets/images/bell-icon.svg" alt="Bell">
</span>
<span class="badge badge-pill"></span>
</a>
<div class="dropdown-menu notifications">
<div class="topnav-dropdown-header">
<span class="notification-title"><?php echo esc_html__('Notifications', 'dreamsrent'); ?></span>
<a href="javascript:void(0)" class="clear-noti"> <?php echo esc_html__('Clear All', 'dreamsrent'); ?> </a>
</div>
<div id="notification-dropdown">
<?php
global $wpdb;
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$role = array_shift($roles);
$table_name = $wpdb->prefix . 'user_notifications';
// Retrieve the latest 5 unread notifications for the user
if (in_array($role, array('administrator', 'dreamsrent_vendor'))) {
$notifications = $wpdb->get_results($wpdb->prepare(
"SELECT * FROM $table_name WHERE owner_id = %d AND is_read = 0 ORDER BY created_at DESC LIMIT 10",
$user_id
));
} else if(in_array($role, array('subscriber'))) {
$notifications = $wpdb->get_results($wpdb->prepare(
"SELECT * FROM $table_name WHERE user_id = %d AND user_read = 0 ORDER BY created_at DESC LIMIT 10",
$user_id
));
}
?>
<div class="noti-content">
<ul class="notification-list">
<?php if (isset($notifications) && $notifications): ?>
<?php foreach ($notifications as $notification): ?>
<li class="notification-message">
<a href="#">
<div class="media d-flex">
<span class="avatar avatar-lg flex-shrink-0">
<?php
if (in_array($role, array('administrator', 'dreamsrent_vendor'))) {
$profile_picture_url = get_user_meta($notification->user_id, 'profile_picture', true);
} else if(in_array($role, array('subscriber'))) {
$profile_picture_url = get_user_meta($notification->owner_id, 'profile_picture', true);
}
$profile_picture_url_default = get_template_directory_uri() . '/assets/images/user_image.jpg';
?>
<?php if($profile_picture_url) { ?>
<img class="avatar-img rounded-circle" alt="User Image" src="<?php echo esc_html($profile_picture_url); ?>">
<?php } else { ?>
<img class="avatar-img rounded-circle" alt="User Image" src="<?php echo esc_html($profile_picture_url_default); ?>">
<?php } ?>
</span>
<div class="media-body flex-grow-1">
<?php
$user_data = get_userdata($notification->user_id);
$order_id = $notification->order_id;
if (!function_exists('get_first_product_name_by_order_id')) {
function get_first_product_name_by_order_id($order_id) {
// Load the WooCommerce order object
$order = wc_get_order($order_id);
if (!$order) {
return ''; // Return an empty string if the order doesn't exist
}
// Get the first item in the order
foreach ($order->get_items() as $item) {
return $item->get_name(); // Return the first product name
}
return ''; // Return an empty string if there are no items
}
}
// Example usage:
$product_name = get_first_product_name_by_order_id($order_id);
$user_first_name = $user_data ? $user_data->first_name : '';
$user_last_name = $user_data ? $user_data->last_name : '';
?>
<?php if($notification->type=='order_placed') { ?>
<p class="noti-details">
<?php if (in_array($role, array('administrator', 'dreamsrent_vendor'))) { ?>
<span class="noti-title"><?php echo esc_html($user_first_name); ?> <?php echo esc_html__('has','dreamsrent'); ?></span>
<?php } else if(in_array($role, array('subscriber'))) { ?>
<span class="noti-title"><?php echo esc_html__('You have','dreamsrent'); ?></span>
<?php } ?>
<?php echo esc_html($notification->message); ?>
<?php if (in_array($role, array('administrator', 'dreamsrent_vendor'))) { ?>
<span class="noti-title"><?php echo esc_html__('your service','dreamsrent'); ?> - <?php if (!empty($product_name)) {
echo esc_html($product_name);
} ?> </span>
<?php } else if(in_array($role, array('subscriber'))) { ?>
<span class="noti-title"><?php echo esc_html__('service','dreamsrent'); ?> - <?php if (!empty($product_name)) {
echo esc_html($product_name);
} ?></span>
<?php } ?>
</p>
<?php } else if($notification->type=='order_canceled') { ?>
<p class="noti-details">
<?php if (in_array($role, array('administrator', 'dreamsrent_vendor'))) { ?>
<span class="noti-title"><?php echo esc_html($user_first_name); ?> <?php echo esc_html__('has','dreamsrent'); ?></span>
<?php echo esc_html($notification->message); ?> <span class="noti-title"><?php echo esc_html__('booking','dreamsrent'); ?> - <?php if (!empty($product_name)) {
echo esc_html($product_name);
} ?></span>
<?php } else if(in_array($role, array('subscriber'))) { ?>
<span class="noti-title"><?php echo esc_html__('You have','dreamsrent'); ?></span>
<?php echo esc_html($notification->message); ?> <span class="noti-title"><?php echo esc_html__('booking','dreamsrent'); ?> - <?php if (!empty($product_name)) {
echo esc_html($product_name);
} ?></span>
<?php } ?>
</p>
<?php } ?>
<p class="noti-time">
<span class="notification-time"><?php echo human_time_diff(strtotime($notification->created_at), current_time('timestamp')); ?> <?php echo esc_html__('ago', 'dreamsrent'); ?></span>
</p>
</div>
</div>
</a>
</li>
<?php endforeach; ?>
<?php else: ?>
<li class="notification-message">
<p><?php echo esc_html__('No new notifications.','dreamsrent'); ?></p>
</li>
<?php endif; ?>
</ul>
</div>
</div>
<div class="topnav-dropdown-footer">
<?php $notifications_page = dreamsrent_fl_framework_getoptions('notifications_page');
if ($notifications_page) {
?>
<a href="<?php echo esc_url(get_permalink($notifications_page)); ?>"><?php echo esc_html__('View all Notifications','dreamsrent'); ?></a> <?php } else { ?>
<a href="#"><?php echo esc_html__('Close','dreamsrent'); ?></a>
<?php } ?>
</div>
</div>
</li>
<!-- /Notifications -->
<?php } ?>
<?php if ( !WC()->cart->is_empty() ) : ?>
<li class="nav-item cart_icon">
<a href="<?php echo esc_url(wc_get_cart_url()); ?>" >
<!-- <i class="fa-solid fa-cart-shopping"></i> -->
<i class="feather-shopping-cart"></i>
<!-- <span class="badge badge-pill"></span> -->
</a>
</li>
<?php endif; ?>
<?php
$template_loader = new Dreams_Core_Template_Loader;
$template_loader->get_template_part('account/logged-section');
?>
</ul>
<?php } ?>
<?php } ?>
</nav>
</div>
<?php if (function_exists('display_notification_bell')) display_notification_bell(); ?>
</header>
<!-- Header ends here -->
<?php
// Check page type and display breadcrumbs accordingly
if (is_front_page()) {
} else if (is_home()) { ?>
<!-- Breadcrumb for Blog List -->
<div class="breadcrumb-bar">
<div class="container">
<div class="row align-items-center text-center">
<div class="col-md-12 col-12">
<h2 class="breadcrumb-title"><?php echo esc_html__('Blog List','dreamsrent' ); ?></h2>
<?php echo dreamsrent_breadcrumbs_header(); ?>
</div>
</div>
</div>
</div>
<?php } else if (function_exists('is_product') && is_product()) { ?>
<?php
// Check if breadcrumbs should be displayed for products
if (get_post_meta(dreamsrent_get_current_id(), 'dreamsrent_met_show_breadcrumbs', true) != 'no') { ?>
<!-- Breadcrumb for Products -->
<div class="breadcrumb-bar">
<div class="container">
<div class="row align-items-center text-center">
<div class="col-md-12 col-12">
<h2 class="breadcrumb-title"><?php echo esc_html__('Product','dreamsrent' ); ?></h2>
<?php
// Display WooCommerce breadcrumbs
$args = array(
'delimiter' => '',
'wrap_before' => '<ol class="breadcrumb">',
'wrap_after' => '</ol>',
'before' => '<li class="breadcrumb-item">',
'after' => '</li>',
);
echo woocommerce_breadcrumb($args);
?>
</div>
</div>
</div>
</div>
<?php } ?>
<?php } else if (is_single()) { ?>
<!-- Breadcrumb for Blog -->
<div class="breadcrumb-bar">
<div class="container">
<div class="row align-items-center text-center">
<div class="col-md-12 col-12">
<h2 class="breadcrumb-title"><?php echo single_post_title(); ?></h2>
<?php echo dreamsrent_breadcrumbs_header(); ?>
</div>
</div>
</div>
</div>
<?php } else if (is_search()) { ?>
<!-- Breadcrumb for Blog -->
<div class="breadcrumb-bar">
<div class="container">
<div class="row align-items-center text-center">
<div class="col-md-12 col-12">
<h2 class="breadcrumb-title"><?php echo esc_html__('Search query for:','dreamsrent' ); ?> <?php echo esc_html(get_search_query()); ?></h2>
<?php echo dreamsrent_breadcrumbs_header(); ?>
</div>
</div>
</div>
</div>
<?php } else { ?>
<?php
// Check if breadcrumbs should be displayed for other pages
if (get_post_meta(dreamsrent_get_current_id(), 'dreamsrent_met_show_breadcrumbs', true) != 'no') { ?>
<!-- Breadcrumb for Other Pages -->
<div class="breadcrumb-bar">
<div class="container">
<div class="row align-items-center text-center">
<div class="col-md-12 col-12">
<h2 class="breadcrumb-title"><?php echo dreamsrent_heading_title(); ?></h2>
<?php echo dreamsrent_breadcrumbs_header(); ?>
</div>
</div>
</div>
</div>
<?php } ?>
<?php } ?>