Created
July 13, 2016 05:52
-
-
Save jeremyfelt/92c5f4f51716469d4d18582e29bddf65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/wp-includes/meta.php | |
=================================================================== | |
--- src/wp-includes/meta.php (revision 38041) | |
+++ src/wp-includes/meta.php (working copy) | |
@@ -14,20 +14,22 @@ | |
* Add metadata for the specified object. | |
* | |
* @since 2.9.0 | |
+ * @since 4.6.0 Added the `$object_subtype` parameter. | |
* | |
* @global wpdb $wpdb WordPress database abstraction object. | |
* | |
- * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) | |
- * @param int $object_id ID of the object metadata is for | |
- * @param string $meta_key Metadata key | |
- * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. | |
- * @param bool $unique Optional, default is false. | |
- * Whether the specified metadata key should be unique for the object. | |
- * If true, and the object already has a value for the specified metadata key, | |
- * no change will be made. | |
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) | |
+ * @param int $object_id ID of the object metadata is for | |
+ * @param string $meta_key Metadata key | |
+ * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. | |
+ * @param bool $unique Optional, default is false. | |
+ * Whether the specified metadata key should be unique for the object. | |
+ * If true, and the object already has a value for the specified metadata key, | |
+ * no change will be made. | |
+ * @param string $object_subtype Optional. Subtype of object. | |
* @return int|false The meta ID on success, false on failure. | |
*/ | |
-function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique = false) { | |
+function add_metadata( $meta_type, $object_id, $meta_key, $meta_value, $unique = false, $object_subtype = '' ) { | |
global $wpdb; | |
if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) ) { | |
@@ -49,7 +51,7 @@ | |
// expected_slashed ($meta_key) | |
$meta_key = wp_unslash($meta_key); | |
$meta_value = wp_unslash($meta_value); | |
- $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); | |
+ $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $object_subtype ); | |
/** | |
* Filters whether to add metadata of a specific type. | |
@@ -129,18 +131,20 @@ | |
* ID and metadata key, the metadata will be added. | |
* | |
* @since 2.9.0 | |
+ * @since 4.6.0 Added the `$object_subtype` parameter. | |
* | |
* @global wpdb $wpdb WordPress database abstraction object. | |
* | |
- * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) | |
- * @param int $object_id ID of the object metadata is for | |
- * @param string $meta_key Metadata key | |
- * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. | |
- * @param mixed $prev_value Optional. If specified, only update existing metadata entries with | |
- * the specified value. Otherwise, update all entries. | |
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) | |
+ * @param int $object_id ID of the object metadata is for | |
+ * @param string $meta_key Metadata key | |
+ * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. | |
+ * @param mixed $prev_value Optional. If specified, only update existing metadata entries with | |
+ * the specified value. Otherwise, update all entries. | |
+ * @param string $object_subtype Optional. Subtype of object. | |
* @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. | |
*/ | |
-function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = '') { | |
+function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_value = '', $object_subtype = '' ) { | |
global $wpdb; | |
if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) ) { | |
@@ -165,7 +169,7 @@ | |
$meta_key = wp_unslash($meta_key); | |
$passed_value = $meta_value; | |
$meta_value = wp_unslash($meta_value); | |
- $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); | |
+ $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $object_subtype ); | |
/** | |
* Filters whether to update metadata of a specific type. | |
@@ -598,16 +602,18 @@ | |
* Update meta data by meta ID | |
* | |
* @since 3.3.0 | |
+ * @since 4.6.0 Added the `$object_subtype` parameter. | |
* | |
* @global wpdb $wpdb WordPress database abstraction object. | |
* | |
- * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) | |
- * @param int $meta_id ID for a specific meta row | |
- * @param string $meta_value Metadata value | |
- * @param string $meta_key Optional, you can provide a meta key to update it | |
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) | |
+ * @param int $meta_id ID for a specific meta row | |
+ * @param string $meta_value Metadata value | |
+ * @param string $meta_key Optional, you can provide a meta key to update it | |
+ * @param string $object_subtype Optional. Subtype of object. | |
* @return bool True on successful update, false on failure. | |
*/ | |
-function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false ) { | |
+function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false, $object_subtype = '' ) { | |
global $wpdb; | |
// Make sure everything is valid. | |
@@ -643,7 +649,7 @@ | |
// Sanitize the meta | |
$_meta_value = $meta_value; | |
- $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); | |
+ $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $object_subtype ); | |
$meta_value = maybe_serialize( $meta_value ); | |
// Format the data query arguments. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment