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
This commit is contained in:
nacin 2010-04-18 15:54:45 +00:00
parent a6d816df0b
commit 98b9ace627
3 changed files with 5 additions and 10 deletions

View File

@ -268,8 +268,7 @@ function bulk_edit_posts( $post_data = null ) {
foreach ( $post_data['tax_input'] as $tax_name => $terms ) { foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
if ( empty($terms) ) if ( empty($terms) )
continue; continue;
$taxonomy = get_taxonomy( $tax_name ); if ( is_taxonomy_hierarchical( $tax_name ) )
if ( $taxonomy->hierarchical )
$tax_input[$tax_name] = array_map( 'absint', $terms ); $tax_input[$tax_name] = array_map( 'absint', $terms );
else { else {
$tax_input[$tax_name] = preg_replace( '/\s*,\s*/', ',', rtrim( trim($terms), ' ,' ) ); $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 ) { foreach ( $tax_names as $tax_name ) {
if( isset( $tax_input[$tax_name]) ) { if( isset( $tax_input[$tax_name]) ) {
$taxonomy = get_taxonomy( $tax_name ); if ( is_taxonomy_hierarchical( $tax_name ) )
if( $taxonomy->hierarchical )
$terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
else else
$terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); $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']; $post_type = $q['post_type'];
else else
$post_type = 'post'; $post_type = 'post';
$post_type_object = get_post_type_object($post_type);
$avail_post_stati = get_available_post_statuses($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'); $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
// Hierarchical types require special args. // Hierarchical types require special args.
if ( $post_type_object->hierarchical ) { if ( is_post_type_hierarchical( $post_type ) ) {
$query['orderby'] = 'menu_order title'; $query['orderby'] = 'menu_order title';
$query['order'] = 'asc'; $query['order'] = 'asc';
$query['posts_per_page'] = -1; $query['posts_per_page'] = -1;

View File

@ -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 // Hierarchical taxonomies must always pass IDs rather than names so that children with the same
// names but different parents aren't confused. // names but different parents aren't confused.
$taxonomy_obj = get_taxonomy( $taxonomy ); if ( is_taxonomy_hierarchical( $taxonomy ) ) {
if ( $taxonomy_obj->hierarchical ) {
$tags = array_map( 'intval', $tags ); $tags = array_map( 'intval', $tags );
$tags = array_unique( $tags ); $tags = array_unique( $tags );
} }

View File

@ -1436,9 +1436,8 @@ class WP_Rewrite {
// For custom post types, we need to add on endpoints as well. // For custom post types, we need to add on endpoints as well.
foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) { foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) {
if ( strpos($struct, "%$ptype%") !== false ) { if ( strpos($struct, "%$ptype%") !== false ) {
$ptype = get_post_type_object($ptype);
$post = true; $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; break;
} }
} }