Make WordPress Core

Changeset 37928


Ignore:
Timestamp:
06/30/2016 04:38:45 PM (8 years ago)
Author:
helen
Message:

Meta: Actually use fallback auth for the previous registration method.

see #35658.

File:
1 edited

Legend:

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

    r37924 r37928  
    10331033    $passed_args = array_slice( func_get_args(), 2 );
    10341034
    1035     // There used to be individual args for sanitize and auth callbacks 
    1036     $has_old_sanitize_cb = $has_old_auth_cb = false;
     1035    // There used to be individual args for sanitize and auth callbacks
     1036    $has_old_sanitize_cb = false;
    10371037
    10381038    if ( is_callable( $passed_args[0] ) ) {
     
    10451045    if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
    10461046        $args['auth_callback'] = $passed_args[1];
    1047         $has_old_auth_cb = true;
    10481047    }
    10491048
     
    10671066    }
    10681067
    1069     // Back-compat: old sanitize and auth callbacks applied to all of an object type
    1070     if ( $has_old_sanitize_cb ) {
    1071         add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
    1072     } elseif ( is_callable( $args['sanitize_callback'] ) && ! empty( $object_subtype ) ) {
    1073         add_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
    1074     }
    1075 
    10761068    // If `auth_callback` is not provided, fall back to `is_protected_meta()`.
    10771069    if ( empty( $args['auth_callback'] ) ) {
     
    10831075    }
    10841076
    1085     if ( $has_old_auth_cb ) {
     1077    // Back-compat: old sanitize and auth callbacks applied to all of an object type
     1078    if ( $has_old_sanitize_cb ) {
     1079        add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
    10861080        add_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
    1087     } elseif ( is_callable( $args['auth_callback'] ) && ! empty( $object_subtype ) ) {
    1088         add_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
    1089     }
    1090 
    1091     $object_subtype = $args['object_subtype'];
     1081    } else {
     1082        if ( is_callable( $args['sanitize_callback'] ) ) {
     1083            add_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
     1084        }
     1085
     1086        if ( is_callable( $args['auth_callback'] ) ) {
     1087            add_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
     1088        }
     1089    }
    10921090
    10931091    // Global registry only contains meta keys registered in the new way with a subtype.
    1094     if ( ! empty( $object_subtype ) ) {
     1092    if ( ! empty( $args['object_subtype'] ) ) {
     1093        $object_subtype = $args['object_subtype'];
    10951094        $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] = $args;
    10961095
Note: See TracChangeset for help on using the changeset viewer.