WordPress.org

Make WordPress Core

Ticket #14084: garyc40.14084.diff

File garyc40.14084.diff, 3.6 KB (added by garyc40, 3 years ago)

there's a patch for that

  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index cea834b..fc4c7cb 100644
    function wp_get_single_post($postid = 0, $mode = OBJECT) { 
    23282328        ) 
    23292329                return ( OBJECT == $mode ? null : array() ); 
    23302330 
     2331        // get custom taxonomies 
     2332        $taxonomies = get_object_taxonomies( $post, 'names', true ); 
     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 
    23312343        // Set categories and tags 
    23322344        if ( $mode == OBJECT ) { 
    23332345                $post->post_category = array(); 
    function wp_get_single_post($postid = 0, $mode = OBJECT) { 
    23362348                $post->tags_input = array(); 
    23372349                if ( is_object_in_taxonomy($post->post_type, 'post_tag') ) 
    23382350                        $post->tags_input = wp_get_post_tags($postid, array('fields' => 'names')); 
     2351                $post->tax_input = $tax_input; 
    23392352        } else { 
    23402353                $post['post_category'] = array(); 
    23412354                if ( is_object_in_taxonomy($post['post_type'], 'category') ) 
    function wp_get_single_post($postid = 0, $mode = OBJECT) { 
    23432356                $post['tags_input'] = array(); 
    23442357                if ( is_object_in_taxonomy($post['post_type'], 'post_tag') ) 
    23452358                        $post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names')); 
     2359                $post['tax_input'] = $tax_input; 
    23462360        } 
    2347  
    23482361        return $post; 
    23492362} 
    23502363 
  • wp-includes/taxonomy.php

    diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php
    index 60068c5..e678c9a 100644
    function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) 
    140140 * 
    141141 * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts) 
    142142 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default. 
     143 * @param bool $exclude_builtin Specify <code>true</code> to return only custom taxonomies. <code>false</code> is the default. 
    143144 * @return array The names of all taxonomy of $object_type. 
    144145 */ 
    145 function get_object_taxonomies($object, $output = 'names') { 
     146function get_object_taxonomies($object, $output = 'names', $exclude_builtin = false) { 
    146147        global $wp_taxonomies; 
    147148 
    148149        if ( is_object($object) ) { 
    function get_object_taxonomies($object, $output = 'names') { 
    155156 
    156157        $taxonomies = array(); 
    157158        foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { 
     159                if ( $exclude_builtin && $tax_obj->_builtin ) 
     160                        continue; 
    158161                if ( array_intersect($object, (array) $tax_obj->object_type) ) { 
    159162                        if ( 'names' == $output ) 
    160163                                $taxonomies[] = $tax_name; 
    function is_taxonomy_hierarchical($taxonomy) { 
    256259 * boolean value. 
    257260 * 
    258261 * update_count_callback - works much like a hook, in that it will be called 
    259  * when the count is updated. 
     262 * when the count is updated; if not defined and show_ui is true, defaults to '_update_post_term_count'. 
     263 * To suppress default callback in any cases, set update_count_callback to false. 
    260264 * 
    261265 * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize 
    262266 * permastruct; default will use $taxonomy as slug. 
    function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 
    335339        if ( is_null($args['show_ui']) ) 
    336340                $args['show_ui'] = $args['public']; 
    337341 
     342        if ( $args['show_ui'] && $args['update_count_callback'] === '' ) { 
     343                $args['update_count_callback'] = '_update_post_term_count'; 
     344        } 
     345 
    338346        // Whether to show this type in nav-menus.php. Defaults to the setting for public. 
    339347        if ( null === $args['show_in_nav_menus'] ) 
    340348                $args['show_in_nav_menus'] = $args['public'];