All features

Cherry Blossom feature

Content types: Content Type base

Provides shared behavior for named content type definitions.

Provides shared behavior for named content type definitions.

Capabilities and extension points

Provides shared behavior for named content type definitions.

Content types use a parameterized identity map rather than a singleton. One canonical object can exist for each combination of definition family and registered name, while unrelated names remain independent.

Canonical definition objects keyed by family and name.

  • var array

Content type identifier.

Extended classes may set this property to support argument-free factory calls such as Project::get_instance().

  • var string

Immutable resolved content type identifier.

  • var string

Unresolved content type definition.

  • var array

Definition supplied to the factory.

  • var array

Resolved content type definition.

  • var array|null

Registered WordPress object.

  • var object|null

Whether definition-specific hooks have been registered.

  • var bool

Creates a canonical content type definition.

Construction is protected and final so callers must use get_instance(). Extended definitions customize themselves through properties, configure(), and the other overridable methods.

  • param string $name Content type identifier.
  • param array $definition Content type definition.

Prevents definition objects from being cloned.

Prevents definition objects from being unserialized.

  • throws \LogicException When unserialization is attempted.

Gets the canonical definition instance.

A conflicting concrete class or definition cannot replace an object that has already claimed the same family and name during the request.

  • param string $name Content type identifier.
  • param array $definition Content type definition.
  • return static Canonical definition object.

Determines whether a named instance exists for the called family.

  • param string $name Content type identifier.
  • return bool Whether an instance exists.

Gets canonical instances for the called definition family.

  • return array Definition objects keyed by content type name.

Gets a default property without constructing a definition object.

  • param string $class Definition class.
  • param string $property Property name.
  • param mixed $default Default value.
  • return mixed Property value or default.

Configures defaults for an extended definition class.

This runs before definition data passed to get_instance() is merged.

Registers definition-specific hooks once.

Registers required content type hooks.

Concrete definition families use this separately from hooks() so their lifecycle integration remains active when an extending class supplies additional hooks of its own.

Registers definition-specific WordPress hooks.

Gets the content type identifier.

  • return string Content type identifier.

Gets the definition family.

  • return string Definition family.

Gets the resolved content type definition.

  • return array Resolved definition.

Gets roles that receive managed content type capabilities.

  • return array Role identifiers.

Gets the registered WordPress object.

  • return object|null Registered object.

Determines whether registration succeeded.

  • return bool Whether the content type is registered.

Validates the shared definition properties.

  • return true|\WP_Error True when valid, otherwise a validation error.

Gets the definition values that affect rewrite rules.

  • return array Rewrite-relevant definition values.

Merges definition arrays while preserving replaceable list values.

  • param array $defaults Definition defaults.
  • param array $definition Definition overrides.
  • return array Merged definition.

Gets the immutable definition family.

  • return string Definition family.

Gets arguments passed to the native registration function.

  • return array Registration arguments.

Registers the content type with WordPress.

  • return object|\WP_Error Registered object or error.

Source reference

This editable reference page is based on the PHP documentation in content-types/abstract-content-type.php.