Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 317 lines (249 sloc) 11.962 kb
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
1 <?php
2 /**
3594f29 Documentation updates galore.
greenshady authored
3 * Hybrid Core is a framework for developing WordPress themes. The framework allows theme developers
4 * to quickly build themes without having to handle all of the "logic" behind the theme or having to code
5 * complex functionality for features that are often needed in themes. The framework does these things
6 * for developers to allow them to get back to what matters the most: developing and designing themes.
7 * The framework was built to make it easy for developers to include (or not include) specific, pre-coded
8 * features. Themes handle all the markup, style, and scripts while the framework handles the logic.
a84cd56 Update the license info specifically for the framework.
greenshady authored
9 *
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
10 * Hybrid Core is a modular system, which means that developers can pick and choose the features they
11 * want to include within their themes. Most files are only loaded if the theme registers support for the
12 * feature using the add_theme_support( $feature ) function within their theme.
13 *
a84cd56 Update the license info specifically for the framework.
greenshady authored
14 * @copyright 2008 - 2010
3594f29 Documentation updates galore.
greenshady authored
15 * @version 1.0.0
a84cd56 Update the license info specifically for the framework.
greenshady authored
16 * @author Justin Tadlock
17 * @link http://themehybrid.com
18 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 *
3594f29 Documentation updates galore.
greenshady authored
20 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
21 * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
22 * that you can use any other version of the GPL.
a84cd56 Update the license info specifically for the framework.
greenshady authored
23 *
3594f29 Documentation updates galore.
greenshady authored
24 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
25 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
a84cd56 Update the license info specifically for the framework.
greenshady authored
26 *
3594f29 Documentation updates galore.
greenshady authored
27 * You should have received a copy of the GNU General Public License along with this program; if not, write
28 * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
a84cd56 Update the license info specifically for the framework.
greenshady authored
29 *
30 * @package HybridCore
31 */
32
33 /**
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
34 * The Hybrid class launches the framework. It's the organizational structure behind the entire framework.
35 * This class should be loaded and initialized before anything else within the theme is called to properly use
36 * the framework.
37 *
38 * After parent themes call the Hybrid class, they should perform a theme setup function on the
39 * 'after_setup_theme' hook with a priority of 10. Child themes should add their theme setup function on
40 * the 'after_setup_theme' hook with a priority of 11. This allows the class to load theme-supported features
41 * at the appropriate time, which is on the 'after_setup_theme' hook with a priority of 12.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
42 *
3594f29 Documentation updates galore.
greenshady authored
43 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
44 */
45 class Hybrid {
46
47 /**
48 * Theme prefix (mostly used for hooks).
49 *
3594f29 Documentation updates galore.
greenshady authored
50 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
51 * @var string
52 */
53 var $prefix;
54
55 /**
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
56 * PHP4 constructor method. This simply provides backwards compatibility for users with setups
57 * on older versions of PHP. Once WordPress no longer supports PHP4, this method will be removed.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
58 *
3594f29 Documentation updates galore.
greenshady authored
59 * @since 0.9.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
60 */
61 function Hybrid() {
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
62 $this->__construct();
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
63 }
64
65 /**
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
66 * Constructor method for the Hybrid class. This method adds other methods of the class to
67 * specific hooks within WordPress. It controls the load order of the required files for running
68 * the framework.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
69 *
c3cf33f Mark all 0.9.1 changes as 1.0.0 since that'll be the release version.
greenshady authored
70 * @since 1.0.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
71 */
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
72 function __construct() {
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
73
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
74 /* Define framework, parent theme, and child theme constants. */
75 add_action( 'after_setup_theme', array( &$this, 'constants' ), 1 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
76
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
77 /* Load the core theme functions required by the rest of the framework. */
78 add_action( 'after_setup_theme', array( &$this, 'core' ), 2 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
79
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
80 /* Language functions and translations setup. */
81 add_action( 'after_setup_theme', array( &$this, 'locale' ), 3 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
82
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
83 /* Initialize the framework's default actions. */
84 add_action( 'after_setup_theme', array( &$this, 'actions' ), 4 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
85
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
86 /* Initialize the framework's default filters. */
87 add_action( 'after_setup_theme', array( &$this, 'filters' ), 4 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
88
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
89 /* Load the framework functions. */
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
90 add_action( 'after_setup_theme', array( &$this, 'functions' ), 12 );
91
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
92 /* Load the framework extensions. */
93 add_action( 'after_setup_theme', array( &$this, 'extensions' ), 13 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
94
02c9e07 Cleaning up the admin functionality for a better development experience.
greenshady authored
95 /* Load admin files. */
96 add_action( 'wp_loaded', array( &$this, 'admin' ) );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
97 }
98
99 /**
100 * Defines the constant paths for use within the core framework, parent theme, and
101 * child theme. Constants prefixed with 'HYBRID_' are for use only within the core
102 * framework and don't reference other areas of the theme.
103 *
3594f29 Documentation updates galore.
greenshady authored
104 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
105 */
106 function constants() {
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
107
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
108 /* Sets the path to the parent theme directory. */
109 define( 'THEME_DIR', get_template_directory() );
110
111 /* Sets the path to the parent theme directory URI. */
112 define( 'THEME_URI', get_template_directory_uri() );
113
114 /* Sets the path to the child theme directory. */
115 define( 'CHILD_THEME_DIR', get_stylesheet_directory() );
116
117 /* Sets the path to the child theme directory URI. */
118 define( 'CHILD_THEME_URI', get_stylesheet_directory_uri() );
119
120 /* Sets the path to the core framework directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
121 define( 'HYBRID_DIR', trailingslashit( THEME_DIR ) . basename( dirname( __FILE__ ) ) );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
122
123 /* Sets the path to the core framework directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
124 define( 'HYBRID_URI', trailingslashit( THEME_URI ) . basename( dirname( __FILE__ ) ) );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
125
126 /* Sets the path to the core framework admin directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
127 define( 'HYBRID_ADMIN', trailingslashit( HYBRID_DIR ) . 'admin' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
128
129 /* Sets the path to the core framework classes directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
130 define( 'HYBRID_CLASSES', trailingslashit( HYBRID_DIR ) . 'classes' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
131
132 /* Sets the path to the core framework extensions directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
133 define( 'HYBRID_EXTENSIONS', trailingslashit( HYBRID_DIR ) . 'extensions' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
134
135 /* Sets the path to the core framework functions directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
136 define( 'HYBRID_FUNCTIONS', trailingslashit( HYBRID_DIR ) . 'functions' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
137
138 /* Sets the path to the core framework images directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
139 define( 'HYBRID_IMAGES', trailingslashit( HYBRID_URI ) . 'images' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
140
141 /* Sets the path to the core framework CSS directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
142 define( 'HYBRID_CSS', trailingslashit( HYBRID_URI ) . 'css' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
143
144 /* Sets the path to the core framework JavaScript directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This wa...
greenshady authored
145 define( 'HYBRID_JS', trailingslashit( HYBRID_URI ) . 'js' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
146 }
147
148 /**
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
149 * Loads the core framework functions. These files are needed before loading anything else in the
150 * framework because they have required functions for use.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
151 *
c3cf33f Mark all 0.9.1 changes as 1.0.0 since that'll be the release version.
greenshady authored
152 * @since 1.0.0
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
153 */
154 function core() {
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
155
156 /* Load the core framework functions. */
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
157 require_once( HYBRID_FUNCTIONS . '/core.php' );
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
158
159 /* Load the context-based functions. */
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
160 require_once( HYBRID_FUNCTIONS . '/context.php' );
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
161
162 /* Theme prefix for creating things such as filter hooks (i.e., "$prefix_hook_name"). */
163 $this->prefix = hybrid_get_prefix();
164 }
165
166 /**
167 * Handles the locale functions file and translations.
168 *
169 * @since 1.0.0
170 */
171 function locale() {
172
173 /* Load theme textdomain. */
174 load_theme_textdomain( hybrid_get_textdomain() );
175
176 /* Get the user's locale. */
177 $locale = get_locale();
178
179 /* Locate a locale-specific functions file. */
180 $locale_functions = locate_template( array( "languages/{$locale}.php", "{$locale}.php" ) );
181
182 /* If the locale file exists and is readable, load it. */
183 if ( !empty( $locale_functions ) && is_readable( $locale_functions ) )
184 require_once( $locale_functions );
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
185 }
186
187 /**
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
188 * Loads the framework functions. Many of these functions are needed to properly run the
189 * framework. Some components are only loaded if the theme supports them.
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
190 *
3594f29 Documentation updates galore.
greenshady authored
191 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
192 */
193 function functions() {
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
194
195 /* Load the comments functions. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
196 require_once( HYBRID_FUNCTIONS . '/comments.php' );
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
197
198 /* Load media-related functions. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
199 require_once( HYBRID_FUNCTIONS . '/media.php' );
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
200
6469db8 Rename the template.php file to utility.php since most of the template s...
greenshady authored
201 /* Load the utility functions. */
202 require_once( HYBRID_FUNCTIONS . '/utility.php' );
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
203
204 /* Load the widget functions. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
205 require_once( HYBRID_FUNCTIONS . '/widgets.php' );
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
206
207 /* Load the menus functions if supported. */
208 require_if_theme_supports( 'hybrid-core-menus', HYBRID_FUNCTIONS . '/menus.php' );
209
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
210 /* Load the core SEO component. */
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
211 require_if_theme_supports( 'hybrid-core-seo', HYBRID_FUNCTIONS . '/core-seo.php' );
212
213 /* Load the shortcodes if supported. */
214 require_if_theme_supports( 'hybrid-core-shortcodes', HYBRID_FUNCTIONS . '/shortcodes.php' );
215
216 /* Load the template hierarchy if supported. */
217 require_if_theme_supports( 'hybrid-core-template-hierarchy', HYBRID_FUNCTIONS . '/template-hierarchy.php' );
218
219 /* Load the deprecated functions if supported. */
a37ce62 Move the deprecated.php file into the /functions folder and remove the o...
greenshady authored
220 require_if_theme_supports( 'hybrid-core-deprecated', HYBRID_FUNCTIONS . '/deprecated.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
221 }
222
223 /**
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
224 * Load extensions (external projects). Extensions are projects that are included within the
225 * framework but are not a part of it. They are external projects developed outside of the
226 * framework. Themes must use add_theme_support( $extension ) to use a specific extension
227 * within the theme. This should be declared on 'after_setup_theme' no later than a priority of 11.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
228 *
3594f29 Documentation updates galore.
greenshady authored
229 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
230 */
231 function extensions() {
232
233 /* Load the Breadcrumb Trail extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specific ...
greenshady authored
234 require_if_theme_supports( 'breadcrumb-trail', HYBRID_EXTENSIONS . '/breadcrumb-trail.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
235
236 /* Load the Custom Field Series extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specific ...
greenshady authored
237 require_if_theme_supports( 'custom-field-series', HYBRID_EXTENSIONS . '/custom-field-series.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
238
239 /* Load the Get the Image extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specific ...
greenshady authored
240 require_if_theme_supports( 'get-the-image', HYBRID_EXTENSIONS . '/get-the-image.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
241
242 /* Load the Get the Object extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specific ...
greenshady authored
243 require_if_theme_supports( 'get-the-object', HYBRID_EXTENSIONS . '/get-the-object.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
244
245 /* Load the Pagination extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specific ...
greenshady authored
246 require_if_theme_supports( 'loop-pagination', HYBRID_EXTENSIONS . '/loop-pagination.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
247
248 /* Load the Entry Views extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specific ...
greenshady authored
249 require_if_theme_supports( 'entry-views', HYBRID_EXTENSIONS . '/entry-views.php' );
680a354 Official introduction of the post layouts extension. First pass.
greenshady authored
250
251 /* Load the Post Layouts extension if supported. */
252 require_if_theme_supports( 'post-layouts', HYBRID_EXTENSIONS . '/post-layouts.php' );
e674efb Moving more Hybrid theme stuff out of core.
greenshady authored
253
982c613 Post Stylesheets is now officially an extension.
greenshady authored
254 /* Load the Post Stylesheets extension if supported. */
255 require_if_theme_supports( 'post-stylesheets', HYBRID_EXTENSIONS . '/post-stylesheets.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
256 }
257
258 /**
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
259 * Load admin files for the framework.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
260 *
3594f29 Documentation updates galore.
greenshady authored
261 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
262 */
263 function admin() {
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
264
265 /* Check if in the WordPress admin. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
266 if ( is_admin() ) {
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
267
268 /* Load the main admin file. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
269 require_once( HYBRID_ADMIN . '/admin.php' );
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
270
02c9e07 Cleaning up the admin functionality for a better development experience.
greenshady authored
271 /* Load the theme settings feature if supported. */
272 require_if_theme_supports( 'hybrid-core-theme-settings', HYBRID_ADMIN . '/theme-settings.php' );
1823e75 Better inline documentation for the Hybrid class.
greenshady authored
273
02c9e07 Cleaning up the admin functionality for a better development experience.
greenshady authored
274 /* Load the post meta box if supported. */
c3f35f5 Rename meta-box.php to a more appropriate post-meta-box.php.
greenshady authored
275 require_if_theme_supports( 'hybrid-core-post-meta-box', HYBRID_ADMIN . '/post-meta-box.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
276 }
277 }
278
279 /**
280 * Adds the default theme actions.
281 *
3594f29 Documentation updates galore.
greenshady authored
282 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
283 */
284 function actions() {
285
286 /* Remove WP and plugin functions. */
287 remove_action( 'wp_head', 'wp_generator' );
288
289 /* Head actions. */
e674efb Moving more Hybrid theme stuff out of core.
greenshady authored
290 add_action( 'wp_head', 'wp_generator', 1 );
291 add_action( 'wp_head', 'hybrid_meta_template', 1 );
292 add_action( 'wp_head', 'hybrid_head_pingback' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
293
13431f4 Removing support for the print style. This should be done on a theme-by...
greenshady authored
294 /* WP print scripts. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
295 add_action( 'template_redirect', 'hybrid_enqueue_script' );
296 }
297
298 /**
299 * Adds the default theme filters.
300 *
3594f29 Documentation updates galore.
greenshady authored
301 * @since 0.7.0
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
302 */
303 function filters() {
977325b Final (hopefully) update of the core Hybrid class to get the method load...
greenshady authored
304
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
305 /* Filter the textdomain mofile to allow child themes to load the parent theme translation. */
306 add_filter( 'load_textdomain_mofile', 'hybrid_load_textdomain', 10, 2 );
307
62f7c4e Better separation of core files and functions and a more logical load st...
greenshady authored
308 /* Make text widgets and term descriptions shortcode aware. */
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
309 add_filter( 'widget_text', 'do_shortcode' );
310 add_filter( 'term_description', 'do_shortcode' );
311
312 /* Stylesheet filters. */
901f79c Clean up the hybrid_debug_stylesheet() function, move the filter call to...
greenshady authored
313 add_filter( 'stylesheet_uri', 'hybrid_debug_stylesheet', 10, 2 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
314 }
315 }
316
317 ?>
Something went wrong with that request. Please try again.