Perfect Brands for WooCommerce - Version 2.0.4

Version Description

  • Fix: Security fix
Download this release

Release Info

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

Code changes from version 2.0.3 to 2.0.4

classes/admin/class-brands-custom-fields.php CHANGED
@@ -136,7 +136,7 @@ class Brands_Custom_Fields
136
 
137
  /* ·············· Brand image ·············· */
138
  $old_img = get_term_meta($term_id, 'pwb_brand_image', true);
139
- $new_img = isset($_POST['pwb_brand_image']) ? $_POST['pwb_brand_image'] : '';
140
 
141
  if ($old_img && '' === $new_img)
142
  delete_term_meta($term_id, 'pwb_brand_image');
@@ -147,7 +147,7 @@ class Brands_Custom_Fields
147
 
148
  /* ·············· Brand banner ·············· */
149
  $old_img = get_term_meta($term_id, 'pwb_brand_banner', true);
150
- $new_img = isset($_POST['pwb_brand_banner']) ? $_POST['pwb_brand_banner'] : '';
151
 
152
  if ($old_img && '' === $new_img)
153
  delete_term_meta($term_id, 'pwb_brand_banner');
@@ -158,7 +158,7 @@ class Brands_Custom_Fields
158
 
159
  /* ·············· Brand banner link ·············· */
160
  $old_img = get_term_meta($term_id, 'pwb_brand_banner_link', true);
161
- $new_img = isset($_POST['pwb_brand_banner_link']) ? $_POST['pwb_brand_banner_link'] : '';
162
 
163
  if ($old_img && '' === $new_img)
164
  delete_term_meta($term_id, 'pwb_brand_banner_link');
136
 
137
  /* ·············· Brand image ·············· */
138
  $old_img = get_term_meta($term_id, 'pwb_brand_image', true);
139
+ $new_img = isset($_POST['pwb_brand_image']) ? sanitize_text_field($_POST['pwb_brand_image']) : '';
140
 
141
  if ($old_img && '' === $new_img)
142
  delete_term_meta($term_id, 'pwb_brand_image');
147
 
148
  /* ·············· Brand banner ·············· */
149
  $old_img = get_term_meta($term_id, 'pwb_brand_banner', true);
150
+ $new_img = isset($_POST['pwb_brand_banner']) ? sanitize_text_field($_POST['pwb_brand_banner']) : '';
151
 
152
  if ($old_img && '' === $new_img)
153
  delete_term_meta($term_id, 'pwb_brand_banner');
158
 
159
  /* ·············· Brand banner link ·············· */
160
  $old_img = get_term_meta($term_id, 'pwb_brand_banner_link', true);
161
+ $new_img = isset($_POST['pwb_brand_banner_link']) ? esc_url_raw($_POST['pwb_brand_banner_link']) : '';
162
 
163
  if ($old_img && '' === $new_img)
164
  delete_term_meta($term_id, 'pwb_brand_banner_link');
classes/admin/class-brands-exporter.php CHANGED
@@ -25,7 +25,13 @@ class Brands_Exporter
25
 
26
  public function export_brands()
27
  {
28
- if (isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'pwb_brands_export')) {
 
 
 
 
 
 
29
  $this->get_brands();
30
  } else {
31
  wp_send_json_error();
@@ -71,7 +77,15 @@ class Brands_Exporter
71
  public function import_brands()
72
  {
73
 
74
- if (isset($_FILES['file']) && isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'pwb_brands_import')) {
 
 
 
 
 
 
 
 
75
 
76
  $file = $_FILES['file'];
77
 
25
 
26
  public function export_brands()
27
  {
28
+ if (
29
+ isset($_REQUEST['nonce'])
30
+ &&
31
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_brands_export')
32
+ &&
33
+ current_user_can('manage_options')
34
+ ) {
35
  $this->get_brands();
36
  } else {
37
  wp_send_json_error();
77
  public function import_brands()
78
  {
79
 
80
+ if (
81
+ isset($_FILES['file'])
82
+ &&
83
+ isset($_REQUEST['nonce'])
84
+ &&
85
+ wp_verify_nonce($_REQUEST['nonce'], 'pwb_brands_import')
86
+ &&
87
+ current_user_can('manage_options')
88
+ ) {
89
 
90
  $file = $_FILES['file'];
91
 
classes/admin/class-pwb-admin-tab.php CHANGED
@@ -53,19 +53,17 @@ class Pwb_Admin_Tab
53
  return;
54
  }
55
 
56
- echo '<ul class="subsubsub">';
57
-
58
- $array_keys = array_keys($sections);
59
-
60
- foreach ($sections as $id => $label) {
61
- echo '<li><a href="' . admin_url('admin.php?page=wc-settings&tab=' . $this->id . '&section=' . sanitize_title($id)) . '" class="' . ($current_section == $id ? 'current' : '') . '">' . $label . '</a> ' . (end($array_keys) == $id ? '' : '|') . ' </li>';
62
- }
63
-
64
- echo ' | <li><a target="_blank" href="' . admin_url('edit-tags.php?taxonomy=pwb-brand&post_type=product') . '">' . __('Brands', 'perfect-woocommerce-brands') . '</a></li>';
65
- echo ' | <li><a target="_blank" href="' . admin_url('admin.php?page=pwb_suggestions') . '">' . __('Suggestions', 'perfect-woocommerce-brands') . '</a></li>';
66
- echo ' | <li><a target="_blank" href="' . PWB_DOCUMENTATION_URL . '">' . __('Documentation', 'perfect-woocommerce-brands') . '</a></li>';
67
-
68
- echo '</ul><br class="clear" />';
69
  }
70
 
71
  public function get_settings($current_section = '')
53
  return;
54
  }
55
 
56
+ ?>
57
+ <ul class="subsubsub">
58
+ <?php foreach ($sections as $id => $label) : ?>
59
+ <li><a href="<?php echo admin_url('admin.php?page=wc-settings&tab=' . $this->id . '&section=' . $id); ?>" class="<?php echo ($current_section == $id ? 'current' : ''); ?>"><?php esc_html_e($label); ?></a></li> |
60
+ <?php endforeach; ?>
61
+ <li><a target="_blank" href="<?php echo admin_url('edit-tags.php?taxonomy=pwb-brand&post_type=product'); ?>"><?php esc_html_e('Brands', 'perfect-woocommerce-brands'); ?></a></li> |
62
+ <li><a target="_blank" href="<?php echo admin_url('admin.php?page=pwb_suggestions'); ?>"><?php esc_attr_e('Suggestions', 'perfect-woocommerce-brands'); ?></a></li> |
63
+ <li><a target="_blank" href="<?php echo esc_url(PWB_DOCUMENTATION_URL); ?>"><?php esc_html_e('Documentation', 'perfect-woocommerce-brands'); ?></a></li>
64
+ </ul>
65
+ <br class="clear" />
66
+ <?php
 
 
67
  }
68
 
69
  public function get_settings($current_section = '')
classes/admin/class-pwb-coupon.php CHANGED
@@ -38,7 +38,7 @@
38
  }
39
 
40
  public function coupon_save( $post_id ){
41
- $_pwb_coupon_restriction = isset( $_POST['_pwb_coupon_restriction'] ) ? $_POST['_pwb_coupon_restriction'] : '';
42
  update_post_meta( $post_id, '_pwb_coupon_restriction', $_pwb_coupon_restriction );
43
  }
44
 
38
  }
39
 
40
  public function coupon_save( $post_id ){
41
+ $_pwb_coupon_restriction = isset( $_POST['_pwb_coupon_restriction'] ) ? sanitize_text_field($_POST['_pwb_coupon_restriction']) : '';
42
  update_post_meta( $post_id, '_pwb_coupon_restriction', $_pwb_coupon_restriction );
43
  }
44
 
classes/admin/class-pwb-migrate.php CHANGED
@@ -1,124 +1,122 @@
1
  <?php
2
- namespace Perfect_Woocommerce_Brands\Admin;
3
 
4
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
5
 
6
- class PWB_Migrate {
7
 
8
- function __construct(){
9
- add_action( 'wp_ajax_pwb_admin_migrate_brands', array( $this, 'migrate_from' ) );
10
- }
11
-
12
- public function migrate_from(){
13
-
14
- if( isset( $_POST['from'] ) ){
15
-
16
- switch( $_POST['from'] ) {
17
- case 'yith':
18
- $this->migrate_from_yith();
19
- break;
20
- case 'ultimate':
21
- $this->migrate_from_ultimate();
22
- break;
23
- case 'woobrands':
24
- $this->migrate_from_woobrands();
25
- break;
26
- }
27
 
 
 
 
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
-
31
- wp_die();
32
  }
33
 
34
- public function migrate_from_yith(){
35
-
36
- global $wpdb;
37
- $terms = $wpdb->get_col( 'SELECT term_id FROM '.$wpdb->prefix.'term_taxonomy WHERE taxonomy LIKE "yith_product_brand"' );
38
-
39
- foreach( $terms as $term_id ) {
40
-
41
- //change taxonomy
42
- $wpdb->update(
43
- $wpdb->prefix . 'term_taxonomy',
44
- array(
45
- 'taxonomy' => 'pwb-brand'
46
- ),
47
- array(
48
- 'term_id' => $term_id
49
- )
50
- );
51
-
52
- //update term meta
53
- $wpdb->update(
54
- $wpdb->prefix . 'termmeta',
55
- array(
56
- 'meta_key' => 'pwb_brand_image'
57
- ),
58
- array(
59
- 'meta_key' => 'thumbnail_id',
60
- 'term_id' => $term_id
61
- )
62
- );
63
-
64
- }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
 
67
 
68
- public function migrate_from_ultimate(){
69
-
70
- global $wpdb;
71
- $terms = $wpdb->get_col( 'SELECT term_id FROM '.$wpdb->prefix.'term_taxonomy WHERE taxonomy LIKE "product_brand"' );
72
-
73
- foreach( $terms as $term_id ) {
74
-
75
- //change taxonomy
76
- $wpdb->update(
77
- $wpdb->prefix . 'term_taxonomy',
78
- array(
79
- 'taxonomy' => 'pwb-brand'
80
- ),
81
- array(
82
- 'term_id' => $term_id
83
- )
84
- );
85
-
86
- /**
87
- * Ultimate WooCommerce Brands uses tax-meta-class, tax meta are really options
88
- * @link https://github.com/bainternet/Tax-Meta-Class
89
- */
90
- $term_meta = get_option('tax_meta_'.$term_id);
91
- if( isset( $term_meta['mgwb_image_brand_thumb']['id'] ) )
92
- add_term_meta( $term_id, 'pwb_brand_image', $term_meta['mgwb_image_brand_thumb']['id'] );
93
-
94
- }
95
-
96
  }
 
97
 
98
- public function migrate_from_woobrands(){
99
-
100
- global $wpdb;
101
- $terms = $wpdb->get_col( 'SELECT term_id FROM '.$wpdb->prefix.'term_taxonomy WHERE taxonomy LIKE "product_brand"' );
102
 
103
- foreach( $terms as $term_id ) {
 
104
 
105
- // change taxonomy
106
- $wpdb->update(
107
- $wpdb->prefix . 'term_taxonomy',
108
- array(
109
- 'taxonomy' => 'pwb-brand'
110
- ),
111
- array(
112
- 'term_id' => $term_id
113
- )
114
- );
115
 
116
- // add the logo id
117
- if( $thumb_id = get_woocommerce_term_meta( $term_id, 'thumbnail_id', true ) )
118
- add_term_meta( $term_id, 'pwb_brand_image', $thumb_id );
119
-
120
- }
 
 
 
 
 
121
 
 
 
 
122
  }
123
-
124
  }
 
1
  <?php
 
2
 
3
+ namespace Perfect_Woocommerce_Brands\Admin;
4
 
5
+ defined('ABSPATH') or die('No script kiddies please!');
6
 
7
+ class PWB_Migrate
8
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
 
33
+ wp_die();
34
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ public function migrate_from_yith()
37
+ {
38
+
39
+ global $wpdb;
40
+ $terms = $wpdb->get_col('SELECT term_id FROM ' . $wpdb->prefix . 'term_taxonomy WHERE taxonomy LIKE "yith_product_brand"');
41
+
42
+ foreach ($terms as $term_id) {
43
+
44
+ //change taxonomy
45
+ $wpdb->update(
46
+ $wpdb->prefix . 'term_taxonomy',
47
+ array(
48
+ 'taxonomy' => 'pwb-brand'
49
+ ),
50
+ array(
51
+ 'term_id' => $term_id
52
+ )
53
+ );
54
+
55
+ //update term meta
56
+ $wpdb->update(
57
+ $wpdb->prefix . 'termmeta',
58
+ array(
59
+ 'meta_key' => 'pwb_brand_image'
60
+ ),
61
+ array(
62
+ 'meta_key' => 'thumbnail_id',
63
+ 'term_id' => $term_id
64
+ )
65
+ );
66
  }
67
+ }
68
 
69
+ public function migrate_from_ultimate()
70
+ {
71
+
72
+ global $wpdb;
73
+ $terms = $wpdb->get_col('SELECT term_id FROM ' . $wpdb->prefix . 'term_taxonomy WHERE taxonomy LIKE "product_brand"');
74
+
75
+ foreach ($terms as $term_id) {
76
+
77
+ //change taxonomy
78
+ $wpdb->update(
79
+ $wpdb->prefix . 'term_taxonomy',
80
+ array(
81
+ 'taxonomy' => 'pwb-brand'
82
+ ),
83
+ array(
84
+ 'term_id' => $term_id
85
+ )
86
+ );
87
+
88
+ /**
89
+ * Ultimate WooCommerce Brands uses tax-meta-class, tax meta are really options
90
+ * @link https://github.com/bainternet/Tax-Meta-Class
91
+ */
92
+ $term_meta = get_option('tax_meta_' . $term_id);
93
+ if (isset($term_meta['mgwb_image_brand_thumb']['id']))
94
+ add_term_meta($term_id, 'pwb_brand_image', $term_meta['mgwb_image_brand_thumb']['id']);
 
 
95
  }
96
+ }
97
 
98
+ public function migrate_from_woobrands()
99
+ {
 
 
100
 
101
+ global $wpdb;
102
+ $terms = $wpdb->get_col('SELECT term_id FROM ' . $wpdb->prefix . 'term_taxonomy WHERE taxonomy LIKE "product_brand"');
103
 
104
+ foreach ($terms as $term_id) {
 
 
 
 
 
 
 
 
 
105
 
106
+ // change taxonomy
107
+ $wpdb->update(
108
+ $wpdb->prefix . 'term_taxonomy',
109
+ array(
110
+ 'taxonomy' => 'pwb-brand'
111
+ ),
112
+ array(
113
+ 'term_id' => $term_id
114
+ )
115
+ );
116
 
117
+ // add the logo id
118
+ if ($thumb_id = get_woocommerce_term_meta($term_id, 'thumbnail_id', true))
119
+ add_term_meta($term_id, 'pwb_brand_image', $thumb_id);
120
  }
 
121
  }
122
+ }
classes/class-perfect-woocommerce-brands.php CHANGED
@@ -190,8 +190,12 @@ class Perfect_Woocommerce_Brands
190
  public function dismiss_pwb_notice()
191
  {
192
  $notice_name_whitelist = array('wc_pwb_notice_plugin_review');
 
193
  if (isset($_POST['notice_name']) && in_array($_POST['notice_name'], $notice_name_whitelist)) {
194
- update_option($_POST['notice_name'], 0);
 
 
 
195
  echo 'ok';
196
  } else {
197
  echo 'error';
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';
classes/class-pwb-product-tab.php CHANGED
@@ -55,8 +55,12 @@ class PWB_Product_Tab
55
 
56
  <div id="tab-pwb_tab-content">
57
  <h3><?php echo esc_html($brand->name); ?></h3>
58
- <?php if (!empty($brand->description)) echo '<div>' . do_shortcode($brand->description) . '</div>'; ?>
59
- <?php if (!empty($brand_logo)) echo '<span>' . $brand_logo . '</span>'; ?>
 
 
 
 
60
  </div>
61
 
62
  <?php endforeach; ?>
55
 
56
  <div id="tab-pwb_tab-content">
57
  <h3><?php echo esc_html($brand->name); ?></h3>
58
+ <?php if (!empty($brand->description)) : ?>
59
+ <div><?php echo do_shortcode($brand->description); ?></div>
60
+ <?php endif; ?>
61
+ <?php if (!empty($brand_logo)) : ?>
62
+ <span><?php echo wp_kses_post($brand_logo); ?></span>
63
+ <?php endif; ?>
64
  </div>
65
 
66
  <?php endforeach; ?>
classes/shortcodes/class-pwb-all-brands.php CHANGED
@@ -86,7 +86,7 @@ class PWB_All_Brands_Shortcode
86
  $page = 1;
87
 
88
  if (isset($_GET['pwb-page']) && filter_var($_GET['pwb-page'], FILTER_VALIDATE_INT) == true) {
89
- $page = $_GET['pwb-page'];
90
  }
91
 
92
  $page = $page < 1 ? 1 : $page;
86
  $page = 1;
87
 
88
  if (isset($_GET['pwb-page']) && filter_var($_GET['pwb-page'], FILTER_VALIDATE_INT) == true) {
89
+ $page = intval($_GET['pwb-page']);
90
  }
91
 
92
  $page = $page < 1 ? 1 : $page;
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.3
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * Text Domain: 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.3');
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.4
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * Text Domain: 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.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');
readme.txt CHANGED
@@ -5,9 +5,9 @@ Tags: woocommerce, woocommerce brands, woocommerce product, woocommerce manufact
5
  Requires at least: 4.7
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
- Stable tag: 2.0.3
9
  WC requires at least: 3.0
10
- WC tested up to: 6.0
11
  License: GPLv3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -90,6 +90,8 @@ You can also contribute [translating the plugin](https://translate.wordpress.org
90
 
91
 
92
  == Changelog ==
 
 
93
  = 2.0.3 =
94
  * Fix: Security fix
95
  = 2.0.2 =
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
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
90
 
91
 
92
  == Changelog ==
93
+ = 2.0.4 =
94
+ * Fix: Security fix
95
  = 2.0.3 =
96
  * Fix: Security fix
97
  = 2.0.2 =