Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Fixed error in outputting icons
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiyazdani committed Nov 7, 2020
1 parent 55626eb commit c45204d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions social-network-widget-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function render_admin_js() {
* @return void
*/
public function widget( $args, $instance ) {
$i = 0;
$html = array();
$instance = wp_parse_args( (array) $instance, $this->defaults );
$instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
Expand All @@ -100,26 +101,27 @@ public function widget( $args, $instance ) {
$html['ul_open'] = '<ul class="social-network-icons">';
foreach ( $instance['icons'] as $icon ) {
if ( ! empty( $icon['url'] ) ) {
$html['li_open'] = '<li class="social-network-icons__item">';
$html['link_open'] = sprintf( '<a href="%s" title="%s" target="%s" rel="%s" style="%s">%s</a>', esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ), sanitize_title( $icon['label'] ), $get_target ? '_blank' : '_self', $get_target ? 'noopener noreferrer nofollow' : '', implode( '', $get_colors ) );
$html[sprintf( 'li_open_%d', $i )] = '<li class="social-network-icons__item">';
$html[sprintf( 'link_open_%d', $i )] = sprintf( '<a href="%s" target="%s" rel="%s" style="%s">', esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ), $get_target ? '_blank' : '_self', $get_target ? 'noopener noreferrer nofollow' : '', implode( '', $get_colors ) );
$found_icon = false;
foreach ( $social_icons as $social_icon ) {
foreach ( $social_icon['url'] as $url_fragment ) {
if ( false !== stripos( $icon['url'], $url_fragment ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$html['link_label'] = sprintf( '<span class="screen-reader-text">%s</span>%s', esc_attr( $social_icon['label'] ), $social_icon['icon'] );
$html[sprintf( 'link_label_%d', $i )] = sprintf( '<span class="screen-reader-text">%s</span>%s', esc_attr( $social_icon['label'] ), $social_icon['icon'] );
$found_icon = true;
break;
}
}
}

if ( ! $found_icon ) {
$html['fallback_icon'] = self::get_default_icon();
$html[sprintf( 'fallback_icon_%d', $i )] = self::get_default_icon();
}

$html['link_close'] = '</a>';
$html[sprintf( 'link_close_%d', $i )] = '</a>';
}
$i++;
}
$html['ul_close'] = '</ul>';
}
Expand Down

0 comments on commit c45204d

Please sign in to comment.