Skip to content

Instantly share code, notes, and snippets.

@kachi
Created February 7, 2014 01:52
Show Gist options
  • Save kachi/52d0982f950721b21c01 to your computer and use it in GitHub Desktop.
Save kachi/52d0982f950721b21c01 to your computer and use it in GitHub Desktop.
/// WPBeginner's YouTube Share Overlay Buttons
function add_share_buttons($atts) {
// ショーートコードでYoutubeのIDを取得
extract( shortcode_atts( array(
'video' => ''
), $atts ) );
// 動画を表示
$string = '<div id="video-container"><iframe src="//www.youtube.com/embed/' . $video . '" height="315" width="560" allowfullscreen="" frameborder="0"></iframe>';
// Facebookのシェアボタン
$string .= '<ul class="share-video-overlay" id="share-video-overlay"><li class="facebook" id="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fyoutube.com/watch%3Fv%3D'. $video .'" target="_blank">
Facebook</a></li>';
// Twitterのシェアボタン
$string .= '<li class="twitter" id="twitter"><a href="http://www.twitter.com/share?&text=Check+this+video&amp;url=http%3A//www.youtube.com/watch%3Fv%3D'. $video .'">Tweet</a></li></ul>';
$string .= '</div>';
return $string;
}
add_shortcode('foobar', 'add_share_buttons');
//[foobar video="Youtubeの動画ID"]というショートコードを書く
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment