Perfect Brands for WooCommerce - Version 1.6.5

Version Description

  • Include icon and banner brand image in api response (thanks @qbig)
  • Feature: New option for show only favorite brands in the dropdown widget and the list widget
  • Feature: New option for configure the max number of brands in filter by brand widget
  • Feature: Filter by brand without submit button
  • Feature: New option for randomize brand logos in the list widget
  • Feature: Hide empty brands in brand carousel
  • Enhancement: Hide widgets when there are no results to show
  • Fix: "Dokan Multivendor Marketplace" JavaScript conflict in admin
Download this release

Release Info

Developer titodevera
Plugin Icon 128x128 Perfect Brands for WooCommerce
Version 1.6.5
Comparing to
See all releases

Code changes from version 1.6.4 to 1.6.5

assets/css/styles-admin.css CHANGED
@@ -107,12 +107,6 @@
107
  }
108
  /* ----------------------- /Taxonomy pwb-brand ----------------------- */
109
 
110
- /* ----------------------- Widgets page ----------------------- */
111
- .widgets-php .widget[id*="_pwb_"] .widget-title{
112
- border-left: 2px solid #cda000;
113
- }
114
- /* ----------------------- /Widgets page ----------------------- */
115
-
116
  /* ----------------------- Settings page ----------------------- */
117
  #wc_pwb_admin_status_result{
118
  display: none;
@@ -129,6 +123,9 @@ select.pwb-admin-tab-field, input[type="text"].pwb-admin-tab-field{
129
  }
130
  /* ----------------------- /Settings page ----------------------- */
131
 
 
 
 
132
  .pwb-display-as-logo{
133
  display: none;
134
  }
107
  }
108
  /* ----------------------- /Taxonomy pwb-brand ----------------------- */
109
 
 
 
 
 
 
 
110
  /* ----------------------- Settings page ----------------------- */
111
  #wc_pwb_admin_status_result{
112
  display: none;
123
  }
124
  /* ----------------------- /Settings page ----------------------- */
125
 
126
+ table.wp-list-table .column-taxonomy-pwb-brand{
127
+ width: 11%!important;
128
+ }
129
  .pwb-display-as-logo{
130
  display: none;
131
  }
assets/css/styles-admin.min.css CHANGED
@@ -1 +1 @@
1
- .pwb-clearfix:after{content:"";display:table;clear:both}.pwb-blocked{opacity:.6}.taxonomy-pwb-brand .pwb_brand_image_selected_remove{color:#ff3030;font-family:Arial,Helvetica,sans-serif;text-decoration:none;font-size:20px;font-weight:bold;position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,0.5);opacity:0;-webkit-transition:opacity 200ms ease-in-out;-moz-transition:opacity 200ms ease-in-out;-ms-transition:opacity 200ms ease-in-out;-o-transition:opacity 200ms ease-in-out;transition:opacity 200ms ease-in-out}.taxonomy-pwb-brand .pwb_brand_image_selected span{display:inline-block;position:relative;text-align:center;line-height:90px;height:90px}.taxonomy-pwb-brand .pwb_brand_image_selected span:hover .pwb_brand_image_selected_remove{opacity:1}.taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_image,.taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_banner{display:none}.taxonomy-pwb-brand .pwb_brand_cont>div{margin-top:10px}#wp-pwb-brand-description-field-wrap,#brand-description-help-text{width:95%}.taxonomy-pwb-brand .term-description-wrap{display:none!important}.taxonomy-pwb-brand #col-right.pwb-force-full-width .pwb-edit-brands-bottom>span{-ms-transform:rotate(180deg);-webkit-transform:rotate(180deg);transform:rotate(180deg)}.taxonomy-pwb-brand table.wp-list-table .column-featured{width:48px;text-align:center}.taxonomy-pwb-brand .pwb-edit-brands-bottom{margin-top:20px;margin-bottom:20px;background-color:#f6f6f6;border-top:1px solid #e4e4e4;padding:10px}.taxonomy-pwb-brand .pwb-edit-brands-bottom>span:hover{cursor:pointer}.taxonomy-pwb-brand .pwb-edit-brands-bottom>span{float:left}.taxonomy-pwb-brand .pwb-featured-count{font-style:italic;float:right;margin-left:12px;margin-top:0;margin-bottom:0}.taxonomy-pwb-brand table.wp-list-table .column-featured .dashicons-star-empty:hover:before{content:"\f155"}.taxonomy-pwb-brand table .column-featured>span:hover{cursor:pointer}@media screen and (max-width:782px){.taxonomy-pwb-brand .wp-list-table thead th.column-logo,.taxonomy-pwb-brand .wp-list-table tfoot th.column-logo{display:none}.taxonomy-pwb-brand .wp-list-table td.column-logo:before{content:""!important}.taxonomy-pwb-brand .pwb-edit-brands-bottom>span{display:none}}@media screen and (min-width:782px){.taxonomy-pwb-brand #col-right.pwb-force-full-width{width:100%!important}.taxonomy-pwb-brand #col-left.pwb-force-full-width{width:0!important;display:none!important}}.widgets-php .widget[id*="_pwb_"] .widget-title{border-left:2px solid #cda000}#wc_pwb_admin_status_result{display:none;background-color:#f6f6f6;padding:14px}#wc_pwb_admin_tab_tools_system_status{display:none!important}select.pwb-admin-tab-field,input[type="text"].pwb-admin-tab-field{min-width:350px;display:block;height:auto}.pwb-display-as-logo{display:none}.pwb-display-as-logo.show{display:block}.pwb-notice-dismissible p a{margin-right:12px}.pwb-notice-dismissible .dashicons-heart{color:#f188ff;margin-left:3px}.pwb-modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:99999999999;line-height:1;background:rgba(0,0,0,0.9);font-size:2em;padding-top:20px;text-align:center}.pwb-modal-inner{max-width:70%;margin:0 auto;animation:pwbblinkkf 3s linear infinite;color:#fff}.pwb-modal-inner p{font-size:2em}@keyframes pwbblinkkf{50%{opacity:0}}
1
+ .pwb-clearfix:after{content:"";display:table;clear:both}.pwb-blocked{opacity:.6}.taxonomy-pwb-brand .pwb_brand_image_selected_remove{color:#ff3030;font-family:Arial,Helvetica,sans-serif;text-decoration:none;font-size:20px;font-weight:bold;position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,0.5);opacity:0;-webkit-transition:opacity 200ms ease-in-out;-moz-transition:opacity 200ms ease-in-out;-ms-transition:opacity 200ms ease-in-out;-o-transition:opacity 200ms ease-in-out;transition:opacity 200ms ease-in-out}.taxonomy-pwb-brand .pwb_brand_image_selected span{display:inline-block;position:relative;text-align:center;line-height:90px;height:90px}.taxonomy-pwb-brand .pwb_brand_image_selected span:hover .pwb_brand_image_selected_remove{opacity:1}.taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_image,.taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_banner{display:none}.taxonomy-pwb-brand .pwb_brand_cont>div{margin-top:10px}#wp-pwb-brand-description-field-wrap,#brand-description-help-text{width:95%}.taxonomy-pwb-brand .term-description-wrap{display:none!important}.taxonomy-pwb-brand #col-right.pwb-force-full-width .pwb-edit-brands-bottom>span{-ms-transform:rotate(180deg);-webkit-transform:rotate(180deg);transform:rotate(180deg)}.taxonomy-pwb-brand table.wp-list-table .column-featured{width:48px;text-align:center}.taxonomy-pwb-brand .pwb-edit-brands-bottom{margin-top:20px;margin-bottom:20px;background-color:#f6f6f6;border-top:1px solid #e4e4e4;padding:10px}.taxonomy-pwb-brand .pwb-edit-brands-bottom>span:hover{cursor:pointer}.taxonomy-pwb-brand .pwb-edit-brands-bottom>span{float:left}.taxonomy-pwb-brand .pwb-featured-count{font-style:italic;float:right;margin-left:12px;margin-top:0;margin-bottom:0}.taxonomy-pwb-brand table.wp-list-table .column-featured .dashicons-star-empty:hover:before{content:"\f155"}.taxonomy-pwb-brand table .column-featured>span:hover{cursor:pointer}@media screen and (max-width:782px){.taxonomy-pwb-brand .wp-list-table thead th.column-logo,.taxonomy-pwb-brand .wp-list-table tfoot th.column-logo{display:none}.taxonomy-pwb-brand .wp-list-table td.column-logo:before{content:""!important}.taxonomy-pwb-brand .pwb-edit-brands-bottom>span{display:none}}@media screen and (min-width:782px){.taxonomy-pwb-brand #col-right.pwb-force-full-width{width:100%!important}.taxonomy-pwb-brand #col-left.pwb-force-full-width{width:0!important;display:none!important}}#wc_pwb_admin_status_result{display:none;background-color:#f6f6f6;padding:14px}#wc_pwb_admin_tab_tools_system_status{display:none!important}select.pwb-admin-tab-field,input[type="text"].pwb-admin-tab-field{min-width:350px;display:block;height:auto}table.wp-list-table .column-taxonomy-pwb-brand{width:11%!important}.pwb-display-as-logo{display:none}.pwb-display-as-logo.show{display:block}.pwb-notice-dismissible p a{margin-right:12px}.pwb-notice-dismissible .dashicons-heart{color:#f188ff;margin-left:3px}.pwb-modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:99999999999;line-height:1;background:rgba(0,0,0,0.9);font-size:2em;padding-top:20px;text-align:center}.pwb-modal-inner{max-width:70%;margin:0 auto;animation:pwbblinkkf 3s linear infinite;color:#fff}.pwb-modal-inner p{font-size:2em}@keyframes pwbblinkkf{50%{opacity:0}}
assets/css/styles-frontend.css CHANGED
@@ -220,6 +220,15 @@
220
  }
221
  /* ----------------------- /PWB All Brands ----------------------- */
222
 
 
 
 
 
 
 
 
 
 
223
  /* ----------------------- Columns ----------------------- */
224
  .pwb-row:after{
225
  content: "";
@@ -242,8 +251,7 @@
242
  width: 16.66666%;
243
  }
244
  .pwb-columns{
245
- display: inline-block;
246
- vertical-align:top;
247
  }
248
  /* ----------------------- /Columns ----------------------- */
249
 
220
  }
221
  /* ----------------------- /PWB All Brands ----------------------- */
222
 
223
+ /* ----------------------- Filter products widget ----------------------- */
224
+ .pwb-filter-products input[type="checkbox"]{
225
+ margin-right: 10px;
226
+ }
227
+ .pwb-filter-products li{
228
+ margin-bottom: 5px;
229
+ }
230
+ /* ----------------------- /Filter products widget ----------------------- */
231
+
232
  /* ----------------------- Columns ----------------------- */
233
  .pwb-row:after{
234
  content: "";
251
  width: 16.66666%;
252
  }
253
  .pwb-columns{
254
+ float: left;
 
255
  }
256
  /* ----------------------- /Columns ----------------------- */
257
 
assets/css/styles-frontend.min.css CHANGED
@@ -1 +1 @@
1
- .pwb-clearfix:after{content:"";display:table;clear:both}.pwb-brand-banner-cont.before-loop{margin-bottom:1em}.pwb-brand-banner-cont.after-loop{margin-top:1em}.pwb-carousel .pwb-slick-slide a{display:block}.pwb-carousel .pwb-slick-slide a>img{margin:0 auto}.pwb-carousel .slick-loading .slick-list,.pwb-product-carousel .slick-loading .slick-list{background:#fff url('./ajax-loader.gif') center center no-repeat}.pwb-carousel .pwb-slick-slide,.pwb-product-carousel .pwb-slick-slide{margin:0 10px}.pwb-carousel .slick-prev,.pwb-carousel .slick-next,.pwb-product-carousel .slick-prev,.pwb-product-carousel .slick-next{font-size:0;position:absolute;top:0;bottom:0;display:block;cursor:pointer;font-size:22px;width:30px;overflow:hidden;text-align:center;color:#aeaeae;border:0;outline:0;z-index:999;background:#eee;opacity:0;transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out}.pwb-carousel .slick-prev>span,.pwb-carousel .slick-next>span,.pwb-product-carousel .slick-prev>span,.pwb-product-carousel .slick-next>span{display:inline-block;height:20px;width:20px;padding:10px;position:absolute;top:50%;margin-top:-20px;left:0;right:0}.pwb-carousel .slick-prev:hover,.pwb-carousel .slick-prev:focus,.pwb-carousel .slick-next:hover,.pwb-carousel .slick-next:focus,.pwb-product-carousel .slick-prev:hover,.pwb-product-carousel .slick-prev:focus,.pwb-product-carousel .slick-next:hover,.pwb-product-carousel .slick-next:focus{outline:0}.pwb-carousel .slick-prev,.pwb-product-carousel .slick-prev{left:0}.pwb-carousel .slick-next,.pwb-product-carousel .slick-next{right:0}.pwb-carousel:hover .slick-next,.pwb-carousel:hover .slick-prev,.pwb-product-carousel:hover .slick-next,.pwb-product-carousel:hover .slick-prev{opacity:.8}.pwb-product-carousel .pwb-amount{display:block;width:100%;margin-bottom:12px}.pwb-carousel,.pwb-product-carousel{min-height:30px}.pwb-carousel .pwb-slick-slide,.pwb-product-carousel .pwb-slick-slide{display:none}.pwb-carousel.slick-initialized .pwb-slick-slide,.pwb-product-carousel.slick-initialized .pwb-slick-slide{display:block}.pwb-carousel .slick-list,.pwb-product-carousel .slick-list{opacity:0;position:absolute}.pwb-carousel.slick-initialized,.pwb-product-carousel.slick-initialized{min-height:none}.pwb-carousel.slick-initialized .slick-list,.pwb-product-carousel.slick-initialized .slick-list{opacity:1;position:relative;transition:opacity .2s ease-in}.pwb-carousel.slick-initialized .pwb-carousel-loader,.pwb-product-carousel.slick-initialized .pwb-carousel-loader{display:none!important;opacity:0!important}.pwb-carousel-loader{font-size:10px;margin:50px auto;text-indent:-9999em;width:30px;height:30px;border-radius:50%;background:#525252;background:-moz-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:-webkit-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:-o-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:-ms-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:linear-gradient(to right,#525252 10%,rgba(82,82,82,0) 42%);position:relative;-webkit-animation:PWBCarouselLoader 1.4s infinite linear;animation:PWBCarouselLoader 1.4s infinite linear;-webkit-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0)}.pwb-carousel-loader:before{width:50%;height:50%;background:#525252;border-radius:100% 0 0 0;position:absolute;top:0;left:0;content:''}.pwb-carousel-loader:after{background:#fff;width:75%;height:75%;border-radius:50%;content:'';margin:auto;position:absolute;top:0;left:0;bottom:0;right:0}@-webkit-keyframes PWBCarouselLoader{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes PWBCarouselLoader{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.pwb-brands-cols-outer{margin-left:-15px;margin-right:-15px}.pwb-all-brands .pwb-pagination-wrapper{margin-top:20px;padding-top:10px;border-top:1px solid #ededed;text-align:right}.pwb-all-brands .pwb-pagination{display:inline-block;margin-right:10px;background-color:#ededed;color:#333;text-align:center;padding:10px}.pwb-all-brands .pwb-brands-cols-outer:after{content:"";display:table;clear:both}.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{padding:0 15px;width:20%;float:left}.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3>p:first-child{height:25px;overflow:hidden;font-size:14px}.pwb-row:after{content:"";display:table;clear:both}.pwb-columns-2{width:50%}.pwb-columns-3{width:33.33333%}.pwb-columns-4{width:25%}.pwb-columns-5{width:20%}.pwb-columns-6{width:16.66666%}.pwb-columns{display:inline-block;vertical-align:top}@media screen and (max-width:1000px){.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{width:25%}}@media screen and (max-width:700px){.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{width:50%}.pwb-columns-5,.pwb-columns-6{width:25%}}@media screen and (max-width:480px){.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{width:100%;float:none}.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3>p:first-child{height:auto}.pwb-columns-3,.pwb-columns-4,.pwb-columns-5,.pwb-columns-6{width:50%}}
1
+ .pwb-clearfix:after{content:"";display:table;clear:both}.pwb-brand-banner-cont.before-loop{margin-bottom:1em}.pwb-brand-banner-cont.after-loop{margin-top:1em}.pwb-carousel .pwb-slick-slide a{display:block}.pwb-carousel .pwb-slick-slide a>img{margin:0 auto}.pwb-carousel .slick-loading .slick-list,.pwb-product-carousel .slick-loading .slick-list{background:#fff url('./ajax-loader.gif') center center no-repeat}.pwb-carousel .pwb-slick-slide,.pwb-product-carousel .pwb-slick-slide{margin:0 10px}.pwb-carousel .slick-prev,.pwb-carousel .slick-next,.pwb-product-carousel .slick-prev,.pwb-product-carousel .slick-next{font-size:0;position:absolute;top:0;bottom:0;display:block;cursor:pointer;font-size:22px;width:30px;overflow:hidden;text-align:center;color:#aeaeae;border:0;outline:0;z-index:999;background:#eee;opacity:0;transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out}.pwb-carousel .slick-prev>span,.pwb-carousel .slick-next>span,.pwb-product-carousel .slick-prev>span,.pwb-product-carousel .slick-next>span{display:inline-block;height:20px;width:20px;padding:10px;position:absolute;top:50%;margin-top:-20px;left:0;right:0}.pwb-carousel .slick-prev:hover,.pwb-carousel .slick-prev:focus,.pwb-carousel .slick-next:hover,.pwb-carousel .slick-next:focus,.pwb-product-carousel .slick-prev:hover,.pwb-product-carousel .slick-prev:focus,.pwb-product-carousel .slick-next:hover,.pwb-product-carousel .slick-next:focus{outline:0}.pwb-carousel .slick-prev,.pwb-product-carousel .slick-prev{left:0}.pwb-carousel .slick-next,.pwb-product-carousel .slick-next{right:0}.pwb-carousel:hover .slick-next,.pwb-carousel:hover .slick-prev,.pwb-product-carousel:hover .slick-next,.pwb-product-carousel:hover .slick-prev{opacity:.8}.pwb-product-carousel .pwb-amount{display:block;width:100%;margin-bottom:12px}.pwb-carousel,.pwb-product-carousel{min-height:30px}.pwb-carousel .pwb-slick-slide,.pwb-product-carousel .pwb-slick-slide{display:none}.pwb-carousel.slick-initialized .pwb-slick-slide,.pwb-product-carousel.slick-initialized .pwb-slick-slide{display:block}.pwb-carousel .slick-list,.pwb-product-carousel .slick-list{opacity:0;position:absolute}.pwb-carousel.slick-initialized,.pwb-product-carousel.slick-initialized{min-height:none}.pwb-carousel.slick-initialized .slick-list,.pwb-product-carousel.slick-initialized .slick-list{opacity:1;position:relative;transition:opacity .2s ease-in}.pwb-carousel.slick-initialized .pwb-carousel-loader,.pwb-product-carousel.slick-initialized .pwb-carousel-loader{display:none!important;opacity:0!important}.pwb-carousel-loader{font-size:10px;margin:50px auto;text-indent:-9999em;width:30px;height:30px;border-radius:50%;background:#525252;background:-moz-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:-webkit-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:-o-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:-ms-linear-gradient(left,#525252 10%,rgba(82,82,82,0) 42%);background:linear-gradient(to right,#525252 10%,rgba(82,82,82,0) 42%);position:relative;-webkit-animation:PWBCarouselLoader 1.4s infinite linear;animation:PWBCarouselLoader 1.4s infinite linear;-webkit-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0)}.pwb-carousel-loader:before{width:50%;height:50%;background:#525252;border-radius:100% 0 0 0;position:absolute;top:0;left:0;content:''}.pwb-carousel-loader:after{background:#fff;width:75%;height:75%;border-radius:50%;content:'';margin:auto;position:absolute;top:0;left:0;bottom:0;right:0}@-webkit-keyframes PWBCarouselLoader{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes PWBCarouselLoader{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.pwb-brands-cols-outer{margin-left:-15px;margin-right:-15px}.pwb-all-brands .pwb-pagination-wrapper{margin-top:20px;padding-top:10px;border-top:1px solid #ededed;text-align:right}.pwb-all-brands .pwb-pagination{display:inline-block;margin-right:10px;background-color:#ededed;color:#333;text-align:center;padding:10px}.pwb-all-brands .pwb-brands-cols-outer:after{content:"";display:table;clear:both}.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{padding:0 15px;width:20%;float:left}.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3>p:first-child{height:25px;overflow:hidden;font-size:14px}.pwb-filter-products input[type="checkbox"]{margin-right:10px}.pwb-filter-products li{margin-bottom:5px}.pwb-row:after{content:"";display:table;clear:both}.pwb-columns-2{width:50%}.pwb-columns-3{width:33.33333%}.pwb-columns-4{width:25%}.pwb-columns-5{width:20%}.pwb-columns-6{width:16.66666%}.pwb-columns{float:left}@media screen and (max-width:1000px){.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{width:25%}}@media screen and (max-width:700px){.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{width:50%}.pwb-columns-5,.pwb-columns-6{width:25%}}@media screen and (max-width:480px){.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{width:100%;float:none}.pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3>p:first-child{height:auto}.pwb-columns-3,.pwb-columns-4,.pwb-columns-5,.pwb-columns-6{width:50%}}
assets/js/functions-admin.js CHANGED
@@ -1,6 +1,4 @@
1
- jQuery.noConflict();
2
-
3
- jQuery(document).ready(function( $ ) {
4
 
5
  var media_uploader = null;
6
 
1
+ jQuery( function ( $ ) {
 
 
2
 
3
  var media_uploader = null;
4
 
assets/js/functions-admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery.noConflict();jQuery(document).ready(function(d){var b=null;function a(h,g){var i=g.parent();b=wp.media({frame:"post",state:"insert",multiple:false});b.on("insert",function(){var l=b.state().get("selection").first().toJSON();var m=l.id;var n=l.url;var k='<img src="'+n+'" width="90" height="90">';var j="";switch(h.target.id){case"pwb_brand_image_select":j=".taxonomy-pwb-brand #pwb_brand_image";break;case"pwb_brand_banner_select":j=".taxonomy-pwb-brand #pwb_brand_banner";break}d(j).val(m);d(j+"_result").remove();if(d(".pwb_brand_image_selected",i).length){d(".pwb_brand_image_selected span",i).html(k)}else{i.append('<div class="pwb_brand_image_selected"><span>'+k+"</span></div>")}c(i)});b.open()}d(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").on("click",function(g){a(g,d(this))});d(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").each(function(){c(d(this).parent())});jQuery(document).ajaxSuccess(function(h,i,g){if(typeof g!="undefined"&&g.data&&~g.data.indexOf("action=add-tag")&&~g.data.indexOf("taxonomy=pwb-brand")){d("#pwb_brand_image").val("");d("#pwb_brand_banner").val("");d(".pwb_brand_image_selected").remove()}});function c(g){d(".pwb_brand_image_selected span",g).append('<a href="#" class="pwb_brand_image_selected_remove">X</a>');d(".pwb_brand_image_selected_remove",g).on("click",function(h){h.preventDefault();d(this).closest(".pwb_brand_image_selected").remove();d("#pwb_brand_image",g).val("");d("#pwb_brand_banner",g).val("")})}d(".taxonomy-pwb-brand table .column-featured > span").not("pwb-blocked").on("click",function(h){h.preventDefault();var i=d(this);i.addClass("pwb-blocked");if(i.hasClass("dashicons-star-filled")){i.removeClass("dashicons-star-filled");i.addClass("dashicons-star-empty")}else{i.removeClass("dashicons-star-empty");i.addClass("dashicons-star-filled")}var g={action:"pwb_admin_set_featured_brand",brand:i.data("brand-id")};d.post(ajax_object.ajax_url,g,function(j){i.removeClass("pwb-blocked");if(j.success){var k=d(".taxonomy-pwb-brand .pwb-featured-count > span");if(j.data.direction=="up"){k.html(parseInt(k.text())+1)}else{k.html(parseInt(k.text())-1)}}else{alert(j.data.error_msg)}})});d(".taxonomy-pwb-brand #pwb-first-featured-brands").on("change",function(h){h.preventDefault();d("#screen-options-apply").replaceWith('<img src="'+ajax_object.site_url+'/wp-admin/images/loading.gif">');var g={action:"pwb_admin_save_screen_settings",new_val:d(this).is(":checked")};d.post(ajax_object.ajax_url,g,function(i){location.reload()})});d(".pwb-edit-brands-bottom > span").on("click",function(g){g.preventDefault();d(".taxonomy-pwb-brand #col-left").toggleClass("pwb-force-full-width");d(".taxonomy-pwb-brand #col-right").toggleClass("pwb-force-full-width")});d("#wc_pwb_admin_tab_tools_migrate").on("change",function(){if(d(this).val()!="-"){if(confirm(ajax_object.translations.migrate_notice)){d("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>');d(".pwb-modal-inner").html("<p>"+ajax_object.translations.migrating+"</p>");var g={action:"pwb_admin_migrate_brands",from:d(this).val()};d.post(ajax_object.ajax_url,g,function(h){setTimeout(function(){location.href=ajax_object.brands_url},1000)})}else{}}d(this).val("-")});d("#wc_pwb_admin_tab_tools_dummy_data").on("change",function(){if(d(this).val()!="-"){if(confirm(ajax_object.translations.dummy_data_notice)){d("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>');d(".pwb-modal-inner").html("<p>"+ajax_object.translations.dummy_data+"</p>");var g={action:"pwb_admin_dummy_data",from:d(this).val()};d.post(ajax_object.ajax_url,g,function(h){setTimeout(function(){location.href=ajax_object.brands_url},1000)})}else{}}d(this).val("-")});var f=d("#wc_pwb_admin_tab_tools_system_status").siblings("p");f.addClass("button wc_pwb_admin_tab_status_btn");d(".wc_pwb_admin_tab_status_btn").on("click",function(h){h.preventDefault();if(!d("#wc_pwb_admin_status_result").length){$systemStatusTextarea=d("#wc_pwb_admin_tab_tools_system_status");d('<pre id="wc_pwb_admin_status_result"></pre>').insertAfter($systemStatusTextarea);jQuery("#wc_pwb_admin_status_result").click(function(l){l.preventDefault();var j=d(this)[0];if(d.browser.msie){var i=document.body.createTextRange();i.moveToElementText(j);i.select()}else{if(d.browser.mozilla||d.browser.opera){var k=window.getSelection();var i=document.createRange();i.selectNodeContents(j);k.removeAllRanges();k.addRange(i)}else{if(d.browser.safari){var k=window.getSelection();k.setBaseAndExtent(j,0,j,1)}}}})}d("#wc_pwb_admin_status_result").html('<img src="'+ajax_object.site_url+'/wp-admin/images/spinner.gif" alt="Loading" height="20" width="20">');d("#wc_pwb_admin_status_result").show();var g={action:"pwb_system_status"};jQuery.post(ajaxurl,g,function(i){d("#wc_pwb_admin_status_result").html(i);d("#wc_pwb_admin_status_result").trigger("click")})});d(document).on("click",".pwb-notice-dismissible .notice-dismiss",function(i){i.preventDefault();var g=d(this).closest(".pwb-notice-dismissible").data("notice");var h={action:"dismiss_pwb_notice",notice_name:g};jQuery.post(ajaxurl,h,function(j){})});e();jQuery(document).bind("widget-added",function(h,g){e(g)});jQuery(document).on("widget-updated",function(h,g){e(g)});function e(g){$currentWidget=d(".pwb-select-display-as");if(g!=undefined){$currentWidget=d(".pwb-select-display-as",g)}$currentWidget.on("change",function(){if(d(this).val()=="brand_logo"){d(this).parent().siblings(".pwb-display-as-logo").addClass("show")}else{d(this).parent().siblings(".pwb-display-as-logo").removeClass("show")}})}});
1
+ jQuery(function(d){var b=null;function a(h,g){var i=g.parent();b=wp.media({frame:"post",state:"insert",multiple:false});b.on("insert",function(){var l=b.state().get("selection").first().toJSON();var m=l.id;var n=l.url;var k='<img src="'+n+'" width="90" height="90">';var j="";switch(h.target.id){case"pwb_brand_image_select":j=".taxonomy-pwb-brand #pwb_brand_image";break;case"pwb_brand_banner_select":j=".taxonomy-pwb-brand #pwb_brand_banner";break}d(j).val(m);d(j+"_result").remove();if(d(".pwb_brand_image_selected",i).length){d(".pwb_brand_image_selected span",i).html(k)}else{i.append('<div class="pwb_brand_image_selected"><span>'+k+"</span></div>")}c(i)});b.open()}d(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").on("click",function(g){a(g,d(this))});d(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").each(function(){c(d(this).parent())});jQuery(document).ajaxSuccess(function(h,i,g){if(typeof g!="undefined"&&g.data&&~g.data.indexOf("action=add-tag")&&~g.data.indexOf("taxonomy=pwb-brand")){d("#pwb_brand_image").val("");d("#pwb_brand_banner").val("");d(".pwb_brand_image_selected").remove()}});function c(g){d(".pwb_brand_image_selected span",g).append('<a href="#" class="pwb_brand_image_selected_remove">X</a>');d(".pwb_brand_image_selected_remove",g).on("click",function(h){h.preventDefault();d(this).closest(".pwb_brand_image_selected").remove();d("#pwb_brand_image",g).val("");d("#pwb_brand_banner",g).val("")})}d(".taxonomy-pwb-brand table .column-featured > span").not("pwb-blocked").on("click",function(h){h.preventDefault();var i=d(this);i.addClass("pwb-blocked");if(i.hasClass("dashicons-star-filled")){i.removeClass("dashicons-star-filled");i.addClass("dashicons-star-empty")}else{i.removeClass("dashicons-star-empty");i.addClass("dashicons-star-filled")}var g={action:"pwb_admin_set_featured_brand",brand:i.data("brand-id")};d.post(ajax_object.ajax_url,g,function(j){i.removeClass("pwb-blocked");if(j.success){var k=d(".taxonomy-pwb-brand .pwb-featured-count > span");if(j.data.direction=="up"){k.html(parseInt(k.text())+1)}else{k.html(parseInt(k.text())-1)}}else{alert(j.data.error_msg)}})});d(".taxonomy-pwb-brand #pwb-first-featured-brands").on("change",function(h){h.preventDefault();d("#screen-options-apply").replaceWith('<img src="'+ajax_object.site_url+'/wp-admin/images/loading.gif">');var g={action:"pwb_admin_save_screen_settings",new_val:d(this).is(":checked")};d.post(ajax_object.ajax_url,g,function(i){location.reload()})});d(".pwb-edit-brands-bottom > span").on("click",function(g){g.preventDefault();d(".taxonomy-pwb-brand #col-left").toggleClass("pwb-force-full-width");d(".taxonomy-pwb-brand #col-right").toggleClass("pwb-force-full-width")});d("#wc_pwb_admin_tab_tools_migrate").on("change",function(){if(d(this).val()!="-"){if(confirm(ajax_object.translations.migrate_notice)){d("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>');d(".pwb-modal-inner").html("<p>"+ajax_object.translations.migrating+"</p>");var g={action:"pwb_admin_migrate_brands",from:d(this).val()};d.post(ajax_object.ajax_url,g,function(h){setTimeout(function(){location.href=ajax_object.brands_url},1000)})}else{}}d(this).val("-")});d("#wc_pwb_admin_tab_tools_dummy_data").on("change",function(){if(d(this).val()!="-"){if(confirm(ajax_object.translations.dummy_data_notice)){d("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>');d(".pwb-modal-inner").html("<p>"+ajax_object.translations.dummy_data+"</p>");var g={action:"pwb_admin_dummy_data",from:d(this).val()};d.post(ajax_object.ajax_url,g,function(h){setTimeout(function(){location.href=ajax_object.brands_url},1000)})}else{}}d(this).val("-")});var f=d("#wc_pwb_admin_tab_tools_system_status").siblings("p");f.addClass("button wc_pwb_admin_tab_status_btn");d(".wc_pwb_admin_tab_status_btn").on("click",function(h){h.preventDefault();if(!d("#wc_pwb_admin_status_result").length){$systemStatusTextarea=d("#wc_pwb_admin_tab_tools_system_status");d('<pre id="wc_pwb_admin_status_result"></pre>').insertAfter($systemStatusTextarea);jQuery("#wc_pwb_admin_status_result").click(function(l){l.preventDefault();var j=d(this)[0];if(d.browser.msie){var i=document.body.createTextRange();i.moveToElementText(j);i.select()}else{if(d.browser.mozilla||d.browser.opera){var k=window.getSelection();var i=document.createRange();i.selectNodeContents(j);k.removeAllRanges();k.addRange(i)}else{if(d.browser.safari){var k=window.getSelection();k.setBaseAndExtent(j,0,j,1)}}}})}d("#wc_pwb_admin_status_result").html('<img src="'+ajax_object.site_url+'/wp-admin/images/spinner.gif" alt="Loading" height="20" width="20">');d("#wc_pwb_admin_status_result").show();var g={action:"pwb_system_status"};jQuery.post(ajaxurl,g,function(i){d("#wc_pwb_admin_status_result").html(i);d("#wc_pwb_admin_status_result").trigger("click")})});d(document).on("click",".pwb-notice-dismissible .notice-dismiss",function(i){i.preventDefault();var g=d(this).closest(".pwb-notice-dismissible").data("notice");var h={action:"dismiss_pwb_notice",notice_name:g};jQuery.post(ajaxurl,h,function(j){})});e();jQuery(document).bind("widget-added",function(h,g){e(g)});jQuery(document).on("widget-updated",function(h,g){e(g)});function e(g){$currentWidget=d(".pwb-select-display-as");if(g!=undefined){$currentWidget=d(".pwb-select-display-as",g)}$currentWidget.on("change",function(){if(d(this).val()=="brand_logo"){d(this).parent().siblings(".pwb-display-as-logo").addClass("show")}else{d(this).parent().siblings(".pwb-display-as-logo").removeClass("show")}})}});
assets/js/functions-frontend.js CHANGED
@@ -1,6 +1,5 @@
1
- jQuery.noConflict();
2
 
3
- jQuery(document).ready(function( $ ) {
4
  $('.pwb-dropdown-widget').on('change',function(){
5
  var href = $(this).find(":selected").val();
6
  location.href = href;
@@ -81,9 +80,7 @@ jQuery(document).ready(function( $ ) {
81
 
82
  /* ··························· Filter by brand widget ··························· */
83
 
84
- var brands = PWBgetUrlParameter('pwb-brand-filter');
85
-
86
- $('.pwb-filter-products button').on( 'click', function(){
87
 
88
  var currentUrl = window.location.href;
89
 
@@ -111,7 +108,12 @@ jQuery(document).ready(function( $ ) {
111
  }
112
  location.href = currentUrl;
113
 
114
- });
 
 
 
 
 
115
 
116
  if(brands!=null){
117
  var brands_array = brands.split(',');
1
+ jQuery( function ( $ ) {
2
 
 
3
  $('.pwb-dropdown-widget').on('change',function(){
4
  var href = $(this).find(":selected").val();
5
  location.href = href;
80
 
81
  /* ··························· Filter by brand widget ··························· */
82
 
83
+ var PWBFilterByBrand = function(){
 
 
84
 
85
  var currentUrl = window.location.href;
86
 
108
  }
109
  location.href = currentUrl;
110
 
111
+ }
112
+
113
+ $('.pwb-filter-products button').on( 'click', function(){ PWBFilterByBrand(); } );
114
+ $('.pwb-filter-products.pwb-hide-submit-btn input').on( 'change', function(){ PWBFilterByBrand(); } );
115
+
116
+ var brands = PWBgetUrlParameter('pwb-brand-filter');
117
 
118
  if(brands!=null){
119
  var brands_array = brands.split(',');
assets/js/functions-frontend.min.js CHANGED
@@ -1 +1 @@
1
- jQuery.noConflict();jQuery(document).ready(function(e){e(".pwb-dropdown-widget").on("change",function(){var f=e(this).find(":selected").val();location.href=f});e(".pwb-carousel").slick({slide:".pwb-slick-slide",infinite:true,draggable:false,prevArrow:'<div class="slick-prev"><span title="Prev">&lt;</span></div>',nextArrow:'<div class="slick-next"><span title="Next">&gt;</span></div>',speed:300,lazyLoad:"progressive",responsive:[{breakpoint:1024,settings:{slidesToShow:4,draggable:true,arrows:false}},{breakpoint:600,settings:{slidesToShow:3,draggable:true,arrows:false}},{breakpoint:480,settings:{slidesToShow:2,draggable:true,arrows:false}}]});e(".pwb-product-carousel").slick({slide:".pwb-slick-slide",infinite:true,draggable:false,prevArrow:'<div class="slick-prev"><span title="Prev">&lt;</span></div>',nextArrow:'<div class="slick-next"><span title="Next">&gt;</span></div>',speed:300,lazyLoad:"progressive",responsive:[{breakpoint:1024,settings:{slidesToShow:3,draggable:true,arrows:false}},{breakpoint:600,settings:{slidesToShow:2,draggable:true,arrows:false}},{breakpoint:480,settings:{slidesToShow:1,draggable:true,arrows:false}}]});var d=PWBgetUrlParameter("pwb-brand-filter");e(".pwb-filter-products button").on("click",function(){var g=window.location.href;var f="";e('.pwb-filter-products input[type="checkbox"]').each(function(h){var i=e(this).prop("checked");if(i){f+=e(this).val();if(e('.pwb-filter-products input[type="checkbox"]').length-1!=h){f+=","}}});g=g.replace(/&?pwb-brand-filter=([^&]$|[^&]*)/i,"");g=g.replace(/\/page\/\d*\//i,"");if(g.indexOf("?")===-1){g=g+"?pwb-brand-filter="+f}else{g=g+"&pwb-brand-filter="+f}location.href=g});if(d!=null){var b=d.split(",");e('.pwb-filter-products input[type="checkbox"]').prop("checked",false);for(var c=0,a=b.length;c<a;c++){e('.pwb-filter-products input[type="checkbox"]').each(function(f){if(e(this).val()){if(b[c]==e(this).val()){e(this).prop("checked",true)}}})}}else{e('.pwb-filter-products input[type="checkbox"]').prop("checked",false)}});var PWBgetUrlParameter=function PWBgetUrlParameter(a){var d=decodeURIComponent(window.location.search.substring(1)),c=d.split("&"),e,b;for(b=0;b<c.length;b++){e=c[b].split("=");if(e[0]===a){return e[1]===undefined?true:e[1]}}};
1
+ jQuery(function(e){e(".pwb-dropdown-widget").on("change",function(){var g=e(this).find(":selected").val();location.href=g});e(".pwb-carousel").slick({slide:".pwb-slick-slide",infinite:true,draggable:false,prevArrow:'<div class="slick-prev"><span title="Prev">&lt;</span></div>',nextArrow:'<div class="slick-next"><span title="Next">&gt;</span></div>',speed:300,lazyLoad:"progressive",responsive:[{breakpoint:1024,settings:{slidesToShow:4,draggable:true,arrows:false}},{breakpoint:600,settings:{slidesToShow:3,draggable:true,arrows:false}},{breakpoint:480,settings:{slidesToShow:2,draggable:true,arrows:false}}]});e(".pwb-product-carousel").slick({slide:".pwb-slick-slide",infinite:true,draggable:false,prevArrow:'<div class="slick-prev"><span title="Prev">&lt;</span></div>',nextArrow:'<div class="slick-next"><span title="Next">&gt;</span></div>',speed:300,lazyLoad:"progressive",responsive:[{breakpoint:1024,settings:{slidesToShow:3,draggable:true,arrows:false}},{breakpoint:600,settings:{slidesToShow:2,draggable:true,arrows:false}},{breakpoint:480,settings:{slidesToShow:1,draggable:true,arrows:false}}]});var f=function(){var h=window.location.href;var g="";e('.pwb-filter-products input[type="checkbox"]').each(function(i){var j=e(this).prop("checked");if(j){g+=e(this).val();if(e('.pwb-filter-products input[type="checkbox"]').length-1!=i){g+=","}}});h=h.replace(/&?pwb-brand-filter=([^&]$|[^&]*)/i,"");h=h.replace(/\/page\/\d*\//i,"");if(h.indexOf("?")===-1){h=h+"?pwb-brand-filter="+g}else{h=h+"&pwb-brand-filter="+g}location.href=h};e(".pwb-filter-products button").on("click",function(){f()});e(".pwb-filter-products.pwb-hide-submit-btn input").on("change",function(){f()});var d=PWBgetUrlParameter("pwb-brand-filter");if(d!=null){var b=d.split(",");e('.pwb-filter-products input[type="checkbox"]').prop("checked",false);for(var c=0,a=b.length;c<a;c++){e('.pwb-filter-products input[type="checkbox"]').each(function(g){if(e(this).val()){if(b[c]==e(this).val()){e(this).prop("checked",true)}}})}}else{e('.pwb-filter-products input[type="checkbox"]').prop("checked",false)}});var PWBgetUrlParameter=function PWBgetUrlParameter(a){var d=decodeURIComponent(window.location.search.substring(1)),c=d.split("&"),e,b;for(b=0;b<c.length;b++){e=c[b].split("=");if(e[0]===a){return e[1]===undefined?true:e[1]}}};
classes/class-perfect-woocommerce-brands.php CHANGED
@@ -74,7 +74,7 @@ class Perfect_Woocommerce_Brands{
74
  */
75
  public function plugin_action_links( $links ) {
76
  $settings_url = esc_url( admin_url( 'admin.php?page=wc-settings&tab=pwb_admin_tab' ) );
77
- $links[] = '<a href="'. $settings_url .'">'.__('Settings','perfect-woocommerce-brands').'</a>';
78
  return $links;
79
  }
80
 
@@ -641,7 +641,7 @@ class Perfect_Woocommerce_Brands{
641
  return $brand_img;
642
  }
643
 
644
- public static function get_brands( $hide_empty = false, $order_by = 'name', $order = 'ASC', $only_featured = false ){
645
  $result = array();
646
 
647
  $brands_args = array( 'hide_empty' => $hide_empty, 'order_by' => $order_by, 'order' => $order );
@@ -649,6 +649,19 @@ class Perfect_Woocommerce_Brands{
649
 
650
  $brands = get_terms('pwb-brand', $brands_args);
651
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  if( is_array($brands) && count($brands)>0 ) $result = $brands;
653
 
654
  return $result;
74
  */
75
  public function plugin_action_links( $links ) {
76
  $settings_url = esc_url( admin_url( 'admin.php?page=wc-settings&tab=pwb_admin_tab' ) );
77
+ array_unshift( $links, '<a href="'. $settings_url .'">'.__('Settings','perfect-woocommerce-brands').'</a>' );
78
  return $links;
79
  }
80
 
641
  return $brand_img;
642
  }
643
 
644
+ public static function get_brands( $hide_empty = false, $order_by = 'name', $order = 'ASC', $only_featured = false, $pwb_term = false ){
645
  $result = array();
646
 
647
  $brands_args = array( 'hide_empty' => $hide_empty, 'order_by' => $order_by, 'order' => $order );
649
 
650
  $brands = get_terms('pwb-brand', $brands_args);
651
 
652
+ foreach( $brands as $key => $brand ){
653
+
654
+ if( $pwb_term ){
655
+ $brands[$key] = new PWB_Term( $brand );
656
+ }else{
657
+ $brand_image_id = get_term_meta($brand->term_id, 'pwb_brand_image', true);
658
+ $brand_banner_id = get_term_meta($brand->term_id, 'pwb_brand_banner', true);
659
+ $brand->brand_image = wp_get_attachment_image_src($brand_image_id);
660
+ $brand->brand_banner = wp_get_attachment_image_src($brand_banner_id);
661
+ }
662
+
663
+ }
664
+
665
  if( is_array($brands) && count($brands)>0 ) $result = $brands;
666
 
667
  return $result;
classes/class-pwb-term.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Perfect_Woocommerce_Brands;
4
+
5
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
6
+
7
+ class PWB_Term{
8
+
9
+ protected $term_obj, $id, $name, $link, $image, $banner, $banner_link, $desc, $slug;
10
+
11
+ function __construct( $term_obj ){
12
+ $this->term_obj = $term_obj;
13
+ $this->is_wp_term();
14
+ }
15
+
16
+ private function is_wp_term(){
17
+ if( is_a( $this->term_obj, 'WP_Term' ) ){
18
+ $this->build_pwb_term( $this->term_obj );
19
+ }else{
20
+ throw new Exception( __('Only WP_Term objects are allowed', 'perfect-woocommerce-brands') );
21
+ }
22
+ }
23
+
24
+ protected function build_pwb_term(){
25
+ $this->id = $this->term_obj->term_id;
26
+ $this->name = $this->term_obj->name;
27
+ $this->slug = $this->term_obj->slug;
28
+ $this->desc = get_term_meta( $this->id, 'pwb_brand_banner_description', true );
29
+ $this->link = get_term_link( $this->term_obj->term_id );
30
+ $this->image = htmlentities( wp_get_attachment_image( get_term_meta( $this->id, 'pwb_brand_image', true ), 'full' ) );
31
+ $this->banner = htmlentities( wp_get_attachment_image( get_term_meta( $this->id, 'pwb_brand_banner', true ), 'full' ) );
32
+ $this->banner_link = get_term_meta( $this->id, 'pwb_brand_banner_link', true) ;
33
+ }
34
+
35
+ public function get( $key = 'id' ){
36
+ return ( isset( $this->$key ) ) ? $this->$key : false;
37
+ }
38
+
39
+ }
classes/shortcodes/class-pwb-all-brands.php CHANGED
@@ -1,130 +1,127 @@
1
  <?php
2
- namespace Perfect_Woocommerce_Brands\Shortcodes;
3
 
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
 
6
- class PWB_All_Brands_Shortcode{
7
 
8
- public static function all_brands_shortcode( $atts ) {
9
 
10
- $atts = shortcode_atts( array(
11
- 'per_page' => "10",
12
- 'image_size' => "thumbnail",
13
- 'hide_empty' => false,
14
- 'order_by' => 'name',
15
- 'order' => 'ASC',
16
- 'title_position' => 'before'
17
- ), $atts, 'pwb-all-brands' );
18
 
19
- $hide_empty = true;
20
- if( $atts['hide_empty'] != 'true' ){
21
- $hide_empty = false;
22
- }
23
 
24
- ob_start();
25
 
26
- $brands = array();
27
- if( $atts['order_by'] == 'rand' ){
28
- $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( $hide_empty );
29
- shuffle( $brands );
30
- }else{
31
- $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( $hide_empty, $atts['order_by'], $atts['order'] );
32
- }
33
 
34
- ?>
35
- <div class="pwb-all-brands">
36
- <?php static::pagination( $brands, $atts['per_page'], $atts['image_size'], $atts['title_position'] );?>
37
- </div>
38
- <?php
39
 
40
- return ob_get_clean();
41
- }
42
 
43
- public static function pagination( $display_array, $show_per_page, $image_size, $title_position ) {
44
- $page = 1;
45
-
46
- if( isset( $_GET['pwb-page'] ) && filter_var( $_GET['pwb-page'], FILTER_VALIDATE_INT ) == true ){
47
- $page = $_GET['pwb-page'];
48
- }
49
-
50
- $page = $page < 1 ? 1 : $page;
51
-
52
- // start position in the $display_array
53
- // +1 is to account for total values.
54
- $start = ($page - 1) * ($show_per_page);
55
- $offset = $show_per_page;
56
-
57
- $outArray = array_slice($display_array, $start, $offset);
58
-
59
- //pagination links
60
- $total_elements = count($display_array);
61
- $pages = ((int)$total_elements / (int)$show_per_page);
62
- $pages = ceil($pages);
63
- if($pages>=1 && $page <= $pages){
64
-
65
- ?>
66
- <div class="pwb-brands-cols-outer">
67
- <?php
68
- foreach($outArray as $brand){
69
- $brand_id = $brand->term_id;
70
- $brand_name = $brand->name;
71
- $brand_link = get_term_link($brand_id);
72
-
73
- $attachment_id = get_term_meta( $brand_id, 'pwb_brand_image', 1 );
74
- $attachment_html = $brand_name;
75
- if($attachment_id!=''){
76
- $attachment_html = wp_get_attachment_image($attachment_id,$image_size);
77
- }
78
-
79
- ?>
80
- <div class="pwb-brands-col3">
81
-
82
- <?php if( $title_position != 'none' && $title_position != 'after' ): ?>
83
- <p>
84
- <?php echo $brand_name;?>
85
- <small>(<?php echo $brand->count;?>)</small>
86
- </p>
87
- <?php endif; ?>
88
-
89
- <div>
90
- <a href="<?php echo $brand_link;?>" title="<?php _e( 'View brand', 'perfect-woocommerce-brands' );?>"><?php echo $attachment_html;?></a>
91
- </div>
92
-
93
- <?php if( $title_position != 'none' && $title_position == 'after' ): ?>
94
- <p>
95
- <?php echo $brand_name;?>
96
- <small>(<?php echo $brand->count;?>)</small>
97
- </p>
98
- <?php endif; ?>
99
-
100
- </div>
101
- <?php
102
- }
103
- ?>
104
- </div>
105
- <?php
106
- $next = $page + 1;
107
- $prev = $page - 1;
108
-
109
- echo '<div class="pwb-pagination-wrapper">';
110
- if($prev>1){
111
- echo '<a href="'.get_the_permalink().'" class="pwb-pagination prev" title="'.__('First page','perfect-woocommerce-brands').'">&laquo;</a>';
112
- }
113
- if($prev>0){
114
- echo '<a href="'.get_the_permalink().'?pwb-page='.$prev.'" class="pwb-pagination last" title="'.__('Previous page','perfect-woocommerce-brands').'">&lsaquo;</a>';
115
- }
116
-
117
- if($next<=$pages){
118
- echo '<a href="'.get_the_permalink().'?pwb-page='.$next.'" class="pwb-pagination first" title="'.__('Next page','perfect-woocommerce-brands').'">&rsaquo;</a>';
119
- }
120
- if($next<$pages){
121
- echo '<a href="'.get_the_permalink().'?pwb-page='.$pages.'" class="pwb-pagination next" title="'.__('Last page','perfect-woocommerce-brands').'">&raquo;</a>';
122
- }
123
- echo '</div>';
124
-
125
- }else{
126
- echo __('No results','perfect-woocommerce-brands');
127
- }
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
 
 
 
1
  <?php
2
+ namespace Perfect_Woocommerce_Brands\Shortcodes;
3
 
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
 
6
+ class PWB_All_Brands_Shortcode{
7
 
8
+ public static function all_brands_shortcode( $atts ) {
9
 
10
+ $atts = shortcode_atts( array(
11
+ 'per_page' => "10",
12
+ 'image_size' => "thumbnail",
13
+ 'hide_empty' => false,
14
+ 'order_by' => 'name',
15
+ 'order' => 'ASC',
16
+ 'title_position' => 'before'
17
+ ), $atts, 'pwb-all-brands' );
18
 
19
+ $hide_empty = ( $atts['hide_empty'] != 'true' ) ? false : true;
 
 
 
20
 
21
+ ob_start();
22
 
23
+ $brands = array();
24
+ if( $atts['order_by'] == 'rand' ){
25
+ $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( $hide_empty );
26
+ shuffle( $brands );
27
+ }else{
28
+ $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( $hide_empty, $atts['order_by'], $atts['order'] );
29
+ }
30
 
31
+ ?>
32
+ <div class="pwb-all-brands">
33
+ <?php static::pagination( $brands, $atts['per_page'], $atts['image_size'], $atts['title_position'] );?>
34
+ </div>
35
+ <?php
36
 
37
+ return ob_get_clean();
38
+ }
39
 
40
+ public static function pagination( $display_array, $show_per_page, $image_size, $title_position ) {
41
+ $page = 1;
42
+
43
+ if( isset( $_GET['pwb-page'] ) && filter_var( $_GET['pwb-page'], FILTER_VALIDATE_INT ) == true ){
44
+ $page = $_GET['pwb-page'];
45
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ $page = $page < 1 ? 1 : $page;
48
+
49
+ // start position in the $display_array
50
+ // +1 is to account for total values.
51
+ $start = ($page - 1) * ($show_per_page);
52
+ $offset = $show_per_page;
53
+
54
+ $outArray = array_slice($display_array, $start, $offset);
55
+
56
+ //pagination links
57
+ $total_elements = count($display_array);
58
+ $pages = ((int)$total_elements / (int)$show_per_page);
59
+ $pages = ceil($pages);
60
+ if($pages>=1 && $page <= $pages){
61
+
62
+ ?>
63
+ <div class="pwb-brands-cols-outer">
64
+ <?php
65
+ foreach($outArray as $brand){
66
+ $brand_id = $brand->term_id;
67
+ $brand_name = $brand->name;
68
+ $brand_link = get_term_link($brand_id);
69
+
70
+ $attachment_id = get_term_meta( $brand_id, 'pwb_brand_image', 1 );
71
+ $attachment_html = $brand_name;
72
+ if($attachment_id!=''){
73
+ $attachment_html = wp_get_attachment_image($attachment_id,$image_size);
74
+ }
75
+
76
+ ?>
77
+ <div class="pwb-brands-col3">
78
+
79
+ <?php if( $title_position != 'none' && $title_position != 'after' ): ?>
80
+ <p>
81
+ <?php echo $brand_name;?>
82
+ <small>(<?php echo $brand->count;?>)</small>
83
+ </p>
84
+ <?php endif; ?>
85
+
86
+ <div>
87
+ <a href="<?php echo $brand_link;?>" title="<?php _e( 'View brand', 'perfect-woocommerce-brands' );?>"><?php echo $attachment_html;?></a>
88
+ </div>
89
+
90
+ <?php if( $title_position != 'none' && $title_position == 'after' ): ?>
91
+ <p>
92
+ <?php echo $brand_name;?>
93
+ <small>(<?php echo $brand->count;?>)</small>
94
+ </p>
95
+ <?php endif; ?>
96
+
97
+ </div>
98
+ <?php
99
  }
100
+ ?>
101
+ </div>
102
+ <?php
103
+ $next = $page + 1;
104
+ $prev = $page - 1;
105
+
106
+ echo '<div class="pwb-pagination-wrapper">';
107
+ if($prev>1){
108
+ echo '<a href="'.get_the_permalink().'" class="pwb-pagination prev" title="'.__('First page','perfect-woocommerce-brands').'">&laquo;</a>';
109
+ }
110
+ if($prev>0){
111
+ echo '<a href="'.get_the_permalink().'?pwb-page='.$prev.'" class="pwb-pagination last" title="'.__('Previous page','perfect-woocommerce-brands').'">&lsaquo;</a>';
112
+ }
113
+
114
+ if($next<=$pages){
115
+ echo '<a href="'.get_the_permalink().'?pwb-page='.$next.'" class="pwb-pagination first" title="'.__('Next page','perfect-woocommerce-brands').'">&rsaquo;</a>';
116
+ }
117
+ if($next<$pages){
118
+ echo '<a href="'.get_the_permalink().'?pwb-page='.$pages.'" class="pwb-pagination next" title="'.__('Last page','perfect-woocommerce-brands').'">&raquo;</a>';
119
+ }
120
+ echo '</div>';
121
+
122
+ }else{
123
+ echo __('No results','perfect-woocommerce-brands');
124
  }
125
+
126
+ }
127
+ }
classes/shortcodes/class-pwb-carousel.php CHANGED
@@ -15,7 +15,8 @@ class PWB_Carousel_Shortcode{
15
  'items_to_scroll' => "1",
16
  'image_size' => "thumbnail",
17
  'autoplay' => "false",
18
- 'arrows' => "false"
 
19
  ), $atts, 'pwb-carousel' );
20
 
21
  return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
@@ -43,9 +44,9 @@ class PWB_Carousel_Shortcode{
43
  $brands = array();
44
  $foreach_i = 0;
45
  if( self::$atts['items'] == 'featured' ){
46
- $brands_array = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( false, 'name', 'ASC', true );
47
  }else{
48
- $brands_array = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands();
49
  }
50
  foreach( $brands_array as $brand ){
51
  if( self::$atts['items'] != 'featured' && $foreach_i >= (int)self::$atts['items'] ) break;
15
  'items_to_scroll' => "1",
16
  'image_size' => "thumbnail",
17
  'autoplay' => "false",
18
+ 'arrows' => "false",
19
+ 'hide_empty' => false
20
  ), $atts, 'pwb-carousel' );
21
 
22
  return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
44
  $brands = array();
45
  $foreach_i = 0;
46
  if( self::$atts['items'] == 'featured' ){
47
+ $brands_array = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( self::$atts['items'], 'name', 'ASC', true );
48
  }else{
49
+ $brands_array = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( self::$atts['items'] );
50
  }
51
  foreach( $brands_array as $brand ){
52
  if( self::$atts['items'] != 'featured' && $foreach_i >= (int)self::$atts['items'] ) break;
classes/widgets/class-pwb-dropdown.php CHANGED
@@ -8,7 +8,7 @@ class PWB_Dropdown_Widget extends \WP_Widget {
8
  function __construct(){
9
  $params = array(
10
  'description' => __( 'Adds a brands dropdown to your site', 'perfect-woocommerce-brands' ),
11
- 'name' => 'PWB: '.__( 'Brands dropdown', 'perfect-woocommerce-brands' )
12
  );
13
  parent::__construct('PWB_Dropdown_Widget', '', $params);
14
  }
@@ -16,7 +16,9 @@ class PWB_Dropdown_Widget extends \WP_Widget {
16
  public function form($instance){
17
  extract($instance);
18
 
 
19
  $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
 
20
  ?>
21
 
22
  <p>
@@ -42,55 +44,49 @@ class PWB_Dropdown_Widget extends \WP_Widget {
42
  </label>
43
  </p>
44
 
 
 
 
 
 
 
 
 
 
 
 
45
  <?php
46
  }
47
 
48
- public function widget($args, $instance){
49
  extract($args);
50
  extract($instance);
51
 
52
- echo $before_widget;
 
 
 
 
 
 
 
53
 
54
- if(!empty($title)) echo $before_title . $title . $after_title;
55
 
56
- $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
57
- $brands_data = $this->get_brands( $hide_empty );
 
58
 
59
- if( !empty( $brands_data ) ){
60
  echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
61
  'dropdown',
62
  'widgets',
63
- array( 'brands' => $brands_data )
64
  );
65
- }else{
66
- echo __( 'There is not available brands', 'perfect-woocommerce-brands' );
67
- }
68
-
69
- echo $after_widget;
70
-
71
- }
72
-
73
- private function get_brands( $hide_empty ){
74
- $brands_data = [];
75
- $brands = get_terms( 'pwb-brand', array( 'hide_empty' => $hide_empty ) );
76
 
77
- $queried_obj = get_queried_object();
78
- $queried_brand_id = ( isset( $queried_obj->term_id ) ) ? $queried_obj->term_id : false;
79
-
80
- if( is_array($brands) && count($brands)>0 ){
81
-
82
- foreach( $brands as $brand ){
83
- $brands_data[] = [
84
- 'name' => $brand->name,
85
- 'link' => get_term_link( $brand ),
86
- 'selected' => ( $brand->term_id == $queried_brand_id ) ? 'selected="selected"' : ''
87
- ];
88
- }
89
 
90
  }
91
 
92
- return $brands_data;
93
-
94
  }
95
 
96
  }
8
  function __construct(){
9
  $params = array(
10
  'description' => __( 'Adds a brands dropdown to your site', 'perfect-woocommerce-brands' ),
11
+ 'name' => __( 'Brands dropdown', 'perfect-woocommerce-brands' )
12
  );
13
  parent::__construct('PWB_Dropdown_Widget', '', $params);
14
  }
16
  public function form($instance){
17
  extract($instance);
18
 
19
+ $title = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : __('Brands', 'perfect-woocommerce-brands');
20
  $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
21
+ $only_featured = ( isset( $only_featured ) && $only_featured == 'on' ) ? true : false;
22
  ?>
23
 
24
  <p>
44
  </label>
45
  </p>
46
 
47
+ <p>
48
+ <input
49
+ type="checkbox"
50
+ id="<?php echo esc_attr( $this->get_field_id('only_featured') ); ?>"
51
+ name="<?php echo esc_attr( $this->get_field_name('only_featured') ); ?>"
52
+ <?php checked( $only_featured ); ?>>
53
+ <label for="<?php echo esc_attr( $this->get_field_id('only_featured') ); ?>">
54
+ <?php echo __( 'Only favorite brands', 'perfect-woocommerce-brands' );?>
55
+ </label>
56
+ </p>
57
+
58
  <?php
59
  }
60
 
61
+ public function widget( $args, $instance ){
62
  extract($args);
63
  extract($instance);
64
 
65
+ $queried_obj = get_queried_object();
66
+ $queried_brand_id = ( isset( $queried_obj->term_id ) ) ? $queried_obj->term_id : false;
67
+
68
+ $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
69
+ $only_featured = ( isset( $only_featured ) && $only_featured == 'on' ) ? true : false;
70
+ $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands(
71
+ $hide_empty, 'name', 'ASC', $only_featured, true
72
+ );
73
 
74
+ if( is_array( $brands ) && count( $brands ) > 0 ){
75
 
76
+ echo $before_widget;
77
+
78
+ if( !empty( $title ) ) echo $before_title . $title . $after_title;
79
 
 
80
  echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
81
  'dropdown',
82
  'widgets',
83
+ array( 'brands' => $brands, 'selected' => $queried_brand_id )
84
  );
 
 
 
 
 
 
 
 
 
 
 
85
 
86
+ echo $after_widget;
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  }
89
 
 
 
90
  }
91
 
92
  }
classes/widgets/class-pwb-filter-by-brand.php CHANGED
@@ -1,146 +1,187 @@
1
  <?php
2
- namespace Perfect_Woocommerce_Brands\Widgets;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
 
6
- class PWB_Filter_By_Brand_Widget extends \WP_Widget {
 
 
7
 
8
- function __construct() {
9
- $params = array(
10
- 'description' => __( 'Recommended for product categories or shop page', 'perfect-woocommerce-brands' ),
11
- 'name' => 'PWB: '.__( 'Filter products by brand', 'perfect-woocommerce-brands' )
12
- );
13
- parent::__construct('PWB_Filter_By_Brand_Widget', '', $params);
14
- }
15
 
16
- public function form( $instance ) {
17
- extract($instance);
18
 
19
- $title = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : __('Brands', 'perfect-woocommerce-brands');
20
- $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
21
- ?>
22
- <p>
23
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
24
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
25
- </p>
26
- <p>
27
- <input
28
- type="checkbox"
29
- id="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>"
30
- name="<?php echo esc_attr( $this->get_field_name('hide_empty') ); ?>"
31
- <?php checked( $hide_empty ); ?>>
32
- <label for="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>">
33
- <?php echo __( 'Hide empty', 'perfect-woocommerce-brands' );?>
34
- </label>
35
- </p>
36
- <?php
37
- }
38
 
39
- public function widget( $args, $instance ) {
40
- extract( $args );
41
- extract( $instance );
42
 
43
- if( !is_tax('pwb-brand') && !is_product() ){
44
- $title = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : __('Brands', 'perfect-woocommerce-brands');
45
- $title = apply_filters( 'widget_title', $title );
 
 
46
 
47
- echo $args['before_widget'];
48
- if ( ! empty( $title ) ) echo $args['before_title'] . $title . $args['after_title'];
49
- $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
50
- $this->render_widget( $hide_empty );
51
- echo $args['after_widget'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
 
 
 
53
 
54
- }
55
-
56
- public function render_widget( $hide_empty ){
57
-
58
- $brands = get_terms('pwb-brand',array(
59
- 'hide_empty' => $hide_empty
60
- ));
61
- $brands_ids = array();
62
- foreach ($brands as $brand) {
63
- $brands_ids[] = $brand->term_id;
64
- }
65
-
66
- $cat = get_queried_object();
67
-
68
- if( is_product_category() ){
69
-
70
- $cat_id = $cat->term_taxonomy_id;
71
- $cat_id_array = get_term_children( $cat_id, 'product_cat' );
72
- $cat_id_array[] = $cat_id;
73
-
74
- $result_brands = array();
75
- $args = array(
76
- 'posts_per_page' => -1,
77
- 'post_type' => 'product',
78
- 'tax_query' => array(
79
- 'relation' => 'AND',
80
- array(
81
- 'taxonomy' => 'product_cat',
82
- 'field' => 'term_id',
83
- 'terms' => $cat_id_array
84
- ),
85
- array(
86
- 'taxonomy' => 'pwb-brand',
87
- 'field' => 'term_id',
88
- 'terms' => $brands_ids
89
- )
90
- )
91
- );
92
-
93
- $the_query = new \WP_Query($args);
94
- if ( $the_query->have_posts() ) {
95
- while ( $the_query->have_posts() ) {
96
- $the_query->the_post();
97
-
98
- $product_brands = wp_get_post_terms(get_the_ID(), 'pwb-brand');
99
-
100
- foreach ($product_brands as $brand) {
101
- $result_brands[] = $brand->term_id;
102
- }
103
-
104
- }
105
- } else {
106
- // no posts found
107
- }
108
- wp_reset_postdata();
109
-
110
- $cate = get_queried_object();
111
- $cateID = $cate->term_id;
112
- $cate_url = get_term_link($cateID);
113
-
114
- }else{
115
- //no product category
116
- $cate_url = get_permalink( wc_get_page_id( 'shop' ));
117
- shuffle($brands_ids);
118
- $result_brands = array_slice($brands_ids, 0, 20);
119
- }
120
-
121
- global $wp;
122
- $current_url = home_url(add_query_arg(array(),$wp->request));
123
-
124
- if( !empty( $result_brands ) ){
125
-
126
- $result_brands = array_unique($result_brands);
127
- $result_brands_ordered = array();
128
- foreach( $result_brands as $brand ){
129
- $brand = get_term($brand);
130
- $result_brands_ordered[$brand->name] = $brand;
131
- }
132
- ksort($result_brands_ordered);
133
-
134
- $result_brands_ordered = apply_filters( 'pwb_widget_brand_filter', $result_brands_ordered );
135
-
136
- echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
137
- 'filter-by-brand',
138
- 'widgets',
139
- array( 'cate_url' => $cate_url, 'brands' => $result_brands_ordered )
140
- );
141
-
142
- }
143
 
144
  }
145
 
146
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ namespace Perfect_Woocommerce_Brands\Widgets;
3
+ use WP_Query;
4
+
5
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
6
+
7
+ class PWB_Filter_By_Brand_Widget extends \WP_Widget {
8
+
9
+ function __construct() {
10
+ $params = array(
11
+ 'description' => __( 'Recommended for product categories or shop page', 'perfect-woocommerce-brands' ),
12
+ 'name' => __( 'Filter products by brand', 'perfect-woocommerce-brands' )
13
+ );
14
+ parent::__construct('PWB_Filter_By_Brand_Widget', '', $params);
15
+ }
16
+
17
+ public function form( $instance ) {
18
+ extract($instance);
19
+
20
+ $title = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : __('Brands', 'perfect-woocommerce-brands');
21
+ $limit = ( isset( $instance[ 'limit' ] ) ) ? $instance[ 'limit' ] : 20;
22
+ $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
23
+ $hide_submit_btn = ( isset( $hide_submit_btn ) && $hide_submit_btn == 'on' ) ? true : false;
24
+ ?>
25
+ <p>
26
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
27
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
28
+ </p>
29
+ <p>
30
+ <label for="<?php echo $this->get_field_id( 'limit' ); ?>">
31
+ <?php echo __( 'Max number of brands', 'perfect-woocommerce-brands' );?>
32
+ </label>
33
+ <input class="widefat" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" />
34
+ </p>
35
+ <p>
36
+ <input
37
+ type="checkbox"
38
+ id="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>"
39
+ name="<?php echo esc_attr( $this->get_field_name('hide_empty') ); ?>"
40
+ <?php checked( $hide_empty ); ?>>
41
+ <label for="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>">
42
+ <?php echo __( 'Hide empty', 'perfect-woocommerce-brands' );?>
43
+ </label>
44
+ </p>
45
+ <p>
46
+ <input
47
+ type="checkbox"
48
+ id="<?php echo esc_attr( $this->get_field_id('hide_submit_btn') ); ?>"
49
+ name="<?php echo esc_attr( $this->get_field_name('hide_submit_btn') ); ?>"
50
+ <?php checked( $hide_submit_btn ); ?>>
51
+ <label for="<?php echo esc_attr( $this->get_field_id('hide_submit_btn') ); ?>">
52
+ <?php echo __( 'Hide filter button', 'perfect-woocommerce-brands' );?>
53
+ </label>
54
+ </p>
55
+ <?php
56
+ }
57
+
58
+ public function update( $new_instance, $old_instance ) {
59
+ $limit = trim( strip_tags( $new_instance['limit'] ) );
60
+ $limit = filter_var( $limit, FILTER_VALIDATE_INT, [ 'options' => [ 'min_range' => 1 ] ] );
61
+
62
+ $instance = array();
63
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : '';
64
+ $instance['limit'] = ( $limit != false ) ? $limit : $old_instance['limit'];
65
+ $instance['hide_empty'] = $new_instance['hide_empty'];
66
+ $instance['hide_submit_btn'] = $new_instance['hide_submit_btn'];
67
+ return $instance;
68
+ }
69
+
70
+ public function widget( $args, $instance ) {
71
+ extract( $args );
72
+ extract( $instance );
73
+
74
+ if( !is_tax('pwb-brand') && !is_product() ){
75
+
76
+ $hide_submit_btn = ( isset( $hide_submit_btn ) && $hide_submit_btn == 'on' ) ? true : false;
77
+ $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
78
+ $brands = get_terms( 'pwb-brand', array( 'hide_empty' => $hide_empty ) );
79
+ $brands_ids = array();
80
+ foreach( $brands as $brand ) $brands_ids[] = $brand->term_id;
81
+
82
+ $show_widget = true;
83
+ $current_products_query = false;
84
+ if( is_product_category() ){
85
+ $current_products_query = $this->current_products_query( $brands_ids );
86
+ if( !$current_products_query->have_posts() ) $show_widget = false;
87
+ }
88
 
89
+ if( $show_widget ){
90
 
91
+ $title = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : __('Brands', 'perfect-woocommerce-brands');
92
+ $title = apply_filters( 'widget_title', $title );
93
+ $limit = ( isset( $instance[ 'limit' ] ) ) ? $instance[ 'limit' ] : 20;
94
 
95
+ echo $args['before_widget'];
96
+ if ( ! empty( $title ) ) echo $args['before_title'] . $title . $args['after_title'];
97
+ $this->render_widget( $current_products_query, $brands_ids, $limit, $hide_submit_btn );
98
+ echo $args['after_widget'];
99
+ }
 
 
100
 
101
+ }
 
102
 
103
+ }
104
+
105
+ public function render_widget( $the_query, $brands_ids, $limit, $hide_submit_btn ){
106
+
107
+ if( is_product_category() ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
+ if( $the_query->have_posts() ) {
110
+ while ( $the_query->have_posts() ) {
111
+ $the_query->the_post();
112
 
113
+ $product_brands = wp_get_post_terms(get_the_ID(), 'pwb-brand');
114
+ foreach ($product_brands as $brand) $result_brands[] = $brand->term_id;
115
+ }
116
+ }
117
+ wp_reset_postdata();
118
 
119
+ $cate = get_queried_object();
120
+ $cateID = $cate->term_id;
121
+ $cate_url = get_term_link($cateID);
122
+
123
+ if( $limit > 0 ) $result_brands = array_slice( $result_brands, 0, $limit );
124
+
125
+ }else{
126
+ //no product category
127
+ $cate_url = get_permalink( wc_get_page_id( 'shop' ));
128
+ $result_brands = $brands_ids;
129
+ if( $limit > 0 ) $result_brands = array_slice( $brands_ids, 0, $limit );
130
+ }
131
+
132
+ global $wp;
133
+ $current_url = home_url(add_query_arg(array(),$wp->request));
134
+
135
+ if( !empty( $result_brands ) ){
136
+
137
+ $result_brands = array_unique($result_brands);
138
+ $result_brands_ordered = array();
139
+ foreach( $result_brands as $brand ){
140
+ $brand = get_term($brand);
141
+ $result_brands_ordered[$brand->name] = $brand;
142
  }
143
+ ksort($result_brands_ordered);
144
+
145
+ $result_brands_ordered = apply_filters( 'pwb_widget_brand_filter', $result_brands_ordered );
146
 
147
+ echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
148
+ 'filter-by-brand',
149
+ 'widgets',
150
+ array( 'cate_url' => $cate_url, 'brands' => $result_brands_ordered, 'hide_submit_btn' => $hide_submit_btn )
151
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
  }
154
 
155
+ }
156
+
157
+ private function current_products_query( $brands_ids ){
158
+
159
+ $cat = get_queried_object();
160
+ $cat_id = $cat->term_taxonomy_id;
161
+ $cat_id_array = get_term_children( $cat_id, 'product_cat' );
162
+ $cat_id_array[] = $cat_id;
163
+
164
+ $result_brands = array();
165
+ $args = array(
166
+ 'posts_per_page' => -1,
167
+ 'post_type' => 'product',
168
+ 'tax_query' => array(
169
+ 'relation' => 'AND',
170
+ array(
171
+ 'taxonomy' => 'product_cat',
172
+ 'field' => 'term_id',
173
+ 'terms' => $cat_id_array
174
+ ),
175
+ array(
176
+ 'taxonomy' => 'pwb-brand',
177
+ 'field' => 'term_id',
178
+ 'terms' => $brands_ids
179
+ )
180
+ )
181
+ );
182
+
183
+ return new WP_Query($args);
184
+
185
+ }
186
+
187
+ }
classes/widgets/class-pwb-list.php CHANGED
@@ -1,120 +1,128 @@
1
  <?php
2
- namespace Perfect_Woocommerce_Brands\Widgets;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
6
- class PWB_List_Widget extends \WP_Widget {
7
-
8
- function __construct(){
9
- $params = array(
10
- 'description' => __( 'Adds a brands list to your site', 'perfect-woocommerce-brands' ),
11
- 'name' => 'PWB: '.__( 'Brands list', 'perfect-woocommerce-brands' )
12
- );
13
- parent::__construct('PWB_List_Widget', '', $params);
14
- }
15
-
16
- public function form($instance){
17
- extract($instance);
18
-
19
- if( !isset( $display_as ) ) $display_as = 'brand_logo';
20
- if( !isset( $columns ) ) $columns = '2';
21
- $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
22
- ?>
23
-
24
- <p>
25
- <label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php echo __( 'Title:', 'perfect-woocommerce-brands' );?></label>
26
- <input
27
- class="widefat"
28
- type="text"
29
- id="<?php echo esc_attr( $this->get_field_id('title') ); ?>"
30
- name="<?php echo esc_attr( $this->get_field_name('title') ); ?>"
31
- value="<?php if(isset($title)) echo esc_attr($title); ?>">
32
- </p>
33
- <p>
34
- <label for="<?php echo esc_attr( $this->get_field_id('display_as') ); ?>"><?php echo __( 'Display as:', 'perfect-woocommerce-brands' );?></label>
35
- <select
36
- class="widefat pwb-select-display-as"
37
- id="<?php echo esc_attr( $this->get_field_id('display_as') ); ?>"
38
- name="<?php echo esc_attr( $this->get_field_name('display_as') ); ?>">
39
- <option value="brand_name" <?php selected( $display_as, 'brand_name' ); ?>><?php _e( 'Brand name', 'perfect-woocommerce-brands' );?></option>
40
- <option value="brand_logo" <?php selected( $display_as, 'brand_logo' ); ?>><?php _e( 'Brand logo', 'perfect-woocommerce-brands' );?></option>
41
- </select>
42
- </p>
43
- <div class="pwb-display-as-logo<?php echo ($display_as=='brand_logo') ? ' show' : '' ;?>">
44
- <p>
45
- <label for="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"><?php echo __( 'Columns:', 'perfect-woocommerce-brands' );?></label>
46
- <select
47
- class="widefat"
48
- id="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"
49
- name="<?php echo esc_attr( $this->get_field_name('columns') ); ?>">
50
- <option value="1" <?php selected( $columns, '1' ); ?>>1</option>
51
- <option value="2" <?php selected( $columns, '2' ); ?>>2</option>
52
- <option value="3" <?php selected( $columns, '3' ); ?>>3</option>
53
- <option value="4" <?php selected( $columns, '4' ); ?>>4</option>
54
- <option value="5" <?php selected( $columns, '5' ); ?>>5</option>
55
- <option value="6" <?php selected( $columns, '6' ); ?>>6</option>
56
- </select>
57
- </p>
58
- </div>
59
- <p>
60
- <input
61
- type="checkbox"
62
- id="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>"
63
- name="<?php echo esc_attr( $this->get_field_name('hide_empty') ); ?>"
64
- <?php checked( $hide_empty ); ?>>
65
- <label for="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>">
66
- <?php echo __( 'Hide empty', 'perfect-woocommerce-brands' );?>
67
- </label>
68
- </p>
69
-
70
- <?php
71
-
72
- }
73
-
74
- public function widget($args, $instance){
75
- extract( $args );
76
- extract( $instance );
77
-
78
- echo $before_widget;
79
-
80
- if( !empty( $title ) ) echo $before_title . $title . $after_title;
81
-
82
- if( !isset( $display_as ) ) $display_as = 'brand_logo';
83
- if( !isset( $columns ) ) $columns = '2';
84
- $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
85
- PWB_List_Widget::get_brands( $display_as, $columns, $hide_empty );
86
-
87
- echo $after_widget;
88
-
89
- }
90
-
91
- private static function get_brands( $display_as, $columns, $hide_empty ){
92
-
93
- $brands = get_terms( 'pwb-brand',array( 'hide_empty' => $hide_empty ) );
94
-
95
- if(is_array($brands) && count($brands)>0){
96
- echo '<ul class="pwb-row">';
97
- foreach ($brands as $brand) {
98
- $brand_name = $brand->name;
99
- $brand_link = get_term_link( $brand->term_id );
100
-
101
- $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
102
- $brand_logo = wp_get_attachment_image( $attachment_id, 'full' );
103
-
104
- $li_class = ( $display_as == 'brand_logo' ) ? "pwb-columns pwb-columns-".$columns : "";
105
- echo '<li class="'. $li_class .'">';
106
- if( $display_as == 'brand_logo' && !empty( $brand_logo ) ){
107
- echo '<a href="'.$brand_link.'" title="'.__( 'Go to', 'perfect-woocommerce-brands' ).' '.$brand->name.'">'.$brand_logo.'</a>';
108
- }else{
109
- echo '<a href="'.$brand_link.'" title="'.__( 'Go to', 'perfect-woocommerce-brands' ).' '.$brand->name.'">'.$brand->name.'</a>';
110
- }
111
- echo '</li>';
112
- }
113
- echo '</ul>';
114
- }else{
115
- echo __( 'There is not available brands', 'perfect-woocommerce-brands' );
116
- }
117
-
118
- }
 
 
 
 
119
 
120
  }
 
 
 
 
1
  <?php
2
+ namespace Perfect_Woocommerce_Brands\Widgets;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
6
+ class PWB_List_Widget extends \WP_Widget {
7
+
8
+ function __construct(){
9
+ $params = array(
10
+ 'description' => __( 'Adds a brands list to your site', 'perfect-woocommerce-brands' ),
11
+ 'name' => __( 'Brands list', 'perfect-woocommerce-brands' )
12
+ );
13
+ parent::__construct('PWB_List_Widget', '', $params);
14
+ }
15
+
16
+ public function form($instance){
17
+ extract($instance);
18
+
19
+ $title = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : __('Brands', 'perfect-woocommerce-brands');
20
+ if( !isset( $display_as ) ) $display_as = 'brand_logo';
21
+ if( !isset( $columns ) ) $columns = '2';
22
+ $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
23
+ $only_featured = ( isset( $only_featured ) && $only_featured == 'on' ) ? true : false;
24
+ $randomize = ( isset( $randomize ) && $randomize == 'on' ) ? true : false;
25
+ ?>
26
+
27
+ <p>
28
+ <label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php echo __( 'Title:', 'perfect-woocommerce-brands' );?></label>
29
+ <input
30
+ class="widefat"
31
+ type="text"
32
+ id="<?php echo esc_attr( $this->get_field_id('title') ); ?>"
33
+ name="<?php echo esc_attr( $this->get_field_name('title') ); ?>"
34
+ value="<?php if(isset($title)) echo esc_attr($title); ?>">
35
+ </p>
36
+ <p>
37
+ <label for="<?php echo esc_attr( $this->get_field_id('display_as') ); ?>"><?php echo __( 'Display as:', 'perfect-woocommerce-brands' );?></label>
38
+ <select
39
+ class="widefat pwb-select-display-as"
40
+ id="<?php echo esc_attr( $this->get_field_id('display_as') ); ?>"
41
+ name="<?php echo esc_attr( $this->get_field_name('display_as') ); ?>">
42
+ <option value="brand_name" <?php selected( $display_as, 'brand_name' ); ?>><?php _e( 'Brand name', 'perfect-woocommerce-brands' );?></option>
43
+ <option value="brand_logo" <?php selected( $display_as, 'brand_logo' ); ?>><?php _e( 'Brand logo', 'perfect-woocommerce-brands' );?></option>
44
+ </select>
45
+ </p>
46
+ <p class="pwb-display-as-logo<?php echo ($display_as=='brand_logo') ? ' show' : '' ;?>">
47
+ <label for="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"><?php echo __( 'Columns:', 'perfect-woocommerce-brands' );?></label>
48
+ <select
49
+ class="widefat"
50
+ id="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"
51
+ name="<?php echo esc_attr( $this->get_field_name('columns') ); ?>">
52
+ <option value="1" <?php selected( $columns, '1' ); ?>>1</option>
53
+ <option value="2" <?php selected( $columns, '2' ); ?>>2</option>
54
+ <option value="3" <?php selected( $columns, '3' ); ?>>3</option>
55
+ <option value="4" <?php selected( $columns, '4' ); ?>>4</option>
56
+ <option value="5" <?php selected( $columns, '5' ); ?>>5</option>
57
+ <option value="6" <?php selected( $columns, '6' ); ?>>6</option>
58
+ </select>
59
+ </p>
60
+ <p>
61
+ <input
62
+ type="checkbox"
63
+ id="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>"
64
+ name="<?php echo esc_attr( $this->get_field_name('hide_empty') ); ?>"
65
+ <?php checked( $hide_empty ); ?>>
66
+ <label for="<?php echo esc_attr( $this->get_field_id('hide_empty') ); ?>">
67
+ <?php echo __( 'Hide empty', 'perfect-woocommerce-brands' );?>
68
+ </label>
69
+ </p>
70
+ <p>
71
+ <input
72
+ type="checkbox"
73
+ id="<?php echo esc_attr( $this->get_field_id('only_featured') ); ?>"
74
+ name="<?php echo esc_attr( $this->get_field_name('only_featured') ); ?>"
75
+ <?php checked( $only_featured ); ?>>
76
+ <label for="<?php echo esc_attr( $this->get_field_id('only_featured') ); ?>">
77
+ <?php echo __( 'Only favorite brands', 'perfect-woocommerce-brands' );?>
78
+ </label>
79
+ </p>
80
+ <p class="pwb-display-as-logo<?php echo ($display_as=='brand_logo') ? ' show' : '' ;?>">
81
+ <input
82
+ type="checkbox"
83
+ id="<?php echo esc_attr( $this->get_field_id('randomize') ); ?>"
84
+ name="<?php echo esc_attr( $this->get_field_name('randomize') ); ?>"
85
+ <?php checked( $randomize ); ?>>
86
+ <label for="<?php echo esc_attr( $this->get_field_id('randomize') ); ?>">
87
+ <?php echo __( 'Randomize', 'perfect-woocommerce-brands' );?>
88
+ </label>
89
+ </p>
90
+
91
+ <?php
92
+ }
93
+
94
+ public function widget( $args, $instance ){
95
+ extract( $args );
96
+ extract( $instance );
97
+
98
+ $hide_empty = ( isset( $hide_empty ) && $hide_empty == 'on' ) ? true : false;
99
+ $only_featured = ( isset( $only_featured ) && $only_featured == 'on' ) ? true : false;
100
+ $randomize = ( isset( $randomize ) && $randomize == 'on' ) ? true : false;
101
+ $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands(
102
+ $hide_empty, 'name', 'ASC', $only_featured, true
103
+ );
104
+ if( isset( $randomize ) && $randomize == 'on' && $display_as == 'brand_logo' ) shuffle( $brands );
105
+
106
+ if( is_array( $brands ) && count( $brands ) > 0 ){
107
+
108
+ echo $before_widget;
109
+
110
+ if( !empty( $title ) ) echo $before_title . $title . $after_title;
111
+
112
+ if( !isset( $display_as ) ) $display_as = 'brand_logo';
113
+ if( !isset( $columns ) ) $columns = '2';
114
+ $li_class = ( $display_as == 'brand_logo' ) ? "pwb-columns pwb-columns-".$columns : "";
115
+
116
+ echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
117
+ ( $display_as == 'brand_logo' ) ? 'list-logo' : 'list',
118
+ 'widgets',
119
+ array( 'brands' => $brands, 'li_class' => $li_class, 'title_prefix' => __( 'Go to', 'perfect-woocommerce-brands' ) )
120
+ );
121
+
122
+ echo $after_widget;
123
 
124
  }
125
+
126
+ }
127
+
128
+ }
main.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Perfect WooCommerce Brands
4
  * Plugin URI: https://wordpress.org/plugins/perfect-woocommerce-brands/
5
  * Description: Perfect WooCommerce Brands allows you to show product brands in your WooCommerce based store.
6
- * Version: 1.6.4
7
  * Author: Alberto de Vera Sevilla
8
  * Author URI: https://profiles.wordpress.org/titodevera/
9
  * Text Domain: perfect-woocommerce-brands
10
  * Domain Path: /lang
11
  * License: GPL3
12
- * Perfect WooCommerce Brands version 1.6.4, Copyright (C) 2018 Alberto de Vera Sevilla
13
  * Perfect WooCommerce Brands is free software: you can redistribute it and/or modify
14
  * it under the terms of the GNU General Public License as published by
15
  * the Free Software Foundation, either version 3 of the License, or
@@ -23,7 +23,7 @@
23
  * along with Perfect WooCommerce Brands. If not, see <http://www.gnu.org/licenses/>.
24
  *
25
  * WC requires at least: 2.4
26
- * WC tested up to: 3.3
27
  */
28
 
29
  namespace Perfect_Woocommerce_Brands;
@@ -34,7 +34,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
34
  define( 'PWB_PLUGIN', plugins_url( '', __FILE__ ) );
35
  define( 'PWB_PLUGIN_PATH', plugin_basename( dirname( __FILE__ ) ) );
36
  define( 'PWB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
37
- define( 'PWB_PLUGIN_VERSION', '1.6.4' );
38
  define( 'PWB_WP_VERSION', get_bloginfo( 'version' ) );
39
  define( 'PWB_WC_VERSION', get_option( 'woocommerce_version' ) );
40
 
@@ -55,6 +55,7 @@ add_action( 'plugins_loaded', function(){
55
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
56
  if( is_plugin_active( 'woocommerce/woocommerce.php' ) ){
57
 
 
58
  require 'classes/widgets/class-pwb-dropdown.php';
59
  require 'classes/widgets/class-pwb-list.php';
60
  require 'classes/widgets/class-pwb-filter-by-brand.php';
3
  * Plugin Name: Perfect WooCommerce Brands
4
  * Plugin URI: https://wordpress.org/plugins/perfect-woocommerce-brands/
5
  * Description: Perfect WooCommerce Brands allows you to show product brands in your WooCommerce based store.
6
+ * Version: 1.6.5
7
  * Author: Alberto de Vera Sevilla
8
  * Author URI: https://profiles.wordpress.org/titodevera/
9
  * Text Domain: perfect-woocommerce-brands
10
  * Domain Path: /lang
11
  * License: GPL3
12
+ * Perfect WooCommerce Brands version 1.6.5, Copyright (C) 2018 Alberto de Vera Sevilla
13
  * Perfect WooCommerce Brands is free software: you can redistribute it and/or modify
14
  * it under the terms of the GNU General Public License as published by
15
  * the Free Software Foundation, either version 3 of the License, or
23
  * along with Perfect WooCommerce Brands. If not, see <http://www.gnu.org/licenses/>.
24
  *
25
  * WC requires at least: 2.4
26
+ * WC tested up to: 3.4
27
  */
28
 
29
  namespace Perfect_Woocommerce_Brands;
34
  define( 'PWB_PLUGIN', plugins_url( '', __FILE__ ) );
35
  define( 'PWB_PLUGIN_PATH', plugin_basename( dirname( __FILE__ ) ) );
36
  define( 'PWB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
37
+ define( 'PWB_PLUGIN_VERSION', '1.6.5' );
38
  define( 'PWB_WP_VERSION', get_bloginfo( 'version' ) );
39
  define( 'PWB_WC_VERSION', get_option( 'woocommerce_version' ) );
40
 
55
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
56
  if( is_plugin_active( 'woocommerce/woocommerce.php' ) ){
57
 
58
+ require 'classes/class-pwb-term.php';
59
  require 'classes/widgets/class-pwb-dropdown.php';
60
  require 'classes/widgets/class-pwb-list.php';
61
  require 'classes/widgets/class-pwb-filter-by-brand.php';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: mailto:hola@albertodevera.es
4
  Tags: woocommerce, brands, brand taxonomy, product brands, woocommerce manufacturer, woocommerce supplier, e-commerce
5
  Requires at least: 4.4
6
  Tested up to: 4.9
7
- Stable tag: 1.6.4
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -78,6 +78,15 @@ Go to `WooCommerce/Settings/` and click on `Brands` tab
78
 
79
 
80
  == Changelog ==
 
 
 
 
 
 
 
 
 
81
  = 1.6.4 =
82
  * Feature: Visual editor with shortcode support added to brand description
83
  * Feature: Hide empty brands in brand widgets
@@ -114,63 +123,3 @@ Go to `WooCommerce/Settings/` and click on `Brands` tab
114
  * Fix: Filter by brand widget fixes
115
  * Fix: Brand description adds description twice
116
  * Other minor bug fixes and code improvements
117
- = 1.5.2 =
118
- * Dev: Adding brands to a products via the REST API + updating namespaces to include v2 (pull request, thanks doekenorg)
119
- = 1.5.1 =
120
- * Fix: Fatal error on old php versions (< 5.5)
121
- = 1.5 =
122
- * Feature (Tool): Install dummy data (generate generic brands and assigns them to available products randomly)
123
- * Feature: Restrict coupon by brands
124
- * Feature: Get system status details for a better plugin support
125
- * Feature: Import brands from "Ultimate WooCommerce Brands"
126
- * Dev: 'pwb_before_single_product_brands' and 'pwb_after_single_product_brands' hooks added
127
- * Dev: Basic WordPress REST API support
128
- * Enhancement: Better HTML markup for the brand banner and the brand description for the archive product page
129
- * Enhancement: Brands importer improvements
130
- * Enhancement: New params for "pwb-all-brands" shortcode
131
- * Fix: The brand description is appearing twice
132
- * Fix: Product filter widget does not seems to work in product category page (thanks hassandad)
133
- * Fix: Support for php 5.3 again
134
- * Fix: Removed ES6 code from admin for better browser support
135
- * Other minor bug fixes and code improvements
136
- = 1.4.5 =
137
- * Fix carousel shortcodes bugs
138
- * WooCommerce 2.7 support
139
- = 1.4.4 =
140
- * Important improvement of the user experience when assigning images to a brand
141
- * Feature (Option): Hide brands in single product, show as image or show as link
142
- * Feature: Hide prev/next arrows on carousel shortcodes
143
- * Feature: Hide empty brands option for "Display all brands" shortcode
144
- * Feature: New options for "Display brands as list" widget
145
- * Fix: Autoplay bug on carousel shortcodes
146
- * Tested on PHP7
147
- * Shortcut to the plugin settings added to the plugin list page
148
- * "Help us" notice added
149
- * Minor code improvements
150
- = 1.4.3 =
151
- * Feature (Widget): Filter products by brand
152
- * Feature (Option): Show brand logo in product loop
153
- * Feature: Brand microdata added to product page
154
- * Feature (Tool): Migrate brands from "YITH WooCommerce Brands Add-on"
155
- = 1.4.2 =
156
- * Fix: Table collapses in "Admin > Products > Brands" (thanks eljkmw)
157
- * Fix: "pwb-brand" shortcode does not display the brand when it has not a logo assigned
158
- = 1.4.1 =
159
- * Feature (Option): Hide brand's description in archive page
160
- * Fix: "pwb-all-brands" and "pwb-brand" show the content before they should
161
- * Clean database on uninstallation
162
- * Minor code improvements and fixes
163
- = 1.4 =
164
- * Feature: Product carousel by brand added
165
- * Minor bug fixes
166
- = 1.3 =
167
- * Feature: If is set, show brand description in brand page
168
- * Feature: Change brands position in single product
169
- = 1.2 =
170
- * Feature: Associate a banner and a link to each brand
171
- * Minor tweaks
172
- * Fully tested on WooCommerce 2.6
173
- = 1.1 =
174
- * Minor bug fixes
175
- = 1.0 =
176
- * Initial release
4
  Tags: woocommerce, brands, brand taxonomy, product brands, woocommerce manufacturer, woocommerce supplier, e-commerce
5
  Requires at least: 4.4
6
  Tested up to: 4.9
7
+ Stable tag: 1.6.5
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
10
 
78
 
79
 
80
  == Changelog ==
81
+ = 1.6.5 =
82
+ * Include icon and banner brand image in api response (thanks @qbig)
83
+ * Feature: New option for show only favorite brands in the dropdown widget and the list widget
84
+ * Feature: New option for configure the max number of brands in filter by brand widget
85
+ * Feature: Filter by brand without submit button
86
+ * Feature: New option for randomize brand logos in the list widget
87
+ * Feature: Hide empty brands in brand carousel
88
+ * Enhancement: Hide widgets when there are no results to show
89
+ * Fix: "Dokan Multivendor Marketplace" JavaScript conflict in admin
90
  = 1.6.4 =
91
  * Feature: Visual editor with shortcode support added to brand description
92
  * Feature: Hide empty brands in brand widgets
123
  * Fix: Filter by brand widget fixes
124
  * Fix: Brand description adds description twice
125
  * Other minor bug fixes and code improvements
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/widgets/dropdown.php CHANGED
@@ -15,8 +15,8 @@
15
  <select class="pwb-dropdown-widget">
16
  <option selected="true" disabled="disabled"><?php _e( 'Brands', 'perfect-woocommerce-brands' ); ?></option>
17
  <?php foreach( $brands as $brand ): ?>
18
- <option value="<?php echo $brand['link'];?>" <?php echo $brand['selected'];?>>
19
- <?php echo $brand['name'];?>
20
  </option>
21
  <?php endforeach; ?>
22
  </select>
15
  <select class="pwb-dropdown-widget">
16
  <option selected="true" disabled="disabled"><?php _e( 'Brands', 'perfect-woocommerce-brands' ); ?></option>
17
  <?php foreach( $brands as $brand ): ?>
18
+ <option value="<?php echo $brand->get('link');?>" <?php selected( $data['selected'], $brand->get('id') );?>>
19
+ <?php echo $brand->get('name');?>
20
  </option>
21
  <?php endforeach; ?>
22
  </select>
templates/widgets/filter-by-brand.php CHANGED
@@ -11,7 +11,7 @@
11
  extract( $data );
12
  ?>
13
 
14
- <div class="pwb-filter-products" data-cat-url="<?php echo $cate_url;?>">
15
  <ul>
16
  <?php foreach( $brands as $brand ): ?>
17
  <li>
@@ -21,5 +21,7 @@
21
  </li>
22
  <?php endforeach; ?>
23
  </ul>
24
- <button><?php _e('Apply filter','perfect-woocommerce-brands') ?></button>
 
 
25
  </div>
11
  extract( $data );
12
  ?>
13
 
14
+ <div class="pwb-filter-products<?php if( $hide_submit_btn ) echo ' pwb-hide-submit-btn'; ?>" data-cat-url="<?php echo $cate_url;?>">
15
  <ul>
16
  <?php foreach( $brands as $brand ): ?>
17
  <li>
21
  </li>
22
  <?php endforeach; ?>
23
  </ul>
24
+ <?php if( !$hide_submit_btn ): ?>
25
+ <button><?php _e('Apply filter','perfect-woocommerce-brands') ?></button>
26
+ <?php endif;?>
27
  </div>
templates/widgets/list-logo.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The template for displaying the list logo widget
4
+ * @version 1.0.0
5
+ */
6
+
7
+ namespace Perfect_Woocommerce_Brands\Templates;
8
+
9
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
10
+
11
+ extract( $data );
12
+ ?>
13
+
14
+ <ul class="pwb-row">
15
+
16
+ <?php foreach( $data['brands'] as $brand ): ?>
17
+
18
+ <li class="<?php echo $data['li_class'];?>">
19
+
20
+ <a href="<?php echo $brand->get('link');?>" title="<?php echo $data['title_prefix'] . ' ' . $brand->get('name'); ?>">
21
+
22
+ <?php if( !empty( html_entity_decode( $brand->get('image') ) ) ): ?>
23
+ <?php echo html_entity_decode( $brand->get('image') ); ?>
24
+ <?php endif; ?>
25
+
26
+ </a>
27
+
28
+ </li>
29
+
30
+ <?php endforeach; ?>
31
+
32
+ </ul>
templates/widgets/list.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The template for displaying the list widget
4
+ * @version 1.0.0
5
+ */
6
+
7
+ namespace Perfect_Woocommerce_Brands\Templates;
8
+
9
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
10
+
11
+ extract( $data );
12
+ ?>
13
+
14
+ <ul class="pwb-row">
15
+
16
+ <?php foreach( $data['brands'] as $brand ): ?>
17
+
18
+ <li>
19
+ <a href="<?php echo $brand->get('link');?>" title="<?php echo $data['title_prefix'] . ' ' . $brand->get('name'); ?>">
20
+ <?php echo $brand->get('name'); ?>
21
+ </a>
22
+ </li>
23
+
24
+ <?php endforeach; ?>
25
+
26
+ </ul>