diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 0d0e739..c241bf5 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1114,6 +1114,22 @@ function theme($hook, $variables = array()) { // Generate the output using either a function or a template. $output = ''; + // Allow common HTML attributes arrays to be instantiated as Attribute objects + // later in the rendering process. Allows arrays to be manipulated as + // standard arrays in the preprocess and process phases. + if (!isset($default_attributes)) { + $default_attributes = new Attribute(); + } + foreach (array('attributes', 'title_attributes', 'content_attributes') as $key) { + if (isset($variables[$key]) && !($variables[$key] instanceof Attribute)) { + if ($variables[$key]) { + $variables[$key] = new Attribute($variables[$key]); + } + else { + $variables[$key] = clone $default_attributes; + } + } + } if (isset($info['function'])) { if (function_exists($info['function'])) { $output = $info['function']($variables); @@ -1160,20 +1176,6 @@ function theme($hook, $variables = array()) { template_preprocess($default_template_variables, $hook); $variables += $default_template_variables; } - if (!isset($default_attributes)) { - $default_attributes = new Attribute(); - } - foreach (array('attributes', 'title_attributes', 'content_attributes') as $key) { - if (isset($variables[$key]) && !($variables[$key] instanceof Attribute)) { - if ($variables[$key]) { - $variables[$key] = new Attribute($variables[$key]); - } - else { - // Create empty attributes. - $variables[$key] = clone $default_attributes; - } - } - } // Render the output using the template file. $template_file = $info['template'] . $extension;