function enjoyinstagram_mb_shortcode_grid()
{
    $shortcode_content = '';
    static $i = 1;
    if (get_option('enjoyinstagram_client_id') || get_option('enjoyinstagram_client_id') != '') {
        $instagram = new Enjoy_Instagram(get_option('enjoyinstagram_client_id'));
        $instagram->setAccessToken(get_option('enjoyinstagram_access_token'));
        if (get_option('enjoyinstagram_user_or_hashtag') == 'hashtag') {
            $result = $instagram->getTagMedia(urlencode(get_option('enjoyinstagram_hashtag')));
        } else {
            $result = $instagram->getUserMedia(urlencode(get_option('enjoyinstagram_user_id')));
        }
        $pre_shortcode_content = "<div id=\"grid-" . $i . "\" class=\"ri-grid ri-grid-size-2 ri-shadow\" style=\"display:none;\"><ul>";
        if (isHttps()) {
            foreach ($result->data as $entry) {
                $entry->images->thumbnail->url = str_replace('http://', 'https://', $entry->images->thumbnail->url);
                $entry->images->standard_resolution->url = str_replace('http://', 'https://', $entry->images->standard_resolution->url);
            }
        }
        foreach ($result->data as $entry) {
            if (!empty($entry->caption)) {
                $caption = $entry->caption->text;
            } else {
                $caption = '';
            }
            if (!empty($entry->user)) {
                $user = $entry->user->username;
                $userPicture = $entry->user->profile_picture;
            } else {
                $user = '';
                $userPicture = '';
            }
            $shortcode_content .= "<li><div class=\"header_ca\"><img  src=\"{$userPicture}\" style=\"width:30px; margin-right: 10px; border-radius: 50%;\">{$user}</div><img  src=\"{$entry->images->standard_resolution->url}\"><div class=\"caption_ca\">{$caption}</div></li>";
        }
        $post_shortcode_content = "</ul></div>";
        ?>
<script type="text/javascript">
			jQuery(function() {
				jQuery('#grid-<?php 
        echo $i;
        ?>
').fadeIn('1000');
			});
		</script>
<?php 
    }
    $i++;
    $shortcode_content = $pre_shortcode_content . $shortcode_content . $post_shortcode_content;
    return $shortcode_content;
}
function enjoyinstagram_mb_shortcode_widget($atts)
{
    if (get_option('enjoyinstagram_client_id') || get_option('enjoyinstagram_client_id') != '') {
        extract(shortcode_atts(array('n' => '4', 'id' => 'owl', 'n_y_n' => 'false', 'u_or_h' => 'user'), $atts));
        ?>
		<script>
			jQuery(function () {
				jQuery(document.body)
					.on('click touchend', '#swipebox-slider .current img', function (e) {
						jQuery('#swipebox-next').click();
						return false;
					})
					.on('click touchend', '#swipebox-slider .current', function (e) {
						jQuery('#swipebox-close').trigger('click');
					});
			});
		</script>
		<script type="text/javascript">
			jQuery(function ($) {
				$(".swipebox").swipebox({
					hideBarsDelay: 0
				});

			});
			jQuery(document).ready(function () {
				jQuery("#owl-<?php 
        echo "{$id}";
        ?>
").owlCarousel({
					items: <?php 
        echo "{$n}";
        ?>
,
					navigation: <?php 
        echo "{$n_y_n}";
        ?>
,
				});
				jQuery("#owl-<?php 
        echo "{$id}";
        ?>
").fadeIn('slow');
			});
		</script>
		<?php 
        $instagram = new Enjoy_Instagram(get_option('enjoyinstagram_client_id'));
        $instagram->setAccessToken(get_option('enjoyinstagram_access_token'));
        if ("{$u_or_h}" == 'hashtag') {
            $result = $instagram->getTagMedia(urlencode(get_option('enjoyinstagram_hashtag')));
        } else {
            $result = $instagram->getUserMedia(urlencode(get_option('enjoyinstagram_user_id')));
        }
        if (isHttps()) {
            foreach ($result->data as $entry) {
                $entry->images->thumbnail->url = str_replace('http://', 'https://', $entry->images->thumbnail->url);
                $entry->images->standard_resolution->url = str_replace('http://', 'https://', $entry->images->standard_resolution->url);
            }
        }
        ?>
		<div id="owl-<?php 
        echo "{$id}";
        ?>
" class="owl-example">
			<?php 
        if ($result->data) {
            foreach ($result->data as $entry) {
                if (!empty($entry->caption)) {
                    $caption = $entry->caption->text;
                } else {
                    $caption = '';
                }
                if (get_option('enjoyinstagram_carousel_items_number') != '1') {
                    echo "<div class=\"box\"><a title=\"{$caption}\" rel=\"gallery_swypebox\" class=\"swipebox\" href=\"{$entry->images->standard_resolution->url}\"><img  src=\"{$entry->images->thumbnail->url}\"></a></div>";
                } else {
                    echo "<div class=\"box\"><a title=\"{$entry->caption->text}\" rel=\"gallery_swypebox\" class=\"swipebox\" href=\"{$entry->images->standard_resolution->url}\"><img style=\"width:100%;\" src=\"{$entry->images->standard_resolution->url}\"></a></div>";
                }
            }
        }
        ?>
		</div>
	<?php 
    }
}
function enjoyinstagram_mb_shortcode($atts)
{
    $shortcode_content = '';
    static $i = 1;
    if (get_option('enjoyinstagram_client_id') || get_option('enjoyinstagram_client_id') != '') {
        extract(shortcode_atts(array('n' => '4'), $atts));
        ?>
<script>
    jQuery(function(){
      jQuery(document.body)
          .on('click touchend','#swipebox-slider .current img', function(e){
              jQuery('#swipebox-next').click();
			  return false;
          })
          .on('click touchend','#swipebox-slider .current', function(e){
              jQuery('#swipebox-close').trigger('click');
          });
    });
</script>
<script type="text/javascript">
jQuery(function($) {
	$(".swipebox").swipebox({
	hideBarsDelay : 0
	});
	
});   
jQuery(document).ready(function() {
jQuery("#owl-<?php 
        echo $i;
        ?>
").owlCarousel({
	  lazyLoad : true,
	  items : <?php 
        echo get_option('enjoyinstagram_carousel_items_number');
        ?>
,
	  itemsDesktop : [1199,<?php 
        echo get_option('enjoyinstagram_carousel_items_number');
        ?>
],
   	  itemsDesktopSmall : [980,<?php 
        echo get_option('enjoyinstagram_carousel_items_number');
        ?>
],
      itemsTablet: [768,<?php 
        echo get_option('enjoyinstagram_carousel_items_number');
        ?>
],
      itemsMobile : [479,<?php 
        echo get_option('enjoyinstagram_carousel_items_number');
        ?>
],
	  stopOnHover: true,
	  navigation: <?php 
        echo get_option('enjoyinstagram_carousel_navigation');
        ?>
	  
		 });
		 jQuery("#owl-<?php 
        echo $i;
        ?>
").fadeIn();
		 });
</script>
<?php 
        $instagram = new Enjoy_Instagram(get_option('enjoyinstagram_client_id'));
        $instagram->setAccessToken(get_option('enjoyinstagram_access_token'));
        if (get_option('enjoyinstagram_user_or_hashtag') == 'hashtag') {
            $result = $instagram->getTagMedia(urlencode(get_option('enjoyinstagram_hashtag')));
        } else {
            $result = $instagram->getUserMedia(urlencode(get_option('enjoyinstagram_user_id')));
        }
        $pre_shortcode_content = "<div id=\"owl-" . $i . "\" class=\"owl-example\" style=\"display:none;\">";
        if (isHttps()) {
            foreach ($result->data as $entry) {
                $entry->images->thumbnail->url = str_replace('http://', 'https://', $entry->images->thumbnail->url);
                $entry->images->standard_resolution->url = str_replace('http://', 'https://', $entry->images->standard_resolution->url);
            }
        }
        foreach ($result->data as $entry) {
            if (!empty($entry->caption)) {
                $caption = $entry->caption->text;
            } else {
                $caption = '';
            }
            if (get_option('enjoyinstagram_carousel_items_number') != '1') {
                $shortcode_content .= "<div class=\"box\"><a title=\"{$caption}\" rel=\"gallery_swypebox\" class=\"swipebox\" href=\"{$entry->images->standard_resolution->url}\"><img  src=\"{$entry->images->standard_resolution->url}\"></a></div>";
            } else {
                $shortcode_content .= "<div class=\"box\"><a title=\"{$entry->caption->text}\" rel=\"gallery_swypebox\" class=\"swipebox\" href=\"{$entry->images->standard_resolution->url}\"><img style=\"width:100%;\" src=\"{$entry->images->standard_resolution->url}\"></a></div>";
            }
        }
        $post_shortcode_content = "</div>";
    }
    $i++;
    $shortcode_content = $pre_shortcode_content . $shortcode_content . $post_shortcode_content;
    return $shortcode_content;
}
function enjoyinstagram_mb_shortcode_grid()
{
    $shortcode_content = '';
    static $i = 1;
    if (get_option('enjoyinstagram_client_id') || get_option('enjoyinstagram_client_id') != '') {
        $instagram = new Enjoy_Instagram(get_option('enjoyinstagram_client_id'));
        $instagram->setAccessToken(get_option('enjoyinstagram_access_token'));
        if (get_option('enjoyinstagram_user_or_hashtag') == 'hashtag') {
            $result = $instagram->getTagMedia(urlencode(get_option('enjoyinstagram_hashtag')));
        } else {
            $result = $instagram->getUserMedia(urlencode(get_option('enjoyinstagram_user_id')));
        }
        $pre_shortcode_content = "<div id=\"grid-" . $i . "\" class=\"ri-grid ri-grid-size-2 ri-shadow\" style=\"display:none;\"><ul>";
        if (isHttps()) {
            foreach ($result->data as $entry) {
                $entry->images->thumbnail->url = str_replace('http://', 'https://', $entry->images->thumbnail->url);
                $entry->images->standard_resolution->url = str_replace('http://', 'https://', $entry->images->standard_resolution->url);
            }
        }
        foreach ($result->data as $entry) {
            if (!empty($entry->caption)) {
                $caption = $entry->caption->text;
            } else {
                $caption = '';
            }
            $shortcode_content .= "<li><a title=\"{$caption}\" class=\"swipebox_grid\" href=\"{$entry->images->standard_resolution->url}\"><img  src=\"{$entry->images->standard_resolution->url}\"></a></li>";
        }
        $post_shortcode_content = "</ul></div>";
        ?>

    

<script type="text/javascript">	
    
			jQuery(function() {
				jQuery('#grid-<?php 
        echo $i;
        ?>
').gridrotator({
					rows		: <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
					columns		: <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
,
					animType	: 'fadeInOut',
					onhover : false,
					interval		: 7000,
					preventClick    : false,
					w1400           : {
    rows    : <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
    columns : <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
},
					w1024           : {
    rows    : <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
    columns : <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
},
 
w768            : {
    rows    : <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
    columns : <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
},
 
w480            : {
    rows    : <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
    columns : <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
},
 
w320            : {
    rows    : <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
    columns : <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
},
 
w240            : {
    rows    : <?php 
        echo get_option('enjoyinstagram_grid_rows');
        ?>
,
    columns : <?php 
        echo get_option('enjoyinstagram_grid_cols');
        ?>
}
				});
				
			jQuery('#grid-<?php 
        echo $i;
        ?>
').fadeIn('1000');
			
			
			});
			
		</script>
<?php 
    }
    $i++;
    $shortcode_content = $pre_shortcode_content . $shortcode_content . $post_shortcode_content;
    return $shortcode_content;
}
function enjoyinstagram_mb_shortcode_grid_widget($atts)
{
    if (get_option('enjoyinstagram_client_id') || get_option('enjoyinstagram_client_id') != '') {
        extract(shortcode_atts(array('id' => 'rigrid_default', 'n_c' => '6', 'n_r' => '2', 'u_or_h' => 'user'), $atts));
        $instagram = new Enjoy_Instagram(get_option('enjoyinstagram_client_id'));
        $instagram->setAccessToken(get_option('enjoyinstagram_access_token'));
        if ("{$u_or_h}" == 'hashtag') {
            $result = $instagram->getTagMedia(urlencode(get_option('enjoyinstagram_hashtag')));
        } else {
            $result = $instagram->getUserMedia(urlencode(get_option('enjoyinstagram_user_id')));
        }
        ?>

	<?php 
        if (isHttps()) {
            foreach ($result->data as $entry) {
                $entry->images->thumbnail->url = str_replace('http://', 'https://', $entry->images->thumbnail->url);
                $entry->images->standard_resolution->url = str_replace('http://', 'https://', $entry->images->standard_resolution->url);
            }
        }
        ?>


<div id="rigrid-<?php 
        echo "{$id}";
        ?>
" class="ri-grid ri-grid-size-2 ri-shadow" style="display:none">
    <ul>
<?php 
        if ($result->data) {
            foreach ($result->data as $entry) {
                echo "<li><a title=\"{$entry->caption->text}\" class=\"swipebox_grid\" href=\"{$entry->images->standard_resolution->url}\"><img  src=\"{$entry->images->standard_resolution->url}\"></a></li>";
            }
        }
        ?>
    </ul></div>

<script type="text/javascript">	
    

			jQuery(function() {
			
				jQuery('#rigrid-<?php 
        echo "{$id}";
        ?>
').gridrotator({
					rows		: <?php 
        echo "{$n_r}";
        ?>
,
					columns		: <?php 
        echo "{$n_c}";
        ?>
,
					animType	: 'fadeInOut',
					onhover : false,
					interval		: 7000,
					preventClick    : false,
					w1024           : {
    rows    : <?php 
        echo "{$n_r}";
        ?>
,
    columns : <?php 
        echo "{$n_c}";
        ?>
},
 
w768            : {
    rows    : <?php 
        echo "{$n_r}";
        ?>
,
    columns : <?php 
        echo "{$n_c}";
        ?>
},
 
w480            : {
    rows    : <?php 
        echo "{$n_r}";
        ?>
,
    columns : <?php 
        echo "{$n_c}";
        ?>
},
 
w320            : {
    rows    : <?php 
        echo "{$n_r}";
        ?>
,
    columns : <?php 
        echo "{$n_c}";
        ?>
},
 
w240            : {
    rows    : <?php 
        echo "{$n_r}";
        ?>
,
    columns : <?php 
        echo "{$n_c}";
        ?>
}
				});
				jQuery('#rigrid-<?php 
        echo "{$id}";
        ?>
').fadeIn('slow');
			});

			
		</script>
<?php 
    }
    ?>

   
<?php 
}