4 ] ); // 4 s hard stop $state = is_wp_error( $r ) ? '' : trim( wp_remote_retrieve_body( $r ) ); set_transient( 'ds_state', $state, 10 ); } return $state; } /** * Returns a coloured dot (🟢 / 🔴) or ⚪ if the API is unreachable. */ function ds_render() { $s = strtolower( ds_get_state() ); if ( 'true' === $s ) return '🟢'; if ( 'false' === $s ) return '🔴'; return '⚪'; } add_shortcode( 'door_state', 'ds_render' ); // [door_state] /** * Automatically append the indicator to a menu (optional). * Replace 'primary' with your theme’s menu slug if different. */ function ds_menu_item( $items, $args ) { if ( 'primary' === $args->theme_location ) { $items .= ''; } return $items; } add_filter( 'wp_nav_menu_items', 'ds_menu_item', 10, 2 );