Created
March 1, 2017 17:48
-
-
Save kellenmace/cd948f2b9f83625e09518c531d272d1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build social sharing icons. | |
* | |
* @return string | |
*/ | |
function wds_eight_display_social_share() { | |
// Build the sharing URLs. | |
$twitter_url = 'https://twitter.com/share?text=' . rawurlencode( html_entity_decode( get_the_title() ) ) . '&url=' . rawurlencode( get_the_permalink() ); | |
$facebook_url = 'https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode( get_the_permalink() ); | |
$linkedin_url = 'https://www.linkedin.com/shareArticle?title=' . rawurlencode( html_entity_decode( get_the_title() ) ) . '&url=' . rawurlencode( get_the_permalink() ); | |
// Output markup. | |
?> | |
<div class="social-share"> | |
<h5 class="social-share-title"><?php esc_html_e( 'Share this:', 'wds' ); ?></h5> | |
<ul class="social-icons menu menu-horizontal"> | |
<li class="social-icon"> | |
<a href="<?php echo esc_url( $twitter_url ); ?>" onclick="window.open(this.href, 'targetWindow', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, top=150, left=0, width=600, height=300' ); return false;"> | |
<?php echo wds_eight_get_svg( array( 'icon' => 'twitter-square', 'title' => 'Twitter', 'desc' => __( 'Share on Twitter', 'wds' ) ) ); // WPCS: XSS ok. ?> | |
<span class="screen-reader-text"><?php esc_html_e( 'Share on Twitter', 'wds' ); ?></span> | |
</a> | |
</li> | |
<li class="social-icon"> | |
<a href="<?php echo esc_url( $facebook_url ); ?>" onclick="window.open(this.href, 'targetWindow', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, top=150, left=0, width=600, height=300' ); return false;"> | |
<?php echo wds_eight_get_svg( array( 'icon' => 'facebook-square', 'title' => 'Facebook', 'desc' => __( 'Share on Facebook', 'wds' ) ) ); // WPCS: XSS ok. ?> | |
<span class="screen-reader-text"><?php esc_html_e( 'Share on Facebook', 'wds' ); ?></span> | |
</a> | |
</li> | |
<li class="social-icon"> | |
<a href="<?php echo esc_url( $linkedin_url ); ?>" onclick="window.open(this.href, 'targetWindow', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, top=150, left=0, width=475, height=505' ); return false;"> | |
<?php echo wds_eight_get_svg( array( 'icon' => 'linkedin-square', 'title' => 'LinkedIn', 'desc' => __( 'Share on LinkedIn', 'wds' ) ) ); // WPCS: XSS ok. ?> | |
<span class="screen-reader-text"><?php esc_html_e( 'Share on LinkedIn', 'wds' ); ?></span> | |
</a> | |
</li> | |
</ul> | |
</div><!-- .social-share --> | |
<?php | |
} | |
/** | |
* Get the social share markup | |
* | |
* @return string The markup. | |
*/ | |
function wds_eight_get_social_share_markup() { | |
ob_start(); | |
wds_eight_display_social_share(); | |
return ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment