function google_authorship_preprocess_username in Google Authorship 7
Same name and namespace in other branches
- 7.2 google_authorship.module \google_authorship_preprocess_username()
Implements template_preprocess_username().
Alters the 'name' variable to be a link to a Google+ profile and sets the "rel='author'" parameter on the generate URL.
File
- ./
google_authorship.module, line 25 - A module to display Google+ profile pictures of node authors in Google search results.
Code
function google_authorship_preprocess_username(&$variables) {
// Checks if the loaded page is a node page.
$is_node_page = $node = menu_get_object('node');
// Checks whether author is a comment author.
$is_not_comment = !isset($variables['account']->comment_body);
// Checks to see if the author's Google+ ID is set, and if so, sets a variable
// for the id.
$is_id_set = $google_id = google_authorship_get_google_id($variables['uid']);
// Checks conditions set above and if it passes, alters the link path of the
// author.
if ($is_node_page && $is_not_comment && $is_id_set) {
$variables['link_path'] = GOOGLE_AUTHORSHIP_PREFIX . $google_id . "?rel=author";
}
}