<?php
/**
 * Created by PhpStorm.
 * User: adiardana
 * Date: 20/03/19
 * Time: 18.51
 */
/*
add_action('wpex_hook_main_after', function(){
    ?>
    <div class="top-footer">
        <?php dynamic_sidebar('top_footer');?>
    </div>
    <?php
});*/
add_action('wpex_hook_main_after', function(){
    $footer_content = get_field('footer_content', 'option');
    if($footer_content){
        echo '<div class="top-footer"><div class="container">';
        echo do_shortcode($footer_content);
        echo '</div></div>';
    }
});

add_action('wp_footer', function(){
    ?><div class="ll-modal-popup">
        <div class="ll-overlay"></div>
        <div class="ll-modal-popup-wrapper">
            <div class="header clearfix"><h4 class="title"></h4><span class="close"><i class="fa fa-times" aria-hidden="true"></i></span></div>
            <div class="body"></div>
        </div>
    </div><?php
});

add_filter( 'wpex_localize_array', function( $array ) {
    unset( $array['menuWidgetAccordion'] );
    return $array;
} );

add_action( 'wp_footer', function() { ?>

    <script>
        ( function( $ ) {
            'use strict';

            $( '#sidebar .widget_nav_menu' ).each( function() {
                var $hasChildren = $( this ).find( '.menu-item-has-children' );
                $hasChildren.each( function() {
                    $( this ).prepend( '<span class="prefix-parent-toggle ticon ticon-chevron-right"></span>' );
                    $( '.prefix-parent-toggle', $( this ) ).on( 'click', function( event ) {
                        var $linkParent = $( this ).parent( 'li' );
                        var $allParents = $linkParent.parents( 'li' );
                        if ( ! $linkParent.hasClass( 'active' ) ) {
                            $hasChildren.not( $allParents ).removeClass( 'active' ).children( '.sub-menu' ).slideUp( 'fast' );
                            $linkParent.addClass( 'active' ).children( '.sub-menu' ).stop( true, true ).slideDown( 'fast' );
                        } else {
                            $linkParent.removeClass( 'active' ).children( '.sub-menu' ).stop( true, true ).slideUp( 'fast' );
                        }
                        return false;
                    } );
                } );
            } );

        } ) ( jQuery );
    </script>

<?php } );
