From e408d8709a3d63f4d957d33bda76e47235b6f903 Mon Sep 17 00:00:00 2001
From: jrfnl <github_nospam@adviesenzo.nl>
Date: Thu, 10 Dec 2015 06:40:13 +0100
Subject: [PATCH] Add $object_id parameter to
`sanitize_{$meta_type}_meta_{$meta_key}` filter.
Implement @sc0ttclark's suggestion.
---
src/wp-includes/meta.php | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php
index 2a5f45f..460a7b0 100644
a
|
b
|
function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique = |
49 | 49 | // expected_slashed ($meta_key) |
50 | 50 | $meta_key = wp_unslash($meta_key); |
51 | 51 | $meta_value = wp_unslash($meta_value); |
52 | | $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); |
| 52 | $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $object_id ); |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Filter whether to add metadata of a specific type. |
… |
… |
function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v |
164 | 164 | $meta_key = wp_unslash($meta_key); |
165 | 165 | $passed_value = $meta_value; |
166 | 166 | $meta_value = wp_unslash($meta_value); |
167 | | $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); |
| 167 | $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $object_id ); |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Filter whether to update metadata of a specific type. |
… |
… |
function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = |
640 | 640 | |
641 | 641 | // Sanitize the meta |
642 | 642 | $_meta_value = $meta_value; |
643 | | $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); |
| 643 | $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $object_id ); |
644 | 644 | $meta_value = maybe_serialize( $meta_value ); |
645 | 645 | |
646 | 646 | // Format the data query arguments. |
… |
… |
function is_protected_meta( $meta_key, $meta_type = null ) { |
920 | 920 | * @param string $meta_key Meta key |
921 | 921 | * @param mixed $meta_value Meta value to sanitize |
922 | 922 | * @param string $meta_type Type of meta |
| 923 | * @param int $object_id ID of the object metadata is for |
923 | 924 | * @return mixed Sanitized $meta_value |
924 | 925 | */ |
925 | | function sanitize_meta( $meta_key, $meta_value, $meta_type ) { |
| 926 | function sanitize_meta( $meta_key, $meta_value, $meta_type, $object_id ) { |
926 | 927 | |
927 | 928 | /** |
928 | 929 | * Filter the sanitization of a specific meta key of a specific meta type. |
… |
… |
function sanitize_meta( $meta_key, $meta_value, $meta_type ) { |
937 | 938 | * @param mixed $meta_value Meta value to sanitize. |
938 | 939 | * @param string $meta_key Meta key. |
939 | 940 | * @param string $meta_type Meta type. |
| 941 | * @param int $object_id ID of the object metadata is for. |
940 | 942 | */ |
941 | | return apply_filters( "sanitize_{$meta_type}_meta_{$meta_key}", $meta_value, $meta_key, $meta_type ); |
| 943 | return apply_filters( "sanitize_{$meta_type}_meta_{$meta_key}", $meta_value, $meta_key, $meta_type, $object_id ); |
942 | 944 | } |
943 | 945 | |
944 | 946 | /** |