diff --git wp-includes/post.php wp-includes/post.php
index cea834b..85d812a 100644
|
|
function wp_get_single_post($postid = 0, $mode = OBJECT) { |
2328 | 2328 | ) |
2329 | 2329 | return ( OBJECT == $mode ? null : array() ); |
2330 | 2330 | |
| 2331 | // get custom taxonomies |
| 2332 | $taxonomies = get_object_taxonomies( $post, 'names', array( '_builtin' => false ) ); |
| 2333 | $tax_input = array(); |
| 2334 | |
| 2335 | if ( ! empty( $taxonomies ) ) { |
| 2336 | foreach ( $taxonomies as $taxonomy ) { |
| 2337 | $post_terms = wp_get_post_terms( $postid, $taxonomy, array( 'fields' => 'ids' ) ); |
| 2338 | if ( ! empty( $post_terms ) ) |
| 2339 | $tax_input[$taxonomy] = $post_terms; |
| 2340 | } |
| 2341 | } |
| 2342 | |
2331 | 2343 | // Set categories and tags |
2332 | 2344 | if ( $mode == OBJECT ) { |
2333 | 2345 | $post->post_category = array(); |
… |
… |
function wp_get_single_post($postid = 0, $mode = OBJECT) { |
2336 | 2348 | $post->tags_input = array(); |
2337 | 2349 | if ( is_object_in_taxonomy($post->post_type, 'post_tag') ) |
2338 | 2350 | $post->tags_input = wp_get_post_tags($postid, array('fields' => 'names')); |
| 2351 | $post->tax_input = $tax_input; |
2339 | 2352 | } else { |
2340 | 2353 | $post['post_category'] = array(); |
2341 | 2354 | if ( is_object_in_taxonomy($post['post_type'], 'category') ) |
… |
… |
function wp_get_single_post($postid = 0, $mode = OBJECT) { |
2343 | 2356 | $post['tags_input'] = array(); |
2344 | 2357 | if ( is_object_in_taxonomy($post['post_type'], 'post_tag') ) |
2345 | 2358 | $post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names')); |
| 2359 | $post['tax_input'] = $tax_input; |
2346 | 2360 | } |
2347 | | |
2348 | 2361 | return $post; |
2349 | 2362 | } |
2350 | 2363 | |
diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php
index 60068c5..a8c3bed 100644
|
|
function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) |
140 | 140 | * |
141 | 141 | * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts) |
142 | 142 | * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default. |
| 143 | * @param array $args An array of key => value arguments to match against the taxonomy objects. |
143 | 144 | * @return array The names of all taxonomy of $object_type. |
144 | 145 | */ |
145 | | function get_object_taxonomies($object, $output = 'names') { |
146 | | global $wp_taxonomies; |
| 146 | function get_object_taxonomies( $object, $output = 'names', $args = array() ) { |
147 | 147 | |
148 | 148 | if ( is_object($object) ) { |
149 | 149 | if ( $object->post_type == 'attachment' ) |
… |
… |
function get_object_taxonomies($object, $output = 'names') { |
152 | 152 | } |
153 | 153 | |
154 | 154 | $object = (array) $object; |
155 | | |
156 | | $taxonomies = array(); |
157 | | foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { |
158 | | if ( array_intersect($object, (array) $tax_obj->object_type) ) { |
159 | | if ( 'names' == $output ) |
160 | | $taxonomies[] = $tax_name; |
161 | | else |
162 | | $taxonomies[ $tax_name ] = $tax_obj; |
163 | | } |
| 155 | |
| 156 | $list = get_taxonomies( $args, 'objects' ); |
| 157 | |
| 158 | foreach ( $list as $tax_name => $tax_obj ) { |
| 159 | if ( ! array_intersect($object, (array) $tax_obj->object_type) ) |
| 160 | unset( $list[$tax_name] ); |
164 | 161 | } |
165 | 162 | |
166 | | return $taxonomies; |
| 163 | if ( 'names' == $output ) |
| 164 | $list = array_values( wp_list_pluck( $list, 'name' ) ); |
| 165 | |
| 166 | return $list; |
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
… |
… |
function is_taxonomy_hierarchical($taxonomy) { |
256 | 256 | * boolean value. |
257 | 257 | * |
258 | 258 | * update_count_callback - works much like a hook, in that it will be called |
259 | | * when the count is updated. |
| 259 | * when the count is updated; if not defined and show_ui is true, defaults to '_update_post_term_count'. |
| 260 | * To suppress default callback in any cases, set update_count_callback to false. |
260 | 261 | * |
261 | 262 | * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize |
262 | 263 | * permastruct; default will use $taxonomy as slug. |
… |
… |
function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
335 | 336 | if ( is_null($args['show_ui']) ) |
336 | 337 | $args['show_ui'] = $args['public']; |
337 | 338 | |
| 339 | if ( $args['show_ui'] && $args['update_count_callback'] === '' ) { |
| 340 | $args['update_count_callback'] = '_update_post_term_count'; |
| 341 | } |
| 342 | |
338 | 343 | // Whether to show this type in nav-menus.php. Defaults to the setting for public. |
339 | 344 | if ( null === $args['show_in_nav_menus'] ) |
340 | 345 | $args['show_in_nav_menus'] = $args['public']; |