[wp-trac] [WordPress Trac] #43941: Add default value to register meta

WordPress Trac noreply at wordpress.org
Thu Jul 9 11:57:36 UTC 2020

#43941: Add default value to register meta
 Reporter:  spacedmonkey                         |       Owner:
                                                 |  TimothyBlynJacobs
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  5.5
Component:  Options, Meta APIs                   |     Version:  4.6
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:  rest-api
  note                                           |

Comment (by SergeyBiryukov):

 Is it intentional that `get_metadata_raw()` and `get_metadata_default()`
 have different function signatures?

 * `get_metadata_raw( $meta_type, $object_id, $meta_key = '', $single =
 false )`
 * `get_metadata_default( $meta_type, $meta_key, $single = false,
 $object_id = 0 )`
 * `filter_default_metadata( $value, $meta_type, $meta_key, $single,
 $object_id )`

 Same goes for `get_{$meta_type}_metadata` and
 `default_{$meta_type}_metadata` filters:
 * `apply_filters( "get_{$meta_type}_metadata", null, $object_id,
 $meta_key, $single )`
 * `apply_filters( "default_{$meta_type}_metadata", $value, $meta_type,
 $meta_key, $single, $object_id )`

 The latter has a `$meta_type` parameter, the former does not (in fact,
 none of the other 20 `*_{$meta_type}_meta` or `*_{$meta_type}_metadata`
 filters have it). I think it should at least be passed to
 `get_{$meta_type}_metadata` too.

 [attachment:"43941.17.diff"] attempts to bring some consistency.

Ticket URL: <https://core.trac.wordpress.org/ticket/43941#comment:80>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list