[wp-trac] [WordPress Trac] #48166: Cannot create a new CPT without taxonomies
WordPress Trac
noreply at wordpress.org
Sun Sep 29 01:02:34 UTC 2019
#48166: Cannot create a new CPT without taxonomies
--------------------------+-----------------------------
Reporter: scarr | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.2.3
Severity: normal | Keywords: has-patch
Focuses: |
--------------------------+-----------------------------
When calling register_post_type() where $args does NOT include taxononies
details ('taxonomies = NULL), the following message is displayed:
Warning: Invalid argument supplied for foreach() in ..\wp-includes\class-
wp-post-type.php on line 597
This is because register_post_type contains a call to
$post_type_object->register_taxonomies().
Bug in wp-includes/class-wp-posst-type.php function =
register_taxonomies()
Current:
public function register_taxonomies() {
foreach ( $this->taxonomies as $taxonomy ) {
register_taxonomy_for_object_type( $taxonomy,
$this->name );
}
}
Proposed Fix:
public function register_taxonomies() {
if (!is_array($this->taxonomies)) { return; }
foreach ( $this->taxonomies as $taxonomy ) {
register_taxonomy_for_object_type( $taxonomy,
$this->name );
}
}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48166>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list