WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/30/2016 06:59:49 PM (4 years ago)
Author:
helen
Message:

Meta registration: Ensure $args is an array and simplify compat logic.

props ocean90, sc0ttkclark.
see #35658.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r37928 r37933  
    981981     */
    982982    return apply_filters( "sanitize_{$object_type}_meta_{$meta_key}", $meta_value, $meta_key, $object_type, $object_subtype );
    983 
    984    
    985983}
    986984
     
    10041002 *     @type bool   $show_in_rest      Whether data associated with this meta key can be considered public.
    10051003 * }
    1006  * @param string|array $auth_callback Deprecated. Use `$args` instead.
     1004 * @param string|array $deprecated Deprecated. Use `$args` instead.
    10071005 *
    10081006 * @return bool True if the meta key was successfully registered in the global array, false if not.
     
    10101008 *              callbacks, but will not add to the global registry as it requires a subtype.
    10111009 */
    1012 function register_meta( $object_type, $meta_key, $args, $auth_callback = null ) {
     1010function register_meta( $object_type, $meta_key, $args, $deprecated = null ) {
    10131011    global $wp_meta_keys;
    10141012
     
    10311029    );
    10321030
    1033     $passed_args = array_slice( func_get_args(), 2 );
    1034 
    10351031    // There used to be individual args for sanitize and auth callbacks
    10361032    $has_old_sanitize_cb = false;
    10371033
    1038     if ( is_callable( $passed_args[0] ) ) {
    1039         $args['sanitize_callback'] = $passed_args[0];
     1034    if ( is_callable( $args ) ) {
     1035        $args = array(
     1036            'sanitize_callback' => $args,
     1037        );
     1038
    10401039        $has_old_sanitize_cb = true;
    10411040    } else {
    1042         $args = $passed_args[0];
    1043     }
    1044 
    1045     if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
    1046         $args['auth_callback'] = $passed_args[1];
     1041        $args = (array) $args;
     1042    }
     1043
     1044    if ( is_callable( $deprecated ) ) {
     1045        $args['auth_callback'] = $deprecated;
    10471046    }
    10481047
Note: See TracChangeset for help on using the changeset viewer.