[wp-trac] [WordPress Trac] #60787: get_registered_meta_keys() should allow for late registration to improve performance

WordPress Trac noreply at wordpress.org
Fri Mar 15 22:50:45 UTC 2024


#60787: get_registered_meta_keys() should allow for late registration to improve
performance
-------------------------+-----------------------------
 Reporter:  sc0ttkclark  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  performance  |
-------------------------+-----------------------------
 For a site with many custom post types, custom taxonomies, and tons of
 custom fields -- the burden of register_meta() can become heavy especially
 when using a plugin like Advanced Custom Fields, Pods, and others.

 But we shouldn't have to register every single field on every single page
 load regardless of whether it's needed. That just drains performance on a
 given site and requires needless DB/transient/cache requests.

 The introduction of things like the Block Bindings API rely on fields
 registered through the REST API.

 You can register fields with the REST API during the `rest_api_init`
 action (which yeah, you pretty much have to register everything all at
 once) but at least it's not every page load.

 With the Block Bindings API rendering on the front of the site, this
 requires you having run your fields through `register_meta()` on any given
 page that might have that field bound.

 Related dev tutorial: https://developer.wordpress.org/news/2024/02/20
 /introducing-block-bindings-part-1-connecting-custom-fields/

 **Proposed solution:**

 Run an action at the top of `get_registered_meta_keys()` so a plugin can
 run `register_meta()` ONLY at the time of that data being needed at the
 code level.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60787>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list