- Timestamp:
- 01/09/2019 05:43:14 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php
r42343 r44497 25 25 } 26 26 27 /** 28 * Creates a term object. 29 * 30 * @param array $args Array or string of arguments for inserting a term. 31 * 32 * @return array|WP_Error 33 */ 27 34 function create_object( $args ) { 28 35 $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); … … 34 41 } 35 42 43 /** 44 * Updates the term. 45 * 46 * @param int|object $term The term to update. 47 * @param array|string $fields The context in which to relate the term to the object. 48 * 49 * @return int The term id. 50 */ 36 51 function update_object( $term, $fields ) { 37 52 $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); … … 43 58 } 44 59 60 /** 61 * Attach terms on the given post. 62 * 63 * @param int $post_id The Post ID. 64 * @param string|array $terms An array of terms to set for the post, or a string of terms 65 * separated by commas. Hierarchical taxonomies must always pass IDs rather 66 * than names so that children with the same names but different parents 67 * aren't confused. 68 * @param string $taxonomy Taxonomy name. 69 * @param bool $append Optional. If true, don't delete existing terms, just add on. If false, 70 * replace the terms with the new terms. Default true. 71 * 72 * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure. 73 */ 45 74 function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) { 46 75 return wp_set_post_terms( $post_id, $terms, $taxonomy, $append ); … … 48 77 49 78 /** 50 * @return array|null|WP_Error|WP_Term 79 * Create a term and returns it as a object. 80 * 81 * @param array $args Array or string of arguments for inserting a term. 82 * @param null $generation_definitions The default values. 83 * 84 * @return null|WP_Error|WP_Term WP_Term on success. WP_error if taxonomy does not exist. Null for miscellaneous failure. 51 85 */ 52 86 function create_and_get( $args = array(), $generation_definitions = null ) { … … 56 90 } 57 91 92 /** 93 * Retrieves the term by given term id. 94 * 95 * @param int $term_id The term id to retrieve. 96 * 97 * @return null|WP_Error|WP_Term WP_Term on success. WP_error if taxonomy does not exist. Null for miscellaneous failure. 98 */ 58 99 function get_object_by_id( $term_id ) { 59 100 return get_term( $term_id, $this->taxonomy );
Note: See TracChangeset
for help on using the changeset viewer.