abstract class Meta

An abstract class for other abstract classes to inherit regarding saving meta values in standard form in the WordPress database.

User Meta and Post Meta abstract classes for example will inherently extend this class.

Properties

protected Meta_Schema $Schema
protected string $single
protected mixed $data

Methods

static string
key()

The meta key used in the database.

mixed
load()

The function used to load meta data from the database.

bool
save()

The function used to save meta data.

mixed
export()

Create a data structure that should be saved in it's own format in the database.

Meta_Schema
get_schema()

Return the Meta schema.

mixed
get_data()

Get the meta data of this instance.

__construct()

Construct the Meta. Load the data from the database.

set_data(mixed $data)

Set the meta data of this instance.

set_schema(Meta_Schema $Schema)

Set the schema for the Meta data.

import(array $data)

Set properties of the class based on an associative array.

WP_Error|bool
validate()

Validate the Meta export values based on the current Schema.

Details

at line 42
abstract static string key()

The meta key used in the database.

Return Value

string

The meta database key.

at line 49
abstract mixed load()

The function used to load meta data from the database.

Return Value

mixed

The meta data from the database.

at line 56
abstract bool save()

The function used to save meta data.

Return Value

bool

The result of saving the meta to the database. Nota bene: With WordPress functions, the result may return FALSE if the data was the same.

at line 63
abstract mixed export()

Create a data structure that should be saved in it's own format in the database.

Return Value

mixed

The data as it should be saved into the database.

at line 70
final Meta_Schema get_schema()

Return the Meta schema.

Return Value

Meta_Schema

The Meta schema.

at line 77
final protected mixed get_data()

Get the meta data of this instance.

Return Value

mixed

The meta data.

at line 82
__construct()

Construct the Meta. Load the data from the database.

at line 95
final protected set_data(mixed $data)

Set the meta data of this instance.

Parameters

mixed $data

The meta data.

at line 110
final protected set_schema(Meta_Schema $Schema)

Set the schema for the Meta data.

Parameters

Meta_Schema $Schema

The Meta Value to use for the schema.

at line 119
final import(array $data)

Set properties of the class based on an associative array.

Parameters

array $data

at line 132
final WP_Error|bool validate()

Validate the Meta export values based on the current Schema.

Return Value

WP_Error|bool

Returns TRUE of the Meta is valid, otherwise returns validation errors.