-
Notifications
You must be signed in to change notification settings - Fork 3
Use JsonValue for post type supports field #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
jkmassel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this – can we validate that we have a post_type_supports("editor") method somewhere that just checks for that key to be present? It seems like the actual data is pretty much a black box, so we're really just checking for the key to be part of the dictionary or not.
7f86913 to
3161a4e
Compare
3161a4e to
bb2ccd9
Compare
@jkmassel This should be addressed in bb2ccd9. Let me know if this works for you or not. Note that there is some weirdness to this design because we are basically bypassing the possible |
WordPress 6.9 returns post type supports as either bool or array, so we use JsonValue wrapped in PostTypeSupportsValue for flexibility. Changes: - Add PostTypeSupportsValue type wrapping JsonValue - Update PostTypeSupportsMap to use Arc<PostTypeSupportsValue> - Update test assertion to use as_json_bool() method
Add a `supports` method to `PostTypeSupportsMap` for Rust usage and a `post_type_supports` free function for FFI clients to check if a post type supports a specific feature by key presence. Includes documentation explaining the assumption that key presence implies support, regardless of the associated value.
Simplify post type supports by using JsonValue directly instead of the PostTypeSupportsValue wrapper type. Tests now use the supports method on PostTypeSupportsMap to check feature support. Changes: - Change PostTypeSupportsMap.map from HashMap<_, Arc<PostTypeSupportsValue>> to HashMap<_, JsonValue> - Remove PostTypeSupportsValue struct and its impl block - Update Rust test to use supports method directly - Update Kotlin test to use postTypeSupports helper
bb2ccd9 to
76f7aa6
Compare
Addresses a breaking change discovered in #1047: WordPress 6.9 returns post type
supportsas eitherboolor array, so we useJsonValue.