Perfect Brands for WooCommerce - Version 1.7.7

Version Description

  • Enhancement: Better support for special characters in "AZ-Listing" shortcode
  • Fix: Filter by brand widget shows incorrect brands under certain conditions
  • Fix: Filter by brands in product tags pages and other product taxonomies
  • Update: WC 3.8 compatibility
  • Dev: New filter hook "pwb_text_before_brands_links"
  • Dev: New filter hook "pwb_product_tab_brand_logo_size"
  • Dev: "[pwb-az-listing]" and "[pwb-brand]" templates for theme overrides
Download this release

Release Info

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

Code changes from version 1.7.6 to 1.7.7

assets/css/styles-frontend.css CHANGED
@@ -303,6 +303,15 @@
303
  }
304
  /* ----------------------- /Columns ----------------------- */
305
 
 
 
 
 
 
 
 
 
 
306
  /* ----------------------- Responsive ----------------------- */
307
  @media screen and (max-width: 1000px) {
308
  .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
303
  }
304
  /* ----------------------- /Columns ----------------------- */
305
 
306
+ /* ----------------------- Single product ----------------------- */
307
+ .pwb-single-product-brands{
308
+ padding-top: 1em;
309
+ }
310
+ .pwb-text-before-brands-links{
311
+ margin-right: 10px;
312
+ }
313
+ /* ----------------------- /Single product ----------------------- */
314
+
315
  /* ----------------------- Responsive ----------------------- */
316
  @media screen and (max-width: 1000px) {
317
  .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
assets/css/styles-frontend.min.css CHANGED
@@ -1 +1 @@
1
- .pwb-clearfix:after{content:"";display:table;clear:both}.pwb-before-loop{margin-bottom:1em}.pwb-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-az-listing-row{margin-bottom:20px}.pwb-az-listing-row-in{margin-left:-5px;margin-right:-5px}.pwb-az-listing-col{padding:5px}.pwb-az-listing-col>a{display:block;text-transform:uppercase;white-space:nowrap;overflow:hidden}.pwb-az-listing-title{border-bottom:1px solid #ddd;font-weight:bold;font-size:115%;text-transform:uppercase}.pwb-az-listing-header{margin-bottom:30px}.pwb-az-listing-header ul{margin:0;padding:0;list-style:none;margin-right:-2px;margin-left:-2px}.pwb-az-listing-header li{display:inline-block;float:left;width:25px;height:25px;margin:2px;line-height:25px;border:1px solid #ddd;text-align:center}.pwb-az-listing-header a{text-transform:uppercase}.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%}}@media(min-width:576px){.pwb-az-listing-col{width:50%;float:left}}@media(min-width:992px){.pwb-az-listing-col{width:25%}}
1
+ .pwb-clearfix:after{content:"";display:table;clear:both}.pwb-before-loop{margin-bottom:1em}.pwb-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-az-listing-row{margin-bottom:20px}.pwb-az-listing-row-in{margin-left:-5px;margin-right:-5px}.pwb-az-listing-col{padding:5px}.pwb-az-listing-col>a{display:block;text-transform:uppercase;white-space:nowrap;overflow:hidden}.pwb-az-listing-title{border-bottom:1px solid #ddd;font-weight:bold;font-size:115%;text-transform:uppercase}.pwb-az-listing-header{margin-bottom:30px}.pwb-az-listing-header ul{margin:0;padding:0;list-style:none;margin-right:-2px;margin-left:-2px}.pwb-az-listing-header li{display:inline-block;float:left;width:25px;height:25px;margin:2px;line-height:25px;border:1px solid #ddd;text-align:center}.pwb-az-listing-header a{text-transform:uppercase}.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}.pwb-single-product-brands{padding-top:1em}.pwb-text-before-brands-links{margin-right:10px}@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%}}@media(min-width:576px){.pwb-az-listing-col{width:50%;float:left}}@media(min-width:992px){.pwb-az-listing-col{width:25%}}
classes/class-perfect-woocommerce-brands.php CHANGED
@@ -177,9 +177,9 @@ class Perfect_Woocommerce_Brands{
177
 
178
  public function pwb_brand_filter( $query ){
179
 
180
- if( !empty($_GET['pwb-brand-filter']) ){
181
 
182
- $terms_array = explode(',',$_GET['pwb-brand-filter']);
183
 
184
  //remove invalid terms (security)
185
  for($i=0; $i < count($terms_array); $i++) {
@@ -187,7 +187,7 @@ class Perfect_Woocommerce_Brands{
187
  }
188
 
189
  $filterable_product = false;
190
- if( is_product_category() || is_post_type_archive( 'product' ) )
191
  $filterable_product = true;
192
 
193
  if( $filterable_product && $query->is_main_query() ) {
@@ -616,6 +616,13 @@ class Perfect_Woocommerce_Brands{
616
  do_action( 'pwb_before_single_product_brands', $brands );
617
 
618
  echo '<div class="pwb-single-product-brands pwb-clearfix">';
 
 
 
 
 
 
 
619
  foreach( $brands as $brand ){
620
  $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
621
  $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
177
 
178
  public function pwb_brand_filter( $query ){
179
 
180
+ if( !empty( $_GET['pwb-brand-filter'] ) ){
181
 
182
+ $terms_array = explode( ',', $_GET['pwb-brand-filter'] );
183
 
184
  //remove invalid terms (security)
185
  for($i=0; $i < count($terms_array); $i++) {
187
  }
188
 
189
  $filterable_product = false;
190
+ if( is_product_taxonomy() || is_post_type_archive( 'product' ) )
191
  $filterable_product = true;
192
 
193
  if( $filterable_product && $query->is_main_query() ) {
616
  do_action( 'pwb_before_single_product_brands', $brands );
617
 
618
  echo '<div class="pwb-single-product-brands pwb-clearfix">';
619
+
620
+ if( $show_as == 'brand_link' ){
621
+ echo '<span class="pwb-text-before-brands-links">';
622
+ echo apply_filters( 'pwb_text_before_brands_links', __('Brands', 'perfect-woocommerce-brands') );
623
+ echo ':</span>';
624
+ }
625
+
626
  foreach( $brands as $brand ){
627
  $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
628
  $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
classes/class-pwb-api-support.php CHANGED
@@ -52,7 +52,7 @@ class PWB_API_Support{
52
  public function create_brand( $request ){
53
  $new_brand = wp_insert_term( $request['name'], 'pwb-brand', array( 'slug' => $request['slug'], 'description' => $request['description'] ) );
54
  if( !is_wp_error( $new_brand ) ){
55
- return true;
56
  }else{
57
  return $new_brand;
58
  }
52
  public function create_brand( $request ){
53
  $new_brand = wp_insert_term( $request['name'], 'pwb-brand', array( 'slug' => $request['slug'], 'description' => $request['description'] ) );
54
  if( !is_wp_error( $new_brand ) ){
55
+ return array('id' => $new_brand['term_id'], 'name' => $request['name'], 'slug' => $request['slug'], 'description' => $request['description']);
56
  }else{
57
  return $new_brand;
58
  }
classes/class-pwb-product-tab.php CHANGED
@@ -46,7 +46,7 @@ class PWB_Product_Tab{
46
 
47
  <?php
48
  $brand_logo = get_term_meta( $brand->term_id, 'pwb_brand_image', true );
49
- $brand_logo = wp_get_attachment_image( $brand_logo, 'thumbnail' );
50
  ?>
51
 
52
  <div id="tab-pwb_tab-content">
46
 
47
  <?php
48
  $brand_logo = get_term_meta( $brand->term_id, 'pwb_brand_image', true );
49
+ $brand_logo = wp_get_attachment_image( $brand_logo, apply_filters( 'pwb_product_tab_brand_logo_size', 'thumbnail' ) );
50
  ?>
51
 
52
  <div id="tab-pwb_tab-content">
classes/shortcodes/class-pwb-az-listing.php CHANGED
@@ -10,88 +10,24 @@ class PWB_AZ_Listing_Shortcode{
10
 
11
  $atts = shortcode_atts( array(), $atts, 'pwb-az-listing' );
12
 
13
- ob_start();
14
-
15
  $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( true, 'name', 'ASC' );
16
  $grouped_brands = array();
17
 
18
- $letter = null;
19
  foreach( $brands as $brand ){
20
- if( $letter != $brand->name[0] ) $letter = $brand->name[0];
21
- $letter = strtolower( self::replace_specials_characters( $letter ) );
22
- $grouped_brands[$letter][] = $brand;
23
  }
24
 
25
- //navigation
26
- if( !empty( $grouped_brands ) ):
27
- ?>
28
- <div class="pwb-az-listing">
29
-
30
- <div class="pwb-az-listing-header">
31
- <ul class="pwb-clearfix">
32
- <?php
33
- foreach( $grouped_brands as $letter => $brand_group ):
34
- ?>
35
- <li><a href="#pwb-az-listing-<?php echo $letter;?>"><?php echo $letter;?></a></li>
36
- <?php
37
- endforeach;
38
- ?>
39
- </ul>
40
- </div>
41
-
42
- <div class="pwb-az-listing-content">
43
- <?php
44
-
45
- foreach( $grouped_brands as $letter => $brand_group ):
46
- ?>
47
- <div id="pwb-az-listing-<?php echo $letter;?>" class="pwb-az-listing-row pwb-clearfix">
48
- <p class="pwb-az-listing-title"><?php echo $letter;?></p>
49
- <div class="pwb-az-listing-row-in">
50
- <?php
51
- foreach( $brand_group as $brand ):
52
- $has_products = self::has_products( $brand->term_id );
53
- if( !empty( $has_products ) ):
54
- ?>
55
- <div class="pwb-az-listing-col">
56
- <a href="<?php echo get_term_link($brand->term_id);?>"><?php echo $brand->name;?></a>
57
- </div>
58
- <?php
59
- endif;
60
- endforeach;
61
- ?>
62
- </div>
63
- </div>
64
- <?php
65
- endforeach;
66
-
67
- ?>
68
- </div>
69
-
70
- </div>
71
- <?php
72
-
73
- endif;
74
-
75
- return ob_get_clean();
76
 
77
  }
78
 
79
- protected static function replace_specials_characters($s){
80
- $s = preg_replace("/á|à|â|ã|ª/","a",$s);
81
- $s = preg_replace("/Á|À|Â|Ã/","A",$s);
82
- $s = preg_replace("/é|è|ê/","e",$s);
83
- $s = preg_replace("/É|È|Ê/","E",$s);
84
- $s = preg_replace("/í|ì|î/","i",$s);
85
- $s = preg_replace("/Í|Ì|Î/","I",$s);
86
- $s = preg_replace("/ó|ò|ô|õ|º/","o",$s);
87
- $s = preg_replace("/Ó|Ò|Ô|Õ/","O",$s);
88
- $s = preg_replace("/ú|ù|û/","u",$s);
89
- $s = preg_replace("/Ú|Ù|Û/","U",$s);
90
-
91
- $s = preg_replace('/[^a-zA-Z0-9_.-]/', '', $s);
92
- return $s;
93
- }
94
-
95
  private static function has_products( $brand_id ){
96
 
97
  $args = array(
10
 
11
  $atts = shortcode_atts( array(), $atts, 'pwb-az-listing' );
12
 
 
 
13
  $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( true, 'name', 'ASC' );
14
  $grouped_brands = array();
15
 
 
16
  foreach( $brands as $brand ){
17
+ $letter = mb_substr( htmlspecialchars_decode( $brand->name ), 0, 1 );
18
+ $letter = strtolower( $letter );
19
+ $grouped_brands[$letter][] = [ 'brand_term' => $brand, 'has_products' => self::has_products( $brand->term_id ) ];
20
  }
21
 
22
+ return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
23
+ 'az-listing',
24
+ 'shortcodes',
25
+ array( 'grouped_brands' => $grouped_brands ),
26
+ false
27
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  private static function has_products( $brand_id ){
32
 
33
  $args = array(
classes/shortcodes/class-pwb-brand.php CHANGED
@@ -8,37 +8,25 @@ class PWB_Brand_Shortcode{
8
  public static function brand_shortcode( $atts ) {
9
  $atts = shortcode_atts( array(
10
  'product_id' => null,
11
- 'image_size' => 'thumbnail'
 
12
  ), $atts, 'pwb-brand' );
13
 
14
- ob_start();
15
-
16
  if( !$atts['product_id'] && is_singular('product') ) $atts['product_id'] = get_the_ID();
17
 
18
  $brands = wp_get_post_terms( $atts['product_id'], 'pwb-brand');
19
 
20
- if( !is_wp_error($brands) && !empty($brands) ){
21
-
22
- echo '<div class="pwb-brand-shortcode">';
23
-
24
- foreach( $brands as $brand ){
25
- $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
26
- $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
27
-
28
- $attachment_html = wp_get_attachment_image($attachment_id,$atts['image_size']);
29
-
30
- if(!empty($attachment_html)){
31
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
32
- }else{
33
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$brand->name.'</a>';
34
- }
35
- }
36
-
37
- echo '</div>';
38
-
39
  }
40
 
41
- return ob_get_clean();
 
 
 
 
 
42
 
43
  }
44
 
8
  public static function brand_shortcode( $atts ) {
9
  $atts = shortcode_atts( array(
10
  'product_id' => null,
11
+ 'as_link' => false,
12
+ 'image_size' => 'thumbnail',
13
  ), $atts, 'pwb-brand' );
14
 
 
 
15
  if( !$atts['product_id'] && is_singular('product') ) $atts['product_id'] = get_the_ID();
16
 
17
  $brands = wp_get_post_terms( $atts['product_id'], 'pwb-brand');
18
 
19
+ foreach( $brands as $key => $brand ){
20
+ $brands[$key]->term_link = get_term_link ( $brand->term_id, 'pwb-brand' );
21
+ $brands[$key]->image = wp_get_attachment_image( get_term_meta( $brand->term_id, 'pwb_brand_image', 1 ), $atts['image_size'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
+ return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
25
+ 'brand',
26
+ 'shortcodes',
27
+ array( 'brands' => $brands, 'as_link' => $atts['as_link'] ),
28
+ false
29
+ );
30
 
31
  }
32
 
classes/widgets/class-pwb-filter-by-brand.php CHANGED
@@ -65,7 +65,7 @@ class PWB_Filter_By_Brand_Widget extends \WP_Widget {
65
 
66
  $show_widget = true;
67
  $current_products = false;
68
- if( is_product_category() || is_shop() ){
69
  $current_products = $this->current_products_query();
70
  if( empty( $current_products ) ) $show_widget = false;
71
  }
@@ -90,7 +90,7 @@ class PWB_Filter_By_Brand_Widget extends \WP_Widget {
90
 
91
  $result_brands = array();
92
 
93
- if( is_product_category() || is_shop() ){
94
 
95
  if( !empty( $current_products ) ) $result_brands = $this->get_products_brands( $current_products );
96
 
@@ -151,11 +151,11 @@ class PWB_Filter_By_Brand_Widget extends \WP_Widget {
151
 
152
  $cat = get_queried_object();
153
  if( is_a( $cat, 'WP_Term' ) ){
154
- $cat_id = $cat->term_taxonomy_id;
155
- $cat_id_array = get_term_children( $cat_id, 'product_cat' );
156
  $cat_id_array[] = $cat_id;
157
  $args['tax_query'][] = array(
158
- 'taxonomy' => 'product_cat',
159
  'field' => 'term_id',
160
  'terms' => $cat_id_array
161
  );
65
 
66
  $show_widget = true;
67
  $current_products = false;
68
+ if( is_product_taxonomy() || is_shop() ){
69
  $current_products = $this->current_products_query();
70
  if( empty( $current_products ) ) $show_widget = false;
71
  }
90
 
91
  $result_brands = array();
92
 
93
+ if( is_product_taxonomy() || is_shop() ){
94
 
95
  if( !empty( $current_products ) ) $result_brands = $this->get_products_brands( $current_products );
96
 
151
 
152
  $cat = get_queried_object();
153
  if( is_a( $cat, 'WP_Term' ) ){
154
+ $cat_id = $cat->term_id;
155
+ $cat_id_array = get_term_children( $cat_id, $cat->taxonomy );
156
  $cat_id_array[] = $cat_id;
157
  $args['tax_query'][] = array(
158
+ 'taxonomy' => $cat->taxonomy,
159
  'field' => 'term_id',
160
  'terms' => $cat_id_array
161
  );
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.7.6
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.7.6, Copyright (C) 2019 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: 3.1.0
26
- * WC tested up to: 3.6
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.7.6' );
38
  define( 'PWB_WP_VERSION', get_bloginfo( 'version' ) );
39
  define( 'PWB_WC_VERSION', get_option( 'woocommerce_version' ) );
40
 
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.7.7
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.7.7, Copyright (C) 2019 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: 3.1.0
26
+ * WC tested up to: 3.8
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.7.7' );
38
  define( 'PWB_WP_VERSION', get_bloginfo( 'version' ) );
39
  define( 'PWB_WC_VERSION', get_option( 'woocommerce_version' ) );
40
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, brands, brand taxonomy, product brands, woocommerce manufactu
5
  Requires at least: 4.7
6
  Tested up to: 5.2
7
  Requires PHP: 5.6
8
- Stable tag: 1.7.6
9
  License: GPL3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
11
 
@@ -20,7 +20,6 @@ With this extension you can add product brands to your WooCommerce site.
20
  > * PHP 5.6 or higher (PHP7 recommended)
21
  > * WordPress 4.7 or higher
22
  > * WooCommerce 3.1.0 or higher
23
- > * Visual Composer (recommended)
24
 
25
  = Features =
26
  > * Very easy to use, 100% free, no ads, no premium version exists
@@ -47,6 +46,7 @@ With this extension you can add product brands to your WooCommerce site.
47
  > * Brand tab for single product page
48
  > * Favorite brands
49
  > * Brands json import/export
 
50
  > * And much more!
51
 
52
 
@@ -81,6 +81,14 @@ You can also contribute [translating the plugin](https://translate.wordpress.org
81
 
82
 
83
  == Changelog ==
 
 
 
 
 
 
 
 
84
  = 1.7.6 =
85
  * Tested up to, bump
86
  * Dev: New filter hook "woocommerce_product_brand_heading" for editing the "Brand" tab heading
5
  Requires at least: 4.7
6
  Tested up to: 5.2
7
  Requires PHP: 5.6
8
+ Stable tag: 1.7.7
9
  License: GPL3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
11
 
20
  > * PHP 5.6 or higher (PHP7 recommended)
21
  > * WordPress 4.7 or higher
22
  > * WooCommerce 3.1.0 or higher
 
23
 
24
  = Features =
25
  > * Very easy to use, 100% free, no ads, no premium version exists
46
  > * Brand tab for single product page
47
  > * Favorite brands
48
  > * Brands json import/export
49
+ > * Brand structured data
50
  > * And much more!
51
 
52
 
81
 
82
 
83
  == Changelog ==
84
+ = 1.7.7 =
85
+ * Enhancement: Better support for special characters in "AZ-Listing" shortcode
86
+ * Fix: Filter by brand widget shows incorrect brands under certain conditions
87
+ * Fix: Filter by brands in product tags pages and other product taxonomies
88
+ * Update: WC 3.8 compatibility
89
+ * Dev: New filter hook "pwb_text_before_brands_links"
90
+ * Dev: New filter hook "pwb_product_tab_brand_logo_size"
91
+ * Dev: "[pwb-az-listing]" and "[pwb-brand]" templates for theme overrides
92
  = 1.7.6 =
93
  * Tested up to, bump
94
  * Dev: New filter hook "woocommerce_product_brand_heading" for editing the "Brand" tab heading
templates/shortcodes/az-listing.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The template for displaying the a-z Listing
4
+ * @version 1.0.0
5
+ */
6
+
7
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
8
+ ?>
9
+
10
+ <?php if( !empty( $grouped_brands ) ): ?>
11
+
12
+ <div class="pwb-az-listing">
13
+
14
+ <div class="pwb-az-listing-header">
15
+
16
+ <ul class="pwb-clearfix">
17
+
18
+ <?php foreach( $grouped_brands as $letter => $brand_group ): ?>
19
+ <li><a href="#pwb-az-listing-<?php echo $letter;?>"><?php echo $letter;?></a></li>
20
+ <?php endforeach; ?>
21
+
22
+ </ul>
23
+
24
+ </div>
25
+
26
+ <div class="pwb-az-listing-content">
27
+
28
+ <?php foreach( $grouped_brands as $letter => $brand_group ): ?>
29
+
30
+ <div id="pwb-az-listing-<?php echo $letter;?>" class="pwb-az-listing-row pwb-clearfix">
31
+ <p class="pwb-az-listing-title"><?php echo $letter;?></p>
32
+ <div class="pwb-az-listing-row-in">
33
+
34
+ <?php foreach( $brand_group as $brand ): ?>
35
+
36
+ <?php if( !empty( $brand['has_products'] ) ): ?>
37
+
38
+ <div class="pwb-az-listing-col">
39
+ <a href="<?php echo get_term_link($brand['brand_term']->term_id);?>">
40
+ <?php echo $brand['brand_term']->name;?>
41
+ </a>
42
+ </div>
43
+
44
+ <?php endif;?>
45
+
46
+ <?php endforeach; ?>
47
+
48
+ </div>
49
+ </div>
50
+
51
+ <?php endforeach; ?>
52
+
53
+ </div>
54
+
55
+ </div>
56
+
57
+ <?php endif; ?>
templates/shortcodes/brand.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The template for displaying the "pwb-brand" shortcode
4
+ * @version 1.0.0
5
+ */
6
+
7
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
8
+ ?>
9
+
10
+ <?php if( !empty( $brands ) ): ?>
11
+
12
+ <div class="pwb-brand-shortcode">
13
+
14
+ <?php foreach( $brands as $brand ): ?>
15
+
16
+ <a href="<?php echo $brand->term_link;?>" title="<?php _e( 'View brand', 'perfect-woocommerce-brands' );?>">
17
+
18
+ <?php if( !$as_link && !empty( $brand->image ) ): ?>
19
+
20
+ <?php echo $brand->image;?>
21
+
22
+ <?php else: ?>
23
+
24
+ <?php echo $brand->name;?>
25
+
26
+ <?php endif; ?>
27
+
28
+ </a>
29
+
30
+ <?php endforeach; ?>
31
+
32
+ </div>
33
+
34
+ <?php endif; ?>