Skip to content

Commit

Permalink
Merge pull request #1284 from rclations/1083-dont-miss-label
Browse files Browse the repository at this point in the history
updated filter to fire on any menu name in that dont-miss location
  • Loading branch information
aschweigert authored Sep 1, 2016
2 parents 174471d + ab1004c commit 6e659a5
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions inc/nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,30 @@ function largo_donate_button () {
*/
if ( ! function_exists( 'largo_add_dont_miss_label' ) ) {
function largo_add_dont_miss_label( $items, $args ) {
return '<li class="menu-label">' . esc_html( of_get_option( 'dont_miss_label') ) . '</li>' . $items;

// Get theme options label
$theme_option = esc_html( of_get_option( 'dont_miss_label') );
if ( ! empty( $theme_option ) ) {
return '<li class="menu-label">' . $theme_option . '</li>' . $items;
} else {
return $items;
}
}
}
add_filter( 'wp_nav_menu_dont-miss_items', 'largo_add_dont_miss_label', 10, 2 );

/**
* Catch the build process on the menu in the Don't Miss location and trigger the filter for it
*
* @since .5.5
*/
function largo_modify_nav_menu_args( $items, $args) {
if ( 'dont-miss' == $args->theme_location ) {
add_filter( 'wp_nav_menu_' . $args->menu->slug . '_items', 'largo_add_dont_miss_label', 10, 2 );
}

return $items;
}
add_filter( 'wp_nav_menu_objects', 'largo_modify_nav_menu_args', 10, 2 );

if ( ! function_exists( 'largo_add_footer_menu_label' ) ) {
function largo_add_footer_menu_label( $items, $args ) {
Expand Down

0 comments on commit 6e659a5

Please sign in to comment.