Unify user and author queries on cache_userdata
git-svn-id: http://svn.automattic.com/wordpress/trunk@1186 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
51335f97bb
commit
cbc0a250e7
|
@ -270,9 +270,10 @@ if ('' != $category_name) {
|
|||
$whichcat .= ")";
|
||||
}
|
||||
|
||||
// author stuff
|
||||
foreach ($users as $auteur) {
|
||||
$cache_authors[$auteur->ID] = $auteur;
|
||||
// Author/user stuff
|
||||
$users = $wpdb->get_results("SELECT * FROM $tableusers WHERE 1=1");
|
||||
foreach ($users as $user) {
|
||||
$cache_userdata[$user->ID] = $user;
|
||||
}
|
||||
|
||||
if ((empty($author)) || ($author == 'all') || ($author == '0')) {
|
||||
|
|
|
@ -175,8 +175,8 @@ function get_currentuserinfo() { // a bit like get_userdata(), on steroids
|
|||
}
|
||||
|
||||
function get_userdata($userid) {
|
||||
global $wpdb, $cache_authors, $tableusers;
|
||||
if ( empty($cache_authors[$userid]) ) {
|
||||
global $wpdb, $cache_userdata, $tableusers;
|
||||
if ( empty($cache_userdata[$userid]) ) {
|
||||
$user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = '$userid'");
|
||||
$user->user_nickname = stripslashes($user->user_nickname);
|
||||
$user->user_firstname = stripslashes($user->user_firstname);
|
||||
|
@ -1095,6 +1095,7 @@ function start_wp() {
|
|||
);
|
||||
}
|
||||
$authordata = get_userdata($post->post_author);
|
||||
|
||||
$day = mysql2date('d.m.y', $post->post_date);
|
||||
$currentmonth = mysql2date('m', $post->post_date);
|
||||
$numpages = 1;
|
||||
|
|
|
@ -5,6 +5,7 @@ function the_author($idmode = '', $echo = true) {
|
|||
if (empty($idmode)) {
|
||||
$idmode = $authordata->user_idmode;
|
||||
}
|
||||
|
||||
if ($idmode == 'nickname') $id = $authordata->user_nickname;
|
||||
if ($idmode == 'login') $id = $authordata->user_login;
|
||||
if ($idmode == 'firstname') $id = $authordata->user_firstname;
|
||||
|
@ -76,7 +77,7 @@ function the_author_posts_link($idmode='') {
|
|||
|
||||
|
||||
function get_author_link($echo = false, $author_id, $author_nicename) {
|
||||
global $wpdb, $tableusers, $post, $querystring_start, $querystring_equal, $cache_authors;
|
||||
global $wpdb, $tableusers, $post, $querystring_start, $querystring_equal, $cache_userdata;
|
||||
$auth_ID = $author_id;
|
||||
$permalink_structure = get_settings('permalink_structure');
|
||||
|
||||
|
@ -84,7 +85,7 @@ function get_author_link($echo = false, $author_id, $author_nicename) {
|
|||
$file = get_settings('siteurl') . '/' . get_settings('blogfilename');
|
||||
$link = $file.$querystring_start.'author'.$querystring_equal.$auth_ID;
|
||||
} else {
|
||||
if ('' == $author_nicename) $author_nicename = $cache_authors[$author_id]->author_nicename;
|
||||
if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->author_nicename;
|
||||
// Get any static stuff from the front
|
||||
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
|
||||
$link = get_settings('siteurl') . $front . 'author/';
|
||||
|
|
Loading…
Reference in New Issue