Plugin Directory

Changeset 1854131


Ignore:
Timestamp:
04/06/2018 12:48:10 PM (8 years ago)
Author:
devdmkr
Message:

update

Location:
prime-ads/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • prime-ads/trunk/inc/services/AdsHelper.php

    r1853454 r1854131  
    5757    public $screenWidth = array();
    5858    public $screenWidthInPx;
     59    public $adblockDetected = 0;
    5960
    6061    public $notIncludeAds = false;
     
    152153            if($i > 0) $sql .= " UNION";
    153154
    154             $sql .= " SELECT id, tags, in_rubrics, ex_rubrics, in_posts, ex_posts, min_lenght, country, region, city, resolutions, by_timetable, days_of_week, from_time, to_time, not_show, is_active, position, position_not_in_timetable, shows*shows_ratio as shows, '" . $this->_functions[$i] . "' as method, ((`from_time`<`to_time` AND `from_time`<=" . $hour . " AND `to_time`>" . $hour . ") OR (`from_time`>`to_time` AND ((`from_time`<=" . $hour . " AND " . $hour . "<=23) OR (`to_time`>" . $hour . " AND " . $hour . ">=0))) OR (`from_time`=`to_time`)) as time_exp FROM " . $wpdb->prefix . $this->_tables[$i];
     155            $sql .= " SELECT id, tags, in_rubrics, ex_rubrics, in_posts, ex_posts, min_lenght, country, region, city, resolutions,adblock_only, by_timetable, days_of_week, from_time, to_time, not_show, is_active, position, position_not_in_timetable, shows*shows_ratio as shows, '" . $this->_functions[$i] . "' as method, ((`from_time`<`to_time` AND `from_time`<=" . $hour . " AND `to_time`>" . $hour . ") OR (`from_time`>`to_time` AND ((`from_time`<=" . $hour . " AND " . $hour . "<=23) OR (`to_time`>" . $hour . " AND " . $hour . ">=0))) OR (`from_time`=`to_time`)) as time_exp FROM " . $wpdb->prefix . $this->_tables[$i];
    155156        }
    156157
     
    199200        }
    200201
    201         $sql .= " order by by_timetable DESC, IF(tags !='',0,1),IF(in_rubrics !='',0,1),IF(in_posts !='',0,1),IF(country !='',0,1),IF(region !='',0,1),IF(city !='',0,1),shows limit 1";
     202        if(!$this->adblockDetected)
     203            $sql .= ' and `adblock_only`=0';
     204
     205        $sql .= " order by";
     206        if($this->adblockDetected) $sql .=" adblock_only DESC, ";
     207
     208        $sql.= " by_timetable DESC, IF(tags !='',0,1),IF(in_rubrics !='',0,1),IF(in_posts !='',0,1),IF(country !='',0,1),IF(region !='',0,1),IF(city !='',0,1),shows limit 1";
    202209        $itemProps = $wpdb->get_row($sql);
    203210        if(!$itemProps) return '';
  • prime-ads/trunk/inc/services/Migration.php

    r1849088 r1854131  
    212212            return '2.1.8';
    213213        }
     214
     215        if($ver == '2.1.8'){
     216            $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_code_block` ADD `adblock_only` TINYINT NOT NULL DEFAULT '0'");
     217
     218            $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_text_block` ADD `adblock_only` TINYINT NOT NULL DEFAULT '0'");
     219
     220            $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_simple_tizer_group` ADD `adblock_only` TINYINT NOT NULL DEFAULT '0'");
     221
     222            $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_comment` ADD `adblock_only` TINYINT NOT NULL DEFAULT '0'");
     223
     224            $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_adsense_block` ADD `adblock_only` TINYINT NOT NULL DEFAULT '0'");
     225
     226            update_option('ads-db-verison', '2.2.1');
     227            return '2.2.1';
     228        }
    214229    }
    215230}
  • prime-ads/trunk/jci/functions.js

    r1747413 r1854131  
     1//AdBlock Detect
     2(function(root, factory) {
     3    /* istanbul ignore next */
     4    if (typeof define === 'function' && define.amd) {
     5        define([], factory);
     6    } else if (typeof module === 'object' && module.exports) {
     7        module.exports = factory();
     8    } else {
     9        root.adblockDetect = factory();
     10    }
     11
     12}(this, function() {
     13    function adblockDetect(callback, options) {
     14        options = merge(adblockDetect.defaults, options || {});
     15
     16        var testNode = createNode(options.testNodeClasses, options.testNodeStyle);
     17        var runsCounter = 0;
     18        var adblockDetected = false;
     19
     20        var testInterval = setInterval(function() {
     21
     22            runsCounter++;
     23            adblockDetected = isNodeBlocked(testNode);
     24
     25            if (adblockDetected || runsCounter === options.testRuns) {
     26                clearInterval(testInterval);
     27                testNode.parentNode && testNode.parentNode.removeChild(testNode);
     28                callback(adblockDetected);
     29            }
     30        }, options.testInterval);
     31    }
     32
     33    function createNode(testNodeClasses, testNodeStyle) {
     34        var document = window.document;
     35        var testNode = document.createElement('div');
     36
     37        testNode.innerHTML = '&nbsp;';
     38        testNode.setAttribute('class', testNodeClasses);
     39        testNode.setAttribute('style', testNodeStyle);
     40
     41        document.body.appendChild(testNode);
     42
     43        return testNode;
     44    }
     45
     46    function isNodeBlocked(testNode) {
     47        return testNode.offsetHeight === 0 ||
     48            !document.body.contains(testNode) ||
     49            testNode.style.display === 'none' ||
     50            testNode.style.visibility === 'hidden'
     51        ;
     52    }
     53
     54    function merge(defaults, options) {
     55        var obj = {};
     56
     57        for (var key in defaults) {
     58            obj[key] = defaults[key];
     59            options.hasOwnProperty(key) && (obj[key] = options[key]);
     60        }
     61
     62        return obj;
     63    }
     64
     65    adblockDetect.defaults = {
     66        testNodeClasses: 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links',
     67        testNodeStyle: 'height: 10px !important; font-size: 20px; color: transparent; position: absolute; bottom: 0; left: -10000px;',
     68        testInterval: 51,
     69        testRuns: 4
     70    };
     71
     72    return adblockDetect;
     73}));
     74// end AdblockDetect
     75
    176var closed_blocks = Cookies.get('closed_blocks');
    277if(!closed_blocks) closed_blocks = [];
     78
     79var loaderStarted = false;
     80
    381function linkCount(obj){
    482    jQuery.ajax({
     
    58136
    59137    if(positions.length > 0){
     138        adblockDetect(function(adblockDetected) {
     139            loadBlocks(adblockDetected);
     140        });
     141
     142        // если не сработала загзрузка после определения адблока
     143        setTimeout(function(){
     144            if(!loaderStarted) loadBlocks(false);
     145        }, 1000);
     146    }
     147
     148    function loadBlocks(adblockDetected){
     149        if(loaderStarted) return;
     150        loaderStarted = true;
    60151        $.ajax({
    61152            type: 'POST',
     
    65156                id: positions,
    66157                width: $(window).width(),
     158                adblockDetected: adblockDetected ? 1 : 0,
    67159                cache: false,
    68160            },
     
    89181        });
    90182    }
    91    
    92183});
  • prime-ads/trunk/prime-ads.php

    r1853454 r1854131  
    33    Plugin Name: Prime Ads
    44    Description: Вывод рекламы с сервиса Prime Ads
    5     Version: 2.2.0
     5    Version: 2.2.1
    66    Author: Proffit
    77    Author URI: http://proffit.guru/
     
    1919use AdsNS\SxGeo\SxGeo;
    2020
    21 define('ADS_VERSION', '2.2.0');
    22 define('ADS_DB_VERSION', '2.1.8');
     21define('ADS_VERSION', '2.2.1');
     22define('ADS_DB_VERSION', '2.2.1');
    2323define('ADS_PATH', realpath(__DIR__));
    2424define('ADS_SERVICE_URL', get_option('ads-service-url', 'http://primeads.ru/'));
     
    215215            wp_enqueue_script('prma-cookie', $upload_dir['baseurl'] . '/' . $folder . '/js.cookie.js', array('jquery'), "2.1.3", true);
    216216            wp_enqueue_script('prma-script', $upload_dir['baseurl'] . '/' . $folder . '/script.js', array('jquery', 'prma-functions'), "1.0.0", false);
    217             wp_enqueue_script('prma-functions', $upload_dir['baseurl'] . '/' . $folder . '/functions.js', array('jquery', 'prma-cookie'), "1.0.1", false);
     217            wp_enqueue_script('prma-functions', $upload_dir['baseurl'] . '/' . $folder . '/functions.js', array('jquery', 'prma-cookie'), "1.0.2", false);
    218218            wp_enqueue_script('prma-fixed', $upload_dir['baseurl'] . '/' . $folder . '/jquery-scrolltofixed.js', array('jquery'), "1.0.7", true);
    219219            wp_enqueue_script('prma-flip', $upload_dir['baseurl'] . '/' . $folder . '/jquery.flip.min.js', array('jquery'), "1.0.20", true);
     
    273273        $this->_adsHelper->getPostAndCat();
    274274        $this->_adsHelper->screenWidthInPx = intVal($_POST['width']);
     275        $this->_adsHelper->adblockDetected = intVal($_POST['adblockDetected']);
    275276        echo json_encode($this->_adsHelper->generatePositionContentByPositionId($_POST['id']));
    276277        $this->_adsHelper->screenWidth = false;
  • prime-ads/trunk/readme.txt

    r1853454 r1854131  
    77Requires at least: 4.0
    88Tested up to: 4.7
    9 Stable tag: 2.2.0
     9Stable tag: 2.2.1
    1010
    1111Ответная часть сервиса монитизации Prime Ads (http://primeads.ru)
Note: See TracChangeset for help on using the changeset viewer.