Changeset 3122355
- Timestamp:
- 07/20/2024 05:13:13 AM (20 months ago)
- Location:
- wcboost-wishlist/trunk
- Files:
-
- 1 added
- 10 edited
-
assets/css/wishlist.css (modified) (1 diff)
-
assets/css/wishlist.scss (added)
-
assets/js/wishlist-fragments.js (modified) (6 diffs)
-
assets/js/wishlist-fragments.min.js (modified) (1 diff)
-
includes/ajax-handler.php (modified) (3 diffs)
-
includes/data-stores/wishlist.php (modified) (7 diffs)
-
includes/frontend.php (modified) (2 diffs)
-
includes/wishlist.php (modified) (3 diffs)
-
languages/wcboost-wishlist.pot (modified) (7 diffs)
-
readme.txt (modified) (3 diffs)
-
wcboost-wishlist.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wcboost-wishlist/trunk/assets/css/wishlist.css
r2866245 r3122355 1 /** Wishlist Page **/ 2 .wcboost-wishlist-header { 3 margin-bottom: 2em; 4 } 5 6 .wcboost-wishlist-title { 7 font-size: 1.5em; 8 } 9 10 .wcboost-wishlist__item .product-thumbnail img { 11 max-width: 5em; 12 height: auto; 13 } 14 15 .wcboost-wishlist__item .product-remove { 16 vertical-align: middle; 17 } 18 19 .wcboost-wishlist__item .product-add-to-cart { 20 text-align: right; 21 } 22 23 .wishlist-share__buttons { 24 list-style: none; 25 margin: 0; 26 padding: 0; 27 } 28 29 .wishlist-share__buttons li { 30 display: inline-block; 31 margin: 0 0.14em 0.3em 0; 32 } 33 34 .wishlist-share__buttons a { 35 color: inherit; 36 text-decoration: none; 37 display: inline-block; 38 padding: 0.6180469716em; 39 background-color: var(--wcboost-wishlist-color--button-background, #eee); 40 } 41 42 .entry-content .wishlist-share__buttons li a { 43 text-decoration: none; 44 } 45 46 .wishlist-share__buttons svg { 47 width: 1em; 48 height: auto; 49 margin-right: 0.25em; 50 vertical-align: -0.125em; 51 } 52 53 .wcboost-wishlist-actions { 54 text-align: right; 55 } 56 57 .wcboost-wishlist-edit-link-wrapper { 58 margin: 1.5em 0; 59 } 60 61 /** Wishlist Button **/ 62 .wcboost-wishlist-button__icon { 63 margin-right: 0.4em; 64 } 65 66 .wcboost-wishlist-button__icon img, 67 .wcboost-wishlist-button__icon svg { 68 vertical-align: -0.125em; 69 width: 1em; 70 height: auto; 71 } 72 73 .wcboost-wishlist-button__icon svg { 74 fill: currentColor; 75 } 76 77 .wcboost-wishlist-button__icon img { 78 display: inline; 79 } 80 81 .wcboost-wishlist-button.disabled { 82 opacity: 0.75; 83 } 84 85 .wcboost-wishlist-button--text { 86 display: inline-block; 87 margin: 0.5em; 88 } 89 90 .wcboost-wishlist-button.loading .wcboost-wishlist-button__icon svg { 91 animation: wcboost-spin .75s linear infinite; 92 } 93 94 @-webkit-keyframes wcboost-spin { 95 0% { -webkit-transform: rotate(0deg); } 96 100% { -webkit-transform: rotate(360deg); } 97 } 98 99 @keyframes wcboost-spin { 100 0% { transform: rotate(0deg); } 101 100% { transform: rotate(360deg); } 102 } 103 104 .woocommerce .wcboost-wishlist-button--custom { 105 color: var(--wcboost-wishlist-button-color--text, #fff); 106 border: 1px solid; 107 border-color: var(--wcboost-wishlist-button-color--border, #333); 108 background-color: var(--wcboost-wishlist-button-color--background, #333); 109 transition: 0.1s ease-in; 110 } 111 112 .woocommerce .wcboost-wishlist-button--custom:hover { 113 color: var(--wcboost-wishlist-button-hover-color--text, #fff); 114 border-color: var(--wcboost-wishlist-button-hover-color--border, #111); 115 background-color: var(--wcboost-wishlist-button-hover-color--background, #111); 116 } 117 118 /** Sharing notices **/ 119 .wcboost-wishlist-share-notice { 120 color: #fff; 121 display: none; 122 position: fixed; 123 bottom: 20px; 124 left: 50%; 125 transform: translateX(-50%); 126 padding: 10px 40px 10px 10px; 127 background-color: rgba(0, 0, 0, 0.7); 128 max-width: 100%; 129 } 130 131 .wcboost-wishlist-share-notice input[type="text"] { 132 width: 300px; 133 max-width: 100%; 134 padding: 5px; 135 } 136 137 .wcboost-wishlist-share-notice__close { 138 font-size: 0; 139 position: absolute; 140 right: 10px; 141 top: 50%; 142 transform: translateY(-50%); 143 cursor: pointer; 144 } 145 146 .wcboost-wishlist-share-notice__close::before { 147 content: "\00d7"; 148 display: inline-block; 149 color: #fff; 150 font-size: 20px; 151 padding: 5px; 152 } 153 154 /** Wishlist Form Edit **/ 155 .wcboost-wishlist-form-edit .form-row--wishlist-privacy .woocommerce-input-wrapper { 156 display: block; 157 } 158 159 .wcboost-wishlist-form-edit .form-row--wishlist-privacy .woocommerce-input-wrapper label { 160 display: inline; 161 margin-left: 6px; 162 } 163 164 .wcboost-wishlist-form-edit .form-row--wishlist-privacy .woocommerce-input-wrapper label::after { 165 content: ""; 166 display: block; 167 white-space: pre; 168 } 169 170 /** Wishlist Form Delete **/ 171 .wcboost-wishlist-form-delete { 172 padding: 1rem 1.5rem; 173 margin-top: 3em; 174 background-color: var(--wcboost-wishlist-color--delete-bg, #fcf1ef); 175 border-left: 3px solid var(--wcboost-wishlist-color--delete, #c91c00); 176 } 177 178 .wcboost-wishlist-form-delete button { 179 color: #fff; 180 background-color: var(--wcboost-wishlist-color--delete, #c91c00); 181 } 182 183 /** Fixes for Storefront **/ 184 ul.products li.product .wcboost-wishlist-button img { 185 display: inline; 186 margin: 0; 187 } 188 189 /** Fixes for Twenty Twenty Two **/ 190 .theme-twentytwentytwo .wishlist_table th, 191 .theme-twentytwentytwo .wishlist_table td { 192 padding: 1rem 0 .5rem 1rem; 193 } 194 195 .theme-twentytwentytwo .wcboost-wishlist-button { 196 line-height: normal; 197 } 198 199 .theme-twentytwentytwo .wcboost-wishlist-button--text { 200 margin: 1rem; 201 } 202 203 /** Wishlist widget **/ 204 .wcboost-wishlist-widget-item { 205 position: relative; 206 margin: 1em 0; 207 } 208 209 .wcboost-wishlist-widget-item::after { 210 content: ""; 211 display: block; 212 clear: both; 213 } 214 215 .wcboost-wishlist-widget-item img { 216 max-width: 60px; 217 margin-right: 1em; 218 float: left; 219 } 220 221 .wcboost-wishlist-widget-item__price, 222 .wcboost-wishlist-widget-item__quantity, 223 .wcboost-wishlist-widget-item__stock, 224 .wcboost-wishlist-widget-item__date, 225 .wcboost-wishlist-widget-item__add-to-cart { 226 display: block; 227 } 228 229 .wcboost-wishlist-widget-item a.remove { 230 line-height: 1; 231 text-decoration: none; 232 position: absolute; 233 left: 0; 234 top: 0; 235 min-width: 1em; 236 min-height: 1em; 237 border-radius: 50%; 238 transform: translate(-50%, -50%); 239 } 1 .wcboost-wishlist-header{margin-bottom:2em}.wcboost-wishlist-title{font-size:1.5em}.wcboost-wishlist__item .product-thumbnail img{max-width:5em;height:auto}.wcboost-wishlist__item .product-remove{vertical-align:middle}.wcboost-wishlist__item .product-add-to-cart{text-align:right}.wishlist-share__buttons{list-style:none;margin:0;padding:0}.wishlist-share__buttons li{display:inline-block;margin:0 .14em .3em 0}.wishlist-share__buttons a{color:inherit;text-decoration:none;display:inline-block;padding:0.6180469716em;background-color:var(--wcboost-wishlist-color--button-background, #eee)}.wishlist-share__buttons svg{width:1em;height:auto;margin-right:.25em;vertical-align:-0.125em}.entry-content .wishlist-share__buttons li a{text-decoration:none}.wcboost-wishlist-actions{text-align:right}.wcboost-wishlist-edit-link-wrapper{margin:1.5em 0}.wcboost-wishlist-button__icon{margin-right:.4em}.wcboost-wishlist-button__icon img,.wcboost-wishlist-button__icon svg{vertical-align:-0.125em;width:1em;height:auto}.wcboost-wishlist-button__icon svg{fill:currentColor}.wcboost-wishlist-button__icon img{display:inline}.wcboost-wishlist-button.disabled{opacity:.75}.wcboost-wishlist-button--text{display:inline-block;margin:.5em}.wcboost-wishlist-button.loading .wcboost-wishlist-button__icon svg{animation:wcboost-spin .75s linear infinite}@-webkit-keyframes wcboost-spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes wcboost-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.woocommerce .wcboost-wishlist-button--custom{color:var(--wcboost-wishlist-button-color--text, #fff);border:1px solid;border-color:var(--wcboost-wishlist-button-color--border, #333);background-color:var(--wcboost-wishlist-button-color--background, #333);transition:.1s ease-in}.woocommerce .wcboost-wishlist-button--custom:hover{color:var(--wcboost-wishlist-button-hover-color--text, #fff);border-color:var(--wcboost-wishlist-button-hover-color--border, #111);background-color:var(--wcboost-wishlist-button-hover-color--background, #111)}.wcboost-wishlist-share-notice{color:#fff;display:none;position:fixed;bottom:20px;left:50%;transform:translateX(-50%);padding:10px 40px 10px 10px;background-color:rgba(0,0,0,.7);max-width:100%}.wcboost-wishlist-share-notice input[type=text]{width:300px;max-width:100%;padding:5px}.wcboost-wishlist-share-notice__close{font-size:0;position:absolute;right:10px;top:50%;transform:translateY(-50%);cursor:pointer}.wcboost-wishlist-share-notice__close::before{content:"×";display:inline-block;color:#fff;font-size:20px;padding:5px}.wcboost-wishlist-form-edit .form-row--wishlist-privacy .woocommerce-input-wrapper{display:block}.wcboost-wishlist-form-edit .form-row--wishlist-privacy .woocommerce-input-wrapper label{display:inline;margin-left:6px}.wcboost-wishlist-form-edit .form-row--wishlist-privacy .woocommerce-input-wrapper label::after{content:"";display:block;white-space:pre}.wcboost-wishlist-form-delete{padding:1rem 1.5rem;margin-top:3em;background-color:var(--wcboost-wishlist-color--delete-bg, #fcf1ef);border-left:3px solid var(--wcboost-wishlist-color--delete, #c91c00)}.wcboost-wishlist-form-delete button{color:#fff;background-color:var(--wcboost-wishlist-color--delete, #c91c00)}ul.products li.product .wcboost-wishlist-button img{display:inline;margin:0}.theme-twentytwentytwo .wishlist_table th,.theme-twentytwentytwo .wishlist_table td{padding:1rem 0 .5rem 1rem}.theme-twentytwentytwo .wcboost-wishlist-button{line-height:normal}.theme-twentytwentytwo .wcboost-wishlist-button--text{margin:1rem}.wcboost-wishlist-widget-item{position:relative;margin:1em 0}.wcboost-wishlist-widget-item::after{content:"";display:block;clear:both}.wcboost-wishlist-widget-item img{max-width:60px;margin-right:1em;float:left}.wcboost-wishlist-widget-item a.remove{line-height:1;text-decoration:none;position:absolute;left:0;top:0;min-width:1em;min-height:1em;border-radius:50%;transform:translate(-50%, -50%)}.wcboost-wishlist-widget-item__price,.wcboost-wishlist-widget-item__quantity,.wcboost-wishlist-widget-item__stock,.wcboost-wishlist-widget-item__date,.wcboost-wishlist-widget-item__add-to-cart{display:block} -
wcboost-wishlist/trunk/assets/js/wishlist-fragments.js
r3113521 r3122355 23 23 */ 24 24 var WCBoostWishlistFragments = function() { 25 var self = this; 26 25 27 this.updateFragments = this.updateFragments.bind( this ); 26 28 this.getProductIds = this.getProductIds.bind( this ); … … 34 36 // Refresh when storage changes in another tab. 35 37 $( window ).on( 'storage onstorage', function( e ) { 36 if ( 'wcboost_wishlist_updated' === e.originalEvent.key ) { 37 // Use option `preventStorageUpdate` to prevent infinite refreshing. 38 $( document.body ).trigger( 'wishlist_fragments_refresh', [ false, { preventStorageUpdate: true } ] ); 38 if ( hash_key_name === e.originalEvent.key && localStorage.getItem( hash_key_name ) !== sessionStorage.getItem( hash_key_name ) ) { 39 $( document.body ).trigger( 'wishlist_fragments_refresh' ); 39 40 } 40 41 } ); … … 52 53 53 54 try { 54 var hash_key = sessionStorage.getItem( hash_key_name ); 55 56 if ( hash_key !== null ) { 55 var wishlist_hash = sessionStorage.getItem( hash_key_name ), 56 cookie_hash = Cookies.get( 'wcboost_wishlist_hash' ); 57 58 if ( wishlist_hash !== null && wishlist_hash === cookie_hash ) { 57 59 this.updateFragmentsFromStorage(); 58 60 this.updateButtons(); 59 61 } else { 60 // Run for the first time. 61 this.refreshFragments(); 62 throw 'No wishlist fragment'; 62 63 } 63 64 } catch ( err ) { 64 65 this.refreshFragments(); 65 66 } 67 } 68 69 // Customiser support. 70 var hasSelectiveRefresh = ( 71 'undefined' !== typeof wp && 72 wp.customize && 73 wp.customize.selectiveRefresh && 74 wp.customize.widgetsPreview && 75 wp.customize.widgetsPreview.WidgetPartial 76 ); 77 78 if ( hasSelectiveRefresh ) { 79 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() { 80 self.refreshFragments(); 81 } ); 66 82 } 67 83 } … … 124 140 } 125 141 126 var hash_key = sessionStorage.getItem( hash_key_name ); 127 128 if ( ! hash_key ) { 129 return; 130 } 131 132 var fragments = JSON.parse( sessionStorage.getItem( 'wcboost_wishlist_fragments_' + hash_key ) ); 133 134 if ( fragments !== null ) { 135 this.updateFragments( fragments ); 142 var wishlist_hash = sessionStorage.getItem( hash_key_name ); 143 144 if ( ! wishlist_hash ) { 145 return; 146 } 147 148 var hash_parts = wishlist_hash.split( '::' ), 149 hash_key = hash_parts[0]; 150 151 if ( hash_key ) { 152 var fragments = JSON.parse( sessionStorage.getItem( 'wcboost_wishlist_fragments_' + hash_key ) ); 153 154 if ( fragments !== null ) { 155 this.updateFragments( fragments ); 156 } 136 157 } else { 137 158 this.refreshFragments(); … … 144 165 } 145 166 146 var hash_key = data.wishlist_hash ? data.wishlist_hash : ''; 147 148 sessionStorage.setItem( hash_key_name, hash_key ); 149 150 if ( ! options || ! options.preventStorageUpdate ) { 151 // Update the wishlist timestamps to sync between tabs. 152 localStorage.setItem( 'wcboost_wishlist_updated', ( new Date() ).getTime() ); 153 } 154 155 if ( hash_key !== '' ) { 167 var wishlist_hash = data.wishlist_hash ? data.wishlist_hash : ''; 168 169 sessionStorage.setItem( hash_key_name, wishlist_hash ); 170 localStorage.setItem( hash_key_name, wishlist_hash ); 171 172 if ( wishlist_hash ) { 173 var hash_parts = wishlist_hash.split( '::' ), 174 hash_key = hash_parts[0]; 175 156 176 if ( data.wishlist_items ) { 157 177 sessionStorage.setItem( 'wcboost_wishlist_' + hash_key, JSON.stringify( data.wishlist_items ) ); … … 179 199 } 180 200 181 var hash_key = sessionStorage.getItem( hash_key_name ); 201 var wishlist_hash = sessionStorage.getItem( hash_key_name ); 202 203 if ( ! wishlist_hash ) { 204 return; 205 } 206 207 var hash_parts = wishlist_hash.split( '::' ), 208 hash_key = hash_parts[0]; 182 209 183 210 if ( ! hash_key ) { -
wcboost-wishlist/trunk/assets/js/wishlist-fragments.min.js
r3113521 r3122355 1 jQuery(function( a){if(typeof wcboost_wishlist_fragments_params==="undefined"){return false}var r=true,o=wcboost_wishlist_fragments_params.hash_name;try{r="sessionStorage"in window&&window.sessionStorage!==null;window.sessionStorage.setItem("wcboost","test");window.sessionStorage.removeItem("wcboost");window.localStorage.setItem("wcboost","test");window.localStorage.removeItem("wcboost")}catch(t){r=false}var t=function(){this.updateFragments=this.updateFragments.bind(this);this.getProductIds=this.getProductIds.bind(this);a(document.body).on("wishlist_fragments_refresh wishlist_updated",{wishlistFragmentsHandler:this},this.refreshFragments).on("wishlist_fragments_refreshed wishlist_item_added wishlist_item_removed",{wishlistFragmentsHandler:this},this.updateStorage).on("added_to_wishlist removed_from_wishlist",{wishlistFragmentsHandler:this},this.updateFragmentsOnChanges).on("wishlist_storage_updated",{wishlistFragmentsHandler:this},this.updateButtons);a(window).on("storage onstorage",function(t){if("wcboost_wishlist_updated"===t.originalEvent.key){a(document.body).trigger("wishlist_fragments_refresh",[false,{preventStorageUpdate:true}])}});if("yes"===wcboost_wishlist_fragments_params.refresh_on_load){a(document.body).trigger("wishlist_fragments_refresh")}else{a(window).on("pageshow",function(t){if(t.originalEvent.persisted){a(document.body).trigger("wishlist_fragments_refresh",[true])}});try{var t=sessionStorage.getItem(o);if(t!==null){this.updateFragmentsFromStorage();this.updateButtons()}else{this.refreshFragments()}}catch(t){this.refreshFragments()}}};t.prototype.refreshFragments=function(t,s,e){var i=t?t.data.wishlistFragmentsHandler:this;var r={time:(new Date).getTime()};if("yes"===wcboost_wishlist_fragments_params.refresh_on_load||s){r.product_ids=i.getProductIds()}a.post({url:woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","get_wishlist_fragments"),data:r,dataType:"json",timeout:wcboost_wishlist_fragments_params.request_timeout,success:function(t){if(!t.success){a(document.body).trigger("wishlist_fragments_failed");return}i.updateFragments(t.data.fragments);a(document.body).trigger("wishlist_fragments_refreshed",[t.data,e])},error:function(){a(document.body).trigger("wishlish_fragments_ajax_error")}})};t.prototype.getProductIds=function(){var e=[];a(".wcboost-wishlist-button").each(function(t,s){e.push(s.dataset.product_id)});return e};t.prototype.updateFragmentsOnChanges=function(t,s,e){var i=t.data.wishlistFragmentsHandler;i.updateFragments(e);if(!s&&!r){i.refreshFragments(t,true)}};t.prototype.updateFragmentsFromStorage=function(){if(!r){return}var t=sessionStorage.getItem(o);if(!t){return}var s=JSON.parse(sessionStorage.getItem("wcboost_wishlist_fragments_"+t));if(s!==null){this.updateFragments(s)}else{this.refreshFragments()}};t.prototype.updateStorage=function(t,s,e){if(!r){return}var i=s.wishlist_hash?s.wishlist_hash:"";sessionStorage.setItem(o,i);if(!e||!e.preventStorageUpdate){localStorage.setItem("wcboost_wishlist_updated",(new Date).getTime())}if(i!==""){if(s.wishlist_items){sessionStorage.setItem("wcboost_wishlist_"+i,JSON.stringify(s.wishlist_items))}if(s.fragments){sessionStorage.setItem("wcboost_wishlist_fragments_"+i,JSON.stringify(s.fragments))}a(document.body).trigger("wishlist_storage_updated")}};t.prototype.updateFragments=function(t){a.each(t,function(t,s){a(t).replaceWith(s)});a(document.body).trigger("wishlist_fragments_loaded")};t.prototype.updateButtons=function(t){if(!r){return}var s=sessionStorage.getItem(o);if(!s){return}var e=JSON.parse(sessionStorage.getItem("wcboost_wishlist_"+s));if(e===null){return}var i=t?t.data.wishlistFragmentsHandler:this;a(".wcboost-wishlist-button").each(function(){var t=this.dataset.product_id,s=e[t]?e[t]:null;i.updateButtonStatus(this,s);if(this.dataset.variations){i.updateButtonVariations(this,e)}})};t.prototype.updateButtonStatus=function(t,s){var e=a(t);if(!e.length){return}if(s){if(e.hasClass("added")){return}e.removeClass("loading").addClass("added");switch(wcboost_wishlist_params.exists_item_behavior){case"view_wishlist":e.attr("href",s.wishlist_url?s.wishlist_url:wcboost_wishlist_params.wishlist_url);e.find(".wcboost-wishlist-button__text").text(wcboost_wishlist_params.i18n_view_wishlist);e.find(".wcboost-wishlist-button__icon").html(wcboost_wishlist_params.icon_filled);break;case"remove":e.attr("href",s.remove_url);e.find(".wcboost-wishlist-button__text").text(wcboost_wishlist_params.i18n_remove_from_wishlist);e.find(".wcboost-wishlist-button__icon").html(wcboost_wishlist_params.icon_filled);break;case"hide":e.hide();break}}else{if(!e.hasClass("added")&&!e.hasClass("loading")){return}e.removeClass("added loading");e.attr("href","?add-to-wishlist="+e.data("product_id"));e.find(".wcboost-wishlist-button__text").text(wcboost_wishlist_params.i18n_add_to_wishlist);e.find(".wcboost-wishlist-button__icon").html(wcboost_wishlist_params.icon_normal)}};t.prototype.updateButtonVariations=function(t,s){var e=a(t);if(!e.length||!e.data("variations")){return}var i=e.data("variations");for(var r in i){i[r]=a.extend({},i[r],{added:s[i[r].variation_id]===undefined?"no":"yes"})}e.data("variations",i)};new t});1 jQuery(function(o){if(typeof wcboost_wishlist_fragments_params==="undefined"){return false}var n=true,d=wcboost_wishlist_fragments_params.hash_name;try{n="sessionStorage"in window&&window.sessionStorage!==null;window.sessionStorage.setItem("wcboost","test");window.sessionStorage.removeItem("wcboost");window.localStorage.setItem("wcboost","test");window.localStorage.removeItem("wcboost")}catch(t){n=false}var t=function(){var t=this;this.updateFragments=this.updateFragments.bind(this);this.getProductIds=this.getProductIds.bind(this);o(document.body).on("wishlist_fragments_refresh wishlist_updated",{wishlistFragmentsHandler:this},this.refreshFragments).on("wishlist_fragments_refreshed wishlist_item_added wishlist_item_removed",{wishlistFragmentsHandler:this},this.updateStorage).on("added_to_wishlist removed_from_wishlist",{wishlistFragmentsHandler:this},this.updateFragmentsOnChanges).on("wishlist_storage_updated",{wishlistFragmentsHandler:this},this.updateButtons);o(window).on("storage onstorage",function(t){if(d===t.originalEvent.key&&localStorage.getItem(d)!==sessionStorage.getItem(d)){o(document.body).trigger("wishlist_fragments_refresh")}});if("yes"===wcboost_wishlist_fragments_params.refresh_on_load){o(document.body).trigger("wishlist_fragments_refresh")}else{o(window).on("pageshow",function(t){if(t.originalEvent.persisted){o(document.body).trigger("wishlist_fragments_refresh",[true])}});try{var s=sessionStorage.getItem(d),e=Cookies.get("wcboost_wishlist_hash");if(s!==null&&s===e){this.updateFragmentsFromStorage();this.updateButtons()}else{throw"No wishlist fragment"}}catch(t){this.refreshFragments()}}var i="undefined"!==typeof wp&&wp.customize&&wp.customize.selectiveRefresh&&wp.customize.widgetsPreview&&wp.customize.widgetsPreview.WidgetPartial;if(i){wp.customize.selectiveRefresh.bind("partial-content-rendered",function(){t.refreshFragments()})}};t.prototype.refreshFragments=function(t,s,e){var i=t?t.data.wishlistFragmentsHandler:this;var r={time:(new Date).getTime()};if("yes"===wcboost_wishlist_fragments_params.refresh_on_load||s){r.product_ids=i.getProductIds()}o.post({url:woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","get_wishlist_fragments"),data:r,dataType:"json",timeout:wcboost_wishlist_fragments_params.request_timeout,success:function(t){if(!t.success){o(document.body).trigger("wishlist_fragments_failed");return}i.updateFragments(t.data.fragments);o(document.body).trigger("wishlist_fragments_refreshed",[t.data,e])},error:function(){o(document.body).trigger("wishlish_fragments_ajax_error")}})};t.prototype.getProductIds=function(){var e=[];o(".wcboost-wishlist-button").each(function(t,s){e.push(s.dataset.product_id)});return e};t.prototype.updateFragmentsOnChanges=function(t,s,e){var i=t.data.wishlistFragmentsHandler;i.updateFragments(e);if(!s&&!n){i.refreshFragments(t,true)}};t.prototype.updateFragmentsFromStorage=function(){if(!n){return}var t=sessionStorage.getItem(d);if(!t){return}var s=t.split("::"),e=s[0];if(e){var i=JSON.parse(sessionStorage.getItem("wcboost_wishlist_fragments_"+e));if(i!==null){this.updateFragments(i)}}else{this.refreshFragments()}};t.prototype.updateStorage=function(t,s,e){if(!n){return}var i=s.wishlist_hash?s.wishlist_hash:"";sessionStorage.setItem(d,i);localStorage.setItem(d,i);if(i){var r=i.split("::"),a=r[0];if(s.wishlist_items){sessionStorage.setItem("wcboost_wishlist_"+a,JSON.stringify(s.wishlist_items))}if(s.fragments){sessionStorage.setItem("wcboost_wishlist_fragments_"+a,JSON.stringify(s.fragments))}o(document.body).trigger("wishlist_storage_updated")}};t.prototype.updateFragments=function(t){o.each(t,function(t,s){o(t).replaceWith(s)});o(document.body).trigger("wishlist_fragments_loaded")};t.prototype.updateButtons=function(t){if(!n){return}var s=sessionStorage.getItem(d);if(!s){return}var e=s.split("::"),i=e[0];if(!i){return}var r=JSON.parse(sessionStorage.getItem("wcboost_wishlist_"+i));if(r===null){return}var a=t?t.data.wishlistFragmentsHandler:this;o(".wcboost-wishlist-button").each(function(){var t=this.dataset.product_id,s=r[t]?r[t]:null;a.updateButtonStatus(this,s);if(this.dataset.variations){a.updateButtonVariations(this,r)}})};t.prototype.updateButtonStatus=function(t,s){var e=o(t);if(!e.length){return}if(s){if(e.hasClass("added")){return}e.removeClass("loading").addClass("added");switch(wcboost_wishlist_params.exists_item_behavior){case"view_wishlist":e.attr("href",s.wishlist_url?s.wishlist_url:wcboost_wishlist_params.wishlist_url);e.find(".wcboost-wishlist-button__text").text(wcboost_wishlist_params.i18n_view_wishlist);e.find(".wcboost-wishlist-button__icon").html(wcboost_wishlist_params.icon_filled);break;case"remove":e.attr("href",s.remove_url);e.find(".wcboost-wishlist-button__text").text(wcboost_wishlist_params.i18n_remove_from_wishlist);e.find(".wcboost-wishlist-button__icon").html(wcboost_wishlist_params.icon_filled);break;case"hide":e.hide();break}}else{if(!e.hasClass("added")&&!e.hasClass("loading")){return}e.removeClass("added loading");e.attr("href","?add-to-wishlist="+e.data("product_id"));e.find(".wcboost-wishlist-button__text").text(wcboost_wishlist_params.i18n_add_to_wishlist);e.find(".wcboost-wishlist-button__icon").html(wcboost_wishlist_params.icon_normal)}};t.prototype.updateButtonVariations=function(t,s){var e=o(t);if(!e.length||!e.data("variations")){return}var i=e.data("variations");for(var r in i){i[r]=o.extend({},i[r],{added:s[i[r].variation_id]===undefined?"no":"yes"})}e.data("variations",i)};new t}); -
wcboost-wishlist/trunk/includes/ajax-handler.php
r3113521 r3122355 72 72 wp_send_json_success( [ 73 73 'fragments' => self::get_refreshed_fragments(), 74 'wishlist_hash' => $wishlist->get_ id() ? md5( get_current_blog_id() . '_' . $wishlist->get_id() . '_' . $wishlist->get_wishlist_token() ) : '',74 'wishlist_hash' => $wishlist->get_hash(), 75 75 'wishlist_url' => $wishlist->get_public_url(), 76 76 'wishlist_items' => self::get_wishlist_items( $wishlist_id ), … … 97 97 wp_send_json_success( [ 98 98 'fragments' => self::get_refreshed_fragments(), 99 'wishlist_hash' => $wishlist->get_ id() ? md5( get_current_blog_id() . '_' . $wishlist->get_id() . '_' . $wishlist->get_wishlist_token() ) : '',99 'wishlist_hash' => $wishlist->get_hash(), 100 100 'wishlist_url' => $wishlist->get_public_url(), 101 101 'wishlist_items' => self::get_wishlist_items( $wishlist_id ), … … 133 133 wp_send_json_success( [ 134 134 'fragments' => $fragments, 135 'wishlist_hash' => $wishlist->get_ id() ? md5( get_current_blog_id() . '_' . $wishlist->get_id() . '_' . $wishlist->get_wishlist_token() ) : '',135 'wishlist_hash' => $wishlist->get_hash(), 136 136 'wishlist_items' => self::get_wishlist_items(), 137 137 ] ); -
wcboost-wishlist/trunk/includes/data-stores/wishlist.php
r2999816 r3122355 11 11 12 12 /** 13 * Is reading data from the database. 14 * 15 * @var bool 16 */ 17 private $is_reading = false; 18 19 /** 13 20 * Method to create a new wishlist in the database 14 21 * … … 17 24 * @global wpdb $wpdb 18 25 * @param \WCBoost\Wishlist\Wishlist $wishlist 19 * @todo Generate slug, token20 26 */ 21 27 public function create( &$wishlist ) { … … 205 211 } 206 212 213 $this->set_is_reading( true ); 214 207 215 if ( false === $data ) { 208 216 if ( $id ) { … … 240 248 $wishlist->set_id( $data->wishlist_id ); 241 249 $wishlist->set_object_read(); 250 $this->set_is_reading( false ); 242 251 } 243 252 … … 256 265 throw new \Exception( __( 'Invalid wishlist.', 'wcboost-wishlist' ) ); 257 266 } 267 268 $this->set_is_reading( true ); 258 269 259 270 $items = wp_cache_get( 'wcboost-wishlist-items-' . $wishlist_id, 'wishlists' ); … … 273 284 $wishlist->add_item_to_trash( $item ); 274 285 } else { 275 $wishlist->add_item( $item ); 276 } 277 } 286 $wishlist->add_item( $item, [ 'silence' => true ] ); 287 } 288 } 289 290 $this->set_is_reading( false ); 278 291 } 279 292 … … 405 418 } 406 419 } 420 421 /** 422 * Set the status to determine if is reading data. 423 * This method is called when initialization is on running. 424 * 425 * @since 1.1.1 426 * 427 * @param bool $reading 428 * 429 * @return void 430 */ 431 private function set_is_reading( $reading = false ) { 432 $this->is_reading = wc_string_to_bool( $reading ); 433 } 434 435 /** 436 * Get the reading_db status 437 * 438 * @since 1.1.1 439 * 440 * @return bool 441 */ 442 public function is_reading() { 443 return $this->is_reading; 444 } 407 445 } -
wcboost-wishlist/trunk/includes/frontend.php
r3113521 r3122355 19 19 add_action( 'init', [ $this, 'register_scripts' ] ); 20 20 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); 21 22 // Cookie events. 23 add_action( 'wcboost_wishlist_add_item', [ $this, 'maybe_set_cookies' ] ); 24 add_action( 'wcboost_wishlist_removed_item', [ $this, 'maybe_set_cookies' ] ); 25 add_action( 'wp', [ $this, 'maybe_set_cookies' ], 99 ); 26 add_action( 'shutdown', [ $this, 'maybe_set_cookies' ], 0 ); 21 27 } 22 28 … … 645 651 ); 646 652 } 653 654 /** 655 * Will set cookies if needed and when possible. 656 * 657 * @since 1.1.1 658 * 659 * @return void 660 */ 661 public function maybe_set_cookies() { 662 if ( headers_sent() || ! did_action( 'wp_loaded' ) ) { 663 return; 664 } 665 666 $wishlist = Helper::get_wishlist(); 667 668 if ( ! $wishlist->is_empty() ) { 669 $this->set_cookies( true ); 670 } else { 671 $this->set_cookies( false ); 672 } 673 } 674 675 /** 676 * Set the comparison cookie 677 * 678 * @since 1.1.1 679 * 680 * @param bool $set Should the cookie be set or unset. 681 * 682 * @return void 683 */ 684 private function set_cookies( $set = true ) { 685 $wishlist = Helper::get_wishlist(); 686 687 if ( $set ) { 688 wc_setcookie( 'wcboost_wishlist_hash', $wishlist->get_hash() ); 689 } else { 690 wc_setcookie( 'wcboost_wishlist_hash', '', time() - HOUR_IN_SECONDS ); 691 unset( $_COOKIE['wcboost_wishlist_hash'] ); 692 } 693 } 647 694 } -
wcboost-wishlist/trunk/includes/wishlist.php
r3113521 r3122355 426 426 * 427 427 * @param Wishlist_Item $item Item to be added 428 * @param bool $save_to_db Save new item to database428 * 429 429 * @return bool|WP_Error Returns TRUE on success, FALSE on failure. WP_Error on invalid. 430 430 */ … … 469 469 } 470 470 471 do_action( 'wcboost_wishlist_add_item', $item ); 471 if ( ! $this->data_store->is_reading() ) { 472 do_action( 'wcboost_wishlist_add_item', $item ); 473 } 472 474 473 475 return true; … … 726 728 return apply_filters( 'wcboost_wishlist_edit_url', $url, $this ); 727 729 } 730 731 /** 732 * Get unique hash key for the wishlist 733 * 734 * @since 1.1.1 735 * 736 * @return string 737 */ 738 public function get_hash_key() { 739 $hash_key = ''; 740 741 if ( $this->get_id() ) { 742 $hash_key = md5( get_current_blog_id() . '_' . $this->get_id() . '_' . $this->get_wishlist_token() ); 743 } 744 745 return $hash_key; 746 } 747 748 /** 749 * Get hash content for the wishlist 750 * 751 * @since 1.1.1 752 * 753 * @return string 754 */ 755 public function get_hash_content() { 756 $hash = $this->get_id() ? md5( $this->get_id() . wp_json_encode( $this->get_items() ) . $this->count_items() ) : ''; 757 758 return apply_filters( 'wcboost_wishlist_hash', $hash, $this ); 759 } 760 761 /** 762 * Get hash for the wishlist. 763 * Generated by combining the hash_key and hash_content. 764 * 765 * @since 1.1.1 766 * 767 * @return string Wishlist hash in format HASH_KEY::HASH_CONTENTS 768 */ 769 public function get_hash() { 770 return $this->get_hash_key() . '::' . $this->get_hash_content(); 771 } 728 772 } -
wcboost-wishlist/trunk/languages/wcboost-wishlist.pot
r3113521 r3122355 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2024-07- 06T11:55:38+00:00\n"12 "POT-Creation-Date: 2024-07-20T04:44:31+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.9.0\n" … … 151 151 #: includes/customizer/customizer.php:326 152 152 #: includes/form-handler.php:96 153 #: includes/frontend.php:6 44153 #: includes/frontend.php:650 154 154 #: includes/helper.php:213 155 155 msgid "View wishlist" … … 246 246 247 247 #: includes/admin/settings.php:192 248 #: includes/data-stores/wishlist.php: 26248 #: includes/data-stores/wishlist.php:32 249 249 msgid "My Wishlist" 250 250 msgstr "" … … 361 361 362 362 #: includes/admin/settings.php:380 363 #: includes/frontend.php:3 57363 #: includes/frontend.php:363 364 364 msgid "Edit wishlist" 365 365 msgstr "" … … 503 503 msgstr "" 504 504 505 #: includes/data-stores/wishlist.php: 197506 #: includes/data-stores/wishlist.php:2 15507 #: includes/data-stores/wishlist.php:2 56505 #: includes/data-stores/wishlist.php:203 506 #: includes/data-stores/wishlist.php:223 507 #: includes/data-stores/wishlist.php:265 508 508 msgid "Invalid wishlist." 509 509 msgstr "" … … 565 565 msgstr "" 566 566 567 #: includes/frontend.php:1 37567 #: includes/frontend.php:143 568 568 msgid "The wishlist link is copied to clipboard" 569 569 msgstr "" 570 570 571 #: includes/frontend.php:1 38571 #: includes/frontend.php:144 572 572 msgid "Close" 573 573 msgstr "" 574 574 575 #: includes/frontend.php:3 35575 #: includes/frontend.php:341 576 576 msgid "Share" 577 577 msgstr "" 578 578 579 #: includes/frontend.php:39 3579 #: includes/frontend.php:399 580 580 msgid "You cannot delete your default wishlist. You have to set another list as default to delete this one." 581 581 msgstr "" 582 582 583 #: includes/frontend.php: 395583 #: includes/frontend.php:401 584 584 msgid "This action moves the wishlist to Trash. It will be kept in Trash for 30 days." 585 585 msgstr "" 586 586 587 #: includes/frontend.php: 399587 #: includes/frontend.php:405 588 588 msgid "Delete this wishlist" 589 589 msgstr "" 590 590 591 591 #. translators: %s product name 592 #: includes/frontend.php:5 04592 #: includes/frontend.php:510 593 593 msgid "Add %s to the wishlist" 594 594 msgstr "" 595 595 596 596 #. translators: %s product name 597 #: includes/frontend.php:54 0597 #: includes/frontend.php:546 598 598 msgid "Remove %s from the wishlist" 599 599 msgstr "" 600 600 601 #: includes/frontend.php:5 46601 #: includes/frontend.php:552 602 602 msgid "Open the wishlist" 603 603 msgstr "" … … 672 672 msgstr "" 673 673 674 #: includes/wishlist.php:48 4675 #: includes/wishlist.php:51 5674 #: includes/wishlist.php:486 675 #: includes/wishlist.php:517 676 676 msgid "You are not allowed to edit the wishlist" 677 677 msgstr "" 678 678 679 #: includes/wishlist.php:4 88680 #: includes/wishlist.php:52 1679 #: includes/wishlist.php:490 680 #: includes/wishlist.php:523 681 681 msgid "Invalid wishlist item" 682 682 msgstr "" -
wcboost-wishlist/trunk/readme.txt
r3120847 r3122355 3 3 Tags: woocommerce wishlist, wishlist, products, e-commerce, woocommerce 4 4 Tested up to: 6.6 5 Stable tag: 1.1. 05 Stable tag: 1.1.1 6 6 Requires PHP: 7.0 7 7 Requires at least: 4.5 8 8 WC requires at least: 3.0.0 9 WC tested up to: 9. 09 WC tested up to: 9.1 10 10 License: GPLv3 11 11 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 95 95 == Changelog == 96 96 97 = 1.1.0 97 = 1.1.1 = 98 - Tweak - Improve caching to dynamically update wishlist fragments. 99 - Tweak - WordPress 6.6 compatibility. 100 - Tweak – WooCommerce 9.1 compatibility. 101 102 = 1.1.0 = 98 103 - Enhancement - Improve performance with the new client caching. 99 104 - Fix - Fix the installation issue. … … 101 106 - Tweak – WooCommerce 9.0 compatibility. 102 107 103 = 1.0.13 108 = 1.0.13 = 104 109 - Tweak - Improve themes compatibility 105 110 - Fix - Fix issues that may occur when installing the plugin. -
wcboost-wishlist/trunk/wcboost-wishlist.php
r3113521 r3122355 5 5 * Plugin URI: https://wcboost.com/plugin/woocommerce-wishlist/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash 6 6 * Author: WCBoost 7 * Version: 1.1. 07 * Version: 1.1.1 8 8 * Author URI: https://wcboost.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash 9 9 * … … 13 13 * Requires PHP: 7.0 14 14 * Requires at least: 4.5 15 * Tested up to: 6. 515 * Tested up to: 6.6 16 16 * WC requires at least: 3.0.0 17 * WC tested up to: 9. 017 * WC tested up to: 9.1 18 18 * 19 19 * @package WCBoost
Note: See TracChangeset
for help on using the changeset viewer.