Add option defaults. Add arg to get_user_option() to avoid querying options table if user option is missing. see #8229

git-svn-id: http://svn.automattic.com/wordpress/trunk@9871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-11-25 18:33:04 +00:00
parent e05cff11ea
commit ceee359abf
8 changed files with 25 additions and 15 deletions

View File

@@ -168,9 +168,10 @@ function user_pass_ok($user_login, $user_pass) {
*
* @param string $option User option name.
* @param int $user Optional. User ID.
* @param bool $check_global Whether to check for a global option if a per-user option does not exist. Default is true.
* @return mixed
*/
function get_user_option( $option, $user = 0 ) {
function get_user_option( $option, $user = 0, $check_global = true ) {
global $wpdb;
$option = preg_replace('|[^a-z0-9_]|i', '', $option);
@@ -183,8 +184,10 @@ function get_user_option( $option, $user = 0 ) {
$result = $user->{$wpdb->prefix . $option};
elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
$result = $user->{$option};
else // Blog global
elseif ( $check_global ) // Blog global
$result = get_option( $option );
else
$result = false;
return apply_filters("get_user_option_{$option}", $result, $option, $user);
}

View File

@@ -15,6 +15,6 @@ $wp_version = '2.7-beta3-9863';
*
* @global int $wp_db_version
*/
$wp_db_version = 9621;
$wp_db_version = 9872;
?>