summaryrefslogtreecommitdiffstats
path: root/wp-includes/taxonomy.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-06-24 17:00:10 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-06-24 17:00:10 +0000
commit631c9bb4d60d242432052f56c00768392f42a392 (patch)
tree50d41b0248d5c5fb156c6d52020675208b77a3e6 /wp-includes/taxonomy.php
parenta1fbe4e0694a66d7351e2f6280ab84568681e8e0 (diff)
downloadwordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.tar.gz
wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.tar.xz
wordpress-mu-631c9bb4d60d242432052f56c00768392f42a392.zip
WP Merge to revision 8180
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1336 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/taxonomy.php')
-rw-r--r--wp-includes/taxonomy.php485
1 files changed, 292 insertions, 193 deletions
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index e150d21..eaf8ade 100644
--- a/wp-includes/taxonomy.php
+++ b/wp-includes/taxonomy.php
@@ -20,13 +20,13 @@ $wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type'
$wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false);
/**
- * get_object_taxonomies() - Return all of the taxonomy names that are of $object_type
+ * Return all of the taxonomy names that are of $object_type.
*
* It appears that this function can be used to find all of the names inside of
* $wp_taxonomies global variable.
*
- * <code><?php $taxonomies = get_object_taxonomies('post'); ?></code>
- * Should result in <code>Array('category', 'post_tag')</code>
+ * <code><?php $taxonomies = get_object_taxonomies('post'); ?></code> Should
+ * result in <code>Array('category', 'post_tag')</code>
*
* @package WordPress
* @subpackage Taxonomy
@@ -58,7 +58,7 @@ function get_object_taxonomies($object) {
}
/**
- * get_taxonomy() - Returns the taxonomy object of $taxonomy.
+ * Retrieves the taxonomy object of $taxonomy.
*
* The get_taxonomy function will first check that the parameter string given
* is a taxonomy object and if it is, it will return it.
@@ -83,7 +83,7 @@ function get_taxonomy( $taxonomy ) {
}
/**
- * is_taxonomy() - Checks that the taxonomy name exists
+ * Checks that the taxonomy name exists.
*
* @package WordPress
* @subpackage Taxonomy
@@ -101,10 +101,10 @@ function is_taxonomy( $taxonomy ) {
}
/**
- * is_taxonomy_hierarchical() - Whether the taxonomy object is hierarchical
+ * Whether the taxonomy object is hierarchical.
*
- * Checks to make sure that the taxonomy is an object first. Then Gets the object, and finally
- * returns the hierarchical value in the object.
+ * Checks to make sure that the taxonomy is an object first. Then Gets the
+ * object, and finally returns the hierarchical value in the object.
*
* A false return value might also mean that the taxonomy does not exist.
*
@@ -127,19 +127,29 @@ function is_taxonomy_hierarchical($taxonomy) {
}
/**
- * register_taxonomy() - Create or modify a taxonomy object. Do not use before init.
+ * Create or modify a taxonomy object. Do not use before init.
*
- * A simple function for creating or modifying a taxonomy object based on the parameters given.
- * The function will accept an array (third optional parameter), along with strings for the
- * taxonomy name and another string for the object type.
+ * A simple function for creating or modifying a taxonomy object based on the
+ * parameters given. The function will accept an array (third optional
+ * parameter), along with strings for the taxonomy name and another string for
+ * the object type.
*
- * Nothing is returned, so expect error maybe or use is_taxonomy() to check whether taxonomy exists.
+ * Nothing is returned, so expect error maybe or use is_taxonomy() to check
+ * whether taxonomy exists.
*
* Optional $args contents:
- * hierarachical - has some defined purpose at other parts of the API and is a boolean value.
- * update_count_callback - works much like a hook, in that it will be called when the count is updated.
- * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize permastruct; default will use $taxonomy as slug
- * query_var - false to prevent queries, or string to customize query var (?$query_var=$term); default will use $taxonomy as query var
+ *
+ * hierarachical - has some defined purpose at other parts of the API and is a
+ * boolean value.
+ *
+ * update_count_callback - works much like a hook, in that it will be called
+ * when the count is updated.
+ *
+ * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize
+ * permastruct; default will use $taxonomy as slug.
+ *
+ * query_var - false to prevent queries, or string to customize query var
+ * (?$query_var=$term); default will use $taxonomy as query var.
*
* @package WordPress
* @subpackage Taxonomy
@@ -184,18 +194,19 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
//
/**
- * get_objects_in_term() - Return object_ids of valid taxonomy and term
+ * Retrieve object_ids of valid taxonomy and term.
*
- * The strings of $taxonomies must exist before this function will continue. On failure of finding
- * a valid taxonomy, it will return an WP_Error class, kind of like Exceptions in PHP 5, except you
- * can't catch them. Even so, you can still test for the WP_Error class and get the error message.
+ * The strings of $taxonomies must exist before this function will continue. On
+ * failure of finding a valid taxonomy, it will return an WP_Error class, kind
+ * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
+ * still test for the WP_Error class and get the error message.
*
- * The $terms aren't checked the same as $taxonomies, but still need to exist for $object_ids to
- * be returned.
+ * The $terms aren't checked the same as $taxonomies, but still need to exist
+ * for $object_ids to be returned.
*
- * It is possible to change the order that object_ids is returned by either using PHP sort family
- * functions or using the database by using $args with either ASC or DESC array. The value should
- * be in the key named 'order'.
+ * It is possible to change the order that object_ids is returned by either
+ * using PHP sort family functions or using the database by using $args with
+ * either ASC or DESC array. The value should be in the key named 'order'.
*
* @package WordPress
* @subpackage Taxonomy
@@ -244,26 +255,29 @@ function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
}
/**
- * get_term() - Get all Term data from database by Term ID.
+ * Get all Term data from database by Term ID.
*
- * The usage of the get_term function is to apply filters to a term object.
- * It is possible to get a term object from the database before applying the
+ * The usage of the get_term function is to apply filters to a term object. It
+ * is possible to get a term object from the database before applying the
* filters.
*
- * $term ID must be part of $taxonomy, to get from the database. Failure, might be
- * able to be captured by the hooks. Failure would be the same value as $wpdb returns for the
- * get_row method.
+ * $term ID must be part of $taxonomy, to get from the database. Failure, might
+ * be able to be captured by the hooks. Failure would be the same value as $wpdb
+ * returns for the get_row method.
*
- * There are two hooks, one is specifically for each term, named 'get_term', and the second is
- * for the taxonomy name, 'term_$taxonomy'. Both hooks gets the term object, and the taxonomy
- * name as parameters. Both hooks are expected to return a Term object.
+ * There are two hooks, one is specifically for each term, named 'get_term', and
+ * the second is for the taxonomy name, 'term_$taxonomy'. Both hooks gets the
+ * term object, and the taxonomy name as parameters. Both hooks are expected to
+ * return a Term object.
*
- * 'get_term' hook - Takes two parameters the term Object and the taxonomy name. Must return
- * term object. Used in get_term() as a catch-all filter for every $term.
+ * 'get_term' hook - Takes two parameters the term Object and the taxonomy name.
+ * Must return term object. Used in get_term() as a catch-all filter for every
+ * $term.
*
- * 'get_$taxonomy' hook - Takes two parameters the term Object and the taxonomy name. Must return
- * term object. $taxonomy will be the taxonomy name, so for example, if 'category', it would be
- * 'get_category' as the filter name. Useful for custom taxonomies or plugging into default taxonomies.
+ * 'get_$taxonomy' hook - Takes two parameters the term Object and the taxonomy
+ * name. Must return term object. $taxonomy will be the taxonomy name, so for
+ * example, if 'category', it would be 'get_category' as the filter name. Useful
+ * for custom taxonomies or plugging into default taxonomies.
*
* @package WordPress
* @subpackage Taxonomy
@@ -316,15 +330,16 @@ function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
}
/**
- * get_term_by() - Get all Term data from database by Term field and data.
+ * Get all Term data from database by Term field and data.
*
- * Warning: $value is not escaped for 'name' $field. You must do it yourself, if required.
+ * Warning: $value is not escaped for 'name' $field. You must do it yourself, if
+ * required.
*
- * The default $field is 'id', therefore it is possible to also use null for field, but not
- * recommended that you do so.
+ * The default $field is 'id', therefore it is possible to also use null for
+ * field, but not recommended that you do so.
*
- * If $value does not exist, the return value will be false. If $taxonomy exists and $field
- * and $value combinations exist, the Term will be returned.
+ * If $value does not exist, the return value will be false. If $taxonomy exists
+ * and $field and $value combinations exist, the Term will be returned.
*
* @package WordPress
* @subpackage Taxonomy
@@ -380,10 +395,10 @@ function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw
}
/**
- * get_term_children() - Merge all term children into a single array.
+ * Merge all term children into a single array.
*
- * This recursive function will merge all of the children of $term into
- * the same array. Only useful for taxonomies which are hierarchical.
+ * This recursive function will merge all of the children of $term into the same
+ * array. Only useful for taxonomies which are hierarchical.
*
* Will return an empty array if $term does not exist in $taxonomy.
*
@@ -419,11 +434,11 @@ function get_term_children( $term, $taxonomy ) {
}
/**
- * get_term_field() - Get sanitized Term field
+ * Get sanitized Term field.
*
- * Does checks for $term, based on the $taxonomy. The function is for
- * contextual reasons and for simplicity of usage. See sanitize_term_field() for
- * more information.
+ * Does checks for $term, based on the $taxonomy. The function is for contextual
+ * reasons and for simplicity of usage. See sanitize_term_field() for more
+ * information.
*
* @package WordPress
* @subpackage Taxonomy
@@ -453,10 +468,10 @@ function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
}
/**
- * get_term_to_edit() - Sanitizes Term for editing
+ * Sanitizes Term for editing.
*
- * Return value is sanitize_term() and usage is for sanitizing the term
- * for editing. Function is for contextual and simplicity.
+ * Return value is sanitize_term() and usage is for sanitizing the term for
+ * editing. Function is for contextual and simplicity.
*
* @package WordPress
* @subpackage Taxonomy
@@ -481,20 +496,24 @@ function get_term_to_edit( $id, $taxonomy ) {
}
/**
- * get_terms() - Retrieve the terms in taxonomy or list of taxonomies.
+ * Retrieve the terms in taxonomy or list of taxonomies.
*
- * You can fully inject any customizations to the query before it is sent, as well as control
- * the output with a filter.
+ * You can fully inject any customizations to the query before it is sent, as
+ * well as control the output with a filter.
*
- * The 'get_terms' filter will be called when the cache has the term and will pass the found
- * term along with the array of $taxonomies and array of $args. This filter is also called
- * before the array of terms is passed and will pass the array of terms, along with the $taxonomies
- * and $args.
+ * The 'get_terms' filter will be called when the cache has the term and will
+ * pass the found term along with the array of $taxonomies and array of $args.
+ * This filter is also called before the array of terms is passed and will pass
+ * the array of terms, along with the $taxonomies and $args.
*
- * The 'list_terms_exclusions' filter passes the compiled exclusions along with the $args.
+ * The 'list_terms_exclusions' filter passes the compiled exclusions along with
+ * the $args.
*
* The list that $args can contain, which will overwrite the defaults.
- * orderby - Default is 'name'. Can be name, count, or nothing (will use term_id).
+ *
+ * orderby - Default is 'name'. Can be name, count, or nothing (will use
+ * term_id).
+ *
* order - Default is ASC. Can use DESC.
* hide_empty - Default is true. Will not return empty $terms.
* fields - Default is all.
@@ -502,19 +521,21 @@ function get_term_to_edit( $id, $taxonomy ) {
* hierarchical - Whether to return hierarchical taxonomy. Default is true.
* name__like - Default is empty string.
*
- * The argument 'pad_counts' will count all of the children along with the $terms.
+ * The argument 'pad_counts' will count all of the children along with the
+ * $terms.
*
- * The 'get' argument allows for overwriting 'hide_empty' and 'child_of', which can be done by
- * setting the value to 'all', instead of its default empty string value.
+ * The 'get' argument allows for overwriting 'hide_empty' and 'child_of', which
+ * can be done by setting the value to 'all', instead of its default empty
+ * string value.
*
- * The 'child_of' argument will be used if you use multiple taxonomy or the first $taxonomy
- * isn't hierarchical or 'parent' isn't used. The default is 0, which will be translated to
- * a false value. If 'child_of' is set, then 'child_of' value will be tested against
- * $taxonomy to see if 'child_of' is contained within. Will return an empty array if test
- * fails.
+ * The 'child_of' argument will be used if you use multiple taxonomy or the
+ * first $taxonomy isn't hierarchical or 'parent' isn't used. The default is 0,
+ * which will be translated to a false value. If 'child_of' is set, then
+ * 'child_of' value will be tested against $taxonomy to see if 'child_of' is
+ * contained within. Will return an empty array if test fails.
*
- * If 'parent' is set, then it will be used to test against the first taxonomy. Much like
- * 'child_of'. Will return an empty array if the test fails.
+ * If 'parent' is set, then it will be used to test against the first taxonomy.
+ * Much like 'child_of'. Will return an empty array if the test fails.
*
* @package WordPress
* @subpackage Taxonomy
@@ -523,7 +544,6 @@ function get_term_to_edit( $id, $taxonomy ) {
* @uses $wpdb
* @uses wp_parse_args() Merges the defaults with those defined by $args and allows for strings.
*
- *
* @param string|array Taxonomy name or list of Taxonomy names
* @param string|array $args The values of what to search for when returning terms
* @return array|WP_Error List of Term Objects and their children. Will return WP_Error, if any of $taxonomies do not exist.
@@ -723,7 +743,7 @@ function &get_terms($taxonomies, $args = '') {
}
/**
- * is_term() - Check if Term exists
+ * Check if Term exists.
*
* Returns the index of a defined term, or 0 (false) if the term doesn't exist.
*
@@ -757,11 +777,11 @@ function is_term($term, $taxonomy = '') {
}
/**
- * sanitize_term() - Sanitize Term all fields
+ * Sanitize Term all fields.
*
- * Relys on sanitize_term_field() to sanitize the term. The difference
- * is that this function will sanitize <strong>all</strong> fields. The context
- * is based on sanitize_term_field().
+ * Relys on sanitize_term_field() to sanitize the term. The difference is that
+ * this function will sanitize <strong>all</strong> fields. The context is based
+ * on sanitize_term_field().
*
* The $term is expected to be either an array or an object.
*
@@ -798,15 +818,17 @@ function sanitize_term($term, $taxonomy, $context = 'display') {
}
/**
- * sanitize_term_field() - Cleanse the field value in the term based on the context
+ * Cleanse the field value in the term based on the context.
*
- * Passing a term field value through the function should be assumed to have cleansed
- * the value for whatever context the term field is going to be used.
+ * Passing a term field value through the function should be assumed to have
+ * cleansed the value for whatever context the term field is going to be used.
*
- * If no context or an unsupported context is given, then default filters will be applied.
+ * If no context or an unsupported context is given, then default filters will
+ * be applied.
*
- * There are enough filters for each context to support a custom filtering without creating
- * your own filter function. Simply create a function that hooks into the filter you need.
+ * There are enough filters for each context to support a custom filtering
+ * without creating your own filter function. Simply create a function that
+ * hooks into the filter you need.
*
* @package WordPress
* @subpackage Taxonomy
@@ -863,10 +885,10 @@ function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
}
/**
- * wp_count_terms() - Count how many terms are in Taxonomy
+ * Count how many terms are in Taxonomy.
*
- * Default $args is 'ignore_empty' which can be <code>'ignore_empty=true'</code> or
- * <code>array('ignore_empty' => true);</code>.
+ * Default $args is 'ignore_empty' which can be <code>'ignore_empty=true'</code>
+ * or <code>array('ignore_empty' => true);</code>.
*
* @package WordPress
* @subpackage Taxonomy
@@ -894,11 +916,11 @@ function wp_count_terms( $taxonomy, $args = array() ) {
}
/**
- * wp_delete_object_term_relationships() - Will unlink the term from the taxonomy
+ * Will unlink the term from the taxonomy.
*
- * Will remove the term's relationship to the taxonomy, not the term or taxonomy itself.
- * The term and taxonomy will still exist. Will require the term's object ID to perform
- * the operation.
+ * Will remove the term's relationship to the taxonomy, not the term or taxonomy
+ * itself. The term and taxonomy will still exist. Will require the term's
+ * object ID to perform the operation.
*
* @package WordPress
* @subpackage Taxonomy
@@ -925,10 +947,10 @@ function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
}
/**
- * wp_delete_term() - Removes a term from the database.
+ * Removes a term from the database.
*
- * If the term is a parent of other terms, then the children will be updated
- * to that term's parent.
+ * If the term is a parent of other terms, then the children will be updated to
+ * that term's parent.
*
* The $args 'default' will only override the terms found, if there is only one
* term found. Any other and the found terms are used.
@@ -938,9 +960,9 @@ function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
* @since 2.3
*
* @uses $wpdb
- * @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action hooks,
- * passing term object, term id. 'delete_term' gets an additional parameter with
- * the $taxonomy parameter.
+ * @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action
+ * hooks, passing term object, term id. 'delete_term' gets an additional
+ * parameter with the $taxonomy parameter.
*
* @param int $term Term ID
* @param string $taxonomy Taxonomy Name
@@ -1006,24 +1028,26 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
}
/**
- * wp_get_object_terms() - Retrieves the terms associated with the given object(s), in the supplied taxonomies.
+ * 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.
+ * 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.
*
- * The first argument is called, 'orderby' and has the default value of 'name'. The other value that is
- * supported is 'count'.
+ * The first argument is called, 'orderby' and has the default value of 'name'.
+ * The other value that is supported is 'count'.
*
- * The second argument is called, 'order' and has the default value of 'ASC'. The only other value that
- * will be acceptable is 'DESC'.
+ * The second argument is called, 'order' and has the default value of 'ASC'.
+ * The only other value that will be acceptable is 'DESC'.
*
- * The final argument supported is called, 'fields' and has the default value of 'all'. There are
- * multiple other options that can be used instead. Supported values are as follows: 'all', 'ids',
- * 'names', and finally 'all_with_object_id'.
+ * The final argument supported is called, 'fields' and has the default value of
+ * 'all'. There are multiple other options that can be used instead. Supported
+ * values are as follows: 'all', 'ids', 'names', and finally
+ * 'all_with_object_id'.
*
- * The fields argument also decides what will be returned. If 'all' or 'all_with_object_id' is choosen or
- * the default kept intact, then all matching terms objects will be returned. If either 'ids' or 'names'
- * is used, then an array of all matching term ids or term names will be returned respectively.
+ * The fields argument also decides what will be returned. If 'all' or
+ * 'all_with_object_id' is choosen or the default kept intact, then all matching
+ * terms objects will be returned. If either 'ids' or 'names' is used, then an
+ * array of all matching term ids or term names will be returned respectively.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1114,34 +1138,40 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
}
/**
- * wp_insert_term() - Adds a new term to the database. Optionally marks it as an alias of an existing term.
+ * Adds a new term to the database. Optionally marks it as an alias of an existing term.
*
- * Error handling is assigned for the nonexistance of the $taxonomy and $term parameters before inserting.
- * If both the term id and taxonomy exist previously, then an array will be returned that contains the term
- * id and the contents of what is returned. The keys of the array are 'term_id' and 'term_taxonomy_id' containing
- * numeric values.
+ * Error handling is assigned for the nonexistance of the $taxonomy and $term
+ * parameters before inserting. If both the term id and taxonomy exist
+ * previously, then an array will be returned that contains the term id and the
+ * contents of what is returned. The keys of the array are 'term_id' and
+ * 'term_taxonomy_id' containing numeric values.
*
- * It is assumed that the term does not yet exist or the above will apply. The term will be first added to the term
- * table and then related to the taxonomy if everything is well. If everything is correct, then several actions
- * will be run prior to a filter and then several actions will be run after the filter is run.
+ * It is assumed that the term does not yet exist or the above will apply. The
+ * term will be first added to the term table and then related to the taxonomy
+ * if everything is well. If everything is correct, then several actions will be
+ * run prior to a filter and then several actions will be run after the filter
+ * is run.
*
- * The arguments decide how the term is handled based on the $args parameter. The following
- * is a list of the available overrides and the defaults.
+ * The arguments decide how the term is handled based on the $args parameter.
+ * The following is a list of the available overrides and the defaults.
*
- * 'alias_of'. There is no default, but if added, expected is the slug that the term will be an alias of.
- * Expected to be a string.
+ * 'alias_of'. There is no default, but if added, expected is the slug that the
+ * term will be an alias of. Expected to be a string.
*
- * 'description'. There is no default. If exists, will be added to the database along with the term. Expected
- * to be a string.
+ * 'description'. There is no default. If exists, will be added to the database
+ * along with the term. Expected to be a string.
*
- * 'parent'. Expected to be numeric and default is 0 (zero). Will assign value of 'parent' to the term.
+ * 'parent'. Expected to be numeric and default is 0 (zero). Will assign value
+ * of 'parent' to the term.
*
* 'slug'. Expected to be a string. There is no default.
*
- * If 'slug' argument exists then the slug will be checked to see if it is not a valid term. If that check
- * succeeds (it is not a valid term), then it is added and the term id is given. If it fails, then a check
- * is made to whether the taxonomy is hierarchical and the parent argument is not empty. If the second check
- * succeeds, the term will be inserted and the term id will be given.
+ * If 'slug' argument exists then the slug will be checked to see if it is not
+ * a valid term. If that check succeeds (it is not a valid term), then it is
+ * added and the term id is given. If it fails, then a check is made to whether
+ * the taxonomy is hierarchical and the parent argument is not empty. If the
+ * second check succeeds, the term will be inserted and the term id will be
+ * given.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1237,13 +1267,15 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
}
/**
- * wp_set_object_terms() - Create Term and Taxonomy Relationships
+ * Create Term and Taxonomy Relationships.
*
- * Relates an object (post, link etc) to a term and taxonomy type. Creates the term and taxonomy
- * relationship if it doesn't already exist. Creates a term if it doesn't exist (using the slug).
+ * Relates an object (post, link etc) to a term and taxonomy type. Creates the
+ * term and taxonomy relationship if it doesn't already exist. Creates a term if
+ * it doesn't exist (using the slug).
*
- * A relationship means that the term is grouped in or belongs to the taxonomy. A term has no
- * meaning until it is given context by defining which taxonomy it exists under.
+ * A relationship means that the term is grouped in or belongs to the taxonomy.
+ * A term has no meaning until it is given context by defining which taxonomy it
+ * exists under.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1317,17 +1349,17 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
}
/**
- * wp_unique_term_slug() - Will make slug unique, if it isn't already
+ * Will make slug unique, if it isn't already.
*
- * The $slug has to be unique global to every taxonomy, meaning that one taxonomy
- * term can't have a matching slug with another taxonomy term. Each slug has to be
- * globally unique for every taxonomy.
+ * The $slug has to be unique global to every taxonomy, meaning that one
+ * taxonomy term can't have a matching slug with another taxonomy term. Each
+ * slug has to be globally unique for every taxonomy.
*
- * The way this works is that if the taxonomy that the term belongs to is heirarchical
- * and has a parent, it will append that parent to the $slug.
+ * The way this works is that if the taxonomy that the term belongs to is
+ * heirarchical and has a parent, it will append that parent to the $slug.
*
- * If that still doesn't return an unique slug, then it try to append a number until
- * it finds a number that is truely unique.
+ * If that still doesn't return an unique slug, then it try to append a number
+ * until it finds a number that is truely unique.
*
* The only purpose for $term is for appending a parent, if one exists.
*
@@ -1378,25 +1410,25 @@ function wp_unique_term_slug($slug, $term) {
}
/**
- * wp_update_term() - Update term based on arguments provided
+ * Update term based on arguments provided.
*
- * The $args will indiscriminately override all values with the same field name. Care
- * must be taken to not override important information need to update or update will
- * fail (or perhaps create a new term, neither would be acceptable).
+ * The $args will indiscriminately override all values with the same field name.
+ * Care must be taken to not override important information need to update or
+ * update will fail (or perhaps create a new term, neither would be acceptable).
*
- * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not defined
- * in $args already.
+ * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not
+ * defined in $args already.
*
- * 'alias_of' will create a term group, if it doesn't already exist, and update it for
- * the $term.
+ * 'alias_of' will create a term group, if it doesn't already exist, and update
+ * it for the $term.
*
- * If the 'slug' argument in $args is missing, then the 'name' in $args will be used.
- * It should also be noted that if you set 'slug' and it isn't unique then a WP_Error
- * will be passed back. If you don't pass any slug, then a unique one will be created
- * for you.
+ * If the 'slug' argument in $args is missing, then the 'name' in $args will be
+ * used. It should also be noted that if you set 'slug' and it isn't unique then
+ * a WP_Error will be passed back. If you don't pass any slug, then a unique one
+ * will be created for you.
*
- * For what can be overrode in $args, check the term scheme can contain and stay away
- * from the term keys.
+ * For what can be overrode in $args, check the term scheme can contain and stay
+ * away from the term keys.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1404,8 +1436,8 @@ function wp_unique_term_slug($slug, $term) {
*
* @uses $wpdb
* @uses do_action() Will call both 'edit_term' and 'edit_$taxonomy' twice.
- * @uses apply_filters() Will call the 'term_id_filter' filter and pass the term id and
- * taxonomy id.
+ * @uses apply_filters() Will call the 'term_id_filter' filter and pass the term
+ * id and taxonomy id.
*
* @param int $term The ID of the term
* @param string $taxonomy The context in which to relate the term to the object.
@@ -1492,8 +1524,14 @@ function wp_update_term( $term, $taxonomy, $args = array() ) {
return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
}
-// enable or disable term count deferring
-// if no value is supplied, the current value of the defer setting is returned
+/**
+ * Enable or disable term counting.
+ *
+ * @since 2.6
+ *
+ * @param bool $defer Optional.
+ * @return bool
+ */
function wp_defer_term_counting($defer=NULL) {
static $_defer = false;
@@ -1508,12 +1546,13 @@ function wp_defer_term_counting($defer=NULL) {
}
/**
- * wp_update_term_count() - Updates the amount of terms in taxonomy
+ * Updates the amount of terms in taxonomy.
*
- * If there is a taxonomy callback applyed, then it will be called for updating the count.
+ * If there is a taxonomy callback applyed, then it will be called for updating
+ * the count.
*
- * The default action is to count what the amount of terms have the relationship of term ID.
- * Once that is done, then update the database.
+ * The default action is to count what the amount of terms have the relationship
+ * of term ID. Once that is done, then update the database.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1550,6 +1589,15 @@ function wp_update_term_count( $terms, $taxonomy, $do_deferred=false ) {
return wp_update_term_count_now( $terms, $taxonomy );
}
+/**
+ * Perform term count update immediately.
+ *
+ * @since 2.6
+ *
+ * @param array $terms IDs of Terms to update.
+ * @param string $taxonomy The context of the term.
+ * @return bool Always true when complete.
+ */
function wp_update_term_count_now( $terms, $taxonomy ) {
global $wpdb;
@@ -1576,11 +1624,13 @@ function wp_update_term_count_now( $terms, $taxonomy ) {
// Cache
//
+
/**
- * clean_object_term_cache() - Removes the taxonomy relationship to terms from the cache.
+ * Removes the taxonomy relationship to terms from the cache.
*
- * Will remove the entire taxonomy relationship containing term $object_id. The term IDs
- * have to exist within the taxonomy $object_type for the deletion to take place.
+ * Will remove the entire taxonomy relationship containing term $object_id. The
+ * term IDs have to exist within the taxonomy $object_type for the deletion to
+ * take place.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1604,8 +1654,9 @@ function clean_object_term_cache($object_ids, $object_type) {
do_action('clean_object_term_cache', $object_ids, $object_type);
}
+
/**
- * clean_term_cache() - Will remove all of the term ids from the cache
+ * Will remove all of the term ids from the cache.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1649,8 +1700,9 @@ function clean_term_cache($ids, $taxonomy = '') {
do_action('clean_term_cache', $ids, $taxonomy);
}
+
/**
- * get_object_term_cache() - Retrieves the taxonomy relationship to the term object id.
+ * Retrieves the taxonomy relationship to the term object id.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1667,19 +1719,19 @@ function &get_object_term_cache($id, $taxonomy) {
return $cache;
}
+
/**
- * update_object_term_cache() - Updates the cache for Term ID(s)
+ * Updates the cache for Term ID(s).
*
* Will only update the cache for terms not already cached.
*
- * The $object_ids expects that the ids be separated by commas, if it is
- * a string.
+ * The $object_ids expects that the ids be separated by commas, if it is a
+ * string.
*
- * It should be noted that update_object_term_cache() is very time extensive.
- * It is advised that the function is not called very often or at least not
- * for a lot of terms that exist in a lot of taxonomies. The amount of time
- * increases for each term and it also increases for each taxonomy the term
- * belongs to.
+ * It should be noted that update_object_term_cache() is very time extensive. It
+ * is advised that the function is not called very often or at least not for a
+ * lot of terms that exist in a lot of taxonomies. The amount of time increases
+ * for each term and it also increases for each taxonomy the term belongs to.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1737,8 +1789,9 @@ function update_object_term_cache($object_ids, $object_type) {
}
}
+
/**
- * update_term_cache() - Updates Terms to Taxonomy in cache.
+ * Updates Terms to Taxonomy in cache.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1761,16 +1814,17 @@ function update_term_cache($terms, $taxonomy = '') {
// Private
//
+
/**
- * _get_term_hierarchy() - Retrieves children of taxonomy
+ * Retrieves children of taxonomy.
*
* @package WordPress
* @subpackage Taxonomy
* @access private
* @since 2.3
*
- * @uses update_option() Stores all of the children in "$taxonomy_children" option.
- * That is the name of the taxonomy, immediately followed by '_children'.
+ * @uses update_option() Stores all of the children in "$taxonomy_children"
+ * option. That is the name of the taxonomy, immediately followed by '_children'.
*
* @param string $taxonomy Taxonomy Name
* @return array Empty if $taxonomy isn't hierarachical or returns children.
@@ -1793,11 +1847,13 @@ function _get_term_hierarchy($taxonomy) {
return $children;
}
+
/**
- * _get_term_children() - Get array of child terms
+ * Get array of child terms.
*
- * If $terms is an array of objects, then objects will returned from the function.
- * If $terms is an array of IDs, then an array of ids of children will be returned.
+ * If $terms is an array of objects, then objects will returned from the
+ * function. If $terms is an array of IDs, then an array of ids of children will
+ * be returned.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1849,11 +1905,12 @@ function &_get_term_children($term_id, $terms, $taxonomy) {
return $term_list;
}
+
/**
- * _pad_term_counts() - Add count of children to parent count
+ * Add count of children to parent count.
*
- * Recalculates term counts by including items from child terms.
- * Assumes all relevant children are already in the $terms argument
+ * Recalculates term counts by including items from child terms. Assumes all
+ * relevant children are already in the $terms argument.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1913,9 +1970,10 @@ function _pad_term_counts(&$terms, $taxonomy) {
//
/**
- * _update_post_term_count() - Will update term count based on posts
+ * Will update term count based on posts.
*
- * Private function for the default callback for post_tag and category taxonomies.
+ * Private function for the default callback for post_tag and category
+ * taxonomies.
*
* @package WordPress
* @subpackage Taxonomy
@@ -1934,8 +1992,11 @@ function _update_post_term_count( $terms ) {
}
}
+
/**
- * get_term_link() - Generates a permalink for a taxonomy term archive
+ * Generates a permalink for a taxonomy term archive.
+ *
+ * @since 2.6
*
* @param object|int|string $term
* @param string $taxonomy
@@ -1978,6 +2039,24 @@ function get_term_link( $term, $taxonomy ) {
return apply_filters('term_link', $termlink, $term, $taxonomy);
}
+/**
+ * Display the taxonomies of a post with available options.
+ *
+ * This function can be used within the loop to display the taxonomies for a
+ * post without specifying the Post ID. You can also use it outside the Loop to
+ * display the taxonomies for a specific post.
+ *
+ * The available defaults are:
+ * 'post' : default is 0. The post ID to get taxonomies of.
+ * 'before' : default is empty string. Display before taxonomies list.
+ * 'sep' : default is empty string. Separate every taxonomy with value in this.
+ * 'after' : default is empty string. Display this after the taxonomies list.
+ *
+ * @since 2.6
+ * @uses get_the_taxonomies()
+ *
+ * @param array $args Override the defaults.
+ */
function the_taxonomies($args = array()) {
$defaults = array(
'post' => 0,
@@ -1992,6 +2071,17 @@ function the_taxonomies($args = array()) {
echo $before . join($sep, get_the_taxonomies($post)) . $after;
}
+/**
+ * Retrieve all taxonomies associated with a post.
+ *
+ * This function can be used within the loop. It will also return an array of
+ * the taxonomies with links to the taxonomy and name.
+ *
+ * @since 2.6
+ *
+ * @param int $post Optional. Post ID or will use Global Post ID (in loop).
+ * @return array
+ */
function get_the_taxonomies($post = 0) {
if ( is_int($post) )
$post =& get_post($post);
@@ -2029,6 +2119,15 @@ function get_the_taxonomies($post = 0) {
return $taxonomies;
}
+/**
+ * Retrieve all taxonomies of a post with just the names.
+ *
+ * @since 2.6
+ * @uses get_object_taxonomies()
+ *
+ * @param int $post Optional. Post ID
+ * @return array
+ */
function get_post_taxonomies($post = 0) {
$post =& get_post($post);