Skip to content

Instantly share code, notes, and snippets.

@moxdev
Created May 9, 2018 20:16
Show Gist options
  • Save moxdev/a8998de9f27845bf3cd6616fb29be94e to your computer and use it in GitHub Desktop.
Save moxdev/a8998de9f27845bf3cd6616fb29be94e to your computer and use it in GitHub Desktop.
Social media svg sprite for use with WordPress and advanced custom fields plugin options page
<?php if( function_exists( 'acf_add_options_page' ) ) :
$fb = get_field( 'facebook_url', 'social' );
$pin = get_field( 'pinterest_url', 'social' );
$tw = get_field( 'twitter_url', 'social' );
$inst = get_field( 'instagram_url', 'social' );
$yt = get_field( 'youtube_url', 'social' );
$goo = get_field( 'google_plus_url', 'social' );
$link = get_field( 'linkedin_url', 'social' );
if( $fb || $pin || $tw || $insta || $yt || $goo || $link ) : ?>
<ul class="social-media">
<? if ( $fb ): ?>
<li class="fb">
<a href="<?php echo wp_kses_post( $fb ); ?>" target="_blank">Find Us On Facebook</a>
</li>
<?php endif; ?>
<? if ( $link ): ?>
<li class="linked">
<a href="<?php echo wp_kses_post( $link ); ?>" target="_blank">Find Us On LinkedIn</a>
</li>
<?php endif; ?>
<? if ( $tw ): ?>
<li class="tw">
<a href="<?php echo wp_kses_post( $tw ); ?>" target="_blank">Follow Us On Twitter</a>
</li>
<?php endif; ?>
<? if ( $pin ): ?>
<li class="pin">
<a href="<?php echo wp_kses_post( $pin ); ?>" target="_blank">Find Us On Pinterest</a>
</li>
<?php endif; ?>
<? if ( $inst ): ?>
<li class="insta">
<a href="<?php echo wp_kses_post( $inst ); ?>" target="_blank">Find Us On Instagram</a>
</li>
<?php endif; ?>
<? if ( $yt ): ?>
<li class="yt">
<a href="<?php echo wp_kses_post( $yt ); ?>" target="_blank">Watch Us On YouTube</a>
</li>
<?php endif; ?>
<? if ( $goo ): ?>
<li class="goo">
<a href="<?php echo wp_kses_post( $goo ); ?>" target="_blank">Find Us On Google+</a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
.social-media {
list-style: none;
margin: 0 0 1.5em;
display: flex;
justify-content: center;
a {
display: block;
text-indent: 110%;
white-space: nowrap;
overflow: hidden;
width: 35px;
height: 35px;
background-image: url(imgs/sprite-social-media-icons.svg);
background-size: auto 100%;
background-repeat: no-repeat;
}
.fb {
a {
background-position: -4px 0;
width: 27px;
}
}
.tw {
a {
background-position: -34px 0;
}
}
.goo {
a {
background-position: -68px 0;
width: 40px;
}
}
.linked {
a {
background-position: -108px 0;
width: 30px;
}
}
.yt {
a {
background-position: -140px 0;
width: 40px;
}
}
.pin {
a {
width: 27px;
background-position: -179px 0;
}
}
.insta {
a {
background-position: -210px 0;
}
}
@include respond-to(large) {
a {
width: 50px;
height: 50px;
}
.fb {
a {
background-position: -10px 0;
width: 32px;
}
}
.tw {
a {
background-position: -50px 0;
}
}
.goo {
a {
background-position: -97px 0;
width: 55px;
}
}
.linked {
a {
background-position: -155px 0;
width: 40px;
}
}
.yt {
a {
background-position: -201px 0;
width: 49px;
}
}
.pin {
a {
width: 42px;
background-position: -255px 0;
}
}
.insta {
a {
background-position: -305px 0;
width: 40px;
}
}
}
}
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="350px" height="50px" viewBox="0 0 350 50" style="enable-background:new 0 0 350 50;" xml:space="preserve">
<style type="text/css">
.st0{fill:#3A3A3C;}
</style>
<g>
<path class="st0" d="M26.9,37.5V26h3.8l0.6-4.4h-4.4v-2.8c0-1.3,0.4-2.1,2.2-2.1h2.4v-4c-0.4-0.1-1.8-0.1-3.4-0.1
c-3.4,0-5.7,2.1-5.7,5.9v3.3h-3.8v4.4h3.8v11.4L26.9,37.5L26.9,37.5z"/>
</g>
<g>
<path class="st0" d="M59.8,34.7c0,0-0.2,0,1.1,0.9s4.8,2,8.3,2c11.6,0,17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-6.4,2.8-6.4,6.4s2.8,6.4,6.4,6.4s6.4-2.8,6.4-6.4S328.5,18.6,325,18.6z M325,29.2
c-2.3,0-4.2-1.9-4.2-4.2s1.9-4.2,4.2-4.2s4.2,1.9,4.2,4.2C329.1,27.3,327.3,29.2,325,29.2z"/>
<circle class="st0" cx="331.6" cy="18.3" r="1.5"/>
</g>
<g>
<path class="st0" d="M181.3,20.4c-2.5,0-4.2,1.4-4.9,2.7h-0.1v-2.3h-5v16.7h5.2v-8.3c0-2.2,0.4-4.3,3.1-4.3c2.7,0,2.7,2.5,2.7,4.4
v8.1h5.2v-9.2C187.5,23.8,186.6,20.4,181.3,20.4z"/>
<circle class="st0" cx="165.5" cy="15.5" r="3"/>
<rect x="162.9" y="20.8" class="st0" width="5.2" height="16.7"/>
</g>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment