Skip to content

Instantly share code, notes, and snippets.

@MatthewEppelsheimer
Created August 21, 2013 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewEppelsheimer/6300605 to your computer and use it in GitHub Desktop.
Save MatthewEppelsheimer/6300605 to your computer and use it in GitHub Desktop.
An idea for Fractal to support classes packaged with themes to overriding/interrupt inheritance of Fractal plugin classes
// An idea for a way to always look in the child theme first, even if you're in a Fractal (parent theme) class.
// Every time you use would require_once for a file with a class you're about to extend, use fractal_require(), instead.
function fractal_require( $file_name_without_extension ) {
$overriding_file = get_stylesheet_directory() . "/fractal/$file_name_without_extension.php";
if ( file_exists( $overriding_file ) ) {
require_once $overriding_file;
return true;
}
// At this point, fall back to just require_once, and assume in the same directory
require_once "$file_name_without_extension.php";
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment