• Resolved Ov3rfly

    (@ov3rfly)


    Here an enhanced version of slick-init.js (based on 1.6.3) which we made for a client, changes are marked with // Ov3rfly

    It can combine multiple WordPress menus into one mobile menu.

    https://pastebin.com/GC937N0A (link expires after 7 days)

    With the enhanced slick-init.js in place, you can use one selector or multiple comma separated selectors at SlickNav Mobile Menu Name in backend, examples:

    #primary-menu

    #primary-menu, #secondary-menu

    #top-menu, #primary-menu, #other-menu, #secondary-menu

    The code is pretty simple, you can add as many menus as you like, the concept is based on a two menus codepen by Josh Cope.

    Additional note: In a future release you should rename phpVars to something like ngSlickVars or similar in php and js.

    Thanks for the great plugin.

    https://www.ads-software.com/plugins/slicknav-mobile-menu/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author neilgee

    (@neilgee)

    Very nice!, have had a couple of requests for this, will be adding this in.

    Plugin Author neilgee

    (@neilgee)

    Question for you; each time I add a new setting I run into the ‘Notice Undefined index’ if WP_DEBUG is enabled, since it is a new value it is undefined I added the if/else for the new setting but still the notice shows.

    Notice: Undefined index: ng_slicknav_close_on_click in /srv/www/genesis-mobile/htdocs/wp-content/plugins/slick-nav-menu/inc/options-page-wrapper.php on line 391
    /> Close Menu on Click

    Can you advise what else is required here to avoid the notice.

    The options-page-wrapper.php on line 391 is in itself an if/else based on if the menu name is set for all the settings.

    https://gist.github.com/neilgee/b3b68bdc1a04ade8fff8

    Thread Starter Ov3rfly

    (@ov3rfly)

    That’s a similar issue as #9 and #11 here, at TODO, set default values if no options have been saved yet in the pastebin.

    In slicknav-mobile-menu.php gist 1.7 the line 317 $options = get_option('ng_slicknavmenu'); returns an array of data, your } else { block is only reached if no data at all was saved before, after first install.

    In your case I would recommend to solve it like this, so all variables are set and ready for settings page:

    function menu_options_page() {
    	// ... current_user_can, check_admin_referer here.
    
    	$options = get_option('ng_slicknavmenu'); // line 317 in 1.7
    
    	$default_options = array(
    		'ng_slicknav_menu' => '',
    		'ng_slicknav_width' => '',
    		// ... all other
    		'$ng_slicknav_alt' => ''
    	);
    
    	if ( $options !== false ) {  // line 319 in 1.7
    		$options = array_merge( $default_options, $options );
    	} else { // line 355 in 1.7
    		$options = $default_options;
    	}
    
    	// set variables for options-page-wrapper.php
    	$ng_slicknav_menu                     = $options['ng_slicknav_menu'];
    	$ng_slicknav_width                    = $options['ng_slicknav_width'];
    	// ... all other
    	$ng_slicknav_alt                      = $options['ng_slicknav_alt'];
    
    	require( 'inc/options-page-wrapper.php' );

    Additional note: In a future release you should rename phpVars to something like ngSlickVars or similar in php and js.

    Thread Starter Ov3rfly

    (@ov3rfly)

    In case all used variable names are exactly the same as the array key, you could also use php extract() to set the variables for options-page-wrapper.php

    Plugin Author neilgee

    (@neilgee)

    I upgraded the version to 1.7.0 – with multi menu capabilities – FYI filter name is changed ng_slicknav_slickNavVars

    I was going to add new options but decided against it for now – if I add new ones in the future I will be adding default values to avoid the notice of undefined index.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Thanks, multi menu works fine.

    With an approach via array_merge() and extract() or similar you can simplify adding options a lot.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Support to combine multiple menus in one mobile menu’ is closed to new replies.