* @copyright Copyright (c) 2008 - 2014, Justin Tadlock * @link http://themehybrid.com/hybrid-core * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ if ( !class_exists( 'Hybrid' ) ) { /** * The Hybrid class launches the framework. It's the organizational structure behind the entire framework. * This class should be loaded and initialized before anything else within the theme is called to properly use * the framework. * * After parent themes call the Hybrid class, they should perform a theme setup function on the * 'after_setup_theme' hook with a priority of 10. Child themes should add their theme setup function on * the 'after_setup_theme' hook with a priority of 11. This allows the class to load theme-supported features * at the appropriate time, which is on the 'after_setup_theme' hook with a priority of 12. * * Note that while it is possible to extend this class, it's not usually recommended unless you absolutely * know what you're doing and expect your sub-class to break on updates. This class often gets modifications * between versions. * * @since 0.7.0 * @access public */ class Hybrid { /** * Constructor method for the Hybrid class. This method adds other methods of the class to * specific hooks within WordPress. It controls the load order of the required files for running * the framework. * * @since 1.0.0 * @access public * @return void */ function __construct() { global $hybrid; /* Set up an empty class for the global $hybrid object. */ $hybrid = new stdClass; /* Define framework, parent theme, and child theme constants. */ add_action( 'after_setup_theme', array( $this, 'constants' ), 1 ); /* Load the core functions/classes required by the rest of the framework. */ add_action( 'after_setup_theme', array( $this, 'core' ), 2 ); /* Initialize the framework's default actions and filters. */ add_action( 'after_setup_theme', array( $this, 'default_filters' ), 3 ); /* Handle theme supported features. */ add_action( 'after_setup_theme', array( $this, 'theme_support' ), 12 ); /* Load framework includes. */ add_action( 'after_setup_theme', array( $this, 'includes' ), 13 ); /* Load the framework extensions. */ add_action( 'after_setup_theme', array( $this, 'extensions' ), 14 ); /* Language functions and translations setup. */ add_action( 'after_setup_theme', array( $this, 'i18n' ), 25 ); /* Load admin files. */ add_action( 'wp_loaded', array( $this, 'admin' ) ); } /** * Defines the constant paths for use within the core framework, parent theme, and child theme. * Constants prefixed with 'HYBRID_' are for use only within the core framework and don't * reference other areas of the parent or child theme. * * @since 0.7.0 * @access public * @return void */ function constants() { /* Sets the framework version number. */ define( 'HYBRID_VERSION', '2.0.4' ); /* Sets the path to the parent theme directory. */ define( 'THEME_DIR', get_template_directory() ); /* Sets the path to the parent theme directory URI. */ define( 'THEME_URI', get_template_directory_uri() ); /* Sets the path to the child theme directory. */ define( 'CHILD_THEME_DIR', get_stylesheet_directory() ); /* Sets the path to the child theme directory URI. */ define( 'CHILD_THEME_URI', get_stylesheet_directory_uri() ); /* Sets the path to the core framework directory. */ if ( !defined( 'HYBRID_DIR' ) ) define( 'HYBRID_DIR', trailingslashit( THEME_DIR ) . basename( dirname( __FILE__ ) ) ); /* Sets the path to the core framework directory URI. */ if ( !defined( 'HYBRID_URI' ) ) define( 'HYBRID_URI', trailingslashit( THEME_URI ) . basename( dirname( __FILE__ ) ) ); /* Sets the path to the core framework admin directory. */ define( 'HYBRID_ADMIN', trailingslashit( HYBRID_DIR ) . 'admin' ); /* Sets the path to the core framework classes directory. */ define( 'HYBRID_CLASSES', trailingslashit( HYBRID_DIR ) . 'classes' ); /* Sets the path to the core framework extensions directory. */ define( 'HYBRID_EXTENSIONS', trailingslashit( HYBRID_DIR ) . 'extensions' ); /* Sets the path to the core framework functions directory. */ define( 'HYBRID_FUNCTIONS', trailingslashit( HYBRID_DIR ) . 'functions' ); /* Sets the path to the core framework languages directory. */ define( 'HYBRID_LANGUAGES', trailingslashit( HYBRID_DIR ) . 'languages' ); /* Sets the path to the core framework images directory URI. */ define( 'HYBRID_IMAGES', trailingslashit( HYBRID_URI ) . 'images' ); /* Sets the path to the core framework CSS directory URI. */ define( 'HYBRID_CSS', trailingslashit( HYBRID_URI ) . 'css' ); /* Sets the path to the core framework JavaScript directory URI. */ define( 'HYBRID_JS', trailingslashit( HYBRID_URI ) . 'js' ); } /** * Loads the core framework files. These files are needed before loading anything else in the * framework because they have required functions for use. Many of the files run filters that * theme authors may wish to remove in their theme setup functions. * * @since 1.0.0 * @access public * @return void */ function core() { /* Load the core framework functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'core.php' ); /* Load the context-based functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'context.php' ); /* Load the core framework internationalization functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'i18n.php' ); /* Load the framework customize functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'customize.php' ); /* Load the framework filters. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'filters.php' ); /* Load the
functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'head.php' ); /* Load media-related functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'media.php' ); /* Load the metadata functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'meta.php' ); /* Load the sidebar functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'sidebars.php' ); /* Load the scripts functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'scripts.php' ); /* Load the styles functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'styles.php' ); /* Load the utility functions. */ require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'utility.php' ); } /** * Loads both the parent and child theme translation files. If a locale-based functions file exists * in either the parent or child theme (child overrides parent), it will also be loaded. All translation * and locale functions files are expected to be within the theme's '/languages' folder, but the * framework will fall back on the theme root folder if necessary. Translation files are expected * to be prefixed with the template or stylesheet path (example: 'templatename-en_US.mo'). * * @since 1.2.0 * @access public * @return void */ function i18n() { global $hybrid; /* Get parent and child theme textdomains. */ $parent_textdomain = hybrid_get_parent_textdomain(); $child_textdomain = hybrid_get_child_textdomain(); /* Load theme textdomain. */ $hybrid->textdomain_loaded[ $parent_textdomain ] = load_theme_textdomain( $parent_textdomain ); /* Load child theme textdomain. */ $hybrid->textdomain_loaded[ $child_textdomain ] = is_child_theme() ? load_child_theme_textdomain( $child_textdomain ) : false; /* Load the framework textdomain. */ $hybrid->textdomain_loaded['hybrid-core'] = hybrid_load_framework_textdomain( 'hybrid-core' ); /* Get the user's locale. */ $locale = get_locale(); /* Locate a locale-specific functions file. */ $locale_functions = locate_template( array( "languages/{$locale}.php", "{$locale}.php" ) ); /* If the locale file exists and is readable, load it. */ if ( !empty( $locale_functions ) && is_readable( $locale_functions ) ) require_once( $locale_functions ); } /** * Removes theme supported features from themes in the case that a user has a plugin installed * that handles the functionality. * * @since 1.3.0 * @access public * @return void */ function theme_support() { // Automatically add