Note to self: Get up to date on WP Trac digests before submitting new tickets. Prevents foot-in-mouth disorder 99 percent of the time.
According to a recent WordPress trac ticket, theme authors could soon be rewarded with a little nugget of functionality that would make using child themes much more extensible.
The ticket suggests introducing a function that works similarly to locate_template(), but rather than returning the path of the file (in the parent theme only), it would return a URI to the file, thus allowing a child theme to override the parent’s .js, .css and even image files. The proposed function is called locate_theme_file().
According to the suggested patch posted by johnbillion, this is the current method for loading template files in parent themes only:
wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', array(), null );
If locate_theme_file() is introduced, we could instead see functions like these:
wp_enqueue_style( 'dark', locate_theme_file( 'colors/dark.css' ), array(), null ); wp_enqueue_style( 'bar', locate_theme_file( 'bar.css' ) ); <img src="<?php echo locate_theme_file( 'icon.png' ); ?>" />
locate_theme_file() would automatically load any of these files via the child theme, BEFORE the parent. Pretty neat huh?
Up to this point, child themes could only override a parent theme’s template files. If theme authors are rewarded with the ability to enqueue many more types of files at the child theme level with this much ease, I anticipate seeing some really exciting new uses for child themes emerging.