wp_delete_category

Definition:
function wp_delete_category( $cat_ID ) {}

Deletes one existing category.

Parameters

  • int $cat_ID

Return values

returns:Returns true if completes delete action; false if term doesn’t exist; Zero on attempted deletion of default Category; WP_Error object is also a possibility.

Source code

function wp_delete_category( $cat_ID ) {

	return wp_delete_term( $cat_ID, 'category' );

}

10692

wp_dashboard_quota

Definition:
function wp_dashboard_quota() {}

Source code

function wp_dashboard_quota() {

	if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) )

		return true;



	$quota = get_space_allowed();

	$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;



	if ( $used > $quota )

		$percentused = '100';

	else

		$percentused = ( $used / $quota ) * 100;

	$used_color = ( $percentused >= 70 ) ? ' spam' : '';

	$used = round( $used, 2 );

	$percentused = number_format( $percentused );



	?>

	<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>

	<div class="table table_content musubtable">

	<table>

		<tr class="first">

			<td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>

			<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>

		</tr>

	</table>

	</div>

	<div class="table table_discussion musubtable">

	<table>

		<tr class="first">

			<td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td>

			<td class="last t comments<?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>

		</tr>

	</table>

	</div>

	<br class="clear" />

	<?php

}

10673

wp_create_user

Definition:
function wp_create_user($username, $password, $email = '') {}

A simpler way of inserting an user into the database.
Creates a new user with just the username, password, and email. For more complex user creation use wp_insert_user() to specify more information.

Parameters

  • string $username: The user’s username.
  • string $password: The user’s password.
  • string $email: The user’s email (optional).

Return values

returns:The new user’s ID.

Source code

function wp_create_user($username, $password, $email = '') {

	$user_login = esc_sql( $username );

	$user_email = esc_sql( $email    );

	$user_pass = $password;



	$userdata = compact('user_login', 'user_email', 'user_pass');

	return wp_insert_user($userdata);

}

10657

wp_check_term_hierarchy_for_loops

Definition:
function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {}

Checks the given subset of the term hierarchy for hierarchy loops.
Prevents loops from forming and breaks those that it finds.

Parameters

  • int $parent: term_id of the parent for the term we’re checking.
  • int $term_id: The term we’re checking.
  • string $taxonomy: The taxonomy of the term we’re checking.

Return values

returns:The new parent for the term.

Source code

function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {

	// Nothing fancy here - bail

	if ( !$parent )

		return 0;



	// Can't be its own parent

	if ( $parent == $term_id )

		return 0;



	// Now look for larger loops



	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )

		return $parent; // No loop



	// Setting $parent to the given value causes a loop

	if ( isset( $loop[$term_id] ) )

		return 0;



	// There's a loop, but it doesn't contain $term_id.  Break the loop.

	foreach ( array_keys( $loop ) as $loop_member )

		wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );



	return $parent;

}

10631

wp_check_post_hierarchy_for_loops

Definition:
function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {}

Checks the given subset of the post hierarchy for hierarchy loops.
Prevents loops from forming and breaks those that it finds.

Parameters

  • int $post_parent: ID of the parent for the post we’re checking.
  • $post_ID

Return values

returns:The new post_parent for the post.

Source code

function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {

	// Nothing fancy here - bail

	if ( !$post_parent )

		return 0;



	// New post can't cause a loop

	if ( empty( $post_ID ) )

		return $post_parent;



	// Can't be its own parent

	if ( $post_parent == $post_ID )

		return 0;



	// Now look for larger loops



	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )

		return $post_parent; // No loop



	// Setting $post_parent to the given value causes a loop

	if ( isset( $loop[$post_ID] ) )

		return 0;



	// There's a loop, but it doesn't contain $post_ID.  Break the loop.

	foreach ( array_keys( $loop ) as $loop_member )

		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );



	return $post_parent;

}

10628