wp/wp-includes/class-wp-term.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 18 be944660c56a
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
   100 
   100 
   101 	/**
   101 	/**
   102 	 * Retrieve WP_Term instance.
   102 	 * Retrieve WP_Term instance.
   103 	 *
   103 	 *
   104 	 * @since 4.4.0
   104 	 * @since 4.4.0
   105 	 * @static
       
   106 	 *
   105 	 *
   107 	 * @global wpdb $wpdb WordPress database abstraction object.
   106 	 * @global wpdb $wpdb WordPress database abstraction object.
   108 	 *
   107 	 *
   109 	 * @param int    $term_id  Term ID.
   108 	 * @param int    $term_id  Term ID.
   110 	 * @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for
   109 	 * @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for
   141 						$_term = $match;
   140 						$_term = $match;
   142 						break;
   141 						break;
   143 					}
   142 					}
   144 				}
   143 				}
   145 
   144 
   146 			// If only one match was found, it's the one we want.
   145 				// If only one match was found, it's the one we want.
   147 			} elseif ( 1 === count( $terms ) ) {
   146 			} elseif ( 1 === count( $terms ) ) {
   148 				$_term = reset( $terms );
   147 				$_term = reset( $terms );
   149 
   148 
   150 			// Otherwise, the term must be shared between taxonomies.
   149 				// Otherwise, the term must be shared between taxonomies.
   151 			} else {
   150 			} else {
   152 				// If the term is shared only with invalid taxonomies, return the one valid term.
   151 				// If the term is shared only with invalid taxonomies, return the one valid term.
   153 				foreach ( $terms as $t ) {
   152 				foreach ( $terms as $t ) {
   154 					if ( ! taxonomy_exists( $t->taxonomy ) ) {
   153 					if ( ! taxonomy_exists( $t->taxonomy ) ) {
   155 						continue;
   154 						continue;
   230 	 * @param string $key Property to get.
   229 	 * @param string $key Property to get.
   231 	 * @return mixed Property value.
   230 	 * @return mixed Property value.
   232 	 */
   231 	 */
   233 	public function __get( $key ) {
   232 	public function __get( $key ) {
   234 		switch ( $key ) {
   233 		switch ( $key ) {
   235 			case 'data' :
   234 			case 'data':
   236 				$data = new stdClass();
   235 				$data    = new stdClass();
   237 				$columns = array( 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count' );
   236 				$columns = array( 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count' );
   238 				foreach ( $columns as $column ) {
   237 				foreach ( $columns as $column ) {
   239 					$data->{$column} = isset( $this->{$column} ) ? $this->{$column} : null;
   238 					$data->{$column} = isset( $this->{$column} ) ? $this->{$column} : null;
   240 				}
   239 				}
   241 
   240