54 $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); |
54 $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); |
55 |
55 |
56 /** |
56 /** |
57 * Short-circuits adding metadata of a specific type. |
57 * Short-circuits adding metadata of a specific type. |
58 * |
58 * |
59 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
59 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
60 * (post, comment, term, user, or any other type with an associated meta table). |
60 * (post, comment, term, user, or any other type with an associated meta table). |
61 * Returning a non-null value will effectively short-circuit the function. |
61 * Returning a non-null value will effectively short-circuit the function. |
|
62 * |
|
63 * Possible hook names include: |
|
64 * |
|
65 * - `add_post_metadata` |
|
66 * - `add_comment_metadata` |
|
67 * - `add_term_metadata` |
|
68 * - `add_user_metadata` |
62 * |
69 * |
63 * @since 3.1.0 |
70 * @since 3.1.0 |
64 * |
71 * |
65 * @param null|bool $check Whether to allow adding metadata for the given type. |
72 * @param null|bool $check Whether to allow adding metadata for the given type. |
66 * @param int $object_id ID of the object metadata is for. |
73 * @param int $object_id ID of the object metadata is for. |
87 $meta_value = maybe_serialize( $meta_value ); |
94 $meta_value = maybe_serialize( $meta_value ); |
88 |
95 |
89 /** |
96 /** |
90 * Fires immediately before meta of a specific type is added. |
97 * Fires immediately before meta of a specific type is added. |
91 * |
98 * |
92 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
99 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
93 * (post, comment, term, user, or any other type with an associated meta table). |
100 * (post, comment, term, user, or any other type with an associated meta table). |
|
101 * |
|
102 * Possible hook names include: |
|
103 * |
|
104 * - `add_post_meta` |
|
105 * - `add_comment_meta` |
|
106 * - `add_term_meta` |
|
107 * - `add_user_meta` |
94 * |
108 * |
95 * @since 3.1.0 |
109 * @since 3.1.0 |
96 * |
110 * |
97 * @param int $object_id ID of the object metadata is for. |
111 * @param int $object_id ID of the object metadata is for. |
98 * @param string $meta_key Metadata key. |
112 * @param string $meta_key Metadata key. |
99 * @param mixed $_meta_value Metadata value. Serialized if non-scalar. |
113 * @param mixed $_meta_value Metadata value. |
100 */ |
114 */ |
101 do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value ); |
115 do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value ); |
102 |
116 |
103 $result = $wpdb->insert( |
117 $result = $wpdb->insert( |
104 $table, |
118 $table, |
118 wp_cache_delete( $object_id, $meta_type . '_meta' ); |
132 wp_cache_delete( $object_id, $meta_type . '_meta' ); |
119 |
133 |
120 /** |
134 /** |
121 * Fires immediately after meta of a specific type is added. |
135 * Fires immediately after meta of a specific type is added. |
122 * |
136 * |
123 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
137 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
124 * (post, comment, term, user, or any other type with an associated meta table). |
138 * (post, comment, term, user, or any other type with an associated meta table). |
|
139 * |
|
140 * Possible hook names include: |
|
141 * |
|
142 * - `added_post_meta` |
|
143 * - `added_comment_meta` |
|
144 * - `added_term_meta` |
|
145 * - `added_user_meta` |
125 * |
146 * |
126 * @since 2.9.0 |
147 * @since 2.9.0 |
127 * |
148 * |
128 * @param int $mid The meta ID after successful update. |
149 * @param int $mid The meta ID after successful update. |
129 * @param int $object_id ID of the object metadata is for. |
150 * @param int $object_id ID of the object metadata is for. |
130 * @param string $meta_key Metadata key. |
151 * @param string $meta_key Metadata key. |
131 * @param mixed $_meta_value Metadata value. Serialized if non-scalar. |
152 * @param mixed $_meta_value Metadata value. |
132 */ |
153 */ |
133 do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value ); |
154 do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value ); |
134 |
155 |
135 return $mid; |
156 return $mid; |
136 } |
157 } |
186 $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); |
207 $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); |
187 |
208 |
188 /** |
209 /** |
189 * Short-circuits updating metadata of a specific type. |
210 * Short-circuits updating metadata of a specific type. |
190 * |
211 * |
191 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
212 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
192 * (post, comment, term, user, or any other type with an associated meta table). |
213 * (post, comment, term, user, or any other type with an associated meta table). |
193 * Returning a non-null value will effectively short-circuit the function. |
214 * Returning a non-null value will effectively short-circuit the function. |
|
215 * |
|
216 * Possible hook names include: |
|
217 * |
|
218 * - `update_post_metadata` |
|
219 * - `update_comment_metadata` |
|
220 * - `update_term_metadata` |
|
221 * - `update_user_metadata` |
194 * |
222 * |
195 * @since 3.1.0 |
223 * @since 3.1.0 |
196 * |
224 * |
197 * @param null|bool $check Whether to allow updating metadata for the given type. |
225 * @param null|bool $check Whether to allow updating metadata for the given type. |
198 * @param int $object_id ID of the object metadata is for. |
226 * @param int $object_id ID of the object metadata is for. |
238 |
266 |
239 foreach ( $meta_ids as $meta_id ) { |
267 foreach ( $meta_ids as $meta_id ) { |
240 /** |
268 /** |
241 * Fires immediately before updating metadata of a specific type. |
269 * Fires immediately before updating metadata of a specific type. |
242 * |
270 * |
243 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
271 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
244 * (post, comment, term, user, or any other type with an associated meta table). |
272 * (post, comment, term, user, or any other type with an associated meta table). |
|
273 * |
|
274 * Possible hook names include: |
|
275 * |
|
276 * - `update_post_meta` |
|
277 * - `update_comment_meta` |
|
278 * - `update_term_meta` |
|
279 * - `update_user_meta` |
245 * |
280 * |
246 * @since 2.9.0 |
281 * @since 2.9.0 |
247 * |
282 * |
248 * @param int $meta_id ID of the metadata entry to update. |
283 * @param int $meta_id ID of the metadata entry to update. |
249 * @param int $object_id ID of the object metadata is for. |
284 * @param int $object_id ID of the object metadata is for. |
250 * @param string $meta_key Metadata key. |
285 * @param string $meta_key Metadata key. |
251 * @param mixed $_meta_value Metadata value. Serialized if non-scalar. |
286 * @param mixed $_meta_value Metadata value. |
252 */ |
287 */ |
253 do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
288 do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
254 |
289 |
255 if ( 'post' === $meta_type ) { |
290 if ( 'post' === $meta_type ) { |
256 /** |
291 /** |
277 |
312 |
278 foreach ( $meta_ids as $meta_id ) { |
313 foreach ( $meta_ids as $meta_id ) { |
279 /** |
314 /** |
280 * Fires immediately after updating metadata of a specific type. |
315 * Fires immediately after updating metadata of a specific type. |
281 * |
316 * |
282 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
317 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
283 * (post, comment, term, user, or any other type with an associated meta table). |
318 * (post, comment, term, user, or any other type with an associated meta table). |
|
319 * |
|
320 * Possible hook names include: |
|
321 * |
|
322 * - `updated_post_meta` |
|
323 * - `updated_comment_meta` |
|
324 * - `updated_term_meta` |
|
325 * - `updated_user_meta` |
284 * |
326 * |
285 * @since 2.9.0 |
327 * @since 2.9.0 |
286 * |
328 * |
287 * @param int $meta_id ID of updated metadata entry. |
329 * @param int $meta_id ID of updated metadata entry. |
288 * @param int $object_id ID of the object metadata is for. |
330 * @param int $object_id ID of the object metadata is for. |
289 * @param string $meta_key Metadata key. |
331 * @param string $meta_key Metadata key. |
290 * @param mixed $_meta_value Metadata value. Serialized if non-scalar. |
332 * @param mixed $_meta_value Metadata value. |
291 */ |
333 */ |
292 do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
334 do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); |
293 |
335 |
294 if ( 'post' === $meta_type ) { |
336 if ( 'post' === $meta_type ) { |
295 /** |
337 /** |
357 $meta_value = wp_unslash( $meta_value ); |
399 $meta_value = wp_unslash( $meta_value ); |
358 |
400 |
359 /** |
401 /** |
360 * Short-circuits deleting metadata of a specific type. |
402 * Short-circuits deleting metadata of a specific type. |
361 * |
403 * |
362 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
404 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
363 * (post, comment, term, user, or any other type with an associated meta table). |
405 * (post, comment, term, user, or any other type with an associated meta table). |
364 * Returning a non-null value will effectively short-circuit the function. |
406 * Returning a non-null value will effectively short-circuit the function. |
|
407 * |
|
408 * Possible hook names include: |
|
409 * |
|
410 * - `delete_post_metadata` |
|
411 * - `delete_comment_metadata` |
|
412 * - `delete_term_metadata` |
|
413 * - `delete_user_metadata` |
365 * |
414 * |
366 * @since 3.1.0 |
415 * @since 3.1.0 |
367 * |
416 * |
368 * @param null|bool $delete Whether to allow metadata deletion of the given type. |
417 * @param null|bool $delete Whether to allow metadata deletion of the given type. |
369 * @param int $object_id ID of the object metadata is for. |
418 * @param int $object_id ID of the object metadata is for. |
405 } |
454 } |
406 |
455 |
407 /** |
456 /** |
408 * Fires immediately before deleting metadata of a specific type. |
457 * Fires immediately before deleting metadata of a specific type. |
409 * |
458 * |
410 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
459 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
411 * (post, comment, term, user, or any other type with an associated meta table). |
460 * (post, comment, term, user, or any other type with an associated meta table). |
|
461 * |
|
462 * Possible hook names include: |
|
463 * |
|
464 * - `delete_post_meta` |
|
465 * - `delete_comment_meta` |
|
466 * - `delete_term_meta` |
|
467 * - `delete_user_meta` |
412 * |
468 * |
413 * @since 3.1.0 |
469 * @since 3.1.0 |
414 * |
470 * |
415 * @param string[] $meta_ids An array of metadata entry IDs to delete. |
471 * @param string[] $meta_ids An array of metadata entry IDs to delete. |
416 * @param int $object_id ID of the object metadata is for. |
472 * @param int $object_id ID of the object metadata is for. |
417 * @param string $meta_key Metadata key. |
473 * @param string $meta_key Metadata key. |
418 * @param mixed $_meta_value Metadata value. Serialized if non-scalar. |
474 * @param mixed $_meta_value Metadata value. |
419 */ |
475 */ |
420 do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); |
476 do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); |
421 |
477 |
422 // Old-style action. |
478 // Old-style action. |
423 if ( 'post' === $meta_type ) { |
479 if ( 'post' === $meta_type ) { |
438 if ( ! $count ) { |
494 if ( ! $count ) { |
439 return false; |
495 return false; |
440 } |
496 } |
441 |
497 |
442 if ( $delete_all ) { |
498 if ( $delete_all ) { |
443 foreach ( (array) $object_ids as $o_id ) { |
499 $data = (array) $object_ids; |
444 wp_cache_delete( $o_id, $meta_type . '_meta' ); |
|
445 } |
|
446 } else { |
500 } else { |
447 wp_cache_delete( $object_id, $meta_type . '_meta' ); |
501 $data = array( $object_id ); |
448 } |
502 } |
|
503 wp_cache_delete_multiple( $data, $meta_type . '_meta' ); |
449 |
504 |
450 /** |
505 /** |
451 * Fires immediately after deleting metadata of a specific type. |
506 * Fires immediately after deleting metadata of a specific type. |
452 * |
507 * |
453 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
508 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
454 * (post, comment, term, user, or any other type with an associated meta table). |
509 * (post, comment, term, user, or any other type with an associated meta table). |
|
510 * |
|
511 * Possible hook names include: |
|
512 * |
|
513 * - `deleted_post_meta` |
|
514 * - `deleted_comment_meta` |
|
515 * - `deleted_term_meta` |
|
516 * - `deleted_user_meta` |
455 * |
517 * |
456 * @since 2.9.0 |
518 * @since 2.9.0 |
457 * |
519 * |
458 * @param string[] $meta_ids An array of metadata entry IDs to delete. |
520 * @param string[] $meta_ids An array of metadata entry IDs to delete. |
459 * @param int $object_id ID of the object metadata is for. |
521 * @param int $object_id ID of the object metadata is for. |
460 * @param string $meta_key Metadata key. |
522 * @param string $meta_key Metadata key. |
461 * @param mixed $_meta_value Metadata value. Serialized if non-scalar. |
523 * @param mixed $_meta_value Metadata value. |
462 */ |
524 */ |
463 do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); |
525 do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); |
464 |
526 |
465 // Old-style action. |
527 // Old-style action. |
466 if ( 'post' === $meta_type ) { |
528 if ( 'post' === $meta_type ) { |
543 } |
605 } |
544 |
606 |
545 /** |
607 /** |
546 * Short-circuits the return value of a meta field. |
608 * Short-circuits the return value of a meta field. |
547 * |
609 * |
548 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
610 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
549 * (post, comment, term, user, or any other type with an associated meta table). |
611 * (post, comment, term, user, or any other type with an associated meta table). |
550 * Returning a non-null value will effectively short-circuit the function. |
612 * Returning a non-null value will effectively short-circuit the function. |
551 * |
613 * |
552 * Possible filter names include: |
614 * Possible filter names include: |
553 * |
615 * |
627 } |
689 } |
628 |
690 |
629 /** |
691 /** |
630 * Filters the default metadata value for a specified meta key and object. |
692 * Filters the default metadata value for a specified meta key and object. |
631 * |
693 * |
632 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
694 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
633 * (post, comment, term, user, or any other type with an associated meta table). |
695 * (post, comment, term, user, or any other type with an associated meta table). |
634 * |
696 * |
635 * Possible filter names include: |
697 * Possible filter names include: |
636 * |
698 * |
637 * - `default_post_metadata` |
699 * - `default_post_metadata` |
740 } |
802 } |
741 |
803 |
742 /** |
804 /** |
743 * Short-circuits the return value when fetching a meta field by meta ID. |
805 * Short-circuits the return value when fetching a meta field by meta ID. |
744 * |
806 * |
745 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
807 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
746 * (post, comment, term, user, or any other type with an associated meta table). |
808 * (post, comment, term, user, or any other type with an associated meta table). |
747 * Returning a non-null value will effectively short-circuit the function. |
809 * Returning a non-null value will effectively short-circuit the function. |
|
810 * |
|
811 * Possible hook names include: |
|
812 * |
|
813 * - `get_post_metadata_by_mid` |
|
814 * - `get_comment_metadata_by_mid` |
|
815 * - `get_term_metadata_by_mid` |
|
816 * - `get_user_metadata_by_mid` |
748 * |
817 * |
749 * @since 5.0.0 |
818 * @since 5.0.0 |
750 * |
819 * |
751 * @param stdClass|null $value The value to return. |
820 * @param stdClass|null $value The value to return. |
752 * @param int $meta_id Meta ID. |
821 * @param int $meta_id Meta ID. |
807 $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; |
876 $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; |
808 |
877 |
809 /** |
878 /** |
810 * Short-circuits updating metadata of a specific type by meta ID. |
879 * Short-circuits updating metadata of a specific type by meta ID. |
811 * |
880 * |
812 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
881 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
813 * (post, comment, term, user, or any other type with an associated meta table). |
882 * (post, comment, term, user, or any other type with an associated meta table). |
814 * Returning a non-null value will effectively short-circuit the function. |
883 * Returning a non-null value will effectively short-circuit the function. |
|
884 * |
|
885 * Possible hook names include: |
|
886 * |
|
887 * - `update_post_metadata_by_mid` |
|
888 * - `update_comment_metadata_by_mid` |
|
889 * - `update_term_metadata_by_mid` |
|
890 * - `update_user_metadata_by_mid` |
815 * |
891 * |
816 * @since 5.0.0 |
892 * @since 5.0.0 |
817 * |
893 * |
818 * @param null|bool $check Whether to allow updating metadata for the given type. |
894 * @param null|bool $check Whether to allow updating metadata for the given type. |
819 * @param int $meta_id Meta ID. |
895 * @param int $meta_id Meta ID. |
923 $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; |
999 $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; |
924 |
1000 |
925 /** |
1001 /** |
926 * Short-circuits deleting metadata of a specific type by meta ID. |
1002 * Short-circuits deleting metadata of a specific type by meta ID. |
927 * |
1003 * |
928 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
1004 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
929 * (post, comment, term, user, or any other type with an associated meta table). |
1005 * (post, comment, term, user, or any other type with an associated meta table). |
930 * Returning a non-null value will effectively short-circuit the function. |
1006 * Returning a non-null value will effectively short-circuit the function. |
|
1007 * |
|
1008 * Possible hook names include: |
|
1009 * |
|
1010 * - `delete_post_metadata_by_mid` |
|
1011 * - `delete_comment_metadata_by_mid` |
|
1012 * - `delete_term_metadata_by_mid` |
|
1013 * - `delete_user_metadata_by_mid` |
931 * |
1014 * |
932 * @since 5.0.0 |
1015 * @since 5.0.0 |
933 * |
1016 * |
934 * @param null|bool $delete Whether to allow metadata deletion of the given type. |
1017 * @param null|bool $delete Whether to allow metadata deletion of the given type. |
935 * @param int $meta_id Meta ID. |
1018 * @param int $meta_id Meta ID. |
950 // Old-style action. |
1033 // Old-style action. |
951 if ( 'post' === $meta_type || 'comment' === $meta_type ) { |
1034 if ( 'post' === $meta_type || 'comment' === $meta_type ) { |
952 /** |
1035 /** |
953 * Fires immediately before deleting post or comment metadata of a specific type. |
1036 * Fires immediately before deleting post or comment metadata of a specific type. |
954 * |
1037 * |
955 * The dynamic portion of the hook, `$meta_type`, refers to the meta |
1038 * The dynamic portion of the hook name, `$meta_type`, refers to the meta |
956 * object type (post or comment). |
1039 * object type (post or comment). |
|
1040 * |
|
1041 * Possible hook names include: |
|
1042 * |
|
1043 * - `delete_postmeta` |
|
1044 * - `delete_commentmeta` |
|
1045 * - `delete_termmeta` |
|
1046 * - `delete_usermeta` |
957 * |
1047 * |
958 * @since 3.4.0 |
1048 * @since 3.4.0 |
959 * |
1049 * |
960 * @param int $meta_id ID of the metadata entry to delete. |
1050 * @param int $meta_id ID of the metadata entry to delete. |
961 */ |
1051 */ |
974 // Old-style action. |
1064 // Old-style action. |
975 if ( 'post' === $meta_type || 'comment' === $meta_type ) { |
1065 if ( 'post' === $meta_type || 'comment' === $meta_type ) { |
976 /** |
1066 /** |
977 * Fires immediately after deleting post or comment metadata of a specific type. |
1067 * Fires immediately after deleting post or comment metadata of a specific type. |
978 * |
1068 * |
979 * The dynamic portion of the hook, `$meta_type`, refers to the meta |
1069 * The dynamic portion of the hook name, `$meta_type`, refers to the meta |
980 * object type (post or comment). |
1070 * object type (post or comment). |
|
1071 * |
|
1072 * Possible hook names include: |
|
1073 * |
|
1074 * - `deleted_postmeta` |
|
1075 * - `deleted_commentmeta` |
|
1076 * - `deleted_termmeta` |
|
1077 * - `deleted_usermeta` |
981 * |
1078 * |
982 * @since 3.4.0 |
1079 * @since 3.4.0 |
983 * |
1080 * |
984 * @param int $meta_ids Deleted metadata entry ID. |
1081 * @param int $meta_ids Deleted metadata entry ID. |
985 */ |
1082 */ |
1028 $object_ids = array_map( 'intval', $object_ids ); |
1125 $object_ids = array_map( 'intval', $object_ids ); |
1029 |
1126 |
1030 /** |
1127 /** |
1031 * Short-circuits updating the metadata cache of a specific type. |
1128 * Short-circuits updating the metadata cache of a specific type. |
1032 * |
1129 * |
1033 * The dynamic portion of the hook, `$meta_type`, refers to the meta object type |
1130 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type |
1034 * (post, comment, term, user, or any other type with an associated meta table). |
1131 * (post, comment, term, user, or any other type with an associated meta table). |
1035 * Returning a non-null value will effectively short-circuit the function. |
1132 * Returning a non-null value will effectively short-circuit the function. |
|
1133 * |
|
1134 * Possible hook names include: |
|
1135 * |
|
1136 * - `update_post_metadata_cache` |
|
1137 * - `update_comment_metadata_cache` |
|
1138 * - `update_term_metadata_cache` |
|
1139 * - `update_user_metadata_cache` |
1036 * |
1140 * |
1037 * @since 5.0.0 |
1141 * @since 5.0.0 |
1038 * |
1142 * |
1039 * @param mixed $check Whether to allow updating the meta cache of the given type. |
1143 * @param mixed $check Whether to allow updating the meta cache of the given type. |
1040 * @param int[] $object_ids Array of object IDs to update the meta cache for. |
1144 * @param int[] $object_ids Array of object IDs to update the meta cache for. |
1084 // Add a value to the current pid/key. |
1188 // Add a value to the current pid/key. |
1085 $cache[ $mpid ][ $mkey ][] = $mval; |
1189 $cache[ $mpid ][ $mkey ][] = $mval; |
1086 } |
1190 } |
1087 } |
1191 } |
1088 |
1192 |
|
1193 $data = array(); |
1089 foreach ( $non_cached_ids as $id ) { |
1194 foreach ( $non_cached_ids as $id ) { |
1090 if ( ! isset( $cache[ $id ] ) ) { |
1195 if ( ! isset( $cache[ $id ] ) ) { |
1091 $cache[ $id ] = array(); |
1196 $cache[ $id ] = array(); |
1092 } |
1197 } |
1093 wp_cache_add( $id, $cache[ $id ], $cache_key ); |
1198 $data[ $id ] = $cache[ $id ]; |
1094 } |
1199 } |
|
1200 wp_cache_add_multiple( $data, $cache_key ); |
1095 |
1201 |
1096 return $cache; |
1202 return $cache; |
1097 } |
1203 } |
1098 |
1204 |
1099 /** |
1205 /** |
1667 } |
1773 } |
1668 |
1774 |
1669 /** |
1775 /** |
1670 * Filters the object subtype identifier for a non-standard object type. |
1776 * Filters the object subtype identifier for a non-standard object type. |
1671 * |
1777 * |
1672 * The dynamic portion of the hook, `$object_type`, refers to the meta object type |
1778 * The dynamic portion of the hook name, `$object_type`, refers to the meta object type |
1673 * (post, comment, term, user, or any other type with an associated meta table). |
1779 * (post, comment, term, user, or any other type with an associated meta table). |
|
1780 * |
|
1781 * Possible hook names include: |
|
1782 * |
|
1783 * - `get_object_subtype_post` |
|
1784 * - `get_object_subtype_comment` |
|
1785 * - `get_object_subtype_term` |
|
1786 * - `get_object_subtype_user` |
1674 * |
1787 * |
1675 * @since 4.9.8 |
1788 * @since 4.9.8 |
1676 * |
1789 * |
1677 * @param string $object_subtype Empty string to override. |
1790 * @param string $object_subtype Empty string to override. |
1678 * @param int $object_id ID of the object to get the subtype for. |
1791 * @param int $object_id ID of the object to get the subtype for. |