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

WordPress Trac noreply at wordpress.org
Mon Jul 13 09:54:21 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 spacedmonkey):

 I strong disagree with the changing of the params here. `$meta_type` and
 `$meta_key` required here, as defaults are defined for type and key. If I
 was developing something I may want to do this.

 {{{#!php
 <?php
  if( get_user_meta( 123, 'test', true ) !== get_metadata_default( 'user',
 'test', true ) ) {
     // do stuff.
  }
 }}}

 Note I did not pass object id here.

 The only change I would think about is making less params optional. So

 {{{#!php
 <?php
 get_metadata( $meta_type, $object_id, $meta_key, $single = false )
 }}}

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


More information about the wp-trac mailing list