[RFC] Posts: Introduce register_content_type() API for declarative content modeling#10617
Draft
whyisjake wants to merge 2 commits intoWordPress:trunkfrom
Draft
[RFC] Posts: Introduce register_content_type() API for declarative content modeling#10617whyisjake wants to merge 2 commits intoWordPress:trunkfrom
whyisjake wants to merge 2 commits intoWordPress:trunkfrom
Conversation
Prototype implementation of the Declarative Content Modeling RFC. Introduces register_content_type() as a higher-level wrapper that combines register_post_type() and register_post_meta() into a single declarative API.
9b93b3e to
2da421e
Compare
Updates the expected routes list in the REST schema test to include the new /wp/v2/content-types endpoints.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Member
Author
|
Trac ticket: https://core.trac.wordpress.org/ticket/64423 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a prototype implementation of the Declarative Content Modeling RFC that introduces
register_content_type()- a higher-level API for registering content types in WordPress.Try it out
Try the demo in WordPress Playground - includes a "Books" content type with sample data.
What it does
register_post_type()register_post_meta()for each declared fieldExample usage
New functions
register_content_type()/unregister_content_type()content_type_exists()/get_content_type_object()/get_content_types()get_content_type_fields()/get_content_type_field()get_content_type_ui()/get_content_type_rest_schema()validate_content_type_values()Files added
src/wp-includes/class-wp-content-type.php- Core classsrc/wp-includes/content-type.php- API functionstests/phpunit/tests/post/wpContentType.php- Unit tests (38 tests)Status
🚧 Work in Progress - This is an early prototype for discussion and feedback.
Test plan