Skip to content

Instantly share code, notes, and snippets.

@mlbd
Created January 20, 2018 07:22
Show Gist options
  • Save mlbd/014a9daa70575e2904c3b21dbef74cc9 to your computer and use it in GitHub Desktop.
Save mlbd/014a9daa70575e2904c3b21dbef74cc9 to your computer and use it in GitHub Desktop.
<?php
$socials = $pixiefy_option['social_links'];
if ( (array) $socials && isset($socials) ) :
echo '<ul id="social-buttons">';
foreach ( (array) $socials as $key => $entry ) {
if ( isset( $entry['url'] ) ) {
$original_url= $entry['url'];
$pieces = parse_url($original_url);
$domain = isset($pieces['host']) ? $pieces['host'] : '';
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
$social_class = strstr( $regs['domain'], '.', true );
}
if($social_class == 'google') {
$social_class = 'google-plus';
}
$social_class = $social_class;
echo '<li><a href="' . esc_url( $entry['url'] ) . '" id="'.$social_class.'"></a></li><span>'.$entry['title'].'</span>';
}
}
echo '</ul>';
endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment