'; echo ''; echo $connectflash; echo ''; echo ''; } function print_alwp_styles () { $content .= ''."\n"; if (file_exists(get_stylesheet_directory().'/alwp.css')) { $content .= ''."\n"; } echo $content; } function print_alwp_scripts () { wp_enqueue_script('alwp', WP_PLUGIN_URL . '/al-gallery/alwp.js', array('jquery')); } function yas_gallery ($atts, $content = null) { global $post; global $alwp_thumb_width; global $alwp_thumb_height; global $alwp_spacing; extract( shortcode_atts( array( 'post_id' => '', 'box_width' => '600', 'box_height' => '770', 'title' => 'Gallery', 'thumbnail' => false, 'thumb_class' => 'alignright', ), $atts ) ); $post_id = $post -> ID; $args = array( 'post_type' => 'attachment', 'numberposts' => -1, // bring them all 'exclude' => get_post_thumbnail_id( $post_id ), /* exclude the featured image */ 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => null, 'post_parent' => $post_id /* post id with the gallery */ ); $slides = get_posts($args); $total_slides = count($slides); $strip_width = ($alwp_thumb_width + ($alwp_spacing * 2)) * $total_slides; /* get the full size img src */ $main_img = wp_get_attachment_image_src($slides[0]->ID, 'alwp_full'); $full_img = wp_get_attachment_image_src($slides[0]->ID, 'full'); $main_img_url = $main_img[0]; $full_img_url = $full_img[0]; $main_slide_caption = $slides[0] -> post_excerpt; /* Image caption */ $main_slide_alt = $slides[0] -> post_content; /* Image description */ $gallery = "\n\n
"; $gallery .= "
\n\"$main_slide_alt\"\n"; $gallery .= "
"; $gallery .= "

$main_slide_caption

\n"; $gallery .= "
"; $gallery .= "

\"previous\"

"; $gallery .= "
"; $gallery .= "
    "; $is_first = true; foreach ($slides as $slide) { $thumbnailObj = wp_get_attachment_image_src($slide->ID, 'alwp_thumb'); $thumbnailURL = $thumbnailObj[0]; $thumb_css_class = ($is_first)?'current':'reg'; $slide_title = $slide -> post_excerpt; $slide_alt = $slide -> post_content; $slideObj = wp_get_attachment_image_src($slide->ID, 'alwp_full'); $slideURL = $slideObj[0]; $fullObj = wp_get_attachment_image_src($slide->ID, 'full'); $fullURL = $fullObj[0]; $gallery .= '
  • '.$slide_alt.'
  • '.PHP_EOL; $is_first = false; } $gallery .= "
\n"; $gallery .= "
\n"; $css_visibility = (count($slides) > 10)?'visible':'hidden'; $gallery .= "

\"next\"

"; $gallery .= "
\n"; $gallery .= "
\n"; return $gallery; } if (!is_admin()) { add_action('wp_print_scripts', 'print_alwp_scripts'); add_action('wp_head', 'print_alwp_styles'); remove_shortcode('gallery'); add_shortcode('gallery', 'yas_gallery'); } add_image_size( 'alwp_thumb', $alwp_thumb_width, $alwp_thumb_height, true ); add_image_size( 'alwp_full', $alwp_full_width, $alwp_full_height, false ); ?>