Perfect Brands for WooCommerce - Version 1.9.7

Version Description

  • Fix: QuadLayers widget cache
Download this release

Release Info

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

Code changes from version 1.9.6 to 1.9.7

includes/quadlayers/widget.php CHANGED
@@ -25,19 +25,8 @@ if (!class_exists('QL_Widget')) {
25
 
26
  public function display_dashboard_widget()
27
  {
28
- $rss = fetch_feed('https://quadlayers.com/news/feed/');
29
 
30
- if (is_wp_error($rss)) {
31
- printf('<p><strong>%s: </strong>%s</p>', __('Error', 'perfect-woocommerce-brands'), $rss->get_error_message());
32
- return;
33
- }
34
-
35
- if (!$rss->get_item_quantity()) {
36
- printf('<ul><li>%s</li></ul>', __('An error has occurred, which probably means the feed is down. Try again later', 'perfect-woocommerce-brands'));
37
- $rss->__destruct();
38
- unset($rss);
39
- return;
40
- }
41
  ?>
42
  <div>
43
  <div>
@@ -51,35 +40,38 @@ if (!class_exists('QL_Widget')) {
51
  </div>
52
  <div style="margin: 16px -12px 0; padding: 12px 12px 0;border-top: 1px solid #eee;">
53
  <ul>
54
- <?php
55
- foreach ($rss->get_items(0, 3) as $item) {
56
- $link = $item->get_link();
57
- while (stristr($link, 'http') !== $link) {
58
- $link = substr($link, 1);
59
- }
60
-
61
- $link = esc_url(strip_tags($link . '?utm_source=ql_dashboard'));
62
- $title = esc_html(trim(strip_tags($item->get_title())));
63
-
64
- if (empty($title)) {
65
- $title = __('Untitled', 'perfect-woocommerce-brands');
66
- }
67
-
68
- $desc = html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'));
69
- $desc = esc_attr(wp_trim_words($desc, 15, '...'));
70
- $summary = $desc;
71
- $summary = '<div class="rssSummary">' . $summary . '</div>';
72
-
73
- $date = $item->get_date('U');
74
- if ($date) {
75
- $date = '<span class="rss-date">' . date_i18n(get_option('date_format'), $date) . '</span>';
76
- }
77
- $author = $item->get_author();
78
- $author = ucfirst($author->get_name());
79
- $author = ' <cite>' . esc_html(strip_tags($author)) . '</cite>';
80
-
81
- printf(__('<li><a href="%s" target="_blank">%s </a>%s%s%s</li>', 'perfect-woocommerce-brands'), $link, $title, $date, $summary, $author);
82
- } ?>
 
 
 
83
  </ul>
84
  </div>
85
  <div style="display: flex; justify-content: space-between;align-items: center;margin: 16px -12px 0;padding: 12px 12px 0; border-top: 1px solid #eee;">
@@ -89,6 +81,41 @@ if (!class_exists('QL_Widget')) {
89
  <?php
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  public static function instance()
93
  {
94
  if (!isset(self::$instance)) {
25
 
26
  public function display_dashboard_widget()
27
  {
28
+ $feed_items = $this->get_feed();
29
 
 
 
 
 
 
 
 
 
 
 
 
30
  ?>
31
  <div>
32
  <div>
40
  </div>
41
  <div style="margin: 16px -12px 0; padding: 12px 12px 0;border-top: 1px solid #eee;">
42
  <ul>
43
+ <?php if (is_array($feed_items)) { ?>
44
+ <?php
45
+ foreach ($feed_items as $item) {
46
+
47
+ $link = $item['link'];
48
+ while (stristr($link, 'http') !== $link) {
49
+ $link = substr($link, 1);
50
+ }
51
+
52
+ $link = esc_url(strip_tags($link . '?utm_source=ql_dashboard'));
53
+ $title = esc_html(trim(strip_tags($item['title'])));
54
+
55
+ if (empty($title)) {
56
+ $title = __('Untitled', 'perfect-woocommerce-brands');
57
+ }
58
+
59
+ $desc = html_entity_decode($item['desc'], ENT_QUOTES, get_option('blog_charset'));
60
+ $desc = esc_attr(wp_trim_words($desc, 15, '...'));
61
+ $summary = $desc;
62
+ $summary = '<div class="rssSummary">' . $summary . '</div>';
63
+ $date = $item['date'];
64
+ if ($date) {
65
+ $date = '<span class="rss-date">' . date_i18n(get_option('date_format'), $date) . '</span>';
66
+ }
67
+ $author = $item['author'];
68
+ $author = ucfirst($author);
69
+ $author = ' <cite>' . esc_html(strip_tags($author)) . '</cite>';
70
+ printf(__('<li><a href="%s" target="_blank">%s </a>%s%s%s</li>', 'perfect-woocommerce-brands'), $link, $title, $date, $summary, $author);
71
+ } ?>
72
+ <?php } else {
73
+ printf(__('<li>%s</li>', 'perfect-woocommerce-brands'), $feed_items);
74
+ } ?>
75
  </ul>
76
  </div>
77
  <div style="display: flex; justify-content: space-between;align-items: center;margin: 16px -12px 0;padding: 12px 12px 0; border-top: 1px solid #eee;">
81
  <?php
82
  }
83
 
84
+ public function get_feed()
85
+ {
86
+ $rss_items = get_transient('quadlayers_news_feed');
87
+
88
+ if ($rss_items === false) {
89
+ $rss = fetch_feed('https://quadlayers.com/news/feed/');
90
+
91
+ if (is_wp_error($rss)) {
92
+ return "An error has occurred, which probably means the feed is down. Try again later";
93
+ }
94
+
95
+ if (!$rss->get_item_quantity()) {
96
+ $rss->__destruct();
97
+ unset($rss);
98
+ return "An error has occurred, which probably means the feed is down. Try again later";
99
+ }
100
+
101
+ $rss_items = [];
102
+
103
+ foreach ($rss->get_items(0, 3) as $item) {
104
+ $rss_items[] = [
105
+ 'link' => $item->get_link(),
106
+ 'author' => $item->get_author()->get_name(),
107
+ 'title' => $item->get_title(),
108
+ 'desc' => $item->get_description(),
109
+ 'date' => $item->get_date('U')
110
+ ];
111
+ }
112
+
113
+ set_transient('quadlayers_news_feed', $rss_items, DAY_IN_SECONDS);
114
+ }
115
+
116
+ return $rss_items;
117
+ }
118
+
119
  public static function instance()
120
  {
121
  if (!isset(self::$instance)) {
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: 1.9.6
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', '1.9.6');
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: 1.9.7
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', '1.9.7');
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,7 +5,7 @@ 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: 1.9.6
9
  WC requires at least: 3.0
10
  WC tested up to: 5.5
11
  License: GPLv3
@@ -90,6 +90,8 @@ You can also contribute [translating the plugin](https://translate.wordpress.org
90
 
91
 
92
  == Changelog ==
 
 
93
  = 1.9.6 =
94
  * Fix: WordPress compatibility
95
  = 1.9.5 =
5
  Requires at least: 4.7
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 1.9.7
9
  WC requires at least: 3.0
10
  WC tested up to: 5.5
11
  License: GPLv3
90
 
91
 
92
  == Changelog ==
93
+ = 1.9.7 =
94
+ * Fix: QuadLayers widget cache
95
  = 1.9.6 =
96
  * Fix: WordPress compatibility
97
  = 1.9.5 =