PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / admin / widget-builder / class-widget-category-badge.php

class-widget-category-badge.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at inc/admin/widget-builder/class-widget-category-badge.php

70 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Admin\WidgetBuilder;
4
5 use MasterAddons\Inc\Classes\Helper;
6
7 defined('ABSPATH') || exit;
8
9 /**
10 * Brand-colours the PRO badge on the Master Addons Widgets panel category.
11 *
12 * The badge itself is rendered by Elementor from the category's `promotion`
13 * property (registered in class-master-elementor-addons.php). This class only
14 * restyles it, scoped to our own category so Elementor's own Pro promotions
15 * keep their native colour.
16 */
17 class Widget_Category_Badge
18 {
19 const CATEGORY_SLUG = 'master-addons-widgets';
20
21 /** Brand purple. Reads well on the light editor theme. */
22 const BRAND_COLOR = '#6814cd';
23
24 /**
25 * Lighter tint for the dark editor theme — #6814cd only reaches roughly
26 * 2:1 contrast against Elementor's near-black panel (#1f2124).
27 */
28 const BRAND_COLOR_DARK = '#a855f7';
29
30 private static $_instance = null;
31
32 public function __construct()
33 {
34 add_action('elementor/editor/after_enqueue_styles', [$this, 'enqueue_badge_style']);
35 }
36
37 public function enqueue_badge_style()
38 {
39 // Licensed sites get no promotion registered, so nothing to style.
40 if (Helper::jltma_premium()) {
41 return;
42 }
43
44 // The plain `color` declaration is the fallback for browsers without
45 // light-dark(); Elementor sets color-scheme on the root, so supporting
46 // browsers pick the tint matching the editor's UI theme.
47 $css = sprintf(
48 '#elementor-panel-category-%1$s .elementor-panel-heading-promotion a,' .
49 '#elementor-panel-category-%1$s .elementor-panel-heading-promotion i' .
50 '{color:%2$s;color:light-dark(%2$s,%3$s)}' .
51 '#elementor-panel-category-%1$s .elementor-panel-heading-promotion a:hover{opacity:.8}',
52 self::CATEGORY_SLUG,
53 self::BRAND_COLOR,
54 self::BRAND_COLOR_DARK
55 );
56
57 wp_register_style('jltma-widget-category-badge', false, [], JLTMA_VER);
58 wp_enqueue_style('jltma-widget-category-badge');
59 wp_add_inline_style('jltma-widget-category-badge', $css);
60 }
61
62 public static function get_instance()
63 {
64 if (is_null(self::$_instance)) {
65 self::$_instance = new self();
66 }
67 return self::$_instance;
68 }
69 }
70