All features

Cherry Blossom feature

Structured data: Context

Describes the current structured data request.

Describes the current structured data request.

Capabilities and extension points

Parsed-block key containing the post that owns its metadata.

  • var string

Queried WordPress object.

  • var mixed

Canonical request URL.

  • var string

Singular post, when available.

  • var \WP_Post|null

Resolved blocks for the singular post.

  • var array|null

Synced pattern references expanded during block parsing.

  • var array

Creates a request context.

  • param mixed $queried_object Queried WordPress object.
  • param string $canonical_url Canonical request URL.
  • param \WP_Post|null $post Singular post, when available.

Creates a context for the current WordPress request.

Call after WordPress resolves the main query so conditional tags and the queried object describe the requested page.

  • return self Request context.

Gets the queried WordPress object.

  • return mixed Queried object.

Gets the canonical request URL.

  • return string Canonical URL.

Gets the singular post.

  • return \WP_Post|null Singular post, when available.

Determines whether the request is singular.

  • return bool Whether the context contains a singular post.

Gets resolved blocks, optionally limited to a block name.

Returns a cached flat list including nested blocks and expanded synced patterns. SOURCE_POST_ID_KEY identifies the post owning block metadata. No post yields an empty list; a supplied name is matched exactly.

  • param string|null $block_name Block name, or null for all blocks.
  • return array Parsed blocks.

Gets the canonical URL for the current request.

  • param \WP_Post|null $post Singular post, when available.
  • return string Canonical URL.

Parses and resolves the singular post's blocks.

  • return array Flattened parsed blocks.

Flattens a parsed block tree.

  • param array $blocks Parsed block tree.
  • param int $source_post_id Post that owns the block data.
  • return array Flattened blocks.

Source reference

This editable reference page is based on the PHP documentation in structured-data/class-context.php.