Content_Renderer
in package
Class Content_Renderer
Table of Contents
- CONTENT_STYLES_FILE = 'content.css'
- $backup_post : WP_Post|null
- Property to store the backup of the current post.
- $backup_query : WP_Query|null
- Property to store the backup of the current query.
- $backup_template_content : string|null
- Property to store the backup of the current template content.
- $backup_template_id : int|null
- Property to store the backup of the current template ID.
- $block_type_registry : WP_Block_Type_Registry
- WordPress Block Type Registry.
- $css_inliner : Css_Inliner
- CSS inliner
- $fallback_renderer : Fallback
- Fallback renderer that is used when render_email_callback is not set for the rendered blockType.
- $logger : Email_Editor_Logger
- Logger instance.
- $process_manager : Process_Manager
- Process manager
- $theme_controller : Theme_Controller
- Theme controller
- __construct() : mixed
- Content_Renderer constructor.
- block_parser() : string
- Get block parser class
- preprocess_parsed_blocks() : array<string|int, mixed>
- Preprocess parsed blocks
- render() : string
- Render the content
- render_block() : string
- Renders block Translates block's HTML to HTML suitable for email clients. The method is intended as a callback for 'render_block' filter.
- initialize() : void
- Initialize the content renderer
- inline_styles() : string
- Method to inline styles into the HTML
- reset() : void
- As we use default WordPress filters, we need to remove them after email rendering so that we don't interfere with possible post rendering that might happen later.
- set_template_globals() : void
- Set template globals
Constants
CONTENT_STYLES_FILE
public
mixed
CONTENT_STYLES_FILE
= 'content.css'
Properties
$backup_post
Property to store the backup of the current post.
private
WP_Post|null
$backup_post
$backup_query
Property to store the backup of the current query.
private
WP_Query|null
$backup_query
$backup_template_content
Property to store the backup of the current template content.
private
string|null
$backup_template_content
$backup_template_id
Property to store the backup of the current template ID.
private
int|null
$backup_template_id
$block_type_registry
WordPress Block Type Registry.
private
WP_Block_Type_Registry
$block_type_registry
$css_inliner
CSS inliner
private
Css_Inliner
$css_inliner
$fallback_renderer
Fallback renderer that is used when render_email_callback is not set for the rendered blockType.
private
Fallback
$fallback_renderer
$logger
Logger instance.
private
Email_Editor_Logger
$logger
$process_manager
Process manager
private
Process_Manager
$process_manager
$theme_controller
Theme controller
private
Theme_Controller
$theme_controller
Methods
__construct()
Content_Renderer constructor.
public
__construct(Process_Manager $preprocess_manager, Css_Inliner $css_inliner, Theme_Controller $theme_controller, Email_Editor_Logger $logger) : mixed
Parameters
- $preprocess_manager : Process_Manager
-
Preprocess manager.
- $css_inliner : Css_Inliner
-
Css inliner.
- $theme_controller : Theme_Controller
-
Theme controller.
- $logger : Email_Editor_Logger
-
Logger instance.
Return values
mixed —block_parser()
Get block parser class
public
block_parser() : string
Return values
string —preprocess_parsed_blocks()
Preprocess parsed blocks
public
preprocess_parsed_blocks(array<string|int, mixed> $parsed_blocks) : array<string|int, mixed>
Parameters
- $parsed_blocks : array<string|int, mixed>
-
Parsed blocks.
Return values
array<string|int, mixed> —render()
Render the content
public
render(WP_Post $post, WP_Block_Template $template) : string
Parameters
- $post : WP_Post
-
Post object.
- $template : WP_Block_Template
-
Block template.
Return values
string —render_block()
Renders block Translates block's HTML to HTML suitable for email clients. The method is intended as a callback for 'render_block' filter.
public
render_block(string $block_content, array<string|int, mixed> $parsed_block) : string
Parameters
- $block_content : string
-
Block content.
- $parsed_block : array<string|int, mixed>
-
Parsed block.
Return values
string —initialize()
Initialize the content renderer
private
initialize() : void
Return values
void —inline_styles()
Method to inline styles into the HTML
private
inline_styles(string $html, WP_Post $post[, WP_Block_Template|null $template = null ]) : string
Parameters
- $html : string
-
HTML content.
- $post : WP_Post
-
Post object.
- $template : WP_Block_Template|null = null
-
Block template.
Return values
string —reset()
As we use default WordPress filters, we need to remove them after email rendering so that we don't interfere with possible post rendering that might happen later.
private
reset() : void
Return values
void —set_template_globals()
Set template globals
private
set_template_globals(WP_Post $email_post, WP_Block_Template $template) : void
Parameters
- $email_post : WP_Post
-
Post object.
- $template : WP_Block_Template
-
Block template.