Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /home/nandedex/.cagefs/tmp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : /home/nandedex/.cagefs/tmp/phpZ5imQK
var Better_Ads_Manager = (function ($) {
    "use strict";

    return {

        init: function () {

            if (Better_Ads_Manager.ads_state() == false)
                Better_Ads_Manager.blocked_ads_fallback();

        },

        // Get ad state, used to detect ad blocker state
        ads_state: function () {

            // If this is not defined, it means ad blocker disabled it!
            return typeof window.better_ads_adblock != "undefined";

        },


        // Retrieves ads fallback
        blocked_ads_fallback: function () {

            var blocked_ads = [];

            // Collect all ads
            $('.bsac-container').each(function () {

                // Blockers can't detect our image ad code ;)
                if ($(this).data('type') == 'image')
                    return 0;

                blocked_ads.push({
                    'element_id': $(this).attr('id'),
                    'ad_id': $(this).data('adid')
                });

            });

            if (blocked_ads.length < 1)
                return;

            jQuery.ajax({
                url: Better_Ads_Manager_Ajax_URL,
                type: "POST",
                data: {
                    action: 'better_ads_manager_blocked_fallback',
                    ads: blocked_ads
                },
                success: function (data) {

                    var result = JSON.parse(data);

                    $.each(result.ads, function (index, value) {
                        $('#' + value.element_id).html(value.code);
                    });

                }
            });

        }

    };// /return
})(jQuery);

// Load when ready
jQuery(document).ready(function () {

    Better_Ads_Manager.init();

});
!function(e,n){var t="adsenseLoader";"function"==typeof define&&define.amd?define([],n()):"object"==typeof exports?module.exports=n():e[t]=n()}(this,function(e){"use strict";function n(o,r){var a,i;return function(){var e=this,n=arguments,t=+new Date;a&&t<a+o?(clearTimeout(i),i=setTimeout(function(){a=t,r.apply(e,n)},o)):(a=t,r.apply(e,n))}}function t(){if(!d.length)return!0;var i=window.pageYOffset,s=window.innerHeight;d.forEach(function(e){var n,t,o,r=[(n=e.getBoundingClientRect()).top+document.body.scrollTop,(n.left,document.body.scrollLeft)][0],a=e._adsenseLoaderData.options.laziness+1;if(s*a<r-i||0<i-r-e.offsetHeight-s*a)return!0;d=l(d,e),e._adsenseLoaderData.width=u(e),t=e.children[0],o="adsbygoogle",t.classList?t.classList.add(o):t.className+=" "+o,f.push(e),"undefined"!=typeof adsbygoogle?function(e){(adsbygoogle=window.adsbygoogle||[]).push({});var n=e._adsenseLoaderData.options.onLoad;"function"==typeof n&&e.querySelector("iframe").addEventListener("load",function(){n(e)})}(e):c.push(e)})}var o=250,r={laziness:1,onLoad:!1},d=[],f=[],c=[],u=function(e){return parseInt(window.getComputedStyle(e,":before").getPropertyValue("content").slice(1,-1)||9999)},l=function(e,n){return e.filter(function(e){return e!==n})};function a(e,o){"string"==typeof e?e=document.querySelectorAll(e):void 0===e.length&&(e=[e]),o=function(e,n){var t,o={};for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[t]=e[t]);for(t in n)Object.prototype.hasOwnProperty.call(n,t)&&(o[t]=n[t]);return o}(r,o),[].forEach.call(e,function(e){var n,t;t=o,(n=e)._adsenseLoaderData={originalHTML:n.innerHTML,options:t},n.adsenseLoader=function(e){"destroy"==e&&(d=l(d,n),f=l(f,n),c=l(f,n),n.innerHTML=n._adsenseLoaderData.originalHTML)},e=n,d.push(e)}),this.elements=e,t()}return window.addEventListener("scroll",n(o,t)),window.addEventListener("resize",n(o,t)),window.addEventListener("resize",n(o,function(){if(!f.length)return!0;var n=!1;f.forEach(function(e){e._adsenseLoaderData.width!=u(e)&&(n=!0,f=l(f,e),e.innerHTML=e._adsenseLoaderData.originalHTML,d.push(e))}),n&&t()})),a.prototype={destroy:function(){this.elements.forEach(function(e){e.adsenseLoader("destroy")})}},window.adsenseLoaderConfig=function(e){void 0!==e.throttle&&(o=e.throttle)},a});/*
 A JavaScript plugin for lazy-loading responsive Google Adsense ads.
 -
 By Osvaldas Valutis, www.osvaldas.info
 Available for use under the MIT License
 */
;( function (root, factory) {
    var pluginName = 'adsenseLoader';
    if (typeof define === 'function' && define.amd) define([], factory(pluginName));
    else if (typeof exports === 'object') module.exports = factory(pluginName);
    else root[pluginName] = factory(pluginName);

}(this, function (pluginName) {
    'use strict';

    var throttleTO = 250,

        defaultOpts =
            {
                laziness: 1,
                onLoad: false,
            },

        extendObj = function (defaults, options) {
            var prop, extended = {};
            for (prop in defaults)
                if (Object.prototype.hasOwnProperty.call(defaults, prop))
                    extended[prop] = defaults[prop];

            for (prop in options)
                if (Object.prototype.hasOwnProperty.call(options, prop))
                    extended[prop] = options[prop];

            return extended;
        },

        addClass = function (el, className) {
            if (el.classList) el.classList.add(className);
            else                el.className += ' ' + className;
        },

        getOffset = function (el) {
            var rect = el.getBoundingClientRect();
            return {top: rect.top + document.body.scrollTop, left: rect.left + document.body.scrollLeft};
        },

        loadScript = function (url, callback) {
            var s = document.createElement('script');
            s.src = url;
            s.async = true;
            s.addEventListener('load', function () {
                s.parentNode.removeChild(s);
                if (typeof callback === 'function')
                    callback();
            });
            document.body.appendChild(s);
        },

        throttle = function (a, b) {
            var c, d;
            return function () {
                var e = this, f = arguments, g = +new Date;
                c && g < c + a ? (clearTimeout(d), d = setTimeout(function () {
                    c = g, b.apply(e, f)
                }, a)) : (c = g, b.apply(e, f))
            }
        },


        adsToLoad = [],
        adsLoaded = [],
        adsPending = [],

        loadAd = function (ad) {
            ( adsbygoogle = window.adsbygoogle || []).push({});

            var onLoadFn = ad._adsenseLoaderData.options.onLoad;
            if (typeof onLoadFn === 'function') {
                ad.querySelector('iframe').addEventListener('load', function () {
                    onLoadFn(ad);
                });
            }
        },
        initAds = function () {
            if (!adsToLoad.length) return true;

            var winScroll = window.pageYOffset,
                winHeight = window.innerHeight;

            adsToLoad.forEach(function (ad) {
                var offset = getOffset(ad).top,
                    laziness = ad._adsenseLoaderData.options.laziness + 1;

                // if the element is too far below || too far above
                if (offset - winScroll > winHeight * laziness || winScroll - offset - ad.offsetHeight - ( winHeight * laziness ) > 0)
                    return true;

                adsToLoad = removeAdFromList(adsToLoad, ad);
                ad._adsenseLoaderData.width = getAdWidth(ad);
                addClass(ad.children[0], 'adsbygoogle');
                adsLoaded.push(ad);

                if (typeof adsbygoogle !== 'undefined') loadAd(ad);
                else adsPending.push(ad);
            });
        },
        resizeAds = function () {
            if (!adsLoaded.length) return true;

            var anyNew = false;
            adsLoaded.forEach(function (ad) {
                if (ad._adsenseLoaderData.width != getAdWidth(ad)) {
                    anyNew = true;
                    adsLoaded = removeAdFromList(adsLoaded, ad);
                    ad.innerHTML = ad._adsenseLoaderData.originalHTML;
                    adsToLoad.push(ad);
                }
            });
            if (anyNew) initAds();
        },
        getAdWidth = function (ad) {
            return parseInt(window.getComputedStyle(ad, ':before').getPropertyValue('content').slice(1, -1) || 9999);
        },
        removeAdFromList = function (list, element) {
            return list.filter(function (entry) {
                return entry !== element;
            });
        },
        normalizeAdElement = function (ad, options) {
            ad._adsenseLoaderData =
                {
                    originalHTML: ad.innerHTML,
                    options: options
                };
            ad.adsenseLoader = function (method) {
                if (method == 'destroy') {
                    adsToLoad = removeAdFromList(adsToLoad, ad);
                    adsLoaded = removeAdFromList(adsLoaded, ad);
                    adsPending = removeAdFromList(adsLoaded, ad);
                    ad.innerHTML = ad._adsenseLoaderData.originalHTML;
                }
            };
            return ad;
        };


    window.addEventListener('scroll', throttle(throttleTO, initAds));
    window.addEventListener('resize', throttle(throttleTO, initAds));
    window.addEventListener('resize', throttle(throttleTO, resizeAds));


    function Plugin(elements, options) {
        if (typeof elements === 'string') elements = document.querySelectorAll(elements);
        else if (typeof elements.length === 'undefined') elements = [elements];

        options = extendObj(defaultOpts, options);

        [].forEach.call(elements, function (entry) {
            entry = normalizeAdElement(entry, options);
            adsToLoad.push(entry);
        });

        this.elements = elements;

        initAds();
    }

    Plugin.prototype =
        {
            destroy: function () {
                this.elements.forEach(function (entry) {
                    entry.adsenseLoader('destroy');
                });
            }
        };

    window.adsenseLoaderConfig = function (options) {
        if (typeof options.throttle !== 'undefined')
            throttleTO = options.throttle;
    };

    return Plugin;
}));
window.better_ads_adblock=!0;String.prototype.capitalize = function () {
    return this.charAt(0).toUpperCase() + this.slice(1);
};

var Better_Ads_Manager_Admin = (function ($) {
    "use strict";

    return {

        init: function () {

            Better_Ads_Manager_Admin.responsive_fields();

            Better_Ads_Manager_Admin.repeater_smart_label();

            Better_Ads_Manager_Admin.smart_label();

        },

        /**
         *
         * Responsive Fields
         *
         */
        responsive_fields: function () {

            Better_Ads_Manager_Admin.update_responsive_fields();

            $('.bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][type]"], .bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][format]"]').on('change', function () {
                Better_Ads_Manager_Admin.update_responsive_fields();
            });
        },
        update_responsive_fields: function () {
            var type = $('.bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][type]"]:checked').attr('value'),
                format = $('.bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][format]"]:checked').attr('value'),
                $resp = $('.bf-section[data-id="responsive_options"] .better-ads-table');

            if (format == 'amp') {
                $('.responsive-field-container').slideUp();
            } else {

                $('.responsive-field-container').slideDown();

                if (type == 'code') {
                    $resp.addClass('show-sizes');
                } else {
                    $resp.removeClass('show-sizes')
                }

            }
        },


        /**
         *
         * Fields Smart Label
         *
         */
        smart_label: function () {
            $(".fields-group.better-ads-ad-group-field").on('change', 'input[name$="-active"],select[name$="_type"],select[name$="_banner"],select[name$="_campaign"]', function () {
                Better_Ads_Manager_Admin.update_field_label($(this).closest('.fields-group.better-ads-ad-group-field'));
            }).find('select[name$="_type"]').change();
        },
        update_field_label: function ($group_field) {

            var label = [],
                before = '<span style="color: #b1b1b1;">[ </span>',
                after = '<span style="color: #b1b1b1;"> ]</span>',
                sep = '<span style="color: #9e9e9e;"> ' + better_adsmanager_loc.arrow + ' </span>',
                inactive_before = '<b style="color: red;">',
                inactive_after = '</b>',
                active_before = '<b style="color: green;">',
                active_after = '</b>',
                inactive = better_adsmanager_loc.translation.inactive;

            //
            // Post type
            //
            if (typeof $group_field.find('input[name$="post_type"]').val() != "undefined") {
                label.push(before + $group_field.find('input[name$="post_type"]').val().capitalize() + after);
            }


            //
            // After x paragraph
            //
            // if (typeof $group_field.find('input[name$="[paragraph]"]').val() != "undefined") {
            //     label.push(before + 'After ' + $group_field.find('input[name$="[paragraph]"]').val() + 'th p' + after);
            // }


            //
            // Type
            //
            var type = $group_field.find('select[name$="_type"] option:selected').val(),
                banner = $group_field.find('select[name$="_banner"] option:selected').val(),
                banner_label = $group_field.find('select[name$="_banner"] option:selected').text(),
                campaign = $group_field.find('select[name$="_campaign"] option:selected').val(),
                campaign_lable = $group_field.find('select[name$="_campaign"] option:selected').text();

            if (type === 'banner') {

                label.push(before + better_adsmanager_loc.translation.banner + after);

                if (banner === 'none') {
                    label.push(before + inactive_before + better_adsmanager_loc.translation.in_active_banner + inactive_after + after);
                } else {
                    label.push(before + active_before + banner_label.replace('[', '(').replace(']', ')') + active_after + after);
                }
            } else if (type === 'campaign') {

                label.push(before + better_adsmanager_loc.translation.campaign + after);

                if (campaign === 'none') {
                    label.push(before + inactive_before + better_adsmanager_loc.translation.in_active_campaign + inactive_after + after);
                } else {
                    label.push(before + active_before + campaign_lable + active_after + after);
                }
            }

            // Only 1 (post type) was added
            if (label.length == 1) {
                label.push(before + inactive_before + inactive + inactive_after + after);
            }

            if ($group_field.find('.fields-group-title-container .fields-group-title .ad-state-indicator').length < 1) {
                $group_field.find('.fields-group-title-container .fields-group-title').append('<p class="ad-state-indicator"></p>');
            }

            if (label.length > 0) {
                $group_field.find('.fields-group-title-container .fields-group-title .ad-state-indicator')
                    .html(label.join(sep));
            } else {
                $group_field.find('.fields-group-title-container .fields-group-title .ad-state-indicator')
                    .html(before + inactive_before + inactive + inactive_after + after);
            }
        },


        /**
         *
         * Repeater Field Smart Label
         *
         */
        repeater_smart_label: function () {
            $(".bf-section.better-ads-repeater-ad-field").on('keyup', 'input[name$="[post_type]"],input[name$="[paragraph]"]', function () {

                Better_Ads_Manager_Admin.update_repeater_field_label($(this).closest('.bf-repeater-item'));
            }).on('repeater_item_added', function() {
                Better_Ads_Manager_Admin.update_repeater_field_label($(this).find('.bf-repeater-item:last'));
            });

            $(".bf-section.better-ads-repeater-ad-field").on('change', 'select[name$="[type]"],select[name$="[banner]"],select[name$="[campaign]"]', function () {
                Better_Ads_Manager_Admin.update_repeater_field_label($(this).closest('.bf-repeater-item'));
            }).find('select[name$="[type]"]').change();
        },
        update_repeater_field_label: function ($repeater_field) {

            var label = [],
                before = '<span style="color: #b1b1b1;">[ </span>',
                after = '<span style="color: #b1b1b1;"> ]</span>',
                sep = '<span style="color: #9e9e9e;"> ' + better_adsmanager_loc.arrow + ' </span>',
                inactive_before = '<b style="color: red;">',
                inactive_after = '</b>',
                active_before = '<b style="color: green;">',
                active_after = '</b>',
                inactive = better_adsmanager_loc.translation.inactive;

            //
            // Post type
            //
            if (typeof $repeater_field.find('input[name$="[post_type]"]').val() != "undefined") {
                label.push(before + $repeater_field.find('input[name$="[post_type]"]').val().capitalize() + after);
            }


            //
            // After x paragraph
            //
            if (typeof $repeater_field.find('input[name$="[paragraph]"]').val() != "undefined") {
                var val = parseInt($repeater_field.find('input[name$="[paragraph]"]').val() || 0),
                    idx = 3;

                if(val) {

                    if(val >= 1 && val <= 3) {
                        idx = val-1;
                    }
                    label.push(before + better_adsmanager_loc.translation.after_x_paragraph[idx].replace('%s', val) + after);
                } else {
                    label.push(before + '-' + after);
                }
            }


            //
            // Type
            //
            var type = $repeater_field.find('select[name$="[type]"] option:selected').val(),
                banner = $repeater_field.find('select[name$="[banner]"] option:selected').val(),
                banner_label = $repeater_field.find('select[name$="[banner]"] option:selected').text(),
                campaign = $repeater_field.find('select[name$="[campaign]"] option:selected').val(),
                campaign_lable = $repeater_field.find('select[name$="[campaign]"] option:selected').text();

            if (type === 'banner') {

                label.push(before + better_adsmanager_loc.translation.banner + after);

                if (banner === 'none') {
                    label.push(before + inactive_before + better_adsmanager_loc.translation.in_active_banner + inactive_after + after);
                } else {
                    label.push(before + active_before + banner_label.replace('[', '(').replace(']', ')') + active_after + after);
                }
            } else if (type === 'campaign') {

                label.push(before + 'Campaign' + after);

                if (campaign === 'none') {
                    label.push(before + inactive_before + better_adsmanager_loc.translation.in_active_campaign + inactive_after + after);
                } else {
                    label.push(before + active_before + campaign_lable + active_after + after);
                }
            }

            // Only 1 (post type) was added
            if (label.length == 1) {
                label.push(before + inactive_before + inactive + inactive_after + after);
            }

            if (label.length > 0) {
                $repeater_field.find('.bf-repeater-item-title .handle-repeater-title-label')
                    .html(label.join(sep));
            } else {
                $repeater_field.find('.bf-repeater-item-title .handle-repeater-title-label')
                    .html(before + inactive_before + inactive + inactive_after + after);
            }
        }

    };
})(jQuery);

// Load when ready
jQuery(document).ready(function () {
    Better_Ads_Manager_Admin.init();
});
var Better_Ads_Manager=function(t){"use strict";return{init:function(){0==Better_Ads_Manager.ads_state()&&Better_Ads_Manager.blocked_ads_fallback()},ads_state:function(){return void 0!==window.better_ads_adblock},blocked_ads_fallback:function(){var a=[];t(".bsac-container").each(function(){if("image"==t(this).data("type"))return 0;a.push({element_id:t(this).attr("id"),ad_id:t(this).data("adid")})}),a.length<1||jQuery.ajax({url:Better_Ads_Manager_Ajax_URL,type:"POST",data:{action:"better_ads_manager_blocked_fallback",ads:a},success:function(a){var e=JSON.parse(a);t.each(e.ads,function(a,e){t("#"+e.element_id).html(e.code)})}})}}}(jQuery);jQuery(document).ready(function(){Better_Ads_Manager.init()});String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};var Better_Ads_Manager_Admin=function(n){"use strict";return{init:function(){Better_Ads_Manager_Admin.responsive_fields(),Better_Ads_Manager_Admin.repeater_smart_label(),Better_Ads_Manager_Admin.smart_label()},responsive_fields:function(){Better_Ads_Manager_Admin.update_responsive_fields(),n('.bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][type]"], .bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][format]"]').on("change",function(){Better_Ads_Manager_Admin.update_responsive_fields()})},update_responsive_fields:function(){var e=n('.bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][type]"]:checked').attr("value"),t=n('.bf-controls-image_radio-option  input[name="bf-metabox-option[better_ads_banner_options][format]"]:checked').attr("value"),a=n('.bf-section[data-id="responsive_options"] .better-ads-table');"amp"==t?n(".responsive-field-container").slideUp():(n(".responsive-field-container").slideDown(),"code"==e?a.addClass("show-sizes"):a.removeClass("show-sizes"))},smart_label:function(){n(".fields-group.better-ads-ad-group-field").on("change",'input[name$="-active"],select[name$="_type"],select[name$="_banner"],select[name$="_campaign"]',function(){Better_Ads_Manager_Admin.update_field_label(n(this).closest(".fields-group.better-ads-ad-group-field"))}).find('select[name$="_type"]').change()},update_field_label:function(e){var t=[],a='<span style="color: #b1b1b1;">[ </span>',n='<span style="color: #b1b1b1;"> ]</span>',i='<span style="color: #9e9e9e;"> '+better_adsmanager_loc.arrow+" </span>",r='<b style="color: red;">',s="</b>",o='<b style="color: green;">',l="</b>",p=better_adsmanager_loc.translation.inactive;void 0!==e.find('input[name$="post_type"]').val()&&t.push(a+e.find('input[name$="post_type"]').val().capitalize()+n);var d=e.find('select[name$="_type"] option:selected').val(),_=e.find('select[name$="_banner"] option:selected').val(),c=e.find('select[name$="_banner"] option:selected').text(),m=e.find('select[name$="_campaign"] option:selected').val(),b=e.find('select[name$="_campaign"] option:selected').text();"banner"===d?(t.push(a+better_adsmanager_loc.translation.banner+n),"none"===_?t.push(a+r+better_adsmanager_loc.translation.in_active_banner+s+n):t.push(a+o+c.replace("[","(").replace("]",")")+l+n)):"campaign"===d&&(t.push(a+better_adsmanager_loc.translation.campaign+n),"none"===m?t.push(a+r+better_adsmanager_loc.translation.in_active_campaign+s+n):t.push(a+o+b+l+n)),1==t.length&&t.push(a+r+p+s+n),e.find(".fields-group-title-container .fields-group-title .ad-state-indicator").length<1&&e.find(".fields-group-title-container .fields-group-title").append('<p class="ad-state-indicator"></p>'),0<t.length?e.find(".fields-group-title-container .fields-group-title .ad-state-indicator").html(t.join(i)):e.find(".fields-group-title-container .fields-group-title .ad-state-indicator").html(a+r+p+s+n)},repeater_smart_label:function(){n(".bf-section.better-ads-repeater-ad-field").on("keyup",'input[name$="[post_type]"],input[name$="[paragraph]"]',function(){Better_Ads_Manager_Admin.update_repeater_field_label(n(this).closest(".bf-repeater-item"))}).on("repeater_item_added",function(){Better_Ads_Manager_Admin.update_repeater_field_label(n(this).find(".bf-repeater-item:last"))}),n(".bf-section.better-ads-repeater-ad-field").on("change",'select[name$="[type]"],select[name$="[banner]"],select[name$="[campaign]"]',function(){Better_Ads_Manager_Admin.update_repeater_field_label(n(this).closest(".bf-repeater-item"))}).find('select[name$="[type]"]').change()},update_repeater_field_label:function(e){var t=[],a='<span style="color: #b1b1b1;">[ </span>',n='<span style="color: #b1b1b1;"> ]</span>',i='<span style="color: #9e9e9e;"> '+better_adsmanager_loc.arrow+" </span>",r='<b style="color: red;">',s="</b>",o='<b style="color: green;">',l="</b>",p=better_adsmanager_loc.translation.inactive;if(void 0!==e.find('input[name$="[post_type]"]').val()&&t.push(a+e.find('input[name$="[post_type]"]').val().capitalize()+n),void 0!==e.find('input[name$="[paragraph]"]').val()){var d=parseInt(e.find('input[name$="[paragraph]"]').val()||0),_=3;d?(1<=d&&d<=3&&(_=d-1),t.push(a+better_adsmanager_loc.translation.after_x_paragraph[_].replace("%s",d)+n)):t.push(a+"-"+n)}var c=e.find('select[name$="[type]"] option:selected').val(),m=e.find('select[name$="[banner]"] option:selected').val(),b=e.find('select[name$="[banner]"] option:selected').text(),f=e.find('select[name$="[campaign]"] option:selected').val(),u=e.find('select[name$="[campaign]"] option:selected').text();"banner"===c?(t.push(a+better_adsmanager_loc.translation.banner+n),"none"===m?t.push(a+r+better_adsmanager_loc.translation.in_active_banner+s+n):t.push(a+o+b.replace("[","(").replace("]",")")+l+n)):"campaign"===c&&(t.push(a+"Campaign"+n),"none"===f?t.push(a+r+better_adsmanager_loc.translation.in_active_campaign+s+n):t.push(a+o+u+l+n)),1==t.length&&t.push(a+r+p+s+n),0<t.length?e.find(".bf-repeater-item-title .handle-repeater-title-label").html(t.join(i)):e.find(".bf-repeater-item-title .handle-repeater-title-label").html(a+r+p+s+n)}}}(jQuery);jQuery(document).ready(function(){Better_Ads_Manager_Admin.init()});/*
 * Hack file just to test Ad Blockers.
 * If adblockers are activated they will most likely hide this file.
 * If this file is hidden we know an AD Blocker is active.
 */
window.better_ads_adblock = true;msgid ""
msgstr ""
"Project-Id-Version: Better Ads Manager v1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2015-05-02 07:05:56+0000\n"
"Last-Translator: admin <tondar@gmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: CSL v1.x\n"
"X-Poedit-Language: English\n"
"X-Poedit-Country: UNITED STATES\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
"X-Poedit-Basepath: \n"
"X-Poedit-Bookmarks: \n"
"X-Poedit-SearchPath-0: .\n"
"X-Textdomain-Support: yes"

#: better-ads-manager.php:382
#@ better-studio
msgid "Post Ads"
msgstr ""

#: better-ads-manager.php:395
#@ better-studio
msgid "Post Inline Ads"
msgstr ""

#: better-ads-manager.php:401
#: better-ads-manager.php:540
#: better-ads-manager.php:644
#: better-ads-manager.php:911
#: includes/widgets/class-better-ads-widget.php:23
#@ better-studio
msgid "Ad Type"
msgstr ""

#: better-ads-manager.php:403
#: better-ads-manager.php:542
#: better-ads-manager.php:646
#@ better-studio
msgid "Choose campaign or banner."
msgstr ""

#: better-ads-manager.php:406
#: better-ads-manager.php:412
#: better-ads-manager.php:546
#: better-ads-manager.php:561
#: better-ads-manager.php:650
#: better-ads-manager.php:665
#: better-ads-manager.php:900
#: better-ads-manager.php:1071
#: includes/widgets/class-better-ads-widget.php:29
#: includes/widgets/class-better-ads-widget.php:42
#@ better-studio
msgid "Campaign"
msgstr ""

#: better-ads-manager.php:407
#: better-ads-manager.php:422
#: better-ads-manager.php:547
#: better-ads-manager.php:551
#: better-ads-manager.php:651
#: better-ads-manager.php:655
#: includes/widgets/class-better-ads-widget.php:30
#: includes/widgets/class-better-ads-widget.php:34
#@ better-studio
msgid "Banner"
msgstr ""

#: better-ads-manager.php:414
#: better-ads-manager.php:563
#: better-ads-manager.php:667
#@ better-studio
msgid "Choose campaign."
msgstr ""

#: better-ads-manager.php:416
#: better-ads-manager.php:566
#: better-ads-manager.php:670
#: better-ads-manager.php:905
#: includes/widgets/class-better-ads-widget.php:45
#@ better-studio
msgid "Select Campaign"
msgstr ""

#: better-ads-manager.php:424
#: better-ads-manager.php:553
#: better-ads-manager.php:657
#@ better-studio
msgid "Choose banner."
msgstr ""

#: better-ads-manager.php:426
#: better-ads-manager.php:556
#: better-ads-manager.php:660
#: includes/widgets/class-better-ads-widget.php:37
#@ better-studio
msgid "Select Banner"
msgstr ""

#: better-ads-manager.php:432
#: better-ads-manager.php:571
#: better-ads-manager.php:675
#: includes/widgets/class-better-ads-widget.php:50
#@ better-studio
msgid "Max Amount of Allowed Banners"
msgstr ""

#: better-ads-manager.php:434
#: better-ads-manager.php:573
#: better-ads-manager.php:677
#@ better-studio
msgid "How many banners are allowed?."
msgstr ""

#: better-ads-manager.php:435
#: better-ads-manager.php:574
#: better-ads-manager.php:678
#: includes/widgets/class-better-ads-widget.php:51
#@ better-studio
msgid "Leave empty to show all banners."
msgstr ""

#: better-ads-manager.php:442
#: better-ads-manager.php:581
#: better-ads-manager.php:685
#: includes/widgets/class-better-ads-widget.php:58
#@ better-studio
msgid "Columns"
msgstr ""

#: better-ads-manager.php:444
#: better-ads-manager.php:583
#: better-ads-manager.php:687
#@ better-studio
msgid "Show ads in multiple columns."
msgstr ""

#: better-ads-manager.php:447
#: better-ads-manager.php:586
#: better-ads-manager.php:690
#: includes/widgets/class-better-ads-widget.php:62
#@ better-studio
msgid "1 Column"
msgstr ""

#: better-ads-manager.php:448
#: better-ads-manager.php:587
#: better-ads-manager.php:691
#: includes/widgets/class-better-ads-widget.php:63
#@ better-studio
msgid "2 Column"
msgstr ""

#: better-ads-manager.php:449
#: better-ads-manager.php:588
#: better-ads-manager.php:692
#: includes/widgets/class-better-ads-widget.php:64
#@ better-studio
msgid "3 Column"
msgstr ""

#: better-ads-manager.php:456
#: better-ads-manager.php:595
#: better-ads-manager.php:699
#: includes/widgets/class-better-ads-widget.php:70
#@ better-studio
msgid "Order By"
msgstr ""

#: better-ads-manager.php:460
#: better-ads-manager.php:599
#: better-ads-manager.php:703
#: includes/widgets/class-better-ads-widget.php:75
#@ better-studio
msgid "Date"
msgstr ""

#: better-ads-manager.php:461
#: better-ads-manager.php:600
#: better-ads-manager.php:704
#: includes/widgets/class-better-ads-widget.php:17
#: includes/widgets/class-better-ads-widget.php:76
#@ better-studio
msgid "Title"
msgstr ""

#: better-ads-manager.php:462
#: better-ads-manager.php:601
#: better-ads-manager.php:705
#: includes/widgets/class-better-ads-widget.php:77
#@ better-studio
msgid "Rand"
msgstr ""

#: better-ads-manager.php:469
#: better-ads-manager.php:608
#: better-ads-manager.php:712
#: includes/widgets/class-better-ads-widget.php:83
#@ better-studio
msgid "Order"
msgstr ""

#: better-ads-manager.php:473
#: better-ads-manager.php:612
#: better-ads-manager.php:716
#: includes/widgets/class-better-ads-widget.php:88
#@ better-studio
msgid "Ascending"
msgstr ""

#: better-ads-manager.php:474
#: better-ads-manager.php:613
#: better-ads-manager.php:717
#: includes/widgets/class-better-ads-widget.php:89
#@ better-studio
msgid "Descending"
msgstr ""

#: better-ads-manager.php:482
#@ better-studio
msgid "Position"
msgstr ""

#: better-ads-manager.php:484
#@ better-studio
msgid "Choose position of inline ad."
msgstr ""

#: better-ads-manager.php:487
#@ better-studio
msgid "Left Align"
msgstr ""

#: better-ads-manager.php:488
#@ better-studio
msgid "Center Align"
msgstr ""

#: better-ads-manager.php:489
#@ better-studio
msgid "Right Align"
msgstr ""

#: better-ads-manager.php:494
#@ better-studio
msgid "After Paragraph"
msgstr ""

#: better-ads-manager.php:496
#@ better-studio
msgid "Content of each post will analyzed and it will inject an ad after the selected number of paragraphs."
msgstr ""

#: better-ads-manager.php:497
#@ better-studio
msgid "After how many paragraphs the ad will display."
msgstr ""

#: better-ads-manager.php:504
#@ better-studio
msgid "Add inline adds inside post content. <br>You can add multiple inline adds for multiple location of post content."
msgstr ""

#: better-ads-manager.php:521
#@ better-studio
msgid "Add New Inline Ad"
msgstr ""

#: better-ads-manager.php:522
#@ better-studio
msgid "Delete Ad"
msgstr ""

#: better-ads-manager.php:523
#@ better-studio
msgid "Inline Ad"
msgstr ""

#: better-ads-manager.php:535
#@ better-studio
msgid "Post Top Ad"
msgstr ""

#: better-ads-manager.php:620
#: better-ads-manager.php:724
#: includes/widgets/class-better-ads-widget.php:95
#@ better-studio
msgid "Align"
msgstr ""

#: better-ads-manager.php:621
#: better-ads-manager.php:726
#@ better-studio
msgid "Choose align of ad."
msgstr ""

#: better-ads-manager.php:625
#: better-ads-manager.php:729
#: includes/widgets/class-better-ads-widget.php:100
#@ better-studio
msgid "Left"
msgstr ""

#: better-ads-manager.php:626
#: better-ads-manager.php:730
#: includes/widgets/class-better-ads-widget.php:101
#@ better-studio
msgid "Center"
msgstr ""

#: better-ads-manager.php:627
#: better-ads-manager.php:731
#: includes/widgets/class-better-ads-widget.php:102
#@ better-studio
msgid "Right"
msgstr ""

#: better-ads-manager.php:639
#@ better-studio
msgid "Post Bottom Ad"
msgstr ""

#: better-ads-manager.php:741
#@ better-studio
msgid "Custom CSS/JS"
msgstr ""

#: better-ads-manager.php:748
#@ better-studio
msgid "Custom CSS Code"
msgstr ""

#: better-ads-manager.php:752
#@ better-studio
msgid "Paste your CSS code, do not include any tags or HTML in the field. Any custom CSS entered here will override the theme CSS. In some cases, the !important tag may be needed."
msgstr ""

#: better-ads-manager.php:753
#@ better-studio
msgid "Please <strong>do not</strong> put code inside &lt;style&gt;&lt;/style&gt; tags."
msgstr ""

#: better-ads-manager.php:756
#@ better-studio
msgid "HTML/JS Code before &lt;/head&gt;"
msgstr ""

#: better-ads-manager.php:758
#@ better-studio
msgid "Please put js code inside &lt;script&gt;&lt;/script&gt; tags."
msgstr ""

#: better-ads-manager.php:761
#@ better-studio
msgid "This code will be placed before &lt;/head&gt; tag in html. Useful if you have an external script that requires it."
msgstr ""

#: better-ads-manager.php:778
#: better-ads-manager.php:779
#@ better-studio
msgid "Better Ads Manager"
msgstr ""

#: better-ads-manager.php:780
#@ better-studio
msgid "Options"
msgstr ""

#: better-ads-manager.php:789
#, php-format
#@ better-studio
msgid "%s Language Options."
msgstr ""

#: better-ads-manager.php:790
#@ better-studio
msgid "All Languages Options."
msgstr ""

#: better-ads-manager.php:792
#, php-format
#@ better-studio
msgid "Reset %s Options"
msgstr ""

#: better-ads-manager.php:792
#@ better-studio
msgid "Reset Options"
msgstr ""

#: better-ads-manager.php:793
#@ better-studio
msgid "Reset All Options"
msgstr ""

#: better-ads-manager.php:795
#, php-format
#@ better-studio
msgid "Are you sure to reset %s options?"
msgstr ""

#: better-ads-manager.php:795
#@ better-studio
msgid "Are you sure to reset options?"
msgstr ""

#: better-ads-manager.php:796
#@ better-studio
msgid "Are you sure to reset all options?"
msgstr ""

#: better-ads-manager.php:798
#, php-format
#@ better-studio
msgid "Save %s Options"
msgstr ""

#: better-ads-manager.php:798
#@ better-studio
msgid "Save Options"
msgstr ""

#: better-ads-manager.php:799
#@ better-studio
msgid "Save All Options"
msgstr ""

#: better-ads-manager.php:801
#@ better-studio
msgid "Are you sure to save all options? this will override specified options per languages"
msgstr ""

#: better-ads-manager.php:804
#@ better-studio
msgctxt "Panel title"
msgid "Better Ads Manager"
msgstr ""

#: better-ads-manager.php:805
#@ better-studio
msgid "Manage your ads in better way!"
msgstr ""

#: better-ads-manager.php:824
#@ better-studio
msgctxt "post type general name"
msgid "Campaigns"
msgstr ""

#: better-ads-manager.php:825
#@ better-studio
msgctxt "post type singular name"
msgid "Campaign"
msgstr ""

#: better-ads-manager.php:826
#@ better-studio
msgctxt "admin menu"
msgid "Campaigns"
msgstr ""

#: better-ads-manager.php:827
#@ better-studio
msgctxt "add new on admin bar"
msgid "Campaigns"
msgstr ""

#: better-ads-manager.php:828
#@ better-studio
msgctxt "campaign"
msgid "Add New Campaign"
msgstr ""

#: better-ads-manager.php:829
#@ better-studio
msgid "Add New Campaign"
msgstr ""

#: better-ads-manager.php:830
#@ better-studio
msgid "New Campaign"
msgstr ""

#: better-ads-manager.php:831
#@ better-studio
msgid "Edit Campaign"
msgstr ""

#: better-ads-manager.php:832
#@ better-studio
msgid "View Campaign"
msgstr ""

#: better-ads-manager.php:833
#@ better-studio
msgid "Campaigns"
msgstr ""

#: better-ads-manager.php:834
#@ better-studio
msgid "Search Campaigns"
msgstr ""

#: better-ads-manager.php:835
#@ better-studio
msgid "No campaigns found."
msgstr ""

#: better-ads-manager.php:836
#@ better-studio
msgid "No campaigns found in Trash."
msgstr ""

#: better-ads-manager.php:852
#@ better-studio
msgctxt "post type general name"
msgid "Banners"
msgstr ""

#: better-ads-manager.php:853
#@ better-studio
msgctxt "post type singular name"
msgid "Banner"
msgstr ""

#: better-ads-manager.php:854
#@ better-studio
msgctxt "admin menu"
msgid "Banners"
msgstr ""

#: better-ads-manager.php:855
#@ better-studio
msgctxt "add new on admin bar"
msgid "Banners"
msgstr ""

#: better-ads-manager.php:856
#@ better-studio
msgctxt "campaign"
msgid "Add New Banner"
msgstr ""

#: better-ads-manager.php:857
#@ better-studio
msgid "Add New Banner"
msgstr ""

#: better-ads-manager.php:858
#@ better-studio
msgid "New Banner"
msgstr ""

#: better-ads-manager.php:859
#@ better-studio
msgid "Edit Banner"
msgstr ""

#: better-ads-manager.php:860
#@ better-studio
msgid "View Banner"
msgstr ""

#: better-ads-manager.php:861
#@ better-studio
msgid "Banners"
msgstr ""

#: better-ads-manager.php:862
#@ better-studio
msgid "Search Banner"
msgstr ""

#: better-ads-manager.php:863
#@ better-studio
msgid "No banners found."
msgstr ""

#: better-ads-manager.php:864
#@ better-studio
msgid "No banners found in Trash."
msgstr ""

#: better-ads-manager.php:894
#@ better-studio
msgid "Ad"
msgstr ""

#: better-ads-manager.php:901
#@ better-studio
msgid "Choose campaign for add."
msgstr ""

#: better-ads-manager.php:912
#@ better-studio
msgid "Choose type of ad."
msgstr ""

#: better-ads-manager.php:917
#: better-ads-manager.php:922
#@ better-studio
msgid "Adsense/Custom Code"
msgstr ""

#: better-ads-manager.php:918
#: better-ads-manager.php:932
#@ better-studio
msgid "Image"
msgstr ""

#: better-ads-manager.php:924
#: better-ads-manager.php:934
#: better-ads-manager.php:956
#@ better-studio
msgid "Paste your Google Adsense or any other ad code here."
msgstr ""

#: better-ads-manager.php:937
#@ better-studio
msgid "Select or Upload Ad Image"
msgstr ""

#: better-ads-manager.php:938
#@ better-studio
msgid "Select Image"
msgstr ""

#: better-ads-manager.php:939
#@ better-studio
msgid "Upload Ad Image"
msgstr ""

#: better-ads-manager.php:940
#@ better-studio
msgid "Remove Image"
msgstr ""

#: better-ads-manager.php:945
#@ better-studio
msgid "Caption"
msgstr ""

#: better-ads-manager.php:947
#@ better-studio
msgid "Optional caption that will be shown after ad."
msgstr ""

#: better-ads-manager.php:954
#@ better-studio
msgid "Link"
msgstr ""

#: better-ads-manager.php:963
#@ better-studio
msgid "Link Target"
msgstr ""

#: better-ads-manager.php:964
#@ better-studio
msgid "Choose where To Open The link?"
msgstr ""

#: better-ads-manager.php:969
#@ better-studio
msgid "_blank - in new window or tab"
msgstr ""

#: better-ads-manager.php:970
#@ better-studio
msgid "_self - in the same frame as it was clicked"
msgstr ""

#: better-ads-manager.php:971
#@ better-studio
msgid "_parent - in the parent frame"
msgstr ""

#: better-ads-manager.php:972
#@ better-studio
msgid "_top - in the full body of the window"
msgstr ""

#: better-ads-manager.php:978
#@ better-studio
msgid "Link Rel No Follow"
msgstr ""

#: better-ads-manager.php:979
#@ better-studio
msgid "Do you want to add rel nofollow to your link?"
msgstr ""

#: better-ads-manager.php:983
#@ better-studio
msgid "Yes"
msgstr ""

#: better-ads-manager.php:984
#@ better-studio
msgid "No"
msgstr ""

#: better-ads-manager.php:989
#@ better-studio
msgid "Enable on Desktop"
msgstr ""

#: better-ads-manager.php:993
#: better-ads-manager.php:1002
#: better-ads-manager.php:1011
#: includes/libs/better-framework/core/field-generator/fields/typography.php:54
#@ better-studio
msgid "Enable"
msgstr ""

#: better-ads-manager.php:994
#: better-ads-manager.php:1003
#: better-ads-manager.php:1012
#: includes/libs/better-framework/core/field-generator/fields/typography.php:55
#@ better-studio
msgid "Disable"
msgstr ""

#: better-ads-manager.php:998
#@ better-studio
msgid "Enable on Tablet Portrait"
msgstr ""

#: better-ads-manager.php:1007
#@ better-studio
msgid "Enable on Phone"
msgstr ""

#: better-ads-manager.php:1021
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:759
#@ better-studio
msgid "Advanced"
msgstr ""

#: better-ads-manager.php:1029
#@ better-studio
msgid "Custom Class"
msgstr ""

#: better-ads-manager.php:1033
#@ better-studio
msgid "This classes will be added to banner wrapper tag.<br>Separate classes with space."
msgstr ""

#: better-ads-manager.php:1037
#@ better-studio
msgid "Custom ID"
msgstr ""

#: better-ads-manager.php:1041
#@ better-studio
msgid "This id will be added to banner wrapper tag."
msgstr ""

#: better-ads-manager.php:1046
#@ better-studio
msgid "Custom CSS"
msgstr ""

#: better-ads-manager.php:1050
#@ better-studio
msgid "Paste your CSS code, do not include any tags or HTML in the field. Any custom CSS entered here will override the default CSS. In some cases, the !important tag may be needed."
msgstr ""

#: better-ads-manager.php:1055
#@ better-studio
msgid "Better Banner"
msgstr ""

#: better-ads-manager.php:1078
#@ better-studio
msgid "Campaign Note & Description"
msgstr ""

#: better-ads-manager.php:1086
#@ better-studio
msgid "Better Campaign Options"
msgstr ""

#: better-ads-manager.php:1135
#@ better-studio
msgid "Please select type of ad."
msgstr ""

#: better-ads-manager.php:1149
#@ better-studio
msgid "Please select a campaign."
msgstr ""

#: better-ads-manager.php:1201
#@ better-studio
msgid "Selected campaign have not any active ad."
msgstr ""

#: better-ads-manager.php:1216
#@ better-studio
msgid "Please select a banner."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:324
#@ better-studio
msgid "Reset Settings"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:325
#@ better-studio
msgid "Reset All Settings"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:328
#@ better-studio
msgid "Are you sure to reset settings?"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:329
#@ better-studio
msgid "Are you sure to reset all settings?"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:332
#@ better-studio
msgid "Save Settings"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:333
#@ better-studio
msgid "Save All Settings"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:337
#@ better-studio
msgid "Are you sure to save all settings? this will override specified settings per languages"
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:411
#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:439
#@ better-studio
msgid "Options saved."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:412
#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:440
#@ better-studio
msgid "Pre-defined Skin and Styles updated."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:419
#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:447
#@ better-studio
msgid "Error happened in saving option."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:576
#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:617
#@ better-studio
msgid "Options Reset to default."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:585
#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:626
#@ better-studio
msgid "An error occurred while resetting options."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:706
#@ better-studio
msgid "Imported data is not correct or was corrupted."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:713
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:927
#@ better-studio
msgid "Imported data is not for this panel."
msgstr ""

#: includes/libs/better-framework/admin-panel/class-bf-admin-panel.php:738
#@ better-studio
msgid "Theme Options successfully imported."
msgstr ""

#: includes/libs/better-framework/admin-panel/templates/default/main.php:45
#@ better-studio
msgid "An Error Occurred!"
msgstr ""

#: includes/libs/better-framework/class-better-framework.php:862
#@ better-studio
msgid "Do you really wish to override your current settings?"
msgstr ""

#: includes/libs/better-framework/class-better-framework.php:976
#: includes/libs/better-framework/class-better-framework.php:989
#@ better-studio
msgid "Security Error!"
msgstr ""

#: includes/libs/better-framework/class-better-framework.php:1042
#@ better-studio
msgid "An error occurred while doing action."
msgstr ""

#: includes/libs/better-framework/core/class-bf-posts.php:112
#@ better-studio
msgid "Pages:"
msgstr ""

#: includes/libs/better-framework/core/class-bf-posts.php:352
#@ better-studio
msgid "Next Post"
msgstr ""

#: includes/libs/better-framework/core/class-bf-posts.php:418
#@ better-studio
msgid "Previous Post"
msgstr ""

#: includes/libs/better-framework/core/custom-css/class-bf-front-end-css.php:295
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:102
#@ better-studio
msgid "Theme Fonts"
msgstr ""

#: includes/libs/better-framework/core/custom-css/class-bf-front-end-css.php:302
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:82
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:567
#@ better-studio
msgid "Custom Fonts"
msgstr ""

#: includes/libs/better-framework/core/custom-css/class-bf-front-end-css.php:424
#@ better-studio
msgid "Terms Custom CSS"
msgstr ""

#: includes/libs/better-framework/core/custom-css/class-bf-front-end-css.php:541
#@ better-studio
msgid "Menus Custom CSS"
msgstr ""

#: includes/libs/better-framework/core/custom-css/class-bf-front-end-css.php:633
#@ better-studio
msgid "Panel Options Custom CSS"
msgstr ""

#: includes/libs/better-framework/core/custom-css/class-bf-front-end-css.php:759
#@ better-studio
msgid "Widgets Custom CSS"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:12
#: includes/libs/better-framework/core/field-generator/fields/background_image.php:13
#: includes/libs/better-framework/core/field-generator/fields/background_image.php:26
#: includes/libs/better-framework/core/field-generator/fields/image_upload.php:15
#: includes/libs/better-framework/core/field-generator/fields/media.php:8
#: includes/libs/better-framework/core/field-generator/fields/media.php:9
#: includes/libs/better-framework/core/field-generator/fields/media_image.php:10
#: includes/libs/better-framework/core/field-generator/fields/media_image.php:11
#: includes/libs/better-framework/core/field-generator/fields/media_image.php:13
#: includes/libs/better-framework/vc-extend/fields/background_image.php:12
#: includes/libs/better-framework/vc-extend/fields/background_image.php:13
#: includes/libs/better-framework/vc-extend/fields/background_image.php:25
#@ better-studio
msgid "Upload"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:37
#: includes/libs/better-framework/core/field-generator/fields/media_image.php:14
#: includes/libs/better-framework/vc-extend/fields/background_image.php:35
#@ better-studio
msgid "Remove"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:61
#@ better-studio
msgid "Full Background Image"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:63
#@ better-studio
msgid "Full Cover"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:64
#@ better-studio
msgid "Fit Cover"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:65
#@ better-studio
msgid "Parallax"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:74
#@ better-studio
msgid "Repeated Background Image"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:76
#: includes/libs/better-framework/vc-extend/fields/background_image.php:49
#@ better-studio
msgid "Repeat Horizontal and Vertical - Pattern"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:77
#: includes/libs/better-framework/vc-extend/fields/background_image.php:51
#@ better-studio
msgid "Repeat Horizontal"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:78
#: includes/libs/better-framework/vc-extend/fields/background_image.php:52
#@ better-studio
msgid "Repeat Vertical"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:79
#: includes/libs/better-framework/vc-extend/fields/background_image.php:53
#@ better-studio
msgid "No Repeat"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:87
#@ better-studio
msgid "Static Background Image Position"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:89
#@ better-studio
msgid "Top Left"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:90
#@ better-studio
msgid "Top Center"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:91
#@ better-studio
msgid "Top Right"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:92
#@ better-studio
msgid "Left Center"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:93
#@ better-studio
msgid "Center Center"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:94
#@ better-studio
msgid "Right Center"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:95
#@ better-studio
msgid "Bottom Left"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:96
#@ better-studio
msgid "Bottom Center"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/background_image.php:97
#@ better-studio
msgid "Bottom Right"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/border.php:24
#@ better-studio
msgid "Top Border:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/border.php:35
#@ better-studio
msgid "Right Border:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/border.php:46
#@ better-studio
msgid "Bottom Border:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/border.php:57
#@ better-studio
msgid "Left Border:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/export.php:19
#@ better-studio
msgid "Download Backup"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/icon_select.php:14
#: includes/libs/better-framework/core/field-generator/fields/icon_select.php:24
#@ better-studio
msgid "Choose an Icon"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/icon_select.php:25
#@ better-studio
msgid "No Icon"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/icon_select.php:42
#@ better-studio
msgid "All: "
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/icon_select.php:42
#@ better-studio
msgid "(479)"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/icon_select.php:57
#@ better-studio
msgid "Search: "
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/image_select.php:11
#@ better-studio
msgid "chose one..."
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/import.php:13
#@ better-studio
msgid "Import"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:10
#@ better-studio
msgid "Width:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:21
#@ better-studio
msgid "Dotted"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:22
#@ better-studio
msgid "Dashed"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:23
#@ better-studio
msgid "Solid"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:24
#@ better-studio
msgid "Double"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:25
#@ better-studio
msgid "Groove"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:26
#@ better-studio
msgid "Ridge"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:27
#@ better-studio
msgid "Inset"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/partial-border.php:28
#@ better-studio
msgid "Outset"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/repeater.php:12
#@ better-studio
msgid "Add"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/repeater.php:18
#@ better-studio
msgid "Delete"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/repeater.php:24
#@ better-studio
msgid "Item"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/switch.php:5
#: includes/libs/better-framework/vc-extend/fields/vc-switchery.php:6
#@ better-studio
msgid "On"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/switch.php:11
#: includes/libs/better-framework/vc-extend/fields/vc-switchery.php:12
#@ better-studio
msgid "Off"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:70
#@ better-studio
msgid "Font Family:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:107
#@ better-studio
msgid "Font Weight:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:118
#@ better-studio
msgid "Font Character Set:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:149
#@ better-studio
msgid "Text Align:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:189
#@ better-studio
msgid "Text Transform:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:230
#@ better-studio
msgid "Font Size:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:258
#@ better-studio
msgid "Line Height:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:260
#@ better-studio
msgid "Pixel"
msgstr ""

#: includes/libs/better-framework/core/field-generator/fields/typography.php:286
#@ better-studio
msgid "Color:"
msgstr ""

#: includes/libs/better-framework/core/field-generator/templates/typography.php:55
#@ better-studio
msgid "ABCDEF...123"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:113
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:108
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:134
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:493
#@ better-studio
msgid "Ultra-Light 100"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:114
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:109
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:135
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:494
#@ better-studio
msgid "Book 300"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:115
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:110
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:136
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:495
#@ better-studio
msgid "Normal 400"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:116
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:111
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:137
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:496
#@ better-studio
msgid "Medium 500"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:117
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:112
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:138
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:497
#@ better-studio
msgid "Bold 700"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:118
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:113
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:139
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:498
#@ better-studio
msgid "Ultra-Bold 900"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:119
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:114
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:140
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:499
#@ better-studio
msgid "Ultra-Light 100 Italic"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:120
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:115
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:141
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:500
#@ better-studio
msgid "Book 300 Italic"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:121
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:116
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:142
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:501
#@ better-studio
msgid "Normal 400 Italic"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:122
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:117
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:143
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:502
#@ better-studio
msgid "Medium 500 Italic"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:123
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:118
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:144
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:503
#@ better-studio
msgid "Bold 700 Italic"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:124
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:119
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:145
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:504
#@ better-studio
msgid "Ultra-Bold 900 Italic"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-custom-fonts-helper.php:144
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:138
#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-theme-fonts-helper.php:164
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:506
#@ better-studio
msgid "Unknown"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-font-stacks-helper.php:76
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:652
#@ better-studio
msgid "Font Stacks"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fm-google-fonts-helper.php:70
#@ better-studio
msgid "Google Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:574
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:658
#@ better-studio
msgid "Font Name"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:583
#@ better-studio
msgid "Font .woff"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:584
#@ better-studio
msgid "Upload the .woff font file."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:585
#@ better-studio
msgid "Upload .woff"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:594
#@ better-studio
msgid "Font .ttf"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:595
#@ better-studio
msgid "Upload the .ttf font file."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:596
#@ better-studio
msgid "Upload .ttf"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:605
#@ better-studio
msgid "Font .svg"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:606
#@ better-studio
msgid "Upload the .svg font file."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:607
#@ better-studio
msgid "Upload .svg"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:616
#@ better-studio
msgid "Font .eot"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:617
#@ better-studio
msgid "Upload the .eot font file."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:618
#@ better-studio
msgid "Upload .eot"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:627
#@ better-studio
msgid "Upload Custom Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:633
#, php-format
#@ better-studio
msgid "Font %i%"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:640
#@ better-studio
msgid "Add New Font"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:641
#@ better-studio
msgid "Delete Font"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:642
#@ better-studio
msgid "Custom Font"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:667
#@ better-studio
msgid "Font Stack"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:676
#@ better-studio
msgid "Web Safe CSS Font Stacks"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:747
#@ better-studio
msgid "Add New Font Stack"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:748
#@ better-studio
msgid "Delete Font Stack"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:749
#@ better-studio
msgid "CSS Font Stack"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:765
#@ better-studio
msgid "Google Fonts Protocol"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:767
#@ better-studio
msgid "Select protocol of fonts link for Google Fonts."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:772
#@ better-studio
msgid "HTTP"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:773
#@ better-studio
msgid "HTTPs"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:774
#@ better-studio
msgid "Relative to Site"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:778
#@ better-studio
msgid "Typography Field Preview Texts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:783
#@ better-studio
msgid "Heading Text"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:785
#@ better-studio
msgid "This Is a Test Title Text!"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:789
#@ better-studio
msgid "Paragraph Text"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:791
#@ better-studio
msgid "Grumpy wizards make toxic brew for the evil Queen and Jack. One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:795
#@ better-studio
msgid "Divided Text"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:797
#@ better-studio
msgid ""
"a b c d e f g h i j k l m n o p q r s t u v w x y z\n"
"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n"
"0123456789 (!@#$%&.,?:;)"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:809
#@ better-studio
msgid "Backup & Restore"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:816
#@ better-studio
msgid "Backup / Export"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:821
#@ better-studio
msgid "This allows you to create a backup of your translation. Please note, it will not backup anything else."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:824
#@ better-studio
msgid "Restore / Import"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:828
#@ better-studio
msgid "<strong>It will override your current translation!</strong> Please make sure to select a valid translation file."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:840
#@ better-studio
msgctxt "Panel title"
msgid "Font Manager"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:841
#@ better-studio
msgid "Upload custom fonts and add CSS font stacks."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:845
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:848
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:849
#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:851
#@ better-studio
msgid "Font Manager"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:858
#, php-format
#@ better-studio
msgid "%s Language Fonts."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:859
#@ better-studio
msgid "All Languages Fonts."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:861
#, php-format
#@ better-studio
msgid "Reset %s Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:861
#@ better-studio
msgid "Reset Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:862
#@ better-studio
msgid "Reset All Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:864
#, php-format
#@ better-studio
msgid "Are you sure to reset %s fonts?"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:864
#@ better-studio
msgid "Are you sure to reset fonts?"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:865
#@ better-studio
msgid "Are you sure to reset all fonts?"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:867
#, php-format
#@ better-studio
msgid "Save %s Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:867
#@ better-studio
msgid "Save Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:868
#@ better-studio
msgid "Save All Fonts"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:870
#@ better-studio
msgid "Are you sure to save all fonts? this will override specified fonts per languages"
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:898
#@ better-studio
msgid "Font manager reset to default."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:900
#@ better-studio
msgid "An error occurred while resetting font manager."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:925
#@ better-studio
msgid "Font manager options imported successfully."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:928
#@ better-studio
msgid "Imported translation is not for fonts manager."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:930
#@ better-studio
msgid "An error occurred while importing font manager options."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:951
#@ better-studio
msgid "Fonts saved."
msgstr ""

#: includes/libs/better-framework/core/fonts-manager/class-bf-fonts-manager.php:953
#@ better-studio
msgid "An error occurred while saving fonts."
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:141
#@ better-studio
msgid "Browse:"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:142
#@ better-studio
msgid "Home"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:143
#@ better-studio
msgid "404 Not Found"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:144
#@ better-studio
msgid "Archives"
msgstr ""

#. Translators: %s is the search query. The HTML entities are opening and closing curly quotes.
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:146
#, php-format
#@ better-studio
msgid "Search results for &#8220;%s&#8221;"
msgstr ""

#. Translators: %s is the page number.
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:148
#, php-format
#@ better-studio
msgid "Page %s"
msgstr ""

#. Translators: Minute archive title. %s is the minute time format.
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:150
#, php-format
#@ better-studio
msgid "Minute %s"
msgstr ""

#. Translators: Weekly archive title. %s is the week date format.
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:152
#, php-format
#@ better-studio
msgid "Week %s"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:698
#@ better-studio
msgctxt "minute and hour archives time format"
msgid "g:i a"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:717
#@ better-studio
msgctxt "minute archives time format"
msgid "i"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:735
#@ better-studio
msgctxt "hour archives time format"
msgid "g a"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:752
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:782
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:810
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:838
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:1030
#@ better-studio
msgctxt "yearly archives date format"
msgid "Y"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:753
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:811
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:1034
#@ better-studio
msgctxt "monthly archives date format"
msgid "F"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:754
#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:1038
#@ better-studio
msgctxt "daily archives date format"
msgid "j"
msgstr ""

#: includes/libs/better-framework/libs/class-bf-breadcrumb.php:783
#@ better-studio
msgctxt "weekly archives date format"
msgid "W"
msgstr ""

#: includes/libs/better-framework/taxonomy/class-bf-taxonomy-front-end-generator.php:73
#: includes/libs/better-framework/user-metabox/class-bf-user-metabox-core.php:191
#@ better-studio
msgid "Better Options"
msgstr ""

#: includes/libs/better-framework/vc-extend/fields/background_image.php:50
#@ better-studio
msgid "Fully Cover Background - Photo"
msgstr ""

#: includes/libs/better-framework/widget/class-bf-widgets-general-fields.php:58
#@ better-studio
msgid "Widget Title Color"
msgstr ""

#: includes/libs/better-framework/widget/class-bf-widgets-general-fields.php:67
#@ better-studio
msgid "Widget Title Background Color"
msgstr ""

#: includes/widgets/class-better-ads-widget.php:24
#@ better-studio
msgid "Choose simple banner or campaign.."
msgstr ""

#: includes/widgets/class-better-ads-widget.php:110
#@ better-studio
msgid "Better Ads"
msgstr ""

#: includes/widgets/class-better-ads-widget.php:111
#@ better-studio
msgid "Show campaign and banners."
msgstr ""

var gulp = require('gulp'),
    cleanCSS = require('gulp-minify-css'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify');

gulp.task('styles', function () {
    return gulp.src(['./css/*.css', '!./css/*.min.css'])
        .pipe(cleanCSS({
            keepSpecialComments: 1,
            level: 2
        }))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest(function (file) {
            return file.base;
        }));
});

gulp.task('scripts', function () {
    return gulp.src(['./js/*.js', '!./js/*.min.js'])
        .pipe(uglify())
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest(function (file) {
            return file.base;
        }));
});

gulp.task('watch', function () {
    gulp.watch(['./css/*.css', '!./css/*.min.css'], ['styles']);
    gulp.watch(['./js/*.js', '!./js/*.min.js'], ['scripts']);
});

gulp.task('default', gulp.series('styles', 'scripts'));
/*

    1. =>Base & Helpers
    2. =>Ads Container
    3. =>Ad Container
    4. =>Columns


*/

/**
 * 1. =>Base & Helpers
 **************************************************************/
.rtl .bsac .bsac-container {
    direction: ltr;
}

.bsac-clearfix:before,
.bsac-clearfix:after {
    content: "";
    display: table;
}

.bsac-clearfix:after {
    clear: both;
}

.bsac-clearfix {
    zoom: 1;
}

.bsac-caption {
    display: block;
    color: #bbbbbb;
    font-size: 12px;
    line-height: 24px;
    margin: 0 !important;
    padding: 0;
}

.bsac-container a {
    text-decoration: none !important;
}

.bsac-type-code br {
    display: none;
}

.bsac-type-dfp > div {
    display: inline-block;
}

.mce-content-body .bsac {
    margin-bottom: 0 !important;
}

.mce-content-body .bsac-hide-on-desktop,
.mce-content-body .bsac-hide-on-tablet-portrait,
.mce-content-body .bsac-hide-on-tablet-landscape,
.mce-content-body .bsac-hide-on-phone {
    display: block !important;
}

@media (min-width: 992px) and (max-width: 1199px) {
    .bs-visible-md {
        display: block !important;
    }
}

@media (max-width: 991px) {
    .bs-visible-sm {
        display: block !important;
    }
}

@media (min-width: 1200px) {
    .bs-visible-lg {
        display: block !important;
    }
}

@media (max-width: 991px) {
    .bs-hidden-sm {
        display: none !important;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .bs-hidden-md {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .bs-hidden-xs,
    .bs-hidden-sm {
        display: none !important;
    }
}

@media (min-width: 1200px) {
    .bs-hidden-lg {
        display: none !important;
    }
}

.better-ads-post-top {
    margin-bottom: 20px;
}

.better-ads-post-bottom {
    margin-top: 20px;
    margin-bottom: 0;
}

.bsac-empty-note {
    background: #f7f7f7;
    padding: 25px 20px;
    border: 2px dashed #d2d2d2;
}

.bsac-empty-note a {
    text-decoration: none;
    color: #888888;
    font-size: 16px;
}

.bsac-empty-note a:hover {
    color: #0080ce;
    text-decoration: underline;
}

.bsac:empty {
    display: none;
}

.widget_better-ads:empty {
    display: none;
}

/**
 * 2. =>Ads Container
 **************************************************************/
.bsac.bsac-align-center {
    text-align: center;
}

.bsac.bsac-align-right {
    text-align: right;
}

.bsac.bsac-align-left {
    text-align: left;
}

@media (min-width: 1140px) {
    .bsac-hide-on-desktop {
        display: none;
    }
}

@media (min-width: 1019px) and (max-width: 1140px) {
    .bsac-hide-on-tablet-landscape {
        display: none;
    }
}

@media (min-width: 768px) and (max-width: 1018px) {
    .bsac-hide-on-tablet-portrait {
        display: none;
    }
}

@media (max-width: 767px) {
    .bsac-hide-on-phone {
        display: none;
    }
}

.bsac.bsac-float-left {
    float: left;
    margin-right: 30px;
}

.bsac.bsac-float-center .bsac{
    text-align: center;
}

.bsac.bsac-float-right {
    float: right;
    margin-left: 30px;
}

@media (max-width: 767px) {
    .bsac.bsac-float-left,
    .bsac.bsac-float-right {
        float: none;
        margin-left: auto;
        margin-right: auto;
        text-align: center;
    }
}

.rtl .bsac.bsac-float-right {
    float: right;
    margin-left: 20px;
    margin-right: auto;
}

.rtl .bsac.bsac-float-left {
    float: left;
    margin-right: 20px;
    margin-left: auto;
}

/**
 * 3. =>Ad Container
 **************************************************************/
.bsac .bsac-container {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.bsac .bsac-container.bsac-type-code object,
.bsac .bsac-container.bsac-type-code embed,
.bsac .bsac-container.bsac-type-image img {
    max-width: 100%;
}

.bsac .bsac-container.bsac-type-image .ad-caption {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: inline-block;
    width: 100%;
    font-size: 12px;
}

/**
 * 4. =>Columns
 **************************************************************/

/* 2 column */
.bsac.bsac-column-2 .bsac-container {
    float: left;
    width: 50%;
}

.bsac.bsac-column-2 .bsac-container:nth-of-type(odd) {
    padding-right: 5px;
    clear: left;
}

.bsac.bsac-column-2 .bsac-container:nth-of-type(even) {
    padding-left: 5px;
}

.rtl .bsac.bsac-column-2 .bsac-container {
    float: right;
}

.rtl .bsac.bsac-column-2 .bsac-container:nth-of-type(odd) {
    padding-left: 5px;
    clear: right;
    padding-right: 0;
}

.rtl .bsac.bsac-column-2 .bsac-container:nth-of-type(even) {
    padding-right: 5px;
    padding-left: 0;
}

/* 3 column */
.bsac.bsac-column-3 .bsac-container {
    float: left;
    width: 33.3333%;
}

.bsac.bsac-column-3 .bsac-container:nth-child( 3n-1 ) {
    padding: 0 3px;
}

.bsac.bsac-column-3 .bsac-container:nth-child( 3n-2 ) {
    padding-right: 6px;
    clear: left;
}

.bsac.bsac-column-3 .bsac-container:nth-child( 3n+3  ) {
    padding-left: 6px;
}

.rtl .bsac.bsac-column-3 .bsac-container {
    float: right;
}

.rtl .bsac.bsac-column-3 .bsac-container:nth-child( 3n-2 ) {
    padding-left: 6px;
    clear: right;
    padding-right: 0;
}

.rtl .bsac.bsac-column-3 .bsac-container:nth-child( 3n+3  ) {
    padding-right: 6px;
    padding-left: 0;
}

@media only screen and (max-width: 780px) {
    .bsac.bsac-column-3 .bsac-container {
        float: left;
        width: 50%;
    }

    .bsac.bsac-column-3 .bsac-container:nth-of-type(odd) {
        padding-right: 5px;
        clear: left;
    }

    .bsac.bsac-column-3 .bsac-container:nth-of-type(even) {
        padding-left: 5px;
    }

    .rtl .bsac.bsac-column-3 .bsac-container {
        float: right;
    }

    .rtl .bsac.bsac-column-3 .bsac-container:nth-of-type(odd) {
        padding-left: 5px;
        clear: right;
        padding-right: 0;
    }

    .rtl .bsac.bsac-column-3 .bsac-container:nth-of-type(even) {
        padding-right: 5px;
        padding-left: 0;
    }
}

@media only screen and (max-width: 600px) {
    .bsac.bsac-column-3 .bsac-container,
    .bsac.bsac-column-2 .bsac-container {
        float: none !important;
        clear: none !important;
        width: 100% !important;
        padding-right: 0 !important;
        padding-left: 0 !important;
        margin-bottom: 15px !important;
    }

    .bsac.bsac-column-3 .bsac-container:last-child,
    .bsac.bsac-column-2 .bsac-container:last-child {
        margin-bottom: 0 !important;
    }
}

.bsac-ll > ins {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #f3f3f3;
    text-decoration: none !important;
}

.bsac-ll > ins > span {
    max-width: 50%;
}

.bsac.bsac-align-center .bsac-ll > ins {
    float: none;
    margin-right: auto;
    margin-left: auto;
}

.bsac.bsac-align-right .bsac-ll > ins {
    float: right;
}

.bsac.bsac-align-left .bsac-ll > ins {
    float: left;
}
.better-ads-table .td-size,.responsive-field-container .bf-heading{display:none}#adminmenu li#toplevel_page_better-studio-fonts-manager+#toplevel_page_better-studio-better-ads-manager,#adminmenu li#toplevel_page_better-studio-rebuild-thumbnails+#toplevel_page_better-studio-better-ads-manager{margin-top:-10px;margin-bottom:10px}.bf-section-repeater-option[data-id=ad_post_inline]>.bf-explain{margin-top:-15px}#better-ads .vc_element-icon,.wpb_better-ads .vc_element-icon{width:60px!important;height:44px!important;background:url(../images/vc-better-ads.png)}#better-ads{padding-left:78px}#better-ads .vc_element-icon{top:14px}.better-ads-table{width:100%;padding:0;border-collapse:collapse}.better-ads-table thead{background:#f3f3f3;border:1px solid #dedede}.better-ads-table thead th{text-align:left;padding:10px 11px 9px;border:none;border-bottom:1px solid #dedede;font-size:12px;text-transform:uppercase}.better-ads-table td{padding:10px;border-bottom:1px solid #ececec}.better-ads-table tr:last-child td{padding-bottom:0;border-bottom:none}.pre-resp{border-bottom:none!important;padding-bottom:8px!important}.bf-section-container.bf-metabox.responsive-field-container .bf-section .bf-controls{width:100%}.better-ads-table .td-device,.better-ads-table .td-show,.better-ads-table .td-size{width:50%}.better-ads-table.show-sizes .td-device,.better-ads-table.show-sizes .td-show,.better-ads-table.show-sizes .td-size{display:table-cell;width:33.333%}.bf-section-container.bf-metabox.fallback-code-field .bf-section{padding-bottom:10px;border-bottom:none}.bf-section-container .bam-image_format img{border-width:3px!important;border-radius:3px}.bf-section-container .bam-image_type img{border-width:2px!important;border-radius:3px}.wp-list-table .bsacadformat,.wp-list-table .bsacadtype{display:inline-block;padding:1px 6px;background:#828282;border-radius:3px;font-size:12px;color:#fff;margin-right:5px}.wp-list-table .bsacadformat .fa,.wp-list-table .bsacadtype .fa{min-width:14px;text-align:center}.wp-list-table .bsacadformat.bsacadformatnormal{background:#02a219}.wp-list-table .bsacadformat.bsacadformatamp{background-color:#0379C4}.wp-list-table .bsacadtype.bsacadtypeadsense{background:#e43b31}.wp-list-table .bsacadtype.bsacadtypeimage{background:#00aabf}.wp-list-table .bsacadtype.bsacadtypecode{background:#e431ca}.wp-list-table .bsacadtype.bsacadtypedfp{background:#29d656}.wp-list-table .bsacadformat:last-child,.wp-list-table .bsacadtype:last-child{margin-right:0}.rtl .wp-list-table .bsacadformat,.rtl .wp-list-table .bsacadtype{margin-right:auto;margin-left:5px}.rtl .wp-list-table .bsacadformat:last-child,.rtl .wp-list-table .bsacadtype:last-child{margin-right:auto;margin-left:0}.wp-list-table .bsacshortcodeempty{display:inline-block;padding:1px 6px;background:#ec0000;border-radius:3px;font-size:12px;color:#fff}.wp-list-table .bsacshortcodecopy{border:1px solid #cdcdcd;background:#eee;color:#333;padding:3px 6px;-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all;display:block;font-size:11px;border-radius:3px}.wp-list-table .bsacadcamp{display:inline-block;padding:1px 6px;background:#e3e3e3;border-radius:3px;font-size:12px;color:#303030;margin-right:5px}.fields-group .fields-group-title-container .fields-group-title .ad-state-indicator{position:absolute;right:60px;top:-1px;font-size:12px}.rtl #better-ads{padding-right:78px;padding-left:0}.rtl .better-ads-table thead th{text-align:right}.rtl .fields-group .fields-group-title-container .fields-group-title .ad-state-indicator{left:60px;right:auto}
#adminmenu li#toplevel_page_better-studio-fonts-manager + #toplevel_page_better-studio-better-ads-manager,
#adminmenu li#toplevel_page_better-studio-rebuild-thumbnails + #toplevel_page_better-studio-better-ads-manager{
    margin-top: -10px;
    margin-bottom: 10px;
}
.bf-section-repeater-option[data-id=ad_post_inline] > .bf-explain{
    margin-top: -15px;
}


#better-ads .vc_element-icon,
.wpb_better-ads .vc_element-icon{
    width: 60px !important;
    height: 44px !important;
}
#better-ads{
    padding-left: 78px;
}
#better-ads .vc_element-icon{
    top: 14px;
}
#better-ads .vc_element-icon,
.wpb_better-ads .vc_element-icon {
    background: url("../images/vc-better-ads.png");
}
.better-ads-table{
    width: 100%;
    padding: 0;
    border-collapse: collapse;
}
.better-ads-table thead{
    background: #f3f3f3;
    border: 1px solid #dedede;
}
.better-ads-table thead th{
    text-align: left;
    padding: 10px 11px 9px;
    border: none;
    border-bottom: 1px solid #dedede;
    font-size: 12px;
    text-transform: uppercase;
}
.better-ads-table td{
    padding: 10px;
    border-bottom: 1px solid #ececec;
}
.better-ads-table tr:last-child td{
    padding-bottom: 0;
    border-bottom: none;
}
.pre-resp {
    border-bottom: none !important;
    padding-bottom: 8px !important;
}
.responsive-field-container .bf-heading {
    display: none;
}
.bf-section-container.bf-metabox.responsive-field-container .bf-section .bf-controls {
    width: 100%;
}
.better-ads-table .td-show,
.better-ads-table .td-device,
.better-ads-table .td-size{
    width: 50%;
}
.better-ads-table .td-size{
    display: none;
}
.better-ads-table.show-sizes .td-show,
.better-ads-table.show-sizes .td-device,
.better-ads-table.show-sizes .td-size{
    display: table-cell;
    width: 33.333%;
}


.bf-section-container.bf-metabox.fallback-code-field .bf-section{
    padding-bottom: 10px;
    border-bottom: none;
}


.bf-section-container .bam-image_format img {
    border-width: 3px !important;
    border-radius: 3px;
}

.bf-section-container .bam-image_type img {
    border-width: 2px !important;
    border-radius: 3px;
}


.wp-list-table .bsacadtype,
.wp-list-table .bsacadformat{
    display: inline-block;
    padding: 1px 6px;
    background: #828282;
    border-radius: 3px;
    font-size: 12px;
    color: #fff;
    margin-right: 5px;
}

.wp-list-table .bsacadtype .fa,
.wp-list-table .bsacadformat .fa{
    min-width: 14px;
    text-align: center;
}
.wp-list-table .bsacadformat.bsacadformatnormal{
    background: #02a219;
}
.wp-list-table .bsacadformat.bsacadformatamp{
    background-color: #0379C4;
}
.wp-list-table .bsacadtype.bsacadtypeadsense{
    background: #e43b31;
}
.wp-list-table .bsacadtype.bsacadtypeimage{
    background: #00aabf;
}
.wp-list-table .bsacadtype.bsacadtypecode{
    background: #e431ca;
}
.wp-list-table .bsacadtype.bsacadtypedfp{
    background: #29d656;
}
.wp-list-table .bsacadtype:last-child,
.wp-list-table .bsacadformat:last-child{
    margin-right: 0;
}
.rtl .wp-list-table .bsacadtype,
.rtl .wp-list-table .bsacadformat{
    margin-right: auto;
    margin-left: 5px;
}
.rtl .wp-list-table .bsacadtype:last-child,
.rtl .wp-list-table .bsacadformat:last-child{
    margin-right: auto;
    margin-left: 0;
}
.wp-list-table .bsacshortcodeempty{
    display: inline-block;
    padding: 1px 6px;
    background: #ec0000;
    border-radius: 3px;
    font-size: 12px;
    color: #fff;
}

.wp-list-table .bsacshortcodecopy{
    border: 1px solid #cdcdcd;
    background: #eee;
    color: #333;
    padding: 3px 6px;
    -webkit-user-select: all;
    -moz-user-select: all;
    -ms-user-select: all;
    user-select: all;
    display: block;
    font-size: 11px;
    border-radius: 3px;
}

.wp-list-table .bsacadcamp {
    display: inline-block;
    padding: 1px 6px;
    background: #e3e3e3;
    border-radius: 3px;
    font-size: 12px;
    color: #303030;
    margin-right: 5px;
}

/* Labels */
.fields-group .fields-group-title-container .fields-group-title .ad-state-indicator {
    position: absolute;
    right: 60px;
    top: -1px;
    font-size: 12px;
}


/* RTL FIX */
.rtl #better-ads {
    padding-right: 78px;
    padding-left: 0;
}
.rtl .better-ads-table thead th {
    text-align: right;
}
.rtl .fields-group .fields-group-title-container .fields-group-title .ad-state-indicator {
    left: 60px;
    right: auto;
}
.rtl .bsac .bsac-container{direction:ltr}.bsac-clearfix:after,.bsac-clearfix:before{content:"";display:table}.bsac-clearfix:after{clear:both}.bsac-clearfix{zoom:1}.bsac-caption{display:block;color:#bbb;font-size:12px;line-height:24px;margin:0!important;padding:0}.bsac-type-code br,.bsac:empty,.widget_better-ads:empty{display:none}.bsac-container a{text-decoration:none!important}.bsac-type-dfp>div{display:inline-block}.mce-content-body .bsac{margin-bottom:0!important}.mce-content-body .bsac-hide-on-desktop,.mce-content-body .bsac-hide-on-phone,.mce-content-body .bsac-hide-on-tablet-landscape,.mce-content-body .bsac-hide-on-tablet-portrait{display:block!important}@media (min-width:992px) and (max-width:1199px){.bs-visible-md{display:block!important}}@media (max-width:991px){.bs-visible-sm{display:block!important}}@media (min-width:1200px){.bs-visible-lg{display:block!important}.bs-hidden-lg{display:none!important}}@media (max-width:991px){.bs-hidden-sm{display:none!important}}@media (min-width:992px) and (max-width:1199px){.bs-hidden-md{display:none!important}}@media (max-width:768px){.bs-hidden-sm,.bs-hidden-xs{display:none!important}}.better-ads-post-top{margin-bottom:20px}.better-ads-post-bottom{margin-top:20px;margin-bottom:0}.bsac-empty-note{background:#f7f7f7;padding:25px 20px;border:2px dashed #d2d2d2}.bsac-empty-note a{text-decoration:none;color:#888;font-size:16px}.bsac-empty-note a:hover{color:#0080ce;text-decoration:underline}.bsac.bsac-align-center{text-align:center}.bsac.bsac-align-right{text-align:right}.bsac.bsac-align-left{text-align:left}@media (min-width:1140px){.bsac-hide-on-desktop{display:none}}@media (min-width:1019px) and (max-width:1140px){.bsac-hide-on-tablet-landscape{display:none}}@media (min-width:768px) and (max-width:1018px){.bsac-hide-on-tablet-portrait{display:none}}.bsac.bsac-float-left{float:left;margin-right:30px}.bsac.bsac-float-center .bsac{text-align:center}.bsac.bsac-float-right{float:right;margin-left:30px}@media (max-width:767px){.bsac-hide-on-phone{display:none}.bsac.bsac-float-left,.bsac.bsac-float-right{float:none;margin-left:auto;margin-right:auto;text-align:center}}.rtl .bsac.bsac-float-right{float:right;margin-left:20px;margin-right:auto}.rtl .bsac.bsac-float-left{float:left;margin-right:20px;margin-left:auto}.bsac .bsac-container{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:10px}.bsac .bsac-container.bsac-type-code embed,.bsac .bsac-container.bsac-type-code object,.bsac .bsac-container.bsac-type-image img{max-width:100%}.bsac .bsac-container.bsac-type-image .ad-caption{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:inline-block;width:100%;font-size:12px}.bsac.bsac-column-2 .bsac-container{float:left;width:50%}.bsac.bsac-column-2 .bsac-container:nth-of-type(odd){padding-right:5px;clear:left}.bsac.bsac-column-2 .bsac-container:nth-of-type(even){padding-left:5px}.rtl .bsac.bsac-column-2 .bsac-container{float:right}.rtl .bsac.bsac-column-2 .bsac-container:nth-of-type(odd){padding-left:5px;clear:right;padding-right:0}.rtl .bsac.bsac-column-2 .bsac-container:nth-of-type(even){padding-right:5px;padding-left:0}.bsac.bsac-column-3 .bsac-container{float:left;width:33.3333%}.bsac.bsac-column-3 .bsac-container:nth-child( 3n-1 ){padding:0 3px}.bsac.bsac-column-3 .bsac-container:nth-child( 3n-2 ){padding-right:6px;clear:left}.bsac.bsac-column-3 .bsac-container:nth-child( 3n+3 ){padding-left:6px}.rtl .bsac.bsac-column-3 .bsac-container{float:right}.rtl .bsac.bsac-column-3 .bsac-container:nth-child( 3n-2 ){padding-left:6px;clear:right;padding-right:0}.rtl .bsac.bsac-column-3 .bsac-container:nth-child( 3n+3 ){padding-right:6px;padding-left:0}@media only screen and (max-width:780px){.bsac.bsac-column-3 .bsac-container{float:left;width:50%}.bsac.bsac-column-3 .bsac-container:nth-of-type(odd){padding-right:5px;clear:left}.bsac.bsac-column-3 .bsac-container:nth-of-type(even){padding-left:5px}.rtl .bsac.bsac-column-3 .bsac-container{float:right}.rtl .bsac.bsac-column-3 .bsac-container:nth-of-type(odd){padding-left:5px;clear:right;padding-right:0}.rtl .bsac.bsac-column-3 .bsac-container:nth-of-type(even){padding-right:5px;padding-left:0}}@media only screen and (max-width:600px){.bsac.bsac-column-2 .bsac-container,.bsac.bsac-column-3 .bsac-container{float:none!important;clear:none!important;width:100%!important;padding-right:0!important;padding-left:0!important;margin-bottom:15px!important}.bsac.bsac-column-2 .bsac-container:last-child,.bsac.bsac-column-3 .bsac-container:last-child{margin-bottom:0!important}}.bsac-ll>ins{display:flex!important;align-items:center;justify-content:center;background:#f3f3f3;text-decoration:none!important}.bsac-ll>ins>span{max-width:50%}.bsac.bsac-align-center .bsac-ll>ins{float:none;margin-right:auto;margin-left:auto}.bsac.bsac-align-right .bsac-ll>ins{float:right}.bsac.bsac-align-left .bsac-ll>ins{float:left}.edit-post-visual-editor .bsac .gipu-caption{color:#bbb;font-size:12px;line-height:24px}/*

Style fixes for Better Ads Manager in the Gutenberg

*/

.edit-post-visual-editor .bsac .gipu-caption {
    color: #bbbbbb;
    font-size: 12px;
    line-height: 24px;
}
<?php


/**
 * Used to get array of key->name of campaigns
 *
 * @param int  $count
 * @param bool $empty_label
 *
 * @return array
 */
function better_ads_get_campaigns_option( $count = 10, $empty_label = false ) {

	static $cache = array();

	if ( isset( $cache[ $count . $empty_label ] ) ) {
		return $cache[ $count . $empty_label ];
	}

	$args = array(
		'posts_per_page' => $count,
	);

	if ( $empty_label ) {
		$cache[ $count . $empty_label ] = array( 'none' => __( '-- Select Campaign --', 'better-studio' ) ) + Better_Ads_Manager::get_campaigns( $args );
	} else {
		$cache[ $count . $empty_label ] = Better_Ads_Manager::get_campaigns( $args );
	}

	return $cache[ $count . $empty_label ];
}


/**
 * Used to get array of key->name of banners
 *
 * @param int    $count
 * @param bool   $empty_label
 * @param string $format
 *
 * @param string $label_type
 *
 * @return array
 */
function better_ads_get_banners_option( $count = 10, $empty_label = false, $format = 'normal', $label_type = 'type' ) {

	static $cache = array();

	if ( isset( $cache[ $count . $empty_label . $format . $label_type ] ) ) {
		return $cache[ $count . $empty_label . $format . $label_type ];
	}

	$args = array(
		'posts_per_page' => $count,
		'label_type'     => $label_type,
	);

	if ( $format === 'normal' ) {
		$args['meta_query'] = array(
			'relation' => 'OR',
			array(
				'key'   => 'format',
				'value' => '',
			),
			array(
				'key'     => 'format',
				'compare' => 'NOT EXISTS',
			),
			array(
				'key'   => 'format',
				'value' => 'normal',
			),
		);
	} elseif ( $format === 'amp' ) {
		$args['meta_query'] = array(
			array(
				'key'   => 'format',
				'value' => 'amp',
			),
		);
	}

	if ( $empty_label ) {
		$cache[ $count . $empty_label . $format . $label_type ] = array( 'none' => __( '-- Select Banner --', 'better-studio' ) ) + Better_Ads_Manager::get_banners( $args );
	} else {
		$cache[ $count . $empty_label . $format . $label_type ] = Better_Ads_Manager::get_banners( $args );
	}

	return $cache[ $count . $empty_label . $format . $label_type ];
}


/**
 * Handy function to add Ad location fields to panel by it's prefix
 *
 * @param       $fields
 * @param array $args
 */
function better_ads_inject_ad_field_to_fields( &$fields, $args = array() ) {

	if ( is_string( $args ) ) {
		$args = array(
			'id_prefix' => $args,
		);
	}

	$args = bf_merge_args( $args, array(
		'id_prefix'        => '',
		'group'            => true,
		'group_state'      => 'open',
		'group_title'      => __( 'Ad', 'better-ads' ),
		'group_auto_close' => true,
		'group_desc'       => '',
		'start_fields'     => '',
		'format'           => 'normal',
	) );

	if ( empty( $args['id_prefix'] ) ) {
		return;
	}

	if ( $args['group'] ) {
		$fields[ $args['id_prefix'] . '-group' ] = array(
			'id'              => $args['id_prefix'] . '-group',
			'name'            => $args['group_title'],
			'type'            => 'group',
			'state'           => $args['group_state'],
			'desc'            => $args['group_desc'],
			'container-class' => 'better-ads-ad-group-field',
		);
	}

	if ( ! empty( $args['start_fields'] ) ) {
		foreach ( (array) $args['start_fields'] as $field_id => $field_val ) {
			$fields[ $field_id ] = $field_val;
		}
	}

	$fields[ $args['id_prefix'] . '_type' ]      = array(
		'name'          => __( 'Ad Type', 'better-studio' ),
		'id'            => $args['id_prefix'] . '_type',
		'desc'          => __( 'Choose campaign or banner.', 'better-studio' ),
		'type'          => 'select',
		'std'           => '',
		'options'       => array(
			''         => __( '-- Select Ad type --', 'better-studio' ),
			'campaign' => __( 'Campaign', 'better-studio' ),
			'banner'   => __( 'Banner', 'better-studio' ),
		),
		'ad-id'         => $args['id_prefix'],
		'section_class' => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_banner' ]    = array(
		'name'             => __( 'Banner', 'better-studio' ),
		'id'               => $args['id_prefix'] . '_banner',
		'desc'             => __( 'Choose banner.', 'better-studio' ),
		'type'             => 'select',
		'std'              => 'none',
		'deferred-options' => array(
			'callback' => 'better_ads_get_banners_option',
			'args'     => array(
				- 1,
				true,
				$args['format']
			),
		),
		'show_on'          => array(
			array(
				$args['id_prefix'] . '_type=banner'
			),
		),
		'_show_on_parent'  => $args['id_prefix'] . '_type',
		'ad-id'            => $args['id_prefix'],
		'section_class'    => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_campaign' ]  = array(
		'name'             => __( 'Campaign', 'better-studio' ),
		'id'               => $args['id_prefix'] . '_campaign',
		'desc'             => __( 'Choose campaign.', 'better-studio' ),
		'type'             => 'select',
		'std'              => 'none',
		'deferred-options' => array(
			'callback' => 'better_ads_get_campaigns_option',
			'args'     => array(
				- 1,
				true
			),
		),
		'show_on'          => array(
			array(
				$args['id_prefix'] . '_type=campaign'
			),
		),
		'_show_on_parent'  => $args['id_prefix'] . '_type',
		'ad-id'            => $args['id_prefix'],
		'section_class'    => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_count' ]     = array(
		'name'            => __( 'Max Amount of Allowed Banners', 'better-studio' ),
		'id'              => $args['id_prefix'] . '_count',
		'desc'            => __( 'How many banners are allowed?.', 'better-studio' ),
		'input-desc'      => __( 'Leave empty to show all banners.', 'better-studio' ),
		'type'            => 'text',
		'std'             => 1,
		'show_on'         => array(
			array(
				$args['id_prefix'] . '_type=campaign'
			),
		),
		'_show_on_parent' => $args['id_prefix'] . '_type',
		'ad-id'           => $args['id_prefix'],
		'section_class'   => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_columns' ]   = array(
		'name'            => __( 'Columns', 'better-studio' ),
		'id'              => $args['id_prefix'] . '_columns',
		'desc'            => __( 'Show ads in multiple columns.', 'better-studio' ),
		'type'            => 'select',
		"options"         => array(
			1 => __( '1 Column', 'better-studio' ),
			2 => __( '2 Column', 'better-studio' ),
			3 => __( '3 Column', 'better-studio' ),
		),
		'std'             => 1,
		'show_on'         => array(
			array(
				$args['id_prefix'] . '_type=campaign'
			),
		),
		'_show_on_parent' => $args['id_prefix'] . '_type',
		'ad-id'           => $args['id_prefix'],
		'section_class'   => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_orderby' ]   = array(
		'name'            => __( 'Order By', 'better-studio' ),
		'id'              => $args['id_prefix'] . '_orderby',
		'type'            => 'select',
		"options"         => array(
			'date'  => __( 'Date', 'better-studio' ),
			'title' => __( 'Title', 'better-studio' ),
			'rand'  => __( 'Random (Rotate)', 'better-studio' ),
		),
		'std'             => 'rand',
		'show_on'         => array(
			array(
				$args['id_prefix'] . '_type=campaign'
			),
		),
		'_show_on_parent' => $args['id_prefix'] . '_type',
		'ad-id'           => $args['id_prefix'],
		'section_class'   => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_order' ]     = array(
		'name'            => __( 'Order', 'better-studio' ),
		'id'              => $args['id_prefix'] . '_order',
		'type'            => 'select',
		"options"         => array(
			'ASC'  => __( 'Ascending', 'better-studio' ),
			'DESC' => __( 'Descending', 'better-studio' ),
		),
		'std'             => 'ASC',
		'show_on'         => array(
			array(
				$args['id_prefix'] . '_type=campaign'
			),
		),
		'_show_on_parent' => $args['id_prefix'] . '_type',
		'ad-id'           => $args['id_prefix'],
		'section_class'   => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_align' ]     = array(
		'name'            => __( 'Align', 'better-studio' ),
		'desc'            => __( 'Choose align of ad.', 'better-studio' ),
		'id'              => $args['id_prefix'] . '_align',
		'type'            => 'select',
		"options"         => array(
			'left'   => __( 'Left', 'better-studio' ),
			'center' => __( 'Center', 'better-studio' ),
			'right'  => __( 'Right', 'better-studio' ),
		),
		'std'             => 'center',
		'show_on'         => array(
			array(
				$args['id_prefix'] . '_type=banner',
			),
			array(
				$args['id_prefix'] . '_type=campaign',
			),
		),
		'_show_on_parent' => $args['id_prefix'] . '_type',
		'ad-id'           => $args['id_prefix'],
		'section_class'   => 'better-ads-ad-field',
	);
	$fields[ $args['id_prefix'] . '_lazy-load' ] = array(
		'name'            => __( 'Lazy Load Ad?', 'better-studio' ),
		'desc'            => __( 'Chose the behaviour of lazy loading.', 'better-studio' ),
		'id'              => $args['id_prefix'] . '_lazy-load',
		'type'            => 'select',
		"options"         => array(
			''        => __( '-- Inherit from panel --', 'better-studio' ),
			'enable'  => __( 'Yes, Lazy load this ad', 'better-studio' ),
			'disable' => __( 'No, Load this Ad as normal', 'better-studio' ),
		),
		'std'             => 'center',
		'show_on'         => array(
			array(
				$args['id_prefix'] . '_type=banner',
			),
			array(
				$args['id_prefix'] . '_type=campaign',
			),
		),
		'_show_on_parent' => $args['id_prefix'] . '_type',
		'ad-id'           => $args['id_prefix'],
		'section_class'   => 'better-ads-ad-field',
	);


	if ( ! empty( $args['end_fields'] ) ) {
		foreach ( (array) $args['end_fields'] as $field_id => $field_val ) {
			$fields[ $field_id ] = $field_val;
		}
	}

	if ( $args['group'] && $args['group_auto_close'] ) {
		$fields[] = array(
			'type' => 'group_close',
		);
	}
}


/**
 * Handy function to add Ad location reperator ad field to panel by it's prefix
 *
 * @param       $fields
 * @param array $args
 */
function better_ads_inject_ad_repeater_field_to_fields( &$fields, $args = array() ) {

	if ( is_string( $args ) ) {
		$args = array(
			'id_prefix' => $args,
		);
	}

	$args = bf_merge_args( $args, array(
		'id_prefix'              => '',
		'group'                  => true,
		'group_state'            => 'close',
		'group_title'            => __( 'Ad', 'better-studio' ),
		'group_auto_close'       => true,
		'group_desc'             => '',
		'field_title'            => '',
		'field_desc'             => '',
		'field_add_label'        => '<i class="fa fa-plus"></i> ' . __( 'New Ad', 'better-studio' ),
		'field_delete_label'     => __( 'Delete Ad', 'better-studio' ),
		'field_item_title'       => __( 'Ad', 'better-studio' ),
		'field_item_smart_title' => true,
		'start_fields'           => '',
		'format'                 => 'normal',
	) );

	if ( empty( $args['id_prefix'] ) ) {
		return;
	}

	if ( $args['group'] ) {
		$fields[] = array(
			'name'  => $args['group_title'],
			'type'  => 'group',
			'state' => $args['group_state'],
			'desc'  => $args['group_desc'],
		);
	}

	if ( ! empty( $args['start_fields'] ) ) {
		foreach ( (array) $args['start_fields'] as $field_id => $field_val ) {
			$fields[ $field_id ] = $field_val;
		}
	}

	$repeater_items = array();

	if ( ! empty( $args['field_start_fields'] ) ) {
		foreach ( (array) $args['field_start_fields'] as $field_id => $field_val ) {
			$repeater_items[ $field_id ] = $field_val;
		}
	}

	$repeater_items['type']      = array(
		'name'          => __( 'Ad Type', 'better-studio' ),
		'id'            => 'type',
		'desc'          => __( 'Choose campaign or banner.', 'better-studio' ),
		'type'          => 'select',
		'options'       => array(
			''         => __( '-- Select Ad Type --', 'better-studio' ),
			'campaign' => __( 'Campaign', 'better-studio' ),
			'banner'   => __( 'Banner', 'better-studio' ),
		),
		'repeater_item' => true,
		'ad-id'         => $args['id_prefix'],
	);
	$repeater_items['campaign']  = array(
		'name'             => __( 'Campaign', 'better-studio' ),
		'id'               => 'campaign',
		'desc'             => __( 'Choose campaign.', 'better-studio' ),
		'type'             => 'select',
		'deferred-options' => array(
			'callback' => 'better_ads_get_campaigns_option',
			'args'     => array(
				- 1,
				true,
				$args['format']
			),
		),
		'show_on'          => array(
			array(
				'type=campaign'
			),
		),
		'repeater_item'    => true,
		'ad-id'            => $args['id_prefix'],
	);
	$repeater_items['banner']    = array(
		'name'             => __( 'Banner', 'better-studio' ),
		'id'               => 'banner',
		'desc'             => __( 'Choose banner.', 'better-studio' ),
		'type'             => 'select',
		'deferred-options' => array(
			'callback' => 'better_ads_get_banners_option',
			'args'     => array(
				- 1,
				true,
				$args['format']
			),
		),
		'show_on'          => array(
			array(
				'type=banner'
			),
		),
		'repeater_item'    => true,
		'ad-id'            => $args['id_prefix'],
	);
	$repeater_items['count']     = array(
		'name'          => __( 'Max Amount of Allowed Banners', 'better-studio' ),
		'id'            => 'count',
		'desc'          => __( 'How many banners are allowed?.', 'better-studio' ),
		'input-desc'    => __( 'Leave empty to show all banners.', 'better-studio' ),
		'type'          => 'text',
		'show_on'       => array(
			array(
				'type=campaign'
			),
		),
		'repeater_item' => true,
		'ad-id'         => $args['id_prefix'],
	);
	$repeater_items['columns']   = array(
		'name'          => __( 'Columns', 'better-studio' ),
		'id'            => 'columns',
		'desc'          => __( 'Show ads in multiple columns.', 'better-studio' ),
		'type'          => 'select',
		"options"       => array(
			1 => __( '1 Column', 'better-studio' ),
			2 => __( '2 Column', 'better-studio' ),
			3 => __( '3 Column', 'better-studio' ),
		),
		'show_on'       => array(
			array(
				'type=campaign'
			),
		),
		'repeater_item' => true,
		'ad-id'         => $args['id_prefix'],
	);
	$repeater_items['orderby']   = array(
		'name'          => __( 'Order By', 'better-studio' ),
		'id'            => 'orderby',
		'type'          => 'select',
		"options"       => array(
			'date'  => __( 'Date', 'better-studio' ),
			'title' => __( 'Title', 'better-studio' ),
			'rand'  => __( 'Rand', 'better-studio' ),
		),
		'show_on'       => array(
			array(
				'type=campaign'
			),
		),
		'repeater_item' => true,
		'ad-id'         => $args['id_prefix'],
	);
	$repeater_items['order']     = array(
		'name'          => __( 'Order', 'better-studio' ),
		'id'            => 'order',
		'type'          => 'select',
		"options"       => array(
			'ASC'  => __( 'Ascending', 'better-studio' ),
			'DESC' => __( 'Descending', 'better-studio' ),
		),
		'show_on'       => array(
			array(
				'type=campaign'
			),
		),
		'repeater_item' => true,
		'ad-id'         => $args['id_prefix'],
	);
	$repeater_items['align']     = array(
		'name'          => __( 'Align', 'better-studio' ),
		'id'            => 'align',
		'desc'          => __( 'Choose align of ad.', 'better-studio' ),
		'type'          => 'select',
		'options'       => array(
			'left'   => __( 'Left Align', 'better-studio' ),
			'center' => __( 'Center Align', 'better-studio' ),
			'right'  => __( 'Right Align', 'better-studio' ),
		),
		'show_on'       => array(
			array(
				'type=banner',
			),
			array(
				'type=campaign',
			),
		),
		'repeater_item' => true,
		'ad-id'         => $args['id_prefix'],
	);
	$repeater_items['lazy-load'] = array(
		'name'          => __( 'Lazy Load Ad?', 'better-studio' ),
		'desc'          => __( 'Chose the behaviour of lazy loading.', 'better-studio' ),
		'id'            => 'lazy-load',
		'type'          => 'select',
		"options"       => array(
			''        => __( '-- Inherit from panel --', 'better-studio' ),
			'enable'  => __( 'Yes, Lazy load this ad', 'better-studio' ),
			'disable' => __( 'No, Load this Ad as normal', 'better-studio' ),
		),
		'std'           => 'center',
		'show_on'       => array(
			array(
				'type=banner',
			),
			array(
				'type=campaign',
			),
		),
		'ad-id'         => $args['id_prefix'],
		'repeater_item' => true,
	);


	if ( ! empty( $args['field_end_fields'] ) ) {
		foreach ( (array) $args['field_end_fields'] as $field_id => $field_val ) {
			$repeater_items[ $field_id ] = $field_val;
		}
	}

	$fields[ $args['id_prefix'] ] = array(
		'name'          => $args['field_title'],
		'desc'          => $args['field_desc'],
		'id'            => $args['id_prefix'],
		'type'          => 'repeater',
		'save-std'      => true,
		'default'       => array(
			array(
				'type'      => '',
				'campaign'  => 'none',
				'banner'    => 'none',
				'paragraph' => 3,
				'count'     => 3,
				'columns'   => 3,
				'orderby'   => 'rand',
				'order'     => 'ASC',
				'align'     => 'center',
				'lazy-load' => '',
				'post_type' => '',
			),
		),
		'add_label'     => $args['field_add_label'],
		'delete_label'  => $args['field_delete_label'],
		'item_title'    => $args['field_item_title'],
		'section_class' => 'full-with-both' . ( $args['field_item_smart_title'] ? ' better-ads-repeater-ad-field' : '' ),
		'options'       => $repeater_items,
		'ad-id'         => $args['id_prefix'],
	);

	if ( ! empty( $args['end_fields'] ) ) {
		foreach ( (array) $args['end_fields'] as $field_id => $field_val ) {
			$fields[ $field_id ] = $field_val;
		}
	}

	if ( $args['group'] && $args['group_auto_close'] ) {
		$fields[] = array(
			'type' => 'group_close',
		);
	}

}


/**
 * Shows ad location code by its panel prefix or data
 *
 * @param string $panel_ad_prefix
 * @param null   $ad_data
 * @param array  $args
 */
function better_ads_show_ad_location( $panel_ad_prefix = '', $ad_data = null, $args = array() ) {

	if ( empty( $panel_ad_prefix ) ) {
		return;
	}

	if ( is_null( $ad_data ) || ! is_array( $ad_data ) ) {
		$ad_data = better_ads_get_ad_location_data( $panel_ad_prefix );
	}

	if ( ! empty( $args['container-class'] ) ) {
		if ( ! empty( $ad_data['container-class'] ) ) {
			$ad_data['container-class'] .= ' ' . $args['container-class'] . ' better-ads-loc-' . $panel_ad_prefix;
		} else {
			$ad_data['container-class'] = $args['container-class'] . ' better-ads-loc-' . $panel_ad_prefix;
		}
	} else {
		$ad_data['container-class'] = 'better-ads-loc-' . $panel_ad_prefix;
	}

	echo Better_Ads_Manager()->show_ads( $ad_data );
}


/**
 * Returns full list of Ad location data from it's prefix inside panel
 *
 * @param string     $panel_ad_prefix
 * @param bool       $multiple
 * @param array|null $extra_fields Extra fields related to this ad location
 *
 * @return array
 */
function better_ads_get_ad_location_data( $panel_ad_prefix = '', $multiple = false, $extra_fields = null ) {

	// Disabled for this item -> not matters for all or not
	if ( ! better_ads_ad_can_be_shown( 'ad-location' ) ) {
		return better_ads_get_ad_data_default( $extra_fields );
	}

	return better_ads_get_ad_data( $panel_ad_prefix, $multiple, $extra_fields );
}


/**
 * Checks the ad can be shown on page based on the location and the disable feature
 * .
 *
 * @param string $type
 *
 * @return bool
 */
function better_ads_ad_can_be_shown( $type = '' ) {

	$func         = '';
	$object       = '';
	$object_id    = null;
	$disable_all  = '';
	$disable_item = '';

	if ( is_singular() ) {
		$func   = 'bf_get_post_meta';
		$object = get_post_type();
	} elseif ( is_archive() ) {

		$queried_object = get_queried_object();

		if ( ! empty( $queried_object->taxonomy ) ) {
			$func   = 'bf_get_term_meta';
			$object = $queried_object->taxonomy;
		} elseif ( is_date() ) {
			$object = 'date';
		} // WooCommerce shop page is a exception because the page ID is not the same as the value of get_the_ID()
		elseif ( function_exists( 'is_woocommerce' ) && is_woocommerce() && is_shop() ) {
			$func      = 'bf_get_post_meta';
			$object    = 'page';
			$object_id = get_option( 'woocommerce_shop_page_id' );
		}
	} elseif ( is_search() ) {
		$object = 'search';
	} elseif ( is_404() ) {
		$object = '404';
	} elseif ( is_home() ) {
		$object = 'home';
	}

	//
	// Disabled for all items
	//
	if ( ! empty( $object ) ) {
		$disable_all = Better_Ads_Manager::get_option( $object . '_disable_all' );
	}

	//
	// Disabled for this item
	//
	if ( ! empty( $func ) ) {

		$disable_loc = '';

		if ( $type == 'ad-location' ) {
			$disable_loc = call_user_func( $func, 'bam_disable_locations', $object_id );
		} elseif ( $type == 'widget' ) {
			$disable_loc = call_user_func( $func, 'bam_disable_widgets', $object_id );
		} elseif ( $type == 'shortcode' ) {
			$disable_loc = call_user_func( $func, 'bam_disable_post_content', $object_id );
		}

		$disable_item = $disable_loc;

		// not 'show' or '1'
		// mean it show for location -> highest priority
		if ( $disable_loc == '' ) {
			$disable_item = call_user_func( $func, 'bam_disable_all', $object_id );
		}

		// '1' means hide
		// '' and 'show' mean Show
		if ( $disable_item == 1 ) {
			$disable_item = 'hide';
		}

		//
		// $disable_item == ''      ->  show    ->  panel have priority
		// $disable_item == '1'     ->  hide    ->  hide it, more priority than panel
		// $disable_item == 'show'  ->  show    ->  show it, more priority than panel
		//
	}

	// Disabled for this item -> not matters for all or not
	if ( $disable_item == 'hide' ) {
		return false;
	} // Disabled for all items but this item made it enable!
	elseif ( $disable_all && $disable_item != 'show' ) {
		return false;
	}

	return true;
}


if ( ! function_exists( 'better_ads_get_ad_data_default' ) ) {
	/**
	 * returns base data for ad banner!
	 *
	 * @param array|null $extra_fields Extra fields related to this ad location
	 *
	 * @return array
	 */
	function better_ads_get_ad_data_default( $extra_fields = null ) {

		$fields = array(
			'type'            => '',
			'banner'          => '',
			'campaign'        => '',
			'count'           => '',
			'columns'         => '',
			'orderby'         => '',
			'order'           => '',
			'align'           => '',
			'lazy-load'       => '',
			'active_location' => false,
		);

		if ( ! is_null( $extra_fields ) ) {
			$fields = bf_merge_args( $fields, $extra_fields );
		}

		return $fields;
	}
}


if ( ! function_exists( 'better_ads_get_ad_data_override' ) ) {
	/**
	 * Returns data for ad location (even overidded data)
	 *
	 * @param string $panel_ad_prefix
	 * @param bool   $multiple
	 * @param string $type
	 * @param null   $extra_fields Extra fields for current ad location
	 *
	 * @return array
	 */
	function better_ads_get_ad_data_override( $panel_ad_prefix = '', $multiple = false, $type = 'ad-location', $extra_fields = null ) {

		$data_ids = better_ads_get_ad_data_default( $extra_fields );

		$object_id   = 0;
		$object_type = '';
		$override_id = false;
		$data        = array();
		$data_filled = false;

		//
		// Find override ID for current page
		//
		if ( is_home() && is_front_page() ) {
			$override_id = 'home';
			$object_type = 'home';
		} elseif ( is_front_page() ) {

			global $wp_query;

			if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && $wp_query->is_page( get_option( 'page_on_front' ) ) ) {
				$override_id = get_post_type();
				$object_id   = get_queried_object_id();
				$object_type = 'post';
			} else {
				$queried_object = get_queried_object();

				if ( ! empty( $queried_object->name ) ) {
					$override_id = $queried_object->name;
				}
			}
		} elseif ( is_singular() ) {
			if ( get_post_type() ) {
				$override_id = get_post_type();
				$object_id   = get_queried_object_id();
				$object_type = 'post';
			}
		} elseif ( is_post_type_archive() ) {

			$queried_object = get_queried_object();

			if ( ! empty( $queried_object->name ) ) {
				$override_id = $queried_object->name;
			}

		} elseif ( is_archive() ) {

			$queried_object = get_queried_object();

			if ( ! empty( $queried_object->taxonomy ) ) {
				$override_id = $queried_object->taxonomy;
				$object_id   = $queried_object->term_id;
				$object_type = 'taxonomy';
			} elseif ( is_date() ) {
				$override_id = 'date';
				$object_type = 'date';
			}
		} elseif ( is_search() ) {
			$override_id = 'search';
			$object_type = 'search';
		} elseif ( is_404() ) {
			$override_id = '404';
			$object_type = '404';
		}


		/**
		 * TODO: Refactor, DRY!
		 */
		if ( $multiple ) {

			if ( $override_id && $object_type === 'post' &&
			     bf_get_post_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix . '-active', $object_id )
			) {

				$data = bf_get_post_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix, $object_id );

			} elseif ( $override_id && $object_type === 'taxonomy' &&
			           bf_get_term_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix . '-active', $object_id )
			) {

				$data = bf_get_term_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix, $object_id );

			} elseif ( $override_id && Better_Ads_Manager::get_option( 'ovr_' . $override_id . '-' . $panel_ad_prefix . '-active' ) ) {


				$data = Better_Ads_Manager::get_option( 'ovr_' . $override_id . '-' . $panel_ad_prefix );

			} else {
				$data = Better_Ads_Manager::get_option( $panel_ad_prefix );
			}

		} else {


			if ( $type == 'ad-location' ) {

				$ad_active_id = 'ovr_' . $override_id . '-' . $panel_ad_prefix . '-active';


				if ( $override_id && $object_type === 'post' ) {

					//
					// The post itself overridden the ad
					//
					if ( bf_get_post_meta( $ad_active_id, $object_id ) ) {
						foreach ( $data_ids as $id => $value ) {
							$data[ $id ] = bf_get_post_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix . '_' . $id, $object_id );
						}

						$data_filled = true;
					} else {

						//
						// iterate all taxonomies of current post to find first term that overridden the ad
						//
						foreach ( get_post_taxonomies( $object_id ) as $taxonomy ) {

							// data filled in prev taxonomy
							if ( $data_filled ) {
								break;
							}

							// Exceptions
							{
								$_check = array(
									'post_format' => '',
									'post_tag'    => '',
								);

								if ( isset( $_check[ $taxonomy ] ) ) {
									continue;
								}
							}

							$terms = wp_get_post_terms( $object_id, $taxonomy );

							// todo add default category support

							// issue in terms
							if ( is_wp_error( $terms ) ) {
								continue;
							}

							foreach ( $terms as $term ) {

								// not override in this term
								if ( ! bf_get_term_meta( 'ovr_' . $taxonomy . '-' . $panel_ad_prefix . '-active', $term->term_id ) ) {
									continue;
								}

								// collects data of overridden ad from term
								foreach ( $data_ids as $id => $value ) {
									$data[ $id ] = bf_get_term_meta( 'ovr_' . $taxonomy . '-' . $panel_ad_prefix . '_' . $id, $term->term_id );
								}

								$data_filled = true;
								break;
							}


						}
					}
				}


				//
				// Taxonomy
				//
				if ( ! $data_filled && $override_id && $object_type === 'taxonomy' &&
				     bf_get_term_meta( $ad_active_id, $object_id )
				) {

					foreach ( $data_ids as $id => $value ) {
						$data[ $id ] = bf_get_term_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix . '_' . $id, $object_id );
					}

					$data_filled = true;
				}

				//
				// Option ad location
				//
				if ( ! $data_filled && $override_id && Better_Ads_Manager::get_option( $ad_active_id ) ) {

					foreach ( $data_ids as $id => $value ) {
						$data[ $id ] = Better_Ads_Manager::get_option( 'ovr_' . $override_id . '-' . $panel_ad_prefix . '_' . $id );
					}

					$data_filled = true;
				}

				//
				// exact option
				//
				if ( ! $data_filled ) {

					foreach ( $data_ids as $id => $value ) {
						$data[ $id ] = Better_Ads_Manager::get_option( $panel_ad_prefix . '_' . $id );
					}
				}
			} elseif ( $type === 'option' ) {

				$data = '___default___';

				if ( $override_id && $object_type === 'post' ) {
					$data = bf_get_post_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix, $object_id, $data );
				} elseif ( $override_id && $object_type === 'taxonomy' ) {
					$data = bf_get_term_meta( 'ovr_' . $override_id . '-' . $panel_ad_prefix, $object_id, $data );
				}

				if ( $data === '___default___' || is_null( $data ) ) {
					$data = Better_Ads_Manager::get_option( $panel_ad_prefix );
				}
			}

		}

		return $data;
	} // better_ads_get_ad_data_override
}


/**
 * Returns full list of Ad location data from it's prefix inside panel
 *
 * @param string $panel_ad_prefix
 * @param bool   $multiple
 * @param null   $extra_fields Extra fields related to current ad location
 *
 * @return array
 */
function better_ads_get_ad_data( $panel_ad_prefix = '', $multiple = false, $extra_fields = null ) {

	$data_ids = better_ads_get_ad_data_default( $extra_fields );

	if ( empty( $panel_ad_prefix ) ) {
		return $multiple ? array( $data_ids ) : $data_ids;
	}

	$final_ads = array();
	$data      = better_ads_get_ad_data_override( $panel_ad_prefix, $multiple, 'ad-location', $extra_fields );

	if ( ! $multiple ) {
		$data = array( $data );
	}

	foreach ( $data as $ad_item ) {

		// Type not selected
		if ( empty( $ad_item['type'] ) || $ad_item['type'] === 'none' ) {
			continue;
		}

		// Banner not selected
		if ( $ad_item['type'] === 'banner' && ( empty( $ad_item['banner'] ) || $ad_item['banner'] === 'none' ) ) {
			continue;
		} // Campaign not selected
		elseif ( $ad_item['type'] === 'campaign' && ( empty( $ad_item['campaign'] ) || $ad_item['campaign'] == 'none' ) ) {
			continue;
		}

		// Post type is not valid
		if ( ! empty( $ad_item['post_type'] ) ) {
			foreach ( explode( ',', $ad_item['post_type'] ) as $post_type ) {
				if ( ! is_singular( $post_type ) ) {
					continue;
				}
			}
		}

		$ad_item['active_location'] = true;

		if ( empty( $ad_item['align'] ) ) {
			$ad_item['align'] = 'center';
		}

		if ( bf_is_doing_ajax() ) {
			$ad_item['lazy-load'] = 'disable';
		} elseif ( empty( $ad_item['lazy-load'] ) ) {
			$ad_item['lazy-load'] = Better_Ads_Manager::get_option( 'lazy_loading_ads' );
		}


		$final_ads[] = $ad_item;
	}

	// return default ID's
	if ( empty( $final_ads ) ) {
		return $multiple ? array( $data_ids ) : $data_ids;
	}

	if ( $multiple ) {
		return $final_ads;
	}

	return current( $final_ads );
}


if ( ! function_exists( 'better_ads_extract_google_ad_code_data' ) ) {
	/**
	 * Handy function to fetching data from Google Adsense code.
	 *
	 * @param $code
	 *
	 * @return array
	 */
	function better_ads_extract_google_ad_code_data( $code ) {

		$data = array(
			'ad-client'             => '',
			'ad-layout'             => '',
			'ad-slot'               => '',
			'ad-format'             => '',
			'ad-layout-key'         => '',
			'style'                 => '',
			'full-width-responsive' => '',
		);

		$code = strtolower( $code );


		/**
		 *
		 * data-ad-client
		 *
		 * Format 1: <ins class="adsbygoogle" data-ad-client="*" ></ins>
		 *
		 * Format 2: <script> google_ad_client = "*"; </script>
		 *
		 */
		{
			// Format 1
			{
				preg_match( '/data-ad-client="(.*)"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['ad-client'] = $matches[1];
				}
			}

			// Other format: google_ad_client = "*";
			if ( empty( $data['ad-client'] ) ) {

				preg_match( '/google_ad_client\s*=\s*"\s*(.*)\s*"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['ad-client'] = $matches[1];
				}
			}
		}


		/**
		 *
		 * data-ad-slot
		 *
		 * Format 1: <ins class="adsbygoogle" data-ad-slot="*" ></ins>
		 *
		 * Format 2: <script> google_ad_slot = "*"; </script>
		 *
		 */
		{
			// Format 1
			{
				preg_match( '/data-ad-slot="(.*)"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['ad-slot'] = $matches[1];
				}
			}

			// Format 2
			if ( empty( $data['ad-slot'] ) ) {

				preg_match( '/google_ad_slot\s*=\s*"\s*(.*)\s*"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['ad-slot'] = $matches[1];
				}
			}
		}


		/**
		 *
		 * data-ad-layout-key
		 *
		 */
		preg_match( '/data-ad-layout-key="(.*)"/', $code, $matches );

		if ( ! empty( $matches[1] ) ) {
			$data['ad-layout-key'] = $matches[1];
		}


		/**
		 *
		 * data-layout
		 *
		 */
		preg_match( '/data-ad-layout="(.*)"/', $code, $matches );

		if ( ! empty( $matches[1] ) ) {
			$data['ad-layout'] = $matches[1];
		}


		/**
		 *
		 * data-ad-format
		 *
		 */
		preg_match( '/data-ad-format="(.*)"/', $code, $matches );

		if ( ! empty( $matches[1] ) ) {
			$data['ad-format'] = $matches[1];
		}

		$_check = array(
			'vertical'    => '',
			'horizontal'  => '',
			'rectangle'   => '',
			'fluid'       => '',
			'autorelaxed' => '',
			'auto'        => '',
		);

		if ( empty( $data['ad-format'] ) || ! isset( $_check[ $data['ad-format'] ] ) ) {
			$data['ad-format'] = 'auto';
		}


		/**
		 *
		 * data-full-width-responsive
		 *
		 */
		preg_match( '/data-full-width-responsive="(.*)"/', $code, $matches );

		if ( ! empty( $matches[1] ) ) {
			$data['full-width-responsive'] = $matches[1];
		}

		$_check = array(
			'false' => '',
			'true'  => '',
			''      => '',
		);
		if ( ! isset( $_check[ $data['full-width-responsive'] ] ) ) {
			$data['full-width-responsive'] = '';
		}


		/**
		 *
		 * style
		 *
		 */
		preg_match( '/style="(.*)"/', $code, $matches );

		if ( ! empty( $matches[1] ) ) {
			$data['style'] = $matches[1];
		}


		/**
		 *
		 * Matched Content Customization Attrs
		 *
		 */
		{

			/**
			 * matched-content-ui-type
			 */
			{
				preg_match( '/data-matched-content-ui-type="(.*)"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['matched-content-ui-type'] = $matches[1];
				}
			}

			/**
			 * matched-content-rows-num
			 */
			{
				preg_match( '/data-matched-content-rows-num="(.*)"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['matched-content-rows-num'] = $matches[1];
				}
			}

			/**
			 * matched-content-columns-num
			 */
			{
				preg_match( '/data-matched-content-columns-num="(.*)"/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['matched-content-columns-num'] = $matches[1];
				}
			}
		}


		/**
		 *
		 * Style width
		 *
		 * Format 1: <ins class="adsbygoogle" style="width:728px" ></ins>
		 *
		 * Format 2: <script> google_ad_width = 728; </script>
		 *
		 */
		if ( empty( $data['width'] ) ) {

			// Format 1
			{
				preg_match( '/[^-]width[: ]+([0-9]+)[px]/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['width'] = $matches[1];
				}
			}

			// Format 2
			if ( empty( $data['width'] ) ) {
				preg_match( '/google_ad_width\s*=\s*(\d*)\s*;/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['width'] = $matches[1];
				}
			}
		}


		/**
		 *
		 * Style height
		 *
		 * Format 1: <ins class="adsbygoogle" style="height:90px" ></ins>
		 *
		 * Format 2: <script> google_ad_height = 90; </script>
		 *
		 */
		if ( empty( $data['height'] ) ) {

			// Format 1
			{
				preg_match( '/[^-]height[: ]+([0-9]+)[px]/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['height'] = $matches[1];
				}
			}

			// Format 2
			if ( empty( $data['height'] ) ) {
				preg_match( '/google_ad_height\s*=\s*(\d*)\s*;/', $code, $matches );

				if ( ! empty( $matches[1] ) ) {
					$data['height'] = $matches[1];
				}
			}
		}

		return $data;
	} // better_ads_extract_google_ad_code_data
}


if ( ! function_exists( 'bam_deferred_dfp_spot_options' ) ) {
	/**
	 * Callback for banner options. Extracts spots from list and shows them to user for easy to use.
	 *
	 * @param array $args
	 *
	 * @return array
	 */
	function bam_deferred_dfp_spot_options( $args = array() ) {

		$options = array(
			''       => __( '-- Select Spot --', 'better-studio' ),
			'custom' => __( 'Custom Code', 'better-studio' ),
		);

		$dfp_code = Better_Ads_Manager::get_option( 'dfp_code' );

		if ( ! empty( $dfp_code ) ) {
			preg_match_all( '#defineSlot\((.*)\).addService#', $dfp_code, $dfp_spots );
		} else {
			$dfp_spots = array();
		}

		$group = array(
			'label'   => __( 'Auto detected DFP spots', 'better-studio' ),
			'options' => array()
		);

		if ( ! empty( $dfp_spots[1] ) ) {
			foreach ( $dfp_spots[1] as $_spot ) {
				$group['options'][ str_replace( ',', '--', $_spot ) ] = $_spot;
			}
		}

		if ( empty( $group['options'] ) ) {
			$group['options']['not-detected'] = array(
				'label'    => __( 'Please enter DFP code into Better Ads Manager panle', 'better-studio' ),
				'disabled' => true,
			);
		}

		$options[] = $group;

		return $options;
	}
}


if ( ! function_exists( 'better_ads_get_override_sections_list' ) ) {
	/**
	 * Returns list of items that can be overridden
	 *
	 * @return array
	 */
	function better_ads_get_override_sections_list() {

		static $sections;

		if ( $sections ) {
			return $sections;
		}

		$sections = array(
			'post_type'     => array(
				'label' => 'Post Types',
				'items' => array(),
			),
			'taxonomy'      => array(
				'label' => 'Taxonomies',
				'items' => array(),
			),
			'general_pages' => array(
				'label' => 'General Pages',
				'items' => array(),
			),
		);


		//
		// CPT's
		//
		{
			$post_types = array_diff_key(
				get_post_types(
					array(
						'public' => true,
					)
				),
				array(
					'attachment' => 0,
				)
			);


			foreach ( $post_types as $cpt_id ) {

				$post_type = get_post_type_object( $cpt_id );

				$sections['post_type']['items'][ $cpt_id ] = array(
					'id'           => $cpt_id,
					'label'        => $post_type->labels->singular_name,
					'label_plural' => $post_type->labels->name,
				);
			}

			ksort( $sections['post_type']['items'] );
		}


		//
		// Taxonomy
		//
		{
			$taxonomies = array_diff_key(
				get_taxonomies(
					array(
						'public' => true,
					)
				),
				array(
					'nav_menu'               => 0,
					'link_category'          => 0,
					'post_format'            => 0,
					'product_shipping_class' => 0,
					'product_type'           => 0,
				)
			);

			foreach ( $taxonomies as $tax_id ) {
				$tax = get_taxonomy( $tax_id );

				$sections['taxonomy']['items'][ $tax_id ] = array(
					'id'           => $tax_id,
					'label'        => $tax->labels->singular_name,
					'label_plural' => $tax->labels->name,
				);
			}

			ksort( $sections['taxonomy']['items'] );
		}


		//
		// General Pages
		//
		{
			// Non-static Homepage
			$sections['general_pages']['items']['home'] = array(
				'id'           => 'home',
				'label'        => 'Non-Static Homepage',
				'label_plural' => 'Non-Static Homepage',
			);

			// Search page
			$sections['general_pages']['items']['search'] = array(
				'id'           => 'search',
				'label'        => 'Search Page',
				'label_plural' => 'Search Pages',
			);

			// Date archive pages
			$sections['general_pages']['items']['date'] = array(
				'id'           => 'date',
				'label'        => 'Date Archive Page',
				'label_plural' => 'Date Archive Pages',
			);

			// 404 page
			$sections['general_pages']['items']['404'] = array(
				'id'           => '404',
				'label'        => '404 Page',
				'label_plural' => '404 Pages',
			);
		}

		return $sections;
	} // better_ads_get_override_sections_list
}


if ( ! function_exists( 'better_ads_get_override_fields_list' ) ) {
	/**
	 * Creates fields list of a overriden section
	 *
	 * @param array $fields
	 * @param array $args
	 *
	 * @return array
	 */
	function better_ads_get_override_fields_list( $fields = array(), $args = array() ) {

		$section_fields = array();

		//
		// Loads fields from filter
		//
		if ( empty( $fields ) ) {
			$fields = apply_filters( 'better-framework/panel/better_ads_manager/fields', array() );
		}

		//
		// Remove extra field or not!
		//
		if ( isset( $args['type'] ) ) {
			$exclude_extra_fields_type = $args['type'];
			$exclude_extra_fields      = true;
		} elseif ( bf_is_doing_ajax() && isset( $_REQUEST['type'] ) ) {
			$exclude_extra_fields_type = $_REQUEST['type'];
			$exclude_extra_fields      = true;
		} else {
			$exclude_extra_fields_type = false;
			$exclude_extra_fields      = false;
		}

		$exclude_to_next_tab = false;

		// Converts tabs and groups to be nested fields
		foreach ( $fields as $field_id => $field ) {

			// from start to DFP or AMP ads
			if ( ! empty( $field['id'] ) && ( $field['id'] === 'dfp_settings' || $field['id'] === 'amp_ads' || $field['id'] === 'override_settings' ) ) {
				break;
			}

			//
			// Remove extra and unneeded override fields.
			// For example post ads in taxonomy does not sense!
			//
			if ( $exclude_extra_fields ) {

				// Note: Commented because we added override tax ads inside their posts and because of that
				//       the posts ads needed to be overridden.
				//
				// Taxonomy and Inside Post Ads
				//if ( $exclude_extra_fields_type === 'taxonomy' && ! empty( $field['id'] ) && $field['id'] === 'post_ads_tab' ) {
				//	$exclude_to_next_tab = TRUE;
				//	continue;
				//} // Metabox and After X Post Ads (archive ads)
				if ( ( $exclude_extra_fields_type === 'metabox' || $exclude_extra_fields_type === 'post_type' ) && ! empty( $field['id'] ) && $field['id'] === 'after_x_post_ad_tab' ) {
					$exclude_to_next_tab = true;
					continue;
				}

				// Exclude all field to the next tab field.
				if ( $exclude_to_next_tab ) {
					if ( ! isset( $field['type'] ) || $field['type'] !== 'tab' ) {
						continue;
					} else {
						$exclude_to_next_tab = false;
					}
				}
			}


			// exclude specific fields
			if ( isset( $field['exclude-in-override'] ) && $field['exclude-in-override'] ) {
				continue;
			}

			if ( ! empty( $field['type'] ) ) {
				if ( $field['type'] === 'tab' ) {
					$field['type']  = 'group';
					$field['level'] = 2;
					$field['state'] = 'close';
					unset( $field['ajax-tab'] );
				} elseif ( $field['type'] === 'group' ) {
					$field['level'] = 4;
					$field['type']  = 'group';
					$field['state'] = 'close';
				} elseif ( $field['type'] === 'heading' ) {
					$field['type']  = 'group';
					$field['level'] = 3;
					$field['state'] = 'close';
				}
			}

			$field['ajax-tab-field'] = 'override_settings';

			$section_fields[ $field_id ] = $field;
		}

		return $section_fields;

	} // better_ads_get_override_fields_list
}


if ( ! function_exists( 'better_ads_inject_override_ad_section_fields' ) ) {
	/**
	 * Creates overridable fields for a section
	 *
	 * @param array $args
	 *
	 * @return array
	 */
	function better_ads_inject_override_ad_section_fields( $args = array() ) {

		$args = bf_merge_args( $args, array(
			'id'                 => '',
			'name'               => '',
			'fields'             => array(),
			'ajax-section-field' => '',
			'type'               => '',
		) );

		$action             = '';
		$condition_field_id = '';
		$override_fields    = array();
		$closed             = true;

		foreach ( $args['fields'] as $field_k => $field ) {

			// create new ID
			if ( ! empty( $field['id'] ) ) {
				$id = 'ovr_' . $args['id'] . '-' . $field['id'];
			} else {
				$id = $field_k;
			}

			if ( ! isset( $override_fields[ $args['id'] . '_disable_all' ] ) ) {
				$override_fields[ $args['id'] . '_disable_all' ] = array(
					'name'           => sprintf( __( 'Hide all Ads in "%s"', 'better-studio' ), $args['name'] ),
					'desc'           => sprintf( __( 'by enabling this all ads inside "%s" will be disabled and not showing.', 'better-studio' ), $args['name'] ),
					'id'             => $args['id'] . '_disable_all',
					'type'           => 'switch',
					'std'            => 0,
					'ajax-tab-field' => $args['ajax-section-field'],
				);
			}

			//
			// Add condition field for group fields
			//
			if ( $action == 'add condition' ) {

				if ( isset( $field['ad-id'] ) ) {
					$condition_field_id = 'ovr_' . $args['id'] . '-' . $field['ad-id'] . '-active';
				} else {
					$condition_field_id = $id . '-active';
				}

				$override_fields[ $condition_field_id ] = array(
					'name'           => __( 'Override this ad?', 'better-studio' ),
					'desc'           => sprintf( __( 'You can override this ad location for "%s" with enabling this option', 'better-studio' ), $args['name'] ),
					'id'             => $condition_field_id,
					'type'           => 'switch',
					'std'            => 0,
					'ajax-tab-field' => $args['ajax-section-field'],
				);

				//
				// Adds an override ads in the post of taxonomy field to the ad override fields
				//
				if ( $args['type'] === 'taxonomy' ) {

					if ( isset( $field['ad-id'] ) ) {
						$override_child_field_id = 'ovr_' . $args['id'] . '-' . $field['ad-id'] . '-override-in-child';
					} else {
						$override_child_field_id = $id . '-override-in-child';
					}

					$override_fields[ $override_child_field_id ] = array(
						'name'           => __( 'Override inside the Child Posts?', 'better-studio' ),
						'desc'           => sprintf( __( 'By enabling this option the overridden ad will be shows for all posts of this "%s".', 'better-studio' ), $args['name'] ),
						'id'             => $override_child_field_id,
						'type'           => 'switch',
						'std'            => 0,
						'ajax-tab-field' => $args['ajax-section-field'],
						'show_on'        => array(
							array(
								$condition_field_id . '=1'
							)
						)
					);
				}

				$action = 'add filter';

			}


			//
			// Add filter for group fields (show_on)
			//
			if ( $action == 'add filter' && $field['type'] !== 'group' ) {

				//
				// Update old show_on value
				//
				if ( isset( $field['show_on'] ) ) {

					$new_show_on = array();

					if ( ! empty( $field['_show_on_parent'] ) ) {
						$type_id = $field['_show_on_parent'];
						$rep_id  = 'ovr_' . $args['id'] . '-' . $field['_show_on_parent'];
					} else {

						//
						// remove text after last _ to detect the parent field id for replacement
						// We suggest to add "_show_on_parent" to parent.
						//
						$type_id = explode( '_', $field['id'] );
						if ( bf_count( $type_id ) > 1 ) {
							array_pop( $type_id );
						}

						$type_id = implode( '_', $type_id );
						$rep_id  = 'ovr_' . $args['id'] . '-' . $type_id;
					}


					// renames old ID's to new id
					foreach ( $field['show_on'] as $show_l1 ) {

						$_show_l1 = array();

						foreach ( $show_l1 as $show_l2 ) {
							$_show_l1[] = str_replace( $type_id, $rep_id, $show_l2 );
						}

						$new_show_on[] = $_show_l1;
					}


					// add new filter to show on
					foreach ( $new_show_on as $idx => $_ ) {
						$new_show_on[ $idx ][] = $condition_field_id . '=1';
					}
					$field['show_on'] = $new_show_on;

				} else {
					$field['show_on'] = array(
						array(
							$condition_field_id . '=1'
						)
					);
				}

			}


			if ( $field['type'] === 'group' && $field['level'] == 2 ) {
				$override_fields[ $id . '-close' ] = array(
					'type'           => 'group_close',
					'ajax-tab-field' => $args['ajax-section-field'],
					'level'          => 'all',
				);
			}


			if ( $field['type'] !== 'group_close' ) {
				$field['id']             = $id;
				$field['ajax-tab-field'] = $args['ajax-section-field'];
				$override_fields[ $id ]  = $field;
			}


			//
			// auto close for old group
			//
			if ( $field['type'] === 'group' && $field['level'] == 4 && ! $closed ) {
				$override_fields[ $id . '-close' ] = array(
					'type'           => 'group_close',
					'ajax-tab-field' => $args['ajax-section-field'],
				);
				$closed                            = true;
			}


			//
			// group start -> condition field should be added
			//
			if ( $field['type'] === 'group' && $field['level'] == 4 ) {
				$action = 'add condition';
			}


			//
			// End of group -> clear
			//
			elseif ( $field['type'] === 'group_close' ) {
				$action             = '';
				$condition_field_id = '';
				$closed             = true;
			}

		}

		return $override_fields;

	} // better_ads_inject_override_ad_section_fields
}


if ( ! function_exists( 'better_ads_section_override_fields_list' ) ) {
	/**
	 * Prepares fields to opened group in ajax action of panel
	 *
	 * @param $args
	 *
	 * @return array
	 */
	function better_ads_section_override_fields_list( $args ) {

		$section_fields_list = better_ads_get_override_fields_list( array(), $args );

		if ( empty( $args['ajax-section-field'] ) ) {
			$args['ajax-section-field'] = 'ajax-section-field';
		}

		$section_fields = better_ads_inject_override_ad_section_fields( array(
			'id'                 => $args['section'],
			'name'               => $args['section-name'],
			'fields'             => $section_fields_list,
			'ajax-section-field' => $args['ajax-section-field'],
			'type'               => ! empty( $args['type'] ) ? $args['type'] : '',
		) );

		return $section_fields;
	}
}


if ( ! function_exists( 'better_ads_section_disable_fields_list' ) ) {
	/**
	 * Prepares fields to opened group in ajax action of panel
	 *
	 * @param array $fields
	 * @param array $args
	 *
	 * @return array
	 */
	function better_ads_section_disable_fields_list( $fields = array(), $args = array() ) {

		$args = bf_merge_args( $args, array(
			'type' => 'post',
		) );

		$fields['bam_disable_all'] = array(
			'name'    => __( 'Disable All Ads?', 'better-studio' ),
			'id'      => 'bam_disable_all',
			'type'    => 'select',
			'options' => array(
				''     => __( '-- Inherit From Ads Manager Panel --', 'better-studio' ),
				'1'    => __( 'Disable All Ads', 'better-studio' ),
				'show' => __( 'Show All Ads', 'better-studio' ),
			),
			'desc'    => __( 'Hides all ads.', 'better-studio' ),
		);

		$fields['bam_disable_locations'] = array(
			'name'    => __( 'Disable All Ad Locations?', 'better-studio' ),
			'id'      => 'bam_disable_locations',
			'type'    => 'select',
			'options' => array(
				''     => __( '-- Inherit From Ads Manager Panel --', 'better-studio' ),
				'1'    => __( 'Disable All Ads', 'better-studio' ),
				'show' => __( 'Show All Ads', 'better-studio' ),
			),
			'desc'    => __( 'Hides only ad locations.', 'better-studio' ),
		);

		$fields['bam_disable_widgets'] = array(
			'name'    => __( 'Disable All Widgets?', 'better-studio' ),
			'id'      => 'bam_disable_widgets',
			'type'    => 'select',
			'options' => array(
				''     => __( '-- Inherit From Ads Manager Panel --', 'better-studio' ),
				'1'    => __( 'Disable All Ads', 'better-studio' ),
				'show' => __( 'Show All Ads', 'better-studio' ),
			),
			'desc'    => __( 'Hides ad widgets.', 'better-studio' ),
		);

		if ( $args['type'] === 'post' ) {
			$fields['bam_disable_post_content'] = array(
				'name'    => __( 'Disable All Content Ads?', 'better-studio' ),
				'id'      => 'bam_disable_post_content',
				'type'    => 'select',
				'options' => array(
					''     => __( '-- Inherit From Ads Manager Panel --', 'better-studio' ),
					'1'    => __( 'Disable All Ads', 'better-studio' ),
					'show' => __( 'Show All Ads', 'better-studio' ),
				),
				'desc'    => __( 'Hides post content ads.', 'better-studio' ),
			);
		}

		return $fields;
	}
}
<?php
/*
Plugin Name: Better Ads Manager
Plugin URI: http://betterstudio.com
Description: Manage your ads in better way!
Version: 1.19.3
Author: BetterStudio
Author URI: http://betterstudio.com
License:
*/


/**
 * Better_Ads_Manager class wrapper for make changes safe in future
 *
 * @return Better_Ads_Manager
 */
function Better_Ads_Manager() {

	return Better_Ads_Manager::self();
}


// Initialize Better Ads Manager 
Better_Ads_Manager();


/**
 * Class Better_Ads_Manager
 */
class Better_Ads_Manager {


	/**
	 * Contains plugin version number that used for assets for preventing cache mechanism
	 *
	 * @var string
	 */
	private static $version = '1.19.3';


	/**
	 * Contains plugin option panel ID
	 *
	 * @var string
	 */
	public static $panel_id = 'better_ads_manager';


	/**
	 * Inner array of instances
	 *
	 * @var array
	 */
	protected static $instances = array();


	/**
	 * Flag to detect Adsense js file was printed or not
	 *
	 * @var bool
	 */
	private $is_google_adsence_printed = false;


	/**
	 * Flag to detect Adsense js file was printed or not
	 *
	 * @var bool
	 */
	private $wp_head_finished = false;


	/**
	 * Flag to detect Adsense lazy loading js file was printed or not
	 *
	 * @var bool
	 */
	private $is_google_adsence_lazy_printed = false;


	/**
	 * Used to cache the ad data while saving post
	 *
	 * @var string
	 */
	private $meta_cache_id = 'ad-data-cache';


	/**
	 * Plugin initialize
	 */
	function __construct() {

		// Defines constant to enable BetterAMP for adding ads
		if ( ! defined( 'BETTER_ADS_MANAGER_AMP' ) ) {
			define( 'BETTER_ADS_MANAGER_AMP', true );
		}

		// Defines constant to prevent ad blockers to detect the Better Ads Manager classes!
		// Other plugins and themes can use this for generating custom css codes
		if ( ! defined( 'BAM_PREFIX' ) ) {
			define( 'BAM_PREFIX', $this->get_unique_id() );
		}

		// Register included BF
		add_filter( 'better-framework/loader', array( $this, 'better_framework_loader' ) );

		// Enable needed sections
		add_filter( 'better-framework/sections', array( $this, 'setup_bf_features' ), 100 );


		// Includes general functions
		include $this->dir_path( 'functions.php' );

		// Add option panel
		include $this->dir_path( 'includes/options/panel.php' );

		// Add metabox
		include $this->dir_path( 'includes/options/metabox.php' );

		// Add taxonomy metabox
		include $this->dir_path( 'includes/options/taxonomy.php' );

		// Add FIA support
		include $this->dir_path( 'includes/fia/bam-fia.php' );

		// Activate and add new shortcodes
		add_filter( 'better-framework/shortcodes', array( $this, 'setup_shortcodes' ), 100 );

		// Initialize after bf init
		add_action( 'better-framework/after_setup', array( $this, 'bf_init' ) );

		// Do some stuff after WP init
		add_action( 'init', array( $this, 'init' ) );

		// Includes BF loader if not included before
		require_once $this->dir_path( '/includes/libs/better-framework/init.php' );

		// Ads plugin textdomain
		add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );

		// Ajax callback for rebuilding image from front end
		add_action( 'wp_ajax_nopriv_better_ads_manager_blocked_fallback', array( $this, 'callback_blocked_ads' ) );
		add_action( 'wp_ajax_better_ads_manager_blocked_fallback', array( $this, 'callback_blocked_ads' ) );

		add_filter( 'better-framework/oculus/logger/turn-off', array( $this, 'oculus_logger' ), 22, 3 );

		// Add custom items to editor shortcodes menu
		add_filter( 'better-framework/editor-shortcodes/shortcodes-array', array(
			$this,
			'register_shortcode_to_editor'
		), 15 );

		// Configs "BF Editor Shortcodes" library
		add_filter( 'better-framework/editor-shortcodes/config', array( $this, 'editor_shortcodes_config' ) );

		// Reset unique ID when the BAM panel saved.
		add_filter( 'better-framework/panel/save/result', array( $this, 'callback_panel_save_result' ), 10, 2 );

		// Change the .bsac in the BetterAMP Style files
		add_filter( 'better-amp/style-files/css/ads.css', array( $this, 'make_prefix_undetectable' ), 10 );
		add_filter( 'better-amp/style-files/css/ads.min.css', array( $this, 'make_prefix_undetectable' ), 10 );
		add_filter( 'better-amp/style-files/css/ads.rtl.css', array( $this, 'make_prefix_undetectable' ), 10 );
		add_filter( 'better-amp/style-files/css/ads.rtl.min.css', array( $this, 'make_prefix_undetectable' ), 10 );

		// Change the widget output for ads
		add_filter( 'dynamic_sidebar_params', array( $this, 'dynamic_sidebar_params' ) );

		// Clear BF CSS cache to make sure BAM auto css will be added
		register_activation_hook( __FILE__, array( 'Better_Ads_Manager', 'plugin_activation_hook' ) );

		// used to collect and finalize ads data for performance improvement.
		add_action( 'save_post', array( $this, 'save_ads_post' ), 10, 3 );

		// Detect the WP_Head was finished or not
		add_action( 'wp_head', array( $this, 'wp_head' ), 1000 );
		add_action( 'better-amp/template/head', array( $this, 'wp_head' ), 1000 );

	}


	/**
	 * Load plugin textdomain.
	 *
	 * @since 1.0.0
	 */
	function load_textdomain() {

		// Register text domain
		load_plugin_textdomain( 'better-studio', false, 'better-ads-manager/languages' );

	}


	/**
	 * Used for accessing plugin directory URL
	 *
	 * @param string $address
	 *
	 * @return string
	 */
	public static function dir_url( $address = '' ) {

		return plugin_dir_url( __FILE__ ) . $address;

	}


	/**
	 * Used for accessing plugin directory Path
	 *
	 * @param string $address
	 *
	 * @return string
	 */
	public static function dir_path( $address = '' ) {

		return plugin_dir_path( __FILE__ ) . $address;

	}


	/**
	 * Returns plugin current Version
	 *
	 * @return string
	 */
	public static function get_version() {

		return self::$version;

	}


	/**
	 * Build the required object instance
	 *
	 * @param   string $object
	 * @param   bool   $fresh
	 * @param   bool   $just_include
	 *
	 * @return  Better_Ads_Manager|null
	 */
	public static function factory( $object = 'self', $fresh = false, $just_include = false ) {

		if ( isset( self::$instances[ $object ] ) && ! $fresh ) {
			return self::$instances[ $object ];
		}

		switch ( $object ) {

			/**
			 * Main Better_Ads_Manager Class
			 */
			case 'self':
				$class = 'Better_Ads_Manager';
				break;

			default:
				return null;
		}


		// Just prepare/includes files
		if ( $just_include ) {
			return;
		}

		// don't cache fresh objects
		if ( $fresh ) {
			return new $class;
		}

		self::$instances[ $object ] = new $class;

		return self::$instances[ $object ];
	}


	/**
	 * Used for accessing alive instance of plugin
	 *
	 * @since 1.0
	 *
	 * @return Better_Ads_Manager
	 */
	public static function self() {

		return self::factory();

	}


	/**
	 * Used for retrieving options simply and safely for next versions
	 *
	 * @param $option_key
	 *
	 * @return mixed|null
	 */
	public static function get_option( $option_key ) {

		return bf_get_option( $option_key, self::$panel_id );

	}


	/**
	 * Callback: Adds included BetterFramework to BF loader
	 *
	 * Filter: better-framework/loader
	 *
	 * @param $frameworks
	 *
	 * @return array
	 */
	function better_framework_loader( $frameworks ) {

		$frameworks[] = array(
			'version' => '3.10.17',
			'path'    => $this->dir_path( 'includes/libs/better-framework/' ),
			'uri'     => $this->dir_url( 'includes/libs/better-framework/' ),
		);

		return $frameworks;
	}


	/**
	 * Setups features of BetterFramework
	 *
	 * @param $features
	 *
	 * @return array
	 */
	function setup_bf_features( $features ) {

		$features['admin_panel']       = true;
		$features['meta_box']          = true;
		$features['taxonomy_meta_box'] = true;
		$features['minify']            = true;
		$features['content-injector']  = true;
		$features['editor-shortcodes'] = true;
		$features['booster']           = true;


		return $features;
	}


	/**
	 *  Init the plugin
	 */
	function bf_init() {

		// Enqueue assets
		add_action( 'wp_footer', array( $this, 'enqueue_scripts' ), 99 );

		// Enqueue admin assets
		add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );

		// Post ads
		add_action( 'the_content', array( $this, 'setup_post_content_ads' ), 5 );

		// Adds custom columns for banners
		if ( is_admin() && ! bf_is_doing_ajax() ) {
			add_filter( 'manage_edit-better-banner_columns', array( $this, 'banner_columns' ) );
			add_action( 'manage_better-banner_posts_custom_column', array( $this, 'banner_columns_content' ), 10, 2 );
			add_action( 'admin_head', array( $this, 'admin_styles' ) );
		}

		// print header codes (FTP...)
		add_action( 'wp_head', array( $this, 'print_wp_head' ) );

		// print css codes for Gutenberg
		add_action( 'admin_head', array( $this, 'print_admin_head' ) );

		// Handles save for override fields
		add_filter( 'better-framework/panel/save', 'Better_Ads_Manager::handle_ads_manager_override_save', 1 );

		// add more codes to BF custom generated CSS
		add_filter( 'better-framework/css/final', array( $this, 'bf_final_front_end_css' ) );
	}


	/**
	 * Appends dynamic css codes to the final generated CSS code of BF.
	 *
	 * @param $css
	 *
	 * @return mixed
	 */
	function bf_final_front_end_css( $css ) {

		/**
		 * This css codes will be printed dynamically at the header of site.
		 */
		{
			ob_start();
			include bf_append_suffix( self::dir_path( 'css/bam' ), '.css' );
			$code = ob_get_clean();

			$code = $this->make_prefix_undetectable( $code );

			if ( ! empty( $css['css'] ) ) {
				$css['css'] .= $code;
			}
		}

		return $css;
	}


	/**
	 * Callback: Used for registering scripts and styles
	 *
	 * Action: enqueue_scripts
	 */
	function enqueue_scripts() {

		// Dynamic JS codes.
		// We are making it undetectable so the AdBlockers can not find a pattern to detect it.
		{
			ob_start();
			include bf_append_suffix( self::dir_path( 'js/bam' ), '.js' );
			$code = ob_get_clean();

			$code = $this->make_prefix_undetectable( $code );

			bf_add_js( $code, true, true );
		}
	}


	/**
	 * Adds advertising.js to page
	 */
	function enqueue_adblocker_detector() {

		static $printed;

		if ( ! is_null( $printed ) ) {
			return;
		}

		wp_enqueue_script(
			'better-advertising',
			bf_append_suffix( self::dir_url() . 'js/advertising', '.js' ),
			array(),
			Better_Ads_Manager::$version,
			false
		);

		$printed = true;
	}


	/**
	 * Callback: Used for adding JS and CSS files to page
	 *
	 * Action: admin_enqueue_scripts
	 */
	function admin_enqueue_scripts() {

		$dir_url  = self::dir_url();
		$dir_path = self::dir_path();

		bf_enqueue_style(
			'better-adsmanager',
			bf_append_suffix( $dir_url . 'css/better-ads-manager-admin', '.css' ),
			array(),
			bf_append_suffix( $dir_path . 'css/better-ads-manager-admin', '.css' ),
			Better_Ads_Manager::$version
		);

		bf_enqueue_script(
			'better-adsmanager',
			bf_append_suffix( $dir_url . 'js/bam-admin', '.js' ),
			array(),
			bf_append_suffix( $dir_path . 'js/bam-admin', '.js' ),
			Better_Ads_Manager::$version
		);

		bf_localize_script(
			'better-adsmanager',
			'better_adsmanager_loc',
			array(
				'ajax_url'    => admin_url( 'admin-ajax.php' ),
				'arrow'       => is_rtl() ? '←' : '→',
				'translation' => array(
					'inactive'           => __( 'Inactive Ad', 'better-studio' ),
					'banner'             => __( 'Banner', 'better-studio' ),
					'in_active_banner'   => __( 'Banner', 'better-studio' ),
					'campaign'           => __( 'Campaign', 'better-studio' ),
					'in_active_campaign' => __( 'Inactive Campaign', 'better-studio' ),
					'after_x_paragraph'  => array(
						__( 'After 1st p', 'better-studio' ),
						__( 'After 2nd p', 'better-studio' ),
						__( 'After 3rd p', 'better-studio' ),
						__( 'After %sth p', 'better-studio' ),
					),
				),
			)
		);
	}


	/**
	 * Get Campaigns
	 *
	 * @param array $extra Extra Options.
	 *
	 * @since 1.0
	 * @return array
	 */
	public static function get_campaigns( $extra = array() ) {

		/*
			Extra Usage:

			array(
				'posts_per_page'  => 5,
				'offset'          => 0,
				'category'        => '',
				'orderby'         => 'post_date',
				'order'           => 'DESC',
				'include'         => '',
				'exclude'         => '',
				'meta_key'        => '',
				'meta_value'      => '',
				'post_type'       => 'post',
				'post_mime_type'  => '',
				'post_parent'     => '',
				'post_status'     => 'publish',
				'suppress_filters' => true
			)
		*/


		$extra = wp_parse_args( $extra, array(
			'post_type'      => array( 'better-campaign' ),
			'posts_per_page' => 400,
		) );

		$output = array();

		$query = get_posts( $extra );

		foreach ( $query as $post ) {
			$output[ $post->ID ] = $post->post_title;
		}

		return $output;

	}


	/**
	 * Get Banners
	 *
	 * @param array $extra Extra Options.
	 *
	 * @since 1.0
	 * @return array
	 */
	public static function get_banners( $extra = array() ) {

		/*
			Extra Usage:

			array(
				'posts_per_page'  => 5,
				'offset'          => 0,
				'category'        => '',
				'orderby'         => 'post_date',
				'order'           => 'DESC',
				'include'         => '',
				'exclude'         => '',
				'meta_key'        => '',
				'meta_value'      => '',
				'post_type'       => 'post',
				'post_mime_type'  => '',
				'post_parent'     => '',
				'post_status'     => 'publish',
				'suppress_filters' => true
			)
		*/

		$label_type = '';

		if ( isset( $extra['label_type'] ) ) {
			$label_type = $extra['label_type'];
			unset( $extra['label_type'] );
		}


		$extra = bf_merge_args( $extra, array(
			'post_type'      => array( 'better-banner' ),
			'posts_per_page' => - 1,
		) );

		$output = array();

		$query = get_posts( $extra );

		foreach ( $query as $post ) {

			$desc = array();

			if ( ! empty( $label_type ) ) {

				if ( $label_type === 'both' || $label_type === 'format' ) {
					$format = get_post_meta( $post->ID, 'format', true );
					if ( $format === 'normal' || empty( $format ) ) {
						$desc[] = 'Normal';
					} elseif ( $format === 'amp' ) {
						$desc[] = 'AMP';
					}
				}

				if ( $label_type === 'both' || $label_type === 'type' ) {
					$type = get_post_meta( $post->ID, 'type', true );
					if ( $type === 'code' ) {
						$desc[] = 'Adsense';
					} elseif ( $type === 'image' ) {
						$desc[] = 'Image';
					} elseif ( $type === 'custom_code' ) {
						$desc[] = 'HTML';
					} elseif ( $type === 'dfp' ) {
						$desc[] = 'DFP';
					}
				}

			}


			$output[ $post->ID ] = $post->post_title . ( ! empty( $desc ) ? ' [' . implode( ' - ', $desc ) . ']' : '' );
		}

		return $output;

	}


	/**
	 * Callback: Used to register post types
	 *
	 * Action: init
	 */
	function init() {

		//
		// Campaigns post type
		//
		$labels = array(
			'name'               => _x( 'Campaigns', 'post type general name', 'better-studio' ),
			'singular_name'      => _x( 'Campaign', 'post type singular name', 'better-studio' ),
			'menu_name'          => _x( 'Campaigns', 'admin menu', 'better-studio' ),
			'name_admin_bar'     => _x( 'Campaigns', 'add new on admin bar', 'better-studio' ),
			'add_new'            => _x( 'Add New Campaign', 'campaign', 'better-studio' ),
			'add_new_item'       => __( 'Add New Campaign', 'better-studio' ),
			'new_item'           => __( 'New Campaign', 'better-studio' ),
			'edit_item'          => __( 'Edit Campaign', 'better-studio' ),
			'view_item'          => __( 'View Campaign', 'better-studio' ),
			'all_items'          => __( 'Campaigns', 'better-studio' ),
			'search_items'       => __( 'Search Campaigns', 'better-studio' ),
			'not_found'          => __( 'No campaigns found.', 'better-studio' ),
			'not_found_in_trash' => __( 'No campaigns found in Trash.', 'better-studio' )
		);

		$args = array(
			'public'              => false,
			'labels'              => $labels,
			'show_in_menu'        => 'better-studio/better-ads-manager',
			'show_ui'             => current_user_can( 'manage_options' ),
			'supports'            => array( 'title' ),
			'exclude_from_search' => true,
			'publicly_queryable'  => false,
			'show_in_nav_menus'   => false,
			'show_in_admin_bar'   => false,
		);
		register_post_type( 'better-campaign', $args );

		//
		// Banners post type
		//
		$labels = array(
			'name'               => _x( 'Banners', 'post type general name', 'better-studio' ),
			'singular_name'      => _x( 'Banner', 'post type singular name', 'better-studio' ),
			'menu_name'          => _x( 'Banners', 'admin menu', 'better-studio' ),
			'name_admin_bar'     => _x( 'Banners', 'add new on admin bar', 'better-studio' ),
			'add_new'            => _x( 'Add New Banner', 'campaign', 'better-studio' ),
			'add_new_item'       => __( 'Add New Banner', 'better-studio' ),
			'new_item'           => __( 'New Banner', 'better-studio' ),
			'edit_item'          => __( 'Edit Banner', 'better-studio' ),
			'view_item'          => __( 'View Banner', 'better-studio' ),
			'all_items'          => __( 'Banners', 'better-studio' ),
			'search_items'       => __( 'Search Banner', 'better-studio' ),
			'not_found'          => __( 'No banners found.', 'better-studio' ),
			'not_found_in_trash' => __( 'No banners found in Trash.', 'better-studio' )
		);
		$args   = array(
			'public'              => false,
			'labels'              => $labels,
			'show_in_menu'        => 'better-studio/better-ads-manager',
			'show_ui'             => current_user_can( 'manage_options' ),
			'supports'            => array( 'title' ),
			'exclude_from_search' => true,
			'publicly_queryable'  => false,
			'show_in_nav_menus'   => false,
			'show_in_admin_bar'   => false,
		);
		register_post_type( 'better-banner', $args );

	}


	/**
	 * Setups Shortcodes
	 *
	 * 6. => Setup Shortcodes
	 *
	 * @param $shortcodes
	 *
	 * @return mixed
	 */
	function setup_shortcodes( $shortcodes ) {

		require_once $this->dir_path( 'includes/shortcodes/class-better-ads-shortcode.php' );
		require_once $this->dir_path( 'includes/widgets/class-better-ads-widget.php' );

		$shortcodes['better-ads'] = array(
			'shortcode_class' => 'Better_Ads_Shortcode',
			'widget_class'    => 'Better_Ads_Widget',
		);

		return $shortcodes;
	}


	/**
	 * Used for showing add
	 *
	 * @param $ad_data
	 *
	 * @return string
	 */
	function show_ads( $ad_data ) {

		if ( ! $this->wp_head_finished && ! bf_is_doing_ajax() && empty( $_GET['ajax_related_post'] ) ) {
			return '';
		}

		$output = '';

		if ( ! empty( $ad_data['title'] ) && bf_get_current_sidebar() === '' ) {
			$title = apply_filters( 'better-framework/shortcodes/title', $ad_data );

			if ( is_string( $title ) ) {
				$output .= $title;
			}
		}

		// ads css class, it comes from VC design option
		if ( ( $css_class = bf_shortcode_custom_css_class( $ad_data ) ) != '' ) {
			if ( ! empty( $ad_data['container-class'] ) ) {
				$ad_data['container-class'] .= ' ' . $css_class;
			} else {
				$ad_data['container-class'] = $css_class;
			}
		}

		if ( ! isset( $ad_data['type'] ) ) {

			if ( is_user_logged_in() ) {
				return $this->make_prefix_undetectable( $this->show_ads_container( $ad_data, '<div class="bsac-empty-note">' . __( 'Please select type of ad.', 'better-studio' ) . '</div>' ) );
			} else {
				return $this->make_prefix_undetectable( $this->show_ads_container( $ad_data, '' ) );
			}
		}

		// args of ads banners
		$args = array(
			'show-caption' => isset( $ad_data['show-caption'] ) ? $ad_data['show-caption'] : true,
			'lazy-load'    => ! empty( $ad_data['lazy-load'] ) ? $ad_data['lazy-load'] : Better_Ads_Manager::get_option( 'lazy_loading_ads' ),
		);

		if ( bf_is_doing_ajax() ) {
			$ad_item['lazy-load'] = 'disable';
		}

		//
		// Custom args for ads from outside
		if ( isset( $ad_data['banner-custom-config'] ) ) {
			$args = array_merge( $args, $ad_data['banner-custom-config'] );
		}


		switch ( $ad_data['type'] ) {


			case 'campaign':

				if ( ! isset( $ad_data['campaign'] ) || $ad_data['campaign'] == 'none' ) {
					return $this->make_prefix_undetectable( $this->show_ads_empty_note( $ad_data ) );
				}

				if ( empty( $ad_data['count'] ) || intval( $ad_data['count'] ) <= 0 ) {
					$ad_data['count'] = 1;
				}

				$c_query = new WP_Query( array(
					'post_type'      => 'better-banner',
					'order'          => $ad_data['order'],
					'orderby'        => $ad_data['orderby'],
					'posts_per_page' => $ad_data['count'],
					'meta_query'     => array(
						array(
							'key'     => 'campaign',
							'value'   => $ad_data['campaign'],
							'compare' => 'LIKE',
						),
					),
				) );

				if ( $c_query->have_posts() ) {

					if ( isset( $ad_data['count'] ) && intval( $ad_data['count'] ) > 0 ) {

						// count of adds
						$count = $ad_data['count'];
						if ( $count > bf_count( $c_query->posts ) ) {
							$count = bf_count( $c_query->posts );
						}

						$counter = 1;
						foreach ( $c_query->posts as $post ) {

							if ( $counter > $count ) {
								break;
							}

							$output .= $this->show_ad_banner( $post->ID, $args );

							$counter ++;
						}

					} else {
						foreach ( $c_query->posts as $post ) {
							$output .= $this->show_ad_banner( $post->ID, $args );
						}
					}

					return $this->make_prefix_undetectable( $this->show_ads_container( $ad_data, $output ) );

				} else {
					return $this->make_prefix_undetectable( $this->show_ads_empty_note( $ad_data ) );
				}

				break; // /campaign

			case 'banner':

				$ad_data['columns'] = 1;

				if ( ! isset( $ad_data['banner'] ) || $ad_data['banner'] === 'none' ) {
					return $this->show_ads_empty_note( $ad_data );
				}

				$ad_code = $this->show_ad_banner( $ad_data['banner'], $args );

				//
				// Hack: The layout=responsive (data-full-width-responsive="true") needs a class in  AMP to make it
				//        Full width (out of wrapper) by CSS
				//
				if ( stripos( $ad_code, 'layout=responsive' ) ) {
					if ( empty( $ad_data['container-class'] ) ) {
						$ad_data['container-class'] = 'bsac-full-width';
					} else {
						$ad_data['container-class'] .= ' bsac-full-width';
					}
				}


				return $this->make_prefix_undetectable( $this->show_ads_container( $ad_data, $ad_code ) );

				break; // /banner

			default:
				return $this->make_prefix_undetectable( $this->show_ads_empty_note( $ad_data ) );
				break;
		}

	}


	/**
	 * Handy function used to show empty message
	 *
	 * @param        $ad_data
	 * @param string $message
	 * @param string $link
	 *
	 * @return string
	 */
	private function show_ads_empty_note( $ad_data, $message = '', $link = '' ) {

		if ( ! is_user_logged_in() ) {
			return $this->show_ads_container( $ad_data, '' );
		}

		if ( empty( $message ) ) {

			switch ( $ad_data['type'] ) {

				case 'banner':

					$message = __( 'Please select an ad banner.', 'better-studio' );

					if ( empty( $link ) ) {
						if ( bf_get_current_sidebar() ) {
							$link = admin_url( 'widgets.php' );
						} elseif ( is_page() ) {
							if ( current_user_can( 'edit_posts' ) ) {
								$link = get_edit_post_link( get_the_ID() );
							}
						} else {
							$link = admin_url( 'admin.php?page=better-studio/better-ads-manager' );
						}
					}

					break;

				case 'campaign':

					if ( $ad_data['campaign'] !== 'none' ) {

						if ( empty( $link ) ) {
							$link = admin_url( 'edit.php?post_type=better-banner' );
						}

						$message = sprintf(
							__( 'Selected campaign have not any active ad, Select an ad for "%s" campaign.', 'better-studio' ),
							get_the_title( $ad_data['campaign'] )
						);

					} else {

						if ( empty( $link ) ) {
							if ( bf_get_current_sidebar() ) {
								$link = admin_url( 'widgets.php' );
							} elseif ( is_page() ) {
								if ( current_user_can( 'edit_posts' ) ) {
									$link = get_edit_post_link( get_the_ID() );
								}
							} else {
								$link = admin_url( 'admin.php?page=better-studio/better-ads-manager' );
							}
						}

						$message = __( 'Selected a campaign fo this ad banner.', 'better-studio' );
					}

					break;

				default:

					if ( empty( $link ) ) {
						if ( bf_get_current_sidebar() ) {
							$link = admin_url( 'widgets.php' );
						} elseif ( is_page() ) {
							if ( current_user_can( 'edit_posts' ) ) {
								$link = get_edit_post_link( get_the_ID() );
							}
						} else {
							$link = admin_url( 'admin.php?page=better-studio/better-ads-manager' );
						}
					}

					$message = __( 'Please select an ad banner or campaign.', 'better-studio' );

					break;

			}

		}

		if ( $this->get_current_format() === 'amp' ) {
			better_amp_enqueue_ad( 'image' );
		}

		if ( empty( $link ) ) {
			return $this->show_ads_container( $ad_data, '<div class="bsac-empty-note">' . $message . '</div>' );
		} else {
			return $this->show_ads_container( $ad_data, '<div class="bsac-empty-note"><a href="' . $link . '">' . $message . '</a></div>' );
		}
	}


	/**
	 * Handy function used to generate ads container
	 *
	 * @param $ad_data
	 * @param $html
	 *
	 * @return string
	 */
	private function show_ads_container( $ad_data, $html ) {

		if ( ! isset( $ad_data['container-class'] ) ) {
			$ad_data['container-class'] = '';
		}

		if ( empty( $ad_data['align'] ) ) {
			$ad_data['align'] = 'center';
		}

		if ( empty( $ad_data['columns'] ) ) {
			$ad_data['columns'] = 1;
		}

		$ad_data['container-class'] .= ' bsac-align-' . $ad_data['align'];
		$ad_data['container-class'] .= ' bsac-column-' . $ad_data['columns'];

		if ( isset( $ad_data['float'] ) && $ad_data['float'] != 'none' ) {
			$ad_data['container-class'] .= ' bsac-float-' . $ad_data['float'];
		}

		//
		// Hide ads in device classes
		// Should not work for campaigns
		//
		if ( $ad_data['type'] !== 'campaign' ) {
			$_check = array();

			$_device_hidden_classes = array(
				'bsac-hide-on-phone',
				'bsac-hide-on-tablet-portrait',
				'bsac-hide-on-tablet-landscape',
				'bsac-hide-on-desktop',
			);

			foreach ( $_device_hidden_classes as $class ) {
				if ( ! isset( $_check[ $class ] ) && stripos( $html, $class ) ) {
					$ad_data['container-class'] .= " $class";
					$_check[ $class ]           = '';
				}
			}
		}

		$output = '<div class="bsac bsac-clearfix ' . $ad_data['container-class'] . '">' . $html . '</div>';

		return $output;
	}


	/**
	 * Handy function to remove "\n" because some plugins are making problem for this and TinyMCE
	 *
	 * @param string $text
	 *
	 * @return mixed
	 */
	private function _fix_new_lines( $text = '' ) {

		return str_replace( array( "\n", "\t" ), ' ', $text );
	}


	/**
	 * Returns ads current format
	 *
	 * @return string
	 */
	public function get_current_format() {

		static $format;

		if ( $format ) {
			return $format;
		}

		if ( function_exists( 'is_better_amp' ) && is_better_amp() ) {
			$format = 'amp';
		} else {
			$format = 'normal';
		}

		return $format;
	}


	/**
	 * Handy function to return ad file template by ad type
	 *
	 * todo add functionality to override template files in themes
	 *
	 * @param string $ad_type
	 *
	 * @return string
	 */
	public function get_template_file( $ad_type = 'image' ) {

		return Better_Ads_Manager::dir_path( 'templates/' . $this->get_current_format() . '-' . $ad_type . '.php' );
	}


	/**
	 * Handy function used for showing ad banner from post id
	 *
	 * @param $banner_id
	 *
	 * @return string
	 */
	private function show_ad_banner( $banner_id, $args = array() ) {

		// used inside ad template files
		$args = bf_merge_args( $args, array(
			'show-caption' => true
		) );

		$banner_data = array_merge( $this->get_banner_data( $banner_id ), $args );

		$output = '';

		switch ( $banner_data['type'] ) {

			case 'dfp':

				if ( ! self::get_option( 'dfp_code' ) ) {

					$message = __( 'Please enter DFP before &lt;/head&gt; code in Better Ads Manager panel.', 'better-studio' );
					$link    = admin_url( 'admin.php?page=better-studio/better-ads-manager' );

					return $this->show_ads_empty_note( $banner_data, $message, $link );
				}

				if ( empty( $banner_data['dfp_spot'] ) ) {

					$message = __( 'Please select a spot id for this banner or enter custom ad code.', 'better-studio' );
					$link    = '';

					if ( current_user_can( 'edit_posts' ) ) {
						$link = get_edit_post_link( $banner_data['id'] );
					}

					return $this->show_ads_empty_note( $banner_data, $message, $link );

				} elseif ( $banner_data['dfp_spot'] === 'custom' ) {

					if ( empty( $banner_data['custom_dfp_code'] ) ) {
						$message = __( 'Custom DFP was selected but the code was not entered.', 'better-studio' );
						$link    = '';

						if ( current_user_can( 'edit_posts' ) ) {
							$link = get_edit_post_link( $banner_data['id'] );
						}

						return $this->show_ads_empty_note( $banner_data, $message, $link );
					}

				} else {


					//
					// Code examples:
					// Single dimention:
					// googletag.defineSlot('/21719673487/AbruzzoLive/F1', [300, 100], 'div-gpt-ad-1535184030575-0').addService(googletag.pubads());
					//
					//
					// Multiple dimention:
					// googletag.defineSlot('/21719673487/AbruzzoLive/3-Alive-Mobile', [[300, 250], [320, 100]], 'div-gpt-ad-1535361184691-0').addService(googletag.pubads());
					//

					$spot = explode( '--', str_replace( '\'', '', $banner_data['dfp_spot'] ) );

					if ( bf_count( $spot ) < 4 ) {
						$message = __( 'The auto selected spot id is not valid. Please enter custom code.', 'better-studio' );
						$link    = '';

						if ( current_user_can( 'edit_posts' ) ) {
							$link = get_edit_post_link( $banner_data['id'] );
						}

						return $this->show_ads_empty_note( $banner_data, $message, $link );
					}

					$banner_data['dfp_spot_id'] = trim( $spot[0] );

					// If the d spot have multiple size dimensions Google recommends this:
					//    "If using multi-size tags, we recommend either omitting this
					//    (in that case, the size of the element takes the size of the selected creative when rendered) or
					//    making both dimensions large enough to contain the largest eligible creative."
					//    https://support.google.com/admanager/answer/1638622?hl=en
					// The single dimension code only have 4 element in array, more elements means multiple dimensions
					if ( bf_count( $spot ) > 4 ) {
						$banner_data['dfp_spot_width']  = '';
						$banner_data['dfp_spot_height'] = '';
					} else {
						$banner_data['dfp_spot_width']  = str_replace( array( '[', ' ' ), '', $spot[1] );
						$banner_data['dfp_spot_height'] = str_replace( array( ']', ' ' ), '', $spot[2] );
					}

					// The last item is always the ad ID
					$banner_data['dfp_spot_tag'] = trim( end( $spot ) );
				}

				$ad_code = include $this->get_template_file( $banner_data['type'] );
				$output  .= $this->show_ad_banner_container( $banner_data, $ad_code );

				break;

			case 'image':
				$ad_code = include $this->get_template_file( $banner_data['type'] );
				$output  .= $this->show_ad_banner_container( $banner_data, $ad_code );
				break;


			// code is Google Adsense code
			case 'code':

				//
				// Advanced:
				// Changes AdSense banner size from the size detected in code or the size that passed for ad location in themes!
				//
				if ( true ) // to fix the PHPStorm reformat bug!
				{
					$c_width = $c_height = false;

					// ad size extracted from AdSense code
					if ( ! empty( $banner_data['width'] ) && ! empty( $banner_data['height'] ) ) {
						$c_width  = $banner_data['width'];
						$c_height = $banner_data['height'];
					} // ad size passed from parent! (usually we use it in ad location to show specific ad size by default)
					elseif ( ! empty( $banner_data['adsense_default_size'][0] ) && ! empty( $banner_data['adsense_default_size'][1] ) ) {
						$c_width  = $banner_data['adsense_default_size'][0];
						$c_height = $banner_data['adsense_default_size'][1];
					}

					//
					// Detects inline width & height and set's it to default size if was not override!
					//
					if ( $c_width && $c_height && empty( $banner_data['size_desktop'] ) ) {
						$banner_data['size_desktop'] = array(
							$c_width,
							$c_height,
						);
					}
				}


				if ( ! empty( $banner_data['ad-client'] ) && ! empty( $banner_data['ad-slot'] ) ) {
					$ad_code = include $this->get_template_file( 'adsense' );
					$output  .= $this->show_ad_banner_container( $banner_data, $ad_code );
				} else {
					$output .= $this->show_ad_banner_container( $banner_data, str_replace( "\n", '', do_shortcode( $banner_data['code'] ) ) );
				}
				break;

			case 'custom_code':

				Better_Ads_Manager()->enqueue_adblocker_detector();
				$ad = do_shortcode( $banner_data['custom_code'] );

				$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;

				if ( $caption == 'above' ) {
					$ad = "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>" . $ad;
				} elseif ( $caption ) {
					$ad .= "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
				}

				// print general ad style
				if ( bf_is_amp() == 'better' ) {
					better_amp_enqueue_ad();
				}

				$output .= $this->show_ad_banner_container( $banner_data, $ad );

				break;

		}

		return $output;

	}


	/**
	 * Handy function used to create single ad container
	 *
	 * @param $banner_data
	 * @param $html
	 *
	 * @return string
	 */
	private function show_ad_banner_container( $banner_data, $html ) {

		if ( empty( $html ) ) {
			return '';
		}

		$banner_data['custom_class'] = 'bsac-container bsac-type-' . $banner_data['type'] . ' ' . $banner_data['custom_class'];

		if ( ! empty( $banner_data['custom_css'] ) ) {
			Better_Framework()->assets_manager()->add_css( $banner_data['custom_css'], true );
		}

		if ( ! $banner_data['show_desktop'] ) {
			$banner_data['custom_class'] .= ' bsac-hide-on-desktop';
		}

		if ( ! $banner_data['show_tablet_portrait'] ) {
			$banner_data['custom_class'] .= ' bsac-hide-on-tablet-portrait';
		}

		if ( ! $banner_data['show_tablet_landscape'] ) {
			$banner_data['custom_class'] .= ' bsac-hide-on-tablet-landscape';
		}

		if ( ! $banner_data['show_phone'] ) {
			$banner_data['custom_class'] .= ' bsac-hide-on-phone';
		}

		return '<div id="' . $banner_data['element_id'] . '" class="' . $banner_data['custom_class'] . '" itemscope="" itemtype="https://schema.org/WPAdBlock" data-adid="' . $banner_data['id'] . '" data-type="' . $banner_data['type'] . '">' . $html . '</div>';

	}


	/**
	 * Handy function used for safely getting banner data
	 *
	 * @param $id
	 *
	 * @return array
	 */
	function fetch_banner_data( $id ) {

		// Return from saved cache
		if ( $data = get_transient( $this->get_meta_cache_id( $id ) ) ) {

			if ( empty( $data['element_id'] ) ) {
				$data['element_id'] = 'bsac-' . $data['id'] . '-' . mt_rand();
			}

			return $data;
		}

		$data = array(
			'id'       => $id,
			'title'    => get_the_title( $id ),
			'campaign' => bf_get_post_meta( 'campaign', $id ),
			'format'   => bf_get_post_meta( 'format', $id ),
			'type'     => bf_get_post_meta( 'type', $id ),
			'caption'  => bf_get_post_meta( 'caption', $id ),
		);


		if ( $data['format'] === 'normal' ) {

			/**
			 *
			 * Normal Adsense code
			 *
			 */
			if ( $data['type'] === 'code' ) {

				$data['code'] = bf_get_post_meta( 'code', $id, '' );

				//
				// Size fields
				//

				$_size_check = array(
					'vertical'   => '',
					'horizontal' => '',
					'rectangle'  => '',
				);

				$_size_fields = array(
					'size_desktop',
					'size_tablet_portrait',
					'size_tablet_landscape',
					'size_phone',
				);

				foreach ( $_size_fields as $_size_f ) {
					$_size = bf_get_post_meta( $_size_f, $id, '' );

					if ( empty( $_size ) ) {
						$data[ $_size_f ] = '';
						continue;
					}

					if ( isset( $_size_check[ $_size ] ) ) {
						$data[ $_size_f ] = $_size;
					} else {
						$data[ $_size_f ] = explode( '_', $_size );
					}
				}

				if ( ! empty( $data['code'] ) ) {
					$data['active-ad'] = true;
				}

			} /**
			 *
			 * Normal Image Ad
			 *
			 */
			elseif ( $data['type'] == 'image' ) {

				$_fields = array(
					'img'       => '',
					'caption'   => '',
					'url'       => '',
					'target'    => '',
					'no_follow' => '',
				);

				foreach ( $_fields as $k => $v ) {
					$data[ $k ] = bf_get_post_meta( $k, $id, $v );
				}

				if ( ! empty( $data['img'] ) ) {
					$data['active-ad'] = true;
				}

			} /**
			 *
			 * Normal DFP
			 *
			 */
			elseif ( $data['type'] == 'dfp' ) {

				$_fields = array(
					'dfp_spot'        => '',
					'custom_dfp_code' => '',
				);

				foreach ( $_fields as $k => $v ) {
					$data[ $k ] = bf_get_post_meta( $k, $id, $v );
				}

				if ( ! empty( $data['dfp_spot'] ) ) {

					if ( $data['dfp_spot'] === 'custom' && ! empty( $data['custom_dfp_code'] ) ) {
						$data['active-ad'] = true;
					}
				}

			} /**
			 *
			 * Normal Custom Code
			 *
			 */ elseif ( $data['type'] === 'custom_code' ) {
				$data['custom_code'] = bf_get_post_meta( 'custom_code', $id, '' );


				if ( ! empty( $data['custom_code'] ) ) {
					$data['active-ad'] = true;
				}

			}


			/**
			 *
			 * Normal Ad -> Show fields
			 *
			 */
			$_fields = array(
				'show_desktop'          => true,
				'show_tablet_portrait'  => true,
				'show_tablet_landscape' => true,
				'show_phone'            => true,
			);

			foreach ( $_fields as $k => $v ) {
				$data[ $k ] = bf_get_post_meta( $k, $id, $v );
			}

		} elseif ( $data['format'] === 'amp' ) {

			/**
			 *
			 * AMP Adsense code
			 *
			 */
			if ( $data['type'] === 'code' ) {

				$data['code'] = bf_get_post_meta( 'code', $id, '' );
				$data['size'] = bf_get_post_meta( 'amp_size', $id, '' );

				if ( $data['size'] === 'custom' ) {
					$data['size'] = array(
						'width'  => bf_get_post_meta( 'amp_size_width', $id, '' ),
						'height' => bf_get_post_meta( 'amp_size_height', $id, '' ),
					);
				} else {
					$_size = explode( '_', $data['size'] );

					$data['size'] = array(
						'width'  => isset( $_size[0] ) ? $_size[0] : '',
						'height' => isset( $_size[1] ) ? $_size[1] : '',
					);
				}


				if ( ! empty( $data['code'] ) ) {
					$data['active-ad'] = true;
				}

			} /**
			 *
			 * Normal Image Ad
			 *
			 */
			elseif ( $data['type'] == 'image' ) {

				$_fields = array(
					'img'       => '',
					'caption'   => '',
					'url'       => '',
					'target'    => '',
					'no_follow' => '',
				);

				foreach ( $_fields as $k => $v ) {
					$data[ $k ] = bf_get_post_meta( $k, $id, $v );
				}


				if ( ! empty( $data['img'] ) ) {
					$data['active-ad'] = true;
				}

			} /**
			 *
			 * AMP DFP
			 *
			 */
			elseif ( $data['type'] == 'dfp' ) {

				$_fields = array(
					'dfp_spot'        => '',
					'dfp_custom_code' => '',
				);

				foreach ( $_fields as $k => $v ) {
					$data[ $k ] = bf_get_post_meta( $k, $id, $v );
				}

				if ( ! empty( $data['dfp_spot'] ) ) {

					if ( $data['dfp_spot'] === 'custom' && ! empty( $data['custom_dfp_code'] ) ) {
						$data['active-ad'] = true;
					}
				}

			} /**
			 *
			 * Normal Custom Code
			 *
			 */ elseif ( $data['type'] === 'custom_code' ) {

				$data['custom_code'] = bf_get_post_meta( 'custom_code', $id, '' );

				if ( ! empty( $data['custom_code'] ) ) {
					$data['active-ad'] = true;
				}
			}


			/**
			 *
			 * Normal Ad -> Show fields
			 *
			 */
			$_fields = array(
				'show_desktop'          => true,
				'show_tablet_portrait'  => true,
				'show_tablet_landscape' => true,
				'show_phone'            => true,
			);

			foreach ( $_fields as $k => $v ) {
				$data[ $k ] = bf_get_post_meta( $k, $id, $v );
			}

		}

		if ( ! isset( $data['active-ad'] ) ) {
			$data['active-ad'] = false;
		}


		/**
		 *
		 * Advanced custom css/class/id
		 *
		 */
		$_fields = array(
			'custom_class' => '',
			'custom_id'    => '',
			'custom_css'   => '',
		);

		foreach ( $_fields as $k => $v ) {
			if ( $k === 'custom_id' ) {
				$data['element_id'] = bf_get_post_meta( $k, $id, $v );
			} else {
				$data[ $k ] = bf_get_post_meta( $k, $id, $v );
			}
		}

		/**
		 * Extract Adsense data from the code in both normal and AMP ads
		 */
		if ( $data['type'] === 'code' && $data['code'] ) {
			$data = $data + better_ads_extract_google_ad_code_data( $data['code'] );
		}

		// Cache it
		set_transient( $this->get_meta_cache_id( $id ), $data, MONTH_IN_SECONDS );

		if ( empty( $data['element_id'] ) ) {
			$data['element_id'] = 'bsac-' . $data['id'] . '-' . mt_rand();
		}

		return $data;
	}


	/**
	 * Handy function used for safely getting banner data
	 *
	 * @param $id
	 *
	 * @return array
	 */
	function get_banner_data( $id ) {

		$data = $this->fetch_banner_data( $id );

		return $data;
	}


	/**
	 * Handy function used for safely getting banner data
	 *
	 * @param $id
	 *
	 * @return array
	 */
	function get_banner_fallback_data( $id ) {

		$data = array(
			'id'        => $id,
			'title'     => get_the_title( $id ),
			'type'      => 'image',
			'code'      => '',
			'img'       => '',
			'caption'   => '',
			'url'       => '',
			'target'    => '',
			'no_follow' => '',
		);

		if ( get_post_meta( $id, 'fallback_type', true ) != false ) {
			$data['type'] = get_post_meta( $id, 'fallback_type', true );
		}

		if ( get_post_meta( $id, 'fallback_code', true ) != false ) {
			$data['code'] = get_post_meta( $id, 'fallback_code', true );
		}

		if ( get_post_meta( $id, 'fallback_img', true ) != false ) {
			$data['img'] = get_post_meta( $id, 'fallback_img', true );
		}

		if ( get_post_meta( $id, 'fallback_caption', true ) != false ) {
			$data['caption'] = get_post_meta( $id, 'fallback_caption', true );
		}

		if ( get_post_meta( $id, 'fallback_url', true ) != false ) {
			$data['url'] = get_post_meta( $id, 'fallback_url', true );
		}

		if ( get_post_meta( $id, 'fallback_target', true ) != false ) {
			$data['target'] = get_post_meta( $id, 'fallback_target', true );
		}

		if ( bf_count( get_post_meta( $id, 'fallback_no_follow' ) ) > 0 ) {
			$data['no_follow'] = get_post_meta( $id, 'fallback_no_follow', true );
		}

		return $data;

	}


	/**
	 * Used for adding inline ads to post content in frond end
	 *
	 * @param string $content
	 *
	 * @return string
	 */
	function setup_post_content_ads( $content = '' ) {

		// Add post ads only 1 time
		if ( bf_is_doing_ajax() ) {
			static $initialized;

			if ( $initialized ) {
				return $content;
			} else {
				$initialized = true;
			}
		}

		if ( is_feed() ) {
			return $content;
		}

		if ( ! bf_is_doing_ajax() && ( ! is_singular() || is_front_page() ) ) {
			return $content;
		}

		if ( ! $this->wp_head_finished && ! bf_is_doing_ajax() && empty( $_GET['ajax_related_post'] ) ) {
			return $content;
		}

		//
		// Ads added to post before!
		//
		{
			static $processed_posts;

			if ( is_null( $processed_posts ) ) {
				$processed_posts = array();
			}

			if ( isset( $processed_posts[ get_the_ID() ] ) ) {
				return $content;
			} else {
				$processed_posts[ get_the_ID() ] = true;
			}
		}


		//
		// Disable ads
		//
		if ( ! better_ads_ad_can_be_shown( 'shortcode' ) ) {
			return $content;
		}


		//
		// Ad locations
		// todo add RSS ads
		//
		if ( $this->get_current_format() === 'amp' ) {
			$locations = array(
				'amp_post_inline'         => array(
					'type'            => 'paragraph',
					'container-class' => 'bsac-post-inline',
					'add-align'       => true,
					'multiple'        => true,
				),
				'amp_post_content_before' => array(
					'type'            => 'before',
					'container-class' => 'bsac-post-top',
					'add-align'       => true,
				),
				'amp_post_content_middle' => array(
					'type'            => 'middle',
					'container-class' => 'bsac-post-middle',
					'add-align'       => true,
				),
				'amp_post_content_after'  => array(
					'type'            => 'after',
					'container-class' => 'bsac-post-bottom',
					'add-align'       => true,
				),
			);
		} else {
			$locations = array(
				'ad_post_inline' => array(
					'type'            => 'paragraph',
					'container-class' => 'bsac-post-inline',
					'add-align'       => true,
					'multiple'        => true,
				),
				'ad_post_top'    => array(
					'type'            => 'before',
					'container-class' => 'bsac-post-top',
					'add-align'       => true,
				),
				'ad_post_middle' => array(
					'type'            => 'middle',
					'container-class' => 'bsac-post-middle',
					'add-align'       => true,
				),
				'ad_post_bottom' => array(
					'type'            => 'after',
					'container-class' => 'bsac-post-bottom',
					'add-align'       => true,
				),
			);
		}

		foreach ( $locations as $k => $v ) {

			$data = array();

			if ( ! empty( $v['multiple'] ) ) {
				$data = better_ads_get_ad_data( $k, true );
			} else {
				$data[] = better_ads_get_ad_data( $k, false );
			}

			foreach ( $data as $ad_item_k => $ad_item ) {

				if ( empty( $ad_item['active_location'] ) ) {
					continue;
				}

				if ( empty( $ad_item['align'] ) ) {
					$ad_item['align'] = 'center';
				}

				if ( ! empty( $v['container-class'] ) ) {
					$ad_item['container-class'] = $v['container-class'];
				} else {
					$ad_item['container-class'] = '';
				}

				if ( $v['add-align'] ) {
					$ad_item['container-class'] .= ' bsac-float-' . $ad_item['align'];
				}

				// Position of ad
				if ( $v['type'] === 'paragraph' ) {

					$inline_ad['paragraph'] = intval( $ad_item['paragraph'] );

					if ( $inline_ad['paragraph'] <= 0 ) {
						continue;
					}

					$position = $inline_ad['paragraph'];

				} elseif ( $v['type'] === 'before' ) {
					$position = 'top';
				} elseif ( $v['type'] === 'middle' ) {
					$position = 'middle';
				} else {
					$position = 'bottom';
				}

				// inject it
				bf_content_inject( array(
					'priority' => 1100, // High Priority [ again in our standards ;)) ]
					'position' => $position,
					'content'  => $this->show_ads( $ad_item ),
					'config'   => 'better-adsmanager',
				) );

			} // foreach items

		} // foreach locations


		if ( $block_elements = self::get_option( 'html_block_tags' ) ) {
			bf_content_inject_config( 'better-adsmanager', array(
				'blocks_elements' => explode( ',', $block_elements ),
			) );
		}

		return $content;
	}


	/**
	 * Callback: Ajax callback for retrieving blocked ads fallback!
	 */
	function callback_blocked_ads() {

		if ( ! empty( $_POST["ads"] ) ) {
			$ads_list = $_POST["ads"];
		} else {
			$ads_list = array();
		}


		// Create ads fallback code
		foreach ( (array) $ads_list as $ad_id => $ad ) {

			if ( empty( $ad['ad_id'] ) || empty( $ad['element_id'] ) ) {
				continue;
			}

			// prepare data
			$banner_data = $this->get_banner_fallback_data( $ad['ad_id'] );

			$output = '';

			switch ( $banner_data['type'] ) {

				case 'image':

					// custom title
					if ( ! empty( $banner_data['caption'] ) ) {
						$title = $banner_data['caption'];
					} else {
						$title = $banner_data['title'];
					}

					if ( ! empty( $banner_data['url'] ) ) {
						$output .= '<a itemprop="url" class="bsac-link" href="' . $banner_data['url'] . '" target="' . $banner_data['target'] . '" ';
						$output .= $banner_data['no_follow'] ? ' rel="nofollow" >' : '>';
					}


					$output .= '<img class="bsac-image" src="' . $banner_data['img'] . '" alt="' . $title . '" />';

					if ( ! empty( $banner_data['caption'] ) ) {
						$output .= '<span class="bsac-caption">' . $banner_data['caption'] . '</span>';
					}

					if ( ! empty( $banner_data['url'] ) ) {
						$output .= '</a>';
					}

					break;

				case 'code':

					$output .= $banner_data['code'];

					if ( ! empty( $banner_data['caption'] ) ) {
						$output .= '<span class="bsac-caption">' . $banner_data['caption'] . '</span>';
					}

					break;

			}

			$ads_list[ $ad_id ]['code'] = $this->make_prefix_undetectable( $output );
		}

		$result = array(
			'ads' => $ads_list
		);

		die( json_encode( apply_filters( 'better-ads/blocked-ads/fallback', $result ) ) );

	}


	/**
	 * Callback: Enable oculus error logging system for plugin
	 * Filter  : better-framework/oculus/logger/filter
	 *
	 * @access private
	 *
	 * @param boolean $bool previous value
	 * @param string  $product_dir
	 * @param string  $type_dir
	 *
	 * @return bool true if error belongs to theme, previous value otherwise.
	 */
	function oculus_logger( $bool, $product_dir, $type_dir ) {

		if ( $type_dir === 'plugins' && $product_dir === 'better-adsmanager' ) {
			return false;
		}

		return $bool;
	}


	/**
	 * Columns for banners
	 *
	 * @param $columns
	 *
	 * @return array
	 */
	function banner_columns( $columns ) {

		$columns = array(
			'cb'        => '<input type="checkbox" />',
			'format'    => __( 'Ad', 'better-studio' ),
			'title'     => __( 'Ad Name', 'better-studio' ),
			'shortcode' => __( 'Shortcode', 'better-studio' ),
			'date'      => __( 'Date', 'better-studio' ),
			'campaign'  => __( 'Campaign', 'better-studio' ),
		);

		return $columns;
	}


	/**
	 * Content of columns
	 *
	 * @param $column
	 * @param $post_id
	 */
	function banner_columns_content( $column, $post_id ) {

		switch ( $column ) {

			case 'format' :
				$format = bf_get_post_meta( 'format', $post_id );

				if ( $format === 'normal' || empty( $format ) ) {
					echo '<strong class="bsacadformat bsacadformatnormal" title="' . __( 'Normal Ad ', 'better-studio' ) . '"><i class="fa fa-desktop"></i></strong>';
				} else {
					echo '<strong class="bsacadformat bsacadformatamp" title="' . __( 'AMP Ad', 'better-studio' ) . '"><i class="fa fa-mobile"></i></strong>';
				}

				$type = bf_get_post_meta( 'type', $post_id );

				if ( $type == 'code' ) {
					echo '<strong class="bsacadtype bsacadtypeadsense" title="' . __( 'Google AdSense Ad', 'better-studio' ) . '"><i class="fa fa-google" "></i></strong>';
				} elseif ( $type == 'image' ) {
					echo '<strong class="bsacadtype bsacadtypeimage" title="' . __( 'Custom Image Ad', 'better-studio' ) . '"><i class="fa fa-image" "></i></strong>';
				} elseif ( $type == 'dfp' ) {
					echo '<strong class="bsacadtype bsacadtypedfp" title="' . __( 'Google DFP Ad', 'better-studio' ) . '"><i class="fa fa-google" "></i></strong>';
				} else {
					echo '<strong class="bsacadtype bsacadtypecode" title="' . __( 'Custom Code Ad', 'better-studio' ) . '"><i class="fa fa-code" "></i></strong>';
				}

				break;

			case 'shortcode' :


				$banner_data = $this->get_banner_data( $post_id );

				if ( empty( $banner_data['active-ad'] ) ) {
					echo '<strong class="bsacshortcodeempty">' . __( 'Ad configuration is not correct.', 'better-studio' ) . '</strong>';
				} else {
					echo '<strong class="bsacshortcodecopy">' . "[better-ads type='banner' banner='{$post_id}' ]" . '</strong>';
				}

				break;

			case 'campaign' :

				$campaigns = bf_get_post_meta( 'campaign', $post_id );
				$all_camps = better_ads_get_campaigns_option( - 1 );

				if ( $campaigns && $campaigns != 'none' ) {
					foreach ( (array) $campaigns as $camp ) {
						if ( isset( $all_camps[ $camp ] ) ) {
							echo '<strong class="bsacadcamp">' . $all_camps[ $camp ] . '</strong>';
						}
					}
				}
				break;

			default :
				break;
		}

	}


	/**
	 * Fix admin menu margins for better UX
	 */
	public function admin_styles() {

		?>
		<style>
			#adminmenu li#toplevel_page_better-studio-better-ads-manager,
			#adminmenu .toplevel_page_better-amp-translation {
				margin-top: 10px;
				margin-bottom: 10px;
			}

			#adminmenu li[id^="toplevel_page_better-studio"] + li#toplevel_page_better-studio-better-ads-manager,
			#adminmenu li[id^="toplevel_page_better-studio"] + .toplevel_page_better-amp-translation {
				margin-top: -10px;
				margin-bottom: 10px;
			}
		</style>
		<?php
	}


	/**
	 * Prints codes into site header.
	 *
	 * @hooked wp_head
	 *
	 * @since  1.9
	 */
	public function print_wp_head() {

		// FTP code
		if ( $dfp_code = self::get_option( 'dfp_code' ) ) {
			echo $dfp_code;
		}

	}


	/**
	 * Save only active override fields
	 *
	 * @param array $args
	 *
	 * @return array
	 */
	public static function handle_ads_manager_override_save( $args = array() ) {

		if ( $args['id'] !== 'better_ads_manager' ) {
			return $args;
		}

		$fields_list = better_ads_get_override_fields_list();   // All fields
		$sections    = better_ads_get_override_sections_list(); // All sections
		$ad_fields   = array();


		//
		// Collect all active (For performance improvement)
		//
		foreach ( $fields_list as $field ) {
			if ( isset( $field['ad-id'] ) && isset( $field['id'] ) ) {
				$ad_fields[ $field['ad-id'] ][] = $field['id'];
			}
		}

		//
		// All Types
		//
		foreach ( $sections as $type_id => $type ) {

			//
			// Sections
			//
			foreach ( $type['items'] as $section ) {

				//
				// Detected fields
				//
				foreach ( $ad_fields as $field_k => $field ) {

					// Ad condition ID
					$condition_field_id = 'ovr_' . $section['id'] . '-' . $field_k . '-active';

					// IF ad override is active
					if ( ! isset( $args['data'][ $condition_field_id ] ) || ! $args['data'][ $condition_field_id ] ) {

						unset( $args['data'][ $condition_field_id ] );

						foreach ( $field as $_k ) {
							unset( $args['data'][ 'ovr_' . $section['id'] . '-' . $_k ] );
						}
					}
				}

			}

		}

		return $args;

	} // handle_ads_manager_override_save


	/**
	 * Removes all override settings in panel
	 *
	 * @return array
	 */
	public static function reset_panel_override_settings() {

		$lang = bf_get_current_language_option_code();

		$ads_options = get_option( self::$panel_id . $lang );


		//
		// Remove all options that start with "ovr_"
		//
		foreach ( $ads_options as $id => $value ) {
			if ( substr( $id, 0, 3 ) === 'ovr_' ) {
				unset( $ads_options[ $id ] );
			}
		}

		// Updates option
		update_option( self::$panel_id . $lang, $ads_options );

		Better_Framework()->admin_notices()->add_notice( array(
			'msg' => __( 'All ad override settings was removed.', 'better-studio' ),
		) );

		return array(
			'status'  => 'succeed',
			'msg'     => __( 'All ad override settings was removed.', 'better-studio' ),
			'refresh' => true
		);

	}


	/**
	 * Filter Callback: Registers shortcode to BetterStudio Editor Shortcodes Plugin
	 *
	 * @param $shortcodes
	 *
	 * @return mixed
	 */
	public static function register_shortcode_to_editor( $shortcodes ) {

		$shortcodes['better-ads'] = array(
			'type'     => 'button',
			'label'    => __( 'Better Ads', 'better-studio' ),
			'callback' => 'BetterAds',
			'register' => false,
			'content'  => '[better-ads]<br />'
		);

		return $shortcodes;
	}


	/**
	 * Configs BF Editor Shortcodes library
	 *
	 * @param $config
	 *
	 * @return array
	 */
	public function editor_shortcodes_config( $config ) {

		// dynamic styles
		$config['editor-dynamic-style'][] = Better_Ads_Manager::dir_path( 'includes/dynamics/editor_css.php' );

		// Show sidebars
		$config['layouts'] = false;

		return $config;
	}


	/**
	 * Returns (and generates) the unique ID for BAM codes
	 *
	 * @param bool $reset
	 *
	 * @return string
	 */
	function get_unique_id( $reset = false ) {

		$id  = false;
		$key = 'bam-unique-id';

		if ( ! $reset ) {
			$id = get_option( $key, $id );
		}

		if ( ! $id ) {
			$id = substr( str_shuffle( "abcdefghijklmnopqrstuvwxyz" ), 0, mt_rand( 3, 10 ) );
			update_option( $key, $id, true );
		}

		return $id;
	}


	/**
	 * Changes all BAM related classes and texts to the unique ID
	 * This makes BAM completely undetectable.
	 *
	 * @return mixed
	 */
	function make_prefix_undetectable( $code ) {

		return str_replace(
			array(
				'bsac',
				'Better_Ads_Manager_Ajax_URL',
				'Better_Ads_Manager',
				'better-ads',
			),
			array(
				BAM_PREFIX,
				'\'' . admin_url( 'admin-ajax.php' ) . '\'',
				BAM_PREFIX,
				BAM_PREFIX,
			),
			$code
		);
	}


	/**
	 * Filter callback: Used for clearing the unique id on save
	 *
	 * @param $output
	 * @param $args
	 *
	 * @return string
	 */
	function callback_panel_save_result( $output, $args ) {

		// change only for BAM panel
		if ( $args['id'] == self::$panel_id ) {

			// Reset unique ID
			self::get_unique_id( true );
		}

		return $output;
	}


	/**
	 * @hooked admin_head
	 */
	function print_admin_head() {

		// Prints BetterAds CSS codes in the header of Gutenberg pages
		// This css code is dynamic
		if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {

			$code = '';

			ob_start();
			include bf_append_suffix( self::dir_path( 'css/bam' ), '.css' );
			$code .= ob_get_clean();

			ob_start();
			include bf_append_suffix( self::dir_path( 'css/gutenberg' ), '.css' );
			$code .= ob_get_clean();

			$code = $this->make_prefix_undetectable( $code );

			echo "<!-- Better Ads Dynamic CSS Code --><style>{$code}</style>";
		}
	}


	/**
	 * Changes the output of BetterAds widget to make it not detectable for Ad Blcokers!
	 *
	 * @param $params
	 *
	 * @return mixed
	 */
	function dynamic_sidebar_params( $params ) {

		if ( ! empty( $params[0]['widget_id'] ) && substr( $params[0]['widget_id'], 0, 11 ) === "better-ads-" ) {
			$params[0]['before_widget'] = Better_Ads_Manager()->make_prefix_undetectable( $params[0]['before_widget'] );
		}

		return $params;
	}


	/**
	 * Clear's BF cache to generate it again to make sure the BAM
	 * auto generated CSS codes will be added to BF CSS cache.
	 */
	public static function plugin_activation_hook() {

		global $wpdb;

		delete_transient( '__better_framework__widgets_css' );
		$wpdb->query( $wpdb->prepare( "
                      DELETE
                      FROM $wpdb->options
                      WHERE option_name LIKE %s
                  ", '_transient___better_framework__panel_css%' ) );
		delete_transient( '__better_framework__menu_css' );
		delete_transient( '__better_framework__terms_css' );

		$wpdb->query( $wpdb->prepare( "
                      DELETE
                      FROM $wpdb->options
                      WHERE option_name LIKE %s
                  ", '_transient___better_framework__final_fe_css%' ) );
		$wpdb->query( $wpdb->prepare( "
                      DELETE
                      FROM $wpdb->options
                      WHERE option_name LIKE %s
                  ", '_transient___better_framework__final_fe_css_version%' ) );
	}


	/**
	 * Clear Ad caches while saving
	 *
	 * @param $post_id
	 * @param $post
	 * @param $update
	 */
	function save_ads_post( $post_id, $post, $update ) {

		if ( wp_is_post_revision( $post_id ) ) {
			return;
		}

		$post_type = get_post_type( $post_id );

		// IS ads post?
		if ( 'better-banner' != $post_type ) {
			return;
		}

		// collect final data
		delete_transient( $this->get_meta_cache_id( $post_id ) );
	}


	/**
	 * Return meta cache ID based for current version of plugin
	 *
	 * @param $post_id
	 *
	 * @return string
	 */
	function get_meta_cache_id( $post_id ) {

		return $this->meta_cache_id . '-' . self::$version . '-' . $post_id . '-';
	}


	/**
	 * hooked to wp_head action
	 */
	function wp_head() {

		// Save this to know the wp_head was finished or not
		// do not show ads on the the_content inside the wp_head
		$this->wp_head_finished = true;

		if ( ! empty( self::get_option( 'custom_css_code' ) ) ) {
			echo '<style>',
			str_replace(
				array(
					'<style>',
					'</style>'
				),
				'',
				self::get_option( 'custom_css_code' )
			),
			'</style>';
		}

		echo self::get_option( 'custom_header_code' );
	}
}
�PNG


IHDRZ7���dPLTE������.�@???���1�C�����މ���������ڱ��0�A/�A�������������������¤ѫ����������ʤ�����������Ǻ���մ2�E-�E��������ֶ���ʞ�ǚ����������������������������Ķ۽����׶�ͥ�˟+�C��������������������˻��ٻ�Ա�԰����ˡ\\\0�B������������������������ʳ���Φ{��*�B.�?=�8��������������������������������æҮ����̣���r�~+�D1�CG�8��)��)������μ�¸ܾ����ٹ�Ϩ�ŗ��������zzza�olllWWWPPP2�F5�F2�E.�@V�)g�#t����������̿�Ž���ϧ��������������󔆆�u��n�zk�x��t[�jY�hfffW�eZZZCCC'�A��?8�?4�<6�4N�+m�j������������������������޺�ﭟШ���z���Ō~�����V��V?�R?�NHHH��A��>K�1[�*_�'������
�����V�l�IDATX��gSQ���:  Ui"
�DT{I��k,�D�-��{��{��O�,�d�觐/	�����Ͻs�ebĈ#�_b����?|��jO�*��Cs�z��=��/��p2��0�R��_�3�TVE��DA
��Q�3Η��Ì�mLLH8�q��礪0��ƒ�T���,Z������Dvk0�Zw�"|���!7���t�{�A���[:�Gd]�E��g��H�A���nj#���ܸ@Q��Y5��:�Y+�����>�WP���:�r�8�:C�-5:����ԇXs���/o�b�[)*!0��i9�Y�BW��M����b@P�H<��˄#���	�z�]:ט����d��s�i�p��4$�BO�ũB5Fڤ�}�a^VqըN���#�g�<��[��V�p��S�!����Og��-��6�)o�oY�ə��v��z�R��g1�w,�,U�PW=�zż����TB!��nL��զj!.ܬ��I'4�0O��g��j���U�}�&������͛P�~:����歬:	��mɡP�Y�&E�|~ȽSX�-�CȧL�ZEX&�
�P���^���?ΒH�
�4w3�
E�z�m0��⒬@eX���
iݣ�g�Q�%["��m�=���$�H�3x[�ByMf'�v-X� �I3[�ũ^C����.\�����p(��$b�qQ*�R���q�����=|�˙B��2�ƥ@u	��kˀLR�3]Kڭ��45LP��dD�)�LC��T�k���'�mʖ"�[�o����"@�T.L�X3G4A�-HWn=�ˑYӵ`�À3*���A9\�k�G��oM�G�����A�cr@\-��j�lWE�
P
Y�{���P�(��>�[��-e6R%Ҕ
<��I�|���!�ӑG_���$5�Y�����wQ�ϯ�-�]�-J]��
������.Մ���U0�6gޘkM�7NE8�IǼơ"j����6E��~km�R���UT$-oǟ
"���9���������dw��A�t*G�9m%��[�m���7��,�?���b%	$�N�(�y\�1\d�j"z�3D7���	B�A����SOXs��Z��^U��S�yoV��DU��Gpi� yk��Z��zM﬉�1MTO���j����?�;�%��N�lIEND�B`��PNG


IHDRZ7����PLTE�����������˴��zzzDDD���PPP���```��߿��^^^���GGG������LLL������������@@@+++


��٠����������������Ƈ��nnnRRR������eee<<<111$$$###�����ͭ�����|||vvv666555�
�=IDATX����r�0��E[(E
�ȾY���?Y�&u�(���U2��.�䐡��%�ѥ<�����j;�U��Hk���<I�8�Т(Z��ah�zг��8�h�cY��O����
����s+�#��i8�K)IeI�������5����B��
�i2��?�zx�٦4Y^�vc��K�h����X���ښ0�0��p^������$7Ў�T�A���Am�R�YO�B�`����B����5�#Ta�K�t�L{��W�f�W���Y�F*���ж�%���.�V�ҁ1�+_�А�~L�q�o�IEND�B`��PNG


IHDRZ7����PLTE���������A�����C�����������Hw���Ŵ���������Ly����={��������ø�����������P|������������������ɶ����p��>����������g��S�Et�������;w�����<1����������y��?��;�����=|�=y��������������Կ�������ˇ�@5�������������u��L��c��K��7~����?~�4t����:x�9u���������Ǻ����zDŽ��z�y�rk�ng��M�NC�������������������r��@��>��4v����3r�2p����-k��������������󸴱����髤�����xqR�a�KA�A;��&��������������������[�������������������M~����������kS�iR�e��]L�\�bZ��Y�[T�TK��G��D��;��6��2�8.����������������E��������������~�����o��e��G��]��V����������������8r��������������V~��ƽ�\����ܵ���c���ج��礠��b{��ҡ����Н����ڋ�߈����ރ�̂r�~��y��w��q��p��p��i��b�f^��[�XI��G��@��4��/��&�$��P�.IDATX���UTSq�����B��6`�6e��
�Fl�@AP���������������]ݘ��>�>��=����gN�%��w=�G3���*+H�%.�Ĭ�gA;B���U�\��=+7f�,e��h�����A[�U)��u��0�6z>�T��ް
p���.]�fM�
����~�9�0���k��‚�,G��%t)	W&����>�n+��J��*��4$��!f��h|鏠�<�F�]��_BnRһ�p�!͖��a,��:O|y�ݒ2�,]�#��ڌ�W�\E�]v������©��K�aW^۔ZT)���C_�3�1���*Ve�2ϻ�n����qq$���p@4�V�1�P���1Rw,�,.Ԓ�k��y�]�1v �Z�2�*j�y��a�xT@V�D��`Ҫ����zN%�1��9m�$p�gnZ�^�_���j,M�j��
8տ߅I	�0�Y=pє��y��uCv��L8ῌf)Ӿ(hVa�f�#7��qF�ө.�Y\���Q�Ub�sW��n}�n8?�ֲW�G������G���y��O4s�k���-�O*^}��tsq�&�f���&�{Ѫf
��aM4���:�5����T.���[~~�۴5^�޴*�ӂ,��-���,�:1����F?S��OMSy�m���&'�SCS��bl���U��O��C��U,�3�x�<�
J@���$�H��@;�x81�4�F�qޔ���x��
a�UJ9L�pR���z���&P�}o�E�%J�@�4�\��@��5XԦ�)ݢx�m�"����T&�C�H���
�2�p��"��y!��
�.ZۧT���`%���t��09�S�e6[��J��B.R��b���	���Sǔ�>VR�Z���ҥ@gH)��8�D�� :�R�%�����X�}��m۶�U�UrX��(R��e�j�Z'�0��(��f���h�DG���ua�WO���� E�����E\�"Z/�'�
C��(@%
�!�+��xxxx��~�^�&"��IEND�B`��PNG


IHDRZ7����PLTE������```???���888���]]]LLL333��ؿ�������񪪪���hhh������������nnnCCC��������ű��������kkkXXXRRROOO���HHH===�����������ʝ��|||uuurrr@@@������������xxx[[[555///)))���������UUU������pppddd,,,"""�����Հ����o��IDATX����r�@���
���@@�1γ�9sr�t@bY�l,au�gA�݋w������z<舘D����V��>��+"J�5A@�>򈆞��+�p2�a�<H��>�ŀ��;��iAo�v[f�I�+�m^��CH֚�h| �y��FB�8��k���Y���p�ْ���:?i6'ѥ3t@`N6f3D�NS�Oj�0-Q?���hS�4>]!��v�|�M
���ƇM�,�
�x��,AgK2�g�r*�ښh��Wc�K�M#�H܈#N$�,؂<R�4
��ޜ��']aXśF����xAU/���޴��\���`��F�Y��nT���/^��)�Y���p��EZC��ﺩ6ɓ`���m����5�I��HJ1��x�N�S�8/7Kƀj	��7�L�b6l�.8���=����ԟi~��{���*���w{CӯNw�������m�ǜ�Л�� ��P�Je�ز���Ȕ�xe�-u
��X����v�ћ�S�2���c�J%�JF�b���9���]���KŦfao��,)�f��2m���{i����*����V�躇��w�9��	s7�`�d\�;nZJ�b#�wU�`�G��ql����q�����_�;����/�>��AWIEND�B`��PNG


IHDR<,9*��gAMA���aeIDAThc�v���X@~�T�^�~�)ӈ�)�'G=�Ò	���|ֹ�6a���C��zϜ9gӊabb��h�ƪ�J��C%��C���Y�������
7���������ן�?���F���c��b���؃ O�80�p2������ǯ���fx��3N��$
�/ß��4dE.��ԕ/N�|�`�%�f��0w�Y�������I��t��|��p��+] ���,���=vVqd�A�&:I�(����E`�>}�	�<��@�̧o?����005�C"I+�2�p�3Ȋ��=�+/�p��C	�r�c�50/�C"I���o?��(VA�J�0��� 7#U�/��{��{�Ԡ��JҠ�HUJ\(��((���t�� yUCF��ǯ?2�8x	��B��@&iFP�[o��--��D���J�Ԏ�A�����`�h�F�z$;d����U���ø4P�a�6���4�G�p��h��Ep���I��@���81�h�&�גd;F\�z��42�4����0��;�bgK_БS�3��r�1�Ѷ4,$�8=��a8��a!1����G=<�S,A�[Z���x�gR��IEND�B`��PNG


IHDRZ7����PLTE���???�����������MMM�����������������Ҷ�����wwweeeIII������oooQQQFFFAAA���UUU��ʼ��������������bbb�����ړ��yyyjjj^^^NNN�����������Š�����}}}mmmgggYYYDDDCCC��������Ǧ��������ttt[[[�����Ѿ��nnn			���666***�>�IDATX���ג�@���n�$  c�9�9M���ŵ
��U�`j����)��ƣG������@�r(�:	��{���x4~H�f�91.߅�c��3dm<yǞ$���(a�ks��i���5)EC�N���z�m�>��gJ���әGg�Ű���YZ�z ��$�t�,�x9������[_O+�@��A+��f~����/����Ҷ/]Kӗ�S�i�#��+��	��ۛ�a���?�8���D*�<�w��z_;�P
��>�l�u��ƹGɕ1oj~~�g��~������f�:����i���_������%2Ţl��]�<����n��gP6����S0�jh(�v����*��
O�0��3aD�K�h�xG�����hZ�U���F���.�H�vZ���K����S�j0�P�o�G��f�l~�n���CbX�	�(���H}歞���oe��gMv& :o"N�T���欢­lw�U`�X�N3.-t�A4_ԲJ�p���j
HRq�q���.��4��-�.q��ijDT��6�,�$�#m��\�!j���DH��_�z@�7:^ ��7h���A�0p�b�G����Z�M��*
5�G8"�=�&s���bq@/�'��$#\/+[�6�tƻ%Ϟ��ꕫI���X�N�妔Qham;i��	��k/2D���g�Ј�Ӂ�eC�Q(X|&��Ng������>ΔGߧ_r�C��WHIEND�B`��PNG


IHDRZ7���uPLTE������+++kkk�����Ο�����]]]���---'''�����������Ł��ddd444���```TTT<<<��������ʶ�����������������qqqYYY!!!c�� �IDATX���G�@�a�IH¤�B��?"J������eY&MӴ���u�M�|f+.�A�u�r�	|r���F�%c��6��/���f�� %�z��45�sY�O�s>��q]��52�!��5F��^�N�$E���k�Wz�n��W|t�z�8�Z�D����K|�Y���g��I�O�۹$M�4�^k����FIEND�B`�<?php

if ( bf_is_amp() == 'better' ) {
	better_amp_enqueue_ad( 'dfp' );
}

$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;
$ad_code = '';

if ( $caption == 'above' ) {
	$ad_code .= "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>";
}

if ( $banner_data['dfp_spot'] === 'custom' ) {
	$ad_code .= $banner_data['custom_dfp_code'];
} else {

	$style = '';

	// no width and height means the spot have multiple dimensions
	if ( ! empty( $banner_data['dfp_spot_width'] ) && ! empty( $banner_data['dfp_spot_height'] ) ) {
		$style = 'width=' . $banner_data['dfp_spot_width'] . ' height=' . $banner_data['dfp_spot_height'];
	}

	$ad_code .= '<amp-ad ' . $style . ' type="doubleclick" data-slot="' . $banner_data['dfp_spot_id'] . '"></amp-ad>';
}

if ( $caption === 'below' ) {
	$ad_code .= "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
}

return $ad_code;
<?php

Better_Ads_Manager()->enqueue_adblocker_detector();

if ( ! empty( $banner_data['caption'] ) ) {
	$title = $banner_data['caption'];
} else {
	$title = $banner_data['title'];
}

$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;

$_ad = '';

if ( $caption == 'above' ) {
	$_ad .= "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>";
}

if ( ! empty( $banner_data['url'] ) ) {
	$_ad .= '<a itemprop="url" class="bsac-link" href="' . $banner_data['url'] . '"' . ( $banner_data['target'] ? ' target="' . $banner_data['target'] . '"' : '' ) . ' ';
	$_ad .= $banner_data['no_follow'] ? ' rel="nofollow" >' : '>';
}

$_ad .= '<img class="bsac-image" src="' . $banner_data['img'] . '" alt="' . $title . '" />';

if ( ! empty( $banner_data['url'] ) ) {
	$_ad .= '</a>';
}

if ( $caption === 'below' ) {
	$_ad .= "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
}

return $_ad;
<?php

Better_Ads_Manager()->enqueue_adblocker_detector();


$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;
$ad_code = '<div id="' . $banner_data['element_id'] . '-place"></div>';

if ( $caption == 'above' ) {
	$ad_code = "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>" . $ad_code;
}

if ( ! $this->is_google_adsence_printed ) {
	$ad_code                         .= '<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';
	$this->is_google_adsence_printed = true;
}

if ( $banner_data['lazy-load'] == 'enable' && ! $this->is_google_adsence_lazy_printed ) {
	$ad_code                              .= '<script>' . bf_get_local_file_content( bf_append_suffix( self::dir_url( '/js/adsense-lazy' ), '.js' ) ) . '</script>';
	$this->is_google_adsence_lazy_printed = true;
}


//
// Ad Attrs
//
{
	$_attrs = array(
		'ad-client',
		'ad-slot',
		'ad-layout',
		'ad-layout-key',
		'full-width-responsive',
		'matched-content-ui-type',
		'matched-content-rows-num',
		'matched-content-columns-num',
	);

	$ad_attrs = '';

	foreach ( $_attrs as $_attr ) {

		if ( empty( $banner_data[ $_attr ] ) ) {
			continue;
		}

		$ad_attrs .= " data-{$_attr}=\"{$banner_data[ $_attr ]}\" ";
	}
}


$ad_code .= '<script type="text/javascript">';
$ad_code .= 'var betterads_screen_width = document.body.clientWidth;';
$ad_code .= $this->_fix_new_lines( 'betterads_el = document.getElementById(\'' . $banner_data['element_id'] . '\');
								
			if (betterads_el.getBoundingClientRect().width) {
				betterads_el_width_raw = betterads_el_width = betterads_el.getBoundingClientRect().width;
			} else {
				betterads_el_width_raw = betterads_el_width = betterads_el.offsetWidth;
			}
			
			var size = ["125", "125"];
			if ( betterads_el_width >= 728 ) 
				betterads_el_width = ["728", "90"];
			else if ( betterads_el_width >= 468 )
				betterads_el_width = ["468", "60"];
			else if ( betterads_el_width >= 336 )
				betterads_el_width = ["336", "280"];
			else if ( betterads_el_width >= 300 )
				betterads_el_width = ["300", "250"];
			else if ( betterads_el_width >= 250 )
				betterads_el_width = ["250", "250"];
			else if ( betterads_el_width >= 200 )
				betterads_el_width = ["200", "200"];
			else if ( betterads_el_width >= 180 )
				betterads_el_width = ["180", "150"];
' );

$ifs = array();

if ( $banner_data['ad-format'] !== 'auto' ) {
	$normal_ad = 'document.getElementById(\'' . $banner_data['element_id'] . '-place\').innerHTML = \'<ins class="adsbygoogle" style="display:inline-block;width:\' + betterads_el_width_raw + \'px" ' . $ad_attrs . ' data-ad-format="' . $banner_data['ad-format'] . '"></ins>\';
								(adsbygoogle = window.adsbygoogle || []).push({});';
} else {

	if ( ! empty( $banner_data['full-width-responsive'] ) ) {

		// ad-format has to be set, It makes issue for the full-width-responsive ads.
		if ( $banner_data['ad-format'] == 'auto' ) {
			$ad_attrs .= ' data-ad-format="auto" ';
		}

		$normal_ad = 'document.getElementById(\'' . $banner_data['element_id'] . '-place\').innerHTML = \'<ins class="adsbygoogle" style="display:block;" ' . $ad_attrs . '></ins>\';
								(adsbygoogle = window.adsbygoogle || []).push({});';
	} else {
		$normal_ad = 'document.getElementById(\'' . $banner_data['element_id'] . '-place\').innerHTML = \'<ins class="adsbygoogle" style="display:inline-block;width:\' + betterads_el_width[0] + \'px;height:\' + betterads_el_width[1] + \'px" ' . $ad_attrs . '></ins>\';
								(adsbygoogle = window.adsbygoogle || []).push({});';
	}
}

$_size_check = array(
	'vertical'   => '',
	'horizontal' => '',
	'rectangle'  => '',
);

// Customize to show in tinyMCE view always
if ( bf_is_user_logged_in() && bf_is_doing_ajax( 'fetch-mce-view-shortcode' ) ) {
	$banner_data['show_desktop']          = true;
	$banner_data['show_tablet_landscape'] = true;
	$banner_data['show_tablet_portrait']  = true;
	$banner_data['show_phone']            = true;
}

$_size_fields = array(
	array(
		'show'      => 'show_desktop',
		'size'      => 'size_desktop',
		'condition' => 'betterads_screen_width >= 1140',
	),
	array(
		'show'      => 'show_tablet_landscape',
		'size'      => 'size_tablet_landscape',
		'condition' => 'betterads_screen_width >= 1019  && betterads_screen_width < 1140',
	),
	array(
		'show'      => 'show_tablet_portrait',
		'size'      => 'size_tablet_portrait',
		'condition' => 'betterads_screen_width >= 768  && betterads_screen_width < 1019',
	),
	array(
		'show'      => 'show_phone',
		'size'      => 'size_phone',
		'condition' => 'betterads_screen_width < 768',
	),
);

foreach ( $_size_fields as $_size_ad ) {

	if ( empty( $banner_data[ $_size_ad['show'] ] ) ) {
		continue;
	}

	// vertical and horizontal
	if ( is_string( $banner_data[ $_size_ad['size'] ] ) && isset( $_size_check[ $banner_data[ $_size_ad['size'] ] ] ) ) {

		$ifs[] = $this->_fix_new_lines( 'if ( ' . $_size_ad['condition'] . ' ) {
									document.getElementById(\'' . $banner_data['element_id'] . '-place\').innerHTML = \'<ins class="adsbygoogle" style="display:inline-block;width:\' + betterads_el_width_raw + \'px" ' . $ad_attrs . ' data-ad-format="' . $banner_data[ $_size_ad['size'] ] . '"></ins>\';
									(adsbygoogle = window.adsbygoogle || []).push({});
								}' );

	} // with and height in pixel
	elseif ( is_array( $banner_data[ $_size_ad['size'] ] ) ) {

		$ifs[] = $this->_fix_new_lines( 'if ( ' . $_size_ad['condition'] . ' ) {
									document.getElementById(\'' . $banner_data['element_id'] . '-place\').innerHTML = \'<ins class="adsbygoogle" style="display:inline-block;width:' . $banner_data[ $_size_ad['size'] ][0] . 'px;height:' . $banner_data[ $_size_ad['size'] ][1] . 'px" ' . $ad_attrs . '></ins>\';
									(adsbygoogle = window.adsbygoogle || []).push({});
								}' );

	} // auto
	else {
		$ifs[] = $this->_fix_new_lines( 'if ( ' . $_size_ad['condition'] . ' ) { ' . $normal_ad . '}' );
	}
}

$ad_code .= implode( 'else ', $ifs );

$ad_code .= '</script>';

if ( $caption === 'below' ) {
	$ad_code .= "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
}

//
// Makes the adsense code lazy load!
//
if ( $banner_data['lazy-load'] == 'enable' ) {
	$ad_code = str_replace( '<div id="' . $banner_data['element_id'] . '-place">', '<div id="' . $banner_data['element_id'] . '-place" class="bsac-ll">', $ad_code );
	$ad_code = str_replace( 'class="adsbygoogle"', '', $ad_code );
	$ad_code = str_replace( '></ins>', '><span>' . Better_Ads_Manager::get_option( 'lazy_loading_text' ) . '</span></ins>', $ad_code );

	$code = $this->_fix_new_lines( 'instant= new adsenseLoader( \'#' . $banner_data['element_id'] . '-place\', {
    onLoad: function( ad ){
	    if (ad.classList.contains(\'bsac-ll\')) {
	        ad.classList.remove(\'bsac-ll\');
	    }
	  }   
	});' );

	$ad_code = str_replace( '(adsbygoogle = window.adsbygoogle || []).push({});', $code, $ad_code );
}


return $ad_code;
<?php

Better_Ads_Manager()->enqueue_adblocker_detector();

$ad_code = '';
$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;

if ( $caption == 'above' ) {
	$ad_code .= "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>";
}

if ( $banner_data['dfp_spot'] === 'custom' ) {
	$ad_code .= $banner_data['custom_dfp_code'];
} else {

	$style = '';

	// no width and height means the spot have multiple dimensions
	if ( ! empty( $banner_data['dfp_spot_width'] ) && ! empty( $banner_data['dfp_spot_height'] ) ) {
		$style = '"style="width:' . $banner_data['dfp_spot_width'] . 'px; height:' . $banner_data['dfp_spot_height'] . 'px;"';
	}

	$ad_code .= '<!-- ' . $banner_data['dfp_spot_id'] . ' -->
<div id="' . $banner_data['dfp_spot_tag'] . '" ' . $style . '>
<script>
googletag.cmd.push(function() { googletag.display("' . $banner_data['dfp_spot_tag'] . '"); });
</script>
</div>';

}

if ( $caption === 'below' ) {
	$ad_code .= "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
}

return $ad_code;
<?php

$attrs = array(
	'type' => 'adsense',
);

$_attrs = array(
	'ad-client',
	'ad-slot',
	//'ad-format', ad format not needed for AMP
	'full-width-responsive', // full width ad in mobile devices
	'ad-layout',
	// 'ad-layout-key', this type of ads does not supported in amp currently!
	// https://github.com/ampproject/amphtml/issues/10957
	'matched-content-ui-type',
	'matched-content-rows-num',
	'matched-content-columns-num',
);

$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;

$ad_attrs = '';

foreach ( $_attrs as $_attr ) {

	if ( empty( $banner_data[ $_attr ] ) ) {
		continue;
	}

	$attrs[ 'data-' . $_attr ] = $banner_data[ $_attr ];
}


if ( ! empty( $banner_data['size']['width'] ) && ! empty( $banner_data['size']['height'] ) ) {
	$attrs['width']  = $banner_data['size']['width'];
	$attrs['height'] = $banner_data['size']['height'];
} elseif ( empty( $banner_data['size']['width'] ) && ! empty( $banner_data['size']['height'] ) ) {
	$attrs['height'] = $banner_data['size']['height'];
	$attrs['layout'] = 'fixed-height';
} else {
	$attrs['width']  = '300';
	$attrs['height'] = '250';
}

if ( bf_is_amp() == 'better' ) {
	better_amp_enqueue_ad( 'adsense' );
}

//
// Change the full-width-responsive to layout=responsive for AMP
//
if ( isset( $attrs['data-full-width-responsive'] ) ) {
	unset( $attrs['data-full-width-responsive'] );
	$attrs['layout'] = 'responsive';
}

ob_start();

if ( $caption == 'above' ) {
	echo "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>";
}

?>
<amp-ad <?php

foreach ( $attrs as $k => $v ) {
	echo $k, '=', $v, ' ';
}

?>></amp-ad><?php

if ( $caption === 'below' ) {
	echo "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
}

return ob_get_clean();
<?php

if ( bf_is_amp() == 'better' ) {
	better_amp_enqueue_ad( 'image' );
}

$caption = ! empty( $banner_data['caption'] ) && $args['show-caption'] ? Better_Ads_Manager::get_option( 'caption_position' ) : false;

if ( ! empty( $banner_data['caption'] ) ) {
	$title = $banner_data['caption'];
} else {
	$title = $banner_data['title'];
}

$_ad = '';

if ( $caption == 'above' ) {
	$_ad .= "<p class='bsac-caption bsac-caption-above'>{$banner_data['caption']}</p>";
}

if ( ! empty( $banner_data['url'] ) ) {
	$_ad .= '<a itemprop="url" class="bsac-link" href="' . $banner_data['url'] . '"' . ( ! empty( $banner_data['target'] ) ? ' target="' . $banner_data['target'] . '"' : '' ) . ' ';
	$_ad .= $banner_data['no_follow'] ? ' rel="nofollow" >' : '>';
}

$_ad .= '<img class="bsac-image" src="' . $banner_data['img'] . '" alt="' . $title . '" />';

if ( ! empty( $banner_data['url'] ) ) {
	$_ad .= '</a>';
}

if ( $caption === 'below' ) {
	$_ad .= "<p class='bsac-caption bsac-caption-below'>{$banner_data['caption']}</p>";
}

return $_ad;
<?php


/**
 * Better Ads Widget
 */
class Better_Ads_Widget extends BF_Widget {


	/**
	 * Register widget with WordPress.
	 */
	function __construct() {

		// Back end form fields
		$this->fields = array(
			array(
				'name'          => __( 'Title', 'better-studio' ),
				'attr_id'       => 'title',
				'type'          => 'text',
				'section_class' => 'widefat',
			),
			array(
				'name'          => __( 'Ad Type', 'better-studio' ),
				'input-desc'    => __( 'Choose simple banner or campaign..', 'better-studio' ),
				'attr_id'       => 'type',
				'type'          => 'select',
				'section_class' => 'widefat',
				"options"       => array(
					''         => __( '-- Select Ad Type --', 'better-studio' ),
					'campaign' => __( 'Campaign', 'better-studio' ),
					'banner'   => __( 'Banner', 'better-studio' ),
				),
			),
			array(
				'name'               => __( 'Banner', 'better-studio' ),
				'attr_id'            => 'banner',
				'type'               => 'select',
				'deferred-options'   => array(
					'callback' => 'better_ads_get_banners_option',
					'args'     => array(
						- 1,
						true
					),
				),
				'filter-field'       => 'type',
				'filter-field-value' => 'banner',
			),
			array(
				'name'               => __( 'Campaign', 'better-studio' ),
				'attr_id'            => 'campaign',
				'type'               => 'select',
				'deferred-options'   => array(
					'callback' => 'better_ads_get_campaigns_option',
					'args'     => array(
						- 1,
						true
					),
				),
				'filter-field'       => 'type',
				'filter-field-value' => 'campaign',
			),
			array(
				'name'               => __( 'Max Amount of Allowed Banners', 'better-studio' ),
				'input-desc'         => __( 'Leave empty to show all banners.', 'better-studio' ),
				'attr_id'            => 'count',
				'type'               => 'text',
				'filter-field'       => 'type',
				'filter-field-value' => 'campaign',
			),
			array(
				'name'               => __( 'Columns', 'better-studio' ),
				'attr_id'            => 'columns',
				'type'               => 'select',
				"options"            => array(
					1 => __( '1 Column', 'better-studio' ),
					2 => __( '2 Column', 'better-studio' ),
					3 => __( '3 Column', 'better-studio' ),
				),
				'filter-field'       => 'type',
				'filter-field-value' => 'campaign',
			),
			array(
				'name'               => __( 'Order By', 'better-studio' ),
				'attr_id'            => 'orderby',
				'type'               => 'select',
				'section_class'      => 'widefat',
				"options"            => array(
					'date'  => __( 'Date', 'better-studio' ),
					'title' => __( 'Title', 'better-studio' ),
					'rand'  => __( 'Rand', 'better-studio' ),
				),
				'filter-field'       => 'type',
				'filter-field-value' => 'campaign',
			),
			array(
				'name'               => __( 'Order', 'better-studio' ),
				'attr_id'            => 'order',
				'type'               => 'select',
				'section_class'      => 'widefat',
				"options"            => array(
					'ASC'  => __( 'Ascending', 'better-studio' ),
					'DESC' => __( 'Descending', 'better-studio' ),
				),
				'filter-field'       => 'type',
				'filter-field-value' => 'campaign',
			),
			array(
				'name'          => __( 'Align', 'better-studio' ),
				'attr_id'       => 'align',
				'type'          => 'select',
				'section_class' => 'widefat',
				"options"       => array(
					'left'   => __( 'Left', 'better-studio' ),
					'center' => __( 'Center', 'better-studio' ),
					'right'  => __( 'Right', 'better-studio' ),
				),
			),
			array(
				'name'          => __( 'Show Captions', 'better-studio' ),
				'attr_id'       => 'show-caption',
				'type'          => 'select',
				'section_class' => 'widefat',
				"options"       => array(
					1 => __( 'Show caption\'s', 'better-studio' ),
					0 => __( 'Hide caption\'s', 'better-studio' ),
				),
			),
			array(
				'name'          => __( 'Lazy Load Ad?', 'better-studio' ),
				'desc'          => __( 'Chose the behaviour of lazy loading.', 'better-studio' ),
				'attr_id'       => 'lazy-load',
				'type'          => 'select',
				"options"       => array(
					''        => __( '-- Inherit from panel --', 'better-studio' ),
					'enable'  => __( 'Yes, Lazy load this ad', 'better-studio' ),
					'disable' => __( 'No, Load this Ad as normal', 'better-studio' ),
				),
				'std'           => 'center',
				'show_on'       => array(
					array(
						'type=banner',
					),
					array(
						'type=campaign',
					),
				),
				'section_class' => 'widefat',
			),
		);

		parent::__construct(
			'better-ads',
			__( 'Better Ads', 'better-studio' ),
			array( 'description' => __( 'Show campaign and banners.', 'better-studio' ) )
		);
	}
}
<?php


class Better_Ads_Shortcode extends BF_Shortcode {

	function __construct( $id, $options ) {

		$id = 'better-ads';

		$this->widget_id = 'better ads';

		$this->name = __( 'Ad Box', 'better-studio' );

		$this->description = 'BetterAds ad box';

		$_options = array(
			'defaults'              => array(
				'title'           => '',
				'type'            => '',
				'banner'          => 'none',
				'campaign'        => 'none',
				'count'           => 2,
				'columns'         => 1,
				'align'           => 'center',
				'lazy-load'       => '',
				'order'           => 'ASC',
				'orderby'         => 'rand',
				'float'           => 'none',
				'show-caption'    => true,
				'bs-show-desktop' => true,
				'bs-show-tablet'  => true,
				'bs-show-phone'   => true,
			),
			'have_widget'           => true,
			'have_vc_add_on'        => true,
			'have_tinymce_add_on'   => apply_filters( 'better-ads/shortcode/live-preview', true ),
			'have_gutenberg_add_on' => apply_filters( 'better-ads/shortcode/live-preview', true ),
		);

		$_options = wp_parse_args( $_options, $options );

		parent::__construct( $id, $_options );

	}


	/**
	 * Handle displaying of shortcode
	 *
	 * @param array  $atts
	 * @param string $content
	 *
	 * @return string
	 */
	function display( array $atts, $content = '' ) {

		// ad can not be shown
		if ( ! better_ads_ad_can_be_shown( bf_get_current_sidebar() ? 'widget' : 'shortcode' ) ) {
			return '';
		}

		// Add float class to shortcodes that are not inside a widget sidebar!
		if ( ! bf_get_current_sidebar() && isset( $atts['align'] ) ) {
			$atts['float'] = $atts['align'];
		}

		ob_start();
		echo Better_Ads_Manager()->show_ads( $atts );

		return ob_get_clean();

	}


	/**
	 * Registers Visual Composer Add-on
	 */
	function register_vc_add_on() {

		vc_map( array(
			"name"           => $this->name,
			"base"           => $this->id,
			"description"    => $this->description,
			"weight"         => 10,
			"wrapper_height" => 'full',

			"category" => __( 'Content', 'better-studio' ),
			"params"   => $this->vc_map_listing_all()
		) );

	} // register_vc_add_on


	/**
	 * Fields for all panels
	 *
	 * @return array
	 */
	public function get_fields() {

		return array(

			array(
				'type' => 'tab',
				'name' => __( 'General', 'better-studio' ),
				'id'   => 'general_tab',
			),
			array(
				"name"           => __( 'Ad Type', 'better-studio' ),
				"type"           => 'select',
				"id"             => 'type',
				'options'        => array(
					''         => __( '-- Select Ad Type', 'better-studio' ),
					'campaign' => __( 'Campaign', 'better-studio' ),
					'banner'   => __( 'Banner', 'better-studio' ),
				),
				//
				"vc_admin_label" => true,
			),
			//
			// Banner
			//
			array(
				"type"             => 'select',
				"name"             => __( 'Banner', 'better-studio' ),
				"id"               => 'banner',
				'deferred-options' => array(
					'callback' => 'better_ads_get_banners_option',
					'args'     => array(
						- 1,
						true
					),
				),
				'show_on'          => array(
					array( 'type=banner' ),
				),
				//
				"vc_admin_label"   => true,
			),
			//
			// Campaign
			//
			array(
				"type"             => 'select',
				"name"             => __( 'Campaign', 'better-studio' ),
				"id"               => 'campaign',
				'deferred-options' => array(
					'callback' => 'better_ads_get_campaigns_option',
					'args'     => array(
						- 1,
						true
					),
				),
				'show_on'          => array(
					array( 'type=campaign' ),
				),
				//
				"vc_admin_label"   => true,
			),
			array(
				"type"           => 'text',
				"name"           => __( 'Max Amount of Allowed Banners', 'better-studio' ),
				"desc"           => __( 'Leave empty to show all banners.', 'better-studio' ),
				"id"             => 'count',
				'show_on'        => array(
					array( 'type=campaign' ),
				),
				//
				"vc_admin_label" => false,
			),
			array(
				"type"           => 'select',
				"name"           => __( 'Columns', 'better-studio' ),
				"id"             => 'columns',
				"options"        => array(
					1 => __( '1 Column', 'better-studio' ),
					2 => __( '2 Column', 'better-studio' ),
					3 => __( '3 Column', 'better-studio' ),
				),
				'show_on'        => array(
					array( 'type=campaign' ),
				),
				//
				"vc_admin_label" => false,
			),
			array(
				"type"           => 'select',
				"name"           => __( 'Order By', 'better-studio' ),
				"id"             => 'orderby',
				"options"        => array(
					'date'  => __( 'Date', 'better-studio' ),
					'title' => __( 'Title', 'better-studio' ),
					'rand'  => __( 'Rand', 'better-studio' ),
				),
				'show_on'        => array(
					array( 'type=campaign' ),
				),
				'section_class'  => 'affect-block-align-on-change',
				//
				"vc_admin_label" => false,
			),
			array(
				"type"           => 'select',
				"name"           => __( 'Order', 'better-studio' ),
				"id"             => 'order',
				"options"        => array(
					'ASC'  => __( 'Ascending', 'better-studio' ),
					'DESC' => __( 'Descending', 'better-studio' ),
				),
				'show_on'        => array(
					array( 'type=campaign' ),
				),
				//
				"vc_admin_label" => false,
			),
			array(
				"type"           => 'select',
				"name"           => __( 'Align', 'better-studio' ),
				"id"             => 'align',
				"options"        => array(
					'left'   => __( 'Left', 'better-studio' ),
					'center' => __( 'Center', 'better-studio' ),
					'right'  => __( 'Right', 'better-studio' ),
				),
				'show_on'        => array(
					array( 'type=campaign' ),
					array( 'type=banner' ),
				),
				//
				"vc_admin_label" => false,
			),
			array(
				"type"           => 'select',
				"name"           => __( 'Show Captions', 'better-studio' ),
				"id"             => 'show-caption',
				"options"        => array(
					1 => __( 'Show caption\'s', 'better-studio' ),
					0 => __( 'Hide caption\'s', 'better-studio' ),
				),
				'show_on'        => array(
					array( 'type=campaign' ),
					array( 'type=banner' ),
				),
				//
				"vc_admin_label" => false,
			),
			array(
				'name'           => __( 'Lazy Load Ad?', 'better-studio' ),
				'desc'           => __( 'Chose the behaviour of lazy loading.', 'better-studio' ),
				'id'             => 'lazy-load',
				'type'           => 'select',
				"options"        => array(
					''        => __( '-- Inherit from panel --', 'better-studio' ),
					'enable'  => __( 'Yes, Lazy load this ad', 'better-studio' ),
					'disable' => __( 'No, Load this Ad as normal', 'better-studio' ),
				),
				'std'            => 'center',
				'show_on'        => array(
					array(
						'type=banner',
					),
					array(
						'type=campaign',
					),
				),
				'section_class'  => 'better-ads-ad-field',
				//
				"vc_admin_label" => false,
			),
		);
	}


	/**
	 * Registers configuration of tinyMCE views
	 *
	 * @return array
	 */
	function tinymce_settings() {

		$styles = array(
			array(
				'type' => 'custom',
				'url'  => bf_append_suffix( Better_Ads_Manager::dir_url( 'css/bam' ), '.css' ),
			),
		);

		return array(
			'name'   => __( 'Better Ads', 'better-studio' ),
			'styles' => $styles,
		);
	}


	/**
	 * Registers Page Builder Add-on
	 */
	function page_builder_settings() {

		return array(
			'name'           => __( 'Better Ads', 'better-studio' ),
			"id"             => $this->id,
			"weight"         => 10,
			"wrapper_height" => 'full',
			"category"       => $this->block_category(),
			'icon_url'       => Better_Ads_Manager::dir_url( 'images/vc-better-ads.png' ),

		);
	} // page_builder_settings


	/**
	 * Page builder block/map category.
	 */
	public function block_category() {

		global $pagenow;

		if ( defined( 'GUTENBERG_VERSION' ) && GUTENBERG_VERSION ) {

			// can not use is_gutenberg_page() function

			if ( in_array( $pagenow, array(
					'post.php',
					'post-new.php'
				) ) && ! isset( $_GET['classic-editor'] )
			) {

				return 'common';
			}

		}

		return __( 'Better Studio', 'better-studio' );
	}
}
Bud1bwspblob� @� @� @� @libsbwspblob�bplist00�	
			]ShowStatusBar_SidebarWidthTenElevenOrLater[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar[ShowPathbar	#@g�		_{{895, 322}, {1427, 869}}	'FR^u�����������libslsvCblob�bplist00�		IJKL_useRelativeDates_showIconPreviewWcolumns_calculateAllSizesXtextSizeZsortColumnXiconSize_viewOptionsVersion		�"&+05:?D�
		ZidentifierUwidthYascendingWvisibleTnameM		�
WvisibleUwidthYascending#Xubiquity�
	\dateModified�	�
#[dateCreated�
'(	Tsizea	�
,-		Tkinds		�
12	Ulabeld	�
67	WversionK	�
;<	Xcomments,	�
@A^dateLastOpened��
GYdateAdded#@(Tname#@0,>FZcnw���������������������!-./8=?@AJOQRS\bdefowyz{������������������M�libslsvpblob^bplist00�		FGHD_useRelativeDates_showIconPreviewWcolumns_calculateAllSizesXtextSizeZsortColumnXiconSize_viewOptionsVersion		�
#(-27<AXcomments^dateLastOpened[dateCreatedTsizeUlabelTkindWversionTname\dateModified�	WvisibleUwidthYascendingUindex,	� "��%'��	*,	a�/	1d	�	4	6	s	�9	;K	�	>	@	M	�	%D	#@(Tname#@0,>FZcnw��������������&')*,5689;DEGHJSTVWYbcefhqrtuw������������I�libsvSrnlongEDSDB `� @� @� @� "��%'��	*,	a�/	1d	�	4	6	s	�9	;K	�	>	@	M	�	%D	#@(Tname#@0,>FZcnw��������������&')*,5689;DEGHJSTVWYbcefhqrtuw������������I�libsvSrnlong<?php
/**
 * bam-fia.php
 *---------------------------
 * Handles all compatibility tasks for FIA
 *
 */


BAM_FIA::init();


/**
 * Better Ads Manager Facebook Instant Article compatibility
 *
 * @since 1.18.5
 */
class BAM_FIA {


	/**
	 *
	 * @since 1.18.5
	 */
	public static function init() {

		// Custom rules
		add_filter( 'instant_articles_transformer_custom_rules_loaded', array(
			'BAM_FIA',
			'customize_role_transformer'
		) );
	}


	/**
	 * Injects BAM custom rules into FIA plugin
	 *
	 * @param $transformer Transformer
	 *
	 * @return \Transformer
	 */
	public static function customize_role_transformer( $transformer ) {

		// Reads from child theme to override it
		$path = Better_Ads_Manager::dir_path( '/includes/fia/rules-configuration.json' );

		$json = bf_get_local_file_content( $path );

		$json = Better_Ads_Manager()->make_prefix_undetectable( $json );

		$transformer->loadRules( $json );

		return $transformer;
	}
} // BAM_FIA
{
  "rules": [
    {
      "class": "PassThroughRule",
      "selector": "div.bsac"
    },
    {
      "class": "PassThroughRule",
      "selector": "div.bsac-container"
    },
    {
      "class": "PassThroughRule",
      "selector": "div.fia-pass"
    }
  ]
}<?php
/**
*
*	King Composer
*	(c) KingComposer.com
*
*/
if(!defined('KC_FILE')) {
	header('HTTP/1.0 403 Forbidden');
	exit;
}

global $kc;

?>
<div id="kc-right-click-helper"><i class="sl-close"></i></div>
<div style="display:none;" id="kc-storage-prepare">
	<div id="kc-css-box-test"></div>
</div>
<img width="50" src="<?php echo KC_URL; ?>/assets/images/drag.png" id="kc-ui-handle-image" />
<img width="50" src="<?php echo KC_URL; ?>/assets/images/drag-copy.png" id="kc-ui-handle-image-copy" />
<div id="kc-undo-deleted-element">
	<a href="javascript:void(0)" class="do-action">
		<i class="sl-action-undo"></i> <?php _e('Restore deleted items', 'kingcomposer'); ?>
		<span class="amount">0</span>
	</a>	
	<div id="drop-to-delete"><span></span></div>
	<i class="sl-close"></i>	
</div>
<script type="text/html" id="tmpl-kc-top-nav-template">
<?php do_action('kc-top-nav'); ?>
</script>
<script type="text/html" id="tmpl-kc-wp-widgets-template">
<div id="kc-wp-list-widgets"><?php

	if( !function_exists( 'submit_button' ) ){
		function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
			echo kc_get_submit_button( $text, $type, $name, $wrap, $other_attributes );
		}
	}

	ob_start();

	global $wp_registered_widget_controls;

	$controls = $wp_registered_widget_controls;

	$wp_registered_widget_controls = array();
	wp_list_widgets();

	$wp_registered_widget_controls = $controls;

		$content = str_replace( array( '<script', '</script>' ), array( '&lt;script', '&lt;/script&gt;' ), ob_get_contents() );
	ob_end_clean();

	echo $content;

?></div>
</script>
<?php do_action('kc_tmpl_nocache'); ?>


<?php

if ( ! class_exists( 'BF_KC_Compatibility' ) ) {

	/**
	 * @since 4.0.0
	 */
	class BF_KC_Compatibility {

		/**
		 * @var self
		 */
		protected static $instance;


		/**
		 * @var array
		 */
		public static $deferred_fields_maps = array();


		/**
		 * @var array
		 */
		public static $dynamic_fields_maps = array();


		/**
		 * Get singleton instance of class
		 */
		public static function instance() {

			if ( ! self::$instance instanceof self ) {
				self::$instance = new self();
				self::$instance->init();
			}

			return self::$instance;
		}


		/**
		 * Initialize the library
		 *
		 * @since 4.0.0
		 */
		public function init() {

			global $kc_pro;

			//		 TODO: load widget lists via ajax
			// add_action( 'admin_footer', array( $this, 'optimized_kc_admin_footer' ) );
			// remove_action( 'admin_footer', 'kc_admin_footer' );

			if ( bf_is_doing_ajax() ) {

				add_action( 'wp_ajax_bf_kc_tmpl_storage', array( $this, 'kc_tmpl_storage' ) );
			}

			if ( $kc_pro && isset( $kc_pro->action ) && 'live-editor' === $kc_pro->action ) {

				add_action( 'kc_after_admin_footer', array( $this, 'append_security_token' ), 0 );
			}

			add_action( 'wp_ajax_bf_load_kc_fields', array( $this, 'ajax_load_fields' ) );
			add_action( 'edit_form_after_editor', array( $this, 'append_security_token' ) );

			add_filter( 'kc_maps', array( $this, 'filter_kc_maps_var' ) );
		}


		/**
		 * @see kc_ajax::tmpl_storage
		 */
		public function kc_tmpl_storage() {

			check_ajax_referer( 'kc-nonce', 'security' );

			global $kc;

			/**
			 * $kc->param_types_cache don't have getter method >.< i have to take it force
			 */
			$reflectionClass   = new ReflectionClass( $kc );
			$param_types_cache = $reflectionClass->getProperty( 'param_types_cache' );
			$param_types_cache->setAccessible( true );
			$param_types = $param_types_cache->getValue( $kc );

			if ( ! empty( $param_types ) ) {

				foreach ( $param_types as $name => $func ) {
					if ( function_exists( $func ) ) {

						echo '<script type="text/html" id="tmpl-kc-field-type-' . esc_attr( $name ) . '-template">';
						ob_start();
						$func();
						$field = ob_get_clean();

						$this->wrap_show_on_atts( $field );

						echo "</script>\n";

					}
				}
			}

			require_once KC_PATH . '/includes/kc.templates.php';
			do_action( 'kc_tmpl_storage' );

			echo '<!----END_KC_TMPL---->';

			exit;
		}


		public function wrap_show_on_atts( $input ) {

			include BF_PATH . 'page-builder/generators/kc/templates/default-js.php';
		}


		/**
		 * Optimized version of the kc_admin_footer() callback
		 *
		 * @hooked admin_footer
		 */
		public function optimized_kc_admin_footer() {

			if ( ! function_exists( 'kc_admin_enable' ) ) {
				return;
			}

			if ( is_admin() && ! kc_admin_enable() ) {
				return;
			}

			do_action( 'kc_before_admin_footer' );

			require_once KC_PATH . '/includes/kc.js_languages.php';
			require_once BF_PATH . 'page-builder/compatibility/kc/kc.nocache_templates.php';

			do_action( 'kc_after_admin_footer' );
		}


		/**
		 * @hooked wp_ajax_bf_load_kc_fields
		 */
		public function ajax_load_fields() {

			if ( empty( $_REQUEST['shortcode'] ) || empty( $_REQUEST['token'] ) ) {
				return;
			}

			check_ajax_referer( 'ajax-load-kc-fields', 'token' );

			$shortcode = $_REQUEST['shortcode'];

			if ( ! $shortcode_instance = BF_Shortcodes_Manager::factory( $shortcode, array(), true ) ) {

				wp_send_json_error( new WP_Error( 'invalid_shortcode' ) );
			}

			$deferred_fields = $this->filter_deferred_fields( $shortcode_instance->page_builder_fields( 'KC' ) );
			$shortcode_atts  = isset( $_REQUEST['shortcode_atts'] ) && is_array( $_REQUEST['shortcode_atts'] )
				? $_REQUEST['shortcode_atts'] : array();

			foreach ( $deferred_fields as $field ) {

				if ( 'js' === $field['_render_engine'] ) {

					$global_fields[] = array(
						//				'html' => $this->get_field( $field_type ),
						'html' => $this->get_field( $field, array(
							'input_name' => '{{data.name}}',
							'value'      => '{{data.value}}',
						) ),
						'id'   => $field['name']
					);

				} elseif ( 'php' === $field['_render_engine'] ) {

					$name = $field['name'];

					//
					$dedicated_fields[] = array(
						'html' => $this->get_field( $field, array(
							'input_name' => $name,
							'value'      => isset( $shortcode_atts[ $name ] ) ? $shortcode_atts[ $name ] : '',
						) ),
						'id'   => $field['type'],
						'name' => $name,
					);
				}
			}

			wp_send_json_success( compact( 'dedicated_fields', 'global_fields' ) );
		}


		/**
		 * @hooked edit_form_after_editor
		 */
		public function append_security_token() {

			wp_nonce_field( 'ajax-load-kc-fields', 'bf_kc_ajax_field', false );
		}


		/**
		 * Mark map as deferred to load field HTML markup via ajax.
		 *
		 * @param string $map_id
		 * @param array  $fields_type
		 */
		public static function mark_fields_as_deferred( $map_id, $fields_type ) {

			self::$deferred_fields_maps[ $map_id ][] = array_unique( $fields_type );
		}


		/**
		 * @param string $map_id
		 */
		public static function always_fetch_map_fields( $map_id ) {

			if ( ! in_array( $map_id, self::$dynamic_fields_maps ) ) {
				self::$dynamic_fields_maps[] = $map_id;
			}
		}


		/**
		 * @param array $kc_maps
		 *
		 * @hooked kc_maps
		 *
		 * @return array
		 */
		public function filter_kc_maps_var( $kc_maps ) {

			foreach ( self::$dynamic_fields_maps as $map_id ) {

				$kc_maps[ $map_id ]['always_fetch_fields'] = true;
			}

			foreach ( self::$deferred_fields_maps as $map_id => $fields_type ) {

				if ( isset( $kc_maps[ $map_id ] ) && empty( $kc_maps[ $map_id ]['always_fetch_fields'] ) ) {
					$kc_maps[ $map_id ]['deferred_fields'] = $fields_type;
				}
			}

			return $kc_maps;
		}


		/**
		 * List deferred fields type.
		 *
		 * @param array $fields
		 *
		 * @return array
		 */
		public function filter_deferred_fields( $fields ) {

			/**
			 * @var BF_KC_Wrapper $kc_wrapper
			 */
			$kc_wrapper = Better_Framework::factory( 'page-builder' )->wrapper_class( 'KC' );
			$kc_wrapper = new $kc_wrapper();

			$deferred_fields         = array();
			$dynamic_deferred_fields = $kc_wrapper->dynamic_deferred_fields();
			$static_deferred_fields  = $kc_wrapper->static_deferred_fields();

			foreach ( $fields as $tab_fields ) {

				foreach ( $tab_fields as $field ) {

					if ( in_array( $field['type'], $dynamic_deferred_fields ) ) {

						$deferred_fields[ $field['name'] ]                   = $field;
						$deferred_fields[ $field['name'] ]['_render_engine'] = 'php';

					} elseif ( in_array( $field['type'], $static_deferred_fields ) ) {

						$deferred_fields[ $field['name'] ]                   = $field;
						$deferred_fields[ $field['name'] ]['_render_engine'] = 'js';
					}
				}
			}

			return $deferred_fields;
		}


		/**
		 * @param string $field
		 * @param array  $options
		 *
		 * @return string
		 */
		public function get_field( $field, $options = array() ) {

			$field = array_merge( $field, $options );

			if ( ! class_exists( 'BF_KC_Fields_Generator' ) ) {

				require BF_PATH . 'page-builder/generators/kc/class-bf-kc-fields-generator.php';
			}

			if ( isset( $field['name'] ) && ! isset( $field['id'] ) ) {
				$field['id'] = $field['name'];
			}

			$generator = new BF_KC_Fields_Generator( $field, $field['input_name'] );

			return $generator->get_field();
		}


		/**
		 * @param array $field
		 *
		 * @return string
		 */
		public function get_field_placeholder( $field ) {

			return sprintf( '<div class="bf-deferred-kc-field" data-field-name="%s"></div>', esc_attr( $field['name'] ) );
		}
	}


	BF_KC_Compatibility::instance();
}
<?php

// let's show them we are better
<?php

// let's show them we are better
<?php

// let's show them we are better
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

global $_vc_column_inner_template_file, $_bf_vc_column_inner_atts;


$_bf_vc_column_inner_atts = $atts;
if ( $_vc_column_inner_template_file ) {
	include $_vc_column_inner_template_file;
}

<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

global $_vc_column_template_file, $_bf_vc_column_inner_atts, $_bf_vc_column_atts;


//todo: include $variable can cause security concerns
$_bf_vc_column_atts       = $atts;
$_bf_vc_column_inner_atts = array();
if ( $_vc_column_template_file ) {
	include $_vc_column_template_file;
}

// Clear atts again to make sure it works in pages with 2 different vc contents
$_bf_vc_column_atts = $_bf_vc_column_inner_atts = array();
<?php

if ( ! function_exists( 'bf_kc_field_generator' ) ) {

	function bf_kc_field_generator( $type, $settings = array() ) {

		if ( ! class_exists( 'BF_KC_Fields_Generator' ) ) {
			require BF_PATH . 'page-builder/generators/kc/class-bf-kc-fields-generator.php';
		}

		$options = wp_parse_args( array(
			'input_name'     => '{{data.name}}',
			'value'          => '{{data.value}}',
			'type'           => $type,
			'bypass_wrapper' => true,
		), $settings );


		$generator = new BF_KC_Fields_Generator( $options, $options['input_name'] );
		$input     = $generator->get_field();

		include BF_PATH . 'page-builder/generators/kc/templates/default-js.php';
	}
}

if ( ! function_exists( 'bf_kc_field_switch' ) ) {

	function bf_kc_field_switch() {

		bf_kc_field_generator( 'switch' );
	}
}
//
//if ( ! function_exists( 'bf_kc_field_color' ) ) {
//
//	function bf_kc_field_color() {
//
//		bf_kc_field_generator( 'color' );
//	}
//}
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

?>
<div class="bf-section-container bf-clearfix">
	<div class="bf-section-heading bf-clearfix" data-id="{{data.name}}"
	     id="{{data.name}}">
		<div class="bf-section-heading-title bf-clearfix">
			<h3>{{data.label}}</h3>
		</div>
	</div>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

include BF_PATH . 'core/field-generator/fields/ajax_select.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */
?>
<div class="bf-switch bf-clearfix">

	<#
			var onLabel = data.options['on-label'] || '<?php _e( 'On', 'better-studio' ) ?>',
			offLabel = data.options['off-label'] || '<?php _e( 'Off', 'better-studio' ) ?>',
			inputClasses = data.options['input-class'];
			#>

		<label class="cb-enable <# if(data.value && data.value !== '0') { #> selected<# } #>"><span>{{{onLabel}}}</span></label>
		<label class="cb-disable <# if(!data.value || data.value === '0') { #> selected<# } #>"><span>{{{offLabel}}}</span></label>

		<input type="hidden" name="{{data.name}}" value="<# if(data.value && data.value !== '0') {#>1<#}else {#>0<#}#>"
		       class="kc-param checkbox {{inputClasses}}">
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

if ( isset( $options['_options'] ) ) {
	$options['options'] = $options['_options'];
}
include BF_PATH . 'core/field-generator/fields/select.php';<?php
include BF_PATH . 'core/field-generator/fields/editor.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

include BF_PATH . 'core/field-generator/fields/term_select.php';
<?php


/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


// Default selected
$current = array(
	'key'    => '',
	'title'  => __( 'Chose an Icon', 'better-studio' ),
	'width'  => '',
	'height' => '',
	'type'   => '',
);


if ( isset( $options['value'] ) ) {

	if ( is_array( $options['value'] ) ) {

		if ( in_array( $options['value']['type'], array( 'custom-icon', 'custom' ) ) ) {
			$current['key']    = isset( $options['value']['icon'] ) ? $options['value']['icon'] : '';
			$current['title']  = bf_get_icon_tag( isset( $options['value'] ) ? $options['value'] : '' ) . ' ' . __( 'Custom icon', 'better-studio' );
			$current['width']  = isset( $options['value']['width'] ) ? $options['value']['width'] : '';
			$current['height'] = isset( $options['value']['height'] ) ? $options['value']['height'] : '';
			$current['type']   = 'custom-icon';
		} else {
			Better_Framework::factory( 'icon-factory' );

			$fontawesome = BF_Icons_Factory::getInstance( 'fontawesome' );

			if ( isset( $fontawesome->icons[ $options['value']['icon'] ] ) ) {
				$current['key']    = $options['value']['icon'];
				$current['title']  = bf_get_icon_tag( $options['value'] ) . $fontawesome->icons[ $options['value']['icon'] ]['label'];
				$current['width']  = $options['value']['width'];
				$current['height'] = $options['value']['height'];
				$current['type']   = 'fontawesome';
			}
		}

	} elseif ( ! empty( $options['value'] ) ) {

		Better_Framework::factory( 'icon-factory' );

		$fontawesome = BF_Icons_Factory::getInstance( 'fontawesome' );

		$icon_label = '';
		if ( substr( $options['value'], 0, 3 ) == 'fa-' ) {
			$icon_label      = bf_get_icon_tag( $options['value'] ) . ' ' . $fontawesome->icons[ $options['value'] ]['label'];
			$current['type'] = 'fontawesome';
		} else {
			$icon_label      = bf_get_icon_tag( $options['value'] );
			$current['type'] = 'custom-icon';
		}

		$current['key']    = $options['value'];
		$current['title']  = $icon_label;
		$current['width']  = '';
		$current['height'] = '';

	}

}

$icon_handler = 'bf-icon-modal-handler-' . mt_rand();


?>
	<div class="bf-icon-modal-handler" id="<?php echo esc_attr( $icon_handler ); ?>">

		<div class="select-options">
			<span class="selected-option"><?php echo wp_kses( $current['title'], bf_trans_allowed_html() ); ?></span>
		</div>

		<input type="hidden" class="kc-param wpb-textinput title textfield icon-input"
		       data-label=""
		       name="<?php echo esc_attr( $options['input_name'] ); ?>"
		       value="<?php echo esc_attr( $current['key'] ); ?>"/>

	</div><!-- modal handler container -->
<?php

bf_enqueue_modal( 'icon' );
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/slider.php';<div class="info-value">
	<?php echo $options['std']; // escaped before ?>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

$classes   = array();
$classes[] = 'bf-section-container';

if ( ! empty( $options['container_class'] ) ) {
	$classes[] = $options['container_class'];
}

printf( '<div class="%s">', implode( ' ', $classes ) );

include BF_PATH . 'core/field-generator/fields/custom.php';

echo '</div>';
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/select_popup.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


// stripcslashes for when json is splashed!
if ( ! empty( $options['value'] ) ) {
	$value = $options['value'];
} else {
	$value = array(
		'img'  => '',
		'type' => 'cover'
	);
}

$media_title = empty( $options['media_title'] ) ? __( 'Upload', 'better-studio' ) : $options['media_title'];
$button_text = empty( $options['button_text'] ) ? __( 'Upload', 'better-studio' ) : $options['button_text'];

// Upload Button
$upload_button = Better_Framework::html()
                                 ->add( 'a' )
                                 ->class( 'bf-button bf-background-image-upload-btn button' )
                                 ->data( 'mediatitle', $media_title )
                                 ->data( 'buttontext', $button_text );

if ( isset( $options['upload_label'] ) ) {
	$upload_button->text( $options['upload_label'] );
} else {
	$upload_button->text( __( 'Upload', 'better-studio' ) );
}

// Remove Button
$remove_button = Better_Framework::html()
                                 ->add( 'a' )
                                 ->class( 'bf-button bf-background-image-remove-btn button' );

if ( isset( $options['remove_label'] ) ) {
	$remove_button->text( $options['remove_label'] );
} else {
	$remove_button->text( __( 'Remove', 'better-studio' ) );
}

if ( $value['img'] == "" ) {
	$remove_button->css( 'display', 'none' );
}

// Select
$select = Better_Framework::html()
                          ->add( 'select' )
                          ->attr( 'id', $options['id'] . '-select' )
                          ->class( 'bf-background-image-uploader-select' )
                          ->name( $options['input_name'] . '[type]' );


$select->text( '<option value="repeat" ' . ( $value['type'] == 'repeat' ? 'selected="selected"' : '' ) . '>' . __( 'Repeat Horizontal and Vertical - Pattern', 'better-studio' ) . '</option>' );
$select->text( '<option value="cover" ' . ( $value['type'] == 'cover' ? 'selected="selected"' : '' ) . '>' . __( 'Fully Cover Background - Photo', 'better-studio' ) . '</option>' );
$select->text( '<option value="repeat-y" ' . ( $value['type'] == 'repeat-y' ? 'selected="selected"' : '' ) . '>' . __( 'Repeat Horizontal', 'better-studio' ) . '</option>' );
$select->text( '<option value="repeat-x" ' . ( $value['type'] == 'repeat-x' ? 'selected="selected"' : '' ) . '>' . __( 'Repeat Vertical', 'better-studio' ) . '</option>' );
$select->text( '<option value="no-repeat" ' . ( $value['type'] == 'no-repeat' ? 'selected="selected"' : '' ) . '>' . __( 'No Repeat', 'better-studio' ) . '</option>' );

if ( $value['img'] == "" ) {
	$select->css( 'display', 'none' );
}

// Main Input
$input = Better_Framework::html()
                         ->add( 'input' )
                         ->type( 'hidden' )
                         ->class( 'bf-background-image-input' )
                         ->name( $options['input_name'] . '[img]' )
                         ->val( $value['img'] );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

echo $upload_button->display(); // escaped before
echo $remove_button->display(); // escaped before
echo '<br>';

echo $select->display(); // escaped before
echo $input->display(); // escaped before

if ( $value['img'] != "" ) {
	echo '<div class="bf-background-image-preview">';
} else {
	echo '<div class="bf-background-image-preview" style="display: none">';
}

echo '<img src="' . esc_url( $value['img'] ) . '" />';
echo '</div>';
<?php

// let's show them we are better
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */
?>


<div class="bs-color-picker-wrapper">

	<input type="text" name="{{data.name}}" value="{{data.value}}" class="bs-color-picker-value color-picker kc-param"
	       data-alpha="true">
</div>

<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


$wrapper = Better_Framework::html()->add( 'div' )->class( 'bf-clearfix' );
$input   = Better_Framework::html()->add( 'input' )->type( 'text' )->name( $options['input_name'] );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

if ( ! empty( $options['value'] ) ) {
	$input->value( $options['value'] )->css( 'border-color', $options['value'] );
}

$wrapper->add( $input );

echo $wrapper->display(); // escaped before
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/media_image.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/image_radio.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

// set options from deferred callback
if ( isset( $options['deferred-options'] ) ) {
	if ( is_string( $options['deferred-options'] ) && is_callable( $options['deferred-options'] ) ) {
		$options['options'] = call_user_func( $options['deferred-options'] );
	} elseif ( is_array( $options['deferred-options'] ) && ! empty( $options['deferred-options']['callback'] ) && is_callable( $options['deferred-options']['callback'] ) ) {
		if ( isset( $options['deferred-options']['args'] ) ) {
			$options['options'] = call_user_func_array( $options['deferred-options']['callback'], $options['deferred-options']['args'] );
		} else {
			$options['options'] = call_user_func( $options['deferred-options']['callback'] );
		}
	}
}

if ( empty( $options['options'] ) ) {
	return;
}

if ( isset( $options['value'] ) && ! empty( $options['value'] ) ) {
	if ( is_string( $options['value'] ) ) {
		$value            = array_flip( explode( ',', $options['value'] ) );
		$options['value'] = array_fill_keys( array_keys( $value ), true );
	}
} else {
	$options['value'] = array();
}


$value     = $options['value'];
$check_all = ( ! isset( $options['check_all'] ) || $options['check_all'] ) && ! bf_count( $value ) ? true : false;

$groups_ids = array();

$selected_items = array();

// Options That Saved Before
foreach ( $value as $item_id => $item ) {

	if ( ! $item ) {
		continue;
	}

	$selected_items[ $item_id ] = $item;
}

$input = Better_Framework::html()->add( 'input' )->type( 'hidden' )->name( $options['input_name'] )->attr( 'value', implode( ',', array_keys( $selected_items ) ) );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

echo $input->display(); // escaped before

?>
<div class="bf-sorter-groups-container">
	<ul id="bf-sorter-group-<?php echo esc_attr( $options['id'] ); ?>"
	    class="bf-sorter-list bf-vc-sorter-list bf-vc-sorter-checkbox-list bf-sorter-<?php echo esc_attr( $options['id'] ); ?>">
		<?php
		// Options That Saved Before
		foreach ( $selected_items as $item_id => $item ) {
			?>
			<li id="bf-sorter-group-item-<?php echo esc_attr( $options['id'] ); ?>-<?php echo esc_attr( $item_id ); ?>"
			    class="<?php echo isset( $options['options'][ $item_id ]['css-class'] ) ? esc_attr( $options['options'][ $item_id ]['css-class'] ) : ''; ?> item-<?php echo esc_attr( $item_id ); ?> checked-item"
			    style="<?php echo isset( $options['options'][ $item_id ]['css'] ) ? esc_attr( $options['options'][ $item_id ]['css'] ) : ''; ?>">
				<label>
					<input name="<?php echo esc_attr( $item_id ); ?>" value="<?php echo esc_attr( $item_id ); ?>"
					       type="checkbox" checked="checked"/>
					<?php echo $options['options'][ $item_id ]['label']; ?>
				</label>
			</li>
			<?php

			unset( $options['options'][ $item_id ] );

		}

		// Options That Not Saved but are Active
		foreach ( $options['options'] as $item_id => $item ) {

			// Skip Disabled Items
			if ( isset( $item['css-class'] ) && strpos( $item['css-class'], 'active-item' ) === false ) {
				continue;
			}
			?>
			<li id="bf-sorter-group-item-<?php echo esc_attr( $options['id'] ); ?>-<?php echo esc_attr( $item_id ); ?>"
			    class="<?php echo isset( $item['css-class'] ) ? esc_attr( $item['css-class'] ) : ''; ?> item-<?php echo esc_attr( $item_id ); ?> <?php echo $check_all ? ' checked-item' : ''; ?>" <?php echo $check_all ? ' checked="checked" ' : ''; ?>
			    style="<?php echo isset( $item['css'] ) ? esc_attr( $item['css'] ) : ''; ?>">
				<label>
					<input name="<?php echo esc_attr( $item_id ); ?>" value="<?php echo esc_attr( $item_id ); ?>"
					       type="checkbox" <?php echo $check_all ? ' checked="checked" ' : ''; ?>/>
					<?php echo is_array( $item ) ? $item['label'] : $item; // escaped before ?>
				</label>
			</li>
			<?php

			unset( $options['options'][ $item_id ] );
		}

		// Disable Items
		foreach ( $options['options'] as $item_id => $item ) { ?>
			<li id="bf-sorter-group-item-<?php echo esc_attr( $options['id'] ); ?>-<?php echo esc_attr( $item_id ); ?>"
			    class="<?php echo isset( $item['css-class'] ) ? esc_attr( $item['css-class'] ) : ''; ?> item-<?php echo esc_attr( $item_id ); ?>"
			    style="<?php echo isset( $item['css'] ) ? esc_attr( $item['css'] ) : ''; ?>">
				<label>
					<input name="<?php echo esc_attr( $item_id ); ?>" value="<?php echo esc_attr( $item_id ); ?>"
					       type="checkbox" disabled/>
					<?php echo is_array( $item ) ? $item['label'] : $item; // escaped before ?>
				</label>
			</li>
			<?php
		}

		?>
	</ul>
	<?php

	echo $this->get_filed_input_desc( $options ); // escaped before

	?>
</div>
<?php


/**
 * Class BF_KC_Front_End_Generator
 *
 * @since 4.0.0
 */
class BF_KC_Fields_Generator extends BF_Admin_Fields {

	/**
	 * Holds Items Array
	 *
	 * @since  1.0
	 * @access public
	 * @var array|null
	 */
	public $item;

	/**
	 * Panel ID
	 *
	 * @since  1.0
	 * @access public
	 * @var string
	 */
	public $id;


	/**
	 * Constructor
	 *
	 * @param array $item Contain details of one field
	 * @param       $id
	 */
	public function __construct( $item = array(), $id = array() ) {

		$generator_options = array(
			'fields_dir'    => BF_PATH . 'page-builder/generators/kc/fields/',
			'templates_dir' => BF_PATH . 'page-builder/generators/kc/templates/'
		);

		parent::__construct( $generator_options );

		$item['input_class'] = 'kc-param';

		$this->item = $item;
		$this->id   = $id;
	}


	/**
	 * Display HTML output of panel array
	 *
	 * Display full html of panel array which is defined in object parameter
	 *
	 * @since  1.0
	 * @access public
	 * @return string
	 */
	public function get_field() {

		$output = '';
		$field  = $this->item;

		if ( ! isset( $field['value'] ) && isset( $field['std'] ) ) {
			$field['value'] = $field['std'];
		}

		$output .= $this->section(
			call_user_func(
				array( $this, $field['type'] ),
				$field
			),
			$field
		);

		return $output;
	}
}
<?php

// let's show them we are better
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

if ( ! isset( $options['id'] ) && isset( $options['name'] ) ) {
	$options['id'] = $options['name'];
}

if ( ! empty( $options['bypass_wrapper'] ) ) {

	echo $input;

	return;
}
?>
<div class="bf-section-container <?php echo isset( $options['section_class'] ) ? esc_attr( $options['section_class'] ) : ''; ?>" <?php echo bf_show_on_attributes( $options ) ?>>
	<?php echo $input; // escaped before ?>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

$style = ! empty( $options['layout'] ) ? $options['layout'] : 'style-1';

if ( ! isset( $options['id'] ) ) {
	$options['id'] = '';
}

if ( ! isset( $options['title'] ) ) {
	$options['title'] = $options['label'];
}

?>
<div class="bf-section-container bf-clearfix">
	<div class="bf-section-heading bf-clearfix <?php echo $style; ?>"
	     data-id="<?php echo esc_attr( $options['id'] ); ?>"
	     id="<?php echo esc_attr( $options['id'] ); ?>">
		<div class="bf-section-heading-title bf-clearfix">
			<h4><?php echo esc_html( $options['title'] ); ?></h4>
		</div>
		<?php if ( ! empty( $options['desc'] ) ) { ?>
			<div class="bf-section-heading-desc bf-clearfix"><?php echo wp_kses( $options['desc'], bf_trans_allowed_html() ); ?></div>
		<?php } ?>
	</div>
</div><#
		var sectionClass = data.options['section_class'] || '',
		settings = data.options['show_on'] ? JSON.stringify(data.options['show_on']) : '';
		#>
	<div
			class="bf-section-container {{sectionClass}}" data-param-name="{{data.name}}"
			data-param-settings="{{settings}}">
		<?php echo $input; // escaped before ?>
	</div><?php

// let's show them we are better
<?php

// let's show them we are better
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

?>
<div class="bf-section-container bf-clearfix">
	<div class="bf-section-heading bf-clearfix" data-id="<?php echo esc_attr( $options['id'] ); ?>"
	     id="<?php echo esc_attr( $options['id'] ); ?>">
		<div class="bf-section-heading-title bf-clearfix">
			<h3><?php echo esc_html( $options['name'] ); ?></h3>
		</div>
	</div>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

include BF_PATH . 'core/field-generator/fields/ajax_select.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

$checkbox = Better_Framework()->html()->add( 'input' )->type( 'input' )->name( $options['input_name'] )->val( '' )->class( 'checkbox' );


// On Label
$on_label = __( 'On', 'better-studio' );
if ( isset( $options['on-label'] ) ) {
	$on_label = $options['on-label'];
}

// On Label
$off_label = __( 'Off', 'better-studio' );
if ( isset( $options['off-label'] ) ) {
	$off_label = $options['off-label'];
}

if ( $options['value'] ) {
	$on_checked  = 'selected';
	$off_checked = '';
	$checkbox->val( 1 );

} else {
	$on_checked  = '';
	$off_checked = 'selected';
	$checkbox->val( 0 );
}

if ( isset( $options['input_class'] ) ) {
	$checkbox->class( $options['input_class'] );
}

?>
<div class="bf-switch bf-clearfix">

	<label
			class="cb-enable <?php echo esc_attr( $on_checked ); ?>"><span><?php echo esc_html( $on_label ); ?></span></label>
	<label class="cb-disable <?php echo esc_attr( $off_checked ); ?>"><span><?php echo esc_html( $off_label ); ?></span></label>
	<?php

	echo $checkbox->display(); // escaped before

	?>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/select.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

include BF_PATH . 'core/field-generator/fields/term_select.php';
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


$value = ! empty( $options['value'] ) ? $options['value'] : '';


$wrapper = Better_Framework::html()->add( 'div' )->class( 'bf-clearfix' );
$input   = Better_Framework::html()->add( 'input' )->type( 'hidden' )->name( $options['input_name'] );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

if ( ! empty( $options['value'] ) ) {
	$input->value( $options['value'] )->css( 'border-color', $options['value'] );
}

$wrapper->add( $input );

echo $wrapper->display(); // escaped before

foreach ( $options['options'] as $key => $item ) {

	$is_checked = ! empty( $value ) && ( $key == $value );

	$image = Better_Framework::html()->add( 'img' )->src( $item['img'] )->alt( $item['label'] )->title( $item['label'] );
	$label = Better_Framework::html()->add( 'label' );


	$label->text( $image );
	if ( isset( $item['label'] ) ) {
		$p = Better_Framework::html()->add( 'p' )->text( $item['label'] )->class( 'item-label' );
		$label->text( $p );
	}

	$object = Better_Framework::html()->add( 'div' )->class( 'vc-bf-image-radio-option' )->data( 'id', $key );

	if ( $is_checked ) {
		$object->class( 'checked' );
	}

	$object->text( $label->display() );

	echo $object->display(); // escaped before
}<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


// Default selected
$current = array(
	'key'    => '',
	'title'  => __( 'Chose an Icon', 'better-studio' ),
	'width'  => '',
	'height' => '',
	'type'   => '',
);


if ( isset( $options['value'] ) ) {

	if ( is_array( $options['value'] ) ) {

		if ( in_array( $options['value']['type'], array( 'custom-icon', 'custom' ) ) ) {
			$current['key']    = isset( $options['value']['icon'] ) ? $options['value']['icon'] : '';
			$current['title']  = bf_get_icon_tag( isset( $options['value'] ) ? $options['value'] : '' ) . ' ' . __( 'Custom icon', 'better-studio' );
			$current['width']  = isset( $options['value']['width'] ) ? $options['value']['width'] : '';
			$current['height'] = isset( $options['value']['height'] ) ? $options['value']['height'] : '';
			$current['type']   = 'custom-icon';
		} else {
			Better_Framework::factory( 'icon-factory' );

			$fontawesome = BF_Icons_Factory::getInstance( 'fontawesome' );

			if ( isset( $fontawesome->icons[ $options['value']['icon'] ] ) ) {
				$current['key']    = $options['value']['icon'];
				$current['title']  = bf_get_icon_tag( $options['value'] ) . $fontawesome->icons[ $options['value']['icon'] ]['label'];
				$current['width']  = $options['value']['width'];
				$current['height'] = $options['value']['height'];
				$current['type']   = 'fontawesome';
			}
		}

	} elseif ( ! empty( $options['value'] ) ) {

		Better_Framework::factory( 'icon-factory' );

		$fontawesome = BF_Icons_Factory::getInstance( 'fontawesome' );

		$icon_label = '';
		if ( substr( $options['value'], 0, 3 ) == 'fa-' ) {
			$icon_label      = bf_get_icon_tag( $options['value'] ) . ' ' . $fontawesome->icons[ $options['value'] ]['label'];
			$current['type'] = 'fontawesome';
		} else {
			$icon_label      = bf_get_icon_tag( $options['value'] );
			$current['type'] = 'custom-icon';
		}

		$current['key']    = $options['value'];
		$current['title']  = $icon_label;
		$current['width']  = '';
		$current['height'] = '';

	}

}

$icon_handler = 'bf-icon-modal-handler-' . mt_rand();


?>
	<div class="bf-icon-modal-handler" id="<?php echo esc_attr( $icon_handler ); ?>">

		<div class="select-options">
			<span class="selected-option"><?php echo wp_kses( $current['title'], bf_trans_allowed_html() ); ?></span>
		</div>

		<input type="hidden" class="wpb_vc_param_value wpb-textinput title textfield icon-input"
		       data-label=""
		       name="<?php echo esc_attr( $options['input_name'] ); ?>"
		       value="<?php echo esc_attr( $current['key'] ); ?>"/>

	</div><!-- modal handler container -->
<?php

bf_enqueue_modal( 'icon' );
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/slider.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

$classes   = array();
$classes[] = 'bf-section-container';

if ( ! empty( $options['container_class'] ) ) {
	$classes[] = $options['container_class'];
}

printf( '<div class="%s">', implode( ' ', $classes ) );

include BF_PATH . 'core/field-generator/fields/custom.php';

echo '</div>';
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/select_popup.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


// stripcslashes for when json is splashed!
if ( ! empty( $options['value'] ) ) {
	$value = $options['value'];
} else {
	$value = array(
		'img'  => '',
		'type' => 'cover'
	);
}

$media_title = empty( $options['media_title'] ) ? __( 'Upload', 'better-studio' ) : $options['media_title'];
$button_text = empty( $options['button_text'] ) ? __( 'Upload', 'better-studio' ) : $options['button_text'];

// Upload Button
$upload_button = Better_Framework::html()
                                 ->add( 'a' )
                                 ->class( 'bf-button bf-background-image-upload-btn button' )
                                 ->data( 'mediatitle', $media_title )
                                 ->data( 'buttontext', $button_text );

if ( isset( $options['upload_label'] ) ) {
	$upload_button->text( $options['upload_label'] );
} else {
	$upload_button->text( __( 'Upload', 'better-studio' ) );
}

// Remove Button
$remove_button = Better_Framework::html()
                                 ->add( 'a' )
                                 ->class( 'bf-button bf-background-image-remove-btn button' );

if ( isset( $options['remove_label'] ) ) {
	$remove_button->text( $options['remove_label'] );
} else {
	$remove_button->text( __( 'Remove', 'better-studio' ) );
}

if ( $value['img'] == "" ) {
	$remove_button->css( 'display', 'none' );
}

// Select
$select = Better_Framework::html()
                          ->add( 'select' )
                          ->attr( 'id', $options['id'] . '-select' )
                          ->class( 'bf-background-image-uploader-select' )
                          ->name( $options['input_name'] . '[type]' );


$select->text( '<option value="repeat" ' . ( $value['type'] == 'repeat' ? 'selected="selected"' : '' ) . '>' . __( 'Repeat Horizontal and Vertical - Pattern', 'better-studio' ) . '</option>' );
$select->text( '<option value="cover" ' . ( $value['type'] == 'cover' ? 'selected="selected"' : '' ) . '>' . __( 'Fully Cover Background - Photo', 'better-studio' ) . '</option>' );
$select->text( '<option value="repeat-y" ' . ( $value['type'] == 'repeat-y' ? 'selected="selected"' : '' ) . '>' . __( 'Repeat Horizontal', 'better-studio' ) . '</option>' );
$select->text( '<option value="repeat-x" ' . ( $value['type'] == 'repeat-x' ? 'selected="selected"' : '' ) . '>' . __( 'Repeat Vertical', 'better-studio' ) . '</option>' );
$select->text( '<option value="no-repeat" ' . ( $value['type'] == 'no-repeat' ? 'selected="selected"' : '' ) . '>' . __( 'No Repeat', 'better-studio' ) . '</option>' );

if ( $value['img'] == "" ) {
	$select->css( 'display', 'none' );
}

// Main Input
$input = Better_Framework::html()
                         ->add( 'input' )
                         ->type( 'hidden' )
                         ->class( 'bf-background-image-input' )
                         ->name( $options['input_name'] . '[img]' )
                         ->val( $value['img'] );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

echo $upload_button->display(); // escaped before
echo $remove_button->display(); // escaped before
echo '<br>';

echo $select->display(); // escaped before
echo $input->display(); // escaped before

if ( $value['img'] != "" ) {
	echo '<div class="bf-background-image-preview">';
} else {
	echo '<div class="bf-background-image-preview" style="display: none">';
}

echo '<img src="' . esc_url( $value['img'] ) . '" />';
echo '</div>';
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

// set options from deferred callback
if ( isset( $options['deferred-options'] ) ) {
	if ( is_string( $options['deferred-options'] ) && is_callable( $options['deferred-options'] ) ) {
		$options['options'] = call_user_func( $options['deferred-options'] );
	} elseif ( is_array( $options['deferred-options'] ) && ! empty( $options['deferred-options']['callback'] ) && is_callable( $options['deferred-options']['callback'] ) ) {
		if ( isset( $options['deferred-options']['args'] ) ) {
			$options['options'] = call_user_func_array( $options['deferred-options']['callback'], $options['deferred-options']['args'] );
		} else {
			$options['options'] = call_user_func( $options['deferred-options']['callback'] );
		}
	}
}

if ( empty( $options['options'] ) ) {
	return;
}

if ( isset( $options['value'] ) && ! empty( $options['value'] ) ) {
	if ( is_string( $options['value'] ) ) {
		$value            = array_flip( explode( ',', $options['value'] ) );
		$options['value'] = array_fill_keys( array_keys( $value ), true );
	}
} else {
	$options['value'] = array();
}


$value     = $options['value'];
$check_all = ( ! isset( $options['check_all'] ) || $options['check_all'] ) && ! bf_count( $value ) ? true : false;

$groups_ids = array();

$selected_items = array();

// Options That Saved Before
foreach ( $value as $item_id => $item ) {

	if ( ! $item ) {
		continue;
	}

	$selected_items[ $item_id ] = $item;
}

$input = Better_Framework::html()->add( 'input' )->type( 'hidden' )->name( $options['input_name'] )->attr( 'value', implode( ',', array_keys( $selected_items ) ) );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

echo $input->display(); // escaped before

?>
<div class="bf-sorter-groups-container">
	<ul id="bf-sorter-group-<?php echo esc_attr( $options['id'] ); ?>"
	    class="bf-sorter-list bf-vc-sorter-list bf-vc-sorter-checkbox-list bf-sorter-<?php echo esc_attr( $options['id'] ); ?>">
		<?php
		// Options That Saved Before
		foreach ( $selected_items as $item_id => $item ) {
			?>
			<li id="bf-sorter-group-item-<?php echo esc_attr( $options['id'] ); ?>-<?php echo esc_attr( $item_id ); ?>"
			    class="<?php echo isset( $options['options'][ $item_id ]['css-class'] ) ? esc_attr( $options['options'][ $item_id ]['css-class'] ) : ''; ?> item-<?php echo esc_attr( $item_id ); ?> checked-item"
			    style="<?php echo isset( $options['options'][ $item_id ]['css'] ) ? esc_attr( $options['options'][ $item_id ]['css'] ) : ''; ?>">
				<label>
					<input name="<?php echo esc_attr( $item_id ); ?>" value="<?php echo esc_attr( $item_id ); ?>"
					       type="checkbox" checked="checked"/>
					<?php echo $options['options'][ $item_id ]['label']; ?>
				</label>
			</li>
			<?php

			unset( $options['options'][ $item_id ] );

		}

		// Options That Not Saved but are Active
		foreach ( $options['options'] as $item_id => $item ) {

			// Skip Disabled Items
			if ( isset( $item['css-class'] ) && strpos( $item['css-class'], 'active-item' ) === false ) {
				continue;
			}
			?>
			<li id="bf-sorter-group-item-<?php echo esc_attr( $options['id'] ); ?>-<?php echo esc_attr( $item_id ); ?>"
			    class="<?php echo isset( $item['css-class'] ) ? esc_attr( $item['css-class'] ) : ''; ?> item-<?php echo esc_attr( $item_id ); ?> <?php echo $check_all ? ' checked-item' : ''; ?>" <?php echo $check_all ? ' checked="checked" ' : ''; ?>
			    style="<?php echo isset( $item['css'] ) ? esc_attr( $item['css'] ) : ''; ?>">
				<label>
					<input name="<?php echo esc_attr( $item_id ); ?>" value="<?php echo esc_attr( $item_id ); ?>"
					       type="checkbox" <?php echo $check_all ? ' checked="checked" ' : ''; ?>/>
					<?php echo is_array( $item ) ? $item['label'] : $item; // escaped before ?>
				</label>
			</li>
			<?php

			unset( $options['options'][ $item_id ] );
		}

		// Disable Items
		foreach ( $options['options'] as $item_id => $item ) { ?>
			<li id="bf-sorter-group-item-<?php echo esc_attr( $options['id'] ); ?>-<?php echo esc_attr( $item_id ); ?>"
			    class="<?php echo isset( $item['css-class'] ) ? esc_attr( $item['css-class'] ) : ''; ?> item-<?php echo esc_attr( $item_id ); ?>"
			    style="<?php echo isset( $item['css'] ) ? esc_attr( $item['css'] ) : ''; ?>">
				<label>
					<input name="<?php echo esc_attr( $item_id ); ?>" value="<?php echo esc_attr( $item_id ); ?>"
					       type="checkbox" disabled/>
					<?php echo is_array( $item ) ? $item['label'] : $item; // escaped before ?>
				</label>
			</li>
			<?php
		}

		?>
	</ul>
	<?php

	echo $this->get_filed_input_desc( $options ); // escaped before

	?>
</div>
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/color.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


$wrapper = Better_Framework::html()->add( 'div' )->class( 'bf-clearfix' );
$input   = Better_Framework::html()->add( 'input' )->type( 'text' )->name( $options['input_name'] );

if ( isset( $options['input_class'] ) ) {
	$input->class( $options['input_class'] );
}

if ( ! empty( $options['value'] ) ) {
	$input->value( $options['value'] )->css( 'border-color', $options['value'] );
}

$wrapper->add( $input );

echo $wrapper->display(); // escaped before
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

include BF_PATH . 'core/field-generator/fields/info.php';<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


include BF_PATH . 'core/field-generator/fields/media_image.php';<?php


/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */
class BF_VC_Front_End_Generator extends BF_Admin_Fields {

	/**
	 * Holds Items Array
	 *
	 * @since  1.0
	 * @access public
	 * @var array|null
	 */
	public $item;

	/**
	 * Panel ID
	 *
	 * @since  1.0
	 * @access public
	 * @var string
	 */
	public $id;

	/**
	 * Panel Values
	 *
	 * @since  1.0
	 * @access public
	 * @var array
	 */
	public $values;


	/**
	 * Constructor Function
	 *
	 * @param array $item Contain details of one field
	 * @param       $id
	 *
	 * @since  1.0
	 * @access public
	 * @return \BF_VC_Front_End_Generator
	 */
	public function __construct( array &$item, &$id ) {

		// Parent Constructor
		$generator_options = array(
			'fields_dir'    => BF_PATH . 'page-builder/generators/vc/fields/',
			'templates_dir' => BF_PATH . 'page-builder/generators/vc/templates/'
		);

		$this->supported_fields[] = 'vc-image_radio';
		$this->supported_fields[] = 'vc-media_image';
		$this->supported_fields[] = 'vc-switchery';
		$this->supported_fields[] = 'vc-sorter_checkbox';
		$this->supported_fields[] = 'vc-info';

		parent::__construct( $generator_options );

		$this->item = $item;

		$this->id = $id;
	}


	/**
	 * Display HTML output of panel array
	 *
	 * Display full html of panel array which is defined in object parameter
	 *
	 * @since  1.0
	 * @access public
	 * @return string
	 */
	public function get_field() {

		$output = '';
		$field  = $this->item;

		if ( ! isset( $field['value'] ) && isset( $field['std'] ) ) {
			$field['value'] = $field['std'];
		}

		$output .= $this->section(
			call_user_func(
				array( $this, $field['type'] ),
				$field
			),
			$field
		);

		return $output;
	}
}<?php

// let's show them we are better
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


if ( ! class_exists( "WPBakeryShortCode" ) ) {
	class WPBakeryShortCode {

	}
}


/**
 * Wrapper for WPBakeryShortCode Class for handling editor
 */
class BF_VC_Shortcode_Extender extends WPBakeryShortCode {

}<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

?>
<div
		class="bf-section-container vc-input bf-clearfix <?php echo isset( $options['section_class'] ) ? esc_attr( $options['section_class'] ) : ''; ?>">
	<?php echo $input; // escaped before ?>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */

$style = ! empty( $options['layout'] ) ? $options['layout'] : 'style-1';

?>
<div class="bf-section-container  vc-input bf-clearfix">
	<div class="bf-section-heading bf-clearfix <?php echo $style; ?>"
	     data-id="<?php echo esc_attr( $options['id'] ); ?>"
	     id="<?php echo esc_attr( $options['id'] ); ?>">
		<div class="bf-section-heading-title bf-clearfix">
			<h4><?php echo esc_html( $options['title'] ); ?></h4>
		</div>
		<?php if ( ! empty( $options['desc'] ) ) { ?>
			<div
					class="bf-section-heading-desc bf-clearfix"><?php echo wp_kses( $options['desc'], bf_trans_allowed_html() ); ?></div>
		<?php } ?>
	</div>
</div><?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


$classes = $this->get_classes( $options );
$iri     = isset( $options['repeater_item'] ) && $options['repeater_item'] == true; // Is this section for a repeater item

$section_classes = $classes['section'] . ' bf-widget-field-section';

$heading_classes  = $classes['heading'] . ' bf-heading';
$controls_classes = $classes['controls'] . ' bf-control not-prepared';
$explain_classes  = $classes['explain'] . ' bf-desc';

if ( $iri ) {

	$section_classes  .= ' ' . $classes['repeater-section'];
	$heading_classes  .= ' ' . $classes['repeater-heading'];
	$controls_classes .= ' ' . $classes['repeater-controls'];
	$explain_classes  .= ' ' . $classes['repeater-explain'];

} else {

	$section_classes  .= ' ' . $classes['nonrepeater-section'];
	$heading_classes  .= ' ' . $classes['nonrepeater-heading'];
	$controls_classes .= ' ' . $classes['nonrepeater-controls'];
	$explain_classes  .= ' ' . $classes['nonrepeater-explain'];

}

$section_classes  .= ' ' . $classes['section-class-by-filed-type'];
$heading_classes  .= ' ' . $classes['heading-class-by-filed-type'];
$controls_classes .= ' ' . $classes['controls-class-by-filed-type'];
$explain_classes  .= ' ' . $classes['explain-class-by-filed-type'];


if ( ! isset( $options['info-type'] ) ) {
	$options['info-type'] = 'info';
}

if ( ! isset( $options['state'] ) ) {
	$options['state'] = 'open';
}

?>
<div class="bf-section-container bf-clearfix">
	<div
			class="bf-section-info <?php echo esc_attr( $options['info-type'] ); ?> <?php echo esc_attr( $options['state'] ); ?> bf-clearfix">
		<div class="bf-section-info-title bf-clearfix">
			<h3><?php

				switch ( $options['info-type'] ) {

					case 'help':
						echo '<i class="fa fa-support"></i> ';
						break;

					case 'info':
						echo '<i class="fa fa-info"></i> ';
						break;

					case 'warning':
						echo '<i class="fa fa-warning"></i> ';
						break;

					case 'danger':
						echo '<i class="fa fa-exclamation"></i> ';
						break;

					default:
						echo '<i class="fa fa-info"></i> ';
						break;

				}

				echo esc_html( $options['name'] ); ?></h3>
		</div>
		<div class="<?php echo esc_attr( $controls_classes ); ?>  bf-clearfix">
			<?php echo $input; // escaped before ?>
		</div>
	</div>
</div><?php

// let's show them we are better
<?php


class BF_Widget_Artificial extends BF_Widget {


	/**
	 * @var string
	 */
	protected $shortcode_id;


	/**
	 * @var BF_Shortcode
	 */
	protected $shortcode_instance;


	public function __construct( $shortcode_id ) {

		$this->set_shortcode_id( $shortcode_id );

		if ( ! $this->shortcode_instance ) {
			return;
		}

		$settings = $this->shortcode_instance->page_builder_settings();

		parent::__construct(
			$shortcode_id,
			$settings['name'],
			isset( $settings['description'] ) ? $settings['description'] : ''
		);
	}


	/**
	 * Loads fields
	 */
	public function load_fields() {

		$this->fields = array_values( $this->shortcode_instance->get_fields() );
	}


	/**
	 * @param string $shortcode_id
	 */
	public function set_shortcode_id( $shortcode_id ) {

		$this->shortcode_id       = $shortcode_id;
		$this->shortcode_instance = BF_Shortcodes_Manager::factory(
			$this->shortcode_id, array(), true
		);
	}


	/**
	 * @return string
	 */
	public function get_shortcode_id() {

		return $this->shortcode_id;
	}
}
<?php


/**
 * Class BF_Page_Builders_Wrapper
 *
 * @since 4.0.0
 */
abstract class BF_Page_Builder_Wrapper {

	/**
	 * Register supported fields.
	 *
	 * @since 4.0.0
	 * @return bool true on success.
	 */
	abstract public function register_fields();


	/**
	 * Unique id of the page builder.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	abstract public function unique_id();

	/**
	 * Register shortcode map.
	 *
	 * @param array $settings
	 * @param mixed $fields transformed fields
	 *
	 * @since 4.0.0
	 * @return bool true on success
	 */
	abstract public function register_map( array $settings, $fields );


	/**
	 * List of supported fields type.
	 *
	 * @since 4.0.0
	 * @return array
	 */
	abstract public function supported_fields();


	/**
	 * Call register_map method when this hook has been fired.
	 *
	 * Empty return value will fire the method immediately.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public static function register_map_hook() {

		return '';
	}


	/**
	 * Call register_fields method when this hook has been fired.
	 *
	 * Empty return value will fire the method immediately.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public static function register_fields_hook() {

		return '';
	}
}
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


/**
 * Initialize custom functionality to VC
 */
class BF_VC_Wrapper extends BF_Page_Builder_Wrapper {


	/**
	 * Register shortcode map.
	 *
	 * @param array $settings
	 * @param array $fields transformed fields
	 *
	 * @since 4.0.0
	 * @return bool true on success
	 */
	public function register_map( array $settings, $fields ) {

		if ( empty( $settings['name'] ) ) {
			return false;
		}

		if ( isset( $settings['id'] ) ) {
			$settings['base'] = $settings['id'];
			unset( $settings['id'] );
		}

		$settings['params'] = $fields;

		vc_map( $settings );
	}


	function register_fields() {

		if ( ! class_exists( 'BF_VC_Shortcode_Extender' ) ) {
			require_once BF_PATH . 'page-builder/generators/vc/class-bf-vc-shortcode-extender.php';
		}

		if ( ! class_exists( 'BF_Admin_Fields' ) ) {
			include BF_PATH . 'core/field-generator/class-bf-admin-fields.php';
		}

		if ( ! class_exists( 'BF_VC_Front_End_Generator' ) ) {
			require_once BF_PATH . 'page-builder/generators/vc/class-bf-vc-front-end-generator.php';
		}

		// Make it theme check plugin friendly ;)
		$shortcode_param_add_func = 'vc_add' . '_' . 'shortcode' . '_' . 'param';

		if ( ! function_exists( $shortcode_param_add_func ) ) {
			return;
		}

		call_user_func( $shortcode_param_add_func, 'bf_select', array( $this, 'select_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_color', array( $this, 'color_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_background_image', array( $this, 'background_image_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_media_image', array( $this, 'media_image_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_image_radio', array( $this, 'image_radio' ) );
		call_user_func( $shortcode_param_add_func, 'bf_info', array( $this, 'info' ) );
		call_user_func( $shortcode_param_add_func, 'bf_slider', array( $this, 'slider_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_sorter_checkbox', array( $this, 'sorter_checkbox_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_switch', array( $this, 'switchery' ) );
		call_user_func( $shortcode_param_add_func, 'bf_switchery', array(
			$this,
			'switchery'
		) ); // old. deprecated, fallback
		call_user_func( $shortcode_param_add_func, 'bf_ajax_select', array( $this, 'ajax_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_icon_select', array( $this, 'icon_select_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_heading', array( $this, 'heading_param' ) );
		call_user_func( $shortcode_param_add_func, 'bf_term_select', array( $this, 'term_select' ) );
		call_user_func( $shortcode_param_add_func, 'bf_custom', array( $this, 'custom_html' ) );
		call_user_func( $shortcode_param_add_func, 'bf_select_popup', array( $this, 'select_popup' ) );

		return true;
	}


	/**
	 * List of supported fields type.
	 *
	 * @since 4.0.0
	 * @return array
	 */
	public function supported_fields() {

		return array(
			'info',
			'switch',
			'slider',
			'color',
			'select',
			'custom',
			'heading',
			'switchery',
			'ajax_select',
			'icon_select',
			'term_select',
			'image_radio',
			'media_image',
			'select_popup',
			'sorter_checkbox',
			'background_image',
		);
	}


	/**
	 * Convert VC Field option to an BF Field Option
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return array
	 */
	private function convert_field_option( $settings, $value ) {

		$options = array(
			'name'        => $settings['heading'],
			'id'          => $settings['param_name'],
			'input_name'  => $settings['param_name'],
			'value'       => $value,
			'input_class' => "wpb_vc_param_value wpb-" . $settings['type'] . " " . $settings['param_name'] . ' ' . $settings['type'] . "_field",
		);

		if ( isset( $settings['description'] ) ) {
			$options['desc'] = $settings['description'];
		}

		if ( isset( $settings['input-desc'] ) ) {
			$options['input-desc'] = $settings['input-desc'];
		}

		if ( isset( $settings['deferred-options'] ) ) {
			$options['deferred-options'] = $settings['deferred-options'];
		}

		if ( isset( $settings['options'] ) ) {
			$options['options'] = $settings['options'];
		}

		if ( isset( $settings['section_class'] ) ) {
			$options['section_class'] = $settings['section_class'];
		}


		return $options;
	}


	/**
	 * Adds BF Image Radio Field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function image_radio( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'vc-image_radio';

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Info Field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function info( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'vc-info';

		$options['value'] = $settings['std'];

		if ( isset( $settings['state'] ) ) {
			$options['state'] = $settings['state'];
		}

		if ( isset( $settings['info-type'] ) ) {
			$options['info-type'] = $settings['info-type'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Image Radio Field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function switchery( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'vc-switchery';

		if ( isset( $settings['on-label'] ) ) {
			$options['on-label'] = $settings['on-label'];
		}

		if ( isset( $settings['off-label'] ) ) {
			$options['off-label'] = $settings['off-label'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Color field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function color_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'color';

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Select field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function select_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'select';

		if ( isset( $settings['multiple'] ) ) {
			$options['multiple'] = $settings['multiple'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Select field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function term_select( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'term_select';

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds custom field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function custom_html( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'custom';

		if ( isset( $settings['input_callback'] ) ) {
			$options['input_callback'] = $settings['input_callback'];
		}

		if ( isset( $settings['container_class'] ) ) {
			$options['container_class'] = $settings['container_class'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds select popup field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function select_popup( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );
		if ( $extra = wp_array_slice_assoc( $settings, bf_field_extra_options( 'select_popup' ) ) ) {
			$options = array_merge( $options, $extra );
		}

		$options['type'] = 'select_popup';

		if ( isset( $settings['input_callback'] ) ) {
			$options['input_callback'] = $settings['input_callback'];
		}

		if ( isset( $settings['container_class'] ) ) {
			$options['container_class'] = $settings['container_class'];
		}


		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Ajax field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function ajax_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'ajax_select';

		$options['callback'] = $settings['callback'];

		$options['get_name'] = $settings['get_name'];

		if ( isset( $settings['placeholder'] ) ) {
			$options['placeholder'] = $settings['placeholder'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Adds BF Background Image field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function background_image_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'background_image';

		if ( isset( $settings['media_title'] ) ) {
			$options['media_title'] = $settings['media_title'];
		}

		if ( isset( $settings['button_text'] ) ) {
			$options['button_text'] = $settings['button_text'];
		}

		if ( isset( $settings['upload_label'] ) ) {
			$options['upload_label'] = $settings['upload_label'];
		}

		if ( isset( $settings['remove_label'] ) ) {
			$options['remove_label'] = $settings['remove_label'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $value );

		return $generator->get_field();
	}


	/**
	 * Adds BF Background Image field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function media_image_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'vc-media_image';

		if ( isset( $settings['upload_label'] ) ) {
			$options['upload_label'] = $settings['upload_label'];
		}

		if ( isset( $settings['remove_label'] ) ) {
			$options['remove_label'] = $settings['remove_label'];
		}

		if ( isset( $settings['media_title'] ) ) {
			$options['media_title'] = $settings['media_title'];
		}

		if ( isset( $settings['media_button'] ) ) {
			$options['media_button'] = $settings['media_button'];
		}

		if ( isset( $settings['data-type'] ) ) {
			$options['data-type'] = $settings['data-type'];
		}

		if ( isset( $settings['show_input'] ) ) {
			$options['show_input'] = $settings['show_input'];
		}

		if ( isset( $settings['hide_preview'] ) ) {
			$options['hide_preview'] = $settings['hide_preview'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $value );

		return $generator->get_field();
	}


	/**
	 * Adds BF slider field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function slider_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'slider';

		if ( isset( $settings['dimension'] ) ) {
			$options['dimension'] = $settings['dimension'];
		}

		if ( isset( $settings['min'] ) ) {
			$options['min'] = $settings['min'];
		}

		if ( isset( $settings['max'] ) ) {
			$options['max'] = $settings['max'];
		}

		if ( isset( $settings['step'] ) ) {
			$options['step'] = $settings['step'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $value );

		return $generator->get_field();
	}


	/**
	 * Adds BF slider field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function sorter_checkbox_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'vc-sorter_checkbox';

		if ( ! is_bool( $value ) && ! empty( $value ) ) {
			$options['value'] = $value;
		} elseif ( isset( $settings['value'] ) ) {
			$options['value'] = $settings['value'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $value );

		return $generator->get_field();
	}


	/**
	 * Adds BF Background Image field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function icon_select_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'icon_select';

		$generator = new BF_VC_Front_End_Generator( $options, $value );

		return $generator->get_field();
	}


	/**
	 * Adds BF Heading field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function heading_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'heading';
		if ( isset( $settings['heading'] ) ) {
			$options['title'] = $settings['heading'];
		} elseif ( isset( $options['title'] ) ) {
			$options['title']   = $settings['title'];
			$options['heading'] = $settings['title'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $value );

		return $generator->get_field();
	}


	/**
	 * Unique id of the page builder.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public function unique_id() {

		return 'VC';
	}
}
<?php


class BF_Elementor_Wrapper extends BF_Page_Builder_Wrapper {

	/**
	 * @var array
	 */
	protected $elementor_built_in_fields = array(
		'text',
		'heading',
		'hr',
		'textarea',
		'wp_editor',
		'code',
		'switch',
		'select',
		'radio',
		'color',
		'media_image',
		'slider',
	);

	/**
	 * @var array
	 */
	protected $wrapper_fields_list = array(
		//		'date',
		//		'checkbox',
		//		'ajax_select',
		//		'ajax_action',
		//		'sorter',
		//		'sorter_checkbox',
		//		'media',
		//		'background_image',
		//		'image_upload',
		//		'image_checkbox',
		//		'image_radio',
		//		'image_select',
		//		'icon_select',
		//		'typography',
		//		'border',
		//		'export',
		//		'import',
		//		'custom',
		//		'group_close',
		//		'editor',
		//		'term_select',
		//		'image_preview',
		//		'select_popup',
		'info',
	);


	/**
	 * Register supported fields.
	 *
	 * @return bool true on success.
	 */
	public function register_fields() {

		if ( ! class_exists( 'BF_Elementor_Control_Wrapper' ) ) {

			require BF_PATH . 'page-builder/wrappers/class-bf-elementor-control-wrapper.php';
		}

		foreach ( $this->wrapper_fields_list as $field_type ) {

			$control = new BF_Elementor_Control_Wrapper();
			$control->set_bf_field_type( $field_type );

			\Elementor\Plugin::$instance->controls_manager->register_control( $field_type, $control );
		}

		return true;
	}


	/**
	 * Register shortcode map.
	 *
	 * @param array $settings
	 * @param array $fields transformed fields
	 *
	 * @return bool true on success
	 */
	public function register_map( array $settings, $fields ) {

		if ( $settings['id'] !== 'bs-about' ) {

			return;
		}

		if ( ! class_exists( 'BF_Elementor_Widget_Wrapper' ) ) {
			require BF_PATH . 'page-builder/wrappers/class-bf-elementor-widget-wrapper.php';
		}

		try {

			$widget = new BF_Elementor_Widget_Wrapper();
			$widget->set_bf_shortcode_settings( $settings );

			return \Elementor\Plugin::instance()->widgets_manager->register_widget_type( $widget );

		} catch( Exception $e ) {

			return false;
		}
	}


	/**
	 * List of supported fields type.
	 *
	 * @return array
	 */
	public function supported_fields() {

		return array_merge( $this->elementor_built_in_fields, $this->wrapper_fields_list );
	}


	/**
	 * Call register_map method when this hook has been fired.
	 *
	 * Empty return value will fire the method immediately.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public static function register_map_hook() {

		return 'elementor/widgets/widgets_registered';
	}


	/**
	 * Call register_map method when this hook has been fired.
	 *
	 * Empty return value will fire the method immediately.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public static function register_fields_hook() {

		return 'elementor/controls/controls_registered';
	}

	/**
	 * Unique id of the page builder.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public function unique_id() {

		return 'Elementor';
	}
}
<?php


class BF_Page_Builder_Widget_Wrapper {

	public $widget_based_page_builders = array(
		'Elementor',
		'SiteOrigin',
	);


	public function __construct() {

		add_action( 'widgets_init', array( $this, 'init_widgets' ), 30 );

		if ( ! class_exists( 'BF_Widget_Artificial' ) ) {

			require BF_PATH . 'page-builder/misc/class-bf-widget-artificial.php';
		}
	}


	/**
	 * Init shortcodes as widget for known page builders.
	 */
	public function init_widgets() {

		if ( ! $this->can_init_widgets() ) {
			return;
		}

		foreach ( BF_Shortcodes_Manager::shortcodes_list() as $key => $shortcode ) {

			if ( isset( $shortcode['widget_class'] ) || ! empty( $shortcode['skip_page_builder'] ) ) {

				continue;
			}

			$this->register_widget( $key );
		}
	}


	/**
	 * @param string $shortcode_id
	 *
	 * @return BF_Widget_Artificial
	 */
	public function widget_class( $shortcode_id ) {

		return new BF_Widget_Artificial( $shortcode_id );
	}


	/**
	 * @param string $shortcode_id
	 */
	public function register_widget( $shortcode_id ) {

		global $wp_widget_factory;

		// we can't use register_widget( $widget ) because siteorigin page builder won't work when $widget is an object

		$wp_widget_factory->widgets["bf-page-builder-widget-$shortcode_id"] = $this->widget_class( $shortcode_id );

	}


	/**
	 * @return bool
	 */
	public function can_init_widgets() {

		if ( $this->is_wp_widgets_page() ) {
			return false;
		}

		$page_builder = Better_Framework::factory( 'page-builder' )->active_page_builders();

		return in_array( $page_builder, $this->widget_based_page_builders );
	}


	public function is_wp_widgets_page() {

		global $pagenow;

		return 'widgets.php' === $pagenow;
	}
}
<?php


class BF_Elementor_Control_Wrapper extends \Elementor\Base_Data_Control {

	/**
	 * @var string
	 */
	public $bf_field_type;


	/**
	 * Get emoji one area control type.
	 *
	 * Retrieve the control type, in this case `emojionearea`.
	 *
	 * @since  1.0.0
	 * @access public
	 *
	 * @return string Control type.
	 */
	public function get_type() {

		return $this->bf_field_type;
	}


	/**
	 * Enqueue emoji one area control scripts and styles.
	 *
	 * Used to register and enqueue custom scripts and styles used by the emoji one
	 * area control.
	 *
	 * @since  1.0.0
	 * @access public
	 */
	public function enqueue() {
	}


	/**
	 * Get emoji one area control default settings.
	 *
	 * Retrieve the default settings of the emoji one area control. Used to return
	 * the default settings while initializing the emoji one area control.
	 *
	 * @since  1.0.0
	 * @access protected
	 *
	 * @return array Control default settings.
	 */
	protected function get_default_settings() {

		return array();
	}


	/**
	 * Render emoji one area control output in the editor.
	 *
	 * Used to generate the control HTML in the editor using Underscore JS
	 * template. The variables for the class are available using `data` JS
	 * object.
	 *
	 * @since  1.0.0
	 * @access public
	 */
	public function content_template() {

		$control_uid = $this->get_control_uid();
		?>

		<div class="elementor-control-field">
			<label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">
				{{{ data.label }}}
			</label>
			<div class="elementor-control-input-wrapper">
				<?php
				$this->render_field();
				?>
			</div>
		</div>
		<# if ( data.description ) { #>
			<div class="elementor-control-field-description">{{{ data.description }}}</div>
			<# } #>
		<?php
	}


	/**
	 * @param string $field_type
	 */
	public function set_bf_field_type( $field_type ) {

		$this->bf_field_type = $field_type;
	}


	/**
	 * @return string
	 */
	public function get_bf_field_type() {

		return $this->bf_field_type;
	}


	/**
	 *
	 */
	protected function render_field() {

		$fields_dir = BF_PATH . 'core/field-generator/fields/';
		$field_file = sprintf( '%s.php', $this->bf_field_type );


		$options = array(
			'value'      => '',
			'input_name' => '___INPUT_NAME_PLACEHOLDER___',
		);

		ob_start();

		include $fields_dir . $field_file;

		$field_markup = ob_get_clean();

		echo $this->embed_unique_id( $field_markup );
	}


	/**
	 * @param string $html
	 *
	 * @return html
	 */
	public function embed_unique_id( $html ) {


		$pattern = '/(
			\< \s*   [a-z]+    [^\>]*
				name\s*=\s*
				([\'\"])?
				___INPUT_NAME_PLACEHOLDER___
				(?(2) \\2)
				[^\>]*
			\>)/isx';

		return preg_replace_callback( $pattern, array( $this, 'embed_unique_id_in_field' ), $html );
	}


	public function embed_unique_id_in_field( $matches ) {

		$field          = $matches[1];
		$modified_field = preg_replace( '/ id\s*=\s* ([^\s\>]+)/isx', 'id="' . $this->get_control_uid() . '"', $field );

		if ( $modified_field !== $field ) {
			return $modified_field;
		}

		return preg_replace( '/(.+)\>/', '$1 id="' . $this->get_control_uid() . '">', $field );
	}
}
<?php


class BF_Elementor_Widget_Wrapper extends \Elementor\Widget_Base {

	public $widget_id;


	public function __construct( array $data = [], array $args = null ) {

		if ( isset( $data['widgetType'] ) ) {
			$this->widget_id = $data['widgetType'];
		}

		parent::__construct( $data, $args );
	}


	/**
	 * @var array
	 */
	protected $bf_shortcode_settings = array();


	/**
	 * Get widget name.
	 *
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {

		return isset( $this->bf_shortcode_settings['id'] ) ? $this->bf_shortcode_settings['id'] : '';
	}


	/**
	 * Get widget title.
	 *
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {

		return isset( $this->bf_shortcode_settings['name'] ) ? $this->bf_shortcode_settings['name'] : '';
	}


	/**
	 * Get widget icon.
	 *
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {

		return isset( $this->bf_shortcode_settings['icon'] ) ? $this->bf_shortcode_settings['icon'] : '';
	}


	/**
	 * Get widget categories.
	 *
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {

		if ( isset( $this->bf_shortcode_settings['category'] ) ) {

			return array(
				$this->bf_shortcode_settings['category']
			);
		}

		return array( 'general' );
	}


	/**
	 * Register oEmbed widget controls.
	 *
	 * @access protected
	 */
	protected function _register_controls() {

		if ( ! class_exists( 'BF_Fields_Adapter' ) ) {

			require BF_PATH . '/page-builder/class-bf-fields-adapter.php';
		}

		if ( ! class_exists( 'BF_To_Elementor_Fields_Adapter' ) ) {

			require BF_PATH . 'page-builder/adapters/elementor/class-bf-to-elementor-fields-adapter.php';
		}

		BF_Shortcodes_Manager::factory();
		$adapter = new BF_To_Elementor_Fields_Adapter();

		$adapter->set_elementor_widget( $this );


		$adapter->load_fields( $this->shortcode_fields() );
		$adapter->transform();
	}


	/**
	 * Render oEmbed widget output on the frontend.
	 *
	 * @access protected
	 */
	protected function render() {

		$content = '';

		echo BF_Shortcodes_Manager::handle_shortcodes(
			$this->attributes(),
			$content,
			$this->widget_id
		);
	}


	/**
	 * @return array
	 */
	protected function attributes() {

		$attrs = $this->get_settings();

		foreach ( $this->attributes_changes() as $id => $index ) {

			if ( ! isset( $attrs[ $id ] ) ) {
				continue;
			}

			$attrs[ $id ] = isset( $attrs[ $id ][ $index ] ) ? $attrs[ $id ][ $index ] : '';
		}

		return $attrs;
	}


	/**
	 * @return array
	 */
	protected function attributes_changes() {

		if ( ! $changes = get_option( 'bf-elementor-fields-comp' ) ) {
			return array();
		}

		return isset( $changes[ $this->widget_id ] ) ? $changes[ $this->widget_id ] : array();
	}


	/**
	 * @param array $settings
	 */
	public function set_bf_shortcode_settings( $settings ) {

		$this->bf_shortcode_settings = $settings;

		if ( ! empty( $settings['id'] ) ) {

			$this->widget_id = $settings['id'];
		}
	}


	/**
	 * @return array
	 */
	public function get_bf_shortcode_settings() {

		return $this->bf_shortcode_settings;
	}


	public function shortcode_fields() {

		$fields = array();

		if ( $shortcode = BF_Shortcodes_Manager::factory( $this->widget_id ) ) {

			$fields = $shortcode->get_fields();

			$this->fields_compatibility( $fields );
		}

		return $fields;
	}


	public function fields_compatibility( &$fields ) {

		$status = get_option( 'bf-elementor-fields-comp', array() );

		foreach ( $fields as $field ) {

			if ( isset( $field['type'] ) && 'media_image' === $field['type'] ) {

				$status[ $this->widget_id ][ $field['id'] ] = isset( $field['data-type'] ) ? $field['data-type'] : 'url';
			}
		}

		update_option( 'bf-elementor-fields-comp', $status );
	}
}
<?php


class BF_KC_Wrapper extends BF_Page_Builder_Wrapper {

	/**
	 * @var array
	 *
	 * @since 4.0.0
	 */
	public $static_fields = array();


	/**
	 * Register
	 *
	 * @return bool true on success.
	 */
	public function register_fields() {

		global $kc;

		if ( ! $kc || ! is_callable( array( $kc, 'add_param_type' ) ) ) {
			return false;
		}

		// Register fields except deferred ones, they will load via ajax
		// @see BF_KC_Compatibility::ajax_load_fields()

		$this->static_fields = array_diff(
			$this->supported_fields(),
			$this->dynamic_deferred_fields(),
			$this->static_deferred_fields()
		);

		/**
		 * We can't use  $kc->add_param_type because the second parameter doesn't accept object
		 * That's silly but we have to handle this part in hard way!
		 *
		 * @see KingComposer::convert_paramTypes
		 */
		//		add_action( 'kc_after_admin_footer', array( $this, 'print_static_fields_template' ) );

		require BF_PATH . 'page-builder/generators/kc/kc-field-generator-functions.php';
		foreach ( $this->static_fields as $field ) {

			if ( function_exists( 'bf_kc_field_' . $field ) ) {
				$kc->add_param_type( $field, 'bf_kc_field_' . $field );
			}
		}

		return true;
	}

	/**
	 * @since 4.0.0
	 */
	/*public function print_static_fields_template() {

		if ( empty( $this->static_fields ) ) {

			return;
		}

		if ( ! class_exists( 'BF_KC_Fields_Generator' ) ) {
			require BF_PATH . 'page-builder/generators/kc/class-bf-kc-fields-generator.php';
		}

		$generator = new BF_KC_Fields_Generator();

		foreach ( $this->static_fields as $field ) {

			echo '<script type="text/html" id="tmpl-kc-field-type-' . esc_attr( $field ) . '-template">';

			$options = array(
				'id'    => '{{data.name}}',
				'value' => '{{data.value}}',
				'type'  => $field,
			);

			call_user_func( array( $generator, $field ), $options );

			echo "</script>\n";
		}
	}*/

	/**
	 * Adds BF Select field to Visual Composer
	 *
	 * @param $settings
	 * @param $value
	 *
	 * @return string
	 */
	function select_param( $settings, $value ) {

		$options = $this->convert_field_option( $settings, $value );

		$options['type'] = 'select';

		if ( isset( $settings['multiple'] ) ) {
			$options['multiple'] = $settings['multiple'];
		}

		$generator = new BF_VC_Front_End_Generator( $options, $settings['param_name'] );

		return $generator->get_field();
	}


	/**
	 * Register shortcode map.
	 *
	 * @param array $settings
	 * @param array $fields transformed fields
	 *
	 * @return bool true on success
	 */
	public function register_map( array $settings, $fields ) {

		if ( empty( $settings['name'] ) || empty( $settings['id'] ) ) {
			return false;
		}
		if ( empty( $fields ) ) {
			return false;
		}

		$always_fetch_fields = false;
		$deferred_types      = $this->dynamic_deferred_fields();

		foreach ( $fields as $tab_fields ) {

			foreach ( $tab_fields as $field ) {

				if ( in_array( $field['type'], $deferred_types ) ) {

					BF_KC_Compatibility::always_fetch_map_fields( $settings['id'] );

					$always_fetch_fields = true;
					break 2;
				}
			}
		}

		if ( ! $always_fetch_fields ) {

			$deferred_types  = $this->static_deferred_fields();
			$deferred_fields = array();

			foreach ( $fields as $tab_fields ) {

				foreach ( $tab_fields as $field ) {

					if ( in_array( $field['type'], $deferred_types ) ) {

						$deferred_fields[] = $field['type'];
					}
				}
			}

			if ( ! empty( $deferred_fields ) ) {
				BF_KC_Compatibility::mark_fields_as_deferred( $settings['id'], $deferred_fields );
			}
		}

		$settings['params'] = $fields;

		if ( isset( $settings['desc'] ) ) {

			$settings['description'] = $settings['desc'];
			unset( $settings['desc'] );
		}

		return $this->kc_map( $settings['id'], $settings );
	}


	/**
	 * List of all supported fields type.
	 *
	 * @return array
	 */
	public function supported_fields() {

		return array(
			'text',
			'color',
			'switch',
			'heading',
			'icon_select',
			'select',
			'select_popup',
			'term_select',
			'ajax_select',
			'custom',
			'group',
			'group_close',
			'info',
			'heading',
			'image_radio',
			'media_image',
			'sorter_checkbox',
			// 'background_image',
		);
	}


	/**
	 * todo: add comment
	 *
	 * @return array
	 */
	public function static_deferred_fields() {

		return array();
	}


	/**
	 * todo: add comment
	 * List of fields types that should be fetch via ajax
	 *
	 * @return array
	 */
	public function dynamic_deferred_fields() {

		return array(
			'icon_select',
			'select',
			'select_popup',
			'term_select',
			'ajax_select',
			'heading',
			'custom',
			'group',
			'group_close',
			'info',
			'image_radio',
			'media_image',
			'sorter_checkbox',
			// 'background_image',
		);
	}


	/**
	 * @param string        $id
	 * @param array         $atts
	 *
	 * @global KingComposer $kc
	 *
	 * @since 4.0.0
	 * @return bool true on success or false on error.
	 */
	public function kc_map( $id, $atts ) {

		global $kc;

		if ( $kc && is_callable( array( $kc, 'add_map' ) ) ) {

			if ( empty( $atts['category'] ) ) {
				$atts['category'] = 'all';
			}

			if ( empty( $atts['icon'] ) ) {

				$atts['icon'] = "$id-icon";
			}

			$kc->add_map( array( $id => $atts ) );

			return true;
		}

		return false;
	}

	/**
	 * Unique id of the page builder.
	 *
	 * @since 4.0.0
	 * @return string
	 */
	public function unique_id() {

		return 'KC';
	}
}<?php

// let's show them we are better
<?php


class BF_Page_Builder_Extender {


	public function __construct() {

		/**
		 * @var BF_Page_Builder_Wrapper $wrapper
		 */

		foreach ( self::active_page_builders() as $page_builder ) {

			if ( ! $wrapper_class = $this->wrapper_class( $page_builder ) ) {
				continue;
			}

			if ( $hook = call_user_func( array( $wrapper_class, 'register_fields_hook' ) ) ) {

				add_action( $hook, array( $this, 'register_fields_hook' ) );

			} else {

				$wrapper = new $wrapper_class();
				$wrapper->register_fields();
			}
		}

		if ( self::is_kc_active() ) {

			require BF_PATH . 'page-builder/compatibility/kc/class-bf-kc-compatibility.php';
		}
	}


	/**
	 * @return bool
	 */
	public function register_fields_hook() {

		foreach ( self::active_page_builders() as $page_builder ) {

			if ( $wrapper_class = $this->wrapper_class( $page_builder ) ) {

				$wrapper = new $wrapper_class();
				$wrapper->register_fields();
			}
		}

		return true;
	}


	/**
	 * Detect current running page builder plugin.
	 *
	 * @since 4.0.0
	 * @return string empty string on error or plugin short name on success.
	 */
	public static function active_page_builders() {

		$page_builders = array();

		if ( defined( 'WPB_VC_VERSION' ) && WPB_VC_VERSION ) {
			$page_builders[] = 'VC';
		}

		if ( defined( 'KCP_VERSION' ) && KCP_VERSION ) {
			$page_builders[] = 'KCP';
		}

		if ( defined( 'KC_VERSION' ) && KC_VERSION ) {
			$page_builders[] = 'KC';
		}

		if ( defined( 'ELEMENTOR_VERSION' ) && ELEMENTOR_VERSION ) {
			$page_builders[] = 'Elementor';
		}

		if ( defined( 'SITEORIGIN_PANELS_VERSION' ) && SITEORIGIN_PANELS_VERSION ) {
			$page_builders[] = 'SiteOrigin';
		}

		if ( ! class_exists( 'BF_Gutenberg_Shortcode_Wrapper' ) ) {
			require BF_PATH . 'gutenberg/class-bf-gutenberg-shortcode-wrapper.php';
		}

		if ( BF_Gutenberg_Shortcode_Wrapper::is_gutenberg_active() ) {
			$page_builders[] = 'Gutenberg';
		}

		return $page_builders;
	}

	public static function is_kc_active() {

		return in_array( 'KCP', self::active_page_builders() )
		       ||
		       in_array( 'KC', self::active_page_builders() );
	}


	/**
	 * Get current active page builder wrapper class.
	 *
	 * @param $page_builder
	 *
	 * @since 4.0.0
	 * @return string empty on failure.
	 */
	public function wrapper_class( $page_builder ) {

		if ( ! class_exists( 'BF_Page_Builder_Wrapper' ) ) {

			require BF_PATH . '/page-builder/class-bf-page-builder-wrapper.php';
		}

		$class_name = '';

		switch ( $page_builder ) {

			case 'VC':

				if ( ! class_exists( 'BF_VC_Wrapper' ) ) {

					require BF_PATH . '/page-builder/wrappers/class-bf-vc-wrapper.php';
				}

				$class_name = 'BF_VC_Wrapper';

				break;

			case 'KC':
			case 'KCP':

				if ( ! class_exists( 'BF_KC_Wrapper' ) ) {

					require BF_PATH . '/page-builder/wrappers/class-bf-kc-wrapper.php';
				}

				$class_name = 'BF_KC_Wrapper';

				break;
			/*
						case 'Elementor':

							if ( ! class_exists( 'BF_Elementor_Wrapper' ) ) {

								require BF_PATH . '/page-builder/wrappers/class-bf-elementor-wrapper.php';
							}

							$class_name = 'BF_Elementor_Wrapper';

							break;

			*/
		}

		return $class_name;
	}


	/**
	 * Get current active page builder adapter class.
	 *
	 * @param string $page_builder
	 *
	 * @since 4.0.0
	 * @return bool|BF_Fields_Adapter false on failure.
	 */
	public function adapter_class( $page_builder ) {

		if ( ! class_exists( 'BF_Fields_Adapter' ) ) {

			require BF_PATH . '/page-builder/class-bf-fields-adapter.php';
		}

		switch ( $page_builder ) {

			case 'VC':

				if ( ! class_exists( 'BF_To_VC_Fields_Adapter' ) ) {

					require BF_PATH . 'page-builder/adapters/class-bf-to-vc-fields-adapter.php';
				}

				$class_name = 'BF_To_VC_Fields_Adapter';

				break;

			case 'KC':
			case 'KCP':

				if ( ! class_exists( 'BF_To_KC_Fields_Adapter' ) ) {

					require BF_PATH . 'page-builder/adapters/class-bf-to-kc-fields-adapter.php';
				}

				$class_name = 'BF_To_KC_Fields_Adapter';

				break;
		}

		if ( ! empty( $class_name ) ) {
			return $class_name;
		}

		return false;
	}


	/**
	 * Transform standard BF fields format to active page builder style.
	 *
	 * @param string      $page_builder_id
	 * @param array $fields
	 * @param array $defaults
	 *
	 * @return mixed WP_Error|false on failure otherwise array|object
	 * @since 4.0.0
	 */
	public function transform( $page_builder_id, array $fields, $defaults = array() ) {

		if ( ! $adapter_class = $this->adapter_class( $page_builder_id ) ) {
			return false;
		}

		$adapter = new $adapter_class();
		$adapter->load_fields( $fields );
		$adapter->load_defaults( $defaults );

		return $adapter->transform();
	}
}
<?php


/**
 * Transform standard BF fields format to King Composer style
 *
 * @since 4.0.0
 */
class BF_To_KC_Fields_Adapter extends BF_Fields_Adapter {

	/**
	 * Transform
	 *
	 * @since 4.0.0
	 * @return array
	 */
	public function transform() {

		if ( empty( $this->fields ) ) {
			return array();
		}


		$shared_field_options = array(
			'type'          => '',
			'name'          => '',
			'value'         => '',
			'label'         => '',
			'admin_label'   => '',
			'description'   => '',
			'section_class' => '',
			'_options'      => '',
			'show_on'       => '',
			'multiple'      => '',
		);
		$replacements         = array(
			// 'bf key' => 'kc key'
			'name'           => 'label',
			'id'             => 'name',
			'desc'           => 'description',
			'vc_admin_label' => 'admin_label',
			'admin_label'    => 'admin_label',
		);

		$standard_fields  = $this->list_standard_fields();
		$supported_fields = $this->list_all_supported_fields();
		$current_tab      = __( 'General', 'better-studio' );

		$new_fields = array();

		foreach ( $this->fields as $idx => $field ) {

			if ( $field['type'] === 'tab' ) {
				$current_tab = $field['name'];
				continue;
			}

			if ( ! in_array( $field['type'], $supported_fields ) ) {
				continue;
			}

			$new_field                = $field;
			$new_field['is_standard'] = in_array( $field['type'], $standard_fields );

			// Set default value if exists
			if ( isset( $field['id'] ) && isset( $this->defaults[ $field['id'] ] ) ) {
				$new_field['value'] = $this->defaults[ $field['id'] ];
			}

			// Transform bf fields key to visual composer type
			foreach ( array_intersect_key( $replacements, $field ) as $key => $new_key ) {

				$new_field[ $new_key ] = $field[ $key ];

				unset( $new_field[ $key ] );
			}

			if ( isset( $new_field['options'] ) ) { // handle reserved 'options' key
				$new_field['_options'] = $new_field['options'];
				unset( $new_field['options'] );
			}
			$new_field['options'] = array_diff_key( $new_field, $shared_field_options );

			// Pass show_on value via options parameter only  for standard fields
			if ( $new_field['is_standard'] && ! empty( $field['show_on'] ) ) {

				$new_field['options']['show_on'] = array( 'show_on' => $field['show_on'] );
			}


			// Change 'group' type to bf_group to prevent conflict with king composer group field.]

			if ( 'group' === $new_field['type'] ) {

				$new_field['type'] = 'bf_group';

			} elseif ( 'group_close' === $new_field['type'] ) {

				$new_field['type'] = 'bf_group_close';
			}

			//TODO: add bf color picker support
			if ( 'color' === $new_field['type'] ) {

				$new_field['type'] = 'color_picker';
			}

			$new_fields[ $current_tab ][] = $new_field;
		}

		return $new_fields;
	}


	/**
	 * @since 4.0.0
	 * @return array
	 */
	public function list_standard_fields() {

		/**
		 * @var BF_KC_Wrapper $kc_wrapper
		 */

		if ( ! $kc_wrapper = Better_Framework::factory( 'page-builder' )->wrapper_class( 'KC' ) ) {
			return array();
		}

		$kc_wrapper = new $kc_wrapper();

		return array_diff(
			$kc_wrapper->supported_fields(),
			$kc_wrapper->dynamic_deferred_fields(),
			$kc_wrapper->static_deferred_fields()
		);
	}


	/**
	 * Get list of all supported fields in King Composer
	 *
	 * @since 4.0.0
	 * @return array
	 */
	public function list_all_supported_fields() {

		if ( ! $kc_wrapper = Better_Framework::factory( 'page-builder' )->wrapper_class( 'KC' ) ) {
			return array();
		}

		$kc_wrapper = new $kc_wrapper;

		return $kc_wrapper->supported_fields();
	}
}
<?php


/**
 * Transform standard BF fields format to VisualComposer style
 *
 * @since 4.0.0
 */
class BF_To_VC_Fields_Adapter extends BF_Fields_Adapter {

	/**
	 * Transform
	 *
	 * @since 4.0.0
	 * @return array
	 */
	public function transform() {

		$replacements = array(
			// 'bf key' => 'vc key'
			'name'           => 'heading',
			'desc'           => 'description',
			'id'             => 'param_name',
			'vc_admin_label' => 'admin_label',
		);


		$wrapper_class    = Better_Framework::factory( 'page-builder' )->wrapper_class( 'VC' );
		$vc_wrapper       = new $wrapper_class;
		$supported_fields = $vc_wrapper->supported_fields();
		$current_tab      = __( 'General', 'better-studio' );
		$fields           = $this->fields;

		foreach ( $this->fields as $idx => $field ) {

			if ( $field['type'] === 'tab' ) {
				$current_tab = $field['name'];
				unset( $fields[ $idx ] );
				continue;
			}

			// Set default value if exists
			if ( isset( $field['id'] ) && isset( $this->defaults[ $field['id'] ] ) ) {
				$fields[ $idx ]['value'] = $this->defaults[ $field['id'] ];
			}

			// Transform field type to vc-extender standard
			if ( $field['type'] === 'text' ) {
				$fields[ $idx ]['type'] = 'textfield';
			} elseif ( in_array( $field['type'], $supported_fields ) ) {
				$fields[ $idx ]['type'] = 'bf_' . $field['type'];
			}

			// Transform bf fields key to visual composer type
			foreach ( array_intersect_key( $replacements, $field ) as $key => $new_key ) {

				$fields[ $idx ][ $new_key ] = $field[ $key ];

				unset( $fields[ $idx ][ $key ] );
			}

			$fields[ $idx ]['group'] = $current_tab;
		}

		return $fields;
	}
}
<?php

// let's show them we are better
<?php


abstract class BF_Elementor_Field_Transformer {

	/**
	 * @var array
	 */
	protected $field;


	/**
	 *
	 * @return array
	 */
	abstract public function transform_field();


	/**
	 * @param array $field
	 */
	public function init( $field ) {

		$this->field = $field;
	}


	/**
	 * @param string $index
	 *
	 * @return mixed
	 */
	public function field( $index = '' ) {

		if ( $index ) {

			return isset( $this->field[ $index ] ) ? $this->field[ $index ] : null;
		}

		return $this->field;
	}
}
<?php


class BF_To_Elementor_Fields_Adapter extends BF_Fields_Adapter {

	/**
	 * @var Elementor\Widget_Base
	 */
	protected $widget;


	/**
	 * @var array
	 */
	protected $supported_fields = array();


	public function __construct( array $fields = array(), array $defaults = array() ) {

		parent::__construct( $fields, $defaults );

		$wrapper_class = Better_Framework::factory( 'page-builder' )->wrapper_class( 'Elementor' );

		$wrapper = new $wrapper_class();
		//
		$this->supported_fields = $wrapper->supported_fields();

	}


	/**
	 * @return mixed|WP_Error WP_Error on failure or transformed fields on success.
	 */
	public function transform() {

		if ( empty( $this->fields ) ) {
			return false;
		}

		reset( $this->fields );
		$first_index = key( $this->fields );
		$first_field = $this->fields[ $first_index ];
		//
		end( $this->fields );
		$last_index = key( $this->fields );
		$last_field = $this->fields[ $last_index ];
		//

		if ( ! isset( $first_field['type'] ) ||
		     ! in_array( $first_field['type'], array( 'group', 'tab' ) )
		) {

			$this->widget->start_controls_section(
				'section_title',
				array(
					'label' => $this->widget->get_title(),
				)
			);
		}
		$tab_started = false;

		foreach ( $this->fields as $id => $field ) {

			if ( empty( $field['type'] ) ) {
				continue;
			}

			$type = $field['type'];

			if ( $type === 'group' ) {

				$this->widget->start_controls_section(
					isset( $field['id'] ) ? $field['id'] : $id,
					array(
						'label' => $field['name'],
					)
				);

				continue;
			}

			if ( $type === 'group_close' ) {

				$this->widget->end_controls_section();

				continue;
			}

			if ( $type === 'tab' ) {

				$this->widget->end_controls_section();

				$this->widget->start_controls_section(
					isset( $field['id'] ) ? $field['id'] : $id,
					array(
						'label' => $field['name'],
					)
				);

				$tab_started = true;
			}

			if ( ! in_array( $type, $this->supported_fields ) ) {
				continue;
			}

			if ( empty( $field['id'] ) ) {
				continue;
			}

			if ( $factory = $this->factory( $field ) ) {
				$override_args = $factory->transform_field();
			} else {
				$override_args = array();
			}

			$type_const = strtoupper( $type );

			$this->widget->add_control( $field['id'], array_merge( array(

				'label'       => $field['name'],
				'type'        => defined( "Controls_Manager::$type_const" ) ? Controls_Manager::$type_const : $field['type'],
				'description' => isset( $field['desc'] ) ? $field['desc'] : '',
			), $override_args ) );
		}

		if ( $tab_started ) {
			$this->widget->end_controls_section();
		}

		if ( ! isset( $last_field['type'] ) ||
		     $last_field['type'] !== 'group_close'
		) {

			$this->widget->end_controls_section();
		}


		return true;
	}


	/**
	 * @param \Elementor\Widget_Base $widget
	 */
	public function set_elementor_widget( \Elementor\Widget_Base $widget ) {

		$this->widget = $widget;
	}


	/**
	 * @return \Elementor\Widget_Base
	 */
	public function get_elementor_widget() {

		return $this->widget;
	}


	/**
	 * @param array $field
	 *
	 * @since 3.9.0
	 * @return BF_Elementor_Field_Transformer on success or null on failure.
	 */
	public function factory( array $field ) {

		if ( empty( $field['type'] ) ) {
			return null;
		}

		if ( ! class_exists( 'BF_Elementor_Field_Transformer' ) ) {

			require BF_PATH . 'page-builder/adapters/elementor/class-bf-elementor-field.php';
		}

		switch ( $field['type'] ) {

			case 'custom';

				if ( ! class_exists( 'BF_Elementor_Raw_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-raw-field.php';
				}

				$instance = new BF_Elementor_Raw_Field();

				break;

			case 'hr';

				if ( ! class_exists( 'BF_Elementor_Divider_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-divider-field.php';
				}

				$instance = new BF_Elementor_Divider_Field();

				break;

			case 'wp_editor';

				if ( ! class_exists( 'BF_Elementor_WYSIWYG_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-wysiwyg-field.php';
				}

				$instance = new BF_Elementor_WYSIWYG_Field();

				break;


			case 'editor';

				if ( ! class_exists( 'BF_Elementor_Code_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-code-field.php';
				}

				$instance = new BF_Elementor_Code_Field();

				break;

			case 'switch';

				if ( ! class_exists( 'BF_Elementor_Switcher_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-switcher-field.php';
				}

				$instance = new BF_Elementor_Switcher_Field();

				break;


			case 'select';

				if ( ! class_exists( 'BF_Elementor_Select_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-select-field.php';
				}

				$instance = new BF_Elementor_Select_Field();

				break;

			case 'radio';

				if ( ! class_exists( 'BF_Elementor_Radio_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-radio-field.php';
				}

				$instance = new BF_Elementor_Radio_Field();

				break;

			case 'media_image';

				if ( ! class_exists( 'BF_Elementor_Media_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-media-field.php';
				}

				$instance = new BF_Elementor_Media_Field();

				break;


			case 'slider';

				if ( ! class_exists( 'BF_Elementor_Slider_Field' ) ) {

					require BF_PATH . 'page-builder/adapters/elementor/fields/class-bf-elementor-slider-field.php';
				}

				$instance = new BF_Elementor_Slider_Field();

				break;
		}

		if ( isset( $instance ) ) {
			$instance->init( $field );

			return $instance;
		}

		return null;
	}
}
<?php


class BF_Elementor_Select_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'options' => isset( $this->field['options'] ) ? $this->field['options'] : array(),
		);
	}
}
<?php


class BF_Elementor_Raw_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		$raw = $this->raw_code();

		return compact( 'raw' );
	}


	/**
	 * @return string
	 */
	public function raw_code() {

		if ( ! isset( $this->field['input_callback'] ) ) {
			return '';
		}

		if ( is_array( $this->field['input_callback'] ) ) {

			$callback = $this->field['input_callback']['callback'];

			if ( isset( $this->field['input_callback']['args'][0] ) ) {

				$callback_args = $this->field['input_callback']['args'];

				$callback_args[0]['field_options'] = $this->field;
			} else {

				$callback_args = array( array( 'field_options' => $this->field ) );
			}

		} else {

			$callback = $this->field['input_callback'];

			$callback_args = array( array( 'field_options' => $this->field ) );
		}

		ob_start();

		call_user_func_array( $callback, $callback_args );

		return ob_get_clean();
	}
}
<?php


class BF_Elementor_WYSIWYG_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'type' => 'wysiwyg',
		);
	}
}
<?php


class BF_Elementor_Slider_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		if ( isset( $this->field['min'] ) ) {
			$min = $this->field['min'];
		}

		if ( isset( $this->field['max'] ) ) {
			$max = $this->field['max'];
		}

		$step = 1;

		return array(
			'type'  => 'slider',
			'range' => compact( 'min', 'max', 'step' ),
		);
	}
}
<?php


class BF_Elementor_Code_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'type'     => 'code',
			'language' => isset( $this->field['lang'] ) ? $this->field['lang'] : '',
		);
	}
}
<?php


class BF_Elementor_Divider_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'type'      => 'divider',
			'separator' => 'after',
		);
	}
}
<?php


class BF_Elementor_Radio_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'options' => $this->field['options']
		);
	}
}
<?php


class BF_Elementor_Switcher_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'type'      => 'switcher',
			'label_on'  => isset( $this->field['on-label'] ) ? $this->field['on-label'] : '',
			'label_off' => isset( $this->field['off-label'] ) ? $this->field['off-label'] : '',
		);
	}
}
<?php

// let's show them we are better
<?php


class BF_Elementor_Media_Field extends BF_Elementor_Field_Transformer {

	/**
	 * @return array
	 */
	public function transform_field() {

		return array(
			'type'        => 'media',
			'show_label'  => ! empty( $this->field['show_input'] ),
			'label_block' => ! empty( $this->field['show_input'] ),
		);
	}
}
<?php

// let's show them we are better
<?php


abstract class BF_Fields_Adapter {

	/**
	 * @var array
	 *
	 * @since 4.0.0
	 */
	protected $fields = array();

	/**
	 * @var array
	 *
	 * @since 4.0.0
	 */
	protected $defaults = array();


	/**
	 * @return mixed|WP_Error WP_Error on failure or transformed fields on success.
	 */
	abstract public function transform();


	/**
	 * BF_Fields_Adapter constructor.
	 *
	 * @param array $fields
	 * @param array $defaults
	 *
	 */
	public function __construct( array $fields = array(), array $defaults = array() ) {

		$this->load_fields( $fields );
		$this->load_defaults( $defaults );
	}


	/**
	 * @param array $fields
	 *
	 * @return bool true on success
	 */
	public function load_fields( array $fields ) {

		$this->fields = $fields;

		return true;
	}


	/**
	 * @param array $defaults
	 *
	 * @return bool true on success
	 */
	public function load_defaults( array $defaults ) {

		$this->defaults = $defaults;

		return true;
	}
}
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


/**
 * User Metabox Fields Generator
 */
class BF_User_Metabox_Front_End_Generator extends BF_Admin_Fields {


	/**
	 * Constructor Function
	 *
	 * @param array  $items  Panel All Options
	 * @param string $id     Panel ID
	 * @param array  $values Panel Saved Values
	 *
	 * @since  1.4
	 * @access public
	 */
	public function __construct( array &$items, &$id, &$values = array() ) {

		// Parent Constructor
		parent::__construct( array(
			'templates_dir' => BF_PATH . 'metabox/templates/'
		) );

		$this->items  = $items;
		$this->id     = $id;
		$this->values = $values;
	}


	/**
	 * Used for creating input name
	 *
	 * @since 1.4
	 *
	 * @param $options
	 *
	 * @return string
	 */
	public function input_name( &$options ) {

		$id   = isset( $options['id'] ) ? $options['id'] : '';
		$type = isset( $options['type'] ) ? $options['type'] : '';

		switch ( $type ) {

			default:
				return "{$id}";
				break;

		}

	}


	/**
	 *  Metabox panel generator
	 *
	 * @since 1.4
	 */
	public function callback( $is_ajax = false ) {

		$skip_ajax_fields      = ! $is_ajax;
		$this->items['fields'] = BF_User_Metabox_Core::get_metabox_fields( $this->id );
		$metabox_config        = BF_User_Metabox_Core::get_metabox_config( $this->id );
		$items_has_tab         = ! $is_ajax && $this->has_tab();
		$has_tab               = false;

		if ( ! $is_ajax ) {
			$wrapper = Better_Framework::html()->add( 'div' )->class( 'bf-user-meta-wrap bf-metabox-wrap bf-clearfix' )->data( 'id', $this->id );

			// Better Option Title
			$wrapper->text(
				Better_Framework::html()->add( 'div' )->class( 'bf-user-metabox-title' )->text(
					Better_Framework::html()->add( 'h3' )->text( $metabox_config['title'] )
				)
			);

			// Add Class For Post Format Filter
			if ( isset( $metabox_config['post_format'] ) ) {
				$wrapper->data( 'bf_pf_filter', implode( ',', $metabox_config['post_format'] ) );
			}
		}

		$container = Better_Framework::html()->add( 'div' );
		if ( ! $is_ajax ) {
			$container = $container->class( 'bf-metabox-container' );
		}

		$tab_counter = 0;

		$group_counter = 0;

		if ( $items_has_tab && ! $is_ajax ) {
			$container->class( 'bf-with-tabs' );
			$tabs_container = Better_Framework::html()->add( 'div' )->class( 'bf-metabox-tabs' );
			$tabs_container->text( $this->get_tabs() );
			$wrapper->text( $tabs_container->display() );
		}

		if ( isset( $this->items['panel-id'] ) ) {
			$std_id = Better_Framework::options()->get_panel_std_id( $this->items['panel-id'] );
		} else {
			$std_id = 'std';
		}

		foreach ( $this->items['fields'] as $field ) {

			$field['input_name'] = $this->input_name( $field );

			$field['value'] = isset( $field['id'] ) && isset( $this->values[ $field['id'] ] ) ? $this->values[ $field['id'] ] : null;

			if ( is_null( $field['value'] ) && isset( $field[ $std_id ] ) ) {
				$field['value'] = $field[ $std_id ];
			} elseif ( is_null( $field['value'] ) && isset( $field['std'] ) ) {
				$field['value'] = $field['std'];
			}

			if ( $skip_ajax_fields && ! empty( $field['ajax-tab-field'] ) ) {  // Backward compatibility
				continue;
			}

			if ( $skip_ajax_fields && ! empty( $field['ajax-section-field'] ) ) {
				continue;
			}


			if ( $field['type'] == 'repeater' ) {
				$field['clone-name-format'] = 'bf-metabox-option[$1][$2][$3][$4]';
				$field['metabox-id']        = $this->id;
				$field['metabox-field']     = true;
			}

			if ( $field['type'] == 'tab' || $field['type'] == 'subtab' ) {

				// close tag for latest group in tab
				if ( $group_counter != 0 ) {
					$group_counter = 0;
					$container->text( $this->get_fields_group_close( $field ) );
				}

				$is_subtab = $field['type'] == 'subtab';

				if ( $tab_counter != 0 ) {
					$container->text( '</div><!-- /Section -->' );
				}

				if ( $is_subtab ) {
					$container->text( "\n\n<!-- Section -->\n<div class='group subtab-group' id='bf-metabox-{$this->id}-{$field["id"]}'>\n" );
				} else {
					$container->text( "\n\n<!-- Section -->\n<div class='group' id='bf-metabox-{$this->id}-{$field["id"]}'>\n" );
				}
				$has_tab = true;
				$tab_counter ++;
				continue;
			}

			if ( $field['type'] == 'group_close' ) {

				// close tag for latest group in tab
				if ( $group_counter != 0 ) {
					$group_counter = 0;
					$container->text( $this->get_fields_group_close( $field ) );
				}
				continue;
			}

			if ( $field['type'] == 'group' ) {

				// close tag for latest group in tab
				if ( $group_counter != 0 ) {
					$group_counter = 0;
					$container->text( $this->get_fields_group_close( $field ) );
				}

				$container->text( $this->get_fields_group_start( $field ) );

				$group_counter ++;
			}


			if ( ! in_array( $field['type'], $this->supported_fields ) ) {
				continue;
			}

			// Filter Each Field For Post Formats!
			if ( isset( $field['post_format'] ) ) {

				if ( is_array( $field['post_format'] ) ) {
					$field_post_formats = implode( ',', $field['post_format'] );
				} else {
					$field_post_formats = $field['post_format'];
				}
				$container->text( "<div class='bf-field-post-format-filter' data-bf_pf_filter='{$field_post_formats}'>" );
			}

			$container->text(
				$this->section(
					call_user_func(
						array( $this, $field['type'] ),
						$field
					),
					$field
				)
			);

			// End Post Format Filter Wrapper
			if ( isset( $field['post_format'] ) ) {

				$container->text( "</div>" );
			}
		}

		// close tag for latest group in tab
		if ( $group_counter != 0 ) {
			$container->text( $this->get_fields_group_close( $field ) );
		}

		// last sub tab closing
		if ( $has_tab ) {
			$container->text( "</div><!-- /Section -->" );
		}

		if ( $is_ajax ) {
			echo $container->display();
		} else {
			$wrapper->text( $container->display() );
			echo $wrapper; // escaped before
		}

	} // callback
}<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


// Prevent Direct Access
defined( 'ABSPATH' ) or die;


/**
 * This class handles all functionality of BetterFramework Users Meta box feature for creating, saving, editing
 *
 * @package    BetterFramework
 * @since      1.4
 */
class BF_User_Metabox_Core {


	/**
	 * Contains all metabox's
	 *
	 * @var array
	 */
	public static $metabox = array();


	/**
	 * Contains config for all metabox's
	 *
	 * @var array
	 */
	public static $config = array();


	/**
	 * Contains all fields
	 *
	 * @var array
	 */
	public static $fields = array();


	/**
	 * Contains all std
	 *
	 * @var array
	 */
	public static $std = array();


	/**
	 * Contains all css
	 *
	 * @var array
	 */
	public static $css = array();


	/**
	 * Initializes all metaboxes
	 */
	public static function init_metabox() {

		static $loaded;

		if ( $loaded ) {
			return;
		}

		self::$metabox = apply_filters( 'better-framework/user-metabox/add', array() );

	}


	/**
	 * loads and returns metabox config
	 *
	 * @param string $metabox_id
	 *
	 * @return array
	 */
	public static function get_metabox_config( $metabox_id = '' ) {

		if ( empty( $metabox_id ) ) {
			return array();
		}

		if ( isset( self::$config[ $metabox_id ] ) ) {
			return self::$config[ $metabox_id ];
		}

		return self::$config[ $metabox_id ] = apply_filters( 'better-framework/user-metabox/' . $metabox_id . '/config', array() );
	}


	/**
	 * loads and returns metabox std values
	 *
	 * @param string $metabox_id
	 *
	 * @return array
	 */
	public static function get_metabox_std( $metabox_id = '' ) {

		if ( empty( $metabox_id ) || ! isset( self::$metabox[ $metabox_id ] ) ) {
			return array( 'asdsd' );
		}

		if ( isset( self::$std[ $metabox_id ] ) ) {
			return self::$std[ $metabox_id ];
		}

		return self::$std[ $metabox_id ] = apply_filters( 'better-framework/user-metabox/' . $metabox_id . '/std', array() );
	}


	/**
	 * loads and returns metabox std values
	 *
	 * @param string $metabox_id
	 *
	 * @return array
	 */
	public static function get_metabox_fields( $metabox_id = '' ) {

		if ( empty( $metabox_id ) || ! isset( self::$metabox[ $metabox_id ] ) ) {
			return array();
		}

		if ( isset( self::$fields[ $metabox_id ] ) ) {
			return self::$fields[ $metabox_id ];
		}

		return self::$fields[ $metabox_id ] = apply_filters( 'better-framework/user-metabox/' . $metabox_id . '/fields', array() );
	}


	/**
	 * loads and returns metabox css
	 *
	 * @param string $metabox_id
	 *
	 * @return array
	 */
	public static function get_metabox_css( $metabox_id = '' ) {

		if ( empty( $metabox_id ) || ! isset( self::$metabox[ $metabox_id ] ) ) {
			return array();
		}

		if ( isset( self::$css[ $metabox_id ] ) ) {
			return self::$css[ $metabox_id ];
		}

		return self::$css[ $metabox_id ] = apply_filters( 'better-framework/user-metabox/' . $metabox_id . '/css', array() );
	}


	/**
	 * Used to add action for constructing the meta box
	 *
	 * @since     1.4
	 * @access    public
	 */
	public function __construct() {

		self::init_metabox();

		// Add options form
		add_action( 'show_user_profile', array( $this, 'add_meta_boxes' ) );
		add_action( 'edit_user_profile', array( $this, 'add_meta_boxes' ) );

		add_action( 'edit_user_profile_update', array( $this, 'save' ), 1 );
		add_action( 'personal_options_update', array( $this, 'save' ), 1 );

		/**
		 * Action to handle ajax user metabox tabs
		 */
		add_action( 'better-framework/user-metabox/ajax-tab', array( $this, 'ajax_tab' ), 10, 3 );
	}


	/**
	 * Used for retrieve meta data values
	 *
	 * @param   string $id meta box id
	 * @param          $user
	 *
	 * @since    1.4
	 * @return  array
	 * @access   public
	 */
	public function get_full_meta_data( $id = '', $user ) {

		global $pagenow;

		$output = array();

		if ( isset( self::$metabox[ $id ]['panel-id'] ) ) {
			$std_id = Better_Framework::options()->get_panel_std_id( self::$metabox[ $id ]['panel-id'] );
		} else {
			$std_id = 'std';
		}

		$metabox_std = self::get_metabox_std( $id );

		if ( $pagenow == 'post-new.php' ) {

			if ( ! empty( $metabox_std ) ) {

				foreach ( (array) $metabox_std as $field_id => $field ) {

					if ( isset( $field[ $std_id ] ) ) {
						$output[ $field_id ] = $field[ $std_id ];
					} elseif ( isset( $field['std'] ) ) {
						$output[ $field_id ] = $field['std'];
					}
				}

			}

			return $output;
		}

		$meta = get_user_meta( $user->ID );

		foreach ( (array) $metabox_std as $field_id => $field ) {

			if ( isset( $meta[ $field_id ] ) ) {

				if ( is_serialized( $meta[ $field_id ][0] ) ) {
					$output[ $field_id ] = unserialize( $meta[ $field_id ][0] );
				} else {
					$output[ $field_id ] = $meta[ $field_id ][0];
				}

			} else {

				if ( isset( $field[ $std_id ] ) ) {
					$output[ $field_id ] = $field[ $std_id ];
				} elseif ( isset( $field['std'] ) ) {
					$output[ $field_id ] = $field['std'];
				}
			}

		}

		return $output;
	}


	/**
	 * Deprecated: Use bf_get_user_meta
	 *
	 * Used for finding user meta field value.
	 *
	 * @since   1.4
	 *
	 * @param $field_key    string              User field ID
	 * @param $user         string|WP_User      User ID or object
	 *
	 * @return mixed
	 */
	public function get_meta( $field_key, $user ) {

		return bf_get_user_meta( $field_key, $user );
	}


	/**
	 * Callback: Used for creating meta boxes
	 *
	 * Action: show_user_profile
	 * Action: edit_user_profile
	 *
	 * @since   1.4
	 * @access  public
	 *
	 * @param   $user   string|WP_User      User ID or object
	 */
	public function add_meta_boxes( $user ) {

		if ( ! class_exists( 'BF_User_Metabox_Front_End_Generator' ) ) {
			require BF_PATH . 'user-metabox/class-bf-user-metabox-front-end-generator.php';
		}

		foreach ( (array) self::$metabox as $metabox_id => $metabox ) {

			$metabox_value = $this->get_full_meta_data( $metabox_id, $user );

			$metabox_config = self::get_metabox_config( $metabox_id );

			if ( empty( $metabox_config['title'] ) ) {
				$metabox_config['title'] = __( 'Better User Options', 'better-studio' );
			}

			$front_end = new BF_User_Metabox_Front_End_Generator( $metabox_config, $metabox_id, $metabox_value );

			$front_end->callback();
		}

	} // add


	/**
	 * Updates user meta in safely
	 *
	 * @param   string|WP_User $user  User ID or object
	 * @param   string         $key   User meta key name
	 * @param   string         $value User meta value
	 *
	 * @static
	 * @since   1.4
	 * @return  bool
	 */
	public static function add_meta( $user, $key, $value ) {

		if ( ! is_object( $user ) ) {
			$user = get_user_by( 'id', $user );
		}

		$old_value = get_user_meta( $user->ID, $key, true );

		if ( $old_value === false ) {
			return add_user_meta( $user->ID, $key, $value );
		} else {
			if ( $old_value === $value ) {
				return true;
			} else {
				delete_user_meta( $user->ID, $key );

				return add_user_meta( $user->ID, $key, $value );
			}
		}

	}


	/**
	 * Callback: Save user meta box values
	 *
	 * Action: edit_user_profile_update
	 * Action: personal_options_update
	 *
	 * @param   int $user_id
	 *
	 * @static
	 * @return  mixed
	 * @since   1.4
	 */
	public function save( $user_id ) {

		if ( ! current_user_can( 'edit_user', $user_id ) ) {
			return false;
		}

		// Iterate all meta boxes
		foreach ( (array) self::$metabox as $metabox_id => $metabox ) {

			if ( isset( $metabox['panel-id'] ) ) {
				$std_id = Better_Framework::options()->get_panel_std_id( $metabox['panel-id'] );
			} else {
				$std_id = 'std';
			}

			$metabox_std = self::get_metabox_std( $metabox_id );

			// Iterate all fields
			foreach ( (array) $metabox_std as $field_id => $field ) {

				if ( ! isset( $_POST[ $field_id ] ) ) {
					continue;
				}

				// Save value if save-std is true or not defined
				if ( ! isset( $field['save-std'] ) || $field['save-std'] == true ) {

					self::add_meta( $user_id, $field_id, $_POST[ $field_id ] );

				} // Don't Save Default Value
				elseif ( isset( $field['save-std'] ) ) {

					// If style std defined then save it
					if ( isset( $field[ $std_id ] ) ) {

						if ( $field[ $std_id ] != $_POST[ $field_id ] ) {
							self::add_meta( $user_id, $field_id, $_POST[ $field_id ] );
						} else {
							delete_user_meta( $user_id, $field_id );
						}

					} // If style std defined then save it
					elseif ( isset( $field['std'] ) ) {

						if ( $field['std'] != $_POST[ $field_id ] ) {
							self::add_meta( $user_id, $field_id, $_POST[ $field_id ] );
						} else {
							delete_user_meta( $user_id, $field_id );
						}

					}

				} // Delete Custom field
				else {
					delete_user_meta( $user_id, $field_id );
				}

			}

		}

	} // save


	/**
	 *
	 *
	 * @param string     $tab_id
	 * @param string     $metabox_id
	 * @param int|string $user_id
	 */
	public function ajax_tab( $tab_id, $metabox_id, $user_id ) {

		$user           = get_user_to_edit( $user_id );
		$fields         = BF_User_Metabox_Core::get_metabox_fields( $metabox_id );
		$metabox_value  = array();
		$metabox_config = self::get_metabox_config( $metabox_id );
		$use_generator  = true;


		if ( empty( $fields[ $tab_id ]['ajax-section-handler'] ) ) {

			$metabox_value = $this->get_full_meta_data( $metabox_id, $user );

			// Modify fields array
			foreach ( $fields as $idx => $field ) {

				// Backward compatibility
				if ( isset( $field['ajax-tab-field'] ) ) {
					$field['ajax-section-field'] = $field['ajax-tab-field'];
				}

				if ( empty( $field['ajax-section-field'] ) || $field['ajax-section-field'] !== $tab_id ) {
					unset( $fields[ $idx ] );
				}
			}

		} else {

			$parent_field = $fields[ $tab_id ];

			$args = isset( $parent_field['ajax-section-handler-args'] ) ? $parent_field['ajax-section-handler-args'] : array();
			$args = array_merge( $args, compact( 'metabox_id', 'tab_id' ) );

			if (
				! isset( $parent_field['ajax-section-handler-type'] ) ||
				$parent_field['ajax-section-handler-type'] === 'field-generator'
			) {

				$fields = call_user_func( $parent_field['ajax-section-handler'], $args );

				foreach ( $fields as $key => $field ) {

					$metabox_value[ $field['id'] ] = bf_get_user_meta( $field['id'], $user_id );
				}
			} else {

				$use_generator = false;
				$out           = call_user_func( $parent_field['ajax-section-handler'], $args );

			}
		}

		if ( $use_generator ) {

			if ( ! class_exists( 'BF_User_Metabox_Front_End_Generator' ) ) {
				require BF_PATH . 'user-metabox/class-bf-user-metabox-front-end-generator.php';
			}
			$front_end = new BF_User_Metabox_Front_End_Generator( $metabox_config, $metabox_id, $metabox_value );

			BF_User_Metabox_Core::$fields[ $metabox_id ] = $fields;

			ob_start();
			// print output
			echo $front_end->callback( true );  // escaped before
			$out = ob_get_clean();
		}

		wp_send_json( array( 'out' => $out, 'tab_id' => $tab_id ) );
	}
}
<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


if ( ! function_exists( 'bf_get_user_meta' ) ) {
	/**
	 * Used for finding user meta field value.
	 *
	 * @since   2.0
	 *
	 * @param   string         $field_key     User field ID
	 * @param   string|WP_User $user          User ID or object
	 * @param   null           $force_default Default value (Optional)
	 *
	 * @return mixed
	 */
	function bf_get_user_meta( $field_key, $user = null, $force_default = null ) {

		if ( is_null( $user ) ) {

			// Get current post author id
			if ( is_singular() ) {
				$user = get_the_author_meta( 'ID' );
			} // Get current archive user
			elseif ( is_author() ) {
				$user = bf_get_author_archive_user();
			} // Return default value
			else {
				return $force_default;
			}
		}

		// Get user id from object
		if ( is_object( $user ) ) {
			$user = $user->ID;
		}

		// get value if saved in DB
		$value = get_user_meta( $user, $field_key, true );

		if ( $value !== false ) {
			return $value;
		} // Or return force default value
		elseif ( ! is_null( $force_default ) ) {
			return $force_default;
		}

		// initialize base BF metabox
		if ( ! class_exists( 'BF_User_Metabox_Core' ) ) {
			Better_Framework()->user_meta();
		}

		// Iterate all meta boxes
		foreach ( BF_User_Metabox_Core::$metabox as $metabox_id => $metabox ) {

			// if this meta box connected to a panel for style field
			if ( isset( $metabox['panel-id'] ) ) {
				$std_id = Better_Framework()->options()->get_panel_std_id( $metabox['panel-id'] );
			} else {
				$std_id = 'std';
			}

			$metabox_std = BF_User_Metabox_Core::get_metabox_std( $metabox_id );

			// retrieve default value
			if ( isset( $metabox_std[ $field_key ][ $std_id ] ) ) {
				return $metabox_std[ $field_key ][ $std_id ];
			} elseif ( isset( $metabox_std[ $field_key ]['std'] ) ) {
				return $metabox_std[ $field_key ]['std'];
			}

		}

		return false;
	}
}


if ( ! function_exists( 'bf_echo_user_meta' ) ) {
	/**
	 * Used to echo user meta field value.
	 *
	 * @since   2.0
	 *
	 * @param   string         $field_key     User field ID
	 * @param   string|WP_User $user          User ID or object
	 * @param   null           $force_default Default value (Optional)
	 *
	 * @return mixed
	 */
	function bf_echo_user_meta( $field_key, $user = null, $force_default = null ) {

		echo bf_get_user_meta( $field_key, $user, $force_default );
	}
}

<?php
die;<?php
/***
 *  BetterFramework is BetterStudio framework for themes and plugins.
 *
 *  ______      _   _             ______                                           _
 *  | ___ \    | | | |            |  ___|                                         | |
 *  | |_/ / ___| |_| |_ ___ _ __  | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 *  | ___ \/ _ \ __| __/ _ \ '__| |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 *  | |_/ /  __/ |_| ||  __/ |    | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 *  \____/ \___|\__|\__\___|_|    \_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 *
 *  Copyright © 2017 Better Studio
 *
 *
 *  Our portfolio is here: https://betterstudio.com/
 *
 *  \--> BetterStudio, 2018 <--/
 */


$classes = $this->get_classes( $options );
$iri     = isset( $options['repeater_item'] ) && $options['repeater_item'] == true; // Is this section for a repeater item

$section_classes = $classes['section'];

$heading_classes  = $classes['heading'];
$controls_classes = $classes['controls'];
$explain_classes  = $classes['explain'];

if ( $iri ) {

	$section_classes  .= ' ' . $classes['repeater-section'];
	$heading_classes  .= ' ' . $classes['repeater-heading'];
	$controls_classes .= ' ' . $classes['repeater-controls'];
	$explain_classes  .= ' ' . $classes['repeater-explain'];

} else {

	$section_classes  .= ' ' . $classes['nonrepeater-section'];
	$heading_classes  .= ' ' . $classes['nonrepeater-heading'];
	$controls_classes .= ' ' . $classes['nonrepeater-controls'];
	$explain_classes  .= ' ' . $classes['nonrepeater-explain'];

}

$section_classes  .= ' ' . $classes['section-class-by-filed-type'];
$heading_classes  .= ' ' . $classes['heading-class-by-filed-type'];
$controls_classes .= ' ' . $classes['controls-class-by-filed-type'];
$explain_classes  .= ' ' . $classes['explain-class-by-filed-type'];

if ( empty( $options['desc'] ) ) {
	$section_classes .= ' no-desc ';
}
?>
<div class="bf-section-container bf-metabox bf-clearfix">
	<div class="<?php echo esc_attr( $section_classes ); ?> bf-clearfix"
	     data-id="<?php echo esc_attr( $options['id'] ); ?>">

		<div class="<?php echo esc_attr( $heading_classes ); ?> bf-clearfix">
			<h3><label><?php echo esc_html( $options['name'] ); ?></label></h3>
		</div>

		<div class="<?php echo esc_attr( $controls_classes ); ?> bf-clearfix">
			<?php echo $input; // escaped before ?>
		</div>

		<?php if ( ! empty( $options['desc'] ) ) { ?>
			<div
					class="<?php echo esc_attr( $explain_classes ); ?> bf-clearfix"><?php echo wp_kses( $options['desc'], bf_trans_allowed_html() ); ?></div>
		<?php } ?>

	</div>
</div>

F1le Man4ger