equal
deleted
inserted
replaced
34 * @link http://codex.wordpress.org/Function_Reference/get_categories |
34 * @link http://codex.wordpress.org/Function_Reference/get_categories |
35 * |
35 * |
36 * @param string|array $args Optional. Change the defaults retrieving categories. |
36 * @param string|array $args Optional. Change the defaults retrieving categories. |
37 * @return array List of categories. |
37 * @return array List of categories. |
38 */ |
38 */ |
39 function &get_categories( $args = '' ) { |
39 function get_categories( $args = '' ) { |
40 $defaults = array( 'taxonomy' => 'category' ); |
40 $defaults = array( 'taxonomy' => 'category' ); |
41 $args = wp_parse_args( $args, $defaults ); |
41 $args = wp_parse_args( $args, $defaults ); |
42 |
42 |
43 $taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); |
43 $taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); |
44 |
44 |
76 * @param int|object $category Category ID or Category row object |
76 * @param int|object $category Category ID or Category row object |
77 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N |
77 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N |
78 * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. |
78 * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. |
79 * @return mixed Category data in type defined by $output parameter. |
79 * @return mixed Category data in type defined by $output parameter. |
80 */ |
80 */ |
81 function &get_category( $category, $output = OBJECT, $filter = 'raw' ) { |
81 function get_category( $category, $output = OBJECT, $filter = 'raw' ) { |
82 $category = get_term( $category, 'category', $output, $filter ); |
82 $category = get_term( $category, 'category', $output, $filter ); |
83 if ( is_wp_error( $category ) ) |
83 if ( is_wp_error( $category ) ) |
84 return $category; |
84 return $category; |
85 |
85 |
86 _make_cat_compat( $category ); |
86 _make_cat_compat( $category ); |
163 /** |
163 /** |
164 * Retrieve the ID of a category from its name. |
164 * Retrieve the ID of a category from its name. |
165 * |
165 * |
166 * @since 1.0.0 |
166 * @since 1.0.0 |
167 * |
167 * |
168 * @param string $cat_name Optional. Default is 'General' and can be any category name. |
168 * @param string $cat_name Category name. |
169 * @return int 0, if failure and ID of category on success. |
169 * @return int 0, if failure and ID of category on success. |
170 */ |
170 */ |
171 function get_cat_ID( $cat_name='General' ) { |
171 function get_cat_ID( $cat_name ) { |
172 $cat = get_term_by( 'name', $cat_name, 'category' ); |
172 $cat = get_term_by( 'name', $cat_name, 'category' ); |
173 if ( $cat ) |
173 if ( $cat ) |
174 return $cat->term_id; |
174 return $cat->term_id; |
175 return 0; |
175 return 0; |
176 } |
176 } |
183 * @param int $cat_id Category ID |
183 * @param int $cat_id Category ID |
184 * @return string Category name, or an empty string if category doesn't exist. |
184 * @return string Category name, or an empty string if category doesn't exist. |
185 */ |
185 */ |
186 function get_cat_name( $cat_id ) { |
186 function get_cat_name( $cat_id ) { |
187 $cat_id = (int) $cat_id; |
187 $cat_id = (int) $cat_id; |
188 $category = &get_category( $cat_id ); |
188 $category = get_category( $cat_id ); |
189 if ( ! $category || is_wp_error( $category ) ) |
189 if ( ! $category || is_wp_error( $category ) ) |
190 return ''; |
190 return ''; |
191 return $category->name; |
191 return $category->name; |
192 } |
192 } |
193 |
193 |
247 * @uses apply_filters() Calls 'get_tags' hook on array of tags and with $args. |
247 * @uses apply_filters() Calls 'get_tags' hook on array of tags and with $args. |
248 * |
248 * |
249 * @param string|array $args Tag arguments to use when retrieving tags. |
249 * @param string|array $args Tag arguments to use when retrieving tags. |
250 * @return array List of tags. |
250 * @return array List of tags. |
251 */ |
251 */ |
252 function &get_tags( $args = '' ) { |
252 function get_tags( $args = '' ) { |
253 $tags = get_terms( 'post_tag', $args ); |
253 $tags = get_terms( 'post_tag', $args ); |
254 |
254 |
255 if ( empty( $tags ) ) { |
255 if ( empty( $tags ) ) { |
256 $return = array(); |
256 $return = array(); |
257 return $return; |
257 return $return; |
278 * @param int|object $tag |
278 * @param int|object $tag |
279 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N |
279 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N |
280 * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. |
280 * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. |
281 * @return object|array Return type based on $output value. |
281 * @return object|array Return type based on $output value. |
282 */ |
282 */ |
283 function &get_tag( $tag, $output = OBJECT, $filter = 'raw' ) { |
283 function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) { |
284 return get_term( $tag, 'post_tag', $output, $filter ); |
284 return get_term( $tag, 'post_tag', $output, $filter ); |
285 } |
285 } |
286 |
286 |
287 /* Cache */ |
287 /* Cache */ |
288 |
288 |