Perfect Brands for WooCommerce - Version 1.9.2

Version Description

  • Add: QuadLayers dashboard widget
Download this release

Release Info

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

Code changes from version 1.9.1 to 1.9.2

includes/quadlayers/widget.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('QL_Widget')) {
4
+
5
+ class QL_Widget
6
+ {
7
+ protected static $instance;
8
+
9
+ public function __construct()
10
+ {
11
+ if (is_admin()) {
12
+ add_action('wp_network_dashboard_setup', [$this, 'add_dashboard_widget'], -10);
13
+ add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget'], -10);
14
+ }
15
+ }
16
+
17
+ public function add_dashboard_widget()
18
+ {
19
+ wp_add_dashboard_widget(
20
+ 'quadlayers-dashboard-overview',
21
+ __('QuadLayers News', 'perfect-woocommerce-brands'),
22
+ [$this, 'display_dashboard_widget']
23
+ );
24
+ }
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>
44
+ <div style="margin-top: 11px;float: left;width: 70%;">
45
+ <?php esc_html_e('Hi! We are Quadlayers! Welcome to QuadLayers! We’re a team of international people who have been working in the WordPress sphere for the last ten years.', 'perfect-woocommerce-brands'); ?>
46
+ <div style="margin-top: 11px; float: left; width: 70%;"><a href="<?php echo admin_url('admin.php?page=' . PWB_PREFIX . '_suggestions'); ?>" target="_blank" class="button button-secondary"><?php esc_html_e('More products', 'perfect-woocommerce-brands'); ?></a></div>
47
+ </div>
48
+ <img style="width: 30%;margin-top: 11px;float: right; max-width: 95px;" src="<?php echo plugins_url('/assets/img/quadlayers.jpg', PWB_PLUGIN_FILE); ?>" />
49
+ </div>
50
+ <div style="clear: both;"></div>
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;">
86
+ <a href="<?php printf('https://quadlayers.com/blog/?utm_source=%s&utm_medium=software&utm_campaign=wordpress&utm_content=dashboard', 'perfect-woocommerce-brands'); ?>" target="_blank"><?php esc_html_e('Read more like this on our blog', 'perfect-woocommerce-brands') ?></a>
87
+ <a class="button-primary" href="<?php printf('https://quadlayers.com/?utm_source=%s&utm_medium=software&utm_campaign=wordpress&utm_content=dashboard', 'perfect-woocommerce-brands'); ?>" target="_blank"><?php esc_html_e('QuadLayers', 'perfect-woocommerce-brands') ?></a>
88
+ </div>
89
+ <?php
90
+ }
91
+
92
+ public static function instance()
93
+ {
94
+ if (!isset(self::$instance)) {
95
+ self::$instance = new self();
96
+ }
97
+ return self::$instance;
98
+ }
99
+ }
100
+
101
+
102
+ QL_Widget::instance();
103
+ }
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.1
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.1');
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');
@@ -47,21 +47,26 @@ define('PWB_DOCUMENTATION_URL', 'https://quadlayers.com/documentation/perfect-wo
47
  define('PWB_GITHUB_URL', 'https://github.com/quadlayers/perfect-woocommerce-brands/');
48
  define('PWB_GROUP_URL', 'https://www.facebook.com/groups/quadlayers');
49
 
50
- register_activation_hook(__FILE__, function() {
51
  update_option('pwb_activate_on', time());
52
  });
53
 
54
  //clean brands slug on plugin deactivation
55
- register_deactivation_hook(__FILE__, function() {
56
  update_option('old_wc_pwb_admin_tab_slug', 'null');
57
  });
58
 
59
  //loads textdomain for the translations
60
- add_action('plugins_loaded', function() {
61
  load_plugin_textdomain('perfect-woocommerce-brands', false, PWB_PLUGIN_DIR . '/lang');
62
  });
63
 
64
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 
 
 
 
 
65
  if (is_plugin_active('woocommerce/woocommerce.php')) {
66
 
67
  require 'classes/class-pwb-term.php';
@@ -109,7 +114,7 @@ if (is_plugin_active('woocommerce/woocommerce.php')) {
109
  new \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands();
110
  } elseif (is_admin()) {
111
 
112
- add_action('admin_notices', function() {
113
  $message = esc_html__('Perfect WooCommerce Brands needs WooCommerce to run. Please, install and active WooCommerce plugin.', 'perfect-woocommerce-brands');
114
  printf('<div class="%1$s"><p>%2$s</p></div>', 'notice notice-error', $message);
115
  });
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.2
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.2');
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');
47
  define('PWB_GITHUB_URL', 'https://github.com/quadlayers/perfect-woocommerce-brands/');
48
  define('PWB_GROUP_URL', 'https://www.facebook.com/groups/quadlayers');
49
 
50
+ register_activation_hook(__FILE__, function () {
51
  update_option('pwb_activate_on', time());
52
  });
53
 
54
  //clean brands slug on plugin deactivation
55
+ register_deactivation_hook(__FILE__, function () {
56
  update_option('old_wc_pwb_admin_tab_slug', 'null');
57
  });
58
 
59
  //loads textdomain for the translations
60
+ add_action('plugins_loaded', function () {
61
  load_plugin_textdomain('perfect-woocommerce-brands', false, PWB_PLUGIN_DIR . '/lang');
62
  });
63
 
64
+
65
+ if (!class_exists('QL_Widget')) {
66
+ include_once(PWB_PLUGIN_DIR . 'includes/quadlayers/widget.php');
67
+ }
68
+
69
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
70
  if (is_plugin_active('woocommerce/woocommerce.php')) {
71
 
72
  require 'classes/class-pwb-term.php';
114
  new \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands();
115
  } elseif (is_admin()) {
116
 
117
+ add_action('admin_notices', function () {
118
  $message = esc_html__('Perfect WooCommerce Brands needs WooCommerce to run. Please, install and active WooCommerce plugin.', 'perfect-woocommerce-brands');
119
  printf('<div class="%1$s"><p>%2$s</p></div>', 'notice notice-error', $message);
120
  });
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.1
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.1 =
94
  * Fix: WordPress compatibility
95
  = 1.9.0 =
5
  Requires at least: 4.7
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 1.9.2
9
  WC requires at least: 3.0
10
  WC tested up to: 5.5
11
  License: GPLv3
90
 
91
 
92
  == Changelog ==
93
+ = 1.9.2 =
94
+ * Add: QuadLayers dashboard widget
95
  = 1.9.1 =
96
  * Fix: WordPress compatibility
97
  = 1.9.0 =