'true',
'theme' => '',
'theme_location' => '',
), $atts
)
);
$args = array(
'echo' => $echo == 'false' ? false : true,
'theme' => $theme,
'theme_location' => '',
'sticky' => 0,
);
return quadmenu($args);
}
function quadmenu($args = array()) {
//Removes the filder in all functions
//remove_filter('wp_nav_menu_args', 'quadmenu_auto_nav_menu_args', 100000);
//$args = quadmenu_get_nav_menu_args($args);
$defaults = array(
'manual' => true,
);
$args = wp_parse_args($args, $defaults);
return wp_nav_menu($args);
}
function quadmenu_auto_nav_menu_args($args) {
if (!empty($args['manual']) || (!empty($args['theme_location']) && is_quadmenu_location($args['theme_location']))) {
$args = quadmenu_get_nav_menu_args($args);
remove_all_filters('wp_nav_menu_items', 60);
remove_all_filters('wp_nav_menu_args', 60);
}
return $args;
}
function quadmenu_layout($nav_menu, $args) {
if (!empty($args->menu_template)) {
$args->menu_items = $nav_menu;
ob_start();
quadmenu_get_template($args->menu_template, $args);
$nav_menu = ob_get_clean();
}
return $nav_menu;
}
function quadmenu_lazyload($nav_menu, $args) {
if (!empty($args->layout_lazyload)) {
$lazy_menu = preg_replace_callback('//', function($matches) {
return preg_replace(array('/\bsrc\s*=\s*[\'"](.*?)[\'"]/', '/\bsrcset\s*=\s*[\'"](.*?)[\'"]/'), array('data-src="$1"', 'data-srcset="$1"'), $matches[0]);
}, $nav_menu);
return $lazy_menu;
}
return $nav_menu;
}
function quadmenu_get_nav_menu_args($args = array()) {
static $instance = 0;
$defaults = array(
'echo' => true,
'instance' => '',
'menu' => '',
'theme' => '',
'theme_location' => '',
);
$args = wp_parse_args($args, $defaults);
// WP
// -------------------------------------------------------------------------
$args['depth'] = 99;
$args['container'] = false;
$args['items_wrap'] = '
%s does not exist.', $located), '2.1');
return;
}
// Allow 3rd party plugin filter template file from their plugin
$located = apply_filters('quadmenu_get_template', $located, $template_name, $args, $template_path, $default_path);
include( $located );
}
function quadmenu_locate_template($template_name, $template_path = '', $default_path = '', $args = null) {
if (!$template_path) {
$template_path = quadmenu_layout_path();
}
if (!$default_path) {
$default_path = QUADMENU_PATH . 'templates/';
}
// Look within passed path within the theme - this is priority
$template = locate_template(
array(
trailingslashit($template_path) . $template_name,
$template_name
)
);
// Get default template
if (!$template) {
$template = $default_path . $template_name;
}
// Return what we found
return apply_filters('quadmenu_locate_template', $template, $template_name, $template_path, $default_path, $args);
}
function quadmenu_layout_path($slash = false) {
return apply_filters('quadmenu_layout_path', 'quadmenu') . ( $slash ? '/' : '' );
}