wordpress.org – Bydefault header menu is taking footer menu as Id and displaying footer menu in header too

Here is my functions.php code

<?php register_nav_menus( array(
'primary' => __( 'Primary Menu', 'akeo-tech' ),  
'footer' => __('Footer Menu', 'akeo-tech'),
'mobile_header' => __('mobile-header', 'akeo-tech')) );
function get_footer_menus() {
$menu_name = 'footer'; // specify custom menu slug
if (($locations = get_nav_menu_locations()) && isset($locations($menu_name))) {
    $menu = wp_get_nav_menu_object($locations($menu_name));
    $menu_items = wp_get_nav_menu_items($menu->term_id);
    $submenu = false;
    $count = 0;
    foreach ((array) $menu_items as $key => $menu_item) {
        $title = $menu_item->title;
        $url = $menu_item->url;
        if ( !$menu_item->menu_item_parent ) {
            $parent_id = $menu_item->ID;
            $menu_list .= '<div class="w-20"><h7 class="menu-header">'.$title.'</h7>' ."n";
        }
        if ( $parent_id == $menu_item->menu_item_parent ) {
            if ( !$submenu ) {
                $submenu = true;
                $menu_list .= '<ul>' ."n";
            }
            $menu_list .= '<li>' ."n";
            $menu_list .= '<a href="'.$url.'" >'.$title.'</a>' ."n";
            $menu_list .= '</li>' ."n";
            if ( $menu_items( $count + 1 )->menu_item_parent != $parent_id && $submenu ){
                $menu_list .= '</ul></div>' ."n";
                $submenu = false;
            }
        }
        if ( $menu_items( $count + 1 )->menu_item_parent != $parent_id ) {    
            $submenu = false;
        }
        $count++;

} 
    // $menu_list .= '</div>' ."n";
} else {
    // $menu_list = '<!-- no list defined -->';
}
echo $menu_list;}?>

Here is my header.php code

 <?php 
                            $args = array(
                                'menu' => 'mobile_header',
                                'menu_class' => 'desktop-navigation-links',
                                // 'menu_css_class' => 'dropdown',
                                'container' => 'nav',
                                'container_class' => '',
                                'depth' => 3
                            );
                            wp_nav_menu($args);
                        ?> 

Here is my footer .php code

 <?php 
            if (function_exists('get_footer_menus')) {
                get_footer_menus();
            }
        ?>

But here in header menu too it is showing footer menu

theme development – how to change footer quick links menus(Primary menu) for certain pages

Need to change Footer quick links menu and footer tagline for certain pages only

we have working on School site it have both higher secondary school pages and nursery school pages if we click the link and open higher secondary the page have different Primary menu and nursery link has separate Menus

Here i need footer quick menu wants to be separate and i used conditional Menu plugins to achieve Separate Menu for ABC Higher secondary and XYZ Nursery.but it won’t works on Footer Quick menu so i need solutions from you guys.!!

Search if menu item has child in wp_get_nav_menu_items hook

I am conditionally showing menu items. All is fine but want to remove parent item if returning no child items.

For example if I have a parent menu (it will always be a custom link with #) called More and it has multiple child items (mostly one level). Now if I am hiding child items based on user roles and for some roles no child items available, in that case, I want to remove More menu items also since it has no child.

I am trying with the following code but since $item is an object, array_search won’t work. So how can I check for child-parent and remove the menu item if it has no child?

array_search( $item( 'ID' ), array_column( $item, 'menu_item_parent' ) )

Below is the working code that hides menu item based on user roles.

public static function exclude_menu_items( $items, $menu, $args ) {

    if ( current_user_can( 'administrator' ) ) {
        return $items;
    }

    foreach ( $items as $key => $item ) {

        if ( $page = get_post( $item->object_id ) ) {
            if ( $page->post_type == 'page' ) {
                $template  = get_post_meta( $page->ID, '_wp_page_template', TRUE );
                $post_type = self::get_cpt_for_template( $template );

                if ( $post_type && ( ! current_user_can( 'cp_access_' . $post_type ) || ! ( new self() )->is_current_user_granted_for_module( $post_type ) ) ) {
                    unset( $items( $key ) );
                }
            }
        }
    }

    return $items;
}

javascript – Popup box after user select certain values in a few dropdown menu fields

I have a multi-step signup form with multiple fields. Relevant to this question are fields asking for the user’s country, whether they are employed/earn a steady salary and if they would like to pay for services in installments or upfront.

I would like to show a popup page in cases where the user selects the country as Nigeria, indicates that they are employed and that they would like to pay for services in installments.

So the popup form would occur the moment the person selects yes to wanting to pay in installments after having selected Nigeria as a country and indicating that they are employed.

Here is my html and what I have tried:

    <div class="row">
        {% if form.errors %}
            <div class="alert alert-error">
                <ul>
                    {% for error in form.non_field_errors %}
                        <li>{{ error }}</li>
                    {% endfor %}
                </ul>
            </div>
        {% endif %}
    </div>
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <!--  -->
            <form  id="msform" method="post" action="" > 
                {% csrf_token %}
                <input type="hidden" name="next" value="{{ next }}" class="form-control">
                <ul id="progressbar">
                    <li>More about you</li>
                    <li>Contact Details</li>
                </ul>
                <fieldset>
                    <h2 class="fs-title">More about you</h2>
                    {{form.city}}
                    <br>
                    <select name='country' required class="form-control my-2">
                        <option value="" disabled selected hidden>Country</option>
                        {% for value, name in form.fields.country.choices %}
                            <option value="{{value}}">{{name}}</option>
                        {% endfor %}
                    </select>
                    <input type="button" name="previous" class="previous action-button-previous" value="Previous" />
                    <input type="button" name="next" class="next action-button" value="Next" />
                </fieldset>
                <fieldset>
                    <h2 class="fs-title">Contact Details</h2>
                    <select name='installments' required class="form-control my-2">
                        <option value="" disabled selected hidden>Would you like to pay the $350 fee upfront or in installments?</option>
                        {% for value, name in form.fields.installments.choices %}
                            <option value="{{value}}">{{name}}</option>
                        {% endfor %}
                    </select>
                    <input type="button" name="previous" class="previous action-button-previous" value="Previous" />
                    <input type="submit"  class="submit action-button" value="Sign Up" />

                </fieldset>
            </form>
        </div>
    </div>
    {% endblock %}
{% block mainjs %}
{% endblock mainjs %}
{% block extrajs %}
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>
<script >

//jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches

$(".next").click(function(){
    if(animating) return false;
    animating = true;

    current_fs = $(this).parent();
    next_fs = $(this).parent().next();

    //activate next step on progressbar using the index of next_fs
    $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");

    //show the next fieldset
    next_fs.show(); 
    //hide the current fieldset with style
    current_fs.animate({opacity: 0}, {
        step: function(now, mx) {
            //as the opacity of current_fs reduces to 0 - stored in "now"
            //1. scale current_fs down to 80%
            scale = 1 - (1 - now) * 0.
      ;
            //2. bring next_fs from the right(50%)
            left = (now * 50)+"%";
            //3. increase opacity of next_fs to 1 as it moves in
            opacity = 1 - now;
            current_fs.css({
        'transform': 'scale('+scale+')',
        'position': 'absolute'
      });
            next_fs.css({'left': left, 'opacity': opacity});
        }, 
        duration: 800, 
        complete: function(){
            current_fs.hide();
            animating = false;
        }, 
        //this comes from the custom easing plugin
        easing: 'easeInOutBack'
    });
});

$(".previous").click(function(){
    if(animating) return false;
    animating = true;

    current_fs = $(this).parent();
    previous_fs = $(this).parent().prev();

    $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
    previous_fs.show(); 
    current_fs.animate({opacity: 0}, {
        step: function(now, mx) {
            scale = 0.8 + (1 - now) * 0.2;
            left = ((1-now) * 50)+"%";
            opacity = 1 - now;
            current_fs.css({'left': left});
            previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
        }, 
        duration: 800, 
        complete: function(){
            current_fs.hide();
            animating = false;
        }, 
        easing: 'easeInOutBack'
    });
});

$(".submit").click(function(){
    return true;
})
</script>
<script>
    $("#installments").bind("change", function() {
        var value = this.value;
        switch (value) {
            case "installments":
            window.open("https://www.google.com/", "Google");
            break;
            }
    });
</script>
{% endblock extrajs %}

navigation – How do you pick the right function to be in the bottom menu?

Im currently designing a student portal mobile application.
It got a lot of functions; 1. frequently used (academic, timetable, assignments) 2. seldom used (fees, library) and 3. others that are not applicable to all students (counselling, international students, visa).

I could not figure out the categorisation of functions and where they should belong.

  1. I plan to have the bottom menu for management (dashboard, timetable, fees, notification, menu).
  2. Then, maybe have shortcut buttons in dashboard for academic, library, hostel. This shortcut is for big functions that have have a lot of features and integration in the future. Example in library, user can search for books, reserve and pay fines.
  3. And the less important ones to be placed in menu (menu in bottom navigation > sidebar).

Or would you guys suggest functions to be categorised based on usage frequency? or maybe theres other factors to be considered?

I really appreciate your help. Thank you in advance!

iOS Shortcuts: shortcut not dismissed after cancelling menu selection

I have a shortcut that ends with a menu choice. After running the shortcut and tapping Cancel in the menu, I expect the shortcut to be dismissed, but it’s not. It doesn’t even help to explicitly exit the shortcut with an action, as seen in the screenshot. The shortcut is dismissed only when I select a menu entry.

Is this a bug or am I misunderstanding something? I don’t see any mention that cancelling a menu selection equals canceling the entire shortcut, and even if it does I don’t understand the purpose of leaving the now cancelled shortcut on screen.

screenshot

Mover un elemento dentro de un menu SOLO CON CSS

Tengo el siguiente menú.

<div class="mo-logo">
    <a href="http://localhost/travellia">
        <img class="logo" src="https://localhost/logoTravellia.jpg" alt="Logo"> </a>
</div>

<ul id="menu-travellia" class="text-right">
    <li id="menu-item-48" class="menu-item-48"><a href="#">Inicio</a></li>
    <li id="menu-item-49" class="menu-item-49"><a href="#">Cruceros</a></li>
    <li id="menu-item-50" class="menu-item-50"><a href="#">Destinos</a></li>
    <li id="menu-item-51" class="menu-item-51"><a href="#">Tours</a></li>
    <li id="menu-item-52" class="menu-item-52"><a href="#">Ofertas</a></li>
    <li id="menu-item-53" class="menu-item-53"><a href="#">Contáctanos</a></li>
</ul>

Como puedo mover el que contiene la imagen entre “Destinos” y “Tours”, SOLO usando CSS.
O alguna sugerencia para mover la imagen, en el centro de los elementos de ul.

magento2 – How to prevent dropdown menu from closing when moving between top level items?

We’re using a dropdown menu modified from snowdog and magento, and our top level items have 6 options. It’s a pretty standard menu; when hovering over the top level items it drops down and shows the subnav items. However, when moving in between the main items, the menu briefly closes before reopening with the options for the next item. My initial thought was to write some javascript to detect when the menu is already open, and if so, prevent the event from bubbling up the DOM, but I have a feeling the answer is probably more simple than this solution. Maybe using a transition delay to make the hovering more forgiving?

If I were to try adding a transition delay, would this be done in our navigation.less file? I inherited this code base and things are a little messy, so I’m not positive how to start going about this.

Ubuntu (Gnome and 18.04) always hides the upper LH corner close box under a menu – can I change this?

Stack Exchange Network


Stack Exchange network consists of 177 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

WordPress menu walker – help to add custom class for each submenu

I am trying to apply to my already existing menu a walker in order to add custom classes to every sub menu anchor tag.

Here is my menu:

            wp_nav_menu(array(
            'theme_location' => 'menu-top',
            'container'      => 'ul',
            'menu_class'     => 'header_nav_ul',
            'menu_id'        => 'header_nav_id',
            'depth'          => 0,
        ))

I added the wolder and it became:

wp_nav_menu(array(
            'theme_location' => 'menu-top',
            'container'      => 'ul',
            'menu_class'     => 'header_nav_ul',
            'menu_id'        => 'header_nav_id',
            'depth'          => 0,
            'walker'        => new my_walker_nav_menu_start_el(),
        ))

The walker function is this one:

function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
        // you can put your if statements in here (use item, depth and args in conditions)
        if ( $depth == 1 ) {
            $item_output = preg_replace('/<a /', '<a class="level-1-menu" ', $item_output, 1);
        } else if ( $depth == 2 ){
            $item_output = preg_replace('/<a /', '<a class="level-2-menu" ', $item_output, 1);
        }
        // .. and so on
        return $item_output;
    }
    add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);

However out of the box it doesn’t work. I am new to php, but I see that it is a new walker which suggests me that I should write that function as a class.

Can anyone help me to edit my function so that it will work fine with my menu?

Thank you