mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Taxonomy: Add support for default terms for custom taxonomies.
The new default_term argument is added to `register_taxonomy()` allowing a user to define the default term `name` and optionally `slug` and `description`. Fixes #43517. Props enrico.sorcinelli, SergeyBiryukov, desrosj, davidbaumwald, whyisjake. git-svn-id: https://develop.svn.wordpress.org/trunk@48356 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4033,6 +4033,15 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
||||
wp_set_post_tags( $post_ID, $postarr['tags_input'] );
|
||||
}
|
||||
|
||||
// Add default term for all associated custom taxonomies.
|
||||
if ( 'auto-draft' !== $post_status ) {
|
||||
foreach ( get_object_taxonomies( $post_type, 'object' ) as $taxonomy => $tax_object ) {
|
||||
if ( ! empty( $tax_object->default_term ) && ( empty( $postarr['tax_input'] ) || ! isset( $postarr['tax_input'][ $taxonomy ] ) ) ) {
|
||||
$postarr['tax_input'][ $taxonomy ] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// New-style support for all custom taxonomies.
|
||||
if ( ! empty( $postarr['tax_input'] ) ) {
|
||||
foreach ( $postarr['tax_input'] as $taxonomy => $tags ) {
|
||||
|
||||
Reference in New Issue
Block a user