Social_Links
extends Abstract_Block_Renderer
in package
Renders the social links block.
Table of Contents
- $core_social_link_services_cache : array<string, array<string|int, mixed>>
- Cache of the core social link services.
- $supported_image_types : array<string|int, string>
- Supported image types.
- get_service_icon_url() : string
- Gets the service icon URL.
- get_service_png_path() : string
- Gets the service PNG path.
- get_service_png_url() : string
- Gets the service PNG URL.
- render() : string
- Render the block.
- add_spacer() : string
- Add a spacer around the block.
- compile_css() : string
- Compile objects containing CSS properties to a string.
- get_styles_from_block() : array<string|int, mixed>
- Wrapper for wp_style_engine_get_styles which ensures all values are returned.
- render_content() : string
- Renders the block content.
- adjust_block_content() : array<string|int, mixed>
- Adjusts the block content.
- adjust_style_attribute() : string
- 1) We need to remove padding because we render padding on wrapping table cell 2) We also need to replace font-size to avoid clamp() because clamp() is not supported in many email clients.
- generate_social_link_content() : string
- Generates the social link content.
- get_block_wrapper() : string
- Gets the block wrapper.
Properties
$core_social_link_services_cache
Cache of the core social link services.
private
array<string, array<string|int, mixed>>
$core_social_link_services_cache
= array()
$supported_image_types
Supported image types.
private
array<string|int, string>
$supported_image_types
= array('white', 'brand')
Methods
get_service_icon_url()
Gets the service icon URL.
public
get_service_icon_url(string $service[, string $image_type = '' ]) : string
Default image type is 'white'.
Parameters
- $service : string
-
The service name.
- $image_type : string = ''
-
The image type. e.g 'white', 'brand'.
Return values
string — The service icon URL.get_service_png_path()
Gets the service PNG path.
public
get_service_png_path(string $service[, string $image_type = 'white' ]) : string
Parameters
- $service : string
-
The service name.
- $image_type : string = 'white'
-
The image type. e.g 'white', 'brand'.
Return values
string — The service PNG path.get_service_png_url()
Gets the service PNG URL.
public
get_service_png_url(string $service[, string $image_type = 'white' ]) : string
Parameters
- $service : string
-
The service name.
- $image_type : string = 'white'
-
The image type. e.g 'white', 'brand'.
Return values
string — The service PNG URL.render()
Render the block.
public
render(string $block_content, array<string|int, mixed> $parsed_block, Settings_Controller $settings_controller) : string
Parameters
- $block_content : string
-
The block content.
- $parsed_block : array<string|int, mixed>
-
The parsed block.
- $settings_controller : Settings_Controller
-
The settings controller.
Return values
string —add_spacer()
Add a spacer around the block.
protected
add_spacer(string $content, array<string|int, mixed> $email_attrs) : string
Parameters
- $content : string
-
The block content.
- $email_attrs : array<string|int, mixed>
-
The email attributes.
Return values
string —compile_css()
Compile objects containing CSS properties to a string.
protected
compile_css(array<string|int, mixed> ...$styles) : string
Parameters
- $styles : array<string|int, mixed>
-
Style arrays to compile.
Return values
string —get_styles_from_block()
Wrapper for wp_style_engine_get_styles which ensures all values are returned.
protected
get_styles_from_block(array<string|int, mixed> $block_styles[, bool $skip_convert_vars = false ]) : array<string|int, mixed>
Parameters
- $block_styles : array<string|int, mixed>
-
Array of block styles.
- $skip_convert_vars : bool = false
-
If true, --wp_preset--spacing--x type values will be left in the original var:preset:spacing:x format.
Return values
array<string|int, mixed> —render_content()
Renders the block content.
protected
render_content(string $block_content, array<string|int, mixed> $parsed_block, Settings_Controller $settings_controller) : string
Parameters
- $block_content : string
-
Block content.
- $parsed_block : array<string|int, mixed>
-
Parsed block.
- $settings_controller : Settings_Controller
-
Settings controller.
Return values
string —adjust_block_content()
Adjusts the block content.
private
adjust_block_content(string $block_content, array<string|int, mixed> $parsed_block) : array<string|int, mixed>
Returns css classes and styles compatible with email clients.
Parameters
- $block_content : string
-
The block content.
- $parsed_block : array<string|int, mixed>
-
The parsed block.
Return values
array<string|int, mixed> — The adjusted block content.adjust_style_attribute()
1) We need to remove padding because we render padding on wrapping table cell 2) We also need to replace font-size to avoid clamp() because clamp() is not supported in many email clients.
private
adjust_style_attribute(string $block_content) : string
The font size values is automatically converted to clamp() when WP site theme is configured to use fluid layouts. Currently (WP 6.5), there is no way to disable this behavior.
Parameters
- $block_content : string
-
Block content.
Return values
string —generate_social_link_content()
Generates the social link content.
private
generate_social_link_content(array<string|int, mixed> $block, array<string|int, mixed> $parent_block_attrs) : string
Parameters
- $block : array<string|int, mixed>
-
The block data.
- $parent_block_attrs : array<string|int, mixed>
-
The parent block attributes.
Return values
string — The generated content.get_block_wrapper()
Gets the block wrapper.
private
get_block_wrapper(string $block_content, array<string|int, mixed> $parsed_block) : string
Parameters
- $block_content : string
-
The block content.
- $parsed_block : array<string|int, mixed>
-
The parsed block.