Exclude external uri for css and js version

Declaring functions inside functions can lead to problems as explained here: https://stackoverflow.com/a/1631579/1228379

To solve the issue of remote files, you can use an additional parameter to indicate it is remote (or local) and call get_theme_file_uri/path accordingly. Alternatively, you can just call wp_enqueue_script/style directly and use standard version numbers, or simply save the files locally.

In addition, if you find it simpler, you can also combine the two functions as one and pass some of the parameters as an associative array ($args need only contain the values you want to change):

function myenqueuer($handle, $src, $args) {
    $defaults = array('type'      => 'script',
                      'local'     => true,
                      'deps'      => array(),
                      'media'     => 'all',
                      'in_footer' => true,
                      'ver'       => false);
    $args = wp_parse_args($args, $defaults);
    if($args['local']) {
        $args['ver'] = md5(filemtime(get_theme_file_path($src)));
        $src = get_theme_file_uri($src);
    }
    if($args['type'] == 'style') {
        wp_enqueue_style($handle, $src, $args['deps'], $args['ver'], $args['media']);
    } else if($args['type'] == 'script') {
        wp_enqueue_script($handle, $src, $args['deps'], $args['ver'], $args['in_footer']);
    }
}

You would call it like this:

myenqueuer('_normalize', '/assets/css/normalize.css', array('type'=>'style'));
myenqueuer('_base', '/assets/css/base.css', array('type'=>'style'));
myenqueuer('_fonts', '//fonts.googleapis.com/css?family=Open+Sans:400,600', array('type'=>'style', 'local'=>false));

myenqueuer('_lightbox2', '//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.9.0/js/lightbox.min.js', array('deps'=>array('jquery'), 'local'=>false));
myenqueuer('_base', '/assets/js/base.js', array('deps'=>array('jquery')));