clean_url

Definition:
function clean_url( $url, $protocols = null, $context = 'display' ) {}

Checks and cleans a URL.
A number of characters are removed from the URL. If the URL is for displaying (the default behaviour) ampersands are also replaced. The ‘clean_url’ filter is applied to the returned cleaned URL.

Parameters

  • string $url: The URL to be cleaned.
  • array $protocols: Optional. An array of acceptable protocols.
  • string $context: Optional. How the URL will be used. Default is ‘display’.

Return values

returns:The cleaned $url after the ‘clean_url’ filter is applied.

Source code

function clean_url( $url, $protocols = null, $context = 'display' ) {

	if ( $context == 'db' )

		_deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' );

	else

		_deprecated_function( __FUNCTION__, '3.0', 'esc_url()' );

	return esc_url( $url, $protocols, $context );

}

633

clean_term_cache

Definition:
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {}

Will remove all of the term ids from the cache.

Parameters

  • int|array $ids: Single or list of Term IDs
  • string $taxonomy: Can be empty and will assume tt_ids, else will use for context.
  • bool $clean_taxonomy: Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.

Defined actions

  • clean_term_cache
    do_action('clean_term_cache', $ids, $taxonomy);

Source code

function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {

	global $wpdb;

	static $cleaned = array();



	if ( !is_array($ids) )

		$ids = array($ids);



	$taxonomies = array();

	// If no taxonomy, assume tt_ids.

	if ( empty($taxonomy) ) {

		$tt_ids = array_map('intval', $ids);

		$tt_ids = implode(', ', $tt_ids);

		$terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)");

		$ids = array();

		foreach ( (array) $terms as $term ) {

			$taxonomies[] = $term->taxonomy;

			$ids[] = $term->term_id;

			wp_cache_delete($term->term_id, $term->taxonomy);

		}

		$taxonomies = array_unique($taxonomies);

	} else {

		$taxonomies = array($taxonomy);

		foreach ( $taxonomies as $taxonomy ) {

			foreach ( $ids as $id ) {

				wp_cache_delete($id, $taxonomy);

			}

		}

	}



	foreach ( $taxonomies as $taxonomy ) {

		if ( isset($cleaned[$taxonomy]) )

			continue;

		$cleaned[$taxonomy] = true;



		if ( $clean_taxonomy ) {

			wp_cache_delete('all_ids', $taxonomy);

			wp_cache_delete('get', $taxonomy);

			delete_option("{$taxonomy}_children");

			// Regenerate {$taxonomy}_children

			_get_term_hierarchy($taxonomy);

		}



		do_action('clean_term_cache', $ids, $taxonomy);

	}

631

clean_pre

Definition:
function clean_pre($matches) {}

Accepts matches array from preg_replace_callback in wpautop() or a string.
Ensures that the contents of a <pre>…</pre> HTML block are not converted into paragraphs or line-breaks.

Parameters

  • array|string $matches: The array or string

Return values

returns:The pre block without paragraph/line-break conversion.

Source code

function clean_pre($matches) {

	if ( is_array($matches) )

		$text = $matches[1] . $matches[2] . "</pre>";

	else

		$text = $matches;



	$text = str_replace('<br />', '', $text);

	$text = str_replace('<p>', "\n", $text);

	$text = str_replace('</p>', '', $text);



	return $text;

}

629

clean_post_cache

Definition:
function clean_post_cache($id) {}

Will clean the post in the cache.
Cleaning means delete from the cache of the post. Will call to clean the term object cache associated with the post ID.

Parameters

  • int $id: The Post ID in the cache to clean

Defined actions

  • clean_post_cache
    do_action('clean_post_cache', $id);

Source code

function clean_post_cache($id) {

	global $_wp_suspend_cache_invalidation, $wpdb;



	if ( !empty($_wp_suspend_cache_invalidation) )

		return;



	$id = (int) $id;



	if ( 0 === $id )

		return;



	wp_cache_delete($id, 'posts');

	wp_cache_delete($id, 'post_meta');



	clean_object_term_cache($id, 'post');



	wp_cache_delete( 'wp_get_archives', 'general' );



	do_action('clean_post_cache', $id);



	if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {

		foreach ( $children as $cid ) {

			// Loop detection

			if ( $cid == $id )

				continue;

			clean_post_cache( $cid );

		}

	}



	if ( is_multisite() )

		wp_cache_delete( $wpdb->blogid . '-' . $id, 'global-posts' );

}

627

clean_page_cache

Definition:
function clean_page_cache($id) {}

Will clean the page in the cache.
Clean (read: delete) page from cache that matches $id. Will also clean cache associated with ‘all_page_ids’ and ‘get_pages’.

Parameters

  • int $id: Page ID to clean

Defined actions

  • clean_page_cache
    do_action('clean_page_cache', $id);

Source code

function clean_page_cache($id) {

	clean_post_cache($id);



	wp_cache_delete( 'all_page_ids', 'posts' );

	wp_cache_delete( 'get_pages', 'posts' );



	do_action('clean_page_cache', $id);

}

625