Skip to content

Instantly share code, notes, and snippets.

@WenLiangTseng
Created July 22, 2013 06:07
Show Gist options
  • Save WenLiangTseng/6051617 to your computer and use it in GitHub Desktop.
Save WenLiangTseng/6051617 to your computer and use it in GitHub Desktop.
使用WP內建的ThickBox
//加入 functions.php
function add_themescript(){
if(!is_admin()){
wp_enqueue_script('jquery');
wp_enqueue_script('thickbox',null,array('jquery'));
wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0');
}
}
add_action('init','add_themescript');
//加在 footer.php,放在 wp_footer() 之前
<script type="text/javascript">
if ( typeof tb_pathToImage != 'string' )
{
var tb_pathToImage = "<?php echo get_bloginfo('url').'/wp-includes/js/thickbox'; ?>/loadingAnimation.gif";
}
if ( typeof tb_closeImage != 'string' )
{
var tb_closeImage = "<?php echo get_bloginfo('url').'/wp-includes/js/thickbox'; ?>/tb-close.png";
}
</script>
//and how to use thickbox you can see the
<a href="http://jquery.com/demo/thickbox/"> thickbox page</a> in jquery site .
//Example: To show feedbernuer subscription link in popup windows
<a href="http://feedburner.google.com/fb/a/mailverify?uri=manchumahara&amp;loc=en_US&amp;KeepThis=true&amp;height=450&amp;width=600&amp;TB_iframe=true" class="thickbox">Subscribe to my blog via Email</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment