Changeset 2760563
- Timestamp:
- 07/23/2022 10:29:31 AM (4 years ago)
- Location:
- woomotiv
- Files:
-
- 2 deleted
- 8 edited
- 14 copied
-
tags/3.4 (copied) (copied from woomotiv/trunk)
-
tags/3.4/freemius (deleted)
-
tags/3.4/freemius-init.php (deleted)
-
tags/3.4/index.php (copied) (copied from woomotiv/trunk/index.php)
-
tags/3.4/js/front.js (copied) (copied from woomotiv/trunk/js/front.js)
-
tags/3.4/js/front.min.js (copied) (copied from woomotiv/trunk/js/front.min.js)
-
tags/3.4/lib/class-backend.php (copied) (copied from woomotiv/trunk/lib/class-backend.php)
-
tags/3.4/lib/class-frontend.php (copied) (copied from woomotiv/trunk/lib/class-frontend.php)
-
tags/3.4/lib/functions.php (copied) (copied from woomotiv/trunk/lib/functions.php)
-
tags/3.4/readme.txt (copied) (copied from woomotiv/trunk/readme.txt)
-
tags/3.4/views/admin-settings.php (copied) (copied from woomotiv/trunk/views/admin-settings.php)
-
tags/3.4/views/tabs/content-template.php (copied) (copied from woomotiv/trunk/views/tabs/content-template.php)
-
tags/3.4/views/tabs/custom-popups.php (copied) (copied from woomotiv/trunk/views/tabs/custom-popups.php)
-
tags/3.4/views/tabs/general.php (copied) (copied from woomotiv/trunk/views/tabs/general.php)
-
tags/3.4/views/tabs/report.php (copied) (copied from woomotiv/trunk/views/tabs/report.php)
-
tags/3.4/views/tabs/style.php (copied) (copied from woomotiv/trunk/views/tabs/style.php)
-
trunk/index.php (modified) (6 diffs)
-
trunk/js/front.js (modified) (17 diffs)
-
trunk/js/front.min.js (modified) (1 diff)
-
trunk/lib/class-backend.php (modified) (1 diff)
-
trunk/lib/class-frontend.php (modified) (5 diffs)
-
trunk/lib/functions.php (modified) (4 diffs)
-
trunk/lib/hooks.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woomotiv/trunk/index.php
r2744861 r2760563 4 4 * Plugin Name: Woomotiv - Live Sales Notification for Woocommerce 5 5 * Description: Laverage social proof to increase trust, traffic and sales. 6 * Version: 3.4. 06 * Version: 3.4.1 7 7 * Author: Sabri Taieb 8 8 * Author Uri: https://delabon.com … … 11 11 * 12 12 * WC requires at least: 3.0 13 * WC tested up to: 6.6. 013 * WC tested up to: 6.6.1 14 14 * 15 15 **/ … … 18 18 19 19 # Defined 20 define( 'WOOMOTIV_VERSION', '3.4. 0' );20 define( 'WOOMOTIV_VERSION', '3.4.1' ); 21 21 define( 'WOOMOTIV_URL', plugins_url( '', __FILE__ ) ); 22 22 define( 'WOOMOTIV_DIR', __DIR__ ); … … 64 64 65 65 /** 66 * @var String 67 */ 68 private static $_site_hash; 69 70 /** 66 71 * Return instance 67 72 */ … … 83 88 require_once __DIR__ . '/lib/hooks.php'; 84 89 $defaultConfig = require_once __DIR__ . '/lib/config.php'; 85 90 86 91 $this->config = new WooMotiv\Framework\Config( $defaultConfig ); 87 92 $this->request = new WooMotiv\Framework\Request(); … … 90 95 } 91 96 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 } 92 110 } 93 111 -
woomotiv/trunk/js/front.js
r2639624 r2760563 7 7 var nonce = woomotivObj.nonce; 8 8 var ajax_url = woomotivObj.ajax_url; 9 var currentIndex = 0; 9 var currentIndex = 0; 10 var cookieDays = 365; 10 11 var noMoreItems = false; 11 12 var $items = []; … … 27 28 var excludedCustomPopKey = 'woomotiv_seen_custompop_' + woomotivObj.site_hash; 28 29 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 29 56 function whichTransitionEndEvent(){ 30 57 var t; … … 199 226 // Fetch new items if possible 200 227 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(); 209 229 } 210 230 // Reset current index 211 231 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 ){ 225 233 start( 1 ); 226 234 } … … 244 252 function addExcludedProduct( orderItemId ){ 245 253 246 // No dulication247 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 257 254 var products = getExcludedProductsFromStorage(); 258 255 var isFound = false; … … 264 261 if( ! isFound ){ 265 262 products.push(orderItemId); 266 localStorage.setItem( excludedProductsKey, products.join(','));263 setCookie(excludedProductsKey, products.join(','), cookieDays); 267 264 } 268 265 } … … 272 269 * @param {*} reviewId 273 270 */ 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 287 273 var reviews = getExcludedReviewsFromStorage(); 288 274 var isFound = false; … … 294 280 if( ! isFound ){ 295 281 reviews.push(reviewId); 296 localStorage.setItem( excludedReviewsKey, reviews.join(','));282 setCookie(excludedReviewsKey, reviews.join(','), cookieDays); 297 283 } 298 284 } … … 302 288 * @param {*} reviewId 303 289 */ 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 ){ 316 291 317 292 var customPops = getExcludedCustomPopsFromStorage(); … … 324 299 if( ! isFound ){ 325 300 customPops.push(id); 326 localStorage.setItem( excludedCustomPopKey, customPops.join(','));301 setCookie(excludedCustomPopKey, customPops.join(','), cookieDays); 327 302 } 328 303 } … … 335 310 function getExcludedProductsFromStorage(){ 336 311 337 var products = localStorage.getItem( excludedProductsKey);312 var products = getCookie(excludedProductsKey); 338 313 products = ! products ? [] : products.split(','); 339 314 … … 353 328 function getExcludedReviewsFromStorage(){ 354 329 355 var reviews = localStorage.getItem( excludedReviewsKey);330 var reviews = getCookie(excludedReviewsKey); 356 331 reviews = ! reviews ? [] : reviews.split(','); 357 332 … … 369 344 * @returns {array} 370 345 */ 371 function getExcludedCustomPopsFromStorage(){372 373 var customPops = localStorage.getItem( excludedCustomPopKey);346 function getExcludedCustomPopsFromStorage(){ 347 348 var customPops = getCookie(excludedCustomPopKey); 374 349 customPops = ! customPops ? [] : customPops.split(','); 375 350 … … 385 360 * Clear localStorage 386 361 */ 387 function clear LocalStorage(){388 localStorage.removeItem( excludedProductsKey);389 localStorage.removeItem( excludedReviewsKey);390 localStorage.removeItem( excludedCustomPopKey);362 function clearCookies(){ 363 deleteCookie(excludedProductsKey); 364 deleteCookie(excludedReviewsKey); 365 deleteCookie(excludedCustomPopKey); 391 366 } 392 367 … … 394 369 * Get items using ajax 395 370 */ 396 function getItems( excluded){371 function getItems(){ 397 372 398 373 // Get items and create html nodes 399 ajax( 'get_items', { 400 excluded: excluded, 401 }).done( function( response ){ 374 ajax('get_items', {}).done( function(response){ 402 375 403 376 if( ! response.hasOwnProperty( 'data' ) ) return; 404 377 if( response.data === '' ) return; 405 if( response.data.length === 0 && $items.length === 0) return;378 if( response.data.length === 0 && isNoRepeatEnabled) return; 406 379 407 380 // No more popups, let's show the first 1 … … 452 425 453 426 }, ( hideTime + hideTime ) ); 454 455 427 }); 456 428 … … 458 430 event.preventDefault(); 459 431 $('.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); 461 433 }); 462 434 … … 505 477 } 506 478 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(); 516 482 } 517 483 518 484 // 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()){ 523 489 return; 524 490 } 525 else {526 getItems( excluded);527 } 528 } 529 else {530 getItems( excluded);491 else { 492 getItems(); 493 } 494 } 495 else { 496 getItems(); 531 497 } 532 498 -
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 87 87 } 88 88 89 // Clear cookies 90 clear_cookies(); 89 91 } 90 92 -
woomotiv/trunk/lib/class-frontend.php
r2639624 r2760563 152 152 153 153 wp_localize_script( 'woomotiv', 'woomotivObj', array( 154 'site_hash' => md5( get_home_url()),154 'site_hash' => woomotiv()->get_site_hash(), 155 155 'nonce' => wp_create_nonce('woomotiv'), 156 156 'ajax_url' => admin_url( 'admin-ajax.php' ), … … 168 168 'is_no_repeat_enabled' => (int)woomotiv()->config->woomotiv_no_repeat_sales_reviews, 169 169 )); 170 171 170 } 172 171 … … 177 176 178 177 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 }193 178 194 179 $country_list = require WC()->plugin_path() . '/i18n/countries.php'; 195 180 $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(); 199 184 $notifications = array(); 200 185 $counter = 1; … … 204 189 $max = count( $reviews ); 205 190 } 206 elseif( $max < count( $custom_popups ) ){191 elseif( $max < count( $custom_popups ) ){ 207 192 $max = count( $custom_popups ); 193 } 194 195 // Clear cookies 196 if (count($products) === 0 && count($reviews) === 0 && count($custom_popups) === 0){ 197 clear_cookies(); 208 198 } 209 199 … … 231 221 } 232 222 223 // Render 233 224 $rendered = $this->render( array_slice( $notifications, 0, (int)woomotiv()->config->woomotiv_limit ) ); 234 225 226 // Response 235 227 response( true, $rendered ); 236 228 } -
woomotiv/trunk/lib/functions.php
r2639624 r2760563 254 254 255 255 /** 256 * Clear cookies 257 * 258 * @return void 259 */ 260 function 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 */ 279 function 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 */ 292 function 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 */ 305 function 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 /** 256 314 * Get orders 257 315 * … … 259 317 * @return array 260 318 */ 261 function get_products( $excluded_order_items = []){319 function get_products(){ 262 320 263 321 global $wpdb; 264 322 323 $excluded_order_items = get_seen_order_items(); 265 324 $is_outofstock_visible = woomotiv()->config->woomotiv_filter_out_of_stock == 1 ? true : false; 266 325 $is_random = woomotiv()->config->woomotiv_display_order === 'random_sales' ? true : false; 267 $excluded_order_items = ! is_array($excluded_order_items) ? [] : $excluded_order_items;268 326 269 327 if( woomotiv()->config->woomotiv_filter_products !== '' && woomotiv()->config->woomotiv_filter_products !== '0' ){ … … 397 455 * @return array 398 456 */ 399 function get_reviews( $excluded_reviews = [] ){ 400 401 $excluded_reviews = ! is_array($excluded_reviews) ? [] : $excluded_reviews; 457 function get_reviews(){ 458 459 global $wpdb; 460 461 $excluded_reviews = get_seen_reviews(); 402 462 $is_random = woomotiv()->config->woomotiv_display_order === 'random_sales' ? true : false; 403 404 global $wpdb;405 463 406 464 $raw = " … … 510 568 * @return array 511 569 */ 512 function get_custom_popups( $excluded_popups){570 function get_custom_popups(){ 513 571 514 572 global $wpdb; 515 573 516 $excluded_popups = ! is_array($excluded_popups) ? [] : $excluded_popups;574 $excluded_popups = get_seen_custom_popups(); 517 575 $now = convert_timezone( new \DateTime() ); 518 576 $today = convert_timezone( $now->format('F d, Y') ); -
woomotiv/trunk/lib/hooks.php
r2513764 r2760563 1 1 <?php 2 3 /**4 * Admin notices process5 */6 7 use WooMotiv\Framework\Helper;8 2 9 3 /** -
woomotiv/trunk/readme.txt
r2744861 r2760563 3 3 Requires at least: 4.6 4 4 Tested up to: 6.0.0 5 Stable tag: 3.4. 05 Stable tag: 3.4.1 6 6 Requires PHP: 5.6 7 7 Tags: woocommerce notification, woocommerce sales notification, woocommerce sales popup, marketing, boost sales, boost conversion … … 97 97 == Changelog == 98 98 99 = 3.4.1 = 100 101 * Updated Woomotiv to use cookies instead of localstorage 102 * Woocommerce 6.6 support! 103 99 104 = 3.4.0 = 100 105
Note: See TracChangeset
for help on using the changeset viewer.