Perfect Brands for WooCommerce - Version 1.4.4

Version Description

  • Important improvement of the user experience when assigning images to a brand
  • Feature (Option): Hide brands in single product, show as image or show as link
  • Feature: Hide prev/next arrows on carousel shortcodes
  • Feature: Hide empty brands option for "Display all brands" shortcode
  • Feature: New options for "Display brands as list" widget
  • Fix: Autoplay bug on carousel shortcodes
  • Tested on PHP7
  • Shortcut to the plugin settings added to the plugin list page
  • "Help us" notice added
  • Minor code improvements
Download this release

Release Info

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

Code changes from version 1.4.3 to 1.4.4

assets/css/styles-admin.css CHANGED
@@ -1,21 +1,63 @@
1
- /* ----------------------- Taxonomy pwb-brand ----------------------- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  .taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_image, .taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_banner{
3
  display: none;
4
- }
5
- .taxonomy-pwb-brand .pwb_brand_cont div{
6
- margin-top: 10px;
7
- }
8
- @media screen and (max-width: 782px) {
9
- .taxonomy-pwb-brand .wp-list-table thead th.column-logo, .taxonomy-pwb-brand .wp-list-table tfoot th.column-logo {
10
- display: none;
11
- }
12
-
13
- .taxonomy-pwb-brand .wp-list-table td.column-logo:before {
14
- content: ""!important;
15
- }
16
- }
17
  /* ----------------------- /Taxonomy pwb-brand ----------------------- */
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  .pwb-modal{
20
  position: fixed;
21
  top: 0;
1
+ /* ----------------------- Taxonomy pwb-brand ----------------------- */
2
+ .taxonomy-pwb-brand .pwb_brand_image_selected_remove{
3
+ color: #FF3030;
4
+ font-family: Arial, Helvetica, sans-serif;
5
+ text-decoration: none;
6
+ font-size: 20px;
7
+ font-weight: bold;
8
+ position: absolute;
9
+ top: 0;
10
+ right: 0;
11
+ bottom: 0;
12
+ left: 0;
13
+ background-color: rgba(0, 0, 0, 0.5);
14
+ opacity: 0;
15
+ -webkit-transition: opacity 200ms ease-in-out;
16
+ -moz-transition: opacity 200ms ease-in-out;
17
+ -ms-transition: opacity 200ms ease-in-out;
18
+ -o-transition: opacity 200ms ease-in-out;
19
+ transition: opacity 200ms ease-in-out;
20
+ }
21
+ .taxonomy-pwb-brand .pwb_brand_image_selected span{
22
+ display: inline-block;
23
+ position: relative;
24
+ text-align: center;
25
+ line-height: 90px;
26
+ height: 90px;
27
+ }
28
+ .taxonomy-pwb-brand .pwb_brand_image_selected span:hover .pwb_brand_image_selected_remove{
29
+ opacity: 1;
30
+ }
31
  .taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_image, .taxonomy-pwb-brand .pwb_brand_cont #pwb_brand_banner{
32
  display: none;
33
+ }
34
+ .taxonomy-pwb-brand .pwb_brand_cont div{
35
+ margin-top: 10px;
36
+ }
37
+ @media screen and (max-width: 782px) {
38
+ .taxonomy-pwb-brand .wp-list-table thead th.column-logo, .taxonomy-pwb-brand .wp-list-table tfoot th.column-logo {
39
+ display: none;
40
+ }
41
+
42
+ .taxonomy-pwb-brand .wp-list-table td.column-logo:before {
43
+ content: ""!important;
44
+ }
45
+ }
46
  /* ----------------------- /Taxonomy pwb-brand ----------------------- */
47
 
48
+ .pwb-display-as-logo{
49
+ display: none;
50
+ }
51
+ .pwb-display-as-logo.show{
52
+ display: block;
53
+ }
54
+ .pwb-notice-dismissible p a{
55
+ margin-right: 12px;
56
+ }
57
+ .pwb-notice-dismissible .dashicons-heart{
58
+ color: #f188ff;
59
+ margin-left: 3px;
60
+ }
61
  .pwb-modal{
62
  position: fixed;
63
  top: 0;
assets/css/styles-frontend.css CHANGED
@@ -1,136 +1,160 @@
1
- /* ----------------------- Global ----------------------- */
2
- .pwb-clearfix:after{
3
- content: "";
4
- display: table;
5
- clear: both;
6
- }
7
- /* ----------------------- /Global ----------------------- */
8
-
9
- /* ----------------------- PWB Carousel ----------------------- */
10
- .pwb-carousel .slick-loading .slick-list, .pwb-product-carousel .slick-loading .slick-list{
11
- background: #fff url('./ajax-loader.gif') center center no-repeat;
12
- }
13
- .pwb-carousel .slick-slide, .pwb-product-carousel .slick-slide{
14
- margin: 0 10px;
15
- }
16
- .pwb-carousel .slick-prev, .pwb-carousel .slick-next,
17
- .pwb-product-carousel .slick-prev, .pwb-product-carousel .slick-next{
18
- font-size: 0;
19
-
20
- position: absolute;
21
- top: 0;
22
- bottom: 0;
23
-
24
- display: block;
25
-
26
- cursor: pointer;
27
-
28
- font-size: 22px;
29
- width: 30px;
30
- overflow: hidden;
31
- text-align: center;
32
-
33
- color: #aeaeae;
34
- border: none;
35
- outline: none;
36
-
37
- z-index: 999;
38
- background: #eee;
39
- opacity: 0;
40
- transition: opacity 0.3s ease-in-out;
41
- -webkit-transition: opacity 0.3s ease-in-out;
42
- -moz-transition: opacity 0.3s ease-in-out;
43
- -o-transition: opacity 0.3s ease-in-out;
44
-
45
- }
46
- .pwb-carousel .slick-prev > span, .pwb-carousel .slick-next > span,
47
- .pwb-product-carousel .slick-prev > span, .pwb-product-carousel .slick-next > span{
48
- display: inline-block;
49
- height: 20px;
50
- width: 20px;
51
- padding: 10px;
52
- position: absolute;
53
- top: 50%;
54
- margin-top: -20px;
55
- left: 0;
56
- right: 0;
57
- }
58
- .pwb-carousel .slick-prev:hover,
59
- .pwb-carousel .slick-prev:focus,
60
- .pwb-carousel .slick-next:hover,
61
- .pwb-carousel .slick-next:focus,
62
- .pwb-product-carousel .slick-prev:hover,
63
- .pwb-product-carousel .slick-prev:focus,
64
- .pwb-product-carousel .slick-next:hover,
65
- .pwb-product-carousel .slick-next:focus{
66
- outline: none;
67
- }
68
- .pwb-carousel .slick-prev, .pwb-product-carousel .slick-prev{
69
- left: 0;
70
- }
71
- .pwb-carousel .slick-next, .pwb-product-carousel .slick-next{
72
- right: 0;
73
- }
74
- .pwb-carousel:hover .slick-next,.pwb-carousel:hover .slick-prev,
75
- .pwb-product-carousel:hover .slick-next,.pwb-product-carousel:hover .slick-prev{
76
- opacity: 0.8;
77
- }
78
- .pwb-product-carousel .pwb-amount{
79
- display: block;
80
- width: 100%;
81
- margin-bottom: 12px;
82
- }
83
- /* ----------------------- /PWB Carousel ----------------------- */
84
-
85
- /* ----------------------- PWB All Brands ----------------------- */
86
- .pwb-all-brands .pwb-pagination-wrapper{
87
- margin-top: 20px;
88
- padding-top: 10px;
89
- border-top: 1px solid #ededed;
90
- text-align: right;
91
- }
92
- .pwb-all-brands .pwb-pagination{
93
- display: inline-block;
94
- margin-right: 10px;
95
- background-color: #ededed;
96
- color: #333;
97
- text-align: center;
98
- padding: 10px;
99
- }
100
- .pwb-all-brands .pwb-brands-cols-outer:after{
101
- content: "";
102
- display: table;
103
- clear: both;
104
- }
105
- .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
106
- padding: 0 15px;
107
- width: 20%;
108
- float: left;
109
- }
110
- .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3 > div:first-child{
111
- height: 25px;
112
- overflow: hidden;
113
- }
114
- /* ----------------------- /PWB All Brands ----------------------- */
115
-
116
- /* ----------------------- Responsive ----------------------- */
117
- @media screen and (max-width: 1000px) {
118
- .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
119
- width: 25%;
120
- }
121
- }
122
- @media screen and (max-width: 700px) {
123
- .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
124
- width: 50%;
125
- }
126
- }
127
- @media screen and (max-width: 480px) {
128
- .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
129
- width: 100%;
130
- float: none;
131
- }
132
- .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3 > div:first-child{
133
- height: auto;
134
- }
135
- }
136
- /* ----------------------- /Responsive ----------------------- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ----------------------- Global ----------------------- */
2
+ .pwb-clearfix:after{
3
+ content: "";
4
+ display: table;
5
+ clear: both;
6
+ }
7
+ /* ----------------------- /Global ----------------------- */
8
+
9
+ /* ----------------------- PWB Carousel ----------------------- */
10
+ .pwb-carousel .slick-loading .slick-list, .pwb-product-carousel .slick-loading .slick-list{
11
+ background: #fff url('./ajax-loader.gif') center center no-repeat;
12
+ }
13
+ .pwb-carousel .slick-slide, .pwb-product-carousel .slick-slide{
14
+ margin: 0 10px;
15
+ }
16
+ .pwb-carousel .slick-prev, .pwb-carousel .slick-next,
17
+ .pwb-product-carousel .slick-prev, .pwb-product-carousel .slick-next{
18
+ font-size: 0;
19
+
20
+ position: absolute;
21
+ top: 0;
22
+ bottom: 0;
23
+
24
+ display: block;
25
+
26
+ cursor: pointer;
27
+
28
+ font-size: 22px;
29
+ width: 30px;
30
+ overflow: hidden;
31
+ text-align: center;
32
+
33
+ color: #aeaeae;
34
+ border: none;
35
+ outline: none;
36
+
37
+ z-index: 999;
38
+ background: #eee;
39
+ opacity: 0;
40
+ transition: opacity 0.3s ease-in-out;
41
+ -webkit-transition: opacity 0.3s ease-in-out;
42
+ -moz-transition: opacity 0.3s ease-in-out;
43
+ -o-transition: opacity 0.3s ease-in-out;
44
+
45
+ }
46
+ .pwb-carousel .slick-prev > span, .pwb-carousel .slick-next > span,
47
+ .pwb-product-carousel .slick-prev > span, .pwb-product-carousel .slick-next > span{
48
+ display: inline-block;
49
+ height: 20px;
50
+ width: 20px;
51
+ padding: 10px;
52
+ position: absolute;
53
+ top: 50%;
54
+ margin-top: -20px;
55
+ left: 0;
56
+ right: 0;
57
+ }
58
+ .pwb-carousel .slick-prev:hover,
59
+ .pwb-carousel .slick-prev:focus,
60
+ .pwb-carousel .slick-next:hover,
61
+ .pwb-carousel .slick-next:focus,
62
+ .pwb-product-carousel .slick-prev:hover,
63
+ .pwb-product-carousel .slick-prev:focus,
64
+ .pwb-product-carousel .slick-next:hover,
65
+ .pwb-product-carousel .slick-next:focus{
66
+ outline: none;
67
+ }
68
+ .pwb-carousel .slick-prev, .pwb-product-carousel .slick-prev{
69
+ left: 0;
70
+ }
71
+ .pwb-carousel .slick-next, .pwb-product-carousel .slick-next{
72
+ right: 0;
73
+ }
74
+ .pwb-carousel:hover .slick-next,.pwb-carousel:hover .slick-prev,
75
+ .pwb-product-carousel:hover .slick-next,.pwb-product-carousel:hover .slick-prev{
76
+ opacity: 0.8;
77
+ }
78
+ .pwb-product-carousel .pwb-amount{
79
+ display: block;
80
+ width: 100%;
81
+ margin-bottom: 12px;
82
+ }
83
+ /* ----------------------- /PWB Carousel ----------------------- */
84
+
85
+ /* ----------------------- PWB All Brands ----------------------- */
86
+ .pwb-all-brands .pwb-pagination-wrapper{
87
+ margin-top: 20px;
88
+ padding-top: 10px;
89
+ border-top: 1px solid #ededed;
90
+ text-align: right;
91
+ }
92
+ .pwb-all-brands .pwb-pagination{
93
+ display: inline-block;
94
+ margin-right: 10px;
95
+ background-color: #ededed;
96
+ color: #333;
97
+ text-align: center;
98
+ padding: 10px;
99
+ }
100
+ .pwb-all-brands .pwb-brands-cols-outer:after{
101
+ content: "";
102
+ display: table;
103
+ clear: both;
104
+ }
105
+ .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
106
+ padding: 0 15px;
107
+ width: 20%;
108
+ float: left;
109
+ }
110
+ .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3 > div:first-child{
111
+ height: 25px;
112
+ overflow: hidden;
113
+ }
114
+ /* ----------------------- /PWB All Brands ----------------------- */
115
+
116
+ /* ----------------------- Columns ----------------------- */
117
+ .pwb-row:after{
118
+ content: "";
119
+ display: table;
120
+ clear: both;
121
+ }
122
+ .pwb-columns-2{
123
+ width: 50%;
124
+ }
125
+ .pwb-columns-3{
126
+ width: 33.33333%;
127
+ }
128
+ .pwb-columns-4{
129
+ width: 25%;
130
+ }
131
+ .pwb-columns{
132
+ display: inline-block;
133
+ vertical-align:top;
134
+ }
135
+ /* ----------------------- /Columns ----------------------- */
136
+
137
+ /* ----------------------- Responsive ----------------------- */
138
+ @media screen and (max-width: 1000px) {
139
+ .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
140
+ width: 25%;
141
+ }
142
+ }
143
+ @media screen and (max-width: 700px) {
144
+ .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
145
+ width: 50%;
146
+ }
147
+ }
148
+ @media screen and (max-width: 480px) {
149
+ .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3{
150
+ width: 100%;
151
+ float: none;
152
+ }
153
+ .pwb-all-brands .pwb-brands-cols-outer .pwb-brands-col3 > div:first-child{
154
+ height: auto;
155
+ }
156
+ .pwb-columns-3, .pwb-columns-4{
157
+ width: 50%;
158
+ }
159
+ }
160
+ /* ----------------------- /Responsive ----------------------- */
assets/js/pwb_admin_functions.js CHANGED
@@ -1,78 +1,164 @@
1
- jQuery.noConflict();
2
-
3
- jQuery(document).ready(function( $ ) {
4
-
5
- var media_uploader = null;
6
-
7
- function open_media_uploader_image(event){
8
- media_uploader = wp.media({
9
- frame: "post",
10
- state: "insert",
11
- multiple: false
12
- });
13
-
14
- media_uploader.on("insert", function(){
15
- var json = media_uploader.state().get("selection").first().toJSON();
16
- var image_id = json.id;
17
- var image_url = json.url;
18
-
19
- var current_selector = '';
20
- switch (event.target.id) {
21
- case 'pwb_brand_image_select':
22
- current_selector = '.taxonomy-pwb-brand #pwb_brand_'+'image';
23
- break;
24
- case 'pwb_brand_banner_select':
25
- current_selector = '.taxonomy-pwb-brand #pwb_brand_'+'banner';
26
- break;
27
- }
28
-
29
- jQuery(current_selector).val(image_id);
30
- jQuery(current_selector+'_result').remove();
31
- jQuery(current_selector+'_select').after('<div>'+image_url+'</div>');
32
- });
33
-
34
- media_uploader.open();
35
- }
36
-
37
-
38
- $('.taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select').on('click',function(event){
39
- open_media_uploader_image(event);
40
- });
41
-
42
-
43
- /* ····························· Settings tab ····························· */
44
-
45
- $('#wc_pwb_admin_tab_tools_migrate').on( 'change', function(){
46
-
47
- if( $(this).val() != '-' ){
48
-
49
- if( confirm(ajax_object.translations.migrate_notice) ){
50
-
51
- $('html').append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>');
52
- $('.pwb-modal-inner').html('<p>'+ajax_object.translations.migrating+'</p>');
53
-
54
- var data = {
55
- 'action': 'pwb_admin_migrate_brands',
56
- 'from': $(this).val()
57
- };
58
- jQuery.post(ajax_object.ajax_url, data, function(response) {
59
-
60
- setTimeout( function(){
61
- location.href = ajax_object.brands_url;
62
- }, 1000 );
63
-
64
- });
65
-
66
- }else{
67
-
68
- }
69
-
70
- }
71
-
72
- $(this).val('-');//reset to default value
73
-
74
- } );
75
-
76
- /* ····························· /Settings tab ····························· */
77
-
78
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.noConflict();
2
+
3
+ jQuery(document).ready(function( $ ) {
4
+
5
+ var media_uploader = null;
6
+
7
+ function open_media_uploader_image( event, imageSelectorButton ){
8
+
9
+ var $imageSelectorScope = imageSelectorButton.parent();
10
+
11
+ media_uploader = wp.media({
12
+ frame: "post",
13
+ state: "insert",
14
+ multiple: false
15
+ });
16
+
17
+ media_uploader.on("insert", function(){
18
+ var json = media_uploader.state().get("selection").first().toJSON();
19
+ var image_id = json.id;
20
+ var image_url = json.url;
21
+ var image_html = '<img src="'+image_url+'" width="90" height="90">';
22
+
23
+ var current_selector = '';
24
+ switch (event.target.id) {
25
+ case 'pwb_brand_image_select':
26
+ current_selector = '.taxonomy-pwb-brand #pwb_brand_'+'image';
27
+ break;
28
+ case 'pwb_brand_banner_select':
29
+ current_selector = '.taxonomy-pwb-brand #pwb_brand_'+'banner';
30
+ break;
31
+ }
32
+
33
+ $(current_selector).val(image_id);
34
+ $(current_selector+'_result').remove();
35
+
36
+ if( $('.pwb_brand_image_selected',$imageSelectorScope).length ){
37
+ $('.pwb_brand_image_selected span', $imageSelectorScope).html(image_html);
38
+ }else{
39
+ $imageSelectorScope.append('<div class="pwb_brand_image_selected"><span>'+image_html+'</span></div>');
40
+ }
41
+ add_delete_link( $imageSelectorScope );
42
+
43
+ });
44
+
45
+ media_uploader.open();
46
+ }
47
+
48
+
49
+ $('.taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select').on('click',function(event){
50
+ open_media_uploader_image( event, $(this) );
51
+ });
52
+
53
+ //bind remove image event for edit page
54
+ $('.taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select').each(function(){
55
+ add_delete_link( $(this).parent() );
56
+ });
57
+
58
+ //clear custom fields when brand is added
59
+ jQuery( document ).ajaxSuccess(function( event, xhr, settings ) {
60
+ //Check ajax action of request that succeeded
61
+ if( ~settings.data.indexOf("action=add-tag") && ~settings.data.indexOf("taxonomy=pwb-brand") ) {
62
+ $('#pwb_brand_image').val('');
63
+ $('#pwb_brand_banner').val('');
64
+ $('.pwb_brand_image_selected').remove();
65
+ }
66
+ });
67
+
68
+ function add_delete_link( $imageSelectorScope ){
69
+
70
+ $( '.pwb_brand_image_selected span', $imageSelectorScope ).append('<a href="#" class="pwb_brand_image_selected_remove">X</a>');
71
+
72
+ $( '.pwb_brand_image_selected_remove', $imageSelectorScope ).on( 'click', function( event ){
73
+
74
+ event.preventDefault();
75
+ $(this).closest('.pwb_brand_image_selected').remove();
76
+
77
+ //remove the img
78
+ $('#pwb_brand_image',$imageSelectorScope).val('');
79
+ $('#pwb_brand_banner',$imageSelectorScope).val('');
80
+
81
+ });
82
+
83
+ }
84
+
85
+
86
+ /* ····························· Settings tab ····························· */
87
+
88
+ $('#wc_pwb_admin_tab_tools_migrate').on( 'change', function(){
89
+
90
+ if( $(this).val() != '-' ){
91
+
92
+ if( confirm(ajax_object.translations.migrate_notice) ){
93
+
94
+ $('html').append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>');
95
+ $('.pwb-modal-inner').html('<p>'+ajax_object.translations.migrating+'</p>');
96
+
97
+ var data = {
98
+ 'action': 'pwb_admin_migrate_brands',
99
+ 'from': $(this).val()
100
+ };
101
+ $.post(ajax_object.ajax_url, data, function(response) {
102
+
103
+ setTimeout( function(){
104
+ location.href = ajax_object.brands_url;
105
+ }, 1000 );
106
+
107
+ });
108
+
109
+ }else{
110
+
111
+ }
112
+
113
+ }
114
+
115
+ $(this).val('-');//reset to default value
116
+
117
+ } );
118
+
119
+ /* ····························· /Settings tab ····························· */
120
+
121
+ /* ····························· Admin notices ····························· */
122
+ $( document ).on( 'click', '.pwb-notice-dismissible .notice-dismiss', function(e) {
123
+
124
+ e.preventDefault();
125
+
126
+ var noticeName = $( this ).closest( '.pwb-notice-dismissible' ).data( 'notice' );
127
+
128
+ var data = {
129
+ 'action': 'dismiss_pwb_notice',
130
+ 'notice_name': noticeName
131
+ };
132
+ jQuery.post(ajaxurl, data, function(response) {
133
+ //callback
134
+ });
135
+
136
+ } );
137
+ /* ····························· /Admin notices ····························· */
138
+
139
+ /* ····························· Widgets ····························· */
140
+ pwbBindEventsToWigets();
141
+ //Fires when a widget is added to a sidebar
142
+ jQuery(document).bind('widget-added',function(e, widget){
143
+ pwbBindEventsToWigets( widget );
144
+ });
145
+ //Fires on widget save
146
+ jQuery(document).on('widget-updated', function(e, widget){
147
+ pwbBindEventsToWigets( widget );
148
+ });
149
+ function pwbBindEventsToWigets( widget = null ){
150
+ $currentWidget = $(".pwb-select-display-as");
151
+ if( widget != null ){
152
+ $currentWidget = $(".pwb-select-display-as", widget);
153
+ }
154
+ $currentWidget.on("change",function(){
155
+ if( $(this).val()=="brand_logo" ){
156
+ $(this).parent().siblings(".pwb-display-as-logo").addClass("show");
157
+ }else{
158
+ $(this).parent().siblings(".pwb-display-as-logo").removeClass("show");
159
+ }
160
+ });
161
+ }
162
+ /* ····························· /Widgets ····························· */
163
+
164
+ });
assets/js/pwb_frontend_functions.js CHANGED
@@ -1,142 +1,142 @@
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;
7
- });
8
-
9
- $('.pwb-carousel').slick({
10
- infinite: true,
11
- draggable: false,
12
- prevArrow: '<div class="slick-prev"><span title="Prev">&lt;</span></div>',
13
- nextArrow: '<div class="slick-next"><span title="Next">&gt;</span></div>',
14
- speed: 300,
15
- responsive: [
16
- {
17
- breakpoint: 1024,
18
- settings: {
19
- slidesToShow: 4,
20
- draggable: true,
21
- arrows: false
22
- }
23
- },
24
- {
25
- breakpoint: 600,
26
- settings: {
27
- slidesToShow: 3,
28
- draggable: true,
29
- arrows: false
30
- }
31
- },
32
- {
33
- breakpoint: 480,
34
- settings: {
35
- slidesToShow: 2,
36
- draggable: true,
37
- arrows: false
38
- }
39
- }
40
- ]
41
- });
42
-
43
- $('.pwb-product-carousel').slick({
44
- infinite: true,
45
- draggable: false,
46
- prevArrow: '<div class="slick-prev"><span title="Prev">&lt;</span></div>',
47
- nextArrow: '<div class="slick-next"><span title="Next">&gt;</span></div>',
48
- speed: 300,
49
- responsive: [
50
- {
51
- breakpoint: 1024,
52
- settings: {
53
- slidesToShow: 3,
54
- draggable: true,
55
- arrows: false
56
- }
57
- },
58
- {
59
- breakpoint: 600,
60
- settings: {
61
- slidesToShow: 2,
62
- draggable: true,
63
- arrows: false
64
- }
65
- },
66
- {
67
- breakpoint: 480,
68
- settings: {
69
- slidesToShow: 1,
70
- draggable: true,
71
- arrows: false
72
- }
73
- }
74
- ]
75
- });
76
-
77
-
78
- /* ··························· Filter by brand widget ··························· */
79
-
80
- var brands = PWBgetUrlParameter('pwb-brand-filter');
81
-
82
- $('.pwb-filter-products button').on( 'click', function(){
83
-
84
- var currentUrl = window.location.href;
85
-
86
- var marcas = '';
87
- $('.pwb-filter-products input[type="checkbox"]').each(function(index){
88
- var checked = $(this).prop('checked');
89
- if(checked){
90
- marcas+=$(this).val();
91
- if($('.pwb-filter-products input[type="checkbox"]').length-1 != index){
92
- marcas+=',';
93
- }
94
- }
95
- });
96
-
97
- //removes previous "pwb-brand" from url
98
- currentUrl = currentUrl.replace(/&?pwb-brand-filter=([^&]$|[^&]*)/i, "");
99
-
100
- if( currentUrl.indexOf("?") === -1 ){
101
- currentUrl = currentUrl + '?pwb-brand-filter='+marcas;
102
- }else{
103
- currentUrl = currentUrl + '&pwb-brand-filter='+marcas;
104
- }
105
- location.href = currentUrl;
106
-
107
- });
108
-
109
- if(brands!=null){
110
- var brands_array = brands.split(',');
111
- $('.pwb-filter-products input[type="checkbox"]').prop('checked',false);
112
- for ( var i = 0, l = brands_array.length; i < l; i++ ) {
113
- $('.pwb-filter-products input[type="checkbox"]').each(function(index){
114
- if($(this).val()){
115
- if(brands_array[i]==$(this).val()){
116
- $(this).prop('checked',true);
117
- }
118
- }
119
- });
120
- }
121
- }else{
122
- $('.pwb-filter-products input[type="checkbox"]').prop('checked', false);
123
- }
124
-
125
- /* ··························· /Filter by brand widget ··························· */
126
-
127
- });
128
-
129
- var PWBgetUrlParameter = function PWBgetUrlParameter(sParam) {
130
- var sPageURL = decodeURIComponent(window.location.search.substring(1)),
131
- sURLVariables = sPageURL.split('&'),
132
- sParameterName,
133
- i;
134
-
135
- for (i = 0; i < sURLVariables.length; i++) {
136
- sParameterName = sURLVariables[i].split('=');
137
-
138
- if (sParameterName[0] === sParam) {
139
- return sParameterName[1] === undefined ? true : sParameterName[1];
140
- }
141
- }
142
- };
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;
7
+ });
8
+
9
+ $('.pwb-carousel').slick({
10
+ infinite: true,
11
+ draggable: false,
12
+ prevArrow: '<div class="slick-prev"><span title="Prev">&lt;</span></div>',
13
+ nextArrow: '<div class="slick-next"><span title="Next">&gt;</span></div>',
14
+ speed: 300,
15
+ responsive: [
16
+ {
17
+ breakpoint: 1024,
18
+ settings: {
19
+ slidesToShow: 4,
20
+ draggable: true,
21
+ arrows: false
22
+ }
23
+ },
24
+ {
25
+ breakpoint: 600,
26
+ settings: {
27
+ slidesToShow: 3,
28
+ draggable: true,
29
+ arrows: false
30
+ }
31
+ },
32
+ {
33
+ breakpoint: 480,
34
+ settings: {
35
+ slidesToShow: 2,
36
+ draggable: true,
37
+ arrows: false
38
+ }
39
+ }
40
+ ]
41
+ });
42
+
43
+ $('.pwb-product-carousel').slick({
44
+ infinite: true,
45
+ draggable: false,
46
+ prevArrow: '<div class="slick-prev"><span title="Prev">&lt;</span></div>',
47
+ nextArrow: '<div class="slick-next"><span title="Next">&gt;</span></div>',
48
+ speed: 300,
49
+ responsive: [
50
+ {
51
+ breakpoint: 1024,
52
+ settings: {
53
+ slidesToShow: 3,
54
+ draggable: true,
55
+ arrows: false
56
+ }
57
+ },
58
+ {
59
+ breakpoint: 600,
60
+ settings: {
61
+ slidesToShow: 2,
62
+ draggable: true,
63
+ arrows: false
64
+ }
65
+ },
66
+ {
67
+ breakpoint: 480,
68
+ settings: {
69
+ slidesToShow: 1,
70
+ draggable: true,
71
+ arrows: false
72
+ }
73
+ }
74
+ ]
75
+ });
76
+
77
+
78
+ /* ··························· Filter by brand widget ··························· */
79
+
80
+ var brands = PWBgetUrlParameter('pwb-brand-filter');
81
+
82
+ $('.pwb-filter-products button').on( 'click', function(){
83
+
84
+ var currentUrl = window.location.href;
85
+
86
+ var marcas = '';
87
+ $('.pwb-filter-products input[type="checkbox"]').each(function(index){
88
+ var checked = $(this).prop('checked');
89
+ if(checked){
90
+ marcas+=$(this).val();
91
+ if($('.pwb-filter-products input[type="checkbox"]').length-1 != index){
92
+ marcas+=',';
93
+ }
94
+ }
95
+ });
96
+
97
+ //removes previous "pwb-brand" from url
98
+ currentUrl = currentUrl.replace(/&?pwb-brand-filter=([^&]$|[^&]*)/i, "");
99
+
100
+ if( currentUrl.indexOf("?") === -1 ){
101
+ currentUrl = currentUrl + '?pwb-brand-filter='+marcas;
102
+ }else{
103
+ currentUrl = currentUrl + '&pwb-brand-filter='+marcas;
104
+ }
105
+ location.href = currentUrl;
106
+
107
+ });
108
+
109
+ if(brands!=null){
110
+ var brands_array = brands.split(',');
111
+ $('.pwb-filter-products input[type="checkbox"]').prop('checked',false);
112
+ for ( var i = 0, l = brands_array.length; i < l; i++ ) {
113
+ $('.pwb-filter-products input[type="checkbox"]').each(function(index){
114
+ if($(this).val()){
115
+ if(brands_array[i]==$(this).val()){
116
+ $(this).prop('checked',true);
117
+ }
118
+ }
119
+ });
120
+ }
121
+ }else{
122
+ $('.pwb-filter-products input[type="checkbox"]').prop('checked', false);
123
+ }
124
+
125
+ /* ··························· /Filter by brand widget ··························· */
126
+
127
+ });
128
+
129
+ var PWBgetUrlParameter = function PWBgetUrlParameter(sParam) {
130
+ var sPageURL = decodeURIComponent(window.location.search.substring(1)),
131
+ sURLVariables = sPageURL.split('&'),
132
+ sParameterName,
133
+ i;
134
+
135
+ for (i = 0; i < sURLVariables.length; i++) {
136
+ sParameterName = sURLVariables[i].split('=');
137
+
138
+ if (sParameterName[0] === sParam) {
139
+ return sParameterName[1] === undefined ? true : sParameterName[1];
140
+ }
141
+ }
142
+ };
classes/class-perfect-woocommerce-brands.php CHANGED
@@ -1,813 +1,886 @@
1
- <?php
2
- namespace Perfect_Woocommerce_Brands;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
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( 'pwb-brand_add_form_fields', array( $this, 'add_brands_metafields_form' ) );
12
- add_action( 'pwb-brand_edit_form_fields', array( $this, 'add_brands_metafields_form_edit' ) );
13
- add_action( 'edit_pwb-brand', array( $this, 'add_brands_metafields_save' ) );
14
- add_action( 'create_pwb-brand', array( $this, 'add_brands_metafields_save' ) );
15
- add_filter( 'manage_edit-pwb-brand_columns', array( $this, 'brand_taxonomy_columns_head' ) );
16
- add_filter( 'manage_pwb-brand_custom_column', array( $this, 'brand_taxonomy_columns' ), 10, 3 );
17
- add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
18
- $this->brand_logo_position();
19
- add_action( 'woocommerce_before_shop_loop', array( $this, 'archive_page_banner' ), 9);
20
- add_action( 'woocommerce_before_shop_loop', array( $this, 'show_brand_description' ), 9);
21
- add_action( 'woocommerce_after_shop_loop_item_title', array( $this, 'show_brands_in_loop' ) );
22
-
23
- if ( !is_admin() ) {
24
- add_action( 'init', array( $this, 'register_frontend_scripts' ) );
25
- }
26
-
27
- $this->add_shortcodes();
28
-
29
- if(is_plugin_active('js_composer/js_composer.php')){
30
- add_action( 'vc_before_init', array( $this,'vc_map_shortcodes' ) );
31
- }
32
-
33
- add_action( 'widgets_init', array( $this, 'register_widgets' ) );
34
-
35
- add_action( 'woocommerce_after_single_product_summary' , array( $this, 'product_microdata' ), 40 );
36
-
37
- add_action( 'wp_ajax_pwb_admin_migrate_brands', array( $this, 'migrate_brands' ) );
38
-
39
- add_action( 'pre_get_posts', array( $this, 'pwb_brand_filter' ) );
40
-
41
- }
42
-
43
- public function pwb_brand_filter( $query ){
44
-
45
- if( !empty($_GET['pwb-brand-filter']) ){
46
-
47
- $terms_array = explode(',',$_GET['pwb-brand-filter']);
48
-
49
- //remove invalid terms (security)
50
- for ($i=0; $i < count($terms_array); $i++) {
51
- if( !term_exists( $terms_array[$i], 'pwb-brand' ) ){
52
- unset($terms_array[$i]);
53
- }
54
- }
55
-
56
- if ( !is_admin() && is_post_type_archive( 'product' ) && $query->is_main_query() ) {
57
-
58
- $query->set('tax_query', array(
59
- array (
60
- 'taxonomy' => 'pwb-brand',
61
- 'field' => 'slug',
62
- 'terms' => $terms_array
63
- )
64
- ));
65
-
66
- }
67
-
68
- }
69
-
70
- }
71
-
72
- public function migrate_brands(){
73
-
74
- if( isset( $_POST['from'] ) ){
75
-
76
- switch ($_POST['from']) {
77
- case 'yith':
78
-
79
- $terms = get_terms( 'yith_product_brand', array(
80
- 'hide_empty' => false
81
- ) );
82
-
83
- foreach ($terms as $term) {
84
-
85
- global $wpdb;
86
-
87
- //change taxonomy
88
- $wpdb->update(
89
- $wpdb->prefix . 'term_taxonomy',
90
- array(
91
- 'taxonomy' => 'pwb-brand'
92
- ),
93
- array(
94
- 'term_id' => $term->term_id
95
- )
96
- );
97
-
98
- //update term meta
99
- $wpdb->update(
100
- $wpdb->prefix . 'termmeta',
101
- array(
102
- 'meta_key' => 'pwb_brand_image'
103
- ),
104
- array(
105
- 'meta_key' => 'thumbnail_id',
106
- 'term_id' => $term->term_id
107
- )
108
- );
109
-
110
- }
111
-
112
- break;
113
- }
114
-
115
- }
116
-
117
- wp_die();
118
- }
119
-
120
- /*
121
- * Adds microdata (brands) to single products
122
- */
123
- public function product_microdata(){
124
- global $product;
125
- $brands = wp_get_post_terms( $product->id, 'pwb-brand');
126
-
127
- foreach ($brands as $brand) {
128
- echo '<meta itemprop="brand" content="'.$brand->name.'">';
129
- }
130
-
131
- }
132
-
133
- public function add_shortcodes(){
134
- add_shortcode( 'pwb-carousel', array(
135
- '\Perfect_Woocommerce_Brands\Shortcodes\PWB_Carousel_Shortcode',
136
- 'carousel_shortcode'
137
- ) );
138
- add_shortcode( 'pwb-product-carousel', array(
139
- '\Perfect_Woocommerce_Brands\Shortcodes\PWB_Product_Carousel_Shortcode',
140
- 'product_carousel_shortcode'
141
- ) );
142
- add_shortcode( 'pwb-all-brands', array(
143
- '\Perfect_Woocommerce_Brands\Shortcodes\PWB_All_Brands_Shortcode',
144
- 'all_brands_shortcode'
145
- ) );
146
- add_shortcode( 'pwb-brand', array(
147
- '\Perfect_Woocommerce_Brands\Shortcodes\PWB_Brand_Shortcode',
148
- 'brand_shortcode'
149
- ) );
150
- }
151
-
152
- public function register_widgets(){
153
- register_widget( '\Perfect_Woocommerce_Brands\Widgets\PWB_List_Widget' );
154
- register_widget( '\Perfect_Woocommerce_Brands\Widgets\PWB_Dropdown_Widget' );
155
- register_widget( '\Perfect_Woocommerce_Brands\Widgets\PWB_Filter_By_Brand_Widget' );
156
- }
157
-
158
- public function show_brand_description(){
159
- $show_desc = get_option('wc_pwb_admin_tab_brand_desc');
160
- $queried_object = get_queried_object();
161
- if(is_a($queried_object,'WP_Term') && $queried_object->taxonomy == 'pwb-brand' && $queried_object->description != '' && $show_desc !== 'no'){
162
- echo '<div class="pwb-brand-description">';
163
- echo $queried_object->description;
164
- echo '</div>';
165
- }
166
- }
167
-
168
- public function show_brands_in_loop(){
169
-
170
- $brands_in_loop = get_option('wc_pwb_admin_tab_brands_in_loop');
171
-
172
- if( $brands_in_loop == 'brand_link' || $brands_in_loop == 'brand_image' ){
173
-
174
- global $product;
175
- $product_id = $product->id;
176
- $product_brands = wp_get_post_terms($product_id, 'pwb-brand');
177
- if(!empty($product_brands)){
178
- echo '<div class="pwb-brands-in-loop">';
179
- foreach ($product_brands as $brand) {
180
-
181
- echo '<span>';
182
- $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
183
- $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
184
-
185
- $attachment_html = wp_get_attachment_image( $attachment_id, 'thumbnail' );
186
- if( !empty($attachment_html) && $brands_in_loop == 'brand_image' ){
187
- echo '<a href="'.$brand_link.'">'.$attachment_html.'</a>';
188
- }else{
189
- echo '<a href="'.$brand_link.'">'.$brand->name.'</a>';
190
- }
191
- echo '</span>';
192
-
193
- }
194
- echo '</div>';
195
- }
196
-
197
- }
198
-
199
- }
200
-
201
- /**
202
- * woocommerce_single_product_summary hook.
203
- *
204
- * @hooked woocommerce_template_single_title - 5
205
- * @hooked woocommerce_template_single_rating - 10
206
- * @hooked woocommerce_template_single_price - 10
207
- * @hooked woocommerce_template_single_excerpt - 20
208
- * @hooked woocommerce_template_single_add_to_cart - 30
209
- * @hooked woocommerce_template_single_meta - 40
210
- * @hooked woocommerce_template_single_sharing - 50
211
- */
212
- private function brand_logo_position(){
213
- $position = 41;
214
- $position_selected = get_option('wc_pwb_admin_tab_brand_single_position');
215
- if(!$position_selected){
216
- update_option('wc_pwb_admin_tab_brand_single_position','after_meta');
217
- }
218
- switch ($position_selected) {
219
- case 'before_title':
220
- $position = 4;
221
- break;
222
- case 'after_title':
223
- $position = 6;
224
- break;
225
- case 'after_price':
226
- $position = 11;
227
- break;
228
- case 'after_excerpt':
229
- $position = 21;
230
- break;
231
- case 'after_add_to_cart':
232
- $position = 31;
233
- break;
234
- case 'after_meta':
235
- $position = 41;
236
- break;
237
- case 'after_sharing':
238
- $position = 51;
239
- break;
240
- }
241
- add_action('woocommerce_single_product_summary', array($this,'action_woocommerce_single_product_summary'), $position);
242
- }
243
-
244
-
245
- /*
246
- * Maps shortcode (for visual composer plugin)
247
- *
248
- * @since 1.0
249
- * @link https://vc.wpbakery.com/
250
- * @return mixed
251
- */
252
- public function vc_map_shortcodes(){
253
- $available_image_sizes_adapted = array();
254
- $available_image_sizes = get_intermediate_image_sizes();
255
-
256
- foreach($available_image_sizes as $image_size){
257
- $available_image_sizes_adapted[$image_size] = $image_size;
258
- }
259
-
260
- vc_map(array(
261
- "name" => __( "PWB Product carousel", "perfect-woocommerce-brands" ),
262
- "description" => __( "Product carousel by brand or by category", "perfect-woocommerce-brands" ),
263
- "base" => "pwb-product-carousel",
264
- "class" => "",
265
- "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
266
- "category" => "WooCommerce",
267
- "params" => array(
268
- array(
269
- "type" => "dropdown",
270
- "heading" => __( "Brand", "perfect-woocommerce-brands" ),
271
- "param_name" => "brand",
272
- "admin_label" => true,
273
- "value" => $this->get_brands_array()
274
- ),
275
- array(
276
- "type" => "textfield",
277
- "holder" => "div",
278
- "heading" => __( "Products", "perfect-woocommerce-brands" ),
279
- "param_name" => "products",
280
- "value" => "10",
281
- "description" => __( "Number of products to load", "perfect-woocommerce-brands" )
282
- ),
283
- array(
284
- "type" => "textfield",
285
- "holder" => "div",
286
- "heading" => __( "Products to show", "perfect-woocommerce-brands" ),
287
- "param_name" => "products_to_show",
288
- "value" => "5",
289
- "description" => __( "Number of products to show", "perfect-woocommerce-brands" )
290
- ),
291
- array(
292
- "type" => "textfield",
293
- "holder" => "div",
294
- "heading" => __( "Products to scroll", "perfect-woocommerce-brands" ),
295
- "param_name" => "products_to_scroll",
296
- "value" => "1",
297
- "description" => __( "Number of products to scroll", "perfect-woocommerce-brands" )
298
- ),
299
- array(
300
- "type" => "checkbox",
301
- "holder" => "div",
302
- "heading" => __( "Autoplay", "perfect-woocommerce-brands" ),
303
- "param_name" => "autoplay",
304
- "description" => __( "Autoplay carousel", "perfect-woocommerce-brands" )
305
- )
306
- )
307
-
308
-
309
- ));
310
-
311
- vc_map(array(
312
- "name" => __( "PWB Brands carousel", "perfect-woocommerce-brands" ),
313
- "description" => __( "Brands carousel", "perfect-woocommerce-brands" ),
314
- "base" => "pwb-carousel",
315
- "class" => "",
316
- "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
317
- "category" => "WooCommerce",
318
- "params" => array(
319
- array(
320
- "type" => "textfield",
321
- "holder" => "div",
322
- "heading" => __( "Items", "perfect-woocommerce-brands" ),
323
- "param_name" => "items",
324
- "value" => "10",
325
- "description" => __( "Number of items to load", "perfect-woocommerce-brands" )
326
- ),
327
- array(
328
- "type" => "textfield",
329
- "holder" => "div",
330
- "heading" => __( "Items to show", "perfect-woocommerce-brands" ),
331
- "param_name" => "items_to_show",
332
- "value" => "5",
333
- "description" => __( "Number of items to show", "perfect-woocommerce-brands" )
334
- ),
335
- array(
336
- "type" => "textfield",
337
- "holder" => "div",
338
- "heading" => __( "Items to scroll", "perfect-woocommerce-brands" ),
339
- "param_name" => "items_to_scroll",
340
- "value" => "1",
341
- "description" => __( "Number of items to scroll", "perfect-woocommerce-brands" )
342
- ),
343
- array(
344
- "type" => "checkbox",
345
- "holder" => "div",
346
- "heading" => __( "Autoplay", "perfect-woocommerce-brands" ),
347
- "param_name" => "autoplay",
348
- "description" => __( "Autoplay carousel", "perfect-woocommerce-brands" )
349
- ),
350
- array(
351
- "type" => "dropdown",
352
- "heading" => __( "Brand logo size", "perfect-woocommerce-brands" ),
353
- "param_name" => "image_size",
354
- "admin_label" => true,
355
- "value" => $available_image_sizes_adapted
356
- )
357
- )
358
-
359
-
360
- ));
361
-
362
- vc_map(array(
363
- "name" => __( "PWB All brands", "perfect-woocommerce-brands" ),
364
- "description" => __( "Show all brands", "perfect-woocommerce-brands" ),
365
- "base" => "pwb-all-brands",
366
- "class" => "",
367
- "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
368
- "category" => "WooCommerce",
369
-
370
- "params" => array(
371
- array(
372
- "type" => "textfield",
373
- "holder" => "div",
374
- "heading" => __( "Brands per page", "perfect-woocommerce-brands" ),
375
- "param_name" => "per_page",
376
- "value" => "10",
377
- "description" => __( "Show x brands per page", "perfect-woocommerce-brands" )
378
- ),
379
- array(
380
- "type" => "dropdown",
381
- "heading" => __( "Brand logo size", "perfect-woocommerce-brands" ),
382
- "param_name" => "image_size",
383
- "admin_label" => true,
384
- "value" => $available_image_sizes_adapted
385
- )
386
- )
387
-
388
-
389
- ));
390
-
391
- vc_map(array(
392
- "name" => __( "PWB brand", "perfect-woocommerce-brands" ),
393
- "description" => __( "Show brand for a specific product", "perfect-woocommerce-brands" ),
394
- "base" => "pwb-brand",
395
- "class" => "",
396
- "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
397
- "category" => "WooCommerce",
398
-
399
- "params" => array(
400
- array(
401
- "type" => "textfield",
402
- "holder" => "div",
403
- "heading" => __( "Product id", "perfect-woocommerce-brands" ),
404
- "param_name" => "product_id",
405
- "value" => null,
406
- "description" => __( "Product id (post id)", "perfect-woocommerce-brands" )
407
- ),
408
- array(
409
- "type" => "dropdown",
410
- "heading" => __( "Brand logo size", "perfect-woocommerce-brands" ),
411
- "param_name" => "image_size",
412
- "admin_label" => true,
413
- "value" => $available_image_sizes_adapted
414
- )
415
-
416
- )
417
-
418
-
419
- ));
420
- }
421
-
422
- public function action_woocommerce_single_product_summary() {
423
- $brands = wp_get_post_terms( get_the_ID(), 'pwb-brand');
424
-
425
- if(!is_wp_error($brands)){
426
- if(sizeof($brands>0)){
427
- echo '<div class="pwb-single-product-brands pwb-clearfix">';
428
- foreach($brands as $brand){
429
- $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
430
- $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
431
-
432
- $image_size = 'thumbnail';
433
- $image_size_selected = get_option('wc_pwb_admin_tab_brand_logo_size');
434
- if($image_size_selected!=false){
435
- $image_size = $image_size_selected;
436
- }
437
-
438
- $attachment_html = wp_get_attachment_image($attachment_id,$image_size);
439
- if(!empty($attachment_html)){
440
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
441
- }else{
442
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$brand->name.'</a>';
443
- }
444
- }
445
- echo '</div>';
446
- }
447
- }
448
- }
449
-
450
- public function register_frontend_scripts(){
451
-
452
- wp_register_script(
453
- 'pwb_slick_lib',
454
- PWB_PLUGIN . '/assets/js/slick/slick.min.js',
455
- array('jquery'),
456
- '1.5.9',
457
- true
458
- );
459
- wp_enqueue_script('pwb_frontend_functions');
460
-
461
- wp_enqueue_style (
462
- 'pwb_slick_lib',
463
- PWB_PLUGIN . '/assets/js/slick/slick.css',
464
- array(),
465
- '1.5.9',
466
- 'all'
467
- );
468
-
469
- wp_enqueue_style (
470
- 'pwb_frontend_styles',
471
- PWB_PLUGIN . '/assets/css/styles-frontend.css',
472
- array('pwb_slick_lib'),
473
- PWB_PLUGIN_VERSION,
474
- 'all'
475
- );
476
-
477
- wp_register_script(
478
- 'pwb_frontend_functions',
479
- PWB_PLUGIN . '/assets/js/pwb_frontend_functions.js',
480
- array('jquery','pwb_slick_lib'),
481
- PWB_PLUGIN_VERSION,
482
- true
483
- );
484
- wp_enqueue_script('pwb_frontend_functions');
485
-
486
- }
487
-
488
- public function register_admin_scripts($hook){
489
- $screen = get_current_screen();
490
-
491
- wp_register_style('pwb_styles_brands', plugins_url('perfect-woocommerce-brands/assets/css/styles-admin.css'), array(), PWB_PLUGIN_VERSION);
492
- wp_register_script('pwb_brands_js', plugins_url('perfect-woocommerce-brands/assets/js/pwb_admin_functions.js'), array('jquery'), PWB_PLUGIN_VERSION, true);
493
-
494
- if ($hook == 'edit-tags.php' && $screen->taxonomy == 'pwb-brand' || $hook == 'term.php' && $screen->taxonomy == 'pwb-brand') {
495
- wp_enqueue_style('pwb_styles_brands');
496
- wp_enqueue_media();
497
- wp_enqueue_script('pwb_brands_js');
498
- }elseif( $hook == 'woocommerce_page_wc-settings' && isset($_GET['tab']) && $_GET['tab']=='pwb_admin_tab' ){
499
- //settings tab page
500
- wp_enqueue_style( 'pwb_styles_brands' );
501
- wp_enqueue_script( 'pwb_brands_js' );
502
- wp_localize_script( 'pwb_brands_js', 'ajax_object', array(
503
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
504
- 'brands_url' => admin_url( 'edit-tags.php?taxonomy=pwb-brand&post_type=product' ),
505
- 'translations' => array(
506
- 'migrate_notice' => __('¿Start migration?','perfect-woocommerce-brands'),
507
- 'migrating' => __('We are migrating the product brands. ¡Don´t close this window until the process is finished!','perfect-woocommerce-brands')
508
- )
509
- ) );
510
- }else{
511
- return;
512
- }
513
-
514
- }
515
-
516
- public function register_brands_taxonomy(){
517
- $labels = array(
518
- 'name' => __( 'Brands', 'perfect-woocommerce-brands' ),
519
- 'singular_name' => __( 'Brand', 'perfect-woocommerce-brands' ),
520
- 'menu_name' => __( 'Brands', 'perfect-woocommerce-brands' ),
521
- 'all_items' => __( 'All Brands', 'perfect-woocommerce-brands' ),
522
- 'edit_item' => __( 'Edit Brand', 'perfect-woocommerce-brands' ),
523
- 'view_item' => __( 'View Brand', 'perfect-woocommerce-brands' ),
524
- 'update_item' => __( 'Update Brand', 'perfect-woocommerce-brands' ),
525
- 'add_new_item' => __( 'Add New Brand', 'perfect-woocommerce-brands' ),
526
- 'new_item_name' => __( 'New Brand Name', 'perfect-woocommerce-brands' ),
527
- 'parent_item' => __( 'Parent Brand', 'perfect-woocommerce-brands' ),
528
- 'parent_item_colon' => __( 'Parent Brand:', 'perfect-woocommerce-brands' ),
529
- 'search_items' => __( 'Search Brands', 'perfect-woocommerce-brands' ),
530
- 'popular_items' => __( 'Popular Brands', 'perfect-woocommerce-brands' ),
531
- 'separate_items_with_commas' => __( 'Separate brands with commas', 'perfect-woocommerce-brands' ),
532
- 'add_or_remove_items' => __( 'Add or remove brands', 'perfect-woocommerce-brands' ),
533
- 'choose_from_most_used' => __( 'Choose from the most used brands', 'perfect-woocommerce-brands' ),
534
- 'not_found' => __( 'No brands found', 'perfect-woocommerce-brands' )
535
- );
536
-
537
- $new_slug = get_option('wc_pwb_admin_tab_slug');
538
- $old_slug = get_option('old_wc_pwb_admin_tab_slug');
539
-
540
- $new_slug = ($new_slug!=false) ? $new_slug : 'brand';
541
- $old_slug = ($old_slug!=false) ? $old_slug : 'null';
542
-
543
- $args = array(
544
- 'hierarchical' => true,
545
- 'labels' => $labels,
546
- 'show_ui' => true,
547
- 'query_var' => true,
548
- 'public' => true,
549
- 'show_admin_column' => true,
550
- 'rewrite' => array(
551
- 'slug' => $new_slug,
552
- 'hierarchical' => true,
553
- 'ep_mask' => EP_PERMALINK
554
- )
555
- );
556
-
557
- register_taxonomy( 'pwb-brand', array( 'product' ), $args );
558
-
559
- if($new_slug != false && $old_slug!= false && $new_slug != $old_slug){
560
- flush_rewrite_rules();
561
- update_option( 'old_wc_pwb_admin_tab_slug', $new_slug );
562
- }
563
-
564
- }
565
-
566
- public function add_brands_metafields(){
567
- register_meta( 'term', 'pwb_brand_image', array($this,'add_brands_metafields_sanitize') );
568
- }
569
-
570
- public function add_brands_metafields_sanitize($brand_img){
571
- return $brand_img;
572
- }
573
-
574
- public function add_brands_metafields_form(){
575
- ob_start();
576
- ?>
577
- <div class="form-field pwb_brand_cont">
578
- <label for="pwb_brand_image"><?php _e( 'Brand logo', 'perfect-woocommerce-brands' ); ?></label>
579
- <input type="text" name="pwb_brand_image" id="pwb_brand_image" value="" >
580
- <a href="#" id="pwb_brand_image_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
581
- <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_brand_image_nonce' );?>
582
- </div>
583
-
584
- <div class="form-field pwb_brand_cont">
585
- <label for="pwb_brand_banner"><?php _e( 'Brand banner', 'perfect-woocommerce-brands' ); ?></label>
586
- <input type="text" name="pwb_brand_banner" id="pwb_brand_banner" value="" >
587
- <a href="#" id="pwb_brand_banner_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
588
- <p><?php _e( 'This image will be shown on brand page', 'perfect-woocommerce-brands' ); ?></p>
589
- <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_brand_banner_nonce' );?>
590
- </div>
591
-
592
- <div class="form-field pwb_brand_cont">
593
- <label for="pwb_brand_banner_link"><?php _e( 'Brand banner link', 'perfect-woocommerce-brands' ); ?></label>
594
- <input type="text" name="pwb_brand_banner_link" id="pwb_brand_banner_link" value="" >
595
- <p><?php _e( 'This link should be relative to site url. Example: product/product-name', 'perfect-woocommerce-brands' ); ?></p>
596
- <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_brand_banner_link_nonce' );?>
597
- </div>
598
- <?php
599
- echo ob_get_clean();
600
- }
601
-
602
- public function add_brands_metafields_form_edit($term){
603
- $term_value_image = get_term_meta( $term->term_id, 'pwb_brand_image', true );
604
- $term_value_banner = get_term_meta( $term->term_id, 'pwb_brand_banner', true );
605
- $term_value_banner_link = get_term_meta( $term->term_id, 'pwb_brand_banner_link', true );
606
- ob_start();
607
- ?>
608
- <table class="form-table pwb_brand_cont">
609
- <tr class="form-field">
610
- <th>
611
- <label for="pwb_brand_image"><?php _e( 'Brand logo', 'perfect-woocommerce-brands' ); ?></label>
612
- </th>
613
- <td>
614
- <input type="text" name="pwb_brand_image" id="pwb_brand_image" value="<?php echo $term_value_image;?>" >
615
- <a href="#" id="pwb_brand_image_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
616
- <div id="pwb_brand_image_result"><?php echo wp_get_attachment_image ( $term_value_image, array('90','90'), false );?></div>
617
- <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_brand_image_nonce' );?>
618
- </td>
619
- </tr>
620
- <tr class="form-field">
621
- <th>
622
- <label for="pwb_brand_banner"><?php _e( 'Brand banner', 'perfect-woocommerce-brands' ); ?></label>
623
- </th>
624
- <td>
625
- <input type="text" name="pwb_brand_banner" id="pwb_brand_banner" value="<?php echo $term_value_banner;?>" >
626
- <a href="#" id="pwb_brand_banner_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
627
- <div id="pwb_brand_banner_result"><?php echo wp_get_attachment_image ( $term_value_banner, array('90','90'), false );?></div>
628
- <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_brand_banner_nonce' );?>
629
- </td>
630
- </tr>
631
- <tr class="form-field">
632
- <th>
633
- <label for="pwb_brand_banner_link"><?php _e( 'Brand banner link', 'perfect-woocommerce-brands' ); ?></label>
634
- </th>
635
- <td>
636
- <input type="text" name="pwb_brand_banner_link" id="pwb_brand_banner_link" value="<?php echo $term_value_banner_link;?>" >
637
- <p class="description"><?php _e( 'This link should be relative to site url. Example: product/product-name', 'perfect-woocommerce-brands' ); ?></p>
638
- <div id="pwb_brand_banner_link_result"><?php echo wp_get_attachment_image ( $term_value_banner_link, array('90','90'), false );?></div>
639
- <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_brand_banner_link_nonce' );?>
640
- </td>
641
- </tr>
642
- </table>
643
- <?php
644
- echo ob_get_clean();
645
- }
646
-
647
- public function add_brands_metafields_save($term_id){
648
-
649
- /* ·············· Brand image ·············· */
650
- if ( ! isset( $_POST['pwb_brand_image_nonce'] ) || ! wp_verify_nonce( $_POST['pwb_brand_image_nonce'], basename( __FILE__ ) ) )
651
- return;
652
-
653
- $old_img = get_term_meta( $term_id, 'pwb_brand_image', true );
654
- $new_img = isset( $_POST['pwb_brand_image'] ) ? $_POST['pwb_brand_image'] : '';
655
-
656
- if ( $old_img && '' === $new_img )
657
- delete_term_meta( $term_id, 'pwb_brand_image' );
658
-
659
- else if ( $old_img !== $new_img )
660
- update_term_meta( $term_id, 'pwb_brand_image', $new_img );
661
- /* ·············· /Brand image ·············· */
662
-
663
- /* ·············· Brand banner ·············· */
664
- if ( ! isset( $_POST['pwb_brand_banner_nonce'] ) || ! wp_verify_nonce( $_POST['pwb_brand_banner_nonce'], basename( __FILE__ ) ) )
665
- return;
666
-
667
- $old_img = get_term_meta( $term_id, 'pwb_brand_banner', true );
668
- $new_img = isset( $_POST['pwb_brand_banner'] ) ? $_POST['pwb_brand_banner'] : '';
669
-
670
- if ( $old_img && '' === $new_img )
671
- delete_term_meta( $term_id, 'pwb_brand_banner' );
672
-
673
- else if ( $old_img !== $new_img )
674
- update_term_meta( $term_id, 'pwb_brand_banner', $new_img );
675
- /* ·············· /Brand banner ·············· */
676
-
677
- /* ·············· Brand banner link ·············· */
678
- if ( ! isset( $_POST['pwb_brand_banner_link_nonce'] ) || ! wp_verify_nonce( $_POST['pwb_brand_banner_link_nonce'], basename( __FILE__ ) ) )
679
- return;
680
-
681
- $old_img = get_term_meta( $term_id, 'pwb_brand_banner_link', true );
682
- $new_img = isset( $_POST['pwb_brand_banner_link'] ) ? $_POST['pwb_brand_banner_link'] : '';
683
-
684
- if ( $old_img && '' === $new_img )
685
- delete_term_meta( $term_id, 'pwb_brand_banner_link' );
686
-
687
- else if ( $old_img !== $new_img )
688
- update_term_meta( $term_id, 'pwb_brand_banner_link', $new_img );
689
- /* ·············· /Brand banner link ·············· */
690
- }
691
-
692
- public function brand_taxonomy_columns_head($defaults) {
693
- $newColumns = array(
694
- 'cb' => $defaults['cb'],
695
- 'logo' => __( 'Logo', 'perfect-woocommerce-brands' )
696
- );
697
-
698
- unset($defaults['description']);
699
- unset($defaults['cb']);
700
-
701
- return array_merge($newColumns,$defaults);
702
- }
703
-
704
- public function brand_taxonomy_columns($c, $column_name, $term_id){
705
- $image = wp_get_attachment_image( get_term_meta( $term_id, 'pwb_brand_image', 1 ), array('60','60') );
706
- if($image){
707
- return $image;
708
- }else{
709
- return "-";
710
- }
711
- }
712
-
713
- public static function get_brands(){
714
- $result = array();
715
-
716
- $brands = get_terms('pwb-brand',array(
717
- 'hide_empty' => false
718
- ));
719
-
720
- if(is_array($brands) && count($brands)>0){
721
- $result = $brands;
722
- }
723
-
724
- return $result;
725
-
726
- }
727
-
728
- public static function get_brands_array(){
729
- $result = array();
730
- $result[0] = 'all';
731
-
732
- $brands = get_terms('pwb-brand',array(
733
- 'hide_empty' => false
734
- ));
735
-
736
- foreach ($brands as $brand) {
737
- $result[$brand->term_id] = $brand->slug;
738
- }
739
-
740
- return $result;
741
-
742
- }
743
-
744
- public static function get_products_by_brand($brand_id, $count){
745
-
746
- if($brand_id === 'all'){
747
- $args = array(
748
- 'post_type' => 'product',
749
- 'posts_per_page' => $count,
750
- 'paged' => false
751
- );
752
- }else{
753
- $args = array(
754
- 'post_type' => 'product',
755
- 'tax_query' => array(
756
- array(
757
- 'taxonomy' => 'pwb-brand',
758
- 'field' => 'slug',
759
- 'terms' => $brand_id,
760
- )
761
- ),
762
- 'posts_per_page' => $count,
763
- 'paged' => false
764
- );
765
- }
766
-
767
- ob_start();
768
-
769
- $loop = new \WP_Query( $args );
770
- if ( $loop->have_posts() && function_exists('get_product') && function_exists('woocommerce_template_loop_add_to_cart') && function_exists('woocommerce_get_product_thumbnail') ) {
771
- while ( $loop->have_posts() ) : $loop->the_post();
772
- $product = get_product( get_the_ID() );
773
-
774
- echo '<div>';
775
- echo '<a href="'.get_the_permalink().'">';
776
- echo woocommerce_get_product_thumbnail();
777
- echo '<h3>'.$product->post->post_title.'</h3>';
778
- echo '<span class="pwb-amount">'.$product->get_price_html().'</span>';
779
- woocommerce_template_loop_add_to_cart();
780
- echo '</a>';
781
- echo '</div>';
782
-
783
- endwhile;
784
- } else {
785
- echo __( 'No products found', 'perfect-woocommerce-brands' );
786
- }
787
- wp_reset_postdata();
788
-
789
- return ob_get_clean();
790
-
791
- }
792
-
793
- public function archive_page_banner(){
794
- $queried_object = get_queried_object();
795
-
796
- if(is_a($queried_object,'WP_Term') && $queried_object->taxonomy == 'pwb-brand'){
797
- //pwb-brand archive
798
- $brand_banner = get_term_meta( $queried_object->term_id, 'pwb_brand_banner', true );
799
- $brand_banner_link = get_term_meta( $queried_object->term_id, 'pwb_brand_banner_link', true );
800
- if($brand_banner!=''){
801
- echo '<div class="pwb-brand-banner pwb-clearfix">';
802
- if($brand_banner_link!=''){
803
- echo '<a href="'.site_url($brand_banner_link).'">'.wp_get_attachment_image ( $brand_banner, 'full', false ).'</a>';
804
- }else{
805
- echo wp_get_attachment_image ( $brand_banner, 'full', false );
806
- }
807
- echo '</div>';
808
- }
809
- }
810
-
811
- }
812
-
813
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Perfect_Woocommerce_Brands;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
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( 'pwb-brand_add_form_fields', array( $this, 'add_brands_metafields_form' ) );
12
+ add_action( 'pwb-brand_edit_form_fields', array( $this, 'add_brands_metafields_form_edit' ) );
13
+ add_action( 'edit_pwb-brand', array( $this, 'add_brands_metafields_save' ) );
14
+ add_action( 'create_pwb-brand', array( $this, 'add_brands_metafields_save' ) );
15
+ add_filter( 'manage_edit-pwb-brand_columns', array( $this, 'brand_taxonomy_columns_head' ) );
16
+ add_filter( 'manage_pwb-brand_custom_column', array( $this, 'brand_taxonomy_columns' ), 10, 3 );
17
+ add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
18
+ $this->brand_logo_position();
19
+ add_action( 'woocommerce_before_shop_loop', array( $this, 'archive_page_banner' ), 9);
20
+ add_action( 'woocommerce_before_shop_loop', array( $this, 'show_brand_description' ), 9);
21
+ add_action( 'woocommerce_after_shop_loop_item_title', array( $this, 'show_brands_in_loop' ) );
22
+
23
+ if ( !is_admin() ) {
24
+ add_action( 'init', array( $this, 'register_frontend_scripts' ) );
25
+ }
26
+
27
+ $this->add_shortcodes();
28
+
29
+ if(is_plugin_active('js_composer/js_composer.php')){
30
+ add_action( 'vc_before_init', array( $this,'vc_map_shortcodes' ) );
31
+ }
32
+
33
+ add_action( 'widgets_init', array( $this, 'register_widgets' ) );
34
+ add_action( 'woocommerce_after_single_product_summary' , array( $this, 'product_microdata' ), 40 );
35
+ add_action( 'wp_ajax_pwb_admin_migrate_brands', array( $this, 'migrate_brands' ) );
36
+ add_action( 'pre_get_posts', array( $this, 'pwb_brand_filter' ) );
37
+ add_filter( 'plugin_action_links_' . PWB_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
38
+ add_action( 'wp_ajax_dismiss_pwb_notice', array( $this, 'dismiss_pwb_notice' ) );
39
+ add_action( 'admin_notices', array( $this, 'review_notice' ) );
40
+
41
+ }
42
+
43
+ public function review_notice(){
44
+ if ( get_option('wc_pwb_notice_plugin_review', true ) ) {
45
+ ?>
46
+ <div class="notice notice-info pwb-notice-dismissible is-dismissible" data-notice="wc_pwb_notice_plugin_review">
47
+ <p><?php echo __('We are offering you maybe the best WooCommerce brands plugin completly free. You can help us making Perfect WooCommerce Brands a bit better. Thanks!', 'perfect-woocommerce-brands' ); ?><span class="dashicons dashicons-heart"></span></p>
48
+ <p>
49
+ <?php _e( '<a href="https://wordpress.org/support/plugin/perfect-woocommerce-brands/reviews/?rate=5#new-post" target="_blank">Leave a review</a>', 'perfect-woocommerce-brands' ); ?>
50
+ <?php _e( '<a href="https://translate.wordpress.org/projects/wp-plugins/perfect-woocommerce-brands" target="_blank">Translate the plugin</a>', 'perfect-woocommerce-brands' ); ?>
51
+ <?php _e( '<a href="https://github.com/titodevera/perfect-woocommerce-brands" target="_blank">View on GitHub</a>', 'perfect-woocommerce-brands' ); ?>
52
+ </p>
53
+ </div>
54
+ <?php
55
+ }
56
+ }
57
+
58
+ public function dismiss_pwb_notice(){
59
+ $notice_name_whitelist = array( 'wc_pwb_notice_plugin_review' );
60
+ if( isset( $_POST['notice_name'] ) && in_array( $_POST['notice_name'], $notice_name_whitelist ) ){
61
+ update_option( $_POST['notice_name'], 0 );
62
+ echo 'ok';
63
+ }else{
64
+ echo 'error';
65
+ }
66
+ wp_die();
67
+ }
68
+
69
+ /**
70
+ * Adds a settings shortcut to plugin´s actions on plugins list
71
+ */
72
+ public function plugin_action_links( $links ) {
73
+ $settings_url = esc_url( admin_url( 'admin.php?page=wc-settings&tab=pwb_admin_tab' ) );
74
+ $links[] = '<a href="'. $settings_url .'">'.__('Settings','perfect-woocommerce-brands').'</a>';
75
+ return $links;
76
+ }
77
+
78
+ public function pwb_brand_filter( $query ){
79
+
80
+ if( !empty($_GET['pwb-brand-filter']) ){
81
+
82
+ $terms_array = explode(',',$_GET['pwb-brand-filter']);
83
+
84
+ //remove invalid terms (security)
85
+ for ($i=0; $i < count($terms_array); $i++) {
86
+ if( !term_exists( $terms_array[$i], 'pwb-brand' ) ){
87
+ unset($terms_array[$i]);
88
+ }
89
+ }
90
+
91
+ if ( !is_admin() && is_post_type_archive( 'product' ) && $query->is_main_query() ) {
92
+
93
+ $query->set('tax_query', array(
94
+ array (
95
+ 'taxonomy' => 'pwb-brand',
96
+ 'field' => 'slug',
97
+ 'terms' => $terms_array
98
+ )
99
+ ));
100
+
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ public function migrate_brands(){
108
+
109
+ if( isset( $_POST['from'] ) ){
110
+
111
+ switch ($_POST['from']) {
112
+ case 'yith':
113
+
114
+ $terms = get_terms( 'yith_product_brand', array(
115
+ 'hide_empty' => false
116
+ ) );
117
+
118
+ foreach ($terms as $term) {
119
+
120
+ global $wpdb;
121
+
122
+ //change taxonomy
123
+ $wpdb->update(
124
+ $wpdb->prefix . 'term_taxonomy',
125
+ array(
126
+ 'taxonomy' => 'pwb-brand'
127
+ ),
128
+ array(
129
+ 'term_id' => $term->term_id
130
+ )
131
+ );
132
+
133
+ //update term meta
134
+ $wpdb->update(
135
+ $wpdb->prefix . 'termmeta',
136
+ array(
137
+ 'meta_key' => 'pwb_brand_image'
138
+ ),
139
+ array(
140
+ 'meta_key' => 'thumbnail_id',
141
+ 'term_id' => $term->term_id
142
+ )
143
+ );
144
+
145
+ }
146
+
147
+ break;
148
+ }
149
+
150
+ }
151
+
152
+ wp_die();
153
+ }
154
+
155
+ /*
156
+ * Adds microdata (brands) to single products
157
+ */
158
+ public function product_microdata(){
159
+ global $product;
160
+ $brands = wp_get_post_terms( $product->id, 'pwb-brand');
161
+
162
+ foreach ($brands as $brand) {
163
+ echo '<meta itemprop="brand" content="'.$brand->name.'">';
164
+ }
165
+
166
+ }
167
+
168
+ public function add_shortcodes(){
169
+ add_shortcode( 'pwb-carousel', array(
170
+ '\Perfect_Woocommerce_Brands\Shortcodes\PWB_Carousel_Shortcode',
171
+ 'carousel_shortcode'
172
+ ) );
173
+ add_shortcode( 'pwb-product-carousel', array(
174
+ '\Perfect_Woocommerce_Brands\Shortcodes\PWB_Product_Carousel_Shortcode',
175
+ 'product_carousel_shortcode'
176
+ ) );
177
+ add_shortcode( 'pwb-all-brands', array(
178
+ '\Perfect_Woocommerce_Brands\Shortcodes\PWB_All_Brands_Shortcode',
179
+ 'all_brands_shortcode'
180
+ ) );
181
+ add_shortcode( 'pwb-brand', array(
182
+ '\Perfect_Woocommerce_Brands\Shortcodes\PWB_Brand_Shortcode',
183
+ 'brand_shortcode'
184
+ ) );
185
+ }
186
+
187
+ public function register_widgets(){
188
+ register_widget( '\Perfect_Woocommerce_Brands\Widgets\PWB_List_Widget' );
189
+ register_widget( '\Perfect_Woocommerce_Brands\Widgets\PWB_Dropdown_Widget' );
190
+ register_widget( '\Perfect_Woocommerce_Brands\Widgets\PWB_Filter_By_Brand_Widget' );
191
+ }
192
+
193
+ public function show_brand_description(){
194
+ $show_desc = get_option('wc_pwb_admin_tab_brand_desc');
195
+ $queried_object = get_queried_object();
196
+ if(is_a($queried_object,'WP_Term') && $queried_object->taxonomy == 'pwb-brand' && $queried_object->description != '' && $show_desc !== 'no'){
197
+ echo '<div class="pwb-brand-description">';
198
+ echo $queried_object->description;
199
+ echo '</div>';
200
+ }
201
+ }
202
+
203
+ public function show_brands_in_loop(){
204
+
205
+ $brands_in_loop = get_option('wc_pwb_admin_tab_brands_in_loop');
206
+
207
+ if( $brands_in_loop == 'brand_link' || $brands_in_loop == 'brand_image' ){
208
+
209
+ global $product;
210
+ $product_id = $product->id;
211
+ $product_brands = wp_get_post_terms($product_id, 'pwb-brand');
212
+ if(!empty($product_brands)){
213
+ echo '<div class="pwb-brands-in-loop">';
214
+ foreach ($product_brands as $brand) {
215
+
216
+ echo '<span>';
217
+ $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
218
+ $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
219
+
220
+ $attachment_html = wp_get_attachment_image( $attachment_id, 'thumbnail' );
221
+ if( !empty($attachment_html) && $brands_in_loop == 'brand_image' ){
222
+ echo '<a href="'.$brand_link.'">'.$attachment_html.'</a>';
223
+ }else{
224
+ echo '<a href="'.$brand_link.'">'.$brand->name.'</a>';
225
+ }
226
+ echo '</span>';
227
+
228
+ }
229
+ echo '</div>';
230
+ }
231
+
232
+ }
233
+
234
+ }
235
+
236
+ /**
237
+ * woocommerce_single_product_summary hook.
238
+ *
239
+ * @hooked woocommerce_template_single_title - 5
240
+ * @hooked woocommerce_template_single_rating - 10
241
+ * @hooked woocommerce_template_single_price - 10
242
+ * @hooked woocommerce_template_single_excerpt - 20
243
+ * @hooked woocommerce_template_single_add_to_cart - 30
244
+ * @hooked woocommerce_template_single_meta - 40
245
+ * @hooked woocommerce_template_single_sharing - 50
246
+ */
247
+ private function brand_logo_position(){
248
+ $position = 41;
249
+ $position_selected = get_option('wc_pwb_admin_tab_brand_single_position');
250
+ if(!$position_selected){
251
+ update_option('wc_pwb_admin_tab_brand_single_position','after_meta');
252
+ }
253
+ switch ($position_selected) {
254
+ case 'before_title':
255
+ $position = 4;
256
+ break;
257
+ case 'after_title':
258
+ $position = 6;
259
+ break;
260
+ case 'after_price':
261
+ $position = 11;
262
+ break;
263
+ case 'after_excerpt':
264
+ $position = 21;
265
+ break;
266
+ case 'after_add_to_cart':
267
+ $position = 31;
268
+ break;
269
+ case 'after_meta':
270
+ $position = 41;
271
+ break;
272
+ case 'after_sharing':
273
+ $position = 51;
274
+ break;
275
+ }
276
+ add_action('woocommerce_single_product_summary', array($this,'action_woocommerce_single_product_summary'), $position);
277
+ }
278
+
279
+
280
+ /*
281
+ * Maps shortcode (for visual composer plugin)
282
+ *
283
+ * @since 1.0
284
+ * @link https://vc.wpbakery.com/
285
+ * @return mixed
286
+ */
287
+ public function vc_map_shortcodes(){
288
+ $available_image_sizes_adapted = array();
289
+ $available_image_sizes = get_intermediate_image_sizes();
290
+
291
+ foreach($available_image_sizes as $image_size){
292
+ $available_image_sizes_adapted[$image_size] = $image_size;
293
+ }
294
+
295
+ vc_map(array(
296
+ "name" => __( "PWB Product carousel", "perfect-woocommerce-brands" ),
297
+ "description" => __( "Product carousel by brand or by category", "perfect-woocommerce-brands" ),
298
+ "base" => "pwb-product-carousel",
299
+ "class" => "",
300
+ "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
301
+ "category" => "WooCommerce",
302
+ "params" => array(
303
+ array(
304
+ "type" => "dropdown",
305
+ "heading" => __( "Brand", "perfect-woocommerce-brands" ),
306
+ "param_name" => "brand",
307
+ "admin_label" => true,
308
+ "value" => $this->get_brands_array()
309
+ ),
310
+ array(
311
+ "type" => "textfield",
312
+ "holder" => "div",
313
+ "heading" => __( "Products", "perfect-woocommerce-brands" ),
314
+ "param_name" => "products",
315
+ "value" => "10",
316
+ "description" => __( "Number of products to load", "perfect-woocommerce-brands" )
317
+ ),
318
+ array(
319
+ "type" => "textfield",
320
+ "holder" => "div",
321
+ "heading" => __( "Products to show", "perfect-woocommerce-brands" ),
322
+ "param_name" => "products_to_show",
323
+ "value" => "5",
324
+ "description" => __( "Number of products to show", "perfect-woocommerce-brands" )
325
+ ),
326
+ array(
327
+ "type" => "textfield",
328
+ "holder" => "div",
329
+ "heading" => __( "Products to scroll", "perfect-woocommerce-brands" ),
330
+ "param_name" => "products_to_scroll",
331
+ "value" => "1",
332
+ "description" => __( "Number of products to scroll", "perfect-woocommerce-brands" )
333
+ ),
334
+ array(
335
+ "type" => "checkbox",
336
+ "holder" => "div",
337
+ "heading" => __( "Autoplay", "perfect-woocommerce-brands" ),
338
+ "param_name" => "autoplay",
339
+ "description" => __( "Autoplay carousel", "perfect-woocommerce-brands" )
340
+ ),
341
+ array(
342
+ "type" => "checkbox",
343
+ "holder" => "div",
344
+ "heading" => __( "Arrows", "perfect-woocommerce-brands" ),
345
+ "param_name" => "arrows",
346
+ "description" => __( "Display prev and next arrows", "perfect-woocommerce-brands" )
347
+ )
348
+ )
349
+ ));
350
+
351
+ vc_map(array(
352
+ "name" => __( "PWB Brands carousel", "perfect-woocommerce-brands" ),
353
+ "description" => __( "Brands carousel", "perfect-woocommerce-brands" ),
354
+ "base" => "pwb-carousel",
355
+ "class" => "",
356
+ "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
357
+ "category" => "WooCommerce",
358
+ "params" => array(
359
+ array(
360
+ "type" => "textfield",
361
+ "holder" => "div",
362
+ "heading" => __( "Items", "perfect-woocommerce-brands" ),
363
+ "param_name" => "items",
364
+ "value" => "10",
365
+ "description" => __( "Number of items to load", "perfect-woocommerce-brands" )
366
+ ),
367
+ array(
368
+ "type" => "textfield",
369
+ "holder" => "div",
370
+ "heading" => __( "Items to show", "perfect-woocommerce-brands" ),
371
+ "param_name" => "items_to_show",
372
+ "value" => "5",
373
+ "description" => __( "Number of items to show", "perfect-woocommerce-brands" )
374
+ ),
375
+ array(
376
+ "type" => "textfield",
377
+ "holder" => "div",
378
+ "heading" => __( "Items to scroll", "perfect-woocommerce-brands" ),
379
+ "param_name" => "items_to_scroll",
380
+ "value" => "1",
381
+ "description" => __( "Number of items to scroll", "perfect-woocommerce-brands" )
382
+ ),
383
+ array(
384
+ "type" => "checkbox",
385
+ "holder" => "div",
386
+ "heading" => __( "Autoplay", "perfect-woocommerce-brands" ),
387
+ "param_name" => "autoplay",
388
+ "description" => __( "Autoplay carousel", "perfect-woocommerce-brands" )
389
+ ),
390
+ array(
391
+ "type" => "checkbox",
392
+ "holder" => "div",
393
+ "heading" => __( "Arrows", "perfect-woocommerce-brands" ),
394
+ "param_name" => "arrows",
395
+ "description" => __( "Display prev and next arrows", "perfect-woocommerce-brands" )
396
+ ),
397
+ array(
398
+ "type" => "dropdown",
399
+ "heading" => __( "Brand logo size", "perfect-woocommerce-brands" ),
400
+ "param_name" => "image_size",
401
+ "admin_label" => true,
402
+ "value" => $available_image_sizes_adapted
403
+ )
404
+ )
405
+
406
+
407
+ ));
408
+
409
+ vc_map(array(
410
+ "name" => __( "PWB All brands", "perfect-woocommerce-brands" ),
411
+ "description" => __( "Show all brands", "perfect-woocommerce-brands" ),
412
+ "base" => "pwb-all-brands",
413
+ "class" => "",
414
+ "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
415
+ "category" => "WooCommerce",
416
+ "params" => array(
417
+ array(
418
+ "type" => "textfield",
419
+ "holder" => "div",
420
+ "heading" => __( "Brands per page", "perfect-woocommerce-brands" ),
421
+ "param_name" => "per_page",
422
+ "value" => "10",
423
+ "description" => __( "Show x brands per page", "perfect-woocommerce-brands" )
424
+ ),
425
+ array(
426
+ "type" => "dropdown",
427
+ "heading" => __( "Brand logo size", "perfect-woocommerce-brands" ),
428
+ "param_name" => "image_size",
429
+ "admin_label" => true,
430
+ "value" => $available_image_sizes_adapted
431
+ ),
432
+ array(
433
+ "type" => "checkbox",
434
+ "holder" => "div",
435
+ "heading" => __( "Hide empty", "perfect-woocommerce-brands" ),
436
+ "param_name" => "hide_empty",
437
+ "description" => __( "Hide brands that have not been assigned to any product", "perfect-woocommerce-brands" )
438
+ )
439
+ )
440
+
441
+
442
+ ));
443
+
444
+ vc_map(array(
445
+ "name" => __( "PWB brand", "perfect-woocommerce-brands" ),
446
+ "description" => __( "Show brand for a specific product", "perfect-woocommerce-brands" ),
447
+ "base" => "pwb-brand",
448
+ "class" => "",
449
+ "icon" => PWB_PLUGIN.'/assets/img/icon_pwb.jpg',
450
+ "category" => "WooCommerce",
451
+
452
+ "params" => array(
453
+ array(
454
+ "type" => "textfield",
455
+ "holder" => "div",
456
+ "heading" => __( "Product id", "perfect-woocommerce-brands" ),
457
+ "param_name" => "product_id",
458
+ "value" => null,
459
+ "description" => __( "Product id (post id)", "perfect-woocommerce-brands" )
460
+ ),
461
+ array(
462
+ "type" => "dropdown",
463
+ "heading" => __( "Brand logo size", "perfect-woocommerce-brands" ),
464
+ "param_name" => "image_size",
465
+ "admin_label" => true,
466
+ "value" => $available_image_sizes_adapted
467
+ )
468
+
469
+ )
470
+
471
+
472
+ ));
473
+ }
474
+
475
+ public function action_woocommerce_single_product_summary() {
476
+ $brands = wp_get_post_terms( get_the_ID(), 'pwb-brand');
477
+
478
+ if(!is_wp_error($brands)){
479
+
480
+ if(sizeof($brands>0)){
481
+
482
+ $show_as = get_option( 'wc_pwb_admin_tab_brands_in_single' );
483
+
484
+ if( $show_as!='no' ){
485
+
486
+ echo '<div class="pwb-single-product-brands pwb-clearfix">';
487
+ foreach($brands as $brand){
488
+ $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
489
+ $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
490
+
491
+ $image_size = 'thumbnail';
492
+ $image_size_selected = get_option('wc_pwb_admin_tab_brand_logo_size');
493
+ if($image_size_selected!=false){
494
+ $image_size = $image_size_selected;
495
+ }
496
+
497
+ $attachment_html = wp_get_attachment_image($attachment_id,$image_size);
498
+ if( !empty($attachment_html) && $show_as=='brand_image' ){
499
+ echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
500
+ }else{
501
+ echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$brand->name.'</a>';
502
+ }
503
+ }
504
+ echo '</div>';
505
+
506
+ }
507
+
508
+ }
509
+
510
+ }
511
+
512
+ }
513
+
514
+ public function register_frontend_scripts(){
515
+
516
+ wp_register_script(
517
+ 'pwb_slick_lib',
518
+ PWB_PLUGIN . '/assets/js/slick/slick.min.js',
519
+ array('jquery'),
520
+ '1.5.9',
521
+ true
522
+ );
523
+ wp_enqueue_script('pwb_frontend_functions');
524
+
525
+ wp_enqueue_style (
526
+ 'pwb_slick_lib',
527
+ PWB_PLUGIN . '/assets/js/slick/slick.css',
528
+ array(),
529
+ '1.5.9',
530
+ 'all'
531
+ );
532
+
533
+ wp_enqueue_style (
534
+ 'pwb_frontend_styles',
535
+ PWB_PLUGIN . '/assets/css/styles-frontend.css',
536
+ array('pwb_slick_lib'),
537
+ PWB_PLUGIN_VERSION,
538
+ 'all'
539
+ );
540
+
541
+ wp_register_script(
542
+ 'pwb_frontend_functions',
543
+ PWB_PLUGIN . '/assets/js/pwb_frontend_functions.js',
544
+ array('jquery','pwb_slick_lib'),
545
+ PWB_PLUGIN_VERSION,
546
+ true
547
+ );
548
+ wp_enqueue_script('pwb_frontend_functions');
549
+
550
+ }
551
+
552
+ public function register_admin_scripts($hook){
553
+ $screen = get_current_screen();
554
+
555
+ wp_register_style('pwb_styles_brands', plugins_url('perfect-woocommerce-brands/assets/css/styles-admin.css'), array(), PWB_PLUGIN_VERSION);
556
+ wp_register_script('pwb_brands_js', plugins_url('perfect-woocommerce-brands/assets/js/pwb_admin_functions.js'), array('jquery'), PWB_PLUGIN_VERSION, true);
557
+
558
+ if ($hook == 'edit-tags.php' && $screen->taxonomy == 'pwb-brand' || $hook == 'term.php' && $screen->taxonomy == 'pwb-brand') {
559
+ wp_enqueue_media();
560
+ }
561
+
562
+ wp_enqueue_style( 'pwb_styles_brands' );
563
+ wp_enqueue_script( 'pwb_brands_js' );
564
+ wp_localize_script( 'pwb_brands_js', 'ajax_object', array(
565
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
566
+ 'brands_url' => admin_url( 'edit-tags.php?taxonomy=pwb-brand&post_type=product' ),
567
+ 'translations' => array(
568
+ 'migrate_notice' => __('¿Start migration?','perfect-woocommerce-brands'),
569
+ 'migrating' => __('We are migrating the product brands. ¡Don´t close this window until the process is finished!','perfect-woocommerce-brands')
570
+ )
571
+ ) );
572
+
573
+ }
574
+
575
+ public function register_brands_taxonomy(){
576
+ $labels = array(
577
+ 'name' => __( 'Brands', 'perfect-woocommerce-brands' ),
578
+ 'singular_name' => __( 'Brand', 'perfect-woocommerce-brands' ),
579
+ 'menu_name' => __( 'Brands', 'perfect-woocommerce-brands' ),
580
+ 'all_items' => __( 'All Brands', 'perfect-woocommerce-brands' ),
581
+ 'edit_item' => __( 'Edit Brand', 'perfect-woocommerce-brands' ),
582
+ 'view_item' => __( 'View Brand', 'perfect-woocommerce-brands' ),
583
+ 'update_item' => __( 'Update Brand', 'perfect-woocommerce-brands' ),
584
+ 'add_new_item' => __( 'Add New Brand', 'perfect-woocommerce-brands' ),
585
+ 'new_item_name' => __( 'New Brand Name', 'perfect-woocommerce-brands' ),
586
+ 'parent_item' => __( 'Parent Brand', 'perfect-woocommerce-brands' ),
587
+ 'parent_item_colon' => __( 'Parent Brand:', 'perfect-woocommerce-brands' ),
588
+ 'search_items' => __( 'Search Brands', 'perfect-woocommerce-brands' ),
589
+ 'popular_items' => __( 'Popular Brands', 'perfect-woocommerce-brands' ),
590
+ 'separate_items_with_commas' => __( 'Separate brands with commas', 'perfect-woocommerce-brands' ),
591
+ 'add_or_remove_items' => __( 'Add or remove brands', 'perfect-woocommerce-brands' ),
592
+ 'choose_from_most_used' => __( 'Choose from the most used brands', 'perfect-woocommerce-brands' ),
593
+ 'not_found' => __( 'No brands found', 'perfect-woocommerce-brands' )
594
+ );
595
+
596
+ $new_slug = get_option('wc_pwb_admin_tab_slug');
597
+ $old_slug = get_option('old_wc_pwb_admin_tab_slug');
598
+
599
+ $new_slug = ($new_slug!=false) ? $new_slug : 'brand';
600
+ $old_slug = ($old_slug!=false) ? $old_slug : 'null';
601
+
602
+ $args = array(
603
+ 'hierarchical' => true,
604
+ 'labels' => $labels,
605
+ 'show_ui' => true,
606
+ 'query_var' => true,
607
+ 'public' => true,
608
+ 'show_admin_column' => true,
609
+ 'rewrite' => array(
610
+ 'slug' => $new_slug,
611
+ 'hierarchical' => true,
612
+ 'ep_mask' => EP_PERMALINK
613
+ )
614
+ );
615
+
616
+ register_taxonomy( 'pwb-brand', array( 'product' ), $args );
617
+
618
+ if($new_slug != false && $old_slug!= false && $new_slug != $old_slug){
619
+ flush_rewrite_rules();
620
+ update_option( 'old_wc_pwb_admin_tab_slug', $new_slug );
621
+ }
622
+
623
+ }
624
+
625
+ public function add_brands_metafields(){
626
+ register_meta( 'term', 'pwb_brand_image', array($this,'add_brands_metafields_sanitize') );
627
+ }
628
+
629
+ public function add_brands_metafields_sanitize($brand_img){
630
+ return $brand_img;
631
+ }
632
+
633
+ public function add_brands_metafields_form(){
634
+ ob_start();
635
+ ?>
636
+ <div class="form-field pwb_brand_cont">
637
+ <label for="pwb_brand_image"><?php _e( 'Brand logo', 'perfect-woocommerce-brands' ); ?></label>
638
+ <input type="text" name="pwb_brand_image" id="pwb_brand_image" value="" >
639
+ <a href="#" id="pwb_brand_image_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
640
+ </div>
641
+
642
+ <div class="form-field pwb_brand_cont">
643
+ <label for="pwb_brand_banner"><?php _e( 'Brand banner', 'perfect-woocommerce-brands' ); ?></label>
644
+ <input type="text" name="pwb_brand_banner" id="pwb_brand_banner" value="" >
645
+ <a href="#" id="pwb_brand_banner_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
646
+ <p><?php _e( 'This image will be shown on brand page', 'perfect-woocommerce-brands' ); ?></p>
647
+ </div>
648
+
649
+ <div class="form-field pwb_brand_cont">
650
+ <label for="pwb_brand_banner_link"><?php _e( 'Brand banner link', 'perfect-woocommerce-brands' ); ?></label>
651
+ <input type="text" name="pwb_brand_banner_link" id="pwb_brand_banner_link" value="" >
652
+ <p><?php _e( 'This link should be relative to site url. Example: product/product-name', 'perfect-woocommerce-brands' ); ?></p>
653
+ </div>
654
+
655
+ <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_nonce' ); ?>
656
+
657
+ <?php
658
+ echo ob_get_clean();
659
+ }
660
+
661
+ public function add_brands_metafields_form_edit($term){
662
+ $term_value_image = get_term_meta( $term->term_id, 'pwb_brand_image', true );
663
+ $term_value_banner = get_term_meta( $term->term_id, 'pwb_brand_banner', true );
664
+ $term_value_banner_link = get_term_meta( $term->term_id, 'pwb_brand_banner_link', true );
665
+ ob_start();
666
+ ?>
667
+ <table class="form-table pwb_brand_cont">
668
+ <tr class="form-field">
669
+ <th>
670
+ <label for="pwb_brand_image"><?php _e( 'Brand logo', 'perfect-woocommerce-brands' ); ?></label>
671
+ </th>
672
+ <td>
673
+ <input type="text" name="pwb_brand_image" id="pwb_brand_image" value="<?php echo $term_value_image;?>" >
674
+ <a href="#" id="pwb_brand_image_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
675
+
676
+ <?php $current_image = wp_get_attachment_image ( $term_value_image, array('90','90'), false ); ?>
677
+ <?php if( !empty($current_image) ): ?>
678
+ <div class="pwb_brand_image_selected">
679
+ <span>
680
+ <?php echo $current_image;?>
681
+ <a href="#" class="pwb_brand_image_selected_remove">X</a>
682
+ </span>
683
+ </div>
684
+ <?php endif; ?>
685
+
686
+ </td>
687
+ </tr>
688
+ <tr class="form-field">
689
+ <th>
690
+ <label for="pwb_brand_banner"><?php _e( 'Brand banner', 'perfect-woocommerce-brands' ); ?></label>
691
+ </th>
692
+ <td>
693
+ <input type="text" name="pwb_brand_banner" id="pwb_brand_banner" value="<?php echo $term_value_banner;?>" >
694
+ <a href="#" id="pwb_brand_banner_select" class="button"><?php _e('Select image','perfect-woocommerce-brands');?></a>
695
+
696
+ <?php $current_image = wp_get_attachment_image ( $term_value_banner, array('90','90'), false ); ?>
697
+ <?php if( !empty($current_image) ): ?>
698
+ <div class="pwb_brand_image_selected">
699
+ <span>
700
+ <?php echo $current_image;?>
701
+ <a href="#" class="pwb_brand_image_selected_remove">X</a>
702
+ </span>
703
+ </div>
704
+ <?php endif; ?>
705
+
706
+ </td>
707
+ </tr>
708
+ <tr class="form-field">
709
+ <th>
710
+ <label for="pwb_brand_banner_link"><?php _e( 'Brand banner link', 'perfect-woocommerce-brands' ); ?></label>
711
+ </th>
712
+ <td>
713
+ <input type="text" name="pwb_brand_banner_link" id="pwb_brand_banner_link" value="<?php echo $term_value_banner_link;?>" >
714
+ <p class="description"><?php _e( 'This link should be relative to site url. Example: product/product-name', 'perfect-woocommerce-brands' ); ?></p>
715
+ <div id="pwb_brand_banner_link_result"><?php echo wp_get_attachment_image ( $term_value_banner_link, array('90','90'), false );?></div>
716
+ </td>
717
+ </tr>
718
+ </table>
719
+
720
+ <?php echo wp_nonce_field( basename( __FILE__ ), 'pwb_nonce' );?>
721
+
722
+ <?php
723
+ echo ob_get_clean();
724
+ }
725
+
726
+ public function add_brands_metafields_save( $term_id ){
727
+
728
+ if ( ! isset( $_POST['pwb_nonce'] ) || ! wp_verify_nonce( $_POST['pwb_nonce'], basename( __FILE__ ) ) )
729
+ return;
730
+
731
+ /* ·············· Brand image ·············· */
732
+ $old_img = get_term_meta( $term_id, 'pwb_brand_image', true );
733
+ $new_img = isset( $_POST['pwb_brand_image'] ) ? $_POST['pwb_brand_image'] : '';
734
+
735
+ if ( $old_img && '' === $new_img )
736
+ delete_term_meta( $term_id, 'pwb_brand_image' );
737
+
738
+ else if ( $old_img !== $new_img )
739
+ update_term_meta( $term_id, 'pwb_brand_image', $new_img );
740
+ /* ·············· /Brand image ·············· */
741
+
742
+ /* ·············· Brand banner ·············· */
743
+ $old_img = get_term_meta( $term_id, 'pwb_brand_banner', true );
744
+ $new_img = isset( $_POST['pwb_brand_banner'] ) ? $_POST['pwb_brand_banner'] : '';
745
+
746
+ if ( $old_img && '' === $new_img )
747
+ delete_term_meta( $term_id, 'pwb_brand_banner' );
748
+
749
+ else if ( $old_img !== $new_img )
750
+ update_term_meta( $term_id, 'pwb_brand_banner', $new_img );
751
+ /* ·············· /Brand banner ·············· */
752
+
753
+ /* ·············· Brand banner link ·············· */
754
+ $old_img = get_term_meta( $term_id, 'pwb_brand_banner_link', true );
755
+ $new_img = isset( $_POST['pwb_brand_banner_link'] ) ? $_POST['pwb_brand_banner_link'] : '';
756
+
757
+ if ( $old_img && '' === $new_img )
758
+ delete_term_meta( $term_id, 'pwb_brand_banner_link' );
759
+
760
+ else if ( $old_img !== $new_img )
761
+ update_term_meta( $term_id, 'pwb_brand_banner_link', $new_img );
762
+ /* ·············· /Brand banner link ·············· */
763
+ }
764
+
765
+ public function brand_taxonomy_columns_head($defaults) {
766
+ $newColumns = array(
767
+ 'cb' => $defaults['cb'],
768
+ 'logo' => __( 'Logo', 'perfect-woocommerce-brands' )
769
+ );
770
+
771
+ unset($defaults['description']);
772
+ unset($defaults['cb']);
773
+
774
+ return array_merge($newColumns,$defaults);
775
+ }
776
+
777
+ public function brand_taxonomy_columns($c, $column_name, $term_id){
778
+ $image = wp_get_attachment_image( get_term_meta( $term_id, 'pwb_brand_image', 1 ), array('60','60') );
779
+ if($image){
780
+ return $image;
781
+ }else{
782
+ return "-";
783
+ }
784
+ }
785
+
786
+ public static function get_brands( $hide_empty = false ){
787
+ $result = array();
788
+
789
+ $brands = get_terms('pwb-brand',array(
790
+ 'hide_empty' => $hide_empty
791
+ ));
792
+
793
+ if(is_array($brands) && count($brands)>0){
794
+ $result = $brands;
795
+ }
796
+
797
+ return $result;
798
+
799
+ }
800
+
801
+ public static function get_brands_array(){
802
+ $result = array();
803
+ $result[0] = 'all';
804
+
805
+ $brands = get_terms('pwb-brand',array(
806
+ 'hide_empty' => false
807
+ ));
808
+
809
+ foreach ($brands as $brand) {
810
+ $result[$brand->term_id] = $brand->slug;
811
+ }
812
+
813
+ return $result;
814
+
815
+ }
816
+
817
+ public static function get_products_by_brand($brand_id, $count){
818
+
819
+ if($brand_id === 'all'){
820
+ $args = array(
821
+ 'post_type' => 'product',
822
+ 'posts_per_page' => $count,
823
+ 'paged' => false
824
+ );
825
+ }else{
826
+ $args = array(
827
+ 'post_type' => 'product',
828
+ 'tax_query' => array(
829
+ array(
830
+ 'taxonomy' => 'pwb-brand',
831
+ 'field' => 'slug',
832
+ 'terms' => $brand_id,
833
+ )
834
+ ),
835
+ 'posts_per_page' => $count,
836
+ 'paged' => false
837
+ );
838
+ }
839
+
840
+ ob_start();
841
+
842
+ $loop = new \WP_Query( $args );
843
+ if ( $loop->have_posts() && function_exists('get_product') && function_exists('woocommerce_template_loop_add_to_cart') && function_exists('woocommerce_get_product_thumbnail') ) {
844
+ while ( $loop->have_posts() ) : $loop->the_post();
845
+ $product = get_product( get_the_ID() );
846
+
847
+ echo '<div>';
848
+ echo '<a href="'.get_the_permalink().'">';
849
+ echo woocommerce_get_product_thumbnail();
850
+ echo '<h3>'.$product->post->post_title.'</h3>';
851
+ echo '<span class="pwb-amount">'.$product->get_price_html().'</span>';
852
+ woocommerce_template_loop_add_to_cart();
853
+ echo '</a>';
854
+ echo '</div>';
855
+
856
+ endwhile;
857
+ } else {
858
+ echo __( 'No products found', 'perfect-woocommerce-brands' );
859
+ }
860
+ wp_reset_postdata();
861
+
862
+ return ob_get_clean();
863
+
864
+ }
865
+
866
+ public function archive_page_banner(){
867
+ $queried_object = get_queried_object();
868
+
869
+ if(is_a($queried_object,'WP_Term') && $queried_object->taxonomy == 'pwb-brand'){
870
+ //pwb-brand archive
871
+ $brand_banner = get_term_meta( $queried_object->term_id, 'pwb_brand_banner', true );
872
+ $brand_banner_link = get_term_meta( $queried_object->term_id, 'pwb_brand_banner_link', true );
873
+ if($brand_banner!=''){
874
+ echo '<div class="pwb-brand-banner pwb-clearfix">';
875
+ if($brand_banner_link!=''){
876
+ echo '<a href="'.site_url($brand_banner_link).'">'.wp_get_attachment_image ( $brand_banner, 'full', false ).'</a>';
877
+ }else{
878
+ echo wp_get_attachment_image ( $brand_banner, 'full', false );
879
+ }
880
+ echo '</div>';
881
+ }
882
+ }
883
+
884
+ }
885
+
886
+ }
classes/class-pwb-admin-tab.php CHANGED
@@ -1,165 +1,177 @@
1
- <?php
2
- namespace Perfect_Woocommerce_Brands\Admin;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
6
- class Pwb_Admin_Tab {
7
-
8
- public static function init() {
9
- add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
10
- add_action( 'woocommerce_settings_tabs_pwb_admin_tab', __CLASS__ . '::settings_tab' );
11
- add_action( 'woocommerce_update_options_pwb_admin_tab', __CLASS__ . '::update_settings' );
12
- }
13
-
14
- /**
15
- * Add a new settings tab to the WooCommerce settings tabs array.
16
- *
17
- * @param array $settings_tabs Array of WooCommerce setting tabs & their labels, excluding the Subscription tab.
18
- * @return array $settings_tabs Array of WooCommerce setting tabs & their labels, including the Subscription tab.
19
- */
20
- public static function add_settings_tab( $settings_tabs ) {
21
- $settings_tabs['pwb_admin_tab'] = __( 'Brands', 'perfect-woocommerce-brands' );
22
- return $settings_tabs;
23
- }
24
-
25
-
26
- /**
27
- * Uses the WooCommerce admin fields API to output settings via the @see woocommerce_admin_fields() function.
28
- *
29
- * @uses woocommerce_admin_fields()
30
- * @uses self::get_settings()
31
- */
32
- public static function settings_tab() {
33
- woocommerce_admin_fields( self::get_settings() );
34
- woocommerce_admin_fields( self::get_tools() );
35
- }
36
-
37
-
38
- /**
39
- * Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function.
40
- *
41
- * @uses woocommerce_update_options()
42
- * @uses self::get_settings()
43
- */
44
- public static function update_settings() {
45
- update_option( 'old_wc_pwb_admin_tab_slug', get_taxonomy('pwb-brand')->rewrite['slug'] );
46
-
47
- if(isset($_POST['wc_pwb_admin_tab_slug'])){
48
- $_POST['wc_pwb_admin_tab_slug'] = sanitize_title($_POST['wc_pwb_admin_tab_slug']);
49
- }
50
-
51
- woocommerce_update_options( self::get_settings() );
52
-
53
- }
54
-
55
-
56
- /**
57
- * Get all the settings for this plugin for @see woocommerce_admin_fields() function.
58
- *
59
- * @return array Array of settings for @see woocommerce_admin_fields() function.
60
- */
61
- public static function get_settings() {
62
-
63
- $available_image_sizes_adapted = array();
64
- $available_image_sizes = get_intermediate_image_sizes();
65
-
66
- foreach($available_image_sizes as $image_size){
67
- $available_image_sizes_adapted[$image_size] = $image_size;
68
- }
69
-
70
- $settings = array(
71
- 'section_title' => array(
72
- 'name' => __( 'Brands settings', 'perfect-woocommerce-brands' ),
73
- 'type' => 'title',
74
- 'desc' => '',
75
- 'id' => 'wc_pwb_admin_tab_section_title'
76
- ),
77
- 'slug' => array(
78
- 'name' => __( 'Slug', 'perfect-woocommerce-brands' ),
79
- 'type' => 'text',
80
- 'desc' => __( 'Brands taxonomy slug', 'perfect-woocommerce-brands' ),
81
- 'id' => 'wc_pwb_admin_tab_slug',
82
- 'placeholder' => get_taxonomy('pwb-brand')->rewrite['slug']
83
- ),
84
- 'brand_logo_size' => array(
85
- 'name' => __( 'Brand logo size', 'perfect-woocommerce-brands' ),
86
- 'type' => 'select',
87
- 'desc' => __( 'Brand logo size for single product view', 'perfect-woocommerce-brands' ),
88
- 'id' => 'wc_pwb_admin_tab_brand_logo_size',
89
- 'options' => $available_image_sizes_adapted
90
- ),
91
- 'brand_single_position' => array(
92
- 'name' => __( 'Brand position', 'perfect-woocommerce-brands' ),
93
- 'type' => 'select',
94
- 'desc' => __( 'For single product', 'perfect-woocommerce-brands' ),
95
- 'id' => 'wc_pwb_admin_tab_brand_single_position',
96
- 'options' => array(
97
- 'before_title' => __( 'Before title', 'perfect-woocommerce-brands' ),
98
- 'after_title' => __( 'After title', 'perfect-woocommerce-brands' ),
99
- 'after_price' => __( 'After price', 'perfect-woocommerce-brands' ),
100
- 'after_excerpt' => __( 'After excerpt', 'perfect-woocommerce-brands' ),
101
- 'after_add_to_cart' => __( 'After add to cart', 'perfect-woocommerce-brands' ),
102
- 'after_meta' => __( 'After meta', 'perfect-woocommerce-brands' ),
103
- 'after_sharing' => __( 'After sharing', 'perfect-woocommerce-brands' )
104
- )
105
- ),
106
- 'brand_description' => array(
107
- 'name' => __( 'Show brand description', 'perfect-woocommerce-brands' ),
108
- 'type' => 'checkbox',
109
- 'default' => 'yes',
110
- 'desc' => __( 'Show brand description (if is set) on brand archive page', 'perfect-woocommerce-brands' ),
111
- 'id' => 'wc_pwb_admin_tab_brand_desc'
112
- ),
113
- 'show_brand_on_loop' => array(
114
- 'name' => __( 'Show brands in loop', 'perfect-woocommerce-brands' ),
115
- 'type' => 'select',
116
- 'desc' => __( 'Show brand logo (or name) in product loop', 'perfect-woocommerce-brands' ),
117
- 'id' => 'wc_pwb_admin_tab_brands_in_loop',
118
- 'options' => array(
119
- 'no' => __( 'No', 'perfect-woocommerce-brands' ),
120
- 'brand_link' => __( 'Show brand link', 'perfect-woocommerce-brands' ),
121
- 'brand_image' => __( 'Show brand image (if is set)', 'perfect-woocommerce-brands' )
122
- )
123
- ),
124
- 'section_end' => array(
125
- 'type' => 'sectionend',
126
- 'id' => 'wc_pwb_admin_tab_section_end'
127
- )
128
- );
129
-
130
- return apply_filters( 'wc_pwb_admin_tab_settings', $settings );
131
-
132
- }
133
-
134
- public static function get_tools() {
135
-
136
- $tools = array(
137
- 'section_title' => array(
138
- 'name' => __( 'Tools', 'perfect-woocommerce-brands' ),
139
- 'type' => 'title',
140
- 'desc' => '',
141
- 'id' => 'wc_pwb_admin_tab_section_tools_title'
142
- ),
143
- 'slug' => array(
144
- 'name' => __( 'Import brands', 'perfect-woocommerce-brands' ),
145
- 'type' => 'select',
146
- 'desc' => __( 'Import brands from old plugin installation', 'perfect-woocommerce-brands' ),
147
- 'id' => 'wc_pwb_admin_tab_tools_migrate',
148
- 'options' => array(
149
- '-' => __( '-', 'perfect-woocommerce-brands' ),
150
- 'yith' => __( 'YITH WooCommerce Brands Add-On', 'perfect-woocommerce-brands' )
151
- )
152
- ),
153
- 'section_end' => array(
154
- 'type' => 'sectionend',
155
- 'id' => 'wc_pwb_admin_tab_section_tools_end'
156
- )
157
- );
158
-
159
- return apply_filters( 'wc_pwb_admin_tab_tools_settings', $tools );
160
-
161
- }
162
-
163
- }
164
-
165
- Pwb_Admin_Tab::init();
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Perfect_Woocommerce_Brands\Admin;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
6
+ class Pwb_Admin_Tab {
7
+
8
+ public static function init() {
9
+ add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
10
+ add_action( 'woocommerce_settings_tabs_pwb_admin_tab', __CLASS__ . '::settings_tab' );
11
+ add_action( 'woocommerce_update_options_pwb_admin_tab', __CLASS__ . '::update_settings' );
12
+ }
13
+
14
+ /**
15
+ * Add a new settings tab to the WooCommerce settings tabs array.
16
+ *
17
+ * @param array $settings_tabs Array of WooCommerce setting tabs & their labels, excluding the Subscription tab.
18
+ * @return array $settings_tabs Array of WooCommerce setting tabs & their labels, including the Subscription tab.
19
+ */
20
+ public static function add_settings_tab( $settings_tabs ) {
21
+ $settings_tabs['pwb_admin_tab'] = __( 'Brands', 'perfect-woocommerce-brands' );
22
+ return $settings_tabs;
23
+ }
24
+
25
+
26
+ /**
27
+ * Uses the WooCommerce admin fields API to output settings via the @see woocommerce_admin_fields() function.
28
+ *
29
+ * @uses woocommerce_admin_fields()
30
+ * @uses self::get_settings()
31
+ */
32
+ public static function settings_tab() {
33
+ woocommerce_admin_fields( self::get_settings() );
34
+ woocommerce_admin_fields( self::get_tools() );
35
+ }
36
+
37
+
38
+ /**
39
+ * Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function.
40
+ *
41
+ * @uses woocommerce_update_options()
42
+ * @uses self::get_settings()
43
+ */
44
+ public static function update_settings() {
45
+ update_option( 'old_wc_pwb_admin_tab_slug', get_taxonomy('pwb-brand')->rewrite['slug'] );
46
+
47
+ if(isset($_POST['wc_pwb_admin_tab_slug'])){
48
+ $_POST['wc_pwb_admin_tab_slug'] = sanitize_title($_POST['wc_pwb_admin_tab_slug']);
49
+ }
50
+
51
+ woocommerce_update_options( self::get_settings() );
52
+
53
+ }
54
+
55
+
56
+ /**
57
+ * Get all the settings for this plugin for @see woocommerce_admin_fields() function.
58
+ *
59
+ * @return array Array of settings for @see woocommerce_admin_fields() function.
60
+ */
61
+ public static function get_settings() {
62
+
63
+ $available_image_sizes_adapted = array();
64
+ $available_image_sizes = get_intermediate_image_sizes();
65
+
66
+ foreach($available_image_sizes as $image_size){
67
+ $available_image_sizes_adapted[$image_size] = $image_size;
68
+ }
69
+
70
+ $settings = array(
71
+ 'section_title' => array(
72
+ 'name' => __( 'Brands settings', 'perfect-woocommerce-brands' ),
73
+ 'type' => 'title',
74
+ 'desc' => '',
75
+ 'id' => 'wc_pwb_admin_tab_section_title'
76
+ ),
77
+ 'slug' => array(
78
+ 'name' => __( 'Slug', 'perfect-woocommerce-brands' ),
79
+ 'type' => 'text',
80
+ 'desc' => __( 'Brands taxonomy slug', 'perfect-woocommerce-brands' ),
81
+ 'id' => 'wc_pwb_admin_tab_slug',
82
+ 'placeholder' => get_taxonomy('pwb-brand')->rewrite['slug']
83
+ ),
84
+ 'brand_description' => array(
85
+ 'name' => __( 'Show brand description', 'perfect-woocommerce-brands' ),
86
+ 'type' => 'checkbox',
87
+ 'default' => 'yes',
88
+ 'desc' => __( 'Show brand description (if is set) on brand archive page', 'perfect-woocommerce-brands' ),
89
+ 'id' => 'wc_pwb_admin_tab_brand_desc'
90
+ ),
91
+ 'show_brand_on_loop' => array(
92
+ 'name' => __( 'Show brands in loop', 'perfect-woocommerce-brands' ),
93
+ 'type' => 'select',
94
+ 'desc' => __( 'Show brand logo (or name) in product loop', 'perfect-woocommerce-brands' ),
95
+ 'id' => 'wc_pwb_admin_tab_brands_in_loop',
96
+ 'options' => array(
97
+ 'no' => __( 'No', 'perfect-woocommerce-brands' ),
98
+ 'brand_link' => __( 'Show brand link', 'perfect-woocommerce-brands' ),
99
+ 'brand_image' => __( 'Show brand image (if is set)', 'perfect-woocommerce-brands' )
100
+ )
101
+ ),
102
+ 'show_brand_in_single' => array(
103
+ 'name' => __( 'Show brands in single product', 'perfect-woocommerce-brands' ),
104
+ 'type' => 'select',
105
+ 'desc' => __( 'Show brand logo (or name) in single product', 'perfect-woocommerce-brands' ),
106
+ 'default' => 'brand_image',
107
+ 'id' => 'wc_pwb_admin_tab_brands_in_single',
108
+ 'options' => array(
109
+ 'no' => __( 'No', 'perfect-woocommerce-brands' ),
110
+ 'brand_link' => __( 'Show brand link', 'perfect-woocommerce-brands' ),
111
+ 'brand_image' => __( 'Show brand image (if is set)', 'perfect-woocommerce-brands' )
112
+ )
113
+ ),
114
+ 'brand_logo_size' => array(
115
+ 'name' => __( 'Brand logo size', 'perfect-woocommerce-brands' ),
116
+ 'type' => 'select',
117
+ 'desc' => __( 'Brand logo size for single product view', 'perfect-woocommerce-brands' ),
118
+ 'id' => 'wc_pwb_admin_tab_brand_logo_size',
119
+ 'options' => $available_image_sizes_adapted
120
+ ),
121
+ 'brand_single_position' => array(
122
+ 'name' => __( 'Brand position', 'perfect-woocommerce-brands' ),
123
+ 'type' => 'select',
124
+ 'desc' => __( 'For single product', 'perfect-woocommerce-brands' ),
125
+ 'id' => 'wc_pwb_admin_tab_brand_single_position',
126
+ 'options' => array(
127
+ 'before_title' => __( 'Before title', 'perfect-woocommerce-brands' ),
128
+ 'after_title' => __( 'After title', 'perfect-woocommerce-brands' ),
129
+ 'after_price' => __( 'After price', 'perfect-woocommerce-brands' ),
130
+ 'after_excerpt' => __( 'After excerpt', 'perfect-woocommerce-brands' ),
131
+ 'after_add_to_cart' => __( 'After add to cart', 'perfect-woocommerce-brands' ),
132
+ 'after_meta' => __( 'After meta', 'perfect-woocommerce-brands' ),
133
+ 'after_sharing' => __( 'After sharing', 'perfect-woocommerce-brands' )
134
+ )
135
+ ),
136
+ 'section_end' => array(
137
+ 'type' => 'sectionend',
138
+ 'id' => 'wc_pwb_admin_tab_section_end'
139
+ )
140
+ );
141
+
142
+ return apply_filters( 'wc_pwb_admin_tab_settings', $settings );
143
+
144
+ }
145
+
146
+ public static function get_tools() {
147
+
148
+ $tools = array(
149
+ 'section_title' => array(
150
+ 'name' => __( 'Tools', 'perfect-woocommerce-brands' ),
151
+ 'type' => 'title',
152
+ 'desc' => '',
153
+ 'id' => 'wc_pwb_admin_tab_section_tools_title'
154
+ ),
155
+ 'slug' => array(
156
+ 'name' => __( 'Import brands', 'perfect-woocommerce-brands' ),
157
+ 'type' => 'select',
158
+ 'desc' => __( 'Import brands from other brand plugin. <strong>Both plugins should be installed and active</strong>', 'perfect-woocommerce-brands' ),
159
+ 'id' => 'wc_pwb_admin_tab_tools_migrate',
160
+ 'options' => array(
161
+ '-' => __( '-', 'perfect-woocommerce-brands' ),
162
+ 'yith' => __( 'YITH WooCommerce Brands Add-On', 'perfect-woocommerce-brands' )
163
+ )
164
+ ),
165
+ 'section_end' => array(
166
+ 'type' => 'sectionend',
167
+ 'id' => 'wc_pwb_admin_tab_section_tools_end'
168
+ )
169
+ );
170
+
171
+ return apply_filters( 'wc_pwb_admin_tab_tools_settings', $tools );
172
+
173
+ }
174
+
175
+ }
176
+
177
+ Pwb_Admin_Tab::init();
classes/shortcodes/class-pwb-all-brands.php CHANGED
@@ -1,102 +1,108 @@
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
- ), $atts, 'pwb-all-brands' );
14
-
15
- ob_start();
16
-
17
- $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands();
18
- ?>
19
- <div class="pwb-all-brands">
20
- <?php static::pagination($brands, $atts['per_page'], $atts['image_size']);?>
21
- </div>
22
- <?php
23
-
24
- return ob_get_clean();
25
- }
26
-
27
- public static function pagination($display_array, $show_per_page, $image_size) {
28
- $page = 1;
29
-
30
- if(isset($_GET['pwb-page']) && filter_var($_GET['pwb-page'], FILTER_VALIDATE_INT) == true){
31
- $page = $_GET['pwb-page'];
32
- }
33
-
34
- $page = $page < 1 ? 1 : $page;
35
-
36
- // start position in the $display_array
37
- // +1 is to account for total values.
38
- $start = ($page - 1) * ($show_per_page);
39
- $offset = $show_per_page;
40
-
41
- $outArray = array_slice($display_array, $start, $offset);
42
-
43
- //pagination links
44
- $total_elements = count($display_array);
45
- $pages = ((int)$total_elements / (int)$show_per_page);
46
- $pages = ceil($pages);
47
- if($pages>=1 && $page <= $pages){
48
-
49
- ?>
50
- <div class="pwb-brands-cols-outer">
51
- <?php
52
- foreach($outArray as $brand){
53
- $brand_id = $brand->term_id;
54
- $brand_name = $brand->name;
55
- $brand_link = get_term_link($brand_id);
56
-
57
- $attachment_id = get_term_meta( $brand_id, 'pwb_brand_image', 1 );
58
- $attachment_html = $brand_name;
59
- if($attachment_id!=''){
60
- $attachment_html = wp_get_attachment_image($attachment_id,$image_size);
61
- }
62
-
63
- ?>
64
- <div class="pwb-brands-col3">
65
- <div>
66
- <?php echo $brand_name;?>
67
- <small>(<?php echo $brand->count;?>)</small>
68
- </div>
69
- <div>
70
- <a href="<?php echo $brand_link;?>" title="<?php _e( 'View brand', 'perfect-woocommerce-brands' );?>"><?php echo $attachment_html;?></a>
71
- </div>
72
- </div>
73
- <?php
74
- }
75
- ?>
76
- </div>
77
- <?php
78
- $next = $page + 1;
79
- $prev = $page - 1;
80
-
81
- echo '<div class="pwb-pagination-wrapper">';
82
- if($prev>1){
83
- echo '<a href="'.get_the_permalink().'" class="pwb-pagination prev" title="'.__('First page','perfect-woocommerce-brands').'">&laquo;</a>';
84
- }
85
- if($prev>0){
86
- echo '<a href="'.get_the_permalink().'?pwb-page='.$prev.'" class="pwb-pagination last" title="'.__('Previous page','perfect-woocommerce-brands').'">&lsaquo;</a>';
87
- }
88
-
89
- if($next<=$pages){
90
- echo '<a href="'.get_the_permalink().'?pwb-page='.$next.'" class="pwb-pagination first" title="'.__('Next page','perfect-woocommerce-brands').'">&rsaquo;</a>';
91
- }
92
- if($next<$pages){
93
- echo '<a href="'.get_the_permalink().'?pwb-page='.$pages.'" class="pwb-pagination next" title="'.__('Last page','perfect-woocommerce-brands').'">&raquo;</a>';
94
- }
95
- echo '</div>';
96
-
97
- }else{
98
- echo __('No results','perfect-woocommerce-brands');
99
- }
100
-
101
- }
102
- }
 
 
 
 
 
 
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
+ ), $atts, 'pwb-all-brands' );
15
+
16
+ $hide_empty = true;
17
+ if($atts['hide_empty']!='true'){
18
+ $hide_empty = false;
19
+ }
20
+
21
+ ob_start();
22
+
23
+ $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( $hide_empty );
24
+ ?>
25
+ <div class="pwb-all-brands">
26
+ <?php static::pagination($brands, $atts['per_page'], $atts['image_size']);?>
27
+ </div>
28
+ <?php
29
+
30
+ return ob_get_clean();
31
+ }
32
+
33
+ public static function pagination($display_array, $show_per_page, $image_size) {
34
+ $page = 1;
35
+
36
+ if(isset($_GET['pwb-page']) && filter_var($_GET['pwb-page'], FILTER_VALIDATE_INT) == true){
37
+ $page = $_GET['pwb-page'];
38
+ }
39
+
40
+ $page = $page < 1 ? 1 : $page;
41
+
42
+ // start position in the $display_array
43
+ // +1 is to account for total values.
44
+ $start = ($page - 1) * ($show_per_page);
45
+ $offset = $show_per_page;
46
+
47
+ $outArray = array_slice($display_array, $start, $offset);
48
+
49
+ //pagination links
50
+ $total_elements = count($display_array);
51
+ $pages = ((int)$total_elements / (int)$show_per_page);
52
+ $pages = ceil($pages);
53
+ if($pages>=1 && $page <= $pages){
54
+
55
+ ?>
56
+ <div class="pwb-brands-cols-outer">
57
+ <?php
58
+ foreach($outArray as $brand){
59
+ $brand_id = $brand->term_id;
60
+ $brand_name = $brand->name;
61
+ $brand_link = get_term_link($brand_id);
62
+
63
+ $attachment_id = get_term_meta( $brand_id, 'pwb_brand_image', 1 );
64
+ $attachment_html = $brand_name;
65
+ if($attachment_id!=''){
66
+ $attachment_html = wp_get_attachment_image($attachment_id,$image_size);
67
+ }
68
+
69
+ ?>
70
+ <div class="pwb-brands-col3">
71
+ <div>
72
+ <?php echo $brand_name;?>
73
+ <small>(<?php echo $brand->count;?>)</small>
74
+ </div>
75
+ <div>
76
+ <a href="<?php echo $brand_link;?>" title="<?php _e( 'View brand', 'perfect-woocommerce-brands' );?>"><?php echo $attachment_html;?></a>
77
+ </div>
78
+ </div>
79
+ <?php
80
+ }
81
+ ?>
82
+ </div>
83
+ <?php
84
+ $next = $page + 1;
85
+ $prev = $page - 1;
86
+
87
+ echo '<div class="pwb-pagination-wrapper">';
88
+ if($prev>1){
89
+ echo '<a href="'.get_the_permalink().'" class="pwb-pagination prev" title="'.__('First page','perfect-woocommerce-brands').'">&laquo;</a>';
90
+ }
91
+ if($prev>0){
92
+ echo '<a href="'.get_the_permalink().'?pwb-page='.$prev.'" class="pwb-pagination last" title="'.__('Previous page','perfect-woocommerce-brands').'">&lsaquo;</a>';
93
+ }
94
+
95
+ if($next<=$pages){
96
+ echo '<a href="'.get_the_permalink().'?pwb-page='.$next.'" class="pwb-pagination first" title="'.__('Next page','perfect-woocommerce-brands').'">&rsaquo;</a>';
97
+ }
98
+ if($next<$pages){
99
+ echo '<a href="'.get_the_permalink().'?pwb-page='.$pages.'" class="pwb-pagination next" title="'.__('Last page','perfect-woocommerce-brands').'">&raquo;</a>';
100
+ }
101
+ echo '</div>';
102
+
103
+ }else{
104
+ echo __('No results','perfect-woocommerce-brands');
105
+ }
106
+
107
+ }
108
+ }
classes/shortcodes/class-pwb-brand.php CHANGED
@@ -1,43 +1,43 @@
1
- <?php
2
- namespace Perfect_Woocommerce_Brands\Shortcodes;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
6
- class PWB_Brand_Shortcode{
7
-
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
- $brands = wp_get_post_terms( $atts['product_id'], 'pwb-brand');
17
-
18
- if(is_array($brands) && count($brands)>0){
19
-
20
- echo '<div class="pwb-brand-shortcode">';
21
-
22
- foreach($brands as $brand){
23
- $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
24
- $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
25
-
26
- $attachment_html = wp_get_attachment_image($attachment_id,$atts['image_size']);
27
-
28
- if(!empty($attachment_html)){
29
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
30
- }else{
31
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$brand->name.'</a>';
32
- }
33
- }
34
-
35
- echo '</div>';
36
-
37
- }
38
-
39
- return ob_get_clean();
40
-
41
- }
42
-
43
- }
1
+ <?php
2
+ namespace Perfect_Woocommerce_Brands\Shortcodes;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
6
+ class PWB_Brand_Shortcode{
7
+
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
+ $brands = wp_get_post_terms( $atts['product_id'], 'pwb-brand');
17
+
18
+ if(is_array($brands) && count($brands)>0){
19
+
20
+ echo '<div class="pwb-brand-shortcode">';
21
+
22
+ foreach($brands as $brand){
23
+ $brand_link = get_term_link ( $brand->term_id, 'pwb-brand' );
24
+ $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
25
+
26
+ $attachment_html = wp_get_attachment_image($attachment_id,$atts['image_size']);
27
+
28
+ if(!empty($attachment_html)){
29
+ echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
30
+ }else{
31
+ echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$brand->name.'</a>';
32
+ }
33
+ }
34
+
35
+ echo '</div>';
36
+
37
+ }
38
+
39
+ return ob_get_clean();
40
+
41
+ }
42
+
43
+ }
classes/shortcodes/class-pwb-carousel.php CHANGED
@@ -1,52 +1,53 @@
1
- <?php
2
- namespace Perfect_Woocommerce_Brands\Shortcodes;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
6
- class PWB_Carousel_Shortcode{
7
-
8
- public static function carousel_shortcode( $atts ) {
9
- $atts = shortcode_atts( array(
10
- 'items' => "10",
11
- 'items_to_show' => "5",
12
- 'items_to_scroll' => "1",
13
- 'image_size' => "thumbnail",
14
- 'autoplay' => "true"
15
- ), $atts, 'pwb-carousel' );
16
-
17
- ob_start();
18
-
19
- $foreach_iterator = 0;
20
-
21
- $autoplay = 'true';
22
- if($atts['autoplay']!='true'){
23
- $autoplay = 'false';
24
- }
25
-
26
- ?><div class="pwb-carousel" data-slick='{"slidesToShow": <?php echo (int)$atts['items_to_show'];?>, "slidesToScroll": <?php echo (int)$atts['items_to_scroll'];?>, "autoplay": <?php echo $autoplay;?>}'><?php
27
- foreach(\Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands() as $brand){
28
- if($foreach_iterator>=(int)$atts['items']){
29
- break;
30
- }
31
-
32
- $brand_id = $brand->term_id;
33
- $brand_link = get_term_link($brand_id);
34
-
35
- $attachment_id = get_term_meta( $brand_id, 'pwb_brand_image', 1 );
36
- $attachment_html = $brand->name;
37
- if($attachment_id!=''){
38
- $attachment_html = wp_get_attachment_image($attachment_id,$atts['image_size']);
39
- }
40
-
41
- echo '<div>';
42
- echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
43
- echo '</div>';
44
-
45
- $foreach_iterator++;
46
- }
47
- echo '</div>';
48
-
49
- return ob_get_clean();
50
- }
51
-
52
- }
 
1
+ <?php
2
+ namespace Perfect_Woocommerce_Brands\Shortcodes;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
6
+ class PWB_Carousel_Shortcode{
7
+
8
+ public static function carousel_shortcode( $atts ) {
9
+ $atts = shortcode_atts( array(
10
+ 'items' => "10",
11
+ 'items_to_show' => "5",
12
+ 'items_to_scroll' => "1",
13
+ 'image_size' => "thumbnail",
14
+ 'autoplay' => false,
15
+ 'arrows' => false
16
+ ), $atts, 'pwb-carousel' );
17
+
18
+ ob_start();
19
+
20
+ $foreach_iterator = 0;
21
+
22
+ $autoplay = 'true';
23
+ if($atts['autoplay']!='true'){
24
+ $autoplay = 'false';
25
+ }
26
+
27
+ ?><div class="pwb-carousel" data-slick='{"slidesToShow": <?php echo (int)$atts['items_to_show'];?>, "slidesToScroll": <?php echo (int)$atts['items_to_scroll'];?>, "autoplay": <?php echo $autoplay;?>, "arrows": <?php echo $arrows;?>}'><?php
28
+ foreach(\Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands() as $brand){
29
+ if($foreach_iterator>=(int)$atts['items']){
30
+ break;
31
+ }
32
+
33
+ $brand_id = $brand->term_id;
34
+ $brand_link = get_term_link($brand_id);
35
+
36
+ $attachment_id = get_term_meta( $brand_id, 'pwb_brand_image', 1 );
37
+ $attachment_html = $brand->name;
38
+ if($attachment_id!=''){
39
+ $attachment_html = wp_get_attachment_image($attachment_id,$atts['image_size']);
40
+ }
41
+
42
+ echo '<div>';
43
+ echo '<a href="'.$brand_link.'" title="'.__( 'View brand', 'perfect-woocommerce-brands' ).'">'.$attachment_html.'</a>';
44
+ echo '</div>';
45
+
46
+ $foreach_iterator++;
47
+ }
48
+ echo '</div>';
49
+
50
+ return ob_get_clean();
51
+ }
52
+
53
+ }
classes/shortcodes/class-pwb-product-carousel.php CHANGED
@@ -1,36 +1,41 @@
1
- <?php
2
- namespace Perfect_Woocommerce_Brands\Shortcodes;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
6
- class PWB_Product_Carousel_Shortcode{
7
-
8
- public static function product_carousel_shortcode( $atts ) {
9
- $atts = shortcode_atts( array(
10
- 'brand' => "all",
11
- 'products' => "10",
12
- 'products_to_show' => "5",
13
- 'products_to_scroll' => "1",
14
- 'autoplay' => "true"
15
- ), $atts, 'pwb-product-carousel' );
16
-
17
- ob_start();
18
-
19
- $foreach_iterator = 0;
20
-
21
- $autoplay = 'true';
22
- if($atts['autoplay']!='true'){
23
- $autoplay = 'false';
24
- }
25
-
26
- ?>
27
-
28
- <div class="pwb-product-carousel" data-slick='{"slidesToShow": <?php echo (int)$atts['products_to_show'];?>, "slidesToScroll": <?php echo (int)$atts['products_to_scroll'];?>, "autoplay": <?php echo $autoplay;?>}'>
29
- <?php echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_products_by_brand($atts['brand'], (int)$atts['products']); ?>
30
- </div>
31
-
32
- <?php
33
- return ob_get_clean();
34
- }
35
-
36
- }
 
 
 
 
 
1
+ <?php
2
+ namespace Perfect_Woocommerce_Brands\Shortcodes;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
6
+ class PWB_Product_Carousel_Shortcode{
7
+
8
+ public static function product_carousel_shortcode( $atts ) {
9
+ $atts = shortcode_atts( array(
10
+ 'brand' => "all",
11
+ 'products' => "10",
12
+ 'products_to_show' => "5",
13
+ 'products_to_scroll' => "1",
14
+ 'autoplay' => false,
15
+ 'arrows' => false
16
+ ), $atts, 'pwb-product-carousel' );
17
+
18
+ ob_start();
19
+
20
+ if($atts['autoplay']){
21
+ $autoplay = 'true';
22
+ }else{
23
+ $autoplay = 'false';
24
+ }
25
+ if($atts['arrows']){
26
+ $arrows = 'true';
27
+ }else{
28
+ $arrows = 'false';
29
+ }
30
+
31
+ ?>
32
+
33
+ <div class="pwb-product-carousel" data-slick='{"slidesToShow": <?php echo (int)$atts['products_to_show'];?>, "slidesToScroll": <?php echo (int)$atts['products_to_scroll'];?>, "autoplay": <?php echo $autoplay;?>, "arrows": <?php echo $arrows;?>}'>
34
+ <?php echo \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_products_by_brand($atts['brand'], (int)$atts['products']); ?>
35
+ </div>
36
+
37
+ <?php
38
+ return ob_get_clean();
39
+ }
40
+
41
+ }
classes/widgets/class-pwb-dropdown.php CHANGED
@@ -8,7 +8,7 @@
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
  }
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
  }
classes/widgets/class-pwb-filter-by-brand.php CHANGED
@@ -8,7 +8,7 @@
8
  function __construct() {
9
  $params = array(
10
  'description' => __( 'Recommended for product categories or shop page', 'perfect-woocommerce-brands' ),
11
- 'name' => __( 'Filter products by brand', 'perfect-woocommerce-brands' )
12
  );
13
  parent::__construct('PWB_Filter_By_Brand_Widget', '', $params);
14
  }
@@ -54,7 +54,7 @@
54
  if( is_product_category() ){
55
 
56
  $cat_id = $cat->term_taxonomy_id;
57
- $cat_id_array = get_term_children( $cat_id, 'product_cat' );
58
  $cat_id_array[] = $cat_id;
59
 
60
  $result_brands = array();
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
  }
54
  if( is_product_category() ){
55
 
56
  $cat_id = $cat->term_taxonomy_id;
57
+ $cat_id_array = get_term_children( $cat_id, 'product_cat' );
58
  $cat_id_array[] = $cat_id;
59
 
60
  $result_brands = array();
classes/widgets/class-pwb-list.php CHANGED
@@ -8,7 +8,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
  }
@@ -18,46 +18,81 @@
18
  ?>
19
 
20
  <p>
21
- <label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php echo __( 'Title', 'perfect-woocommerce-brands' );?></label>
22
  <input
23
- class="widefat"
24
- type="text"
25
- id="<?php echo esc_attr( $this->get_field_id('title') ); ?>"
26
- name="<?php echo esc_attr( $this->get_field_name('title') ); ?>"
27
- value="<?php if(isset($title)) echo esc_attr($title); ?>">
 
 
 
 
 
 
 
 
 
 
28
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  <?php
 
31
  }
32
 
33
  public function widget($args, $instance){
34
- extract($args);
35
- extract($instance);
36
 
37
  echo $before_widget;
38
 
39
- if(!empty($title)){
40
  echo $before_title . $title . $after_title;
41
  }
42
 
43
- $this->get_brands();
44
 
45
  echo $after_widget;
46
 
47
  }
48
 
49
- private function get_brands(){
 
50
  $brands = get_terms('pwb-brand',array(
51
  'hide_empty' => false
52
  ));
53
 
54
  if(is_array($brands) && count($brands)>0){
55
- echo '<ul>';
56
  foreach ($brands as $brand) {
57
  $brand_name = $brand->name;
58
- $brand_link = get_term_link($brand->term_id);
59
- echo '<li>';
60
- echo '<a href="'.$brand_link.'" title="'.__( 'Go to', 'perfect-woocommerce-brands' ).' '.$brand->name.'">'.$brand->name.'</a>';
 
 
 
 
 
 
 
 
 
61
  echo '</li>';
62
  }
63
  echo '</ul>';
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
  }
18
  ?>
19
 
20
  <p>
21
+ <label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php echo __( 'Title:', 'perfect-woocommerce-brands' );?></label>
22
  <input
23
+ class="widefat"
24
+ type="text"
25
+ id="<?php echo esc_attr( $this->get_field_id('title') ); ?>"
26
+ name="<?php echo esc_attr( $this->get_field_name('title') ); ?>"
27
+ value="<?php if(isset($title)) echo esc_attr($title); ?>">
28
+ </p>
29
+ <p>
30
+ <label for="<?php echo esc_attr( $this->get_field_id('display_as') ); ?>"><?php echo __( 'Display as:', 'perfect-woocommerce-brands' );?></label>
31
+ <select
32
+ class="widefat pwb-select-display-as"
33
+ id="<?php echo esc_attr( $this->get_field_id('display_as') ); ?>"
34
+ name="<?php echo esc_attr( $this->get_field_name('display_as') ); ?>">
35
+ <option value="brand_name" <?php selected( $display_as, 'brand_name' ); ?>><?php _e( 'Brand name', 'perfect-woocommerce-brands' );?></option>
36
+ <option value="brand_logo" <?php selected( $display_as, 'brand_logo' ); ?>><?php _e( 'Brand logo', 'perfect-woocommerce-brands' );?></option>
37
+ </select>
38
  </p>
39
+ <div class="pwb-display-as-logo<?php echo ($display_as=='brand_logo') ? ' show' : '' ;?>">
40
+ <p>
41
+ <label for="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"><?php echo __( 'Columns:', 'perfect-woocommerce-brands' );?></label>
42
+ <select
43
+ class="widefat"
44
+ id="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"
45
+ name="<?php echo esc_attr( $this->get_field_name('columns') ); ?>">
46
+ <option value="1" <?php selected( $columns, '1' ); ?>>1</option>
47
+ <option value="2" <?php selected( $columns, '2' ); ?>>2</option>
48
+ <option value="3" <?php selected( $columns, '3' ); ?>>3</option>
49
+ <option value="4" <?php selected( $columns, '4' ); ?>>4</option>
50
+ </select>
51
+ </p>
52
+ </div>
53
 
54
  <?php
55
+
56
  }
57
 
58
  public function widget($args, $instance){
59
+ extract( $args );
60
+ extract( $instance );
61
 
62
  echo $before_widget;
63
 
64
+ if( !empty( $title ) ){
65
  echo $before_title . $title . $after_title;
66
  }
67
 
68
+ PWB_List_Widget::get_brands( $display_as, $columns );
69
 
70
  echo $after_widget;
71
 
72
  }
73
 
74
+ private static function get_brands( $display_as, $columns ){
75
+
76
  $brands = get_terms('pwb-brand',array(
77
  'hide_empty' => false
78
  ));
79
 
80
  if(is_array($brands) && count($brands)>0){
81
+ echo '<ul class="pwb-row">';
82
  foreach ($brands as $brand) {
83
  $brand_name = $brand->name;
84
+ $brand_link = get_term_link( $brand->term_id );
85
+
86
+ $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
87
+ $brand_logo = wp_get_attachment_image( $attachment_id, 'full' );
88
+
89
+ $li_class = ( $display_as == 'brand_logo' ) ? "pwb-columns pwb-columns-".$columns : "";
90
+ echo '<li class="'. $li_class .'">';
91
+ if( $display_as == 'brand_logo' && !empty( $brand_logo ) ){
92
+ echo '<a href="'.$brand_link.'" title="'.__( 'Go to', 'perfect-woocommerce-brands' ).' '.$brand->name.'">'.$brand_logo.'</a>';
93
+ }else{
94
+ echo '<a href="'.$brand_link.'" title="'.__( 'Go to', 'perfect-woocommerce-brands' ).' '.$brand->name.'">'.$brand->name.'</a>';
95
+ }
96
  echo '</li>';
97
  }
98
  echo '</ul>';
lang/perfect-woocommerce-brands-es_ES.mo CHANGED
Binary file
lang/perfect-woocommerce-brands-es_ES.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Perfect WooCommerce Brands\n"
4
- "POT-Creation-Date: 2016-11-26 19:26+0100\n"
5
- "PO-Revision-Date: 2016-11-26 19:26+0100\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: es_ES\n"
@@ -10,7 +10,7 @@ msgstr ""
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
- "X-Generator: Poedit 1.8.11\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-WPHeader: main.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
@@ -20,138 +20,193 @@ msgstr ""
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
- #: classes/class-perfect-woocommerce-brands.php:261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  msgid "PWB Product carousel"
25
  msgstr "PWB Carrusel de productos"
26
 
27
- #: classes/class-perfect-woocommerce-brands.php:262
28
  msgid "Product carousel by brand or by category"
29
  msgstr "Carrusel de productos por marca o categoría"
30
 
31
- #: classes/class-perfect-woocommerce-brands.php:270
32
- #: classes/class-perfect-woocommerce-brands.php:519
33
  msgid "Brand"
34
  msgstr "Marca"
35
 
36
- #: classes/class-perfect-woocommerce-brands.php:278
37
  msgid "Products"
38
  msgstr "Productos"
39
 
40
- #: classes/class-perfect-woocommerce-brands.php:281
41
  msgid "Number of products to load"
42
  msgstr "Número de productos que cargar"
43
 
44
- #: classes/class-perfect-woocommerce-brands.php:286
45
  msgid "Products to show"
46
  msgstr "Productos a mostrar"
47
 
48
- #: classes/class-perfect-woocommerce-brands.php:289
49
  msgid "Number of products to show"
50
  msgstr "Número de productos que mostrar"
51
 
52
- #: classes/class-perfect-woocommerce-brands.php:294
53
  msgid "Products to scroll"
54
  msgstr "Número de productos por scroll"
55
 
56
- #: classes/class-perfect-woocommerce-brands.php:297
57
  msgid "Number of products to scroll"
58
  msgstr "Número de productos por cada scroll"
59
 
60
- #: classes/class-perfect-woocommerce-brands.php:302
61
- #: classes/class-perfect-woocommerce-brands.php:346
62
  msgid "Autoplay"
63
  msgstr "Modo automático"
64
 
65
- #: classes/class-perfect-woocommerce-brands.php:304
66
- #: classes/class-perfect-woocommerce-brands.php:348
67
  msgid "Autoplay carousel"
68
  msgstr "Modo automático para el carrusel"
69
 
70
- #: classes/class-perfect-woocommerce-brands.php:312
 
 
 
 
 
 
 
 
 
 
71
  msgid "PWB Brands carousel"
72
  msgstr "PWB Carrusel de marcas"
73
 
74
- #: classes/class-perfect-woocommerce-brands.php:313
75
  msgid "Brands carousel"
76
  msgstr "Carrusel de marcas"
77
 
78
- #: classes/class-perfect-woocommerce-brands.php:322
79
  msgid "Items"
80
  msgstr "Elementos"
81
 
82
- #: classes/class-perfect-woocommerce-brands.php:325
83
  msgid "Number of items to load"
84
  msgstr "Número de elementos que cargar"
85
 
86
- #: classes/class-perfect-woocommerce-brands.php:330
87
  msgid "Items to show"
88
  msgstr "Elementos a mostrar"
89
 
90
- #: classes/class-perfect-woocommerce-brands.php:333
91
  msgid "Number of items to show"
92
  msgstr "Número de elementos a mostrar"
93
 
94
- #: classes/class-perfect-woocommerce-brands.php:338
95
  msgid "Items to scroll"
96
  msgstr "Número de elementos por scroll"
97
 
98
- #: classes/class-perfect-woocommerce-brands.php:341
99
  msgid "Number of items to scroll"
100
  msgstr "Número de elementos por cada scroll"
101
 
102
- #: classes/class-perfect-woocommerce-brands.php:352
103
- #: classes/class-perfect-woocommerce-brands.php:381
104
- #: classes/class-perfect-woocommerce-brands.php:410
105
- #: classes/class-pwb-admin-tab.php:85
106
  msgid "Brand logo size"
107
  msgstr "Tamaño del logo de la marca"
108
 
109
- #: classes/class-perfect-woocommerce-brands.php:363
110
  msgid "PWB All brands"
111
  msgstr "PWB Todas las marcas"
112
 
113
- #: classes/class-perfect-woocommerce-brands.php:364
114
  msgid "Show all brands"
115
  msgstr "Mostrar todas las marcas"
116
 
117
- #: classes/class-perfect-woocommerce-brands.php:374
118
  msgid "Brands per page"
119
  msgstr "Marcas por página"
120
 
121
- #: classes/class-perfect-woocommerce-brands.php:377
122
  msgid "Show x brands per page"
123
  msgstr "Mostrar x marcas por página"
124
 
125
- #: classes/class-perfect-woocommerce-brands.php:392
 
 
 
 
 
 
 
 
126
  msgid "PWB brand"
127
  msgstr "PWB Marca"
128
 
129
- #: classes/class-perfect-woocommerce-brands.php:393
130
  msgid "Show brand for a specific product"
131
  msgstr "Ver marcas de un producto específico"
132
 
133
- #: classes/class-perfect-woocommerce-brands.php:403
134
  msgid "Product id"
135
  msgstr "Id del producto"
136
 
137
- #: classes/class-perfect-woocommerce-brands.php:406
138
  msgid "Product id (post id)"
139
  msgstr "Id del producto (id del post)"
140
 
141
- #: classes/class-perfect-woocommerce-brands.php:440
142
- #: classes/class-perfect-woocommerce-brands.php:442
143
- #: classes/shortcodes/class-pwb-all-brands.php:70
144
  #: classes/shortcodes/class-pwb-brand.php:29
145
  #: classes/shortcodes/class-pwb-brand.php:31
146
- #: classes/shortcodes/class-pwb-carousel.php:42
147
  msgid "View brand"
148
  msgstr "Ver marca"
149
 
150
- #: classes/class-perfect-woocommerce-brands.php:506
151
  msgid "¿Start migration?"
152
  msgstr "¿Comenzar la migración?"
153
 
154
- #: classes/class-perfect-woocommerce-brands.php:507
155
  msgid ""
156
  "We are migrating the product brands. ¡Don´t close this window until the "
157
  "process is finished!"
@@ -159,106 +214,107 @@ msgstr ""
159
  "Estamos migrando las marcas de producto. ¡No cierres esta ventana hasta que "
160
  "el proceso finalice!"
161
 
162
- #: classes/class-perfect-woocommerce-brands.php:518
163
- #: classes/class-perfect-woocommerce-brands.php:520
164
  #: classes/class-pwb-admin-tab.php:21 classes/widgets/class-pwb-dropdown.php:56
165
  msgid "Brands"
166
  msgstr "Marcas"
167
 
168
- #: classes/class-perfect-woocommerce-brands.php:521
169
  msgid "All Brands"
170
  msgstr "Todas las marcas"
171
 
172
- #: classes/class-perfect-woocommerce-brands.php:522
173
  msgid "Edit Brand"
174
  msgstr "Editar marca"
175
 
176
- #: classes/class-perfect-woocommerce-brands.php:523
177
  msgid "View Brand"
178
  msgstr "Ver marca"
179
 
180
- #: classes/class-perfect-woocommerce-brands.php:524
181
  msgid "Update Brand"
182
  msgstr "Actualizar marca"
183
 
184
- #: classes/class-perfect-woocommerce-brands.php:525
185
  msgid "Add New Brand"
186
  msgstr "Añadir nueva marca"
187
 
188
- #: classes/class-perfect-woocommerce-brands.php:526
189
  msgid "New Brand Name"
190
  msgstr "Nuevo nombre de marca"
191
 
192
- #: classes/class-perfect-woocommerce-brands.php:527
193
  msgid "Parent Brand"
194
  msgstr "Marca Padre"
195
 
196
- #: classes/class-perfect-woocommerce-brands.php:528
197
  msgid "Parent Brand:"
198
  msgstr "Marca Padre:"
199
 
200
- #: classes/class-perfect-woocommerce-brands.php:529
201
  msgid "Search Brands"
202
  msgstr "Buscar Marcas"
203
 
204
- #: classes/class-perfect-woocommerce-brands.php:530
205
  msgid "Popular Brands"
206
  msgstr "Marcas Populares"
207
 
208
- #: classes/class-perfect-woocommerce-brands.php:531
209
  msgid "Separate brands with commas"
210
  msgstr "Separar marcas con comas"
211
 
212
- #: classes/class-perfect-woocommerce-brands.php:532
213
  msgid "Add or remove brands"
214
  msgstr "Añadir o eliminar marcas"
215
 
216
- #: classes/class-perfect-woocommerce-brands.php:533
217
  msgid "Choose from the most used brands"
218
  msgstr "Seleccionar de las marcas más utilizadas"
219
 
220
- #: classes/class-perfect-woocommerce-brands.php:534
221
  msgid "No brands found"
222
  msgstr "No se han encontrado marcas"
223
 
224
- #: classes/class-perfect-woocommerce-brands.php:578
225
- #: classes/class-perfect-woocommerce-brands.php:611
 
226
  msgid "Brand logo"
227
  msgstr "Logo de la marca"
228
 
229
- #: classes/class-perfect-woocommerce-brands.php:580
230
- #: classes/class-perfect-woocommerce-brands.php:587
231
- #: classes/class-perfect-woocommerce-brands.php:615
232
- #: classes/class-perfect-woocommerce-brands.php:626
233
  msgid "Select image"
234
  msgstr "Seleccionar imagen"
235
 
236
- #: classes/class-perfect-woocommerce-brands.php:585
237
- #: classes/class-perfect-woocommerce-brands.php:622
238
  msgid "Brand banner"
239
  msgstr "Banner de la marca"
240
 
241
- #: classes/class-perfect-woocommerce-brands.php:588
242
  msgid "This image will be shown on brand page"
243
  msgstr "Esta imagen se mostrará en la página de la marca"
244
 
245
- #: classes/class-perfect-woocommerce-brands.php:593
246
- #: classes/class-perfect-woocommerce-brands.php:633
247
  msgid "Brand banner link"
248
  msgstr "Enlace para el banner de la marca"
249
 
250
- #: classes/class-perfect-woocommerce-brands.php:595
251
- #: classes/class-perfect-woocommerce-brands.php:637
252
  msgid "This link should be relative to site url. Example: product/product-name"
253
  msgstr ""
254
  "Este enlace ha de ser relativo a la url del sitio web. Ejemplo: producto/"
255
  "nombre-del-producto"
256
 
257
- #: classes/class-perfect-woocommerce-brands.php:695
258
  msgid "Logo"
259
  msgstr "Logo"
260
 
261
- #: classes/class-perfect-woocommerce-brands.php:785
262
  msgid "No products found"
263
  msgstr "No se han encontrado productos"
264
 
@@ -274,111 +330,123 @@ msgstr "Slug"
274
  msgid "Brands taxonomy slug"
275
  msgstr "Slug de la taxonomía marcas"
276
 
277
- #: classes/class-pwb-admin-tab.php:87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  msgid "Brand logo size for single product view"
279
  msgstr "Tamaño del logo para la vista individual de producto"
280
 
281
- #: classes/class-pwb-admin-tab.php:92
282
  msgid "Brand position"
283
  msgstr "Posición de la marca"
284
 
285
- #: classes/class-pwb-admin-tab.php:94
286
  msgid "For single product"
287
  msgstr "En la página individual de cada producto"
288
 
289
- #: classes/class-pwb-admin-tab.php:97
290
  msgid "Before title"
291
  msgstr "Antes del título"
292
 
293
- #: classes/class-pwb-admin-tab.php:98
294
  msgid "After title"
295
  msgstr "Después del título"
296
 
297
- #: classes/class-pwb-admin-tab.php:99
298
  msgid "After price"
299
  msgstr "Después del precio"
300
 
301
- #: classes/class-pwb-admin-tab.php:100
302
  msgid "After excerpt"
303
  msgstr "Después de la descripción corta"
304
 
305
- #: classes/class-pwb-admin-tab.php:101
306
  msgid "After add to cart"
307
  msgstr "Después del botón de comprar"
308
 
309
- #: classes/class-pwb-admin-tab.php:102
310
  msgid "After meta"
311
  msgstr "Después del meta"
312
 
313
- #: classes/class-pwb-admin-tab.php:103
314
  msgid "After sharing"
315
  msgstr "Después de compartir"
316
 
317
- #: classes/class-pwb-admin-tab.php:107
318
- msgid "Show brand description"
319
- msgstr "Mostrar descripción de la marca"
320
-
321
- #: classes/class-pwb-admin-tab.php:110
322
- msgid "Show brand description (if is set) on brand archive page"
323
- msgstr "Mostrar descripción de la marca en la página de archivo"
324
-
325
- #: classes/class-pwb-admin-tab.php:114
326
- msgid "Show brands in loop"
327
- msgstr "Mostrar marcas en el loop"
328
-
329
- #: classes/class-pwb-admin-tab.php:116
330
- msgid "Show brand logo (or name) in product loop"
331
- msgstr "Mostrar el logo de la marca (o el nombre) en el loop"
332
-
333
- #: classes/class-pwb-admin-tab.php:119
334
- msgid "No"
335
- msgstr "No"
336
-
337
- #: classes/class-pwb-admin-tab.php:120
338
- msgid "Show brand link"
339
- msgstr "Mostrar el link de la marca"
340
-
341
- #: classes/class-pwb-admin-tab.php:121
342
- msgid "Show brand image (if is set)"
343
- msgstr "Mostrar el logo de la marca (si tiene uno asignado)"
344
-
345
- #: classes/class-pwb-admin-tab.php:138
346
  msgid "Tools"
347
  msgstr "Herramientas"
348
 
349
- #: classes/class-pwb-admin-tab.php:144
350
  msgid "Import brands"
351
  msgstr "Importar marcas"
352
 
353
- #: classes/class-pwb-admin-tab.php:146
354
- msgid "Import brands from old plugin installation"
355
- msgstr "Importar marcas de otro plugin"
 
 
 
 
356
 
357
- #: classes/class-pwb-admin-tab.php:149
358
  msgid "-"
359
  msgstr "-"
360
 
361
- #: classes/class-pwb-admin-tab.php:150
362
  msgid "YITH WooCommerce Brands Add-On"
363
  msgstr "YITH WooCommerce Brands Add-On"
364
 
365
- #: classes/shortcodes/class-pwb-all-brands.php:83
366
  msgid "First page"
367
  msgstr "Primera página"
368
 
369
- #: classes/shortcodes/class-pwb-all-brands.php:86
370
  msgid "Previous page"
371
  msgstr "Página anterior"
372
 
373
- #: classes/shortcodes/class-pwb-all-brands.php:90
374
  msgid "Next page"
375
  msgstr "Siguiente página"
376
 
377
- #: classes/shortcodes/class-pwb-all-brands.php:93
378
  msgid "Last page"
379
  msgstr "Última página"
380
 
381
- #: classes/shortcodes/class-pwb-all-brands.php:98
382
  msgid "No results"
383
  msgstr "No se han encontrado resultados"
384
 
@@ -391,12 +459,11 @@ msgid "Brands dropdown"
391
  msgstr "Desplegable de marcas"
392
 
393
  #: classes/widgets/class-pwb-dropdown.php:21
394
- #: classes/widgets/class-pwb-list.php:21
395
  msgid "Title"
396
  msgstr "Título"
397
 
398
  #: classes/widgets/class-pwb-dropdown.php:64
399
- #: classes/widgets/class-pwb-list.php:65
400
  msgid "There is not available brands"
401
  msgstr "No se encuentran marcas disponibles"
402
 
@@ -409,6 +476,7 @@ msgid "Filter products by brand"
409
  msgstr "Filtrar productos por marca"
410
 
411
  #: classes/widgets/class-pwb-filter-by-brand.php:24
 
412
  msgid "Title:"
413
  msgstr "Título:"
414
 
@@ -424,11 +492,23 @@ msgstr "Añade una lista de marcas a tu sitio"
424
  msgid "Brands list"
425
  msgstr "Lista de marcas"
426
 
427
- #: classes/widgets/class-pwb-list.php:60
 
 
 
 
 
 
 
 
 
 
 
 
428
  msgid "Go to"
429
  msgstr "Ir a"
430
 
431
- #: main.php:67
432
  msgid ""
433
  "Perfect WooCommerce Brands needs WooCommerce to run. Please, install and "
434
  "active WooCommerce plugin."
@@ -460,6 +540,9 @@ msgstr "Alberto de Vera Sevilla"
460
  msgid "https://profiles.wordpress.org/titodevera/"
461
  msgstr "https://profiles.wordpress.org/titodevera/"
462
 
 
 
 
463
  #~ msgid "Brands metabox"
464
  #~ msgstr "Marcas metabox"
465
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Perfect WooCommerce Brands\n"
4
+ "POT-Creation-Date: 2017-02-24 22:56+0100\n"
5
+ "PO-Revision-Date: 2017-02-24 23:00+0100\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: es_ES\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Generator: Poedit 1.8.12\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-WPHeader: main.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
+ #: classes/class-perfect-woocommerce-brands.php:47
24
+ msgid ""
25
+ "We are offering you maybe the best WooCommerce brands plugin completly free. "
26
+ "You can help us making Perfect WooCommerce Brands a bit better. Thanks!"
27
+ msgstr ""
28
+ "Estamos ofreciendo de forma completamente gratuita el que probablemente sea "
29
+ "el mejor plugin de marcas para WooCommerce. Puedes ayudarnos haciendo "
30
+ "Perfect WooCommerce Brands un poco mejor. ¡Gracias!"
31
+
32
+ #: classes/class-perfect-woocommerce-brands.php:49
33
+ msgid ""
34
+ "<a href=\"https://wordpress.org/support/plugin/perfect-woocommerce-brands/"
35
+ "reviews/?rate=5#new-post\" target=\"_blank\">Leave a review</a>"
36
+ msgstr ""
37
+ "<a href=\"https://wordpress.org/support/plugin/perfect-woocommerce-brands/"
38
+ "reviews/?rate=5#new-post\" target=\"_blank\">Dejar una review</a>"
39
+
40
+ #: classes/class-perfect-woocommerce-brands.php:50
41
+ msgid ""
42
+ "<a href=\"https://translate.wordpress.org/projects/wp-plugins/perfect-"
43
+ "woocommerce-brands\" target=\"_blank\">Translate the plugin</a>"
44
+ msgstr ""
45
+ "<a href=\"https://translate.wordpress.org/projects/wp-plugins/perfect-"
46
+ "woocommerce-brands\" target=\"_blank\">Traducir el plugin</a>"
47
+
48
+ #: classes/class-perfect-woocommerce-brands.php:51
49
+ msgid ""
50
+ "<a href=\"https://github.com/titodevera/perfect-woocommerce-brands\" target="
51
+ "\"_blank\">View on GitHub</a>"
52
+ msgstr ""
53
+ "<a href=\"https://github.com/titodevera/perfect-woocommerce-brands\" target="
54
+ "\"_blank\">Ver en GitHub</a>"
55
+
56
+ #: classes/class-perfect-woocommerce-brands.php:74
57
+ msgid "Settings"
58
+ msgstr "Ajustes"
59
+
60
+ #: classes/class-perfect-woocommerce-brands.php:296
61
  msgid "PWB Product carousel"
62
  msgstr "PWB Carrusel de productos"
63
 
64
+ #: classes/class-perfect-woocommerce-brands.php:297
65
  msgid "Product carousel by brand or by category"
66
  msgstr "Carrusel de productos por marca o categoría"
67
 
68
+ #: classes/class-perfect-woocommerce-brands.php:305
69
+ #: classes/class-perfect-woocommerce-brands.php:578
70
  msgid "Brand"
71
  msgstr "Marca"
72
 
73
+ #: classes/class-perfect-woocommerce-brands.php:313
74
  msgid "Products"
75
  msgstr "Productos"
76
 
77
+ #: classes/class-perfect-woocommerce-brands.php:316
78
  msgid "Number of products to load"
79
  msgstr "Número de productos que cargar"
80
 
81
+ #: classes/class-perfect-woocommerce-brands.php:321
82
  msgid "Products to show"
83
  msgstr "Productos a mostrar"
84
 
85
+ #: classes/class-perfect-woocommerce-brands.php:324
86
  msgid "Number of products to show"
87
  msgstr "Número de productos que mostrar"
88
 
89
+ #: classes/class-perfect-woocommerce-brands.php:329
90
  msgid "Products to scroll"
91
  msgstr "Número de productos por scroll"
92
 
93
+ #: classes/class-perfect-woocommerce-brands.php:332
94
  msgid "Number of products to scroll"
95
  msgstr "Número de productos por cada scroll"
96
 
97
+ #: classes/class-perfect-woocommerce-brands.php:337
98
+ #: classes/class-perfect-woocommerce-brands.php:386
99
  msgid "Autoplay"
100
  msgstr "Modo automático"
101
 
102
+ #: classes/class-perfect-woocommerce-brands.php:339
103
+ #: classes/class-perfect-woocommerce-brands.php:388
104
  msgid "Autoplay carousel"
105
  msgstr "Modo automático para el carrusel"
106
 
107
+ #: classes/class-perfect-woocommerce-brands.php:344
108
+ #: classes/class-perfect-woocommerce-brands.php:393
109
+ msgid "Arrows"
110
+ msgstr "Flechas de navegación"
111
+
112
+ #: classes/class-perfect-woocommerce-brands.php:346
113
+ #: classes/class-perfect-woocommerce-brands.php:395
114
+ msgid "Display prev and next arrows"
115
+ msgstr "Mostrar flechas de navegación"
116
+
117
+ #: classes/class-perfect-woocommerce-brands.php:352
118
  msgid "PWB Brands carousel"
119
  msgstr "PWB Carrusel de marcas"
120
 
121
+ #: classes/class-perfect-woocommerce-brands.php:353
122
  msgid "Brands carousel"
123
  msgstr "Carrusel de marcas"
124
 
125
+ #: classes/class-perfect-woocommerce-brands.php:362
126
  msgid "Items"
127
  msgstr "Elementos"
128
 
129
+ #: classes/class-perfect-woocommerce-brands.php:365
130
  msgid "Number of items to load"
131
  msgstr "Número de elementos que cargar"
132
 
133
+ #: classes/class-perfect-woocommerce-brands.php:370
134
  msgid "Items to show"
135
  msgstr "Elementos a mostrar"
136
 
137
+ #: classes/class-perfect-woocommerce-brands.php:373
138
  msgid "Number of items to show"
139
  msgstr "Número de elementos a mostrar"
140
 
141
+ #: classes/class-perfect-woocommerce-brands.php:378
142
  msgid "Items to scroll"
143
  msgstr "Número de elementos por scroll"
144
 
145
+ #: classes/class-perfect-woocommerce-brands.php:381
146
  msgid "Number of items to scroll"
147
  msgstr "Número de elementos por cada scroll"
148
 
149
+ #: classes/class-perfect-woocommerce-brands.php:399
150
+ #: classes/class-perfect-woocommerce-brands.php:427
151
+ #: classes/class-perfect-woocommerce-brands.php:463
152
+ #: classes/class-pwb-admin-tab.php:115
153
  msgid "Brand logo size"
154
  msgstr "Tamaño del logo de la marca"
155
 
156
+ #: classes/class-perfect-woocommerce-brands.php:410
157
  msgid "PWB All brands"
158
  msgstr "PWB Todas las marcas"
159
 
160
+ #: classes/class-perfect-woocommerce-brands.php:411
161
  msgid "Show all brands"
162
  msgstr "Mostrar todas las marcas"
163
 
164
+ #: classes/class-perfect-woocommerce-brands.php:420
165
  msgid "Brands per page"
166
  msgstr "Marcas por página"
167
 
168
+ #: classes/class-perfect-woocommerce-brands.php:423
169
  msgid "Show x brands per page"
170
  msgstr "Mostrar x marcas por página"
171
 
172
+ #: classes/class-perfect-woocommerce-brands.php:435
173
+ msgid "Hide empty"
174
+ msgstr "Ocultar vacías"
175
+
176
+ #: classes/class-perfect-woocommerce-brands.php:437
177
+ msgid "Hide brands that have not been assigned to any product"
178
+ msgstr "Ocultar marcas que no han sido asignadas a ningún producto"
179
+
180
+ #: classes/class-perfect-woocommerce-brands.php:445
181
  msgid "PWB brand"
182
  msgstr "PWB Marca"
183
 
184
+ #: classes/class-perfect-woocommerce-brands.php:446
185
  msgid "Show brand for a specific product"
186
  msgstr "Ver marcas de un producto específico"
187
 
188
+ #: classes/class-perfect-woocommerce-brands.php:456
189
  msgid "Product id"
190
  msgstr "Id del producto"
191
 
192
+ #: classes/class-perfect-woocommerce-brands.php:459
193
  msgid "Product id (post id)"
194
  msgstr "Id del producto (id del post)"
195
 
196
+ #: classes/class-perfect-woocommerce-brands.php:499
197
+ #: classes/class-perfect-woocommerce-brands.php:501
198
+ #: classes/shortcodes/class-pwb-all-brands.php:76
199
  #: classes/shortcodes/class-pwb-brand.php:29
200
  #: classes/shortcodes/class-pwb-brand.php:31
201
+ #: classes/shortcodes/class-pwb-carousel.php:43
202
  msgid "View brand"
203
  msgstr "Ver marca"
204
 
205
+ #: classes/class-perfect-woocommerce-brands.php:568
206
  msgid "¿Start migration?"
207
  msgstr "¿Comenzar la migración?"
208
 
209
+ #: classes/class-perfect-woocommerce-brands.php:569
210
  msgid ""
211
  "We are migrating the product brands. ¡Don´t close this window until the "
212
  "process is finished!"
214
  "Estamos migrando las marcas de producto. ¡No cierres esta ventana hasta que "
215
  "el proceso finalice!"
216
 
217
+ #: classes/class-perfect-woocommerce-brands.php:577
218
+ #: classes/class-perfect-woocommerce-brands.php:579
219
  #: classes/class-pwb-admin-tab.php:21 classes/widgets/class-pwb-dropdown.php:56
220
  msgid "Brands"
221
  msgstr "Marcas"
222
 
223
+ #: classes/class-perfect-woocommerce-brands.php:580
224
  msgid "All Brands"
225
  msgstr "Todas las marcas"
226
 
227
+ #: classes/class-perfect-woocommerce-brands.php:581
228
  msgid "Edit Brand"
229
  msgstr "Editar marca"
230
 
231
+ #: classes/class-perfect-woocommerce-brands.php:582
232
  msgid "View Brand"
233
  msgstr "Ver marca"
234
 
235
+ #: classes/class-perfect-woocommerce-brands.php:583
236
  msgid "Update Brand"
237
  msgstr "Actualizar marca"
238
 
239
+ #: classes/class-perfect-woocommerce-brands.php:584
240
  msgid "Add New Brand"
241
  msgstr "Añadir nueva marca"
242
 
243
+ #: classes/class-perfect-woocommerce-brands.php:585
244
  msgid "New Brand Name"
245
  msgstr "Nuevo nombre de marca"
246
 
247
+ #: classes/class-perfect-woocommerce-brands.php:586
248
  msgid "Parent Brand"
249
  msgstr "Marca Padre"
250
 
251
+ #: classes/class-perfect-woocommerce-brands.php:587
252
  msgid "Parent Brand:"
253
  msgstr "Marca Padre:"
254
 
255
+ #: classes/class-perfect-woocommerce-brands.php:588
256
  msgid "Search Brands"
257
  msgstr "Buscar Marcas"
258
 
259
+ #: classes/class-perfect-woocommerce-brands.php:589
260
  msgid "Popular Brands"
261
  msgstr "Marcas Populares"
262
 
263
+ #: classes/class-perfect-woocommerce-brands.php:590
264
  msgid "Separate brands with commas"
265
  msgstr "Separar marcas con comas"
266
 
267
+ #: classes/class-perfect-woocommerce-brands.php:591
268
  msgid "Add or remove brands"
269
  msgstr "Añadir o eliminar marcas"
270
 
271
+ #: classes/class-perfect-woocommerce-brands.php:592
272
  msgid "Choose from the most used brands"
273
  msgstr "Seleccionar de las marcas más utilizadas"
274
 
275
+ #: classes/class-perfect-woocommerce-brands.php:593
276
  msgid "No brands found"
277
  msgstr "No se han encontrado marcas"
278
 
279
+ #: classes/class-perfect-woocommerce-brands.php:637
280
+ #: classes/class-perfect-woocommerce-brands.php:670
281
+ #: classes/widgets/class-pwb-list.php:36
282
  msgid "Brand logo"
283
  msgstr "Logo de la marca"
284
 
285
+ #: classes/class-perfect-woocommerce-brands.php:639
286
+ #: classes/class-perfect-woocommerce-brands.php:645
287
+ #: classes/class-perfect-woocommerce-brands.php:674
288
+ #: classes/class-perfect-woocommerce-brands.php:694
289
  msgid "Select image"
290
  msgstr "Seleccionar imagen"
291
 
292
+ #: classes/class-perfect-woocommerce-brands.php:643
293
+ #: classes/class-perfect-woocommerce-brands.php:690
294
  msgid "Brand banner"
295
  msgstr "Banner de la marca"
296
 
297
+ #: classes/class-perfect-woocommerce-brands.php:646
298
  msgid "This image will be shown on brand page"
299
  msgstr "Esta imagen se mostrará en la página de la marca"
300
 
301
+ #: classes/class-perfect-woocommerce-brands.php:650
302
+ #: classes/class-perfect-woocommerce-brands.php:710
303
  msgid "Brand banner link"
304
  msgstr "Enlace para el banner de la marca"
305
 
306
+ #: classes/class-perfect-woocommerce-brands.php:652
307
+ #: classes/class-perfect-woocommerce-brands.php:714
308
  msgid "This link should be relative to site url. Example: product/product-name"
309
  msgstr ""
310
  "Este enlace ha de ser relativo a la url del sitio web. Ejemplo: producto/"
311
  "nombre-del-producto"
312
 
313
+ #: classes/class-perfect-woocommerce-brands.php:768
314
  msgid "Logo"
315
  msgstr "Logo"
316
 
317
+ #: classes/class-perfect-woocommerce-brands.php:858
318
  msgid "No products found"
319
  msgstr "No se han encontrado productos"
320
 
330
  msgid "Brands taxonomy slug"
331
  msgstr "Slug de la taxonomía marcas"
332
 
333
+ #: classes/class-pwb-admin-tab.php:85
334
+ msgid "Show brand description"
335
+ msgstr "Mostrar descripción de la marca"
336
+
337
+ #: classes/class-pwb-admin-tab.php:88
338
+ msgid "Show brand description (if is set) on brand archive page"
339
+ msgstr "Mostrar descripción de la marca en la página de archivo"
340
+
341
+ #: classes/class-pwb-admin-tab.php:92
342
+ msgid "Show brands in loop"
343
+ msgstr "Mostrar marcas en el loop"
344
+
345
+ #: classes/class-pwb-admin-tab.php:94
346
+ msgid "Show brand logo (or name) in product loop"
347
+ msgstr "Mostrar el logo de la marca (o el nombre) en el loop"
348
+
349
+ #: classes/class-pwb-admin-tab.php:97 classes/class-pwb-admin-tab.php:109
350
+ msgid "No"
351
+ msgstr "No"
352
+
353
+ #: classes/class-pwb-admin-tab.php:98 classes/class-pwb-admin-tab.php:110
354
+ msgid "Show brand link"
355
+ msgstr "Mostrar el link de la marca"
356
+
357
+ #: classes/class-pwb-admin-tab.php:99 classes/class-pwb-admin-tab.php:111
358
+ msgid "Show brand image (if is set)"
359
+ msgstr "Mostrar el logo de la marca (si tiene uno asignado)"
360
+
361
+ #: classes/class-pwb-admin-tab.php:103
362
+ msgid "Show brands in single product"
363
+ msgstr "Mostrar marcas en la página del producto"
364
+
365
+ #: classes/class-pwb-admin-tab.php:105
366
+ msgid "Show brand logo (or name) in single product"
367
+ msgstr "Mostrar el logo de la marca (o el nombre) en la página del producto"
368
+
369
+ #: classes/class-pwb-admin-tab.php:117
370
  msgid "Brand logo size for single product view"
371
  msgstr "Tamaño del logo para la vista individual de producto"
372
 
373
+ #: classes/class-pwb-admin-tab.php:122
374
  msgid "Brand position"
375
  msgstr "Posición de la marca"
376
 
377
+ #: classes/class-pwb-admin-tab.php:124
378
  msgid "For single product"
379
  msgstr "En la página individual de cada producto"
380
 
381
+ #: classes/class-pwb-admin-tab.php:127
382
  msgid "Before title"
383
  msgstr "Antes del título"
384
 
385
+ #: classes/class-pwb-admin-tab.php:128
386
  msgid "After title"
387
  msgstr "Después del título"
388
 
389
+ #: classes/class-pwb-admin-tab.php:129
390
  msgid "After price"
391
  msgstr "Después del precio"
392
 
393
+ #: classes/class-pwb-admin-tab.php:130
394
  msgid "After excerpt"
395
  msgstr "Después de la descripción corta"
396
 
397
+ #: classes/class-pwb-admin-tab.php:131
398
  msgid "After add to cart"
399
  msgstr "Después del botón de comprar"
400
 
401
+ #: classes/class-pwb-admin-tab.php:132
402
  msgid "After meta"
403
  msgstr "Después del meta"
404
 
405
+ #: classes/class-pwb-admin-tab.php:133
406
  msgid "After sharing"
407
  msgstr "Después de compartir"
408
 
409
+ #: classes/class-pwb-admin-tab.php:150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  msgid "Tools"
411
  msgstr "Herramientas"
412
 
413
+ #: classes/class-pwb-admin-tab.php:156
414
  msgid "Import brands"
415
  msgstr "Importar marcas"
416
 
417
+ #: classes/class-pwb-admin-tab.php:158
418
+ msgid ""
419
+ "Import brands from other brand plugin. <strong>Both plugins should be "
420
+ "installed and active</strong>"
421
+ msgstr ""
422
+ "Importar marcas de otro plugin. <strong>Ambos plugins han de encontrarse "
423
+ "instalados y activados</strong>"
424
 
425
+ #: classes/class-pwb-admin-tab.php:161
426
  msgid "-"
427
  msgstr "-"
428
 
429
+ #: classes/class-pwb-admin-tab.php:162
430
  msgid "YITH WooCommerce Brands Add-On"
431
  msgstr "YITH WooCommerce Brands Add-On"
432
 
433
+ #: classes/shortcodes/class-pwb-all-brands.php:89
434
  msgid "First page"
435
  msgstr "Primera página"
436
 
437
+ #: classes/shortcodes/class-pwb-all-brands.php:92
438
  msgid "Previous page"
439
  msgstr "Página anterior"
440
 
441
+ #: classes/shortcodes/class-pwb-all-brands.php:96
442
  msgid "Next page"
443
  msgstr "Siguiente página"
444
 
445
+ #: classes/shortcodes/class-pwb-all-brands.php:99
446
  msgid "Last page"
447
  msgstr "Última página"
448
 
449
+ #: classes/shortcodes/class-pwb-all-brands.php:104
450
  msgid "No results"
451
  msgstr "No se han encontrado resultados"
452
 
459
  msgstr "Desplegable de marcas"
460
 
461
  #: classes/widgets/class-pwb-dropdown.php:21
 
462
  msgid "Title"
463
  msgstr "Título"
464
 
465
  #: classes/widgets/class-pwb-dropdown.php:64
466
+ #: classes/widgets/class-pwb-list.php:100
467
  msgid "There is not available brands"
468
  msgstr "No se encuentran marcas disponibles"
469
 
476
  msgstr "Filtrar productos por marca"
477
 
478
  #: classes/widgets/class-pwb-filter-by-brand.php:24
479
+ #: classes/widgets/class-pwb-list.php:21
480
  msgid "Title:"
481
  msgstr "Título:"
482
 
492
  msgid "Brands list"
493
  msgstr "Lista de marcas"
494
 
495
+ #: classes/widgets/class-pwb-list.php:30
496
+ msgid "Display as:"
497
+ msgstr "Mostrar como:"
498
+
499
+ #: classes/widgets/class-pwb-list.php:35
500
+ msgid "Brand name"
501
+ msgstr "Nombre de la marca"
502
+
503
+ #: classes/widgets/class-pwb-list.php:41
504
+ msgid "Columns:"
505
+ msgstr "Columnas:"
506
+
507
+ #: classes/widgets/class-pwb-list.php:92 classes/widgets/class-pwb-list.php:94
508
  msgid "Go to"
509
  msgstr "Ir a"
510
 
511
+ #: main.php:68
512
  msgid ""
513
  "Perfect WooCommerce Brands needs WooCommerce to run. Please, install and "
514
  "active WooCommerce plugin."
540
  msgid "https://profiles.wordpress.org/titodevera/"
541
  msgstr "https://profiles.wordpress.org/titodevera/"
542
 
543
+ #~ msgid "Import brands from old plugin installation"
544
+ #~ msgstr "Importar marcas de otro plugin"
545
+
546
  #~ msgid "Brands metabox"
547
  #~ msgstr "Marcas metabox"
548
 
main.php CHANGED
@@ -1,71 +1,72 @@
1
- <?php
2
- /*
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.4.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
-
13
- Perfect WooCommerce Brands version 1.4.3, Copyright (C) 2016 Alberto de Vera Sevilla
14
-
15
- Perfect WooCommerce Brands is free software: you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License as published by
17
- the Free Software Foundation, either version 3 of the License, or
18
- (at your option) any later version.
19
-
20
- Perfect WooCommerce Brands is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with Perfect WooCommerce Brands. If not, see <http://www.gnu.org/licenses/>.
27
-
28
- */
29
-
30
- namespace Perfect_Woocommerce_Brands;
31
-
32
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
33
-
34
- //plugin constants
35
- define('PWB_PLUGIN', plugins_url( '', __FILE__ ));
36
- define('PWB_PLUGIN_PATH', plugin_basename( dirname( __FILE__ ) ));
37
- define('PWB_PLUGIN_VERSION', '1.4.3');
38
-
39
- //clean brands slug on plugin deactivation
40
- register_deactivation_hook( __FILE__, function(){
41
- update_option( 'old_wc_pwb_admin_tab_slug', 'null' );
42
- } );
43
-
44
- //loads textdomain for the translations
45
- add_action( 'plugins_loaded', function(){
46
- load_plugin_textdomain( 'perfect-woocommerce-brands', false, PWB_PLUGIN_PATH . '/lang' );
47
- } );
48
-
49
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
50
- if( is_plugin_active( 'woocommerce/woocommerce.php' ) ){
51
-
52
- require 'classes/widgets/class-pwb-dropdown.php';
53
- require 'classes/widgets/class-pwb-list.php';
54
- require 'classes/widgets/class-pwb-filter-by-brand.php';
55
- require 'classes/shortcodes/class-pwb-product-carousel.php';
56
- require 'classes/shortcodes/class-pwb-carousel.php';
57
- require 'classes/shortcodes/class-pwb-all-brands.php';
58
- require 'classes/shortcodes/class-pwb-brand.php';
59
- require 'classes/class-perfect-woocommerce-brands.php';
60
- require 'classes/class-pwb-admin-tab.php';
61
-
62
- new \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands();
63
-
64
- }elseif( is_admin() ){
65
-
66
- add_action( 'admin_notices', function() {
67
- $message = __( 'Perfect WooCommerce Brands needs WooCommerce to run. Please, install and active WooCommerce plugin.', 'perfect-woocommerce-brands' );
68
- printf( '<div class="%1$s"><p>%2$s</p></div>', 'notice notice-error', $message );
69
- });
70
-
71
- }
 
1
+ <?php
2
+ /*
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.4.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
+
13
+ Perfect WooCommerce Brands version 1.4.4, Copyright (C) 2016 Alberto de Vera Sevilla
14
+
15
+ Perfect WooCommerce Brands is free software: you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License as published by
17
+ the Free Software Foundation, either version 3 of the License, or
18
+ (at your option) any later version.
19
+
20
+ Perfect WooCommerce Brands is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with Perfect WooCommerce Brands. If not, see <http://www.gnu.org/licenses/>.
27
+
28
+ */
29
+
30
+ namespace Perfect_Woocommerce_Brands;
31
+
32
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
33
+
34
+ //plugin constants
35
+ define( 'PWB_PLUGIN', plugins_url( '', __FILE__ ) );
36
+ define( 'PWB_PLUGIN_PATH', plugin_basename( dirname( __FILE__ ) ) );
37
+ define( 'PWB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
38
+ define( 'PWB_PLUGIN_VERSION', '1.4.4' );
39
+
40
+ //clean brands slug on plugin deactivation
41
+ register_deactivation_hook( __FILE__, function(){
42
+ update_option( 'old_wc_pwb_admin_tab_slug', 'null' );
43
+ } );
44
+
45
+ //loads textdomain for the translations
46
+ add_action( 'plugins_loaded', function(){
47
+ load_plugin_textdomain( 'perfect-woocommerce-brands', false, PWB_PLUGIN_PATH . '/lang' );
48
+ } );
49
+
50
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
51
+ if( is_plugin_active( 'woocommerce/woocommerce.php' ) ){
52
+
53
+ require 'classes/widgets/class-pwb-dropdown.php';
54
+ require 'classes/widgets/class-pwb-list.php';
55
+ require 'classes/widgets/class-pwb-filter-by-brand.php';
56
+ require 'classes/shortcodes/class-pwb-product-carousel.php';
57
+ require 'classes/shortcodes/class-pwb-carousel.php';
58
+ require 'classes/shortcodes/class-pwb-all-brands.php';
59
+ require 'classes/shortcodes/class-pwb-brand.php';
60
+ require 'classes/class-perfect-woocommerce-brands.php';
61
+ require 'classes/class-pwb-admin-tab.php';
62
+
63
+ new \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands();
64
+
65
+ }elseif( is_admin() ){
66
+
67
+ add_action( 'admin_notices', function() {
68
+ $message = __( 'Perfect WooCommerce Brands needs WooCommerce to run. Please, install and active WooCommerce plugin.', 'perfect-woocommerce-brands' );
69
+ printf( '<div class="%1$s"><p>%2$s</p></div>', 'notice notice-error', $message );
70
+ });
71
+
72
+ }
readme.txt CHANGED
@@ -1,98 +1,110 @@
1
- === Perfect WooCommerce Brands ===
2
- Contributors: titodevera
3
- Donate link: mailto:albertodeverasevilla@gmail.com
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.6.1
7
- Stable tag: 1.4.3
8
- License: GPL3
9
- License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
10
-
11
- Perfect WooCommerce Brands allows you to show product brands in your WooCommerce based store
12
-
13
- == Description ==
14
- Whether we like to admit it or not, we are all influenced by brands. Brands are a guarantee for quality, they assure product recognition in customers.
15
- Is essential to work with product brands for increase sales and generate reliability on your e-commerce site.
16
- With this extension you can add product brands to your WooCommerce site.
17
-
18
- = Requirements =
19
- > * PHP 5.3 or higher
20
- > * WordPress 4.4 or higher
21
- > * WooCommerce 2.4.0 or higher
22
- > * Visual Composer (recommended)
23
-
24
- = Features =
25
- > * Very easy to use, 100% free, no ads, no premium version exists
26
- > * Assign brands to products
27
- > * Associate a banner and a link to each brand
28
- > * Translation-ready (English and Spanish included)
29
- > * Shortcode: Display all brands
30
- > * Shortcode: Display brands carousel
31
- > * Shortcode: Display product carousel by brand
32
- > * Shortcode: Display brands for a specific product
33
- > * Visual Composer support
34
- > * Widget: Display brands as dropdown
35
- > * Widget: Display brands as list
36
- > * Widget: Filter products by brand **NEW!**
37
- > * Import brands from other brands plugins **NEW!**
38
- > * Minimalist design and fully responsive
39
- > * Very lightweight
40
- > * Customizable brands slug
41
- > * And much more!
42
-
43
-
44
- == Installation ==
45
- 1. Upload the plugin to the '/wp-content/plugins/' directory.
46
- 2. Activate the plugin through the 'Plugins' menu in WordPress.
47
-
48
-
49
- == Frequently Asked Questions ==
50
- = Is Perfect WooCommerce Brands free? =
51
- Yes, of course. This plugin is 100% free. No ads, no premium version exists.
52
-
53
- = Where are plugin settings? =
54
- Go to `WooCommerce/Settings/` and click on `Brands` tab
55
-
56
- = How can i use the available shortcodes without Visual Composer? =
57
- There are four shortcodes available:
58
- > * Display all brands: [pwb-all-brands per_page="10" image_size="thumbnail"]
59
- > * Display brands carousel: [pwb-carousel items="10" items_to_show="5" items_to_scroll="1" image_size="thumbnail" autoplay="true"]
60
- > * Display product carousel by brand: [pwb-product-carousel brand="all" products="10" products_to_show="4" products_to_scroll="2" image_size="" items_to_show="2" autoplay="true"]
61
- > * Display brands for a specific product: [pwb-brand product_id="5" image_size="thumbnail"]
62
-
63
-
64
- == Screenshots ==
65
- 1. Brands carousel
66
- 2. Brands page
67
- 3. Brands taxonomy
68
- 4. Brands shortcodes (with Visual Composer)
69
-
70
-
71
- == Changelog ==
72
- = 1.4.3 =
73
- * Feature (Widget): Filter products by brand
74
- * Feature (Option): Show brand logo in product loop
75
- * Feature: Brand microdata added to product page
76
- * Feature (Tool): Migrate brands from "YITH WooCommerce Brands Add-on"
77
- = 1.4.2 =
78
- * Fix: Table collapses in "Admin > Products > Brands" (thanks eljkmw)
79
- * Fix: "pwb-brand" shortcode does not display the brand when it has not a logo assigned
80
- = 1.4.1 =
81
- * Feature (Option): Hide brand's description in archive page
82
- * Fix: "pwb-all-brands" and "pwb-brand" show the content before they should
83
- * Clean database on uninstallation
84
- * Minor code improvements and fixes
85
- = 1.4 =
86
- * Feature: Product carousel by brand added
87
- * Minor bug fixes
88
- = 1.3 =
89
- * Feature: If is set, show brand description in brand page
90
- * Feature: Change brands position in single product
91
- = 1.2 =
92
- * Feature: Associate a banner and a link to each brand
93
- * Minor tweaks
94
- * Fully tested on WooCommerce 2.6
95
- = 1.1 =
96
- * Minor bug fixes
97
- = 1.0 =
 
 
 
 
 
 
 
 
 
 
 
 
98
  * Initial release
1
+ === Perfect WooCommerce Brands ===
2
+ Contributors: titodevera
3
+ 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.7.2
7
+ Stable tag: 1.4.4
8
+ License: GPL3
9
+ License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
10
+
11
+ Perfect WooCommerce Brands allows you to show product brands in your WooCommerce based store
12
+
13
+ == Description ==
14
+ Whether we like to admit it or not, we are all influenced by brands. Brands are a guarantee for quality, they assure product recognition in customers.
15
+ Is essential to work with product brands for increase sales and generate reliability on your e-commerce site.
16
+ With this extension you can add product brands to your WooCommerce site.
17
+
18
+ = Requirements =
19
+ > * PHP 5.3 or higher (tested on PHP7 too)
20
+ > * WordPress 4.4 or higher
21
+ > * WooCommerce 2.4.0 or higher
22
+ > * Visual Composer (recommended)
23
+
24
+ = Features =
25
+ > * Very easy to use, 100% free, no ads, no premium version exists
26
+ > * Assign brands to products
27
+ > * Associate a banner and a link to each brand
28
+ > * Translation-ready (English and Spanish included)
29
+ > * Shortcode: Display all brands
30
+ > * Shortcode: Display brands carousel
31
+ > * Shortcode: Display product carousel by brand
32
+ > * Shortcode: Display brands for a specific product
33
+ > * Visual Composer support
34
+ > * Widget: Display brands as dropdown
35
+ > * Widget: Display brands as list (brand names or brand logos)
36
+ > * Widget: Filter products by brand
37
+ > * Import brands from other brands plugins
38
+ > * Minimalist design and fully responsive
39
+ > * Very lightweight
40
+ > * Customizable brands slug
41
+ > * And much more!
42
+
43
+
44
+ == Installation ==
45
+ 1. Upload the plugin to the '/wp-content/plugins/' directory.
46
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
47
+
48
+
49
+ == Frequently Asked Questions ==
50
+ = Is Perfect WooCommerce Brands free? =
51
+ Yes, of course. This plugin is 100% free. No ads, no premium version exists.
52
+
53
+ = Where are plugin settings? =
54
+ Go to `WooCommerce/Settings/` and click on `Brands` tab
55
+
56
+ = How can i use the available shortcodes without Visual Composer? =
57
+ There are four shortcodes available:
58
+ > * Display all brands: [pwb-all-brands per_page="10" image_size="thumbnail" hide_empty="false"]
59
+ > * Display brands carousel: [pwb-carousel items="10" items_to_show="5" items_to_scroll="1" image_size="thumbnail" autoplay="true" arrows="true"]
60
+ > * Display product carousel by brand: [pwb-product-carousel brand="all" products="10" products_to_show="4" products_to_scroll="2" image_size="" items_to_show="2" autoplay="true" arrows="true"]
61
+ > * Display brands for a specific product: [pwb-brand product_id="5" image_size="thumbnail"]
62
+
63
+
64
+ == Screenshots ==
65
+ 1. Brands carousel
66
+ 2. Brands page
67
+ 3. Brands taxonomy
68
+ 4. Brands shortcodes (with Visual Composer)
69
+ 5. Product carousel by brand
70
+
71
+
72
+ == Changelog ==
73
+ = 1.4.4 =
74
+ * Important improvement of the user experience when assigning images to a brand
75
+ * Feature (Option): Hide brands in single product, show as image or show as link
76
+ * Feature: Hide prev/next arrows on carousel shortcodes
77
+ * Feature: Hide empty brands option for "Display all brands" shortcode
78
+ * Feature: New options for "Display brands as list" widget
79
+ * Fix: Autoplay bug on carousel shortcodes
80
+ * Tested on PHP7
81
+ * Shortcut to the plugin settings added to the plugin list page
82
+ * "Help us" notice added
83
+ * Minor code improvements
84
+ = 1.4.3 =
85
+ * Feature (Widget): Filter products by brand
86
+ * Feature (Option): Show brand logo in product loop
87
+ * Feature: Brand microdata added to product page
88
+ * Feature (Tool): Migrate brands from "YITH WooCommerce Brands Add-on"
89
+ = 1.4.2 =
90
+ * Fix: Table collapses in "Admin > Products > Brands" (thanks eljkmw)
91
+ * Fix: "pwb-brand" shortcode does not display the brand when it has not a logo assigned
92
+ = 1.4.1 =
93
+ * Feature (Option): Hide brand's description in archive page
94
+ * Fix: "pwb-all-brands" and "pwb-brand" show the content before they should
95
+ * Clean database on uninstallation
96
+ * Minor code improvements and fixes
97
+ = 1.4 =
98
+ * Feature: Product carousel by brand added
99
+ * Minor bug fixes
100
+ = 1.3 =
101
+ * Feature: If is set, show brand description in brand page
102
+ * Feature: Change brands position in single product
103
+ = 1.2 =
104
+ * Feature: Associate a banner and a link to each brand
105
+ * Minor tweaks
106
+ * Fully tested on WooCommerce 2.6
107
+ = 1.1 =
108
+ * Minor bug fixes
109
+ = 1.0 =
110
  * Initial release
uninstall.php CHANGED
@@ -1,15 +1,16 @@
1
- <?php
2
- namespace Perfect_Woocommerce_Brands;
3
-
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
-
6
- delete_option('wc_pwb_admin_tab_section_title');
7
- delete_option('wc_pwb_admin_tab_slug');
8
- delete_option('wc_pwb_admin_tab_brand_logo_size');
9
- delete_option('wc_pwb_admin_tab_brand_single_position');
10
- delete_option('wc_pwb_admin_tab_brand_desc');
11
- delete_option('wc_pwb_admin_tab_section_end');
12
-
13
- //update permalinks and clean cache
14
- flush_rewrite_rules();
15
- wp_cache_flush();
 
1
+ <?php
2
+ namespace Perfect_Woocommerce_Brands;
3
+
4
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
+
6
+ delete_option('wc_pwb_admin_tab_section_title');
7
+ delete_option('wc_pwb_admin_tab_slug');
8
+ delete_option('wc_pwb_admin_tab_brand_logo_size');
9
+ delete_option('wc_pwb_admin_tab_brand_single_position');
10
+ delete_option('wc_pwb_admin_tab_brand_desc');
11
+ delete_option('wc_pwb_admin_tab_section_end');
12
+ delete_option('wc_pwb_notice_plugin_review');
13
+
14
+ //update permalinks and clean cache
15
+ flush_rewrite_rules();
16
+ wp_cache_flush();