Created
August 21, 2013 21:39
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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