Perfect Brands for WooCommerce - Version 2.0.5

Version Description

  • Fix: Security fix
  • Fix: WooCommerce compatibility
Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 Perfect Brands for WooCommerce
Version 2.0.5
Comparing to
See all releases

Code changes from version 2.0.4 to 2.0.5

assets/js/functions-admin.js CHANGED
@@ -95,7 +95,11 @@
95
  $currentStar.removeClass('dashicons-star-empty');
96
  $currentStar.addClass('dashicons-star-filled');
97
  }
98
- var data = { 'action': 'pwb_admin_set_featured_brand', 'brand': $currentStar.data('brand-id') };
 
 
 
 
99
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) {
100
  $currentStar.removeClass('pwb-blocked');
101
  if (response.success) {
@@ -114,7 +118,11 @@
114
  $('.taxonomy-pwb-brand #pwb-first-featured-brands').on('change', function (e) {
115
  e.preventDefault();
116
  $('#screen-options-apply').replaceWith('<img src="' + pwb_ajax_object_admin.site_url + '/wp-admin/images/loading.gif">');
117
- var data = { 'action': 'pwb_admin_save_screen_settings', 'new_val': $(this).is(':checked') };
 
 
 
 
118
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) { location.reload(); });
119
  });
120
 
@@ -143,7 +151,8 @@
143
 
144
  var data = {
145
  'action': 'pwb_admin_migrate_brands',
146
- 'from': $(this).val()
 
147
  };
148
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) {
149
 
@@ -175,7 +184,8 @@
175
 
176
  var data = {
177
  'action': 'pwb_admin_dummy_data',
178
- 'from': $(this).val()
 
179
  };
180
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) {
181
 
@@ -224,7 +234,8 @@
224
  $('#wc_pwb_admin_status_result').html('<img src="' + pwb_ajax_object_admin.site_url + '/wp-admin/images/spinner.gif' + '" alt="Loading" height="20" width="20">');
225
  $('#wc_pwb_admin_status_result').show();
226
  var data = {
227
- 'action': 'pwb_system_status'
 
228
  };
229
  $.post(ajaxurl, data, function (response) {
230
  $('#wc_pwb_admin_status_result').html(response);
@@ -243,8 +254,9 @@
243
  var noticeName = $(this).closest('.pwb-notice-dismissible').data('notice');
244
 
245
  var data = {
246
- 'action': 'dismiss_pwb_notice',
247
- 'notice_name': noticeName
 
248
  };
249
  $.post(ajaxurl, data, function (response) {
250
  //callback
@@ -290,7 +302,7 @@
290
 
291
  var data = {
292
  'action': 'pwb_brands_export',
293
- 'nonce': pwb_ajax_object_admin.nonce.export
294
  };
295
 
296
 
@@ -331,7 +343,7 @@
331
  var reqData = new FormData();
332
  reqData.append('action', 'pwb_brands_import');
333
  reqData.append('file', file);
334
- reqData.append('nonce', pwb_ajax_object_admin.nonce.import);
335
 
336
  $.ajax({
337
  url: pwb_ajax_object_admin.ajax_url,
95
  $currentStar.removeClass('dashicons-star-empty');
96
  $currentStar.addClass('dashicons-star-filled');
97
  }
98
+ var data = {
99
+ 'action': 'pwb_admin_set_featured_brand',
100
+ 'brand': $currentStar.data('brand-id'),
101
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_admin_set_featured_brand
102
+ };
103
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) {
104
  $currentStar.removeClass('pwb-blocked');
105
  if (response.success) {
118
  $('.taxonomy-pwb-brand #pwb-first-featured-brands').on('change', function (e) {
119
  e.preventDefault();
120
  $('#screen-options-apply').replaceWith('<img src="' + pwb_ajax_object_admin.site_url + '/wp-admin/images/loading.gif">');
121
+ var data = {
122
+ 'action': 'pwb_admin_save_screen_settings',
123
+ 'new_val': $(this).is(':checked'),
124
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_admin_save_screen_settings
125
+ };
126
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) { location.reload(); });
127
  });
128
 
151
 
152
  var data = {
153
  'action': 'pwb_admin_migrate_brands',
154
+ 'from': $(this).val(),
155
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_admin_migrate_brands
156
  };
157
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) {
158
 
184
 
185
  var data = {
186
  'action': 'pwb_admin_dummy_data',
187
+ 'from': $(this).val(),
188
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_admin_dummy_data
189
  };
190
  $.post(pwb_ajax_object_admin.ajax_url, data, function (response) {
191
 
234
  $('#wc_pwb_admin_status_result').html('<img src="' + pwb_ajax_object_admin.site_url + '/wp-admin/images/spinner.gif' + '" alt="Loading" height="20" width="20">');
235
  $('#wc_pwb_admin_status_result').show();
236
  var data = {
237
+ 'action': 'pwb_system_status',
238
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_system_status
239
  };
240
  $.post(ajaxurl, data, function (response) {
241
  $('#wc_pwb_admin_status_result').html(response);
254
  var noticeName = $(this).closest('.pwb-notice-dismissible').data('notice');
255
 
256
  var data = {
257
+ 'action': 'pwb_dismiss_notice',
258
+ 'notice_name': noticeName,
259
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_dismiss_notice
260
  };
261
  $.post(ajaxurl, data, function (response) {
262
  //callback
302
 
303
  var data = {
304
  'action': 'pwb_brands_export',
305
+ 'nonce': pwb_ajax_object_admin.nonce.pwb_brands_export
306
  };
307
 
308
 
343
  var reqData = new FormData();
344
  reqData.append('action', 'pwb_brands_import');
345
  reqData.append('file', file);
346
+ reqData.append('nonce', pwb_ajax_object_admin.nonce.pwb_brands_import);
347
 
348
  $.ajax({
349
  url: pwb_ajax_object_admin.ajax_url,
assets/js/functions-admin.min.js CHANGED
@@ -1 +1 @@
1
- !function($){"use strict";var media_uploader=null,$systemStatusBtn;function open_media_uploader_image(event,imageSelectorButton){var $imageSelectorScope=imageSelectorButton.parent();(media_uploader=wp.media({frame:"post",state:"insert",multiple:!1})).on("insert",(function(){var json=media_uploader.state().get("selection").first().toJSON(),image_id=json.id,image_url,image_html='<img src="'+json.url+'" width="90" height="90">',current_selector="";switch(event.target.id){case"pwb_brand_image_select":current_selector=".taxonomy-pwb-brand #pwb_brand_image";break;case"pwb_brand_banner_select":current_selector=".taxonomy-pwb-brand #pwb_brand_banner"}$(current_selector).val(image_id),$(current_selector+"_result").remove(),$(".pwb_brand_image_selected",$imageSelectorScope).length?$(".pwb_brand_image_selected span",$imageSelectorScope).html(image_html):$imageSelectorScope.append('<div class="pwb_brand_image_selected"><span>'+image_html+"</span></div>"),add_delete_link($imageSelectorScope)})),media_uploader.open()}function add_delete_link($imageSelectorScope){$(".pwb_brand_image_selected span",$imageSelectorScope).append('<a href="#" class="pwb_brand_image_selected_remove">X</a>'),$(".pwb_brand_image_selected_remove",$imageSelectorScope).on("click",(function(event){event.preventDefault(),$(this).closest(".pwb_brand_image_selected").remove(),$("#pwb_brand_image",$imageSelectorScope).val(""),$("#pwb_brand_banner",$imageSelectorScope).val("")}))}function pwbBindEventsToWigets(widget){var $currentWidget=$(".pwb-select-display-as");null!=widget&&($currentWidget=$(".pwb-select-display-as",widget)),$currentWidget.on("change",(function(){"brand_logo"==$(this).val()?$(this).parent().siblings(".pwb-display-as-logo").addClass("show"):$(this).parent().siblings(".pwb-display-as-logo").removeClass("show")}))}$(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").on("click",(function(event){open_media_uploader_image(event,$(this))})),$(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").each((function(){add_delete_link($(this).parent())})),$("body").hasClass("edit-tags-php")&&$("body").hasClass("taxonomy-pwb-brand")&&$(document).ajaxSuccess((function(event,xhr,settings){void 0!==settings&&settings.data&&~settings.data.indexOf("action=add-tag")&&~settings.data.indexOf("taxonomy=pwb-brand")&&($("#pwb_brand_image").val(""),$("#pwb_brand_banner").val(""),$(".pwb_brand_image_selected").remove())})),$(".taxonomy-pwb-brand table .column-featured > span").not("pwb-blocked").on("click",(function(e){e.preventDefault();var $currentStar=$(this);$currentStar.addClass("pwb-blocked"),$currentStar.hasClass("dashicons-star-filled")?($currentStar.removeClass("dashicons-star-filled"),$currentStar.addClass("dashicons-star-empty")):($currentStar.removeClass("dashicons-star-empty"),$currentStar.addClass("dashicons-star-filled"));var data={action:"pwb_admin_set_featured_brand",brand:$currentStar.data("brand-id")};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){if($currentStar.removeClass("pwb-blocked"),response.success){var $featuredCount=$(".taxonomy-pwb-brand .pwb-featured-count > span");"up"==response.data.direction?$featuredCount.html(parseInt($featuredCount.text())+1):$featuredCount.html(parseInt($featuredCount.text())-1)}else alert(response.data.error_msg)}))})),$(".taxonomy-pwb-brand #pwb-first-featured-brands").on("change",(function(e){e.preventDefault(),$("#screen-options-apply").replaceWith('<img src="'+pwb_ajax_object_admin.site_url+'/wp-admin/images/loading.gif">');var data={action:"pwb_admin_save_screen_settings",new_val:$(this).is(":checked")};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){location.reload()}))})),$(".pwb-edit-brands-bottom > span").on("click",(function(e){e.preventDefault(),$(".taxonomy-pwb-brand #col-left").toggleClass("pwb-force-full-width"),$(".taxonomy-pwb-brand #col-right").toggleClass("pwb-force-full-width")})),$(".pwb-admin-selectwoo").length&&$(".pwb-admin-selectwoo").selectWoo(),$("#wc_pwb_admin_tab_tools_migrate").on("change",(function(){if("-"!=$(this).val()&&confirm(pwb_ajax_object_admin.translations.migrate_notice)){$("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>'),$(".pwb-modal-inner").html("<p>"+pwb_ajax_object_admin.translations.migrating+"</p>");var data={action:"pwb_admin_migrate_brands",from:$(this).val()};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){setTimeout((function(){location.href=pwb_ajax_object_admin.brands_url}),1e3)}))}$(this).val("-")})),$("#wc_pwb_admin_tab_tools_dummy_data").on("change",(function(){if("-"!=$(this).val()&&confirm(pwb_ajax_object_admin.translations.dummy_data_notice)){$("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>'),$(".pwb-modal-inner").html("<p>"+pwb_ajax_object_admin.translations.dummy_data+"</p>");var data={action:"pwb_admin_dummy_data",from:$(this).val()};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){setTimeout((function(){location.href=pwb_ajax_object_admin.brands_url}),1e3)}))}$(this).val("-")})),$("#wc_pwb_admin_tab_tools_system_status").siblings("p").addClass("button wc_pwb_admin_tab_status_btn"),$(".wc_pwb_admin_tab_status_btn").on("click",(function(e){if(e.preventDefault(),!$("#wc_pwb_admin_status_result").length){var $systemStatusTextarea=$("#wc_pwb_admin_tab_tools_system_status");$('<pre id="wc_pwb_admin_status_result"></pre>').insertAfter($systemStatusTextarea),$("#wc_pwb_admin_status_result").click((function(e){e.preventDefault();var refNode=$(this)[0],range;if($.browser.msie)(range=document.body.createTextRange()).moveToElementText(refNode),range.select();else if($.browser.mozilla||$.browser.opera){var selection=window.getSelection(),range;(range=document.createRange()).selectNodeContents(refNode),selection.removeAllRanges(),selection.addRange(range)}else if($.browser.safari){var selection;(selection=window.getSelection()).setBaseAndExtent(refNode,0,refNode,1)}}))}$("#wc_pwb_admin_status_result").html('<img src="'+pwb_ajax_object_admin.site_url+'/wp-admin/images/spinner.gif" alt="Loading" height="20" width="20">'),$("#wc_pwb_admin_status_result").show();var data={action:"pwb_system_status"};$.post(ajaxurl,data,(function(response){$("#wc_pwb_admin_status_result").html(response),$("#wc_pwb_admin_status_result").trigger("click")}))})),$(document).on("click",".pwb-notice-dismissible .notice-dismiss",(function(e){e.preventDefault();var noticeName,data={action:"dismiss_pwb_notice",notice_name:$(this).closest(".pwb-notice-dismissible").data("notice")};$.post(ajaxurl,data,(function(response){}))})),pwbBindEventsToWigets(),$(document).bind("widget-added",(function(e,widget){pwbBindEventsToWigets(widget)})),$(document).on("widget-updated",(function(e,widget){pwbBindEventsToWigets(widget)})),$("button.pwb-brands-export").on("click",(function(e){e.preventDefault();var $clickedBtn=$(this);$clickedBtn.addClass("pwb-loading-overlay"),$clickedBtn.prop("disabled",!0);var data={action:"pwb_brands_export",nonce:pwb_ajax_object_admin.nonce.export};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){if(response.success){$clickedBtn.removeClass("pwb-loading-overlay"),$clickedBtn.prop("disabled",!1),$("#pwb-download-export-file").remove();var link=document.createElement("a");link.download="brands.json",link.id="pwb-download-export-file",link.href=response.data.export_file_url,$("body").append(link),link.click()}}))})),$("button.pwb-brands-import").on("click",(function(e){e.preventDefault(),$("input.pwb-brands-import-file").trigger("click")})),$("input.pwb-brands-import-file").on("change",(function(e){e.preventDefault();var $clickedBtn=$("button.pwb-brands-import");$clickedBtn.addClass("pwb-loading-overlay"),$clickedBtn.prop("disabled",!0);var file=$(this)[0].files[0],reqData=new FormData;reqData.append("action","pwb_brands_import"),reqData.append("file",file),reqData.append("nonce",pwb_ajax_object_admin.nonce.import),$.ajax({url:pwb_ajax_object_admin.ajax_url,type:"post",cache:!1,dataType:"json",contentType:!1,processData:!1,data:reqData,success:function(resp){resp.success?($clickedBtn.removeClass("pwb-loading-overlay"),location.reload()):alert("Importer error")}})}))}(jQuery);
1
+ !function($){"use strict";var media_uploader=null,$systemStatusBtn;function open_media_uploader_image(event,imageSelectorButton){var $imageSelectorScope=imageSelectorButton.parent();(media_uploader=wp.media({frame:"post",state:"insert",multiple:!1})).on("insert",(function(){var json=media_uploader.state().get("selection").first().toJSON(),image_id=json.id,image_url,image_html='<img src="'+json.url+'" width="90" height="90">',current_selector="";switch(event.target.id){case"pwb_brand_image_select":current_selector=".taxonomy-pwb-brand #pwb_brand_image";break;case"pwb_brand_banner_select":current_selector=".taxonomy-pwb-brand #pwb_brand_banner"}$(current_selector).val(image_id),$(current_selector+"_result").remove(),$(".pwb_brand_image_selected",$imageSelectorScope).length?$(".pwb_brand_image_selected span",$imageSelectorScope).html(image_html):$imageSelectorScope.append('<div class="pwb_brand_image_selected"><span>'+image_html+"</span></div>"),add_delete_link($imageSelectorScope)})),media_uploader.open()}function add_delete_link($imageSelectorScope){$(".pwb_brand_image_selected span",$imageSelectorScope).append('<a href="#" class="pwb_brand_image_selected_remove">X</a>'),$(".pwb_brand_image_selected_remove",$imageSelectorScope).on("click",(function(event){event.preventDefault(),$(this).closest(".pwb_brand_image_selected").remove(),$("#pwb_brand_image",$imageSelectorScope).val(""),$("#pwb_brand_banner",$imageSelectorScope).val("")}))}function pwbBindEventsToWigets(widget){var $currentWidget=$(".pwb-select-display-as");null!=widget&&($currentWidget=$(".pwb-select-display-as",widget)),$currentWidget.on("change",(function(){"brand_logo"==$(this).val()?$(this).parent().siblings(".pwb-display-as-logo").addClass("show"):$(this).parent().siblings(".pwb-display-as-logo").removeClass("show")}))}$(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").on("click",(function(event){open_media_uploader_image(event,$(this))})),$(".taxonomy-pwb-brand #pwb_brand_image_select, .taxonomy-pwb-brand #pwb_brand_banner_select").each((function(){add_delete_link($(this).parent())})),$("body").hasClass("edit-tags-php")&&$("body").hasClass("taxonomy-pwb-brand")&&$(document).ajaxSuccess((function(event,xhr,settings){void 0!==settings&&settings.data&&~settings.data.indexOf("action=add-tag")&&~settings.data.indexOf("taxonomy=pwb-brand")&&($("#pwb_brand_image").val(""),$("#pwb_brand_banner").val(""),$(".pwb_brand_image_selected").remove())})),$(".taxonomy-pwb-brand table .column-featured > span").not("pwb-blocked").on("click",(function(e){e.preventDefault();var $currentStar=$(this);$currentStar.addClass("pwb-blocked"),$currentStar.hasClass("dashicons-star-filled")?($currentStar.removeClass("dashicons-star-filled"),$currentStar.addClass("dashicons-star-empty")):($currentStar.removeClass("dashicons-star-empty"),$currentStar.addClass("dashicons-star-filled"));var data={action:"pwb_admin_set_featured_brand",brand:$currentStar.data("brand-id"),nonce:pwb_ajax_object_admin.nonce.pwb_admin_set_featured_brand};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){if($currentStar.removeClass("pwb-blocked"),response.success){var $featuredCount=$(".taxonomy-pwb-brand .pwb-featured-count > span");"up"==response.data.direction?$featuredCount.html(parseInt($featuredCount.text())+1):$featuredCount.html(parseInt($featuredCount.text())-1)}else alert(response.data.error_msg)}))})),$(".taxonomy-pwb-brand #pwb-first-featured-brands").on("change",(function(e){e.preventDefault(),$("#screen-options-apply").replaceWith('<img src="'+pwb_ajax_object_admin.site_url+'/wp-admin/images/loading.gif">');var data={action:"pwb_admin_save_screen_settings",new_val:$(this).is(":checked"),nonce:pwb_ajax_object_admin.nonce.pwb_admin_save_screen_settings};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){location.reload()}))})),$(".pwb-edit-brands-bottom > span").on("click",(function(e){e.preventDefault(),$(".taxonomy-pwb-brand #col-left").toggleClass("pwb-force-full-width"),$(".taxonomy-pwb-brand #col-right").toggleClass("pwb-force-full-width")})),$(".pwb-admin-selectwoo").length&&$(".pwb-admin-selectwoo").selectWoo(),$("#wc_pwb_admin_tab_tools_migrate").on("change",(function(){if("-"!=$(this).val()&&confirm(pwb_ajax_object_admin.translations.migrate_notice)){$("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>'),$(".pwb-modal-inner").html("<p>"+pwb_ajax_object_admin.translations.migrating+"</p>");var data={action:"pwb_admin_migrate_brands",from:$(this).val(),nonce:pwb_ajax_object_admin.nonce.pwb_admin_migrate_brands};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){setTimeout((function(){location.href=pwb_ajax_object_admin.brands_url}),1e3)}))}$(this).val("-")})),$("#wc_pwb_admin_tab_tools_dummy_data").on("change",(function(){if("-"!=$(this).val()&&confirm(pwb_ajax_object_admin.translations.dummy_data_notice)){$("html").append('<div class="pwb-modal"><div class="pwb-modal-inner"></div></div>'),$(".pwb-modal-inner").html("<p>"+pwb_ajax_object_admin.translations.dummy_data+"</p>");var data={action:"pwb_admin_dummy_data",from:$(this).val(),nonce:pwb_ajax_object_admin.nonce.pwb_admin_dummy_data};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){setTimeout((function(){location.href=pwb_ajax_object_admin.brands_url}),1e3)}))}$(this).val("-")})),$("#wc_pwb_admin_tab_tools_system_status").siblings("p").addClass("button wc_pwb_admin_tab_status_btn"),$(".wc_pwb_admin_tab_status_btn").on("click",(function(e){if(e.preventDefault(),!$("#wc_pwb_admin_status_result").length){var $systemStatusTextarea=$("#wc_pwb_admin_tab_tools_system_status");$('<pre id="wc_pwb_admin_status_result"></pre>').insertAfter($systemStatusTextarea),$("#wc_pwb_admin_status_result").click((function(e){e.preventDefault();var refNode=$(this)[0],range;if($.browser.msie)(range=document.body.createTextRange()).moveToElementText(refNode),range.select();else if($.browser.mozilla||$.browser.opera){var selection=window.getSelection(),range;(range=document.createRange()).selectNodeContents(refNode),selection.removeAllRanges(),selection.addRange(range)}else if($.browser.safari){var selection;(selection=window.getSelection()).setBaseAndExtent(refNode,0,refNode,1)}}))}$("#wc_pwb_admin_status_result").html('<img src="'+pwb_ajax_object_admin.site_url+'/wp-admin/images/spinner.gif" alt="Loading" height="20" width="20">'),$("#wc_pwb_admin_status_result").show();var data={action:"pwb_system_status",nonce:pwb_ajax_object_admin.nonce.pwb_system_status};$.post(ajaxurl,data,(function(response){$("#wc_pwb_admin_status_result").html(response),$("#wc_pwb_admin_status_result").trigger("click")}))})),$(document).on("click",".pwb-notice-dismissible .notice-dismiss",(function(e){e.preventDefault();var noticeName,data={action:"pwb_dismiss_notice",notice_name:$(this).closest(".pwb-notice-dismissible").data("notice"),nonce:pwb_ajax_object_admin.nonce.pwb_dismiss_notice};$.post(ajaxurl,data,(function(response){}))})),pwbBindEventsToWigets(),$(document).bind("widget-added",(function(e,widget){pwbBindEventsToWigets(widget)})),$(document).on("widget-updated",(function(e,widget){pwbBindEventsToWigets(widget)})),$("button.pwb-brands-export").on("click",(function(e){e.preventDefault();var $clickedBtn=$(this);$clickedBtn.addClass("pwb-loading-overlay"),$clickedBtn.prop("disabled",!0);var data={action:"pwb_brands_export",nonce:pwb_ajax_object_admin.nonce.pwb_brands_export};$.post(pwb_ajax_object_admin.ajax_url,data,(function(response){if(response.success){$clickedBtn.removeClass("pwb-loading-overlay"),$clickedBtn.prop("disabled",!1),$("#pwb-download-export-file").remove();var link=document.createElement("a");link.download="brands.json",link.id="pwb-download-export-file",link.href=response.data.export_file_url,$("body").append(link),link.click()}}))})),$("button.pwb-brands-import").on("click",(function(e){e.preventDefault(),$("input.pwb-brands-import-file").trigger("click")})),$("input.pwb-brands-import-file").on("change",(function(e){e.preventDefault();var $clickedBtn=$("button.pwb-brands-import");$clickedBtn.addClass("pwb-loading-overlay"),$clickedBtn.prop("disabled",!0);var file=$(this)[0].files[0],reqData=new FormData;reqData.append("action","pwb_brands_import"),reqData.append("file",file),reqData.append("nonce",pwb_ajax_object_admin.nonce.pwb_brands_import),$.ajax({url:pwb_ajax_object_admin.ajax_url,type:"post",cache:!1,dataType:"json",contentType:!1,processData:!1,data:reqData,success:function(resp){resp.success?($clickedBtn.removeClass("pwb-loading-overlay"),location.reload()):alert("Importer error")}})}))}(jQuery);
classes/admin/class-brands-exporter.php CHANGED
@@ -10,8 +10,8 @@ class Brands_Exporter
10
  function __construct()
11
  {
12
  add_action('after-pwb-brand-table', array($this, 'exporter_button'));
13
- add_action('wp_ajax_pwb_brands_export', array($this, 'export_brands'));
14
- add_action('wp_ajax_pwb_brands_import', array($this, 'import_brands'));
15
  }
16
 
17
  public function exporter_button()
@@ -23,7 +23,7 @@ class Brands_Exporter
23
  );
24
  }
25
 
26
- public function export_brands()
27
  {
28
  if (
29
  isset($_REQUEST['nonce'])
@@ -74,7 +74,7 @@ class Brands_Exporter
74
  wp_send_json_success($result);
75
  }
76
 
77
- public function import_brands()
78
  {
79
 
80
  if (
10
  function __construct()
11
  {
12
  add_action('after-pwb-brand-table', array($this, 'exporter_button'));
13
+ add_action('wp_ajax_pwb_brands_export', array($this, 'brands_export'));
14
+ add_action('wp_ajax_pwb_brands_import', array($this, 'brands_import'));
15
  }
16
 
17
  public function exporter_button()
23
  );
24
  }
25
 
26
+ public function brands_export()
27
  {
28
  if (
29
  isset($_REQUEST['nonce'])
74
  wp_send_json_success($result);
75
  }
76
 
77
+ public function brands_import()
78
  {
79
 
80
  if (
classes/admin/class-edit-brands-page.php CHANGED
@@ -14,9 +14,9 @@ class Edit_Brands_Page
14
  add_filter('get_terms', array($this, 'brand_list_admin_filter'), 10, 3);
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('wp_ajax_pwb_admin_set_featured_brand', array($this, 'set_featured_brand'));
18
  add_filter('screen_settings', array($this, 'add_screen_options'), 10, 2);
19
- add_action('wp_ajax_pwb_admin_save_screen_settings', array($this, 'save_screen_options'));
20
  add_action('plugins_loaded', function () {
21
  \Perfect_Woocommerce_Brands\Admin\Edit_Brands_Page::$current_user = wp_get_current_user();
22
  });
@@ -56,7 +56,7 @@ class Edit_Brands_Page
56
  $featured_brands = array();
57
  $other_brands = array();
58
  foreach ($brands as $brand) {
59
- if (get_term_meta($brand->term_id, 'pwb_featured_brand', true)) {
60
  $featured_brands[] = $brand;
61
  } else {
62
  $other_brands[] = $brand;
@@ -109,20 +109,29 @@ class Edit_Brands_Page
109
  return (get_term_meta($brand_id, 'pwb_featured_brand', true));
110
  }
111
 
112
- public function set_featured_brand()
113
  {
114
- if (isset($_POST['brand'])) {
115
- $direction = 'up';
116
- $brand = intval($_POST['brand']);
117
- if ($this->is_featured_brand($brand)) {
118
- delete_term_meta($brand, 'pwb_featured_brand', true);
119
- $direction = 'down';
 
 
 
 
 
 
 
 
 
 
 
 
120
  } else {
121
- update_term_meta($brand, 'pwb_featured_brand', true);
122
  }
123
- wp_send_json_success(array('success' => true, 'direction' => $direction));
124
- } else {
125
- wp_send_json_error(array('success' => false, 'error_msg' => __('Error!', 'perfect-woocommerce-brands')));
126
  }
127
  wp_die();
128
  }
@@ -143,11 +152,20 @@ class Edit_Brands_Page
143
  }
144
  }
145
 
146
- public function save_screen_options()
147
  {
148
- if (isset($_POST['new_val'])) {
149
- $new_val = ($_POST['new_val'] == 'true') ? true : false;
150
- update_user_option(self::$current_user->ID, 'pwb-first-featured-brands', $new_val);
 
 
 
 
 
 
 
 
 
151
  }
152
  wp_die();
153
  }
14
  add_filter('get_terms', array($this, 'brand_list_admin_filter'), 10, 3);
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('wp_ajax_pwb_admin_set_featured_brand', array($this, 'admin_set_featured_brand'));
18
  add_filter('screen_settings', array($this, 'add_screen_options'), 10, 2);
19
+ add_action('wp_ajax_pwb_admin_save_screen_settings', array($this, 'admin_save_screen_settings'));
20
  add_action('plugins_loaded', function () {
21
  \Perfect_Woocommerce_Brands\Admin\Edit_Brands_Page::$current_user = wp_get_current_user();
22
  });
56
  $featured_brands = array();
57
  $other_brands = array();
58
  foreach ($brands as $brand) {
59
+ if (isset($brand->term_id) && get_term_meta($brand->term_id, 'pwb_featured_brand', true)) {
60
  $featured_brands[] = $brand;
61
  } else {
62
  $other_brands[] = $brand;
109
  return (get_term_meta($brand_id, 'pwb_featured_brand', true));
110
  }
111
 
112
+ public function admin_set_featured_brand()
113
  {
114
+ if (
115
+ isset($_REQUEST['nonce'])
116
+ &&
117
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_admin_set_featured_brand')
118
+ &&
119
+ current_user_can('manage_options')
120
+ ) {
121
+
122
+ if (isset($_POST['brand'])) {
123
+ $direction = 'up';
124
+ $brand = intval($_POST['brand']);
125
+ if ($this->is_featured_brand($brand)) {
126
+ delete_term_meta($brand, 'pwb_featured_brand', true);
127
+ $direction = 'down';
128
+ } else {
129
+ update_term_meta($brand, 'pwb_featured_brand', true);
130
+ }
131
+ wp_send_json_success(array('success' => true, 'direction' => $direction));
132
  } else {
133
+ wp_send_json_error(array('success' => false, 'error_msg' => __('Error!', 'perfect-woocommerce-brands')));
134
  }
 
 
 
135
  }
136
  wp_die();
137
  }
152
  }
153
  }
154
 
155
+ public function admin_save_screen_settings()
156
  {
157
+ if (
158
+ isset($_REQUEST['nonce'])
159
+ &&
160
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_admin_save_screen_settings')
161
+ &&
162
+ current_user_can('manage_options')
163
+ ) {
164
+
165
+ if (isset($_POST['new_val'])) {
166
+ $new_val = ($_POST['new_val'] == 'true') ? true : false;
167
+ update_user_option(self::$current_user->ID, 'pwb-first-featured-brands', $new_val);
168
+ }
169
  }
170
  wp_die();
171
  }
classes/admin/class-pwb-dummy-data.php CHANGED
@@ -1,94 +1,108 @@
1
  <?php
2
- namespace Perfect_Woocommerce_Brands\Admin;
3
 
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
 
6
- class PWB_Dummy_Data {
7
 
8
- function __construct(){
9
- add_action( 'wp_ajax_pwb_admin_dummy_data', array( $this, 'dummy_data' ) );
10
- }
11
-
12
- private static function get_attachment_id_from_src($image_src){
13
- global $wpdb;
14
- $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
15
- $id = $wpdb->get_var($query);
16
- return $id;
17
- }
18
-
19
- private static function retrieve_img_src( $img ) {
20
- if (preg_match('/<img(\s+?)([^>]*?)src=(\"|\')([^>\\3]*?)\\3([^>]*?)>/is', $img, $m) && isset($m[4]))
21
- return $m[4];
22
- return false;
23
- }
24
 
25
- private static function upload_image( $post_id, $img_url ){
 
 
 
26
 
27
- require_once ABSPATH . "wp-admin" . '/includes/image.php';
28
- require_once ABSPATH . "wp-admin" . '/includes/file.php';
29
- require_once ABSPATH . "wp-admin" . '/includes/media.php';
 
 
 
 
30
 
31
- //solves media_sideload_image bug with spaces in filenames
32
- $parsed_file = parse_url($img_url);
33
- $path = $parsed_file['path'];
34
- $file_name = basename($path);
35
- $encoded_file_name = rawurlencode($file_name);
36
- $path = str_replace($file_name, $encoded_file_name, $path);
37
- $img_url = $parsed_file['scheme'] . "://" . $parsed_file['host'] . $path;
38
- $image = '';
39
 
40
- preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $img_url, $file_matches);
41
- if(isset($file_matches[0])){
42
- $image = media_sideload_image($img_url, $post_id );
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- //media_sideload_image returns a html image
46
- //extract the src value for get the attachment id
47
- $image_src = self::retrieve_img_src( $image );
48
- return self::get_attachment_id_from_src( $image_src );
 
49
 
50
- }
 
 
 
 
 
 
 
 
 
51
 
52
- private function build_description(){
53
- $desc = 'lorem ipsum dolor <strong>sit</strong> amet consectetur adipiscing elit etiam mollis faucibus aliquet';
54
- $desc.= 'sed risus turpis dapibus vel <strong>rhoncus</strong> a vestibulum sed lectus in hac habitasse platea dictumst';
55
- $desc.= 'suspendisse non luctus felis <strong>morbi</strong> id volutpat ligula quisque rutrum arcu at erat lobortis';
56
- $exploded_desc = explode( ' ', $desc );
57
- shuffle( $exploded_desc );
58
- $desc = implode( ' ', $exploded_desc );
59
- return ucfirst( $desc );
60
- }
61
 
62
- public function dummy_data(){
 
 
 
 
 
 
63
 
64
- for( $i=1; $i<11; $i++ ) {
65
  $term_desc = $this->build_description();
66
- $brand_name = 'brand'.$i;
67
- $attachment_id = self::upload_image( false, PWB_PLUGIN_URL . '/assets/img/dummy-data/'.$brand_name.'.png' );
68
- $inserted_brand = wp_insert_term( ucfirst( $brand_name ), 'pwb-brand', array( "description" => $term_desc ) );
69
- if( !is_wp_error( $inserted_brand ) && isset( $inserted_brand['term_id'] ) ){
70
- add_term_meta( $inserted_brand['term_id'], 'pwb_brand_image', $attachment_id );
71
  }
72
  }
73
 
74
  $this->set_brands_randomly();
75
-
76
- wp_die();
77
-
78
  }
79
 
80
- public function set_brands_randomly(){
 
81
 
82
- $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands_array();
 
83
 
84
- $the_query = new \WP_Query( array( 'posts_per_page' => -1 , 'post_type' => 'product' ) );
85
 
86
- while ( $the_query->have_posts() ) {
87
- $the_query->the_post();
88
- wp_set_object_terms( get_the_ID(), array_rand( $brands ), 'pwb-brand' );
89
- }
90
- wp_reset_postdata();
91
 
 
 
 
92
  }
93
-
94
  }
 
1
  <?php
 
2
 
3
+ namespace Perfect_Woocommerce_Brands\Admin;
4
 
5
+ defined('ABSPATH') or die('No script kiddies please!');
6
 
7
+ class PWB_Dummy_Data
8
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ function __construct()
11
+ {
12
+ add_action('wp_ajax_pwb_admin_dummy_data', array($this, 'admin_dummy_data'));
13
+ }
14
 
15
+ private static function get_attachment_id_from_src($image_src)
16
+ {
17
+ global $wpdb;
18
+ $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
19
+ $id = $wpdb->get_var($query);
20
+ return $id;
21
+ }
22
 
23
+ private static function retrieve_img_src($img)
24
+ {
25
+ if (preg_match('/<img(\s+?)([^>]*?)src=(\"|\')([^>\\3]*?)\\3([^>]*?)>/is', $img, $m) && isset($m[4]))
26
+ return $m[4];
27
+ return false;
28
+ }
 
 
29
 
30
+ private static function upload_image($post_id, $img_url)
31
+ {
32
+
33
+ require_once ABSPATH . "wp-admin" . '/includes/image.php';
34
+ require_once ABSPATH . "wp-admin" . '/includes/file.php';
35
+ require_once ABSPATH . "wp-admin" . '/includes/media.php';
36
+
37
+ //solves media_sideload_image bug with spaces in filenames
38
+ $parsed_file = parse_url($img_url);
39
+ $path = $parsed_file['path'];
40
+ $file_name = basename($path);
41
+ $encoded_file_name = rawurlencode($file_name);
42
+ $path = str_replace($file_name, $encoded_file_name, $path);
43
+ $img_url = $parsed_file['scheme'] . "://" . $parsed_file['host'] . $path;
44
+ $image = '';
45
+
46
+ preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $img_url, $file_matches);
47
+ if (isset($file_matches[0])) {
48
+ $image = media_sideload_image($img_url, $post_id);
49
+ }
50
 
51
+ //media_sideload_image returns a html image
52
+ //extract the src value for get the attachment id
53
+ $image_src = self::retrieve_img_src($image);
54
+ return self::get_attachment_id_from_src($image_src);
55
+ }
56
 
57
+ private function build_description()
58
+ {
59
+ $desc = 'lorem ipsum dolor <strong>sit</strong> amet consectetur adipiscing elit etiam mollis faucibus aliquet';
60
+ $desc .= 'sed risus turpis dapibus vel <strong>rhoncus</strong> a vestibulum sed lectus in hac habitasse platea dictumst';
61
+ $desc .= 'suspendisse non luctus felis <strong>morbi</strong> id volutpat ligula quisque rutrum arcu at erat lobortis';
62
+ $exploded_desc = explode(' ', $desc);
63
+ shuffle($exploded_desc);
64
+ $desc = implode(' ', $exploded_desc);
65
+ return ucfirst($desc);
66
+ }
67
 
68
+ public function admin_dummy_data()
69
+ {
 
 
 
 
 
 
 
70
 
71
+ if (
72
+ isset($_REQUEST['nonce'])
73
+ &&
74
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_admin_dummy_data')
75
+ &&
76
+ current_user_can('manage_options')
77
+ ) {
78
 
79
+ for ($i = 1; $i < 11; $i++) {
80
  $term_desc = $this->build_description();
81
+ $brand_name = 'brand' . $i;
82
+ $attachment_id = self::upload_image(false, PWB_PLUGIN_URL . '/assets/img/dummy-data/' . $brand_name . '.png');
83
+ $inserted_brand = wp_insert_term(ucfirst($brand_name), 'pwb-brand', array("description" => $term_desc));
84
+ if (!is_wp_error($inserted_brand) && isset($inserted_brand['term_id'])) {
85
+ add_term_meta($inserted_brand['term_id'], 'pwb_brand_image', $attachment_id);
86
  }
87
  }
88
 
89
  $this->set_brands_randomly();
 
 
 
90
  }
91
 
92
+ wp_die();
93
+ }
94
 
95
+ public function set_brands_randomly()
96
+ {
97
 
98
+ $brands = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands_array();
99
 
100
+ $the_query = new \WP_Query(array('posts_per_page' => -1, 'post_type' => 'product'));
 
 
 
 
101
 
102
+ while ($the_query->have_posts()) {
103
+ $the_query->the_post();
104
+ wp_set_object_terms(get_the_ID(), array_rand($brands), 'pwb-brand');
105
  }
106
+ wp_reset_postdata();
107
  }
108
+ }
classes/admin/class-pwb-migrate.php CHANGED
@@ -9,24 +9,33 @@ class PWB_Migrate
9
 
10
  function __construct()
11
  {
12
- add_action('wp_ajax_pwb_admin_migrate_brands', array($this, 'migrate_from'));
13
  }
14
 
15
- public function migrate_from()
16
  {
17
 
18
- if (isset($_POST['from'])) {
19
-
20
- switch ($_POST['from']) {
21
- case 'yith':
22
- $this->migrate_from_yith();
23
- break;
24
- case 'ultimate':
25
- $this->migrate_from_ultimate();
26
- break;
27
- case 'woobrands':
28
- $this->migrate_from_woobrands();
29
- break;
 
 
 
 
 
 
 
 
 
30
  }
31
  }
32
 
9
 
10
  function __construct()
11
  {
12
+ add_action('wp_ajax_pwb_admin_migrate_brands', array($this, 'admin_migrate_brands'));
13
  }
14
 
15
+ public function admin_migrate_brands()
16
  {
17
 
18
+ if (
19
+ isset($_REQUEST['nonce'])
20
+ &&
21
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_admin_migrate_brands')
22
+ &&
23
+ current_user_can('manage_options')
24
+ ) {
25
+
26
+ if (isset($_POST['from'])) {
27
+
28
+ switch ($_POST['from']) {
29
+ case 'yith':
30
+ $this->migrate_from_yith();
31
+ break;
32
+ case 'ultimate':
33
+ $this->migrate_from_ultimate();
34
+ break;
35
+ case 'woobrands':
36
+ $this->migrate_from_woobrands();
37
+ break;
38
+ }
39
  }
40
  }
41
 
classes/admin/class-pwb-system-status.php CHANGED
@@ -1,61 +1,76 @@
1
  <?php
2
- namespace Perfect_Woocommerce_Brands\Admin;
3
 
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
 
6
- class PWB_System_Status{
7
 
8
- function __construct(){
9
- add_action( 'wp_ajax_pwb_system_status', array( $this, 'pwb_system_status' ) );
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- public function pwb_system_status(){
13
  print_r(array(
14
- 'home_url' => get_option( 'home' ),
15
- 'site_url' => get_option( 'siteurl' ),
16
  'version' => WC()->version,
17
- 'wp_version' => get_bloginfo( 'version' ),
18
  'wp_multisite' => is_multisite(),
19
  'wp_memory_limit' => WP_MEMORY_LIMIT,
20
- 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
21
- 'wp_cron' => !( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
22
  'language' => get_locale(),
23
  'server_info' => $_SERVER['SERVER_SOFTWARE'],
24
  'php_version' => phpversion(),
25
- 'php_post_max_size' => ini_get( 'post_max_size' ),
26
- 'php_max_execution_time' => ini_get( 'max_execution_time' ),
27
- 'php_max_input_vars' => ini_get( 'max_input_vars' ),
28
  'max_upload_size' => wp_max_upload_size(),
29
  'default_timezone' => date_default_timezone_get(),
30
  'theme' => $this->theme_info(),
31
- 'active_plugins' => get_option( 'active_plugins' ),
32
  'pwb_options' => $this->pwb_options()
33
  ));
34
- wp_die();
35
  }
36
 
37
- private function theme_info(){
38
- $current_theme = wp_get_theme();
39
- return array(
40
- 'name' => $current_theme->__get('name'),
41
- 'version' => $current_theme->__get('version'),
42
- 'parent_theme' => $current_theme->__get('parent_theme')
43
- );
44
- }
45
 
46
- private function pwb_options(){
47
- return array(
48
- 'version' => PWB_PLUGIN_VERSION,
49
- 'wc_pwb_admin_tab_brand_single_position' => get_option( 'wc_pwb_admin_tab_brand_single_position' ),
50
- 'old_wc_pwb_admin_tab_slug' => get_option( 'old_wc_pwb_admin_tab_slug' ),
51
- 'wc_pwb_notice_plugin_review' => get_option( 'wc_pwb_notice_plugin_review' ),
52
- 'wc_pwb_admin_tab_slug' => get_option( 'wc_pwb_admin_tab_slug' ),
53
- 'wc_pwb_admin_tab_brand_desc' => get_option( 'wc_pwb_admin_tab_brand_desc' ),
54
- 'wc_pwb_admin_tab_brand_single_product_tab' => get_option( 'wc_pwb_admin_tab_brand_single_product_tab' ),
55
- 'wc_pwb_admin_tab_brands_in_loop' => get_option( 'wc_pwb_admin_tab_brands_in_loop' ),
56
- 'wc_pwb_admin_tab_brands_in_single' => get_option( 'wc_pwb_admin_tab_brands_in_single' ),
57
- 'wc_pwb_admin_tab_brand_logo_size' => get_option( 'wc_pwb_admin_tab_brand_logo_size' )
58
- );
59
- }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
 
1
  <?php
 
2
 
3
+ namespace Perfect_Woocommerce_Brands\Admin;
4
 
5
+ defined('ABSPATH') or die('No script kiddies please!');
6
 
7
+ class PWB_System_Status
8
+ {
9
+
10
+ function __construct()
11
+ {
12
+ add_action('wp_ajax_pwb_system_status', array($this, 'system_status'));
13
+ }
14
+
15
+ public function system_status()
16
+ {
17
+ if (
18
+ isset($_REQUEST['nonce'])
19
+ &&
20
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_system_status')
21
+ &&
22
+ current_user_can('manage_options')
23
+ ) {
24
 
 
25
  print_r(array(
26
+ 'home_url' => get_option('home'),
27
+ 'site_url' => get_option('siteurl'),
28
  'version' => WC()->version,
29
+ 'wp_version' => get_bloginfo('version'),
30
  'wp_multisite' => is_multisite(),
31
  'wp_memory_limit' => WP_MEMORY_LIMIT,
32
+ 'wp_debug_mode' => (defined('WP_DEBUG') && WP_DEBUG),
33
+ 'wp_cron' => !(defined('DISABLE_WP_CRON') && DISABLE_WP_CRON),
34
  'language' => get_locale(),
35
  'server_info' => $_SERVER['SERVER_SOFTWARE'],
36
  'php_version' => phpversion(),
37
+ 'php_post_max_size' => ini_get('post_max_size'),
38
+ 'php_max_execution_time' => ini_get('max_execution_time'),
39
+ 'php_max_input_vars' => ini_get('max_input_vars'),
40
  'max_upload_size' => wp_max_upload_size(),
41
  'default_timezone' => date_default_timezone_get(),
42
  'theme' => $this->theme_info(),
43
+ 'active_plugins' => get_option('active_plugins'),
44
  'pwb_options' => $this->pwb_options()
45
  ));
 
46
  }
47
 
48
+ wp_die();
49
+ }
 
 
 
 
 
 
50
 
51
+ private function theme_info()
52
+ {
53
+ $current_theme = wp_get_theme();
54
+ return array(
55
+ 'name' => $current_theme->__get('name'),
56
+ 'version' => $current_theme->__get('version'),
57
+ 'parent_theme' => $current_theme->__get('parent_theme')
58
+ );
59
+ }
 
 
 
 
 
60
 
61
+ private function pwb_options()
62
+ {
63
+ return array(
64
+ 'version' => PWB_PLUGIN_VERSION,
65
+ 'wc_pwb_admin_tab_brand_single_position' => get_option('wc_pwb_admin_tab_brand_single_position'),
66
+ 'old_wc_pwb_admin_tab_slug' => get_option('old_wc_pwb_admin_tab_slug'),
67
+ 'wc_pwb_notice_plugin_review' => get_option('wc_pwb_notice_plugin_review'),
68
+ 'wc_pwb_admin_tab_slug' => get_option('wc_pwb_admin_tab_slug'),
69
+ 'wc_pwb_admin_tab_brand_desc' => get_option('wc_pwb_admin_tab_brand_desc'),
70
+ 'wc_pwb_admin_tab_brand_single_product_tab' => get_option('wc_pwb_admin_tab_brand_single_product_tab'),
71
+ 'wc_pwb_admin_tab_brands_in_loop' => get_option('wc_pwb_admin_tab_brands_in_loop'),
72
+ 'wc_pwb_admin_tab_brands_in_single' => get_option('wc_pwb_admin_tab_brands_in_single'),
73
+ 'wc_pwb_admin_tab_brand_logo_size' => get_option('wc_pwb_admin_tab_brand_logo_size')
74
+ );
75
  }
76
+ }
classes/class-perfect-woocommerce-brands.php CHANGED
@@ -24,7 +24,7 @@ class Perfect_Woocommerce_Brands
24
  add_action('widgets_init', array($this, 'register_widgets'));
25
  add_filter('woocommerce_structured_data_product', array($this, 'product_microdata'), 10, 2);
26
  add_action('pre_get_posts', array($this, 'pwb_brand_filter'));
27
- add_action('wp_ajax_dismiss_pwb_notice', array($this, 'dismiss_pwb_notice'));
28
  add_action('admin_notices', array($this, 'review_notice'));
29
 
30
  add_action('wp', function () {
@@ -187,18 +187,28 @@ class Perfect_Woocommerce_Brands
187
  }
188
  }
189
 
190
- public function dismiss_pwb_notice()
191
  {
192
- $notice_name_whitelist = array('wc_pwb_notice_plugin_review');
193
 
194
- if (isset($_POST['notice_name']) && in_array($_POST['notice_name'], $notice_name_whitelist)) {
 
 
 
 
 
 
195
 
196
- $notice_key = sanitize_key($_POST['notice_name']);
197
 
198
- update_option($notice_key, 0);
199
- echo 'ok';
200
- } else {
201
- echo 'error';
 
 
 
 
 
202
  }
203
  wp_die();
204
  }
@@ -208,7 +218,7 @@ class Perfect_Woocommerce_Brands
208
 
209
  if (!empty($_GET['pwb-brand-filter'])) {
210
 
211
- $terms_array = explode(',', $_GET['pwb-brand-filter']);
212
 
213
  //remove invalid terms (security)
214
  for ($i = 0; $i < count($terms_array); $i++) {
@@ -752,8 +762,14 @@ class Perfect_Woocommerce_Brands
752
  'dummy_data' => esc_html__('We are importing the dummy data. ¡Don´t close this window until the process is finished!', 'perfect-woocommerce-brands')
753
  ),
754
  'nonce' => [
755
- 'import' => wp_create_nonce('pwb_brands_import'),
756
- 'export' => wp_create_nonce('pwb_brands_export'),
 
 
 
 
 
 
757
  ]
758
  ));
759
  wp_enqueue_script('pwb-functions-admin');
24
  add_action('widgets_init', array($this, 'register_widgets'));
25
  add_filter('woocommerce_structured_data_product', array($this, 'product_microdata'), 10, 2);
26
  add_action('pre_get_posts', array($this, 'pwb_brand_filter'));
27
+ add_action('wp_ajax_pwb_dismiss_notice', array($this, 'dismiss_notice'));
28
  add_action('admin_notices', array($this, 'review_notice'));
29
 
30
  add_action('wp', function () {
187
  }
188
  }
189
 
190
+ public function dismiss_notice()
191
  {
 
192
 
193
+ if (
194
+ isset($_REQUEST['nonce'])
195
+ &&
196
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_dismiss_notice')
197
+ &&
198
+ current_user_can('manage_options')
199
+ ) {
200
 
201
+ $notice_name_whitelist = array('wc_pwb_notice_plugin_review');
202
 
203
+ if (isset($_POST['notice_name']) && in_array($_POST['notice_name'], $notice_name_whitelist)) {
204
+
205
+ $notice_key = sanitize_key($_POST['notice_name']);
206
+
207
+ update_option($notice_key, 0);
208
+ echo 'ok';
209
+ } else {
210
+ echo 'error';
211
+ }
212
  }
213
  wp_die();
214
  }
218
 
219
  if (!empty($_GET['pwb-brand-filter'])) {
220
 
221
+ $terms_array = explode(',', sanitize_text_field($_GET['pwb-brand-filter']));
222
 
223
  //remove invalid terms (security)
224
  for ($i = 0; $i < count($terms_array); $i++) {
762
  'dummy_data' => esc_html__('We are importing the dummy data. ¡Don´t close this window until the process is finished!', 'perfect-woocommerce-brands')
763
  ),
764
  'nonce' => [
765
+ 'pwb_brands_export' => wp_create_nonce('pwb_brands_export'), //ok
766
+ 'pwb_brands_import' => wp_create_nonce('pwb_brands_import'), //ok
767
+ 'pwb_dismiss_notice' => wp_create_nonce('pwb_dismiss_notice'), //ok
768
+ 'pwb_admin_set_featured_brand' => wp_create_nonce('pwb_admin_set_featured_brand'), //ok
769
+ 'pwb_admin_save_screen_settings' => wp_create_nonce('pwb_admin_save_screen_settings'), //ok
770
+ 'pwb_admin_dummy_data' => wp_create_nonce('pwb_admin_dummy_data'), //ok
771
+ 'pwb_admin_migrate_brands' => wp_create_nonce('pwb_admin_migrate_brands'),
772
+ 'pwb_system_status' => wp_create_nonce('pwb_system_status')
773
  ]
774
  ));
775
  wp_enqueue_script('pwb-functions-admin');
classes/shortcodes/class-pwb-all-brands.php CHANGED
@@ -160,14 +160,14 @@ class PWB_All_Brands_Shortcode
160
  echo '<a href="' . get_the_permalink() . '" class="pwb-pagination prev" title="' . esc_html__('First page', 'perfect-woocommerce-brands') . '">&laquo;</a>';
161
  }
162
  if ($prev > 0) {
163
- echo '<a href="' . get_the_permalink() . '?pwb-page=' . $prev . '" class="pwb-pagination last" title="' . esc_html__('Previous page', 'perfect-woocommerce-brands') . '">&lsaquo;</a>';
164
  }
165
 
166
  if ($next <= $pages) {
167
- echo '<a href="' . get_the_permalink() . '?pwb-page=' . $next . '" class="pwb-pagination first" title="' . esc_html__('Next page', 'perfect-woocommerce-brands') . '">&rsaquo;</a>';
168
  }
169
  if ($next < $pages) {
170
- echo '<a href="' . get_the_permalink() . '?pwb-page=' . $pages . '" class="pwb-pagination next" title="' . esc_html__('Last page', 'perfect-woocommerce-brands') . '">&raquo;</a>';
171
  }
172
  echo '</div>';
173
  } else {
160
  echo '<a href="' . get_the_permalink() . '" class="pwb-pagination prev" title="' . esc_html__('First page', 'perfect-woocommerce-brands') . '">&laquo;</a>';
161
  }
162
  if ($prev > 0) {
163
+ echo '<a href="' . get_the_permalink() . '?pwb-page=' . esc_attr($prev) . '" class="pwb-pagination last" title="' . esc_html__('Previous page', 'perfect-woocommerce-brands') . '">&lsaquo;</a>';
164
  }
165
 
166
  if ($next <= $pages) {
167
+ echo '<a href="' . get_the_permalink() . '?pwb-page=' . esc_attr($next) . '" class="pwb-pagination first" title="' . esc_html__('Next page', 'perfect-woocommerce-brands') . '">&rsaquo;</a>';
168
  }
169
  if ($next < $pages) {
170
+ echo '<a href="' . get_the_permalink() . '?pwb-page=' . esc_attr($pages) . '" class="pwb-pagination next" title="' . esc_html__('Last page', 'perfect-woocommerce-brands') . '">&raquo;</a>';
171
  }
172
  echo '</div>';
173
  } else {
perfect-woocommerce-brands.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Perfect Brands for WooCommerce
5
  * Plugin URI: https://quadlayers.com/portfolio/perfect-woocommerce-brands/
6
  * Description: Perfect WooCommerce Brands allows you to show product brands in your WooCommerce based store.
7
- * Version: 2.0.4
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * Text Domain: perfect-woocommerce-brands
@@ -24,7 +24,7 @@
24
  * along with Perfect WooCommerce Brands. If not, see <http://www.gnu.org/licenses/>.
25
  *
26
  * WC requires at least: 3.1.0
27
- * WC tested up to: 6.0
28
  */
29
 
30
  namespace Perfect_Woocommerce_Brands;
@@ -36,7 +36,7 @@ define('PWB_PLUGIN_FILE', __FILE__);
36
  define('PWB_PLUGIN_URL', plugins_url('', __FILE__));
37
  define('PWB_PLUGIN_DIR', __DIR__ . DIRECTORY_SEPARATOR);
38
  define('PWB_PLUGIN_BASENAME', plugin_basename(__FILE__));
39
- define('PWB_PLUGIN_VERSION', '2.0.4');
40
  define('PWB_PLUGIN_NAME', 'Perfect WooCommerce Brands');
41
  define('PWB_PREFIX', 'pwb');
42
  define('PWB_REVIEW_URL', 'https://wordpress.org/support/plugin/perfect-woocommerce-brands/reviews/?filter=5#new-post');
4
  * Plugin Name: Perfect Brands for WooCommerce
5
  * Plugin URI: https://quadlayers.com/portfolio/perfect-woocommerce-brands/
6
  * Description: Perfect WooCommerce Brands allows you to show product brands in your WooCommerce based store.
7
+ * Version: 2.0.5
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * Text Domain: perfect-woocommerce-brands
24
  * along with Perfect WooCommerce Brands. If not, see <http://www.gnu.org/licenses/>.
25
  *
26
  * WC requires at least: 3.1.0
27
+ * WC tested up to: 6.1
28
  */
29
 
30
  namespace Perfect_Woocommerce_Brands;
36
  define('PWB_PLUGIN_URL', plugins_url('', __FILE__));
37
  define('PWB_PLUGIN_DIR', __DIR__ . DIRECTORY_SEPARATOR);
38
  define('PWB_PLUGIN_BASENAME', plugin_basename(__FILE__));
39
+ define('PWB_PLUGIN_VERSION', '2.0.5');
40
  define('PWB_PLUGIN_NAME', 'Perfect WooCommerce Brands');
41
  define('PWB_PREFIX', 'pwb');
42
  define('PWB_REVIEW_URL', 'https://wordpress.org/support/plugin/perfect-woocommerce-brands/reviews/?filter=5#new-post');
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: quadlayers, titodevera
3
  Donate link: https://quadlayers.com
4
  Tags: woocommerce, woocommerce brands, woocommerce product, woocommerce manufacturer, woocommerce supplier, e-commerce
5
  Requires at least: 4.7
6
- Tested up to: 5.8
7
  Requires PHP: 5.6
8
- Stable tag: 2.0.4
9
  WC requires at least: 3.0
10
  WC tested up to: 6.1
11
  License: GPLv3
@@ -90,6 +90,9 @@ You can also contribute [translating the plugin](https://translate.wordpress.org
90
 
91
 
92
  == Changelog ==
 
 
 
93
  = 2.0.4 =
94
  * Fix: Security fix
95
  = 2.0.3 =
3
  Donate link: https://quadlayers.com
4
  Tags: woocommerce, woocommerce brands, woocommerce product, woocommerce manufacturer, woocommerce supplier, e-commerce
5
  Requires at least: 4.7
6
+ Tested up to: 5.9
7
  Requires PHP: 5.6
8
+ Stable tag: 2.0.5
9
  WC requires at least: 3.0
10
  WC tested up to: 6.1
11
  License: GPLv3
90
 
91
 
92
  == Changelog ==
93
+ = 2.0.5 =
94
+ * Fix: Security fix
95
+ * Fix: WooCommerce compatibility
96
  = 2.0.4 =
97
  * Fix: Security fix
98
  = 2.0.3 =