[wp-trac] [WordPress Trac] #44387: Add support for site meta in `register_meta()`
WordPress Trac
noreply at wordpress.org
Sun Jun 17 13:36:33 UTC 2018
#44387: Add support for site meta in `register_meta()`
--------------------------------+-------------------------
Reporter: flixos90 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 5.0
Component: Options, Meta APIs | Version:
Severity: normal | Keywords: 2nd-opinion
Focuses: multisite |
--------------------------------+-------------------------
#38323 adds subtype handling to `register_meta()`. These efforts include
introducing a function `get_object_subtype()` which returns the object
subtype of a given type and ID combination. For the initial merge, this
only includes the single site types "post", "term", "comment" and "user".
Since [42836], sites in a multisite also support metadata, so they should
receive subtype support as well.
Since sites do not actually use subtypes at this point, we basically only
need to add a clause which checks whether a site with the given ID exists,
and if so, return the type identifier.
The tricky part into which we need to put some thought is the naming:
Sites have been historically called "blogs", and WordPress core aims to
get rid of the legacy naming in its APIs (and only the database schema
remains untouched). For example, there are wrapper functions like
`get_site_meta()`, but they actually call the low-level meta functions
like `get_metadata( 'blog', ... )` because those are tightly coupled to
the DB schema. Since registering site meta would be new, we should
consider actually naming the type "site" here, and then only internally
handling the "blog" part of it. However, this may introduce unexpected
inconsistencies with other areas, so we need to investigate whether this
is a wise choice or not.
I'd generally argue the simplest solution would be to introduce
`register_site_meta()` and `unregister_site_meta()` and otherwise keep the
"blog" name (which would be consistent with the way existing site meta
wrappers work) - however we decided wrappers should only be introduced for
object types that use subtypes, so here with sites, developers would
actually need to call `register_meta( 'blog', ... )` themselves which
would be sub-optimal. Let's discuss.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44387>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list