Perfect Brands for WooCommerce - Version 1.7.4

Version Description

  • Fix: Mismatched columns when a brand is added
  • Tweak: Disable brand tab when product not have brand
  • Dev: New filter hook 'pwb_dropdown_placeholder'
  • Dev: New filter hooks 'pwb_carousel_prev' and 'pwb_carousel_next' for customize the carousel arrows
  • Dev: Override templates via a theme
  • Minor fixes and tweaks
Download this release

Release Info

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

Code changes from version 1.7.3 to 1.7.4

assets/css/styles-admin.css CHANGED
@@ -57,7 +57,6 @@
57
  }
58
  .taxonomy-pwb-brand table.wp-list-table .column-featured{
59
  width: 48px;
60
- text-align: center;
61
  }
62
  .taxonomy-pwb-brand .pwb-edit-brands-bottom{
63
  margin-top: 20px;
@@ -104,6 +103,13 @@
104
  width: 0!important;
105
  display: none!important;
106
  }
 
 
 
 
 
 
 
107
  }
108
  .pwb-brands-exporter{
109
  margin-top: 20px;
@@ -114,6 +120,10 @@
114
  .pwb-brands-exporter p{
115
  font-style: italic;
116
  }
 
 
 
 
117
  /* ----------------------- /Taxonomy pwb-brand ----------------------- */
118
 
119
  /* ----------------------- Settings page ----------------------- */
57
  }
58
  .taxonomy-pwb-brand table.wp-list-table .column-featured{
59
  width: 48px;
 
60
  }
61
  .taxonomy-pwb-brand .pwb-edit-brands-bottom{
62
  margin-top: 20px;
103
  width: 0!important;
104
  display: none!important;
105
  }
106
+ .taxonomy-pwb-brand table.wp-list-table .column-featured,
107
+ .taxonomy-pwb-brand .wp-list-table .column-logo{
108
+ text-align: center;
109
+ }
110
+ .taxonomy-pwb-brand .pwb-featured-col-title{
111
+ display: none;
112
+ }
113
  }
114
  .pwb-brands-exporter{
115
  margin-top: 20px;
120
  .pwb-brands-exporter p{
121
  font-style: italic;
122
  }
123
+ .taxonomy-pwb-brand .wp-list-table .column-logo{
124
+ width: 52px;
125
+ white-space: nowrap;
126
+ }
127
  /* ----------------------- /Taxonomy pwb-brand ----------------------- */
128
 
129
  /* ----------------------- Settings page ----------------------- */
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}}.pwb-brands-exporter{margin-top:20px;padding-top:20px;border-top:1px solid #ddd;text-align:right}.pwb-brands-exporter p{font-style:italic}#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}}@keyframes PWBLoadingOverlay{to{transform:rotate(360deg)}}.pwb-loading-overlay{position:relative}.pwb-loading-overlay::after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(255,255,255,.7);z-index:1}.pwb-loading-overlay::before{content:"";position:absolute;box-sizing:border-box;top:50%;left:50%;width:15px;height:15px;margin-top:-7.5px;margin-left:-7.5px;border-radius:50%;border-top:2px solid #000;border-right:2px solid transparent;animation:PWBLoadingOverlay .6s linear infinite;z-index:1}input.pwb-brands-import-file{display:none!important}
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}.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}.taxonomy-pwb-brand table.wp-list-table .column-featured,.taxonomy-pwb-brand .wp-list-table .column-logo{text-align:center}.taxonomy-pwb-brand .pwb-featured-col-title{display:none}}.pwb-brands-exporter{margin-top:20px;padding-top:20px;border-top:1px solid #ddd;text-align:right}.pwb-brands-exporter p{font-style:italic}.taxonomy-pwb-brand .wp-list-table .column-logo{width:52px;white-space:nowrap}#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}}@keyframes PWBLoadingOverlay{to{transform:rotate(360deg)}}.pwb-loading-overlay{position:relative}.pwb-loading-overlay::after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(255,255,255,.7);z-index:1}.pwb-loading-overlay::before{content:"";position:absolute;box-sizing:border-box;top:50%;left:50%;width:15px;height:15px;margin-top:-7.5px;margin-left:-7.5px;border-radius:50%;border-top:2px solid #000;border-right:2px solid transparent;animation:PWBLoadingOverlay .6s linear infinite;z-index:1}input.pwb-brands-import-file{display:none!important}
assets/js/functions-frontend.js CHANGED
@@ -11,8 +11,8 @@ jQuery( function ( $ ) {
11
  slide: '.pwb-slick-slide',
12
  infinite: true,
13
  draggable: false,
14
- prevArrow: '<div class="slick-prev"><span title="Prev">&lt;</span></div>',
15
- nextArrow: '<div class="slick-next"><span title="Next">&gt;</span></div>',
16
  speed: 300,
17
  lazyLoad: 'progressive',
18
  responsive: [
@@ -47,8 +47,8 @@ jQuery( function ( $ ) {
47
  slide: '.pwb-slick-slide',
48
  infinite: true,
49
  draggable: false,
50
- prevArrow: '<div class="slick-prev"><span title="Prev">&lt;</span></div>',
51
- nextArrow: '<div class="slick-next"><span title="Next">&gt;</span></div>',
52
  speed: 300,
53
  lazyLoad: 'progressive',
54
  responsive: [
11
  slide: '.pwb-slick-slide',
12
  infinite: true,
13
  draggable: false,
14
+ prevArrow: '<div class="slick-prev"><span>'+ajax_object.carousel_prev+'</span></div>',
15
+ nextArrow: '<div class="slick-next"><span>'+ajax_object.carousel_next+'</span></div>',
16
  speed: 300,
17
  lazyLoad: 'progressive',
18
  responsive: [
47
  slide: '.pwb-slick-slide',
48
  infinite: true,
49
  draggable: false,
50
+ prevArrow: '<div class="slick-prev"><span>'+ajax_object.carousel_prev+'</span></div>',
51
+ nextArrow: '<div class="slick-next"><span>'+ajax_object.carousel_next+'</span></div>',
52
  speed: 300,
53
  lazyLoad: 'progressive',
54
  responsive: [
assets/js/functions-frontend.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){e(".pwb-dropdown-widget").on("change",function(){var g=e(this).find(":selected").val();location.href=g});if(typeof e.fn.slick==="function"){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=[location.protocol,"//",location.host,location.pathname].join("");var i=window.location.href;var g=[];e('.pwb-filter-products input[type="checkbox"]').each(function(j){if(e(this).prop("checked")){g.push(e(this).val())}});g=g.join();if(g){i=i.replace(/&?pwb-brand-filter=([^&]$|[^&]*)/i,"");i=i.replace(/\/page\/\d*\//i,"");if(i.indexOf("?")===-1){i=i+"?pwb-brand-filter="+g}else{i=i+"&pwb-brand-filter="+g}}else{i=h}location.href=i};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]}}};
1
+ jQuery(function(e){e(".pwb-dropdown-widget").on("change",function(){var g=e(this).find(":selected").val();location.href=g});if(typeof e.fn.slick==="function"){e(".pwb-carousel").slick({slide:".pwb-slick-slide",infinite:true,draggable:false,prevArrow:'<div class="slick-prev"><span>'+ajax_object.carousel_prev+"</span></div>",nextArrow:'<div class="slick-next"><span>'+ajax_object.carousel_next+"</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>'+ajax_object.carousel_prev+"</span></div>",nextArrow:'<div class="slick-next"><span>'+ajax_object.carousel_next+"</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=[location.protocol,"//",location.host,location.pathname].join("");var i=window.location.href;var g=[];e('.pwb-filter-products input[type="checkbox"]').each(function(j){if(e(this).prop("checked")){g.push(e(this).val())}});g=g.join();if(g){i=i.replace(/&?pwb-brand-filter=([^&]$|[^&]*)/i,"");i=i.replace(/\/page\/\d*\//i,"");if(i.indexOf("?")===-1){i=i+"?pwb-brand-filter="+g}else{i=i+"&pwb-brand-filter="+g}}else{i=h}location.href=i};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/admin/class-edit-brands-page.php CHANGED
@@ -64,39 +64,36 @@ class Edit_Brands_Page {
64
 
65
  }
66
 
67
- public function brand_taxonomy_columns_head($defaults) {
 
68
 
69
- if( self::is_edit_brands_page() ){
70
- $defaults['featured'] = '';
71
-
72
- $newColumns = array(
73
- 'cb' => $defaults['cb'],
74
- 'logo' => __( 'Logo', 'perfect-woocommerce-brands' )
75
- );
76
 
77
- unset( $defaults['description'] );
78
- unset( $defaults['cb'] );
79
 
80
- return array_merge( $newColumns, $defaults );
81
- }
82
- return $defaults;
83
 
 
84
  }
85
 
86
  public function brand_taxonomy_columns($c, $column_name, $term_id){
87
- switch( $column_name ){
88
- case 'logo':
89
- $image = wp_get_attachment_image( get_term_meta( $term_id, 'pwb_brand_image', 1 ), array('60','60') );
90
- return ( $image ) ? $image : "-";
91
- break;
92
- case 'featured':
93
- $featured_class = ( $this->is_featured_brand( $term_id ) ) ? 'dashicons-star-filled' : 'dashicons-star-empty';
94
- printf(
95
- '<span class="dashicons %1$s" title="%2$s" data-brand-id="%3$s"></span>',
96
- $featured_class, __('Set as featured', 'perfect-woocommerce-brands'), $term_id
97
- );
98
- break;
99
- }
100
  }
101
 
102
  private function is_featured_brand( $brand_id ){
64
 
65
  }
66
 
67
+ public function brand_taxonomy_columns_head( $columns ){
68
+ $new_columns = array();
69
 
70
+ if ( isset( $columns['cb'] ) ) {
71
+ $new_columns['cb'] = $columns['cb'];
72
+ unset( $columns['cb'] );
73
+ }
 
 
 
74
 
75
+ if( isset( $columns['description'] ) ) unset( $columns['description'] );
 
76
 
77
+ $new_columns['logo'] = __( 'Logo', 'perfect-woocommerce-brands' );
78
+ $columns['featured'] = '<span class="pwb-featured-col-title">'.__( 'Featured', 'perfect-woocommerce-brands' ).'</span>';
 
79
 
80
+ return array_merge( $new_columns, $columns );
81
  }
82
 
83
  public function brand_taxonomy_columns($c, $column_name, $term_id){
84
+ switch( $column_name ){
85
+ case 'logo':
86
+ $image = wp_get_attachment_image( get_term_meta( $term_id, 'pwb_brand_image', 1 ), array('40','40') );
87
+ return ( $image ) ? $image : wc_placeholder_img( array('40','40') );
88
+ break;
89
+ case 'featured':
90
+ $featured_class = ( $this->is_featured_brand( $term_id ) ) ? 'dashicons-star-filled' : 'dashicons-star-empty';
91
+ printf(
92
+ '<span class="dashicons %1$s" title="%2$s" data-brand-id="%3$s"></span>',
93
+ $featured_class, __('Set as featured', 'perfect-woocommerce-brands'), $term_id
94
+ );
95
+ break;
96
+ }
97
  }
98
 
99
  private function is_featured_brand( $brand_id ){
classes/class-perfect-woocommerce-brands.php CHANGED
@@ -6,6 +6,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
6
  class Perfect_Woocommerce_Brands{
7
 
8
  function __construct(){
 
9
  add_action( 'woocommerce_init', array( $this, 'register_brands_taxonomy' ), 10, 0 );
10
  add_action( 'init', array( $this, 'add_brands_metafields' ) );
11
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -40,6 +41,24 @@ class Perfect_Woocommerce_Brands{
40
  add_filter( 'post_type_link', array( $this, 'brand_name_in_url' ), 10, 2 );
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  public function brand_name_in_url( $permalink, $post ){
44
  if( $post->post_type == 'product' && strpos( $permalink, '%pwb-brand%' ) !== false ) {
45
  $term = 'product';
@@ -637,6 +656,11 @@ class Perfect_Woocommerce_Brands{
637
  true
638
  );
639
 
 
 
 
 
 
640
  wp_register_style(
641
  'pwb-lib-slick',
642
  PWB_PLUGIN . '/assets/lib/slick/slick.css',
@@ -841,10 +865,21 @@ class Perfect_Woocommerce_Brands{
841
 
842
  }
843
 
844
- public static function render_template( $name, $folder = '', $data ){
845
- ob_start();
846
  if( $folder ) $folder = $folder . '/';
847
  $template_file = dirname( __DIR__ ) . '/templates/' . $folder . $name . '.php';
 
 
 
 
 
 
 
 
 
 
 
848
  include $template_file;
849
  return ob_get_clean();
850
  }
6
  class Perfect_Woocommerce_Brands{
7
 
8
  function __construct(){
9
+ add_action( 'plugin_row_meta', array( '\Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands', 'plugin_row_meta' ), 10, 2 );
10
  add_action( 'woocommerce_init', array( $this, 'register_brands_taxonomy' ), 10, 0 );
11
  add_action( 'init', array( $this, 'add_brands_metafields' ) );
12
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
41
  add_filter( 'post_type_link', array( $this, 'brand_name_in_url' ), 10, 2 );
42
  }
43
 
44
+ /**
45
+ * Show row meta on the plugin screen.
46
+ *
47
+ * @param mixed $links Plugin Row Meta.
48
+ * @param mixed $file Plugin Base file.
49
+ *
50
+ * @return array
51
+ */
52
+ public static function plugin_row_meta( $links, $file ) {
53
+ if( PWB_PLUGIN_BASENAME === $file ){
54
+ $row_meta = array(
55
+ 'docs' => '<a target="_blank" rel="noopener noferrer" href="https://github.com/titodevera/perfect-woocommerce-brands/wiki">' . esc_html__( 'Developer docs', 'perfect-woocommerce-brands' ) . '</a>',
56
+ );
57
+ return array_merge( $links, $row_meta );
58
+ }
59
+ return (array)$links;
60
+ }
61
+
62
  public function brand_name_in_url( $permalink, $post ){
63
  if( $post->post_type == 'product' && strpos( $permalink, '%pwb-brand%' ) !== false ) {
64
  $term = 'product';
656
  true
657
  );
658
 
659
+ wp_localize_script( 'pwb-lib-slick', 'ajax_object', array(
660
+ 'carousel_prev' => apply_filters('pwb_carousel_prev','&lt;'),
661
+ 'carousel_next' => apply_filters('pwb_carousel_next','&gt;')
662
+ ) );
663
+
664
  wp_register_style(
665
  'pwb-lib-slick',
666
  PWB_PLUGIN . '/assets/lib/slick/slick.css',
865
 
866
  }
867
 
868
+ public static function render_template( $name, $folder = '', $data, $private = true ){
869
+ //default template
870
  if( $folder ) $folder = $folder . '/';
871
  $template_file = dirname( __DIR__ ) . '/templates/' . $folder . $name . '.php';
872
+
873
+ //theme overrides
874
+ if( !$private ){
875
+ $theme_template_path = get_stylesheet_directory() . '/perfect-woocommerce-brands/';
876
+ if( file_exists( $theme_template_path . $folder . $name . '.php' ) )
877
+ $template_file = $theme_template_path . $folder . $name . '.php';
878
+ }
879
+
880
+ extract($data);
881
+
882
+ ob_start();
883
  include $template_file;
884
  return ob_get_clean();
885
  }
classes/class-pwb-product-tab.php CHANGED
@@ -10,21 +10,27 @@ class PWB_Product_Tab{
10
  add_filter( 'woocommerce_product_tabs', array( $this, 'product_tab' ) );
11
  }
12
 
13
- public function product_tab( $tabs ) {
14
-
15
- $show_brand_tab = get_option( 'wc_pwb_admin_tab_brand_single_product_tab' );
16
- if( $show_brand_tab == 'yes' || !$show_brand_tab ){
17
- $tabs['pwb_tab'] = array(
18
- 'title' => __( 'Brand', 'perfect-woocommerce-brands' ),
19
- 'priority' => 20,
20
- 'callback' => array( $this, 'product_tab_content' )
21
- );
 
 
 
 
 
22
  }
 
23
  return $tabs;
24
 
25
  }
26
 
27
- public function product_tab_content() {
28
 
29
  global $product;
30
  $brands = wp_get_object_terms( $product->get_id(), 'pwb-brand' );
10
  add_filter( 'woocommerce_product_tabs', array( $this, 'product_tab' ) );
11
  }
12
 
13
+ public function product_tab( $tabs ){
14
+
15
+ global $product;
16
+ $brands = wp_get_object_terms( $product->get_id(), 'pwb-brand' );
17
+
18
+ if( !empty( $brands ) ){
19
+ $show_brand_tab = get_option( 'wc_pwb_admin_tab_brand_single_product_tab' );
20
+ if( $show_brand_tab == 'yes' || !$show_brand_tab ){
21
+ $tabs['pwb_tab'] = array(
22
+ 'title' => __( 'Brand', 'perfect-woocommerce-brands' ),
23
+ 'priority' => 20,
24
+ 'callback' => array( $this, 'product_tab_content' )
25
+ );
26
+ }
27
  }
28
+
29
  return $tabs;
30
 
31
  }
32
 
33
+ public function product_tab_content(){
34
 
35
  global $product;
36
  $brands = wp_get_object_terms( $product->get_id(), 'pwb-brand' );
classes/shortcodes/class-pwb-carousel.php CHANGED
@@ -26,7 +26,8 @@ class PWB_Carousel_Shortcode{
26
  return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
27
  'carousel',
28
  'shortcodes',
29
- array( 'slick_settings' => self::slick_settings(), 'brands' => self::brands_data() )
 
30
  );
31
 
32
  }
26
  return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
27
  'carousel',
28
  'shortcodes',
29
+ array( 'slick_settings' => self::slick_settings(), 'brands' => self::brands_data() ),
30
+ false
31
  );
32
 
33
  }
classes/shortcodes/class-pwb-product-carousel.php CHANGED
@@ -21,11 +21,12 @@ class PWB_Product_Carousel_Shortcode{
21
  //enqueue deps
22
  if( !wp_style_is('pwb-lib-slick') ) wp_enqueue_style('pwb-lib-slick');
23
  if( !wp_script_is('pwb-lib-slick') ) wp_enqueue_script('pwb-lib-slick');
24
-
25
  return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
26
  'product-carousel',
27
  'shortcodes',
28
- array( 'slick_settings' => self::slick_settings(), 'products' => self::products_data() )
 
29
  );
30
 
31
  }
21
  //enqueue deps
22
  if( !wp_style_is('pwb-lib-slick') ) wp_enqueue_style('pwb-lib-slick');
23
  if( !wp_script_is('pwb-lib-slick') ) wp_enqueue_script('pwb-lib-slick');
24
+
25
  return \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
26
  'product-carousel',
27
  'shortcodes',
28
+ array( 'slick_settings' => self::slick_settings(), 'products' => self::products_data() ),
29
+ false
30
  );
31
 
32
  }
classes/widgets/class-pwb-dropdown.php CHANGED
@@ -80,7 +80,8 @@ class PWB_Dropdown_Widget extends \WP_Widget {
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;
80
  echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
81
  'dropdown',
82
  'widgets',
83
+ array( 'brands' => $brands, 'selected' => $queried_brand_id ),
84
+ false
85
  );
86
 
87
  echo $after_widget;
classes/widgets/class-pwb-filter-by-brand.php CHANGED
@@ -127,7 +127,8 @@ class PWB_Filter_By_Brand_Widget extends \WP_Widget {
127
  echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
128
  'filter-by-brand',
129
  'widgets',
130
- array( 'cate_url' => $cate_url, 'brands' => $result_brands_ordered, 'hide_submit_btn' => $hide_submit_btn )
 
131
  );
132
 
133
  }
127
  echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::render_template(
128
  'filter-by-brand',
129
  'widgets',
130
+ array( 'cate_url' => $cate_url, 'brands' => $result_brands_ordered, 'hide_submit_btn' => $hide_submit_btn ),
131
+ false
132
  );
133
 
134
  }
classes/widgets/class-pwb-list.php CHANGED
@@ -116,7 +116,8 @@ class PWB_List_Widget extends \WP_Widget {
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;
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
+ false
121
  );
122
 
123
  echo $after_widget;
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.3
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.3, 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
@@ -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.3' );
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.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.7.4, 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
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.4' );
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.1
7
  Requires PHP: 5.6
8
- Stable tag: 1.7.3
9
  License: GPL3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
11
 
@@ -81,6 +81,13 @@ You can also contribute [translating the plugin](https://translate.wordpress.org
81
 
82
 
83
  == Changelog ==
 
 
 
 
 
 
 
84
  = 1.7.3 =
85
  * Enhancement: Performance improvements
86
  * Fix: Breadcrumbs doesn't take in account pagination
5
  Requires at least: 4.7
6
  Tested up to: 5.1
7
  Requires PHP: 5.6
8
+ Stable tag: 1.7.4
9
  License: GPL3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
11
 
81
 
82
 
83
  == Changelog ==
84
+ = 1.7.4 =
85
+ * Fix: Mismatched columns when a brand is added
86
+ * Tweak: Disable brand tab when product not have brand
87
+ * Dev: New filter hook 'pwb_dropdown_placeholder'
88
+ * Dev: New filter hooks 'pwb_carousel_prev' and 'pwb_carousel_next' for customize the carousel arrows
89
+ * Dev: Override templates via a theme
90
+ * Minor fixes and tweaks
91
  = 1.7.3 =
92
  * Enhancement: Performance improvements
93
  * Fix: Breadcrumbs doesn't take in account pagination
templates/admin/brands-exporter.php CHANGED
@@ -4,11 +4,7 @@
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
  <div class="pwb-brands-exporter pwb-clearfix">
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <div class="pwb-brands-exporter pwb-clearfix">
templates/admin/edit-brands-bottom.php CHANGED
@@ -4,11 +4,7 @@
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
  <div class="pwb-edit-brands-bottom pwb-clearfix">
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <div class="pwb-edit-brands-bottom pwb-clearfix">
templates/shortcodes/carousel.php CHANGED
@@ -4,11 +4,7 @@
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
  <div class="pwb-carousel" data-slick="<?php echo $slick_settings; ?>">
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <div class="pwb-carousel" data-slick="<?php echo $slick_settings; ?>">
templates/shortcodes/product-carousel.php CHANGED
@@ -4,11 +4,7 @@
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
  <?php if( !empty( $products ) ): ?>
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <?php if( !empty( $products ) ): ?>
templates/widgets/dropdown.php CHANGED
@@ -4,16 +4,13 @@
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
 
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');?>
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
 
8
  ?>
9
 
10
  <select class="pwb-dropdown-widget">
11
+ <option selected="true" disabled="disabled">
12
+ <?php echo apply_filters( 'pwb_dropdown_placeholder', __( 'Brands', 'perfect-woocommerce-brands' ) ); ?>
13
+ </option>
14
  <?php foreach( $brands as $brand ): ?>
15
  <option value="<?php echo $brand->get('link');?>" <?php selected( $data['selected'], $brand->get('id') );?>>
16
  <?php echo $brand->get('name');?>
templates/widgets/filter-by-brand.php CHANGED
@@ -4,11 +4,7 @@
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
  <div class="pwb-filter-products<?php if( $hide_submit_btn ) echo ' pwb-hide-submit-btn'; ?>" data-cat-url="<?php echo $cate_url;?>">
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <div class="pwb-filter-products<?php if( $hide_submit_btn ) echo ' pwb-hide-submit-btn'; ?>" data-cat-url="<?php echo $cate_url;?>">
templates/widgets/list-logo.php CHANGED
@@ -4,11 +4,7 @@
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">
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <ul class="pwb-row">
templates/widgets/list.php CHANGED
@@ -4,11 +4,7 @@
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">
4
  * @version 1.0.0
5
  */
6
 
 
 
7
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
8
  ?>
9
 
10
  <ul class="pwb-row">