ID ) ) { return $title; } // The AAFE Nav Menu widget prints badges itself (inside its own walker). if ( is_object( $args ) && isset( $args->walker ) && $args->walker instanceof \AddronixAddons\Widgets\AAFE_Nav_Menu_Walker ) { return $title; } $text = get_post_meta( $item->ID, '_aafe_badge_text', true ); if ( '' === (string) $text ) { return $title; } $color = sanitize_hex_color( get_post_meta( $item->ID, '_aafe_badge_color', true ) ); $bg = sanitize_hex_color( get_post_meta( $item->ID, '_aafe_badge_bg', true ) ); $style = 'color:' . ( $color ? $color : '#ffffff' ) . ';background-color:' . ( $bg ? $bg : '#ff0000' ) . ';'; return $title . ' '; } /** * Small stylesheet for the badges (inline, no extra request). */ public function enqueue_styles() { wp_register_style( 'aafe-menu-badges', false, [], AAFE_VERSION ); wp_enqueue_style( 'aafe-menu-badges' ); wp_add_inline_style( 'aafe-menu-badges', '.aafe-menu-badge{display:inline-block;margin-left:6px;padding:2px 6px;border-radius:3px;font-size:10px;font-weight:700;line-height:1.4;letter-spacing:.03em;text-transform:uppercase;vertical-align:middle;white-space:nowrap;}' ); } /** * Output custom fields in the Menu Item editor. */ public function add_badge_fields( $item_id, $item ) { $badge_text = get_post_meta( $item_id, '_aafe_badge_text', true ); $badge_color = get_post_meta( $item_id, '_aafe_badge_color', true ); $badge_bg = get_post_meta( $item_id, '_aafe_badge_bg', true ); ?>