Rendering_Context
in package
Class Rendering_Context
Table of Contents
- $email_context : array<string|int, mixed>
- Email-specific context data.
- $theme_json : WP_Theme_JSON
- Instance of the WP Theme.
- __construct() : mixed
- Rendering_Context constructor.
- get() : mixed
- Get a specific value from the email context.
- get_email_context() : array<string, mixed>
- Get the email-specific context data.
- get_layout_width_without_padding() : string
- Returns the width of the layout without padding.
- get_recipient_email() : string|null
- Get the recipient email address from the email context.
- get_theme_json() : WP_Theme_JSON
- Returns WP_Theme_JSON instance that should be used during the email rendering.
- get_theme_settings() : array<string|int, mixed>
- Get settings from the theme.
- get_theme_styles() : array{spacing: array{blockGap: string, padding: array{bottom: string, left: string, right: string, top: string}}, color: array{background: string, text: string}, typography: array{fontFamily: string}}
- Get the email theme styles.
- get_user_id() : int|null
- Get the user ID from the email context.
- translate_slug_to_color() : string
- Translate color slug to color.
Properties
$email_context
Email-specific context data.
private
array<string|int, mixed>
$email_context
This array contains email-specific information that can be used during rendering, such as:
- 'user_id': The ID of the user receiving the email
- 'recipient_email': The recipient's email address
- Additional context can be added by extensions using the generic get() method
$theme_json
Instance of the WP Theme.
private
WP_Theme_JSON
$theme_json
Methods
__construct()
Rendering_Context constructor.
public
__construct(WP_Theme_JSON $theme_json[, array<string, mixed> $email_context = array() ]) : mixed
Parameters
- $theme_json : WP_Theme_JSON
-
Theme Json used in the email.
- $email_context : array<string, mixed> = array()
-
Email-specific context data.
Return values
mixed —get()
Get a specific value from the email context.
public
get(string $key[, mixed $default_value = null ]) : mixed
This method allows extensions to access custom context data that may be specific to their implementation (e.g., order IDs, email types, etc.).
Parameters
- $key : string
-
The context key.
- $default_value : mixed = null
-
Default value if key is not found.
Return values
mixed — The context value or default.get_email_context()
Get the email-specific context data.
public
get_email_context() : array<string, mixed>
Return values
array<string, mixed> —get_layout_width_without_padding()
Returns the width of the layout without padding.
public
get_layout_width_without_padding() : string
Return values
string —get_recipient_email()
Get the recipient email address from the email context.
public
get_recipient_email() : string|null
Return values
string|null — The email address if available, null otherwise.get_theme_json()
Returns WP_Theme_JSON instance that should be used during the email rendering.
public
get_theme_json() : WP_Theme_JSON
Return values
WP_Theme_JSON —get_theme_settings()
Get settings from the theme.
public
get_theme_settings() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_theme_styles()
Get the email theme styles.
public
get_theme_styles() : array{spacing: array{blockGap: string, padding: array{bottom: string, left: string, right: string, top: string}}, color: array{background: string, text: string}, typography: array{fontFamily: string}}
Return values
array{spacing: array{blockGap: string, padding: array{bottom: string, left: string, right: string, top: string}}, color: array{background: string, text: string}, typography: array{fontFamily: string}} —get_user_id()
Get the user ID from the email context.
public
get_user_id() : int|null
Return values
int|null — The user ID if available, null otherwise.translate_slug_to_color()
Translate color slug to color.
public
translate_slug_to_color(string $color_slug) : string
Parameters
- $color_slug : string
-
Color slug.
