# yaymail/4.4.5/templates/elements/social-icon.php

YayMail – WooCommerce Email Customizer, version 4.4.5. 114 lines.

- Page: https://pluginprobe.com/plugins/yaymail/4.4.5/code/templates/elements/social-icon.php
- Raw: https://pluginprobe.com/plugins/yaymail/4.4.5/raw/templates/elements/social-icon.php
- Modified: 2026-08-23T09:24:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/yaymail/4.4.5/code/templates/elements/social-icon.php#L10-L20`.

```php
<?php

defined( 'ABSPATH' ) || exit;

use YayMail\SocialIcons\SocialIconEndpoint;
use YayMail\Utils\TemplateHelpers;

if ( empty( $args['element'] ) ) {
    return;
}

$element = $args['element'];
$data    = $element['data'];

if ( empty( $data['icon_list'] ) ) {
    return;
}

$direction_rtl = yaymail_get_email_direction();

$wrapper_style = TemplateHelpers::get_style(
    [
        'word-break'       => 'break-word',
        'background-color' => $data['background_color'],
        'padding'          => TemplateHelpers::get_spacing_value( isset( $data['padding'] ) ? $data['padding'] : [] ),
    ]
);

$theme = [
    'Colorful'   => 'colorful',
    'LineDark'   => 'line-dark',
    'LineLight'  => 'line-light',
    'SolidDark'  => 'solid-dark',
    'SolidLight' => 'solid-light',
];

$is_custom_theme = isset( $data['theme'] ) && 'Custom' === $data['theme'];
$icon_color      = isset( $data['icon_color'] ) ? $data['icon_color'] : '#333333';
// Resolve global preset paths (presets/...) to hex BEFORE building the image URL.
// Otherwise TemplateRenderer's post-pass replaces the path with "#rrggbb" inside the
// query string, and the "#" truncates the URL as a fragment.
$icon_color  = TemplateHelpers::replace_color_paths( $icon_color );
$icon_size   = isset( $data['width_icon'] ) ? absint( $data['width_icon'] ) : 24;
$render_size = max( 32, min( 256, $icon_size * 2 ) );

// Handle table alignment
$table_margin = '0 auto';
if ( isset( $data['align'] ) ) {
    switch ( $data['align'] ) {
        case 'center':
            $table_margin = '0 auto';
            break;
        case 'right':
            $table_margin = '0 0 0 auto';
            break;
        case 'left':
        default:
            $table_margin = '0';
            break;
    }
}

$item_style = TemplateHelpers::get_style(
    [
        'display'        => 'inline-block',
        'vertical-align' => 'top',
        'text-align'     => 'center',
        'margin'         => '5px 0',
        'padding-left'   => TemplateHelpers::get_dimension_value( max( ( $data['spacing'] ?? 0 ) - 5, 0 ) / 2 ),
        'padding-right'  => TemplateHelpers::get_dimension_value( max( ( $data['spacing'] ?? 0 ) - 5, 0 ) / 2 ),
        'padding-top'    => 0,
        'padding-bottom' => 0,
    ]
);

$a_style = TemplateHelpers::get_style(
    [
        'display'         => 'inline-block',
        'border'          => 'none',
        'text-decoration' => 'none',
    ]
);

ob_start();
?>
<table class="yaymail-customizer-element-social" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse: collapse; margin: <?php echo esc_attr( $table_margin ); ?>; width: 100%;">
    <tr>
        <td style="text-align: <?php echo esc_attr( $data['align'] ?? 'center' ); ?>;">
        <?php foreach ( $data['icon_list'] as $key => $el ) : ?>
            <?php
            if ( $is_custom_theme ) {
                $img_url = SocialIconEndpoint::get_url( $el['icon'], $icon_color, $render_size );
            } else {
                $theme_slug = $theme[ $data['theme'] ] ?? 'colorful';
                $img_url    = YAYMAIL_PLUGIN_URL . 'assets/images/social-icons/' . $el['icon'] . '/' . $theme_slug . '.png';
            }
            $first_index = ( 'rtl' === $direction_rtl ) ? count( $data['icon_list'] ) - 1 : 0;
            $spacing     = ( $first_index === $key ) ? '0px' : $data['spacing'] . 'px';
            $text_align  = isset( $data['align'] ) ? $data['align'] : 'center';
            ?>
            <span class="yaymail-social-icon-item" style="<?php echo esc_attr( $item_style ); ?>">
                <a href="<?php echo esc_attr( do_shortcode( $el['url'] ) ); ?>" target="_blank" style="<?php echo esc_attr( $a_style ); ?>">
                    <img border="0" tabindex="0" src="<?php echo esc_url( $img_url ); ?>" height="<?php echo esc_attr( $data['width_icon'] ); ?>" width="<?php echo esc_attr( $data['width_icon'] ); ?>" style="display: block; border: 0; margin: 0; padding: 0; outline: none;" />
                </a>
            </span>
        <?php endforeach; ?>
        </td>
    </tr>
</table>
<?php
$element_content = ob_get_clean();

TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style );

```
