Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Social Sharing with Javascript Pop-up
<?php
/**
* Social sharing links.
*/
function wds_client_get_social_share_links( ) {
$facebook_url = 'https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode ( get_the_permalink() );
$twitter_url = 'https://twitter.com/intent/tweet?text=?text=' . urlencode( html_entity_decode( get_the_title() ) ) . '&amp;url=' . rawurlencode ( get_the_permalink() );
$linkedin_url = 'https://www.linkedin.com/shareArticle?mini=true&amp;url=' . rawurlencode ( get_the_permalink() ) . '&amp;title=' . urlencode( html_entity_decode( get_the_title() ) );
$email_url = 'mailto:?subject=' . rawurlencode( 'Check this out!' ) . '&amp;body=' . rawurlencode( get_the_title() ) . rawurlencode( ': ' ) . rawurlencode ( get_the_permalink() );
$output = '';
$output .= '<ul class="social-sharing">';
$output .= ' <li class="facebook-item"><a href="' . esc_url( $facebook_url ) . '" onclick="window.open(this.href, \'targetWindow\', \'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, top=400, left=400, width=600, height=300\' ); return false;">' . wds_client_get_svg( 'facebook' ) . '<span class="screen-reader-text">' . __( 'Facebook', 'textdomain' ). '</span></a></li>';
$output .= ' <li class="twitter-item"><a href="' . esc_url( $twitter_url ) . '" onclick="window.open(this.href, \'targetWindow\', \'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, top=400, left=400, width=600, height=300\' ); return false;">' . wds_client_get_svg( 'twitter' ) . '<span class="screen-reader-text">' . __( 'Twitter', 'textdomain' ) . '</span></a></li>';
$output .= ' <li class="linkedin-item"><a href="' . esc_url( $linkedin_url ) . '" onclick="window.open(this.href, \'targetWindow\', \'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, top=400, left=400, width=600, height=300\' ); return false;">' . wds_client_get_svg( 'linkedin' ) . '<span class="screen-reader-text">' . __( 'LinkedIn', 'textdomain' ) . '</span></a></li>';
$output .= ' <li class="email-item"><a href="' . esc_url( $email_url ) . '">' . wds_client_get_svg( 'envelope' ) . '<span class="screen-reader-text">' . __( 'E-mail', 'textdomain' ) . '</span></a></li>';
$output .= '</ul>';
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.