Changeset 49000
- Timestamp:
- 09/19/2020 01:20:48 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r48976 r49000 4376 4376 } 4377 4377 4378 // Ensure at least one term is applied for taxonomies with a default term. 4379 foreach ( get_object_taxonomies( $post->post_type, 'object' ) as $taxonomy => $tax_object ) { 4380 // Skip taxonomy if no default term is set. 4381 if ( 4382 'category' !== $taxonomy && 4383 empty( $tax_object->default_term ) 4384 ) { 4385 continue; 4386 } 4387 4388 // Do not modify previously set terms. 4389 if ( ! empty( get_the_terms( $post, $taxonomy ) ) ) { 4390 continue; 4391 } 4392 4393 if ( 'category' === $taxonomy ) { 4394 $default_term_id = (int) get_option( 'default_category', 0 ); 4395 } else { 4396 $default_term_id = (int) get_option( 'default_term_' . $taxonomy, 0 ); 4397 } 4398 4399 if ( ! $default_term_id ) { 4400 continue; 4401 } 4402 wp_set_post_terms( $post->ID, array( $default_term_id ), $taxonomy ); 4403 } 4404 4378 4405 $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); 4379 4406
Note: See TracChangeset
for help on using the changeset viewer.