| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | defined( 'ABSPATH' ) || exit; |
| 4 | 4 | |
| 5 | +use YayMail\SocialIcons\SocialIconEndpoint; | |
| 5 | 6 | use YayMail\Utils\TemplateHelpers; |
| 6 | 7 | |
| 7 | 8 | if ( empty( $args['element'] ) ) { |
| 8 | 9 | return; |
| @@ -32,8 +33,17 @@ | ||
| 32 | 33 | 'SolidDark' => 'solid-dark', |
| 33 | 34 | 'SolidLight' => 'solid-light', |
| 34 | 35 | ]; |
| 35 | 36 | |
| 37 | +$is_custom_theme = isset( $data['theme'] ) && 'Custom' === $data['theme']; | |
| 38 | +$icon_color = isset( $data['icon_color'] ) ? $data['icon_color'] : '#333333'; | |
| 39 | +// Resolve global preset paths (presets/...) to hex BEFORE building the image URL. | |
| 40 | +// Otherwise TemplateRenderer's post-pass replaces the path with "#rrggbb" inside the | |
| 41 | +// query string, and the "#" truncates the URL as a fragment. | |
| 42 | +$icon_color = TemplateHelpers::replace_color_paths( $icon_color ); | |
| 43 | +$icon_size = isset( $data['width_icon'] ) ? absint( $data['width_icon'] ) : 24; | |
| 44 | +$render_size = max( 32, min( 256, $icon_size * 2 ) ); | |
| 45 | + | |
| 36 | 46 | // Handle table alignment |
| 37 | 47 | $table_margin = '0 auto'; |
| 38 | 48 | if ( isset( $data['align'] ) ) { |
| 39 | 49 | switch ( $data['align'] ) { |
| @@ -77,9 +87,14 @@ | ||
| 77 | 87 | <tr> |
| 78 | 88 | <td style="text-align: <?php echo esc_attr( $data['align'] ?? 'center' ); ?>;"> |
| 79 | 89 | <?php foreach ( $data['icon_list'] as $key => $el ) : ?> |
| 80 | 90 | <?php |
| 81 | - $img_url = YAYMAIL_PLUGIN_URL . 'assets/images/social-icons/' . $el['icon'] . '/' . $theme[ $data['theme'] ] . '.png'; | |
| 91 | + if ( $is_custom_theme ) { | |
| 92 | + $img_url = SocialIconEndpoint::get_url( $el['icon'], $icon_color, $render_size ); | |
| 93 | + } else { | |
| 94 | + $theme_slug = $theme[ $data['theme'] ] ?? 'colorful'; | |
| 95 | + $img_url = YAYMAIL_PLUGIN_URL . 'assets/images/social-icons/' . $el['icon'] . '/' . $theme_slug . '.png'; | |
| 96 | + } | |
| 82 | 97 | $first_index = ( 'rtl' === $direction_rtl ) ? count( $data['icon_list'] ) - 1 : 0; |
| 83 | 98 | $spacing = ( $first_index === $key ) ? '0px' : $data['spacing'] . 'px'; |
| 84 | 99 | $text_align = isset( $data['align'] ) ? $data['align'] : 'center'; |
| 85 | 100 | ?> |
| @@ -84,9 +99,9 @@ | ||
| 84 | 99 | $text_align = isset( $data['align'] ) ? $data['align'] : 'center'; |
| 85 | 100 | ?> |
| 86 | 101 | <span class="yaymail-social-icon-item" style="<?php echo esc_attr( $item_style ); ?>"> |
| 87 | 102 | <a href="<?php echo esc_attr( do_shortcode( $el['url'] ) ); ?>" target="_blank" style="<?php echo esc_attr( $a_style ); ?>"> |
| 88 | - <img border="0" tabindex="0" src="<?php echo esc_attr( $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;" /> | |
| 103 | + <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;" /> | |
| 89 | 104 | </a> |
| 90 | 105 | </span> |
| 91 | 106 | <?php endforeach; ?> |
| 92 | 107 | </td> |