Rendering_Context
in package
Class Rendering_Context
Table of Contents
- $email_context : array<string|int, mixed>
- Email-specific context data.
- $language : string|null
- Email language used for deterministic direction fallback.
- $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_default_text_align() : string
- Get the default physical text alignment for this render.
- get_email_context() : array<string, mixed>
- Get the email-specific context data.
- get_end_side() : string
- Get the physical end side.
- get_language() : string|null
- Get the email language.
- 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_start_side() : string
- Get the physical start side.
- get_text_direction() : string
- Get the HTML/CSS text direction.
- 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.
- is_rtl() : bool
- Whether this render should use right-to-left direction.
- resolve_text_align() : string
- Resolve a text alignment value with direction-aware default.
- sanitize_text_align() : string|null
- Sanitize a text alignment value.
- translate_slug_to_color() : string
- Translate color slug to color.
- get_primary_language_subtag() : string|null
- Get the primary language subtag from a locale/language value.
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
$language
Email language used for deterministic direction fallback.
private
string|null
$language
$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() ][, string|null $language = null ]) : mixed
Parameters
- $theme_json : WP_Theme_JSON
-
Theme Json used in the email.
- $email_context : array<string, mixed> = array()
-
Email-specific context data.
- $language : string|null = null
-
Email language.
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_default_text_align()
Get the default physical text alignment for this render.
public
get_default_text_align() : string
Return values
string —get_email_context()
Get the email-specific context data.
public
get_email_context() : array<string, mixed>
Return values
array<string, mixed> —get_end_side()
Get the physical end side.
public
get_end_side() : string
Return values
string —get_language()
Get the email language.
public
get_language() : string|null
Return values
string|null —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_start_side()
Get the physical start side.
public
get_start_side() : string
Return values
string —get_text_direction()
Get the HTML/CSS text direction.
public
get_text_direction() : string
Return values
string —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.is_rtl()
Whether this render should use right-to-left direction.
public
is_rtl() : bool
Return values
bool —resolve_text_align()
Resolve a text alignment value with direction-aware default.
public
resolve_text_align(mixed $alignment) : string
Parameters
- $alignment : mixed
-
Alignment candidate.
Return values
string —sanitize_text_align()
Sanitize a text alignment value.
public
sanitize_text_align(mixed $alignment) : string|null
Parameters
- $alignment : mixed
-
Alignment candidate.
Return values
string|null —translate_slug_to_color()
Translate color slug to color.
public
translate_slug_to_color(string $color_slug) : string
Parameters
- $color_slug : string
-
Color slug.
Return values
string —get_primary_language_subtag()
Get the primary language subtag from a locale/language value.
private
get_primary_language_subtag(string|null $language) : string|null
Parameters
- $language : string|null
-
Language or locale.
