mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 15:47:38 +02:00
Meta: Actually use fallback auth for the previous registration method.
see #35658. Built from https://develop.svn.wordpress.org/trunk@37928 git-svn-id: http://core.svn.wordpress.org/trunk@37869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
21ae71eaa1
commit
48ca588a6c
@ -1033,7 +1033,7 @@ function register_meta( $object_type, $meta_key, $args, $auth_callback = null )
|
|||||||
$passed_args = array_slice( func_get_args(), 2 );
|
$passed_args = array_slice( func_get_args(), 2 );
|
||||||
|
|
||||||
// There used to be individual args for sanitize and auth callbacks
|
// There used to be individual args for sanitize and auth callbacks
|
||||||
$has_old_sanitize_cb = $has_old_auth_cb = false;
|
$has_old_sanitize_cb = false;
|
||||||
|
|
||||||
if ( is_callable( $passed_args[0] ) ) {
|
if ( is_callable( $passed_args[0] ) ) {
|
||||||
$args['sanitize_callback'] = $passed_args[0];
|
$args['sanitize_callback'] = $passed_args[0];
|
||||||
@ -1044,7 +1044,6 @@ function register_meta( $object_type, $meta_key, $args, $auth_callback = null )
|
|||||||
|
|
||||||
if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
|
if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
|
||||||
$args['auth_callback'] = $passed_args[1];
|
$args['auth_callback'] = $passed_args[1];
|
||||||
$has_old_auth_cb = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
@ -1066,13 +1065,6 @@ function register_meta( $object_type, $meta_key, $args, $auth_callback = null )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back-compat: old sanitize and auth callbacks applied to all of an object type
|
|
||||||
if ( $has_old_sanitize_cb ) {
|
|
||||||
add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
|
|
||||||
} elseif ( is_callable( $args['sanitize_callback'] ) && ! empty( $object_subtype ) ) {
|
|
||||||
add_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// If `auth_callback` is not provided, fall back to `is_protected_meta()`.
|
// If `auth_callback` is not provided, fall back to `is_protected_meta()`.
|
||||||
if ( empty( $args['auth_callback'] ) ) {
|
if ( empty( $args['auth_callback'] ) ) {
|
||||||
if ( is_protected_meta( $meta_key, $object_type ) ) {
|
if ( is_protected_meta( $meta_key, $object_type ) ) {
|
||||||
@ -1082,16 +1074,23 @@ function register_meta( $object_type, $meta_key, $args, $auth_callback = null )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $has_old_auth_cb ) {
|
// Back-compat: old sanitize and auth callbacks applied to all of an object type
|
||||||
|
if ( $has_old_sanitize_cb ) {
|
||||||
|
add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
|
||||||
add_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
|
add_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
|
||||||
} elseif ( is_callable( $args['auth_callback'] ) && ! empty( $object_subtype ) ) {
|
} else {
|
||||||
add_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
|
if ( is_callable( $args['sanitize_callback'] ) ) {
|
||||||
|
add_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$object_subtype = $args['object_subtype'];
|
if ( is_callable( $args['auth_callback'] ) ) {
|
||||||
|
add_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Global registry only contains meta keys registered in the new way with a subtype.
|
// Global registry only contains meta keys registered in the new way with a subtype.
|
||||||
if ( ! empty( $object_subtype ) ) {
|
if ( ! empty( $args['object_subtype'] ) ) {
|
||||||
|
$object_subtype = $args['object_subtype'];
|
||||||
$wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] = $args;
|
$wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] = $args;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.6-beta1-37927';
|
$wp_version = '4.6-beta1-37928';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user