API / Minn\Runtime / MetaData

MetaData final class

Minn\Runtime\MetaData · public/minn/src/Minn/Runtime/MetaData.php · 313 lines

Metadata as WordPress's meta functions read and write it, for posts, terms, comments, users and any type a plugin's table names: read through get_{type}_metadata and the object cache (a value its default when unset), written and removed with the filters that may answer first and the actions around each change (post meta also told as postmeta), values sanitized and stored serialized.

Public

staticget(mixed $type, mixed $objectId, mixed $key = '', mixed $single = false): mixed#

A value, a key's values, or every key's (get_metadata), the default when the key is unset.

staticraw(mixed $type, mixed $objectId, mixed $key = '', mixed $single = false): mixed#

What is stored (get_metadata_raw): false for no type or object, null for an unknown type or an unset key; get_{type}_metadata may answer first; else the object's meta, read once into the cache.

staticfallback(mixed $type, mixed $objectId, mixed $key, mixed $single = false): mixed#

An unset key's value (get_metadata_default): empty, or an empty list, as default_{type}_metadata leaves it.

staticexists(mixed $type, mixed $objectId, mixed $key): bool#

Whether a key is set for an object (metadata_exists), get_{type}_metadata answering first.

staticadd(mixed $type, mixed $objectId, mixed $key, mixed $value, mixed $unique = false): mixed#

A value added (add_metadata): its id, or false; refused when unique and the key is already set.

staticupdate(mixed $type, mixed $objectId, mixed $key, mixed $value, mixed $previous = ''): mixed#

A value changed (update_metadata): every row of the key, or only those holding the previous value given; a key not stored yet is added from the value as it was handed in (and the new row's id answers).

staticdelete(mixed $type, mixed $objectId, mixed $key, mixed $value = '', mixed $all = false): bool#

Values removed (delete_metadata): the key's, or only those holding the value given; for every object when all are asked.

staticisProtected(mixed $key, mixed $type = ''): mixed#

Whether a key is private to code (is_protected_meta): one starting with an underscore, as the filter leaves it.

staticsanitize(mixed $key, mixed $value, mixed $objectType, mixed $subtype = ''): mixed#

A value as its key's sanitizer leaves it (sanitize_meta), the subtype's own sanitizer first when one is hooked.

statictable(string $type): ?array#

A meta type's table, or null when there is none: the built-in types, and a plugin's type by the table it set on $wpdb as "{type}meta".

@return list<string>|null
staticuserOption(mixed $option, mixed $user = 0, mixed $deprecated = ''): mixed#

A user's option (get_user_option): the site's prefixed key first, then the bare one; false for nobody or neither; as get_user_option_{option} leaves it.

staticbyMid(mixed $type, mixed $metaId): mixed#

One meta row by its id (get_metadata_by_mid): an object under the table's own column names, the value decoded, unless get_{type}_metadata_by_mid answers first; false when there is none.

staticdeleteByMid(mixed $type, mixed $metaId): bool#

One meta row removed by its id (delete_metadata_by_mid), with the delete actions for that row (posts and comments also told by their older names, with the row id alone), unless delete_{type}_metadata_by_mid answers first.

staticofPost(mixed $postId, mixed $key = '', mixed $single = false): mixed#

A post's meta (get_post_meta).

staticupdatePost(mixed $postId, mixed $key, mixed $value, mixed $previous = ''): mixed#

A post's meta changed (update_post_meta).

staticupdateUser(mixed $userId, mixed $key, mixed $value, mixed $previous = ''): mixed#

A user's meta changed (update_user_meta).

staticpostCustom(mixed $postId = 0): mixed#

Every key of a post's meta (get_post_custom), the post being read's when none is named.

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatestore(): Minn\Runtime\Meta#
privateannounce(string $verb, string $type, array $args, array $legacy): void#

An action told for a meta change, and its postmeta twin for posts.

privaterows(): Minn\Runtime\Meta#