Site icon Hip-Hop Website Design and Development

How do I define and register a shortcode function in a namespaced functions.php file?

I wrote a function in my theme’s functions.php and am attempting to register it with add_shortcode() as shown in the Codex:

<?php
/**
 * theme's functions.php
 */

namespace MyNamespace;

//[foobar]
function foobar_func( $atts ){
    return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );

However this does not work and a post containing [foobar] simply renders "[foobar]" as text instead of being replaced by the handler function’s return value.

My guess is it has something to do with my functions.php being namespaced. Does something special need to be done to reference namespaced Callables in add_shortcode?