diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 30161a2..9aadeae 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1084,7 +1084,7 @@ function template_preprocess_node(&$variables) { // http://drupal.org/node/1941286. $variables['name'] = theme('username', array( 'account' => $node, - 'link_attributes' => array('rel' => 'author'), + 'link_options' => array('attributes' => array('rel' => 'author')), )); $uri = $node->uri(); diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index aaea6bb..83606f2 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -647,13 +647,14 @@ function rdf_preprocess_user(&$variables) { * Implements hook_preprocess_HOOK() for theme_username(). */ function rdf_preprocess_username(&$variables) { + $attributes = array(); // Because lang is set on the HTML element that wraps the page, the // username inherits this language attribute. However, since the username // might not be transliterated to the same language that the content is in, // we do not want it to inherit the language attribute, so we set the // attribute to an empty string. if (empty($variables['attributes']['lang'])) { - $variables['attributes']['lang'] = ''; + $attributes['lang'] = ''; } // $variables['account'] is a pseudo account object, and as such, does not @@ -672,10 +673,9 @@ function rdf_preprocess_username(&$variables) { // a user profile URI for it (only a homepage which cannot be used as user // profile in RDF.) if ($variables['uid'] > 0) { - $variables['attributes']['about'] = url('user/' . $variables['uid']); + $attributes['about'] = url('user/' . $variables['uid']); } - $attributes = array(); // The typeof attribute specifies the RDF type(s) of this resource. They // are defined in the 'rdftype' property of the user RDF mapping. if (!empty($rdf_mapping['rdftype'])) { @@ -696,8 +696,14 @@ function rdf_preprocess_username(&$variables) { // separating the values in the RDFa attributes // (see http://www.w3.org/TR/rdfa-syntax/#rdfa-attributes). // Therefore, merge rather than override so as not to clobber values set by - // earlier preprocess functions. - $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], $attributes); + // earlier preprocess functions. These attributes will be placed in the a + // element if a link is rendered, or on a span element otherwise. + if (isset($variables['link_path'])) { + $variables['link_options']['attributes'] = array_merge_recursive($variables['link_options']['attributes'], $attributes); + } + else { + $variables['attributes'] = array_merge_recursive($variables['attributes'], $attributes); + } } /** diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 28083e0..fdfde30 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -738,6 +738,7 @@ function template_preprocess_username(&$variables) { } $variables['extra'] = ''; + $variables['attributes'] = array(); if (empty($account->uid)) { $variables['uid'] = 0; if (theme_get_setting('features.comment_user_verification')) { @@ -763,45 +764,21 @@ function template_preprocess_username(&$variables) { // Populate link path and attributes if appropriate. if ($variables['uid'] && $variables['profile_access']) { // We are linking to a local user. - $variables['link_attributes']['title'] = t('View user profile.'); + $variables['link_options']['attributes']['title'] = t('View user profile.'); $variables['link_path'] = 'user/' . $variables['uid']; } elseif (!empty($account->homepage)) { // Like the 'class' attribute, the 'rel' attribute can hold a // space-separated set of values, so initialize it as an array to make it // easier for other preprocess functions to append to it. - $variables['link_attributes']['rel'] = 'nofollow'; + $variables['link_options']['attributes']['rel'] = 'nofollow'; $variables['link_path'] = $account->homepage; $variables['homepage'] = $account->homepage; } // We do not want the l() function to check_plain() a second time. $variables['link_options']['html'] = TRUE; // Set a default class. - $variables['attributes'] = array('class' => array('username')); -} - -/** - * Processes variables for theme_username(). - * - * @see template_preprocess_username() - */ -function template_process_username(&$variables) { - // Finalize the link_options array for passing to the l() function. - // This is done in the process phase so that attributes may be added by - // modules or the theme during the preprocess phase. - if (isset($variables['link_path'])) { - // $variables['attributes'] contains attributes that should be applied - // regardless of whether a link is being rendered or not. - // $variables['link_attributes'] contains attributes that should only be - // applied if a link is being rendered. Preprocess functions are encouraged - // to use the former unless they want to add attributes on the link only. - // If a link is being rendered, these need to be merged. Some attributes are - // themselves arrays, so the merging needs to be recursive. - // This purposefully does not use - // \Drupal\Component\Utility\NestedArray::mergeDeep() for performance - // reasons, since it is potentially called very often. - $variables['link_options']['attributes'] = array_merge_recursive($variables['link_attributes'], $variables['attributes']); - } + $variables['link_options']['attributes']['class'] = array('username'); } /**