wp_get_post_categories

Definition:
function wp_get_post_categories( $post_id = 0, $args = array() {}

Retrieve the list of categories for a post.
Compatibility layer for themes and plugins. Also an easy layer of abstraction away from the complexity of the taxonomy layer.

Parameters

  • int $post_id: Optional. The Post ID.
  • array $args: Optional. Overwrite the defaults.

Source code

function wp_get_post_categories( $post_id = 0, $args = array() ) {

	$post_id = (int) $post_id;



	$defaults = array('fields' => 'ids');

	$args = wp_parse_args( $args, $defaults );



	$cats = wp_get_object_terms($post_id, 'category', $args);

	return $cats;

}

3729

wp_get_post_autosave

Definition:
function wp_get_post_autosave( $post_id ) {}

Retrieve the autosaved data of the specified post.
Returns a post object containing the information that was autosaved for the specified post.

Parameters

  • int $post_id: The post ID.

Return values

returns:The autosaved data or false on failure or when no autosave exists.

Source code

function wp_get_post_autosave( $post_id ) {



	if ( !$post = get_post( $post_id ) )

		return false;



	$q = array(

		'name' => "{$post->ID}-autosave",

3727

wp_get_original_referer

Definition:
function wp_get_original_referer() {}

Retrieve original referer that was posted, if it exists.

Return values

returns:False if no original referer or original referer if set.

Source code

function wp_get_original_referer() {

	if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )

		return $_REQUEST['_wp_original_http_referer'];

	return false;

}

3725

wp_get_object_terms

Definition:
function wp_get_object_terms($object_ids, $taxonomies, $args = array() {}

Retrieves the terms associated with the given object(s), in the supplied taxonomies.
The following information has to do the $args parameter and for what can be contained in the string or array of that parameter, if it exists.

Parameters

  • int|array $object_ids: The ID(s) of the object(s) to retrieve.
  • string|array $taxonomies: The taxonomies to retrieve terms from.
  • array|string $args: Change what is returned

Return values

returns:The requested term data or empty array if no terms found. WP_Error if $taxonomy does not exist.

Defined filters

  • wp_get_object_terms
    apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args)

Source code

function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {

	global $wpdb;



	if ( !is_array($taxonomies) )

		$taxonomies = array($taxonomies);



	foreach ( (array) $taxonomies as $taxonomy ) {

		if ( ! taxonomy_exists($taxonomy) )

			return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));

	}



	if ( !is_array($object_ids) )

		$object_ids = array($object_ids);

	$object_ids = array_map('intval', $object_ids);



	$defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');

	$args = wp_parse_args( $args, $defaults );



	$terms = array();

	if ( count($taxonomies) > 1 ) {

		foreach ( $taxonomies as $index => $taxonomy ) {

			$t = get_taxonomy($taxonomy);

			if ( isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args) ) {

				unset($taxonomies[$index]);

				$terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));

			}

		}

	} else {

		$t = get_taxonomy($taxonomies[0]);

		if ( isset($t->args) && is_array($t->args) )

			$args = array_merge($args, $t->args);

	}



	extract($args, EXTR_SKIP);



	if ( 'count' == $orderby )

		$orderby = 'tt.count';

	else if ( 'name' == $orderby )

		$orderby = 't.name';

	else if ( 'slug' == $orderby )

		$orderby = 't.slug';

	else if ( 'term_group' == $orderby )

		$orderby = 't.term_group';

	else if ( 'term_order' == $orderby )

		$orderby = 'tr.term_order';

	else if ( 'none' == $orderby ) {

		$orderby = '';

		$order = '';

	} else {

		$orderby = 't.term_id';

	}



	// tt_ids queries can only be none or tr.term_taxonomy_id

	if ( ('tt_ids' == $fields) && !empty($orderby) )

		$orderby = 'tr.term_taxonomy_id';



	if ( !empty($orderby) )

		$orderby = "ORDER BY $orderby";



	$taxonomies = "'" . implode("', '", $taxonomies) . "'";

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



	$select_this = '';

	if ( 'all' == $fields )

		$select_this = 't.*, tt.*';

	else if ( 'ids' == $fields )

		$select_this = 't.term_id';

	else if ( 'names' == $fields )

		$select_this = 't.name';

	else if ( 'slugs' == $fields )

		$select_this = 't.slug';

	else if ( 'all_with_object_id' == $fields )

		$select_this = 't.*, tt.*, tr.object_id';



	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";



	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {

		$terms = array_merge($terms, $wpdb->get_results($query));

		update_term_cache($terms);

	} else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) {

		$terms = array_merge($terms, $wpdb->get_col($query));

	} else if ( 'tt_ids' == $fields ) {

		$terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");

	}



	if ( ! $terms )

		$terms = array();



	return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);

}

3723

wp_get_nocache_headers

Definition:
function wp_get_nocache_headers() {}

Gets the header information to prevent caching.
The several different headers cover the different ways cache prevention is handled by different browsers

Return values

returns:The associative array of header names and field values.

Defined filters

  • nocache_headers
    apply_filters('nocache_headers', $headers)

Source code

function wp_get_nocache_headers() {

	$headers = array(

		'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',

		'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',

		'Cache-Control' => 'no-cache, must-revalidate, max-age=0',

		'Pragma' => 'no-cache',

	);



	if ( function_exists('apply_filters') ) {

		$headers = (array) apply_filters('nocache_headers', $headers);

	}

	return $headers;

}

3721