summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnAlbin2007-12-22 14:45:01 (GMT)
committer JohnAlbin2007-12-22 14:45:01 (GMT)
commit027e9d2af3ea337a23e54acf26dc7ccba7f194ca (patch)
tree555c65f7deeaa7f15e22753b9c668935662dad14
parent8ba4c4976ec98f61221550f5ba34010d03f6cd8f (diff)
Moved _phptemplate_HOOK functionality to _zen_hook().
-rw-r--r--template-subtheme.php28
-rw-r--r--template.php22
2 files changed, 27 insertions, 23 deletions
diff --git a/template-subtheme.php b/template-subtheme.php
index c5f225b..dbd9198 100644
--- a/template-subtheme.php
+++ b/template-subtheme.php
@@ -108,10 +108,32 @@ function _zen_default($hook, $variables, $suggestions = array(), $extension = '.
}
}
+/**
+ * To allow themes to have their own template files, we have to override
+ * _phptemplate_default() by dynamically defining _phptemplate_HOOK().
+ */
+function _zen_hook($hook) {
+ if (!function_exists("_phptemplate_$hook")) {
+ // Only create a function if $hook contains letters and underscores.
+ if (!preg_match('/\W/', $hook)) {
+ $declaration = <<<EOD
+ function _phptemplate_$hook(\$vars, \$suggestions = array()) {
+ return _zen_default('$hook', \$vars, \$suggestions);
+ }
+EOD;
+ eval($declaration);
+ }
+ else {
+ // Since we can't create an override function, we simply add a template
+ // suggestion that contains the sub-theme directory.
+ $vars['template_file'] = "$theme_key/$hook";
+ }
+ }
+}
+
/*
- * Rather than let _phptemplate_variables() dynamically, and slowly, define
- * override functions for functions we will definitely need, we define them
- * explicitly here.
+ * Rather than let _zen_hook() dynamically, and slowly, define override
+ * functions for functions we will definitely need, we define them explicitly.
*/
function _phptemplate_page($vars, $suggestions) {
return _zen_default('page', $vars, $suggestions);
diff --git a/template.php b/template.php
index 9be62ff..aeaf116 100644
--- a/template.php
+++ b/template.php
@@ -321,32 +321,14 @@ function _phptemplate_variables($hook, $vars = array()) {
break;
}
- /* To override _phptemplate_default(), we need to dynamically define a
- * _phptemplate_HOOK() function.
- */
- if (!function_exists("_phptemplate_$hook")) {
- // Only create a function if $hook contains letters and underscores.
- if (!preg_match('/\W/', $hook)) {
- $declaration = <<<EOD
- function _phptemplate_$hook(\$vars, \$suggestions = array()) {
- return _zen_default('$hook', \$vars, \$suggestions);
- }
-EOD;
- eval($declaration);
- }
- else {
- // Since we can't create an override function, we simply add a template
- // suggestion that contains the sub-theme directory.
- $vars['template_file'] = "$theme_key/$hook";
- }
- }
-
// The following is a deprecated function included for backwards compatibility
// with Zen 5.x-0.8 and earlier. New sub-themes should not use this function.
if (function_exists('zen_variables')) {
$vars = zen_variables($hook, $vars);
}
+ _zen_hook($hook); // Add support for sub-theme template files
+
return $vars;
}