|
15 | 15 | /** |
16 | 16 | * Adds metadata for the specified object. |
17 | 17 | * |
| 18 | + * For historial reasons both the meta key and the meta value are expected to be "slashed" (slashes escaped) on input. |
| 19 | + * This means if data is coming from user-generated content you need to wp_slash() it before passing it to this function. |
| 20 | + * |
18 | 21 | * @since 2.9.0 |
19 | 22 | * |
20 | 23 | * @global wpdb $wpdb WordPress database abstraction object. |
@@ -167,19 +170,27 @@ function add_metadata( $meta_type, $object_id, $meta_key, $meta_value, $unique = |
167 | 170 | /** |
168 | 171 | * Adds multiple items of metadata for the specified object. |
169 | 172 | * |
170 | | - * For historial reasons both the meta key and the meta value are expected to be "slashed" (slashes |
171 | | - * escaped) on input. This means if the data is coming from user-generated |
172 | | - * content you will need to wp_slash() it before passing it to this function. |
| 173 | + * For historial reasons both the meta key and the meta value are expected to be "slashed" (slashes escaped) on input. |
| 174 | + * This means if data is coming from user-generated content you need to wp_slash() it before passing it to this function. |
| 175 | + * |
| 176 | + * This function will always insert all of the provided metadata even if matching keys already exist. This behaviour |
| 177 | + * matches that of add_metadata() when its `$unique` parameter is set to false. |
| 178 | + * |
| 179 | + * If the insert fails, no metadata will be inserted. It's not possible for some rows to be inserted and not others. |
173 | 180 | * |
174 | | - * This function will always insert all of the provided metadata even if matching keys |
175 | | - * already exist. This behaviour matches that of add_metadata() when its `$unique` |
176 | | - * parameter is set to false. |
| 181 | + * This is more performant than calling `add_metadata()` multiple times because it only queries the database once and |
| 182 | + * only clears the meta cache once. |
177 | 183 | * |
178 | | - * If the insert fails, no metadata will be inserted. It's not possible for some rows |
179 | | - * to be inserted and not others. |
| 184 | + * Examples: |
180 | 185 | * |
181 | | - * This is more performant than calling `add_metadata()` multiple times because it |
182 | | - * only queries the database once and only clears the meta cache once. |
| 186 | + * bulk_add_metadata( |
| 187 | + * 'post', |
| 188 | + * $post_id, |
| 189 | + * array( |
| 190 | + * 'meta_key_1' => 'value_1', |
| 191 | + * 'meta_key_2' => 'value_2', |
| 192 | + * ) |
| 193 | + * ); |
183 | 194 | * |
184 | 195 | * @todo: |
185 | 196 | * |
@@ -283,6 +294,9 @@ function bulk_add_metadata( string $meta_type, $object_id, array $meta_fields ) |
283 | 294 | * Updates metadata for the specified object. If no value already exists for the specified object |
284 | 295 | * ID and metadata key, the metadata will be added. |
285 | 296 | * |
| 297 | + * For historial reasons both the meta key and the meta value are expected to be "slashed" (slashes escaped) on input. |
| 298 | + * This means if data is coming from user-generated content you need to wp_slash() it before passing it to this function. |
| 299 | + * |
286 | 300 | * @since 2.9.0 |
287 | 301 | * |
288 | 302 | * @global wpdb $wpdb WordPress database abstraction object. |
@@ -478,6 +492,9 @@ function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_ |
478 | 492 | /** |
479 | 493 | * Deletes metadata for the specified object. |
480 | 494 | * |
| 495 | + * For historial reasons both the meta key and the meta value are expected to be "slashed" (slashes escaped) on input. |
| 496 | + * This means if data is coming from user-generated content you need to wp_slash() it before passing it to this function. |
| 497 | + * |
481 | 498 | * @since 2.9.0 |
482 | 499 | * |
483 | 500 | * @global wpdb $wpdb WordPress database abstraction object. |
|
0 commit comments