function gllr_shortcode($attr) { global $gllr_options; extract(shortcode_atts(array('id' => '', 'display' => 'full', 'cat_id' => ''), $attr)); ob_start(); if (empty($gllr_options)) { $gllr_options = get_option('gllr_options'); } require_once ABSPATH . 'wp-admin/includes/plugin.php'; if (!empty($cat_id) && (is_plugin_active('gallery-categories/gallery-categories.php') || is_plugin_active('gallery-categories-pro/gallery-categories-pro.php'))) { global $first_query; $term = get_term($cat_id, 'gallery_categories'); if (!empty($term)) { $args = array('post_type' => 'gallery', 'post_status' => 'publish', 'posts_per_page' => -1, 'gallery_categories' => $term->slug); $first_query = new WP_Query($args); ?> <div class="gallery_box"> <ul> <?php global $post, $wpdb, $wp_query; if ($first_query->have_posts()) { while ($first_query->have_posts()) { $first_query->the_post(); $attachments = get_post_thumbnail_id($post->ID); if (empty($attachments)) { $images_id = get_post_meta($post->ID, '_gallery_images', true); $attachments = get_posts(array("showposts" => 1, "what_to_show" => "posts", "post_status" => "inherit", "post_type" => "attachment", "orderby" => $gllr_options['order_by'], "order" => $gllr_options['order'], "post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png", 'post__in' => explode(',', $images_id), 'meta_key' => '_gallery_order_' . $post->ID)); if (!empty($attachments[0])) { $first_attachment = $attachments[0]; $image_attributes = wp_get_attachment_image_src($first_attachment->ID, "album-thumb"); } else { $image_attributes = array(''); } } else { $image_attributes = wp_get_attachment_image_src($attachments, 'album-thumb'); } ?> <li> <a rel="bookmark" href="<?php echo get_permalink(); ?> " title="<?php the_title(); ?> "> <img width="<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> " height="<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> " style="width:<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> px; height:<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> px;" alt="<?php the_title(); ?> " title="<?php the_title(); ?> " src="<?php echo $image_attributes[0]; ?> " /> </a> <div class="gallery_detail_box"> <div><?php the_title(); ?> </div> <div><?php echo gllr_the_excerpt_max_charlength(100); ?> </div> <a href="<?php echo get_permalink($post->ID); ?> "><?php echo $gllr_options["read_more_link_text"]; ?> </a> </div><!-- .gallery_detail_box --> <div class="gllr_clear"></div> </li> <?php } } ?> </ul> </div><!-- .gallery_box --> <?php wp_reset_query(); } } else { $args = array('post_type' => 'gallery', 'post_status' => 'publish', 'p' => $id, 'posts_per_page' => 1); $second_query = new WP_Query($args); if ($display == 'short') { ?> <div class="gallery_box"> <ul> <?php global $post, $wpdb, $wp_query; if ($second_query->have_posts()) { $second_query->the_post(); $attachments = get_post_thumbnail_id($post->ID); if (empty($attachments)) { $images_id = get_post_meta($post->ID, '_gallery_images', true); $attachments = get_posts(array("showposts" => 1, "what_to_show" => "posts", "post_status" => "inherit", "post_type" => "attachment", "orderby" => $gllr_options['order_by'], "order" => $gllr_options['order'], "post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png", 'post__in' => explode(',', $images_id), 'meta_key' => '_gallery_order_' . $post->ID)); if (!empty($attachments[0])) { $first_attachment = $attachments[0]; $image_attributes = wp_get_attachment_image_src($first_attachment->ID, "album-thumb"); } else { $image_attributes = array(''); } } else { $image_attributes = wp_get_attachment_image_src($attachments, 'album-thumb'); } if (1 == $gllr_options['border_images']) { $gllr_border = 'border-width: ' . $gllr_options['border_images_width'] . 'px; border-color:' . $gllr_options['border_images_color'] . ';border: ' . $gllr_options['border_images_width'] . 'px solid ' . $gllr_options['border_images_color']; } else { $gllr_border = ''; } ?> <li> <a rel="bookmark" href="<?php echo get_permalink(); ?> " title="<?php the_title(); ?> "> <img width="<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> " height="<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> " style="width:<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> px; height:<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> px; <?php echo $gllr_border; ?> " alt="<?php the_title(); ?> " title="<?php the_title(); ?> " src="<?php echo $image_attributes[0]; ?> " /> </a> <div class="gallery_detail_box"> <div><?php the_title(); ?> </div> <div><?php echo gllr_the_excerpt_max_charlength(100); ?> </div> <a href="<?php echo get_permalink($post->ID); ?> "><?php echo $gllr_options["read_more_link_text"]; ?> </a> </div><!-- .gallery_detail_box --> <div class="gllr_clear"></div> </li> <?php } ?> </ul> </div><!-- .gallery_box --> <?php } else { if ($second_query->have_posts()) { while ($second_query->have_posts()) { global $post; $second_query->the_post(); ?> <div class="gallery_box_single"> <?php echo do_shortcode(get_the_content()); $images_id = get_post_meta($post->ID, '_gallery_images', true); $posts = get_posts(array("showposts" => -1, "what_to_show" => "posts", "post_status" => "inherit", "post_type" => "attachment", "orderby" => $gllr_options['order_by'], "order" => $gllr_options['order'], "post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png", 'post__in' => explode(',', $images_id), 'meta_key' => '_gallery_order_' . $post->ID)); if (0 < count($posts)) { $count_image_block = 0; ?> <div class="gallery clearfix"> <?php foreach ($posts as $attachment) { $key = "gllr_image_text"; $link_key = "gllr_link_url"; $alt_tag_key = "gllr_image_alt_tag"; $image_attributes = wp_get_attachment_image_src($attachment->ID, 'photo-thumb'); $image_attributes_large = wp_get_attachment_image_src($attachment->ID, 'large'); $image_attributes_full = wp_get_attachment_image_src($attachment->ID, 'full'); if (1 == $gllr_options['border_images']) { $gllr_border = 'border-width: ' . $gllr_options['border_images_width'] . 'px; border-color:' . $gllr_options['border_images_color'] . ';border: ' . $gllr_options['border_images_width'] . 'px solid ' . $gllr_options['border_images_color']; $gllr_border_images = $gllr_options['border_images_width'] * 2; } else { $gllr_border = ''; $gllr_border_images = 0; } if ($count_image_block % $gllr_options['custom_image_row_count'] == 0) { ?> <div class="gllr_image_row"> <?php } ?> <div class="gllr_image_block"> <p style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0] + $gllr_border_images; ?> px;height:<?php echo $gllr_options['gllr_custom_size_px'][1][1] + $gllr_border_images; ?> px;"> <?php if (($url_for_link = get_post_meta($attachment->ID, $link_key, true)) != "") { ?> <a href="<?php echo $url_for_link; ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> " target="_blank"> <img width="<?php echo $gllr_options['gllr_custom_size_px'][1][0]; ?> " height="<?php echo $gllr_options['gllr_custom_size_px'][1][1]; ?> " style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0]; ?> px; height:<?php echo $gllr_options['gllr_custom_size_px'][1][1]; ?> px; <?php echo $gllr_border; ?> " alt="<?php echo get_post_meta($attachment->ID, $alt_tag_key, true); ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> " src="<?php echo $image_attributes[0]; ?> " /> </a> <?php } else { ?> <a rel="gallery_fancybox<?php if (0 == $gllr_options['single_lightbox_for_multiple_galleries']) { echo '_' . $post->ID; } ?> " href="<?php echo $image_attributes_large[0]; ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> "> <img style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0]; ?> px;height:<?php echo $gllr_options['gllr_custom_size_px'][1][1]; ?> px; <?php echo $gllr_border; ?> " alt="<?php echo get_post_meta($attachment->ID, $alt_tag_key, true); ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> " src="<?php echo $image_attributes[0]; ?> " rel="<?php echo $image_attributes_full[0]; ?> " /> </a> <?php } ?> </p> <?php if (1 == $gllr_options["image_text"]) { ?> <div style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0] + $gllr_border_images; ?> px;" class="gllr_single_image_text"><?php echo get_post_meta($attachment->ID, $key, true); ?> </div> <?php } ?> </div><!-- .gllr_image_block --> <?php if ($count_image_block % $gllr_options['custom_image_row_count'] == $gllr_options['custom_image_row_count'] - 1) { ?> </div><!-- .gllr_image_row --> <?php } $count_image_block++; } if (0 < $count_image_block && $count_image_block % $gllr_options['custom_image_row_count'] != 0) { ?> </div><!-- .gllr_image_row --> <?php } ?> </div><!-- .gallery.clearfix --> <?php } ?> </div><!-- .gallery_box_single --> <div class="gllr_clear"></div> <?php } } else { ?> <div class="gallery_box_single"> <p class="not_found"><?php _e('Sorry, nothing found.', 'gallery-plugin'); ?> </p> </div><!-- .gallery_box_single --> <?php } if (1 == $gllr_options['return_link_shortcode']) { if ('gallery_template_url' == $gllr_options["return_link_page"]) { global $wpdb; $parent = $wpdb->get_var("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND (post_status = 'publish' OR post_status = 'private') AND {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id"); ?> <div class="return_link"><a href="<?php echo !empty($parent) ? get_permalink($parent) : ''; ?> "><?php echo $gllr_options['return_link_text']; ?> </a></div> <?php } else { ?> <div class="return_link"><a href="<?php echo $gllr_options["return_link_url"]; ?> "><?php echo $gllr_options['return_link_text']; ?> </a></div> <?php } } ?> <script type="text/javascript"> (function($) { $(document).ready( function() { $( "a[rel=gallery_fancybox<?php if (0 == $gllr_options['single_lightbox_for_multiple_galleries']) { echo '_' . $post->ID; } ?> ]" ).fancybox( { 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'titlePosition' : 'inside', 'speedIn' : 500, 'speedOut' : 300, 'titleFormat' : function( title, currentArray, currentIndex, currentOpts ) { return '<div id="fancybox-title-inside">' + ( title.length ? '<span id="bws_gallery_image_title">' + title + '</span><br />' : '' ) + '<span id="bws_gallery_image_counter"><?php _e("Image", "gallery-plugin"); ?> ' + ( currentIndex + 1 ) + ' / ' + currentArray.length + '</span></div><?php if (get_post_meta($post->ID, 'gllr_download_link', true) != '') { ?> <a id="bws_gallery_download_link" href="' + $( currentOpts.orig ).attr( 'rel' ) + '" target="_blank"><?php echo addslashes(__("Download high resolution image", "gallery-plugin")); ?> </a><?php } ?> '; }<?php if (1 == $gllr_options['start_slideshow']) { ?> , 'onComplete': function() { clearTimeout( jQuery.fancybox.slider ); jQuery.fancybox.slider = setTimeout( "jQuery.fancybox.next()",<?php echo $gllr_options['slideshow_interval']; ?> ); }<?php } ?> }); }); })(jQuery); </script> <?php } wp_reset_query(); } $gllr_output = ob_get_clean(); return $gllr_output; }
</a> </div> <div class="gallery-detail"> <h2><a href="<?php echo get_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if (function_exists('gllr_the_excerpt_max_charlength')) { if (gllr_the_excerpt_max_charlength(100) != '') { ?> <p><?php echo gllr_the_excerpt_max_charlength(100); ?> </p> <?php } } ?> <p><a href="<?php echo get_permalink(); ?> "><?php echo $gllr_options["read_more_link_text"]; ?> </a></p> </div><!-- .gallery_detail_box --> </li>
function x_get_gallery_photo_list($attr) { global $gllr_options; extract(shortcode_atts(array('id' => '', 'display' => 'full', 'cat_id' => ''), $attr)); ob_start(); if (empty($gllr_options)) { $gllr_options = get_option('gllr_options'); } require_once ABSPATH . 'wp-admin/includes/plugin.php'; if (!empty($cat_id) && (is_plugin_active('gallery-categories/gallery-categories.php') || is_plugin_active('gallery-categories-pro/gallery-categories-pro.php'))) { global $first_query; $term = get_term($cat_id, 'gallery_categories'); if (!empty($term)) { $args = array('post_type' => 'gallery', 'post_status' => 'publish', 'posts_per_page' => -1, 'gallery_categories' => $term->slug, 'orderby' => $gllr_options['album_order_by'], 'order' => $gllr_options['album_order']); $first_query = new WP_Query($args); ?> <div class="gallery_box"> <ul> <?php global $post, $wpdb, $wp_query; if ($first_query->have_posts()) { while ($first_query->have_posts()) { $first_query->the_post(); $attachments = get_post_thumbnail_id($post->ID); if (empty($attachments)) { $images_id = get_post_meta($post->ID, '_gallery_images', true); $attachments = get_posts(array("showposts" => 1, "what_to_show" => "posts", "post_status" => "inherit", "post_type" => "attachment", "orderby" => $gllr_options['order_by'], "order" => $gllr_options['order'], "post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png", 'post__in' => explode(',', $images_id), 'meta_key' => '_gallery_order_' . $post->ID)); if (!empty($attachments[0])) { $first_attachment = $attachments[0]; $image_attributes = wp_get_attachment_image_src($first_attachment->ID, "album-thumb"); } else { $image_attributes = array(''); } } else { $image_attributes = wp_get_attachment_image_src($attachments, 'album-thumb'); } ?> <!-- <li> <a rel="bookmark" href="<?php echo get_permalink(); ?> " title="<?php the_title(); ?> "> <img width="<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> " height="<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> " style="width:<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> px; height:<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> px;" alt="<?php the_title(); ?> " title="<?php the_title(); ?> " src="<?php echo $image_attributes[0]; ?> " /> </a> <div class="gallery_detail_box"> <div><?php the_title(); ?> </div> <div><?php echo gllr_the_excerpt_max_charlength(100); ?> </div> <a href="<?php echo get_permalink($post->ID); ?> "><?php echo $gllr_options["read_more_link_text"]; ?> </a> </div> <div class="gllr_clear"></div> </li> --> <?php } } ?> </ul> </div><!-- .gallery_box --> <?php wp_reset_query(); } } else { $args = array('post_type' => 'gallery', 'post_status' => 'publish', 'p' => $id, 'posts_per_page' => 1); $second_query = new WP_Query($args); if ($display == 'short') { ?> <div class="gallery_box"> <ul> <?php global $post, $wpdb, $wp_query; if ($second_query->have_posts()) { $second_query->the_post(); $attachments = get_post_thumbnail_id($post->ID); if (empty($attachments)) { $images_id = get_post_meta($post->ID, '_gallery_images', true); $attachments = get_posts(array("showposts" => 1, "what_to_show" => "posts", "post_status" => "inherit", "post_type" => "attachment", "orderby" => $gllr_options['order_by'], "order" => $gllr_options['order'], "post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png", 'post__in' => explode(',', $images_id), 'meta_key' => '_gallery_order_' . $post->ID)); if (!empty($attachments[0])) { $first_attachment = $attachments[0]; $image_attributes = wp_get_attachment_image_src($first_attachment->ID, "album-thumb"); } else { $image_attributes = array(''); } } else { $image_attributes = wp_get_attachment_image_src($attachments, 'album-thumb'); } if (1 == $gllr_options['border_images']) { $gllr_border = 'border-width: ' . $gllr_options['border_images_width'] . 'px; border-color:' . $gllr_options['border_images_color'] . ';border: ' . $gllr_options['border_images_width'] . 'px solid ' . $gllr_options['border_images_color']; } else { $gllr_border = ''; } ?> <!-- <li> <a rel="bookmark" href="<?php echo get_permalink(); ?> " title="<?php the_title(); ?> "> <img width="<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> " height="<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> " style="width:<?php echo $gllr_options['gllr_custom_size_px'][0][0]; ?> px; height:<?php echo $gllr_options['gllr_custom_size_px'][0][1]; ?> px; <?php echo $gllr_border; ?> " alt="<?php the_title(); ?> " title="<?php the_title(); ?> " src="<?php echo $image_attributes[0]; ?> " /> </a> <div class="gallery_detail_box"> <div><?php the_title(); ?> </div> <div><?php echo gllr_the_excerpt_max_charlength(100); ?> </div> <a href="<?php echo get_permalink($post->ID); ?> "><?php echo $gllr_options["read_more_link_text"]; ?> </a> </div> <div class="gllr_clear"></div> </li> --> <?php } ?> </ul> </div><!-- .gallery_box --> <?php } else { if ($second_query->have_posts()) { while ($second_query->have_posts()) { global $post; $second_query->the_post(); ?> <div class="swiper-container"> <?php echo do_shortcode(get_the_content()); $images_id = get_post_meta($post->ID, '_gallery_images', true); //get Gallery Item Cate global $gllrctgrs_taxonomy; $galleryCateArr = get_the_terms($post->ID, $gllrctgrs_taxonomy); if (count($galleryCateArr)) { $galleryCate = $galleryCateArr[0]; } $posts = get_posts(array("showposts" => -1, "what_to_show" => "posts", "post_status" => "inherit", "post_type" => "attachment", "orderby" => $gllr_options['order_by'], "order" => $gllr_options['order'], "post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png", 'post__in' => explode(',', $images_id), 'meta_key' => '_gallery_order_' . $post->ID)); if (0 < count($posts)) { $count_image_block = 0; ?> <div class="swiper-wrapper clearfix"> <?php foreach ($posts as $attachment) { $key = "gllr_image_text"; $link_key = "gllr_link_url"; $alt_tag_key = "gllr_image_alt_tag"; $image_attributes = wp_get_attachment_image_src($attachment->ID, 'photo-thumb'); $image_attributes_large = wp_get_attachment_image_src($attachment->ID, 'large'); $image_attributes_full = wp_get_attachment_image_src($attachment->ID, 'full'); if (1 == $gllr_options['border_images']) { $gllr_border = 'border-width: ' . $gllr_options['border_images_width'] . 'px; border-color:' . $gllr_options['border_images_color'] . ';border: ' . $gllr_options['border_images_width'] . 'px solid ' . $gllr_options['border_images_color']; $gllr_border_images = $gllr_options['border_images_width'] * 2; } else { $gllr_border = ''; $gllr_border_images = 0; } ?> <div class="swiper-slide post-item-swiper"> <?php if (($url_for_link = get_post_meta($attachment->ID, $link_key, true)) != "" && $galleryCate->name == 'Video') { ?> <a class="fancybox-photo-item fancybox-media video-item-wrapper" href="<?php echo $url_for_link; ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> "></a> <img class="gallery-photo-item" width="<?php echo $gllr_options['gllr_custom_size_px'][1][0]; ?> " height="<?php echo $gllr_options['gllr_custom_size_px'][1][1]; ?> " alt="<?php echo get_post_meta($attachment->ID, $alt_tag_key, true); ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> " src="<?php echo $image_attributes[0]; ?> " /> <?php } else { ?> <a class="fancybox-photo-item" rel="gallery_fancybox<?php if (0 == $gllr_options['single_lightbox_for_multiple_galleries']) { echo '_' . $post->ID; } ?> " href="<?php echo $image_attributes_large[0]; ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> "></a> <img class="gallery-photo-item" alt="<?php echo get_post_meta($attachment->ID, $alt_tag_key, true); ?> " title="<?php echo get_post_meta($attachment->ID, $key, true); ?> " src="<?php echo $image_attributes[0]; ?> " rel="<?php echo $image_attributes_full[0]; ?> " /> <?php } ?> <?php if (1 == $gllr_options["image_text"]) { ?> <div style="width:<?php echo $gllr_options['gllr_custom_size_px'][1][0] + $gllr_border_images; ?> px;" class="gllr_single_image_text"><?php echo get_post_meta($attachment->ID, $key, true); ?> </div> <?php } ?> </div><!-- .swiper-slide --> <?php $count_image_block++; } ?> </div><!-- .swiper-wrapper.clearfix --> <?php } ?> <div class="swiper-pagination"></div> </div><!-- .swiper-container --> <div class="gllr_clear"></div> <?php } } else { ?> <div class="swiper-container"> <p class="not_found"><?php _e('Sorry, nothing found.', 'gallery-plugin'); ?> </p> </div><!-- .swiper-container --> <?php } if (1 == $gllr_options['return_link_shortcode']) { if ('gallery_template_url' == $gllr_options["return_link_page"]) { global $wpdb; $parent = $wpdb->get_var("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND (post_status = 'publish' OR post_status = 'private') AND {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id"); ?> <div class="return_link"><a href="<?php echo !empty($parent) ? get_permalink($parent) : ''; ?> "><?php echo $gllr_options['return_link_text']; ?> </a></div> <?php } else { ?> <div class="return_link"><a href="<?php echo $gllr_options["return_link_url"]; ?> "><?php echo $gllr_options['return_link_text']; ?> </a></div> <?php } } ?> <?php } wp_reset_query(); } $gllr_output = ob_get_clean(); return $gllr_output; }