Last active
August 29, 2015 14:02
-
-
Save unr/00a64b479f5841722d42 to your computer and use it in GitHub Desktop.
An example of using classes to bootstrap a WordPress Theme.
This file contains 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
<?php | |
/** | |
* Our main class for our theme. | |
* | |
* This will act as our controller, and activate other hooks/functions for wordpress. | |
*/ | |
class Example { | |
// Called by our bootstrap_theme function | |
public static function init() { | |
echo "Hello World"; | |
} | |
} |
This file contains 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
<?php | |
/** | |
* Our functions file. We're hooking into the wp after_setup_theme | |
* hook to bootstrap our theme, instead of just firing everything | |
* all willy-nilly. | |
*/ | |
// Bootstrap our theme, this is called by the after_setup_theme hook | |
function bootstrap_theme { | |
// Include our class file, which we use to control our theme | |
require_once locate_template('/lib/theme/class.php'); | |
Example::init(); | |
} | |
add_action( 'after_setup_theme', 'bootstrap_theme' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment