File: /home/dh_5jabqq/bermudashipwreckarchive.com/wp-content/themes/loquet/includes/off-canvas.php
<?php
/*======
*
* Off Canvas
*
======*/
if( !function_exists( 'loquet_off_canvas' ) ) {
function loquet_off_canvas() {
/*====== Customizer Settings ======*/
$style = get_theme_mod( 'loquet_off_canvas_style', 'style-1' );
$skin = get_theme_mod( 'loquet_off_canvas_skin', 'light' );
$position = get_theme_mod( 'loquet_off_canvas_position', 'right' );
$animation = get_theme_mod( 'loquet_off_canvas_animation', 'false' );
$menu = get_theme_mod( 'loquet_off_canvas_menu', '1' );
$widgets = get_theme_mod( 'loquet_off_canvas_widgets', '1' );
$widgets_column = get_theme_mod( 'loquet_off_canvas_widgets_column', '1' );
$widgets_column_space = get_theme_mod( 'loquet_off_canvas_widgets_column_space', '45' );
$social_media = get_theme_mod( 'loquet_off_canvas_social_media', '1' );
$social_media_style = get_theme_mod( 'loquet_off_canvas_social_media_style', 'style-1' );
$social_media_size = get_theme_mod( 'loquet_off_canvas_social_media_size', 'size-m' );
$copyright = get_theme_mod( 'loquet_off_canvas_copyright' );
$copyright_text = get_theme_mod( 'loquet_off_canvas_copyright_text' );
if( $animation == "true" ) {
$animation_status = "on";
} else {
$animation_status = "off";
}
/*====== HTML Output ======*/
if( has_nav_menu( 'off-canvas-menu' ) or $widgets == "1" and is_active_sidebar( 'loquet-off-canvas-sidebar' ) ) {
if( $style == "style-1" ) {
echo '<div class="gt-off-canvas gt-' . esc_attr( $style ) . ' gt-position-' . esc_attr( $position ) . ' gt-' . esc_attr( $skin ) . ' gt-animation-' . esc_attr( $animation_status ) . '" data-simplebar>';
echo '<div class="gt-off-canvas-header">';
echo '<div class="gt-close">';
echo '<svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>';
echo '</div>';
if( $social_media == "1" ) {
if( function_exists( 'loquet_social_media_sites' ) ) {
echo '<div class="gt-social-links">';
echo loquet_social_media_links( $class = "", $style = esc_attr( $social_media_style ), $skin = esc_attr( $skin ), $size = esc_attr( $social_media_size ) );
echo '</div>';
}
}
echo '</div>';
echo '<div class="gt-off-canvas-inner">';
if( $menu == "1" or $copyright == "1" ) {
echo '<div class="gt-off-canvas-left">';
if( $menu == "1" ) {
wp_nav_menu(
array(
'theme_location' => 'off-canvas-menu',
'container' => 'div',
'container_class' => 'gt-menu',
'menu_class' => 'gt-nav-menu',
'fallback_cb' => 'loquet_off_canvas_menu_walker::fallback',
'walker' => new loquet_off_canvas_menu_walker(),
'depth' => '3',
)
);
}
if( $copyright == "1" and !empty( $copyright_text ) ) {
echo '<div class="gt-copyright">';
echo wpautop( $copyright_text );
echo '</div>';
}
echo '</div>';
}
if( $widgets == "1" ) {
if( is_active_sidebar( 'loquet-off-canvas-sidebar' ) ) {
echo '<div class="gt-off-canvas-right">';
echo '<div class="gt-widgets">';
echo '<div class="gt-grid gt-grid-' . esc_attr( $widgets_column ) . ' gt-spacing-' . esc_attr( $widgets_column_space ) . '">';
dynamic_sidebar( 'loquet-off-canvas-sidebar' );
echo '</div>';
echo '</div>';
echo '</div>';
}
}
echo '</div>';
echo '</div>';
} elseif( $style == "style-2" ) {
echo '<div class="gt-off-canvas gt-' . esc_attr( $style ) . ' gt-position-' . esc_attr( $position ) . ' gt-' . esc_attr( $skin ) . ' gt-animation-' . esc_attr( $animation_status ) . '" data-simplebar>';
echo '<div class="gt-off-canvas-header">';
echo '<div class="gt-close">';
echo '<svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>';
echo '</div>';
if( $social_media == "1" ) {
if( function_exists( 'loquet_social_media_sites' ) ) {
echo '<div class="gt-social-links">';
echo loquet_social_media_links( $class = "", $style = esc_attr( $social_media_style ), $skin = esc_attr( $skin ), $size = esc_attr( $social_media_size ) );
echo '</div>';
}
}
echo '</div>';
echo '<div class="gt-off-canvas-inner">';
if( $menu == "1" ) {
wp_nav_menu(
array(
'theme_location' => 'off-canvas-menu',
'container' => 'div',
'container_class' => 'gt-menu',
'menu_class' => 'gt-nav-menu',
'depth' => '1',
)
);
}
if( $copyright == "1" and !empty( $copyright_text ) ) {
echo '<div class="gt-copyright">';
echo wpautop( $copyright_text );
echo '</div>';
}
echo '</div>';
echo '</div>';
}
echo '<div class="gt-overlay-opacity-bg"></div>';
}
}
add_action( 'wp_footer', 'loquet_off_canvas' );
}
/*======
*
* Off Canvas Menu Walker
*
======*/
if( !class_exists( 'loquet_off_canvas_menu_walker' ) ) {
class loquet_off_canvas_menu_walker extends Walker_Nav_Menu {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<div class=\"gt-submenu-wrap\"><div class=\"gt-back-toggle\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line><polyline points=\"12 19 5 12 12 5\"></polyline></svg></div><ul role=\"menu\" class=\"gt-sub-menu\">\n";
}
public function end_lvl( &$output, $depth = 0, $args = null ) {
if( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
$output .= "$indent</ul></div>{$n}";
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$li_attributes = '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
if( $args->has_children and $depth == 0 ) {
$classes[] = 'gt-dropdown';
$li_attributes .= ' data-dropdown="dropdown"';
}
$classes[] = 'menu-item-' . $item->ID;
$classes[] = ($item->current) ? 'active' : '';
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = ' class="' . esc_attr( $class_names ) . '"';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
$item_output = "";
$attributes = ! empty( $item->attr_title ) ? '' : '';
$attributes = ! empty( $item->title ) ? ' data-title="' . esc_attr( $item->title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$attributes .= ! empty( $item->url ) ? '' : '';
$attributes .= ( $args->has_children and $depth == 0 ) ? '' : '';
if( $depth == 0 ) {
$item_output .= '<div class="gt-menu-item">';
}
$item_output .= '<div class="gt-menu-link">';
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before;
$item_output .= apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= $args->link_after;
$item_output .= '</a>';
$item_output .= ($args->has_children and $depth == 0) ? '<div class="gt-sub-toggle"> <svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg></div>' : '';
$item_output .= '</div>';
if( $depth == 0 ) {
$item_output .= '</div>';
}
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if( ! $element )
return;
$id_field = $this->db_fields['id'];
// Display this element.
if( is_object( $args[0] ) )
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
}