Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active April 19, 2021 23:12
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GaryJones/1707986 to your computer and use it in GitHub Desktop.
Save GaryJones/1707986 to your computer and use it in GitHub Desktop.
Apply superfish enhancement to usual Genesis menus with different settings.
<?php
// For Genesis 2.0.0 and later:
add_filter( 'genesis_superfish_args_url', 'prefix_superfish_args_url' );
/**
* Filter in URL for custom Superfish arguments.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/change-superfish-arguments
*
* @param string $url Existing URL.
*
* @return string Amended URL.
*/
function prefix_superfish_args_url( $url ) {
return get_stylesheet_directory_uri() . '/js/superfish-args.js';
}
// For Genesis 1.9.* and earlier:
add_action( 'get_header', 'custom_superfish_arguments' );
/**
* Just before we start outputting, we deregister the default settings, and
* add reference to our own instead.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/change-superfish-arguments/
*/
function custom_superfish_arguments() {
if ( genesis_get_option( 'nav_superfish' ) ||
genesis_get_option( 'subnav_superfish' ) ||
is_active_widget( 0, 0, 'menu-categories' ) ||
is_active_widget( 0, 0, 'menu-pages' )
) {
wp_deregister_script( 'superfish-args' );
wp_enqueue_script( 'superfish-args', CHILD_URL . '/js/superfish.args.js', array( 'superfish' ), '1.0', true );
}
}
// For Genesis 2.0 and later:
jQuery(function ($) {
'use strict';
$('.js-superfish').superfish({
'delay': 100, // 0.1 second delay on mouseout
'animation': {'opacity': 'show', 'height': 'show'}, // fade-in and slide-down animation
'dropShadows': false // disable drop shadows
});
});
// For Genesis 1.9.* and earlier:
/**
* Apply superfish enhancement to usual menus with different settings.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/change-superfish-arguments/
*/
jQuery(document).ready(function($) {
$('#nav ul.superfish, #subnav ul.superfish, #header ul.nav, #header ul.menu').superfish({
// 0.2 second delay on mouseout
delay: 200,
// fade-in and slide-down animation
animation: {opacity:'show',height:'show'},
// enable drop shadows
dropShadows: true,
// Dropdown our menu slowly
speed: 'slow'
});
});
@biberkopf
Copy link

Shouldn't line 17
return get_stylesheet_directory_uri() . '/js/superfish.args.js';
('.' instead of dash)
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment