Opened 8 years ago
Closed 5 weeks ago
#41739 closed enhancement (maybelater)
Support a "source" attribute in post types, taxonomies, and post statuses
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Posts, Post Types | Keywords: | reporter-feedback |
| Focuses: | Cc: |
Description
When registering custom post types, taxonomies, or post statuses, it would be nice to have a way to tell the system what plugin was responsible for those registrations.
Use Case:
In bbPress, there are 3 post types, 1 taxonomy, and 4 post statuses. There are several places where an "any bbPress post type" or "any bbPress post status" comparison is necessary, but it's somewhat annoying and repetitive to need to write:
array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() )
I'd prefer to write:
get_post_types( array( 'source' => 'bbpress' ) )
Tangentially, this could replace the otherwise vague internal property, with:
'source' => 'wordpress'
I'm not confident that source is the best descriptor, or if domain or namespace or something else might be more appropriate (without being too vague to be useful.)
Change History (4)
#2
in reply to:
↑ 1
;
follow-up:
↓ 3
@
8 years ago
Replying to SergeyBiryukov:
WP_Post_Type::set_props()already sets any custom properties you pass toregister_post_type(), so this appears to be possible without any special support from WordPress core.
Just tested by adding
'source' => 'bbpress'to the post types inbbPress::register_post_types()and checkingget_post_types( array( 'source' => 'bbpress' ) ).
Yep! It will work, but... I think it's an idea worth officially endorsing and promoting as a best practice.
(I added it to bbPress as I was creating this ticket: https://bbpress.trac.wordpress.org/changeset/6672)
#3
in reply to:
↑ 2
@
4 months ago
- Keywords reporter-feedback added
- Version 3.0 deleted
Replying to johnjamesjacoby:
Yep! It will work, but... I think it's an idea worth officially endorsing and promoting as a best practice.
How do you think it would be the best way to endorse this?
#4
@
5 weeks ago
- Milestone Awaiting Review deleted
- Resolution set to maybelater
- Status changed from new to closed
It appears that this is not relevant anymore since after a couple of months no answer has been given, so maybe it's time to close this as maybelater.
@johnjamesjacoby if you think you can provide some additional information so we can look into it further, feel free to comment, and I will be happy to come by and proceed with this.
WP_Post_Type::set_props()already sets any custom properties you pass toregister_post_type(), so this appears to be possible without any special support from WordPress core.Just tested by adding
'source' => 'bbpress'to the post types inbbPress::register_post_types()and checkingget_post_types( array( 'source' => 'bbpress' ) ).