Featured_Image
Featured Image block class.
Namespace: WebberZone\Contextual_Related_Posts\Pro\Blocks
Since: 3.6.0
Source: includes/blocks/class-featured-image.php line 22
Methods
__construct()
Register widget with WordPress.
Line: 27
public function __construct( );
default_attributes() static
Get the default attributes for the block.
Since: 3.6.0
Line: 40
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: 66
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.
enqueue_block_editor_assets() static
Enqueue scripts and styles for the block editor.
Since: 3.6.0
Line: 178
static public function enqueue_block_editor_assets( );
register_custom_featured_image_endpoint()
Register REST fields for the block.
Since: 3.6.0
Line: 203
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: 227
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: 267
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: 370
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()
Create the style attribute for the image tag.
Since: 3.6.0
Line: 411
public function get_style_attribute( $attributes ): string;
| Type | Name | Description |
|---|---|---|
array | $attributes | The block attributes. |
Returns: string — Style attribute for the image tag.