wpsc_delete_post_archives()WPSCache 1.0

No Hooks.

Return

null. Nothing (null).

Usage

wpsc_delete_post_archives( $post );
$post (required)
-

wpsc_delete_post_archives() code WPSCache 1.12.0

function wpsc_delete_post_archives( $post ) {
	$post = @get_post( $post );
	if ( ! is_object( $post ) ) {
		return;
	}

	// Taxonomies - categories, tags, custom taxonomies
	foreach ( get_object_taxonomies( $post, 'objects' ) as $taxonomy ) {

		if ( ! $taxonomy->public || ! $taxonomy->rewrite ) {
			continue;
		}

		$terms = get_the_terms( $post->ID, $taxonomy->name );
		if ( empty( $terms ) ) {
			continue;
		}

		foreach ( $terms as $term ) {

			$term_url = get_term_link( $term, $taxonomy->name );
			if ( is_wp_error( $term_url ) ) {
				continue;
			}

			wpsc_delete_url_cache( $term_url );
			wp_cache_debug( 'wpsc_delete_post_archives: deleting cache of taxonomies: ' . $term_url );
		}
	}

	// Post type archive page
	if ( $post->post_type === 'page' ) {
		$archive_url = false;
	} elseif ( $post->post_type === 'post' && get_option( 'show_on_front' ) !== 'posts' && ! get_option( 'page_for_posts' ) ) {
		$archive_url = false;
	} else {
		$archive_url = get_post_type_archive_link( $post->post_type );
	}

	if ( $archive_url ) {
		wpsc_delete_url_cache( $archive_url );
		wp_cache_debug( 'wpsc_delete_post_archives: deleting cache of post type archive: ' . $archive_url );
	}

	// Author archive page
	$author_url = get_author_posts_url( $post->post_author );
	if ( $author_url ) {
		wpsc_delete_url_cache( $author_url );
		wp_cache_debug( 'wpsc_delete_post_archives: deleting cache of author archive: ' . $author_url );
	}
}