From 891ee385584f3464bb428edb812430219e44220e Mon Sep 17 00:00:00 2001 From: rclations Date: Wed, 31 Aug 2016 15:12:25 -0400 Subject: [PATCH 1/3] updated filter to fire on any menu name in that dont-miss location --- inc/nav-menus.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/inc/nav-menus.php b/inc/nav-menus.php index 0e7295c0e..973b39ae4 100644 --- a/inc/nav-menus.php +++ b/inc/nav-menus.php @@ -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 '' . $items; + + // Get theme options label + $theme_option = esc_html( of_get_option( 'dont_miss_label') ); + if ( !empty( $theme_option ) ) { + return '' . $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 ) { From 4bd3bc30f7f1ad140c80dc749852a8618a07b551 Mon Sep 17 00:00:00 2001 From: rclations Date: Thu, 1 Sep 2016 08:17:37 -0400 Subject: [PATCH 2/3] no need to esc_html() twice --- inc/nav-menus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/nav-menus.php b/inc/nav-menus.php index 973b39ae4..218ac74d3 100644 --- a/inc/nav-menus.php +++ b/inc/nav-menus.php @@ -28,7 +28,7 @@ function largo_add_dont_miss_label( $items, $args ) { // Get theme options label $theme_option = esc_html( of_get_option( 'dont_miss_label') ); if ( !empty( $theme_option ) ) { - return '' . $items; + return '' . $items; } else { return $items; } From ab1004cabdea34fb40874e72d528c5ecc7eaba20 Mon Sep 17 00:00:00 2001 From: rclations Date: Thu, 1 Sep 2016 08:18:54 -0400 Subject: [PATCH 3/3] WP coding standards --- inc/nav-menus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/nav-menus.php b/inc/nav-menus.php index 218ac74d3..1b9f1c0fe 100644 --- a/inc/nav-menus.php +++ b/inc/nav-menus.php @@ -27,7 +27,7 @@ function largo_add_dont_miss_label( $items, $args ) { // Get theme options label $theme_option = esc_html( of_get_option( 'dont_miss_label') ); - if ( !empty( $theme_option ) ) { + if ( ! empty( $theme_option ) ) { return '' . $items; } else { return $items;