| 1 |
<?php |
| 2 |
/* |
| 3 |
* @link http://themeforest.digitalkroy.com/gallery-box/ |
| 4 |
* @since 1.0.0 |
| 5 |
* @package Gallery box wordpress plugin |
| 6 |
* description All gallery output by this shortcode |
| 7 |
* |
| 8 |
* @ Gallery box |
| 9 |
*/ |
| 10 |
|
| 11 |
|
| 12 |
//All front display here |
| 13 |
if ( ! function_exists( 'galleryBox_shortcode' ) ) : |
| 14 |
function galleryBox_shortcode($atts, $content = null){ |
| 15 |
ob_start(); |
| 16 |
global $post; |
| 17 |
$gallery_box = shortcode_atts( array( |
| 18 |
'id'=> '', |
| 19 |
), $atts ); |
| 20 |
|
| 21 |
//Query args |
| 22 |
$args = array( |
| 23 |
'post_type' => 'gallery_box', |
| 24 |
'post_status' => 'publish', |
| 25 |
'posts_per_page' => 1, |
| 26 |
'p' => $gallery_box['id'] |
| 27 |
|
| 28 |
); |
| 29 |
//start WP_Query |
| 30 |
$loop= new WP_Query($args); |
| 31 |
$number=1; |
| 32 |
|
| 33 |
?> |
| 34 |
|
| 35 |
<?php if ($loop -> have_posts() ) : ?> |
| 36 |
<?php while ( $loop->have_posts()) : $loop->the_post(); |
| 37 |
$post_ID = $post->ID; |
| 38 |
//for typography option |
| 39 |
if(get_option('Lightbox_settings')){ |
| 40 |
$gbox_lightbox = get_option('Lightbox_settings'); |
| 41 |
} else { |
| 42 |
$gbox_lightbox = array(); |
| 43 |
} |
| 44 |
$gbox_use_typography = isset( $gbox_lightbox['use_typography'] ) ? $gbox_lightbox['use_typography'] : 'yes'; |
| 45 |
?> |
| 46 |
<div id="boxGallery" class="g-box<?php echo esc_attr($post_ID); ?> Gallery-container gallery-box <?php if($gbox_use_typography == 'yes'): ?>gbox-font<?php endif; ?>"> |
| 47 |
<!-- Regular images --> |
| 48 |
<?php |
| 49 |
//simple image gallery meta |
| 50 |
$gbox_simple_imgs = get_post_meta(get_the_ID(), 'simple_imgs', true); |
| 51 |
//advance image gallery meta |
| 52 |
$gbox_img_main = get_post_meta(get_the_ID(), 'img_main', true); |
| 53 |
$image_title = !empty( $gbox_img_main[0]['image_title']) ? $gbox_img_main[0]['image_title'] : ''; |
| 54 |
$image_small = !empty( $gbox_img_main[0]['image_small']) ? $gbox_img_main[0]['image_small'] : ''; |
| 55 |
//Portfolio gallery meta |
| 56 |
$gbox_portfo_main = get_post_meta(get_the_ID(), 'portfo_main', true); |
| 57 |
$portfolio_title = !empty( $gbox_portfo_main[0]['portfolio_title']) ? $gbox_portfo_main[0]['portfolio_title'] : ''; |
| 58 |
$port_img = !empty( $gbox_portfo_main[0]['port_img']) ? $gbox_portfo_main[0]['port_img'] : ''; |
| 59 |
|
| 60 |
|
| 61 |
//Youtube gallery meta |
| 62 |
$gbox_youtube_main = get_post_meta(get_the_ID(),'youtube_main', true); |
| 63 |
$you_url = !empty( $gbox_youtube_main[0]['you_url']) ? $gbox_youtube_main[0]['you_url'] : ''; |
| 64 |
|
| 65 |
|
| 66 |
//Vimeo gallery meta |
| 67 |
$gbox_vimeo_main = get_post_meta(get_the_ID(), 'vimeo_main', true); |
| 68 |
$vimeo_url = !empty( $gbox_vimeo_main[0]['vimeo_url']) ? $gbox_vimeo_main[0]['vimeo_url'] : ''; |
| 69 |
|
| 70 |
//Soundcloud gallery meta |
| 71 |
$gbox_Soundcloud_main = get_post_meta(get_the_ID(), 'Soundcloud_main', true); |
| 72 |
$sound_id = !empty( $gbox_Soundcloud_main[0]['sound_id']) ? $gbox_Soundcloud_main[0]['sound_id'] : ''; |
| 73 |
|
| 74 |
//Iframe gallery meta |
| 75 |
$gbox_iframe_main = get_post_meta(get_the_ID(), 'iframe_main', true); |
| 76 |
$iframe_url = !empty( $gbox_iframe_main[0]['iframe_url']) ? $gbox_iframe_main[0]['iframe_url'] : ''; |
| 77 |
|
| 78 |
|
| 79 |
if(!empty($gbox_simple_imgs)){ |
| 80 |
// Simple image gallery |
| 81 |
do_action( 'gallery_box_simple_image', get_the_ID() ); |
| 82 |
} |
| 83 |
|
| 84 |
if( !empty($image_title) || !empty($image_small) ){ |
| 85 |
// Advance image gallery |
| 86 |
do_action( 'gallery_box_image', get_the_ID() ); |
| 87 |
|
| 88 |
} |
| 89 |
if( !empty($portfolio_title) || !empty($port_img) ){ |
| 90 |
// portfolio gallery |
| 91 |
do_action( 'gallery_box_portfolio', get_the_ID() ); |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
if(!empty($you_url)){ |
| 96 |
//youtube gallery |
| 97 |
do_action( 'gallery_box_youtube', get_the_ID() ); |
| 98 |
} |
| 99 |
|
| 100 |
if(!empty($vimeo_url)){ |
| 101 |
//vimeo gallery |
| 102 |
do_action( 'gallery_box_vimeo', get_the_ID() ); |
| 103 |
} |
| 104 |
|
| 105 |
if(!empty($sound_id)){ |
| 106 |
//Soundcloud gallery |
| 107 |
esc_html_e( 'Soundcloud Gallery No longer Available!!','gallery-box' ); |
| 108 |
} |
| 109 |
|
| 110 |
if(!empty($iframe_url)){ |
| 111 |
//iframe gallery |
| 112 |
do_action( 'gallery_box_iframe', get_the_ID() ); |
| 113 |
} |
| 114 |
?> |
| 115 |
|
| 116 |
</div> |
| 117 |
<?php endwhile; ?> |
| 118 |
|
| 119 |
<?php wp_reset_postdata(); ?> |
| 120 |
<?php else: ?> |
| 121 |
<div class="gbox-error"> |
| 122 |
<?php esc_html_e('No gallery item found!','gallery-box'); ?> |
| 123 |
</div> |
| 124 |
<?php endif; ?> |
| 125 |
|
| 126 |
<?php |
| 127 |
$galleryBox = ob_get_clean(); |
| 128 |
return $galleryBox; |
| 129 |
} |
| 130 |
add_shortcode('GalleryBox','galleryBox_shortcode'); |
| 131 |
add_shortcode('gallerybox','galleryBox_shortcode'); |
| 132 |
endif; |
| 133 |
|