Verify that $key is actually a string

… before attempting to use it as an array index.

This error can crop up when running cli scripts that do not have a
specified theme loaded.