So, I’m not sure exactly what is causing the problem, but you might try the following:
- Plugin file path: replace
dirname(__FILE__)
withplugin_dir_path( __FILE__ )
- Theme file path: replace
TEMPLATEDIR
withget_stylesheet_directory()
It’s possible that the problem comes from referencing the constants directly.