From 98b9ace6279e4b139401de074d5912f5b0804f4d Mon Sep 17 00:00:00 2001 From: nacin Date: Sun, 18 Apr 2010 15:54:45 +0000 Subject: [PATCH] Use is_post_type_hierarchical and is_taxonomy_hierarchical when we're fetching a post/tax object only to check the hierarchical flag. fixes #12950. git-svn-id: http://svn.automattic.com/wordpress/trunk@14155 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 9 +++------ wp-includes/post.php | 3 +-- wp-includes/rewrite.php | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index c384229356..9ca702f989 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -268,8 +268,7 @@ function bulk_edit_posts( $post_data = null ) { foreach ( $post_data['tax_input'] as $tax_name => $terms ) { if ( empty($terms) ) continue; - $taxonomy = get_taxonomy( $tax_name ); - if ( $taxonomy->hierarchical ) + if ( is_taxonomy_hierarchical( $tax_name ) ) $tax_input[$tax_name] = array_map( 'absint', $terms ); else { $tax_input[$tax_name] = preg_replace( '/\s*,\s*/', ',', rtrim( trim($terms), ' ,' ) ); @@ -316,8 +315,7 @@ function bulk_edit_posts( $post_data = null ) { foreach ( $tax_names as $tax_name ) { if( isset( $tax_input[$tax_name]) ) { - $taxonomy = get_taxonomy( $tax_name ); - if( $taxonomy->hierarchical ) + if ( is_taxonomy_hierarchical( $tax_name ) ) $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); else $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); @@ -861,7 +859,6 @@ function wp_edit_posts_query( $q = false ) { $post_type = $q['post_type']; else $post_type = 'post'; - $post_type_object = get_post_type_object($post_type); $avail_post_stati = get_available_post_statuses($post_type); @@ -891,7 +888,7 @@ function wp_edit_posts_query( $q = false ) { $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); // Hierarchical types require special args. - if ( $post_type_object->hierarchical ) { + if ( is_post_type_hierarchical( $post_type ) ) { $query['orderby'] = 'menu_order title'; $query['order'] = 'asc'; $query['posts_per_page'] = -1; diff --git a/wp-includes/post.php b/wp-includes/post.php index af5e6beee3..e70bd43392 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2510,8 +2510,7 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a // Hierarchical taxonomies must always pass IDs rather than names so that children with the same // names but different parents aren't confused. - $taxonomy_obj = get_taxonomy( $taxonomy ); - if ( $taxonomy_obj->hierarchical ) { + if ( is_taxonomy_hierarchical( $taxonomy ) ) { $tags = array_map( 'intval', $tags ); $tags = array_unique( $tags ); } diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index bf015fafe9..0a4919353f 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1436,9 +1436,8 @@ class WP_Rewrite { // For custom post types, we need to add on endpoints as well. foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) { if ( strpos($struct, "%$ptype%") !== false ) { - $ptype = get_post_type_object($ptype); $post = true; - $page = $ptype->hierarchical; // This is for page style attachment url's + $page = is_post_type_hierarchical( $ptype ); // This is for page style attachment url's break; } }