Featured_Image
Featured Image block class.
Namespace: WebberZone\Contextual_Related_Posts\Pro\Blocks
Since: 3.6.0
Source: includes/pro/blocks/class-featured-image.php line 23
Methods
__construct()
Register widget with WordPress.
Line: 28
public function __construct( );
default_attributes() static
Get the default attributes for the block.
Since: 3.6.0
Line: 43
static public function default_attributes( ): array;
Returns: array — Default attributes.
render_block()
Modify the output of the post-featured-image block
Since: 3.6.0
Line: 69
public function render_block( $block_content, $block, $instance ): string;
| Type | Name | Description |
|---|---|---|
string |
$block_content |
The block content about to be appended. |
array |
$block |
The full block, including name and attributes. |
\WP_Block |
$instance |
The block instance. |
Returns: string — Modified block content.
render_image() static
Render a CRP image inside the active block wrapper.
Since: 4.5.0
Line: 110
static public function render_image( array $attributes, int $post_id, string $wrapper_class = ..., string $wrapper_style = ... ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
Image block attributes. |
int |
$post_id |
Related post ID. |
string |
$wrapper_class |
Additional wrapper class. |
string |
$wrapper_style |
Additional wrapper style. |
Returns: string — Image markup.
enqueue_block_editor_assets() static
Enqueue scripts and styles for the block editor.
Since: 3.6.0
Line: 209
static public function enqueue_block_editor_assets( );
register_custom_featured_image_endpoint()
Register REST fields for the block.
Since: 3.6.0
Line: 235
public function register_custom_featured_image_endpoint( );
permissions_check()
Check whether the current user can request featured image data for a post.
The endpoint is used in the editor, so we require block editor access and also validate access to the specific post ID being queried.
Since: 4.2.2
Line: 263
public function permissions_check( $request ): \WP_Error|bool;
| Type | Name | Description |
|---|---|---|
\WP_REST_Request |
$request |
Request object. |
Returns: \WP_Error|bool
get_items_params()
Get the arguments for fetching the popular posts.
Since: 3.6.0
Line: 303
public function get_items_params( ): array;
Returns: array — Contextual Related Posts REST API popular posts arguments.
get_featured_image()
Get the featured image for a post.
Since: 3.6.0
Line: 406
public function get_featured_image( $request ): \WP_REST_Response|\WP_Error;
| Type | Name | Description |
|---|---|---|
\WP_REST_Request |
$request |
The request object. |
Returns: \WP_REST_Response|\WP_Error — The featured image or WP_Error if no post ID.
get_style_attribute() static
Create the style attribute for the image tag.
Since: 3.6.0
Line: 450
static public function get_style_attribute( $attributes ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
The block attributes. |
Returns: string — Style attribute for the image tag.
get_figure_style_attribute() static
Create the wrapper dimensions used by the legacy Query Loop image fallback.
Since: 4.5.0
Line: 483
static public function get_figure_style_attribute( $attributes ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
The block attributes. |
Returns: string — Style attribute for the figure element.
get_aspect_ratio_style_attribute() static
Create the aspect ratio style used by the related image figure.
Since: 4.5.0
Line: 504
static public function get_aspect_ratio_style_attribute( $attributes ): string;
| Type | Name | Description |
|---|---|---|
array |
$attributes |
The block attributes. |
Returns: string — Style attribute fragment.