This documentation describes unreleased changes on the main branch.

#[PostMeta]

Attribute on classes.

use Saij\WpAppFramework\Post\PostMeta;

Declares a class of post meta fields: each promoted constructor parameter is a field, stored in its own meta key {namespace}_{field} (field name in snake case). The fields are reached through the post object only: $event->meta(EventDetails::class).

The class is not readonly: the fields are usually private, with getters and setters, and save() of the post writes the changed values.

Arguments

#[PostMeta(string $name, string $title, array $postTypes)]
ParameterTypeDefaultDescription
namestringrequiredName of the class within each post type: lowercase letters, digits and "_", starting with a letter (post.meta('details') in templates).
titlestringrequiredTitle of the panel in the block editor and of the meta box.
postTypeslist<class-string<AbstractPost>>requiredPost classes the fields belong to: classes with #[PostType], Post or Page.