upgrade_100

Definition:
function upgrade_100() {}

Execute changes made in WordPress 1.0.

Source code

function upgrade_100() {

	global $wpdb;



	// Get the title and ID of every post, post_name to check if it already has a value

	$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");

	if ($posts) {

		foreach($posts as $post) {

			if ('' == $post->post_name) {

				$newtitle = sanitize_title($post->post_title);

				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );

			}

		}

	}



	$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");

	foreach ($categories as $category) {

		if ('' == $category->category_nicename) {

			$newtitle = sanitize_title($category->cat_name);

			$wpdb>update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );

		}

	}



	$wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')

	WHERE option_name LIKE 'links_rating_image%'

	AND option_value LIKE 'wp-links/links-images/%'");



	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");

	if ($done_ids) :

		foreach ($done_ids as $done_id) :

			$done_posts[] = $done_id->post_id;

		endforeach;

		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';

	else:

		$catwhere = '';

	endif;



	$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");

	if ($allposts) :

		foreach ($allposts as $post) {

			// Check to see if it's already been imported

			$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );

			if (!$cat && 0 != $post->post_category) { // If there's no result

				$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );

			}

		}

	endif;

}

3219

update_user_status

Definition:
function update_user_status( $id, $pref, $value, $deprecated = null ) {}

Parameters

  • $id
  • $pref
  • $value
  • $deprecated

Defined actions

  • make_spam_user
    do_action( 'make_spam_user', $id );
  • make_ham_user
    do_action( 'make_ham_user', $id );

Source code

function update_user_status( $id, $pref, $value, $deprecated = null ) {

	global $wpdb;



	if ( null !== $deprecated  )

		_deprecated_argument( __FUNCTION__, '3.1' );



	$wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) );



	clean_user_cache( $id );



	if ( $pref == 'spam' ) {

		if ( $value == 1 )

			do_action( 'make_spam_user', $id );

		else

			do_action( 'make_ham_user', $id );

	}



	return $value;

}

3217

update_user_option

Definition:
function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {}

Update user option with global blog capability.
User options are just like user metadata except that they have support for global blog options. If the ‘global’ parameter is false, which it is by default it will prepend the WordPress table prefix to the option name.

Parameters

  • int $user_id: User ID
  • string $option_name: User option name.
  • mixed $newvalue: User option value.
  • bool $global: Optional. Whether option name is global or blog specific. Default false (blog specific).

Source code

function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {

	global $wpdb;



	if ( !$global )

		$option_name = $wpdb->prefix . $option_name;



	// For backward compatibility. See differences between update_user_meta() and deprecated update_usermeta().

	// http://core.trac.wordpress.org/ticket/13088

	if ( is_null( $newvalue ) || is_scalar( $newvalue ) && empty( $newvalue ) )

		return delete_user_meta( $user_id, $option_name );



	return update_user_meta( $user_id, $option_name, $newvalue );

}

3215

update_user_meta

Definition:
function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {}

Update user meta field based on user ID.
Use the $prev_value parameter to differentiate between meta fields with the same key and user ID.

Parameters

  • int $user_id: Post ID.
  • string $meta_key: Metadata key.
  • mixed $meta_value: Metadata value.
  • mixed $prev_value: Optional. Previous value to check before removing.

Return values

returns:False on failure, true if success.

Source code

function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {

	return update_metadata('user', $user_id, $meta_key, $meta_value, $prev_value);

}

3213

update_user_caches

Definition:
function update_user_caches($user) {}

Update all user caches

Parameters

  • object $user: User object to be cached

Source code

function update_user_caches($user) {

	wp_cache_add($user->ID, $user, 'users');

	wp_cache_add($user->user_login, $user->ID, 'userlogins');

	wp_cache_add($user->user_email, $user->ID, 'useremail');

	wp_cache_add($user->user_nicename, $user->ID, 'userslugs');

}

3211