예제 #1
0
        return 'bsaOrderActive';
    } else {
        return null;
    }
}
$model = new BSA_PRO_Model();
$get_spaces = $model->getSpaces('both');
$first_space = $get_spaces[0]['id'];
if (isset($_GET['space_id']) && $_GET['space_id'] != NULL && $_GET['space_id'] != '') {
    $space_id = $_GET['space_id'];
} elseif ($get_spaces != NULL) {
    $space_id = $first_space;
} else {
    $space_id = 0;
}
$getActiveAds = $model->getActiveAds($space_id, bsa_space($space_id, 'max_items'), 'admin');
$getPendingAds = $model->getPendingAds('pending_ads', $space_id);
$getNotPaidAds = $model->getNotPaidAds($space_id);
$getBlockedAds = $model->getBlockedAds($space_id);
$getArchiveAds = $model->getArchiveAds($space_id);
?>

<div class="bsaSortableNotice" style="display:none">
	Changes has been saved.
</div>

<h2>
	<span class="dashicons dashicons-welcome-widgets-menus"></span> Manage Ad Spaces and Ads
</h2>

<?php 
예제 #2
0
function bsa_pro_ad_space($space_id = null, $max_width = null, $delay = null, $padding_top = null, $attachment = null, $crop = null, $hide_for_id = null, $if_empty = null)
{
    if ($space_id == null) {
        echo "<strong>ADS Error</strong> Missing <strong>id</strong> parameter!";
        return '';
    } else {
        $show_in_country = bsa_space($space_id, 'show_in_country');
        $hide_in_country = bsa_space($space_id, 'hide_in_country');
        $show_in_advanced = bsa_space($space_id, 'show_in_advanced');
        $hide_in_advanced = bsa_space($space_id, 'hide_in_advanced');
        if (get_option('bsa_pro_plugin_' . 'hide_if_logged') != 'yes' && is_user_logged_in() && in_array(get_the_ID(), explode(',', $hide_for_id), false) !== true && bsa_pro_verify_geo('show', $show_in_country) && bsa_pro_verify_geo('hide', $hide_in_country) && bsa_pro_verify_geo('show_advanced', $show_in_advanced) && bsa_pro_verify_geo('hide_advanced', $hide_in_advanced) && bsa_pro_verify_device($space_id) || !is_user_logged_in() && in_array(get_the_ID(), explode(',', $hide_for_id), false) !== true && bsa_pro_verify_geo('show', $show_in_country) && bsa_pro_verify_geo('hide', $hide_in_country) && bsa_pro_verify_geo('show_advanced', $show_in_advanced) && bsa_pro_verify_geo('hide_advanced', $hide_in_advanced) && bsa_pro_verify_device($space_id)) {
            // Rand Space ID
            $space_ids = explode(',', $space_id);
            $space_rand_id = array_rand($space_ids, 1);
            $space_id = $space_ids[$space_rand_id];
            // if in category or has tag
            if (bsa_space($space_id, 'id') && bsa_space($space_id, 'in_categories') != '' && bsa_space($space_id, 'in_categories') != null || bsa_space($space_id, 'id') && bsa_space($space_id, 'has_tags') != '' && bsa_space($space_id, 'has_tags') != null) {
                $get_categories = bsa_space($space_id, 'in_categories');
                $get_tags = bsa_space($space_id, 'has_tags');
                $exp_categories = explode(',', $get_categories);
                $exp_tags = explode(',', $get_tags);
                $taxonomy_cat = 'empty';
                $taxonomy_tag = 'empty';
                if (is_array($exp_categories)) {
                    foreach ($exp_categories as $category) {
                        if (in_category($category)) {
                            $taxonomy_cat = 'isset';
                            break;
                        }
                    }
                }
                if (is_array($exp_tags)) {
                    foreach ($exp_tags as $tag) {
                        if (has_tag($tag)) {
                            $taxonomy_tag = 'isset';
                            break;
                        }
                    }
                }
                if ($get_categories == '' && $get_categories == null && $get_tags == '' && $get_tags == null || $get_categories == '' && $get_categories == null && $taxonomy_tag == 'isset' || $taxonomy_cat == 'isset' && $get_tags == '' && $get_tags == null || $taxonomy_cat == 'isset' && $taxonomy_tag == 'isset') {
                    $taxonomy = 'isset';
                } else {
                    $taxonomy = 'empty';
                }
            } else {
                $taxonomy = 'none';
            }
            if (bsa_space($space_id, 'id') && bsa_space($space_id, 'status') == 'active' && $taxonomy == 'isset' || bsa_space($space_id, 'id') && bsa_space($space_id, 'status') == 'active' && $taxonomy == 'none') {
                if (glob(plugin_dir_path(__FILE__) . "../frontend/template/" . bsa_space($space_id, 'template') . ".php") == null) {
                    $styleName = 'default';
                } else {
                    $styleName = bsa_space($space_id, 'template');
                }
                $sid = $space_id;
                $model = new BSA_PRO_Model();
                $ads = $model->getActiveAds($sid, bsa_space($sid, 'max_items'), null, '0' . bsaGetCappedAds($sid));
                $type = bsa_space($sid, 'site_id') != NULL ? 'agency' : null;
                $crop = $crop == 'no' ? 'no' : null;
                if (defined('W3TC') && !isset($if_empty)) {
                    // w3 total cache
                    if (!defined('W3TC_DYNAMIC_SECURITY')) {
                        define('W3TC_DYNAMIC_SECURITY', md5(rand(0, 99999)));
                    }
                    echo "<!--mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->";
                    $ads = $model->getActiveAds($sid, bsa_space($sid, 'max_items'), null, '0' . bsaGetCappedAds($sid));
                    echo "<!--/mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->";
                }
                $example = null;
                if (!isset($if_empty) && get_option('bsa_pro_plugin_example_ad') == 'yes') {
                    // example ads if empty ad space
                    $example = true;
                }
                if (count($ads) > 0 || count($ads) == 0 && !isset($if_empty)) {
                    if (isset($sid) && bsa_space($sid, 'display_type') == 'corner') {
                        echo '<div class="bsaProCorner bsaProCorner-' . $sid . '">';
                        // -- START -- CORNER
                        echo '
				<div class="bsaProRibbon"></div>
					<div class="bsaProCornerContent">
						<div class="bsaProCornerInner">';
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'floating' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-bottom-right' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-bottom-left' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-top-left' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-top-right') {
                        echo '<div class="bsaProFloating bsaProFloating-' . $sid . '" style="display: none"><div class="bsaFloatingButton"><span class="bsaFloatingClose bsaFloatingClose-' . $sid . '"></span></div>';
                        // -- START -- FLOATING
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'carousel') {
                        echo '<div class="bsaProCarousel bsaProCarousel-' . $sid . '">';
                        // -- START -- CAROUSEL
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'top_scroll_bar' || isset($sid) && bsa_space($sid, 'display_type') == 'bottom_scroll_bar') {
                        echo '<div class="bsaProScrollBar bsaProScrollBar-' . $sid . '">';
                        // -- START -- TOP / BOTTOM SCROLL BAR
                        if (bsa_space($sid, 'display_type') == 'bottom_scroll_bar') {
                            echo '<div class="bsaProScrollBarButton"><span class="bsaProScrollBarClose bsaProScrollBarClose-' . $sid . '"></span></div>';
                        }
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'popup' || isset($sid) && bsa_space($sid, 'display_type') == 'exit_popup') {
                        echo '
					<div class="bsaPopupWrapperBg bsaPopupWrapperBg-' . $sid . ' bsaHidden" style="display:none"></div>

					<div class="bsaPopupWrapper bsaPopupWrapper-' . $sid . ' bsaHidden" style="display:none">

						<div class="bsaPopupWrapperInner">
				';
                        // -- START -- POPUP, EXIT POPUP
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'layer') {
                        echo '
					<div class="bsaPopupWrapperBg bsaPopupWrapperBg-' . $sid . ' bsaHidden"></div>

					<div class="bsaPopupWrapper bsaPopupWrapper-' . $sid . ' bsaHidden">
				';
                        // -- START -- LAYER
                    }
                    // -- START -- DEFAULT
                    require dirname(__FILE__) . '/../frontend/template/' . $styleName . '.php';
                    // -- END -- DEFAULT
                    if (isset($sid) && bsa_space($sid, 'display_type') != 'popup' && bsa_space($sid, 'display_type') != 'corner' && bsa_space($sid, 'display_type') != 'layer' && bsa_space($sid, 'display_type') != 'exit_popup' && bsa_space($sid, 'display_type') != 'background' && bsa_space($sid, 'display_type') != 'link') {
                        if (bsaGetCloseActions($sid, 'show_ads') > 0) {
                            ?>
							<style>
								.bsaProContainer-<?php 
                            echo $sid;
                            ?>
 {
									display: none;
								}
							</style>
						<?php 
                        }
                        ?>
						<script>
							(function ($) {
								var bsaProContainer = $('.bsaProContainer-<?php 
                        echo $sid;
                        ?>
');
								var number_show_ads = "<?php 
                        echo bsaGetCloseActions($sid, 'show_ads');
                        ?>
";
								var number_hide_ads = "<?php 
                        echo bsaGetCloseActions($sid, 'close_ads');
                        ?>
";
								if ( number_show_ads > 0 ) {
									setTimeout(function () { bsaProContainer.fadeIn(); }, number_show_ads * 1000);
								}
								if ( number_hide_ads > 0 ) {
									setTimeout(function () { bsaProContainer.fadeOut(); }, number_hide_ads * 1000);
								}
							})(jQuery);
						</script>
					<?php 
                    }
                    if (isset($sid) && bsa_space($sid, 'display_type') == 'background') {
                        ?>
						<style>
							body {
								background-position: top center !important;
								background-color: #e6e6e6 !important;
								background-repeat: no-repeat !important;
								background-attachment: <?php 
                        echo isset($attachment) && $attachment == 'scroll' ? 'scroll' : 'fixed';
                        ?>
 !important;
								padding-top: <?php 
                        echo isset($padding_top) && $padding_top != '' ? $padding_top . 'px' : 'inherit';
                        ?>
 !important;
							}
						</style>
						<script>
							(function ($) {
								$(document).ready(function () {
									var body = "body";
									var getImage = $(".bsaProContainer-<?php 
                        echo $sid;
                        ?>
 .bsaProItemInner__img").css("background-image");
									var getUrl = $(".bsaProContainer-<?php 
                        echo $sid;
                        ?>
 .bsaProItem__url").attr('href');
									$(".bsaProContainer-<?php 
                        echo $sid;
                        ?>
").hide();
									$(body).css("background-image", getImage);
									$(body).click(function (e) {
										var body_target = $(e.target);
										if (body_target.is(body) == true) {
											window.open(getUrl, "_blank");
										}
									});

									$(document).mousemove(function (e) {
										var body_target = $(e.target);
										if (body_target.is(body)) {
											body_target.css("cursor", "pointer");
										} else {
											$(body).css("cursor", "auto");
										}
									});
								});
							})(jQuery);
						</script>
					<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'corner') {
                        echo '
						</div>
					</div>
				</div>';
                        // -- END -- CORNER
                        ?>
						<script>
							(function ($) {
								var body = $(document);
								$(window).scroll(function () {
									if ($(window).scrollTop() >= (body.height() - (body.height() - (body.height() * (<?php 
                        echo ($delay != 0 && $delay != NULL ? $delay : $delay) / 100;
                        ?>
)))) - $(window).height()) {
										setTimeout(function () {
											<?php 
                        if (bsaGetCloseActions($sid, 'show_ads') == 0) {
                            ?>
											$(".bsaProCorner-<?php 
                            echo $sid;
                            ?>
").fadeIn();
											<?php 
                        }
                        ?>
										}, 400);
									}
								});
								var number_show = "<?php 
                        echo bsaGetCloseActions($sid, 'show_ads');
                        ?>
";
								var number_close = "<?php 
                        echo bsaGetCloseActions($sid, 'close_ads');
                        ?>
";
								if ( number_show > 0 ) {
									setTimeout(function () { bsaProCorner.fadeIn(400); }, number_show * 1000);
								}
								if ( number_close > 0 ) {
									setTimeout(function () { bsaProCorner.fadeOut(400); }, number_close * 1000);
								}
								var bsaProCorner = $(".bsaProCorner-<?php 
                        echo $sid;
                        ?>
");
								bsaProCorner.appendTo(document.body);
							})(jQuery);
						</script>
						<style>
							.bsaProCorner-<?php 
                        echo $sid;
                        ?>
 {
								display: <?php 
                        echo bsaGetCloseActions($sid, 'show_ads') > 0 ? 'none' : 'block';
                        ?>
;
								position: fixed;
								width: 150px;
								height: 150px;
								z-index: 10000;
								top: <?php 
                        echo is_user_logged_in() ? '32px' : '0';
                        ?>
;
								right: 0;
								-webkit-transition: all .5s; /* Safari */
								transition: all .5s;
							}
							.bsaProCorner:hover {
								width: 250px;
								height: 250px;
							}
						</style>
					<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'floating' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-bottom-right' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-bottom-left' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-top-left' || isset($sid) && bsa_space($sid, 'display_type') == 'floating-top-right') {
                        echo '</div>';
                        // -- END -- FLOATING
                        ?>
						<script>
							(function ($) {
								var body = $(document);
								$(window).scroll(function () {
									if ($(window).scrollTop() >= (body.height() - (body.height() - (body.height() * (<?php 
                        echo ($delay != 0 && $delay != NULL ? $delay : $delay) / 100;
                        ?>
)))) - $(window).height()) {
										setTimeout(function () {
											$(".bsaProFloating-<?php 
                        echo $sid;
                        ?>
").fadeIn();
										}, 400);
									}
								});
								var bsaProFloating = $(".bsaProFloating-<?php 
                        echo $sid;
                        ?>
");
								var bsaFloatingClose = $(".bsaFloatingClose-<?php 
                        echo $sid;
                        ?>
");
								bsaProFloating.appendTo(document.body);
								bsaFloatingClose.click(function () {
									setTimeout(function () {
										bsaProFloating.removeClass("zoomInDown").addClass("animated zoomOutUp");
									}, 400);
								});
								var number_close = "<?php 
                        echo bsaGetCloseActions($sid, 'close_ads');
                        ?>
";
								var number_show = "<?php 
                        echo bsaGetCloseActions($sid, 'show_close_btn');
                        ?>
";
								if ( number_close > 0 ) {
									setTimeout(function () { bsaProFloating.fadeOut(400); }, number_close * 1000);
									setTimeout(function () { bsaProFloating.remove(); }, (number_close * 1000) + 400);
								}
								if ( number_show > 0 ) {
									bsaFloatingClose.hide();
									setTimeout(function () {
										bsaFloatingClose.fadeIn();
									}, number_show * 1000);
								}
							})(jQuery);
						</script>
						<style>
							.bsaProFloating-<?php 
                        echo $sid;
                        ?>
 {
								position: fixed;
								max-width: <?php 
                        echo $max_width != 0 && $max_width != NULL ? $max_width : '320';
                        ?>
px;
								width: 90%;
								z-index: 10000;
							<?php 
                        if (bsa_space($sid, 'display_type') == 'floating-top-left') {
                            echo '
										top: ' . (is_user_logged_in() ? 47 : 15) . 'px;
										left: 15px;
									';
                        } elseif (bsa_space($sid, 'display_type') == 'floating-top-right') {
                            echo '
										top: ' . (is_user_logged_in() ? 47 : 15) . 'px;
										right: 15px;
									';
                        } elseif (bsa_space($sid, 'display_type') == 'floating-bottom-left') {
                            echo '
										bottom: ' . (is_user_logged_in() ? 47 : 15) . 'px;
										left: 15px;
									';
                        } else {
                            echo '
										bottom: ' . (is_user_logged_in() ? 47 : 15) . 'px;
										right: 15px;
									';
                        }
                        ?>
							}

							<?php 
                        if (bsa_space($sid, 'display_type') == 'floating-top-left' || bsa_space($sid, 'display_type') == 'floating-bottom-left') {
                            echo '
										.bsaProFloating-' . $sid . ' .bsaFloatingButton {
											float: left;
										}
									';
                        }
                        ?>
						</style>
					<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'carousel') {
                        echo '</div>';
                        // -- END -- CAROUSEL
                        ?>
					<script>
						(function ($) {
							$(document).ready(function () {
								setTimeout(function () {
									var owl = $(".bsa-owl-carousel-<?php 
                        echo $sid;
                        ?>
");
									owl.owlCarousel({
										autoPlay: <?php 
                        echo ($delay != 0 && $delay != NULL ? $delay : '2') * 1000;
                        ?>
,
										autoWidth: true,
										slideSpeed: 400,
										paginationSpeed: 700,
										rewindSpeed: 1000,
										singleItem: true,
										stopOnHover: true,
										items: 1,
										responsive:{
											0:{
												items:1
											}
										}
									});
								}, 10);
							});
							window.addEventListener("orientationchange", function() {
								setTimeout(function () {
									var owl = $(".bsa-owl-carousel-<?php 
                        echo $sid;
                        ?>
");
									owl.data('owlCarousel').reinit();
								}, 200);
							}, false);
						})(jQuery);
					</script>
					<style>
						.bsaProCarousel-<?php 
                        echo $sid;
                        ?>
 {
							max-width: <?php 
                        echo $max_width != 0 && $max_width != NULL ? $max_width : '728';
                        ?>
px;
							width: 100%;
							overflow: hidden;
						}
					</style>
				<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'top_scroll_bar' || isset($sid) && bsa_space($sid, 'display_type') == 'bottom_scroll_bar') {
                        if (bsa_space($sid, 'display_type') == 'top_scroll_bar') {
                            echo '<div class="bsaProScrollBarButton"><span class="bsaProScrollBarClose bsaProScrollBarClose-' . $sid . '"></span></div>';
                        }
                        echo '</div>';
                        // -- END -- TOP / BOTTOM SCROLL BAR
                        ?>
					<script>
						(function ($) {
							$(document).ready(function () {
								var bsaScrollBarWrapper = $('.bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
');
								var bsaScrollBarInner = $('.bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
 .bsaProContainer-<?php 
                        echo $sid;
                        ?>
 .bsaProItems');
								var bsaScrollBarClose = $(".bsaProScrollBarClose-<?php 
                        echo $sid;
                        ?>
");
								bsaScrollBarWrapper.appendTo(document.body);
								bsaScrollBarInner.simplyScroll({
									speed: 2
								});
								bsaScrollBarClose.click(function () {
									setTimeout(function () {
										bsaScrollBarWrapper.removeClass("zoomInDown").addClass("animated zoomOutUp");
									}, 400);
								});
								var number_close = "<?php 
                        echo bsaGetCloseActions($sid, 'close_ads');
                        ?>
";
								var number_show = "<?php 
                        echo bsaGetCloseActions($sid, 'show_close_btn');
                        ?>
";
								if ( number_close > 0 ) {
									setTimeout(function () { bsaScrollBarWrapper.fadeOut(400); }, number_close * 1000);
									setTimeout(function () { bsaScrollBarWrapper.remove(); }, (number_close * 1000) + 400);
								}
								if ( number_show > 0 ) {
									bsaScrollBarClose.hide();
									setTimeout(function () {
										bsaScrollBarClose.fadeIn();
									}, number_show * 1000);
								}
							});
						})(jQuery);
					</script>
					<style>
						.bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
 {
							width: 100%;
							position: fixed;
						<?php 
                        if (bsa_space($sid, 'display_type') == 'top_scroll_bar') {
                            ?>
 top: <?php 
                            echo is_user_logged_in() ? '32px' : '0';
                            ?>
;
						<?php 
                        } else {
                            ?>
 bottom: 0;
						<?php 
                        }
                        ?>
 left: 0;
							z-index: 10000;
						}
						.bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
 .bsaProItem {
							margin: 0 !important;
						}
						.bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
, .bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
 .bsaProItems, .bsaProScrollBar-<?php 
                        echo $sid;
                        ?>
 .bsaProContainer .bsaProItem.bsaReset {
							clear: none;
						}
						/* Explicitly set height/width of each list item */
						.simply-scroll .simply-scroll-list .bsaProItem {
							float: left; /* Horizontal scroll only */
							width: <?php 
                        echo ($max_width != 0 && $max_width != NULL ? $max_width . 'px' : 1920 / bsa_space($sid, 'col_per_row')) . 'px';
                        ?>
 !important;
							height: auto;
						}
					</style>
				<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'popup') {
                        echo '</div><span class="bsaPopupClose bsaPopupClose-' . $sid . '"></span>';
                        echo '</div>';
                        // -- END -- POPUP
                        ?>
					<script>
						(function ($) {
							var bsaPopupWrapperBg = $(".bsaPopupWrapperBg-<?php 
                        echo $sid;
                        ?>
");
							var bsaPopupWrapper = $(".bsaPopupWrapper-<?php 
                        echo $sid;
                        ?>
");
							var bsaBody = $("body");
							if (bsaPopupWrapper.hasClass('bsaClosed') == false) {
								setTimeout(function () {
									bsaBody.css({
										"overflow": "hidden",
										"height": ( bsaBody.hasClass("logged-in") ) ? $(window).height() - 32 : $(window).height()
									});
									bsaPopupWrapper.appendTo(document.body).removeClass("bsaHidden").addClass("animated fadeIn").fadeIn();
									bsaPopupWrapperBg.appendTo(document.body).removeClass("bsaHidden").addClass("animated fadeIn").fadeIn();
								}, <?php 
                        echo bsaGetCloseActions($sid, 'show_ads') * 1000;
                        ?>
);
							}
							$(document).ready(function () {
								var bsaPopupClose = $(".bsaPopupClose-<?php 
                        echo $sid;
                        ?>
");
								bsaPopupClose.click(function () {
									bsaBody.css({"overflow": "visible", "height": "auto"});
									bsaPopupClose.addClass("animated zoomOut");
									bsaPopupWrapper.removeClass("fadeIn").addClass("animated fadeOut bsaClosed").fadeOut();
									bsaPopupWrapperBg.removeClass("fadeIn").addClass("animated fadeOut").fadeOut();
								});
								var number_close = "<?php 
                        echo bsaGetCloseActions($sid, 'close_ads');
                        ?>
";
								var number_show = "<?php 
                        echo bsaGetCloseActions($sid, 'show_close_btn');
                        ?>
";
								if ( number_close > 0 ) {
									setTimeout(function () {
//										bsaPopupWrapperBg.fadeOut();
//										bsaPopupWrapper.fadeOut();
//										setTimeout(function () { bsaPopupWrapperBg.remove(); bsaPopupWrapper.remove(); }, 1000);
									}, number_close * 1000);
								}
								if ( number_show > 0 ) {
									bsaPopupClose.hide();
									setTimeout(function () {
										bsaPopupClose.fadeIn();
									}, number_show * 1000);
								}
							});
						})(jQuery);
					</script>
					<?php 
                        if (bsa_option_exists($sid, 'spaces', 'ad_extra_color_1') || $max_width != '') {
                            ?>
						<style>
							<?php 
                            if ($max_width != '') {
                                ?>
							.bsaPopupWrapper-<?php 
                                echo $sid;
                                ?>
 .bsaProContainer {
								max-width: <?php 
                                echo $max_width != 0 && $max_width != NULL ? $max_width . 'px' : '100%';
                                ?>
 !important;
								margin: 0 auto;
							}
							<?php 
                            }
                            ?>
							<?php 
                            if (bsa_option_exists($sid, 'spaces', 'ad_extra_color_1')) {
                                ?>
							.bsaPopupWrapper-<?php 
                                echo $sid;
                                ?>
 {
								background-color: <?php 
                                echo bsa_space($sid, 'ad_extra_color_1');
                                ?>
;
							}
							<?php 
                            }
                            ?>
						</style>
					<?php 
                        }
                        ?>
				<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'layer') {
                        echo '<span class="bsaPopupClose bsaPopupClose-' . $sid . '"></span>';
                        echo '</div>';
                        // -- END -- LAYER
                        ?>
					<script>
						(function ($) {
							var bsaPopupWrapperBg = $(".bsaPopupWrapperBg-<?php 
                        echo $sid;
                        ?>
");
							var bsaPopupWrapper = $(".bsaPopupWrapper-<?php 
                        echo $sid;
                        ?>
");
							var bsaBody = $("body");
							setTimeout(function () {
								var getImage = $(".bsaProContainer-<?php 
                        echo $sid;
                        ?>
 .bsaProItemInner__img").css("background-image");
								$(".bsaProContainer-<?php 
                        echo $sid;
                        ?>
").hide();
								bsaBody.css({
									"overflow": "hidden",
									"height": ( bsaBody.hasClass("logged-in") ) ? $(window).height() - 32 : $(window).height()
								});
								bsaPopupWrapper.css("background-image", getImage).appendTo(document.body).removeClass("bsaHidden").addClass("animated fadeIn").fadeIn();
								bsaPopupWrapperBg.appendTo(document.body).removeClass("bsaHidden").addClass("animated fadeIn").fadeIn();
							}, <?php 
                        echo bsaGetCloseActions($sid, 'show_ads') * 1000;
                        ?>
);
							$(document).ready(function () {
								var bsaPopupClose = $(".bsaPopupClose-<?php 
                        echo $sid;
                        ?>
");
								bsaPopupClose.click(function () {
									bsaBody.css({"overflow": "visible", "height": "auto"});
									bsaPopupClose.addClass("animated zoomOut");
									bsaPopupWrapper.removeClass("fadeIn").addClass("animated fadeOut").fadeOut();
									bsaPopupWrapperBg.removeClass("fadeIn").addClass("animated fadeOut").fadeOut();
								});
								var getUrl = $(".bsaProContainer-<?php 
                        echo $sid;
                        ?>
 .bsaProItem__url").attr('href');
								$(bsaPopupWrapper).click(function (e) {
									var layer_target = $(e.target);
									if (layer_target.is(bsaPopupWrapper) == true) {
										window.open(getUrl, "_blank");
									}
								});
								$(document).mousemove(function (e) {
									var layer_target = $(e.target);
									if (layer_target.is(bsaPopupWrapper)) {
										layer_target.css("cursor", "pointer");
									} else {
										$(bsaPopupWrapper).css("cursor", "auto");
									}
								});
								var number_close = "<?php 
                        echo bsaGetCloseActions($sid, 'close_ads');
                        ?>
";
								var number_show = "<?php 
                        echo bsaGetCloseActions($sid, 'show_close_btn');
                        ?>
";
								if ( number_close > 0 ) {
									setTimeout(function () {
										bsaPopupWrapperBg.fadeOut(400);
										bsaPopupWrapper.fadeOut(400);
										setTimeout(function () { bsaPopupWrapperBg.remove(); bsaPopupWrapper.remove(); }, 400);
									}, number_close * 1000);
								}
								if ( number_show > 0 ) {
									bsaPopupClose.hide();
									setTimeout(function () {
										bsaPopupClose.fadeIn();
									}, number_show * 1000);
								}
							});
						})(jQuery);
					</script>
				<?php 
                    } elseif (isset($sid) && bsa_space($sid, 'display_type') == 'exit_popup') {
                        echo '</div><span class="bsaPopupClose bsaPopupClose-' . $sid . '"></span>';
                        echo '</div>';
                        // -- END -- EXIT POPUP
                        ?>
					<script>
						(function ($) {
							var isDesktop = (function () {
								return !('ontouchstart' in window) || !('onmsgesturechange' in window);
							})();
							window.isDesktop = isDesktop;
							if (isDesktop) {
								var bsaPopupWrapperBg = $(".bsaPopupWrapperBg-<?php 
                        echo $sid;
                        ?>
");
								var bsaPopupWrapper = $(".bsaPopupWrapper-<?php 
                        echo $sid;
                        ?>
");
								var bsaBody = $("body");
								$(document).ready(function () {
									var bsaPopupClose = $(".bsaPopupClose-<?php 
                        echo $sid;
                        ?>
");
									bsaPopupClose.click(function () {
										bsaBody.css({"overflow": "visible", "height": "auto"});
										bsaPopupClose.addClass("animated zoomOut");
										bsaPopupWrapper.removeClass("fadeIn").addClass("animated fadeOut").fadeOut();
										bsaPopupWrapperBg.removeClass("fadeIn").addClass("animated fadeOut").fadeOut();
									});
								});
								$(document).bind("mouseleave", function () {
									if (bsaPopupWrapper.hasClass('fadeIn') == false && bsaPopupWrapper.hasClass('bsaClosed') == false) {
										bsaBody.css({
											"overflow": "hidden",
											"height": ( bsaBody.hasClass("logged-in") ) ? $(window).height() - 32 : $(window).height()
										});
										bsaPopupWrapper.appendTo(document.body).removeClass("bsaHidden").addClass("animated fadeIn bsaClosed").fadeIn();
										bsaPopupWrapperBg.appendTo(document.body).removeClass("bsaHidden").addClass("animated fadeIn").fadeIn();
									}
								});
							}
						})(jQuery);
					</script>
					<style>
						.bsaPopupWrapper-<?php 
                        echo $sid;
                        ?>
 .bsaProContainer {
							max-width: <?php 
                        echo $max_width != 0 && $max_width != NULL ? $max_width . 'px' : '100%';
                        ?>
;
							margin: 0 auto;
						}
						.bsaPopupWrapper-<?php 
                        echo $sid;
                        ?>
 {
							background-color: <?php 
                        echo bsa_space($sid, 'ad_extra_color_1');
                        ?>
;
						}
					</style>
				<?php 
                    }
                    return '';
                }
            } else {
                return null;
            }
        }
    }
    return '';
}