Advanced
Owns source resolution, previews and repeated card rendering.
Namespace: WebberZone\Contextual_Related_Posts\Pro\Blocks
Since: 4.5.0
Source: includes/pro/blocks/class-advanced.php line 25
Methods
__construct()
Register the block family.
Line: 30
public function __construct( );
register_blocks()
Register metadata and selectable patterns.
Since: 4.5.0
Line: 43
public function register_blocks( );
editor_settings()
Supply the same patterns and defaults to every editor surface.
Since: 4.5.0
Line: 73
public function editor_settings( );
resolve_source() static
Resolve a live source without persisting the editor’s current post.
Since: 4.5.0
Line: 100
static public function resolve_source( array $attributes, array $context ): int;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Block attributes. |
array |
$context |
Block context. |
Returns: int — Source post ID, or zero when no source exists.
query_args() static
Normalize the shared query input.
Since: 4.5.0
Line: 123
static public function query_args( array $query, int $source, bool $is_preview = ... ): array;
| Type | Name | Description |
|---|---|---|
array |
$query |
Saved query settings. |
int |
$source |
Source post ID. |
bool |
$is_preview |
Whether to enforce REST meta permissions. |
Returns: array — CRP arguments.
results() static
Return public results through the existing CRP engine and cache.
Since: 4.5.0
Line: 198
static public function results( array $query, int $source, bool $is_preview = ... ): array;
| Type | Name | Description |
|---|---|---|
array |
$query |
Query settings. |
int |
$source |
Source ID. |
bool |
$is_preview |
Whether to enforce REST meta permissions. |
Returns: array — Results.
render_advanced()
Render a section only after resolving its source and results.
Since: 4.5.0
Line: 227
public function render_advanced( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
render_template()
Render each card with its own post context, restoring surrounding globals.
Since: 4.5.0
Line: 262
public function render_template( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
render_empty()
Render the optional empty state.
Since: 4.5.0
Line: 319
public function render_empty( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
render_related_post_image()
Render a related post image in every editor surface.
Since: 4.5.0
Line: 338
public function render_related_post_image( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
render_related_post_title()
Render a related post title.
Since: 4.5.0
Line: 362
public function render_related_post_title( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
render_related_post_date()
Render a related post date.
Since: 4.5.0
Line: 399
public function render_related_post_date( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
render_related_post_excerpt()
Render a related post excerpt.
Since: 4.5.0
Line: 428
public function render_related_post_excerpt( $attributes, $content, $block ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Attributes. |
string |
$content |
Unrendered content. |
\WP_Block |
$block |
Block instance. |
Returns: string — HTML.
register_routes()
Register an editor-only preview endpoint.
Since: 4.5.0
Line: 479
public function register_routes( );
preview_permission()
Authorize the editor and its source, including draft previews.
Since: 4.5.0
Line: 543
public function preview_permission( $request ): bool;
| Type | Name | Description |
|---|---|---|
\WP_REST_Request |
$request |
Request. |
Returns: bool — Whether the preview is permitted.
preview()
Preview the normalized query without exposing arbitrary post meta.
Since: 4.5.0
Line: 559
public function preview( $request ): \WP_REST_Response|\WP_Error;
| Type | Name | Description |
|---|---|---|
\WP_REST_Request |
$request |
Request. |
Returns: \WP_REST_Response|\WP_Error — Result identities or a validation error.