Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 256 lines (204 sloc) 8.677 kb
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
1 <?php
2 /**
3 * The Hybrid class launches the framework. It's the organizational structure behind the
4 * entire theme. This class should be initialized before anything else in the theme is called.
5 *
6 * @package HybridCore
7 * @subpackage Classes
8 */
9
10 class Hybrid {
11
12 /**
13 * Theme prefix (mostly used for hooks).
14 *
15 * @since 0.7
16 * @var string
17 */
18 var $prefix;
19
20 /**
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
21 * PHP4 constructor method.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
22 *
23 * @since 0.9
24 */
25 function Hybrid() {
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
26 $this->__construct();
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
27 }
28
29 /**
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
30 * Constructor method for the Hybrid class. Initializes the theme framework, loads the
31 * required files, and calls the functions needed to run the framework.
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
32 *
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
33 * @since 0.9.1
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
34 */
7a9980c Appropriate PHP4 and PHP5 constructor methods.
greenshady authored
35 function __construct() {
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
36
37 /* Define theme constants. */
38 $this->constants();
39
40 /* Load theme functions. */
41 $this->functions();
42
43 /* Load legacy files and functions. */
44 $this->legacy();
45
46 /* Load admin files. */
47 $this->admin();
48
49 /* Theme prefix for creating things such as filter hooks (i.e., "$prefix_hook_name"). */
50 $this->prefix = hybrid_get_prefix();
51
52 /* Initialize the theme's default actions. */
53 $this->actions();
54
55 /* Initialize the theme's default filters. */
56 $this->filters();
57
58 /* Load theme extensions later since we need to check if they're supported. */
59 add_action( 'after_setup_theme', array( &$this, 'extensions' ), 12 );
60
61 /* Load theme textdomain. */
62 $domain = hybrid_get_textdomain();
63 $locale = get_locale();
64 load_theme_textdomain( $domain );
65
66 /* Load locale-specific functions file. */
67 $locale_functions = locate_template( array( "languages/{$locale}.php", "{$locale}.php" ) );
68 if ( !empty( $locale_functions ) && is_readable( $locale_functions ) )
69 require_once( $locale_functions );
70
71 /* Theme init hook. */
72 do_action( "{$this->prefix}_init" );
73 }
74
75 /**
76 * Defines the constant paths for use within the core framework, parent theme, and
77 * child theme. Constants prefixed with 'HYBRID_' are for use only within the core
78 * framework and don't reference other areas of the theme.
79 *
80 * @since 0.7
81 */
82 function constants() {
83 /* Sets the path to the parent theme directory. */
84 define( 'THEME_DIR', get_template_directory() );
85
86 /* Sets the path to the parent theme directory URI. */
87 define( 'THEME_URI', get_template_directory_uri() );
88
89 /* Sets the path to the child theme directory. */
90 define( 'CHILD_THEME_DIR', get_stylesheet_directory() );
91
92 /* Sets the path to the child theme directory URI. */
93 define( 'CHILD_THEME_URI', get_stylesheet_directory_uri() );
94
95 /* Sets the path to the core framework directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
96 define( 'HYBRID_DIR', trailingslashit( THEME_DIR ) . basename( dirname( __FILE__ ) ) );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
97
98 /* Sets the path to the core framework directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
99 define( 'HYBRID_URI', trailingslashit( THEME_URI ) . basename( dirname( __FILE__ ) ) );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
100
101 /* Sets the path to the core framework admin directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
102 define( 'HYBRID_ADMIN', trailingslashit( HYBRID_DIR ) . 'admin' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
103
104 /* Sets the path to the core framework classes directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
105 define( 'HYBRID_CLASSES', trailingslashit( HYBRID_DIR ) . 'classes' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
106
107 /* Sets the path to the core framework extensions directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
108 define( 'HYBRID_EXTENSIONS', trailingslashit( HYBRID_DIR ) . 'extensions' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
109
110 /* Sets the path to the core framework functions directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
111 define( 'HYBRID_FUNCTIONS', trailingslashit( HYBRID_DIR ) . 'functions' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
112
113 /* Sets the path to the core framework legacy directory. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
114 define( 'HYBRID_LEGACY', trailingslashit( HYBRID_DIR ) . 'legacy' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
115
116 /* Sets the path to the core framework images directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
117 define( 'HYBRID_IMAGES', trailingslashit( HYBRID_URI ) . 'images' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
118
119 /* Sets the path to the core framework CSS directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
120 define( 'HYBRID_CSS', trailingslashit( HYBRID_URI ) . 'css' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
121
122 /* Sets the path to the core framework JavaScript directory URI. */
40f0819 Moving the Hybrid class to the root directory of the framework. This…
greenshady authored
123 define( 'HYBRID_JS', trailingslashit( HYBRID_URI ) . 'js' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
124 }
125
126 /**
127 * Loads the core theme functions.
128 *
129 * @since 0.7
130 */
131 function functions() {
132 require_once( HYBRID_FUNCTIONS . '/core.php' );
133 require_once( HYBRID_FUNCTIONS . '/hooks-filters.php' );
134 require_once( HYBRID_FUNCTIONS . '/comments.php' );
135 require_once( HYBRID_FUNCTIONS . '/context.php' );
136 require_once( HYBRID_FUNCTIONS . '/media.php' );
18865d0 Always load the menus.php functions file. The checking for use of co…
greenshady authored
137 require_once( HYBRID_FUNCTIONS . '/menus.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
138 require_once( HYBRID_FUNCTIONS . '/shortcodes.php' );
139 require_once( HYBRID_FUNCTIONS . '/template.php' );
140 require_once( HYBRID_FUNCTIONS . '/widgets.php' );
141 }
142
143 /**
144 * Load extensions (external projects). Themes must use add_theme_support( $extension ) to
145 * use a specific extension within the theme. This should be declared on 'after_setup_theme' no
146 * later than the default priority of 10.
147 *
148 * @since 0.7
149 */
150 function extensions() {
151
152 /* Load the Breadcrumb Trail extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specif…
greenshady authored
153 require_if_theme_supports( 'breadcrumb-trail', HYBRID_EXTENSIONS . '/breadcrumb-trail.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
154
155 /* Load the Custom Field Series extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specif…
greenshady authored
156 require_if_theme_supports( 'custom-field-series', HYBRID_EXTENSIONS . '/custom-field-series.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
157
158 /* Load the Get the Image extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specif…
greenshady authored
159 require_if_theme_supports( 'get-the-image', HYBRID_EXTENSIONS . '/get-the-image.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
160
161 /* Load the Get the Object extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specif…
greenshady authored
162 require_if_theme_supports( 'get-the-object', HYBRID_EXTENSIONS . '/get-the-object.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
163
164 /* Load the Pagination extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specif…
greenshady authored
165 require_if_theme_supports( 'loop-pagination', HYBRID_EXTENSIONS . '/loop-pagination.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
166
167 /* Load the Entry Views extension if supported. */
673f7a8 Use the require_if_theme_supports() function for loading theme-specif…
greenshady authored
168 require_if_theme_supports( 'entry-views', HYBRID_EXTENSIONS . '/entry-views.php' );
680a354 Official introduction of the post layouts extension. First pass.
greenshady authored
169
170 /* Load the Post Layouts extension if supported. */
171 require_if_theme_supports( 'post-layouts', HYBRID_EXTENSIONS . '/post-layouts.php' );
e674efb Moving more Hybrid theme stuff out of core.
greenshady authored
172
982c613 Post Stylesheets is now officially an extension.
greenshady authored
173 /* Load the Post Stylesheets extension if supported. */
174 require_if_theme_supports( 'post-stylesheets', HYBRID_EXTENSIONS . '/post-stylesheets.php' );
175
e674efb Moving more Hybrid theme stuff out of core.
greenshady authored
176 /* Load the temporary core SEO component. */
177 require_if_theme_supports( 'hybrid-core-seo', HYBRID_FUNCTIONS . '/core-seo.php' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
178 }
179
180 /**
181 * Load legacy functions for backwards compatibility.
182 *
183 * @since 0.7
184 */
185 function legacy() {
186 require_once( HYBRID_LEGACY . '/deprecated.php' );
187 }
188
189 /**
190 * Load admin files.
191 *
192 * @since 0.7
193 */
194 function admin() {
195 if ( is_admin() ) {
196 require_once( HYBRID_ADMIN . '/admin.php' );
197 require_once( HYBRID_ADMIN . '/meta-box.php' );
198 require_once( HYBRID_ADMIN . '/settings-page.php' );
199 }
200 }
201
202 /**
203 * Adds the default theme actions.
204 *
205 * @since 0.7
206 */
207 function actions() {
208
209 /* Remove WP and plugin functions. */
210 remove_action( 'wp_head', 'wp_generator' );
211
212 /* Head actions. */
e674efb Moving more Hybrid theme stuff out of core.
greenshady authored
213 add_action( 'wp_head', 'wp_generator', 1 );
214 add_action( 'wp_head', 'hybrid_meta_template', 1 );
215 add_action( 'wp_head', 'hybrid_head_pingback' );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
216
217 /* WP print scripts and styles. */
218 add_action( 'template_redirect', 'hybrid_enqueue_style' );
219 add_action( 'template_redirect', 'hybrid_enqueue_script' );
220 }
221
222 /**
223 * Adds the default theme filters.
224 *
225 * @since 0.7
226 */
227 function filters() {
228 /* Filter the textdomain mofile to allow child themes to load the parent theme translation. */
229 add_filter( 'load_textdomain_mofile', 'hybrid_load_textdomain', 10, 2 );
230
231 /* Add same filters to user description as term descriptions. */
232 add_filter( 'get_the_author_description', 'wptexturize' );
233 add_filter( 'get_the_author_description', 'convert_chars' );
234 add_filter( 'get_the_author_description', 'wpautop' );
235 add_filter( 'get_the_author_description', 'shortcode_unautop' );
236
237 /* Make text widgets, term descriptions, and user descriptions shortcode aware. */
238 add_filter( 'widget_text', 'do_shortcode' );
239 add_filter( 'term_description', 'do_shortcode' );
240 add_filter( 'get_the_author_description', 'do_shortcode' );
241
242 /* Stylesheet filters. */
901f79c Clean up the hybrid_debug_stylesheet() function, move the filter call…
greenshady authored
243 add_filter( 'stylesheet_uri', 'hybrid_debug_stylesheet', 10, 2 );
0586624 Importing the initial Hybrid Core files and folders.
greenshady authored
244
245 /* Template filters. */
246 add_filter( 'date_template', 'hybrid_date_template' );
247 add_filter( 'author_template', 'hybrid_user_template' );
248 add_filter( 'tag_template', 'hybrid_taxonomy_template' );
249 add_filter( 'category_template', 'hybrid_taxonomy_template' );
250 add_filter( 'single_template', 'hybrid_singular_template' );
251 add_filter( 'page_template', 'hybrid_singular_template' );
252 add_filter( 'attachment_template', 'hybrid_singular_template' );
253 }
254 }
255
256 ?>
Something went wrong with that request. Please try again.