Plugin Directory

Changeset 2760563


Ignore:
Timestamp:
07/23/2022 10:29:31 AM (4 years ago)
Author:
delabon
Message:

tagging version 3.4.1

Location:
woomotiv
Files:
2 deleted
8 edited
14 copied

Legend:

Unmodified
Added
Removed
  • woomotiv/trunk/index.php

    r2744861 r2760563  
    44 * Plugin Name: Woomotiv - Live Sales Notification for Woocommerce
    55 * Description: Laverage social proof to increase trust, traffic and sales.
    6  * Version: 3.4.0
     6 * Version: 3.4.1
    77 * Author: Sabri Taieb
    88 * Author Uri: https://delabon.com
     
    1111 *
    1212 * WC requires at least: 3.0
    13  * WC tested up to: 6.6.0
     13 * WC tested up to: 6.6.1
    1414 *
    1515**/
     
    1818
    1919# Defined
    20 define( 'WOOMOTIV_VERSION', '3.4.0' );
     20define( 'WOOMOTIV_VERSION', '3.4.1' );
    2121define( 'WOOMOTIV_URL', plugins_url( '', __FILE__ ) );
    2222define( 'WOOMOTIV_DIR', __DIR__ );
     
    6464
    6565    /**
     66     * @var String
     67     */
     68    private static $_site_hash;
     69
     70    /**
    6671     * Return instance
    6772     */
     
    8388        require_once __DIR__ . '/lib/hooks.php';
    8489        $defaultConfig = require_once __DIR__ . '/lib/config.php';
    85 
     90   
    8691        $this->config = new WooMotiv\Framework\Config( $defaultConfig );
    8792        $this->request = new WooMotiv\Framework\Request();
     
    9095    }
    9196
     97    /**
     98     * Get site hash
     99     *
     100     * @return void
     101     */
     102    function get_site_hash(){
     103
     104        if (!self::$_site_hash){
     105            self::$_site_hash = md5(get_home_url());
     106        }
     107
     108        return self::$_site_hash;
     109    }
    92110}
    93111
  • woomotiv/trunk/js/front.js

    r2639624 r2760563  
    77    var nonce = woomotivObj.nonce;
    88    var ajax_url = woomotivObj.ajax_url;
    9     var currentIndex = 0;
     9    var currentIndex = 0;
     10    var cookieDays = 365;
    1011    var noMoreItems = false;
    1112    var $items = [];
     
    2728    var excludedCustomPopKey = 'woomotiv_seen_custompop_' + woomotivObj.site_hash;
    2829
     30    function getCookie(name){
     31        var value = `; ${document.cookie}`;
     32        var parts = value.split(`; ${name}=`);
     33       
     34        if (parts.length === 2) return parts.pop().split(';').shift();
     35    }
     36
     37    function setCookie(name, value, days){
     38       
     39        var expires = "";
     40
     41        if (days) {
     42            var date = new Date();
     43            date.setTime(date.getTime() + (days*24*60*60*1000));
     44            expires = "; expires=" + date.toUTCString();
     45        }
     46
     47        document.cookie = name + "=" + (value || "")  + expires + "; path=/";
     48    }
     49
     50    function deleteCookie(name) {
     51        document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
     52    }
     53
     54    window.deleteCookie = deleteCookie;
     55
    2956    function whichTransitionEndEvent(){
    3057        var t;
     
    199226                        // Fetch new items if possible
    200227                        if( cindex === $items.length && ! noMoreItems ){
    201                            
    202                             if( isNoRepeatEnabled ){
    203                                 excluded.products = getExcludedProductsFromStorage();
    204                                 excluded.reviews = getExcludedReviewsFromStorage();
    205                                 excluded.custom = getExcludedCustomPopsFromStorage();
    206                             }
    207 
    208                             getItems(excluded);
     228                            getItems();
    209229                        }
    210230                        // Reset current index
    211231                        else if( cindex === $items.length && noMoreItems ){
    212 
    213                             // Clear excluded items
    214                             if( isNoRepeatEnabled ){
    215                                
    216                                 clearLocalStorage();
    217                                 excluded.products = [];
    218                                 excluded.reviews = [];
    219                                 excluded.custom = [];
    220 
    221                                 // Do not show any items, leave for the next reload
    222                             }
    223                             else{
    224                                 // First one
     232                            if( !isNoRepeatEnabled ){
    225233                                start( 1 );
    226234                            }
     
    244252    function addExcludedProduct( orderItemId ){
    245253
    246         // No dulication
    247         excluded.products = excluded.products.filter(function( item ){
    248             if( item == orderItemId ) return false;
    249 
    250             return true;
    251         });
    252        
    253         excluded.products.push(orderItemId);
    254 
    255         if( ! isNoRepeatEnabled ) return;
    256 
    257254        var products = getExcludedProductsFromStorage();
    258255        var isFound = false;
     
    264261        if( ! isFound ){
    265262            products.push(orderItemId);
    266             localStorage.setItem( excludedProductsKey, products.join(',') );
     263            setCookie(excludedProductsKey, products.join(','), cookieDays);
    267264        }
    268265    }
     
    272269     * @param {*} reviewId
    273270     */
    274      function addExcludedReview( reviewId ){
    275        
    276         // No dulication
    277         excluded.reviews = excluded.reviews.filter(function( item ){
    278             if( item == reviewId ) return false;
    279 
    280             return true;
    281         });
    282 
    283         excluded.reviews.push(reviewId);
    284 
    285         if( ! isNoRepeatEnabled ) return;
    286 
     271    function addExcludedReview( reviewId ){
     272       
    287273        var reviews = getExcludedReviewsFromStorage();
    288274        var isFound = false;
     
    294280        if( ! isFound ){
    295281            reviews.push(reviewId);
    296             localStorage.setItem( excludedReviewsKey, reviews.join(',') );
     282            setCookie(excludedReviewsKey, reviews.join(','), cookieDays);
    297283        }
    298284    }
     
    302288     * @param {*} reviewId
    303289     */
    304      function addExcludedCustomPop( id ){
    305        
    306         // No dulication
    307         excluded.custom = excluded.custom.filter(function( item ){
    308             if( item == id ) return false;
    309 
    310             return true;
    311         });
    312 
    313         excluded.custom.push( id );
    314 
    315         if( ! isNoRepeatEnabled ) return;
     290    function addExcludedCustomPop( id ){
    316291
    317292        var customPops = getExcludedCustomPopsFromStorage();
     
    324299        if( ! isFound ){
    325300            customPops.push(id);
    326             localStorage.setItem( excludedCustomPopKey, customPops.join(',') );
     301            setCookie(excludedCustomPopKey, customPops.join(','), cookieDays);
    327302        }
    328303    }
     
    335310    function getExcludedProductsFromStorage(){
    336311
    337         var products = localStorage.getItem( excludedProductsKey );
     312        var products = getCookie(excludedProductsKey);
    338313        products = ! products ? [] : products.split(',');
    339314
     
    353328    function getExcludedReviewsFromStorage(){
    354329
    355         var reviews = localStorage.getItem( excludedReviewsKey );
     330        var reviews = getCookie(excludedReviewsKey);
    356331        reviews = ! reviews ? [] : reviews.split(',');
    357332
     
    369344     * @returns {array}
    370345     */
    371      function getExcludedCustomPopsFromStorage(){
    372 
    373         var customPops = localStorage.getItem( excludedCustomPopKey );
     346    function getExcludedCustomPopsFromStorage(){
     347
     348        var customPops = getCookie(excludedCustomPopKey);
    374349        customPops = ! customPops ? [] : customPops.split(',');
    375350
     
    385360     * Clear localStorage
    386361     */
    387     function clearLocalStorage(){
    388         localStorage.removeItem( excludedProductsKey );
    389         localStorage.removeItem( excludedReviewsKey );
    390         localStorage.removeItem( excludedCustomPopKey );
     362    function clearCookies(){
     363        deleteCookie(excludedProductsKey);
     364        deleteCookie(excludedReviewsKey);
     365        deleteCookie(excludedCustomPopKey);
    391366    }
    392367
     
    394369     * Get items using ajax
    395370     */
    396     function getItems( excluded ){
     371    function getItems(){
    397372       
    398373        // Get items and create html nodes
    399         ajax( 'get_items', {
    400             excluded: excluded,
    401         }).done( function( response ){
     374        ajax('get_items', {}).done( function(response){
    402375
    403376            if( ! response.hasOwnProperty( 'data' ) ) return;
    404377            if( response.data === '' ) return;
    405             if( response.data.length === 0 && $items.length === 0 ) return;
     378            if( response.data.length === 0 && isNoRepeatEnabled) return;
    406379
    407380            // No more popups, let's show the first 1
     
    452425
    453426                    }, ( hideTime + hideTime ) );
    454 
    455427                });
    456428
     
    458430                    event.preventDefault();
    459431                    $('.woomotiv-popup').remove();
    460                     localStorage.setItem('woomotiv_pause_date_' + woomotivObj.site_hash , dateAdd( new Date(), 'minute', 10 ) );
     432                    setCookie('woomotiv_pause_date_' + woomotivObj.site_hash, dateAdd( new Date(), 'minute', 10 ), cookieDays);
    461433                });
    462434
     
    505477    }
    506478
    507     // No-repeat is disabled, lets clear the local storage
    508     if( ! isNoRepeatEnabled ){
    509         clearLocalStorage();
    510     }
    511     // No-repeat is enabled, let's get the excluded one from the local storage
    512     else{
    513         excluded.products = getExcludedProductsFromStorage();
    514         excluded.reviews = getExcludedReviewsFromStorage();
    515         excluded.custom = getExcludedCustomPopsFromStorage();
     479    // No-repeat is disabled, lets clear cookies
     480    if (!isNoRepeatEnabled){
     481        clearCookies();
    516482    }
    517483
    518484    // Show time
    519     if( localStorage.getItem('woomotiv_pause_date_' + woomotivObj.site_hash ) ){
    520         var pause_date = new Date( localStorage.getItem('woomotiv_pause_date_' + woomotivObj.site_hash ) );
    521 
    522         if( pause_date > new Date() ){
     485    if (getCookie('woomotiv_pause_date_' + woomotivObj.site_hash)){
     486        var pause_date = new Date(getCookie('woomotiv_pause_date_' + woomotivObj.site_hash));
     487
     488        if (pause_date > new Date()){
    523489            return;
    524490        }
    525         else{
    526             getItems(excluded);
    527         }
    528     }
    529     else{
    530         getItems(excluded);
     491        else {
     492            getItems();
     493        }
     494    }
     495    else {
     496        getItems();
    531497    }
    532498
  • woomotiv/trunk/js/front.min.js

    r2639624 r2760563  
    1 !function(i){var a,e=i("body"),o=woomotivObj.nonce,n=woomotivObj.ajax_url,r=0,c=!1,d=[],l=!1,f=!1,p=1e3*parseInt(woomotivObj.interval),w=1e3*parseInt(woomotivObj.hide),s=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,u=window.cancelAnimationFrame||window.mozCancelAnimationFrame,v={products:[],reviews:[],custom:[]},h=parseInt(woomotivObj.is_no_repeat_enabled),b="woomotiv_seen_products_"+woomotivObj.site_hash,g="woomotiv_seen_reviews_"+woomotivObj.site_hash,_="woomotiv_seen_custompop_"+woomotivObj.site_hash,t=function(){var t,e=document.createElement("fakeelement"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in o)if(void 0!==e.style[t])return o[t]}(),m=function(){var t,e=document.createElement("fakeelement"),o={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in o)if(void 0!==e.style[t])return o[t]}(),k=(function(){var t,e=document.createElement("fakeelement"),o={transition:"transitionstart",OTransition:"oTransitionStart",MozTransition:"transitionstart",WebkitTransition:"webkitTransitionStart"};for(t in o)if(void 0!==e.style[t])return}(),function(){var t,e=document.createElement("fakeelement"),o={animation:"animationstart",OAnimation:"oAnimationStart",MozAnimation:"animationstart",WebkitAnimation:"webkitAnimationStart"};for(t in o)if(void 0!==e.style[t])return}(),["fade","slideup","slidedown","slideright","slideleft"]),T=(k.indexOf(woomotivObj.animation),-1!=k.indexOf(woomotivObj.animation)?t:m);function O(t,e){return(e="object"==typeof e?e:{}).action="woomotiv_"+t,e.hasOwnProperty("nonce")||(e.nonce=o),i.ajax({type:"POST",url:n,data:e})}function I(u){u=parseInt(u);var m=d[(r=u)-1];m.addClass("wmt-current"),m.one(T,function(){var e,o,n,t,i,a,r,s;m.is('[data-type="product"]')?(a=parseInt(m.attr("data-orderitemid")),v.products=v.products.filter(function(t){return t!=a}),v.products.push(a),h&&(r=j(),s=!1,r.map(function(t){t==a&&(s=!0)}),s||(r.push(a),localStorage.setItem(b,r.join(","))))):m.is('[data-type="review"]')?(n=parseInt(m.attr("data-review")),v.reviews=v.reviews.filter(function(t){return t!=n}),v.reviews.push(n),h&&(t=y(),i=!1,t.map(function(t){t==n&&(i=!0)}),i||(t.push(n),localStorage.setItem(g,t.join(","))))):m.is('[data-type="custom"]')&&(e=parseInt(m.attr("data-id")),v.custom=v.custom.filter(function(t){return t!=e}),v.custom.push(e),h&&(t=S(),o=!1,t.map(function(t){t==e&&(o=!0)}),o||(t.push(e),localStorage.setItem(_,t.join(","))))),f=setTimeout(function(){m.removeClass("wmt-current"),m.one(T,function(){l=setTimeout(function(){u!==d.length||c?u===d.length&&c?h?(A(),v.products=[],v.reviews=[],v.custom=[]):I(1):I(u+1):(h&&(v.products=j(),v.reviews=y(),v.custom=S()),D(v))},p)})},w)})}function j(){var t=localStorage.getItem(b);return(t=t?t.split(","):[]).filter(function(t){return""!==t})}function y(){var t=localStorage.getItem(g);return(t=t?t.split(","):[]).filter(function(t){return""!==t})}function S(){var t=localStorage.getItem(_);return(t=t?t.split(","):[]).filter(function(t){return""!==t})}function A(){localStorage.removeItem(b),localStorage.removeItem(g),localStorage.removeItem(_)}function D(t){O("get_items",{excluded:t}).done(function(t){if(t.hasOwnProperty("data")&&""!==t.data&&(0!==t.data.length||0!==d.length)){if(0===t.data.length)return c=!0,void I(1);t.data.map(function(t){t=i(t.markup);t.attr("data-index",d.length+1),e.append(t),d.push(t),t.on("mouseenter",function(t){i(this).off(T),clearTimeout(l),clearTimeout(f),u(a)}),t.on("mouseleave",function(t){var e=i(".woomotiv-popup.wmt-current"),o=parseInt(e.attr("data-index")),n=parseInt(w/2);void 0!==o&&(setTimeout(function(){e.removeClass("wmt-current")},n),setTimeout(function(){a=s(function(){I(o+1)})},w+w))}),t.find(".woomotiv-close").on("click",function(t){t.preventDefault(),i(".woomotiv-popup").remove(),localStorage.setItem("woomotiv_pause_date_"+woomotivObj.site_hash,function(t,e,o){function n(){i.getDate()!=t.getDate()&&i.setDate(0)}var i=new Date(t);switch(e.toLowerCase()){case"year":i.setFullYear(i.getFullYear()+o),n();break;case"quarter":i.setMonth(i.getMonth()+3*o),n();break;case"month":i.setMonth(i.getMonth()+o),n();break;case"week":i.setDate(i.getDate()+7*o);break;case"day":i.setDate(i.getDate()+o);break;case"hour":i.setTime(i.getTime()+36e5*o);break;case"minute":i.setTime(i.getTime()+6e4*o);break;case"second":i.setTime(i.getTime()+1e3*o);break;default:i=void 0}return i}(new Date,"minute",10))}),t.on("click",function(t){t.preventDefault();var e=i(this),t={};"product"===e.data("type")?(t.type="product",t.product_id=e.data("product")):"review"===e.data("type")?(t.type="review",t.product_id=e.data("product")):(t.type="custom",t.id=e.data("id")),O("update_stats",t).done(function(t){1!=woomotivObj.disable_link&&(location.href=e.find(".woomotiv-link").attr("href"))})})}),setTimeout(function(){a=s(function(){I(r+1)})},parseInt(p/2))}})}h?(v.products=j(),v.reviews=y(),v.custom=S()):A(),localStorage.getItem("woomotiv_pause_date_"+woomotivObj.site_hash)&&new Date(localStorage.getItem("woomotiv_pause_date_"+woomotivObj.site_hash))>new Date||D(v)}(jQuery);
     1!function($){var k,l=$("body"),m=woomotivObj.nonce,n=woomotivObj.ajax_url,o=0,p=!1,q=[],r=!1,s=!1,t=1e3*parseInt(woomotivObj.interval),u=1e3*parseInt(woomotivObj.hide),v=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,w=window.cancelAnimationFrame||window.mozCancelAnimationFrame,d=parseInt(woomotivObj.is_no_repeat_enabled),e="woomotiv_seen_products_"+woomotivObj.site_hash,f="woomotiv_seen_reviews_"+woomotivObj.site_hash,g="woomotiv_seen_custompop_"+woomotivObj.site_hash;function b(b){var a=`; ${document.cookie}`.split(`; ${b}=`);if(2===a.length)return a.pop().split(";").shift()}function x(d,e,b){var c="";if(b){var a=new Date;a.setTime(a.getTime()+864e5*b),c="; expires="+a.toUTCString()}document.cookie=d+"="+(e||"")+c+"; path=/"}function a(a){document.cookie=a+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"}window.deleteCookie=a;var h=function(){var a,c=document.createElement("fakeelement"),b={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in b)if(void 0!==c.style[a])return b[a]}(),i=function(){var a,c=document.createElement("fakeelement"),b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(a in b)if(void 0!==c.style[a])return b[a]}(),c=(function(){var a,c=document.createElement("fakeelement"),b={transition:"transitionstart",OTransition:"oTransitionStart",MozTransition:"transitionstart",WebkitTransition:"webkitTransitionStart"};for(a in b)if(void 0!==c.style[a])return b[a]}(),function(){var a,c=document.createElement("fakeelement"),b={animation:"animationstart",OAnimation:"oAnimationStart",MozAnimation:"animationstart",WebkitAnimation:"webkitAnimationStart"};for(a in b)if(void 0!==c.style[a])return b[a]}(),["fade","slideup","slidedown","slideright","slideleft"]);c.indexOf(woomotivObj.animation);var y=-1!=c.indexOf(woomotivObj.animation)?h:i;function z(b,a){return(a="object"==typeof a?a:{}).action="woomotiv_"+b,a.hasOwnProperty("nonce")||(a.nonce=m),$.ajax({type:"POST",url:n,data:a})}function A(a){o=a=parseInt(a);var b=q[a-1];b.addClass("wmt-current"),b.one(y,function(){b.is('[data-type="product"]')?B(parseInt(b.attr("data-orderitemid"))):b.is('[data-type="review"]')?C(parseInt(b.attr("data-review"))):b.is('[data-type="custom"]')&&D(parseInt(b.attr("data-id"))),s=setTimeout(function(){b.removeClass("wmt-current"),b.one(y,function(){r=setTimeout(function(){a!==q.length||p?a===q.length&&p?d||A(1):A(a+1):j()},t)})},u)})}function B(b){var a=E(),c=!1;a.map(function(a){a==b&&(c=!0)}),c||(a.push(b),x(e,a.join(","),365))}function C(b){var a=F(),c=!1;a.map(function(a){a==b&&(c=!0)}),c||(a.push(b),x(f,a.join(","),365))}function D(b){var a=G(),c=!1;a.map(function(a){a==b&&(c=!0)}),c||(a.push(b),x(g,a.join(","),365))}function E(){var a=b(e);return(a=a?a.split(","):[]).filter(function(a){return""!==a})}function F(){var a=b(f);return(a=a?a.split(","):[]).filter(function(a){return""!==a})}function G(){var a=b(g);return(a=a?a.split(","):[]).filter(function(a){return""!==a})}function j(){z("get_items",{}).done(function(a){if(a.hasOwnProperty("data")&&""!==a.data&&(0!==a.data.length||!d)){if(0===a.data.length){p=!0,A(1);return}a.data.map(function(b){var a=$(b.markup);a.attr("data-index",q.length+1),l.append(a),q.push(a),a.on("mouseenter",function(a){$(this).off(y),clearTimeout(r),clearTimeout(s),w(k)}),a.on("mouseleave",function(d){var a=$(".woomotiv-popup.wmt-current"),b=parseInt(a.attr("data-index")),c=parseInt(u/2);void 0!==b&&(setTimeout(function(){a.removeClass("wmt-current")},c),setTimeout(function(){k=v(function(){A(b+1)})},u+u))}),a.find(".woomotiv-close").on("click",function(a){a.preventDefault(),$(".woomotiv-popup").remove(),x("woomotiv_pause_date_"+woomotivObj.site_hash,function(d,e,b){var a=new Date(d),c=function(){a.getDate()!=d.getDate()&&a.setDate(0)};switch(e.toLowerCase()){case"year":a.setFullYear(a.getFullYear()+b),c();break;case"quarter":a.setMonth(a.getMonth()+3*b),c();break;case"month":a.setMonth(a.getMonth()+b),c();break;case"week":a.setDate(a.getDate()+7*b);break;case"day":a.setDate(a.getDate()+b);break;case"hour":a.setTime(a.getTime()+36e5*b);break;case"minute":a.setTime(a.getTime()+6e4*b);break;case"second":a.setTime(a.getTime()+1e3*b);break;default:a=void 0}return a}(new Date,"minute",10),365)}),a.on("click",function(c){c.preventDefault();var b=$(this),a={};"product"===b.data("type")?(a.type="product",a.product_id=b.data("product")):"review"===b.data("type")?(a.type="review",a.product_id=b.data("product")):(a.type="custom",a.id=b.data("id")),z("update_stats",a).done(function(a){1!=woomotivObj.disable_link&&(location.href=b.find(".woomotiv-link").attr("href"))})})}),setTimeout(function(){k=v(function(){A(o+1)})},parseInt(t/2))}})}d||(a(e),a(f),a(g)),b("woomotiv_pause_date_"+woomotivObj.site_hash)&&new Date(b("woomotiv_pause_date_"+woomotivObj.site_hash))>new Date||j()}(jQuery)
  • woomotiv/trunk/lib/class-backend.php

    r2639624 r2760563  
    8787            }
    8888           
     89            // Clear cookies
     90            clear_cookies();
    8991        }
    9092
  • woomotiv/trunk/lib/class-frontend.php

    r2639624 r2760563  
    152152
    153153        wp_localize_script( 'woomotiv', 'woomotivObj', array(
    154             'site_hash'     => md5( get_home_url() ),
     154            'site_hash'     => woomotiv()->get_site_hash(),
    155155            'nonce'         => wp_create_nonce('woomotiv'),
    156156            'ajax_url'      => admin_url( 'admin-ajax.php' ),
     
    168168            'is_no_repeat_enabled' => (int)woomotiv()->config->woomotiv_no_repeat_sales_reviews,
    169169        ));
    170 
    171170    }
    172171
     
    177176       
    178177        validateNounce();
    179 
    180         $excluded = isset( $_POST['excluded'] ) ? $_POST['excluded'] : [];
    181 
    182         if( ! array_key_exists( 'products', $excluded ) ){
    183             $excluded['products'] = [];
    184         }
    185 
    186         if( ! array_key_exists( 'reviews', $excluded ) ){
    187             $excluded['reviews'] = [];
    188         }
    189 
    190         if( ! array_key_exists( 'custom', $excluded ) ){
    191             $excluded['custom'] = [];
    192         }
    193178
    194179        $country_list = require WC()->plugin_path() . '/i18n/countries.php';
    195180        $date_now = date_now();
    196         $products = get_products( $excluded['products'] );
    197         $reviews = get_reviews( $excluded['reviews'] );
    198         $custom_popups = get_custom_popups( $excluded['custom'] );
     181        $products = get_products();
     182        $reviews = get_reviews();
     183        $custom_popups = get_custom_popups();
    199184        $notifications = array();
    200185        $counter = 1;
     
    204189            $max = count( $reviews );
    205190        }
    206         elseif( $max < count( $custom_popups )  ){
     191        elseif( $max < count( $custom_popups ) ){
    207192            $max = count( $custom_popups );
     193        }
     194
     195        // Clear cookies
     196        if (count($products) === 0 && count($reviews) === 0 && count($custom_popups) === 0){
     197            clear_cookies();
    208198        }
    209199
     
    231221        }
    232222
     223        // Render
    233224        $rendered = $this->render( array_slice( $notifications, 0, (int)woomotiv()->config->woomotiv_limit ) );
    234225
     226        // Response
    235227        response( true, $rendered );
    236228    }
  • woomotiv/trunk/lib/functions.php

    r2639624 r2760563  
    254254
    255255/**
     256 * Clear cookies
     257 *
     258 * @return void
     259 */
     260function clear_cookies(){
     261    $cookie_key = 'woomotiv_seen_products_' . woomotiv()->get_site_hash();
     262    unset($_COOKIE[$cookie_key]);
     263    setcookie($cookie_key, null, -1, '/');
     264
     265    $cookie_key = 'woomotiv_seen_reviews_' . woomotiv()->get_site_hash();
     266    unset($_COOKIE[$cookie_key]);
     267    setcookie($cookie_key, null, -1, '/');
     268
     269    $cookie_key = 'woomotiv_seen_custompop_' . woomotiv()->get_site_hash();
     270    unset($_COOKIE[$cookie_key]);
     271    setcookie($cookie_key, null, -1, '/');
     272}
     273
     274/**
     275 * Get see order items
     276 *
     277 * @return array
     278 */
     279function get_seen_order_items(){
     280    $cookie_key = 'woomotiv_seen_products_' . woomotiv()->get_site_hash();
     281    $excluded = isset($_COOKIE[$cookie_key]) ? $_COOKIE[$cookie_key] : '';
     282    $excluded = array_filter(explode(',', $excluded));
     283
     284    return $excluded;
     285}
     286
     287/**
     288 * Get seen reviews
     289 *
     290 * @return array
     291 */
     292function get_seen_reviews(){
     293    $cookie_key = 'woomotiv_seen_reviews_' . woomotiv()->get_site_hash();
     294    $excluded = isset($_COOKIE[$cookie_key]) ? $_COOKIE[$cookie_key] : '';
     295    $excluded = array_filter(explode(',', $excluded));
     296
     297    return $excluded;
     298}
     299
     300/**
     301 * Get seen custom popups
     302 *
     303 * @return array
     304 */
     305function get_seen_custom_popups(){
     306    $cookie_key = 'woomotiv_seen_custompop_' . woomotiv()->get_site_hash();
     307    $excluded = isset($_COOKIE[$cookie_key]) ? $_COOKIE[$cookie_key] : '';
     308    $excluded = array_filter(explode(',', $excluded));
     309
     310    return $excluded;
     311}
     312
     313/**
    256314 * Get orders
    257315 *
     
    259317 * @return array
    260318 */
    261 function get_products( $excluded_order_items = [] ){
     319function get_products(){
    262320
    263321    global $wpdb;
    264322
     323    $excluded_order_items = get_seen_order_items();
    265324    $is_outofstock_visible = woomotiv()->config->woomotiv_filter_out_of_stock == 1 ? true : false;
    266325    $is_random = woomotiv()->config->woomotiv_display_order === 'random_sales' ? true : false;
    267     $excluded_order_items = ! is_array($excluded_order_items) ? [] : $excluded_order_items;
    268326
    269327    if( woomotiv()->config->woomotiv_filter_products !== '' && woomotiv()->config->woomotiv_filter_products !== '0' ){
     
    397455 * @return array
    398456 */
    399 function get_reviews( $excluded_reviews = [] ){
    400 
    401     $excluded_reviews = ! is_array($excluded_reviews) ? [] : $excluded_reviews;
     457function get_reviews(){
     458
     459    global $wpdb;
     460
     461    $excluded_reviews = get_seen_reviews();
    402462    $is_random = woomotiv()->config->woomotiv_display_order === 'random_sales' ? true : false;
    403    
    404     global $wpdb;
    405463
    406464    $raw = "
     
    510568 * @return array
    511569 */
    512 function get_custom_popups( $excluded_popups ){
     570function get_custom_popups(){
    513571   
    514572    global $wpdb;
    515573
    516     $excluded_popups = ! is_array($excluded_popups) ? [] : $excluded_popups;
     574    $excluded_popups = get_seen_custom_popups();
    517575    $now = convert_timezone( new \DateTime() );
    518576    $today = convert_timezone( $now->format('F d, Y') );
  • woomotiv/trunk/lib/hooks.php

    r2513764 r2760563  
    11<?php
    2 
    3 /**
    4  * Admin notices process
    5  */
    6 
    7 use WooMotiv\Framework\Helper;
    82
    93/**
  • woomotiv/trunk/readme.txt

    r2744861 r2760563  
    33Requires at least: 4.6
    44Tested up to: 6.0.0
    5 Stable tag: 3.4.0
     5Stable tag: 3.4.1
    66Requires PHP: 5.6
    77Tags: woocommerce notification, woocommerce sales notification, woocommerce sales popup, marketing, boost sales, boost conversion
     
    9797== Changelog ==
    9898
     99= 3.4.1 =
     100
     101* Updated Woomotiv to use cookies instead of localstorage
     102* Woocommerce 6.6 support!
     103
    99104= 3.4.0 =
    100105
Note: See TracChangeset for help on using the changeset viewer.