posts) { for($i=0;$iposts);$i++) { if ( preg_match('/\[gallery([^\]]+)?\]/', $wp_query->posts[$i]->post_content) ) { $flag = true; break; } } } if ( !is_admin() && $flag ) { if (@file_exists(TEMPLATEPATH.'/lightbox-gallery.css')) { echo ''."\n"; } else { echo ''."\n"; } echo ''."\n"; echo ''."\n"; } } function add_lightbox_gallery_jquery() { global $wp_query; $flag = false; if($wp_query->posts) { for($i=0;$iposts);$i++) { if ( preg_match('/\[gallery([^\]]+)?\]/', $wp_query->posts[$i]->post_content) ) { $flag = true; break; } } } if ( !is_admin() && $flag ) { wp_enqueue_script( 'jquery'); wp_enqueue_script('dimensions', '/wp-content/plugins/lightbox-gallery/js/jquery.dimensions.js', array('jquery')); wp_enqueue_script('bgtiframe', '/wp-content/plugins/lightbox-gallery/js/jquery.bgiframe.js', array('jquery')); wp_enqueue_script('lightbox', '/wp-content/plugins/lightbox-gallery/js/jquery.lightbox.js', array('jquery')); wp_enqueue_script('tooltip', '/wp-content/plugins/lightbox-gallery/js/jquery.tooltip.js', array('jquery')); wp_enqueue_script('lightbox-gallery', '/wp-content/plugins/lightbox-gallery/lightbox-gallery.js', array('jquery')); } } add_shortcode('gallery', 'lightbox_gallery'); function lightbox_gallery($attr) { global $post; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) unset( $attr['orderby'] ); } if ( !isset( $attr['orderby'] ) && get_bloginfo('version')<2.6 ) { $attr['orderby'] = 'menu_order ASC, ID ASC'; } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'lightboxsize' => 'medium', 'meta' => 'false', 'class' => 'gallery1', 'nofollow' => false ), $attr)); $id = intval($id); $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $id => $attachment ) $output .= wp_get_attachment_link($id, $size, true) . "\n"; return $output; } $listtag = tag_escape($listtag); $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $output = apply_filters('gallery_style', " '; return $output; } ?>