Changeset 2703 for trunk/wp-includes/functions.php
- Timestamp:
- 07/11/2005 10:39:50 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r2702 r2703 1219 1219 function update_category_cache() { 1220 1220 global $cache_categories, $wpdb; 1221 $dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories"); 1222 foreach ($dogs as $catt) 1223 $cache_categories[$catt->cat_ID] = $catt; 1224 } 1225 1226 function update_user_cache() { 1227 global $cache_userdata, $wpdb; 1228 $level_key = $wpdb->prefix . 'user_level'; 1229 $user_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'"); 1230 $user_ids = join(',', $user_ids); 1231 $query = apply_filters('user_cache_query', "SELECT * FROM $wpdb->users WHERE ID IN ($user_ids)"); 1232 if ( $users = $wpdb->get_results( $query ) ) : 1233 foreach ($users as $user) : 1234 $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'"); 1235 foreach ( $metavalues as $meta ) { 1236 $user->{$meta->meta_key} = $meta->meta_value; 1237 // We need to set user_level from meta, not row 1238 if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) 1239 $user->user_level = $meta->meta_value; 1240 } 1241 1242 $cache_userdata[$user->ID] = $user; 1243 $cache_userdata[$user->user_login] =& $cache_userdata[$user->ID]; 1244 endforeach; 1221 if($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")): 1222 foreach ($dogs as $catt) 1223 $cache_categories[$catt->cat_ID] = $catt; 1245 1224 return true; 1246 else :1225 else: 1247 1226 return false; 1248 1227 endif; … … 1960 1939 } 1961 1940 1941 function get_usermeta( $user_id, $meta_key = '') { 1942 global $wpdb; 1943 $user_id = (int) $user_id; 1944 1945 if ( !empty($meta_key) ) { 1946 $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key); 1947 $metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); 1948 } else { 1949 $metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id'"); 1950 } 1951 1952 foreach ($metas as $index => $meta) { 1953 @ $value = unserialize($meta->meta_key); 1954 if ($value !== FALSE) 1955 $metas[$index]->meta_key = $value; 1956 } 1957 1958 if ( !empty($meta_key) ) 1959 return $metas[0]; 1960 else 1961 return $metas; 1962 } 1963 1962 1964 function update_usermeta( $user_id, $meta_key, $meta_value ) { 1963 1965 global $wpdb; … … 1965 1967 return false; 1966 1968 $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key); 1969 1970 if ( is_array($meta_value) || is_object($meta_value) ) 1971 $meta_value = serialize($meta_value); 1972 1967 1973 $cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); 1968 1974 if ( !$cur ) {
Note: See TracChangeset
for help on using the changeset viewer.