← All changes
|
includes/features/Matte_Glass_Background/Matte_Glass_Background.php
+89
-0
51.1.2
→
51.1.86
View file →
| @@ -1,0 +1,89 @@ | ||
| 1 | +<?php /** @noinspection SpellCheckingInspection, PhpUnused */ | |
| 2 | + | |
| 3 | +namespace King_Addons; | |
| 4 | + | |
| 5 | +use Elementor\Controls_Manager; | |
| 6 | + | |
| 7 | +if (!defined('ABSPATH')) { | |
| 8 | + exit; // Exit if accessed directly. | |
| 9 | +} | |
| 10 | + | |
| 11 | +class Matte_Glass_Background | |
| 12 | +{ | |
| 13 | + private static ?Matte_Glass_Background $_instance = null; | |
| 14 | + | |
| 15 | + public static function instance(): Matte_Glass_Background | |
| 16 | + { | |
| 17 | + if (is_null(self::$_instance)) { | |
| 18 | + self::$_instance = new self(); | |
| 19 | + } | |
| 20 | + return self::$_instance; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public function __construct() | |
| 24 | + { | |
| 25 | + add_action('elementor/element/container/section_layout/after_section_end', [__CLASS__, 'addControls'], 1); | |
| 26 | + add_action('elementor/element/column/section_advanced/after_section_end', [__CLASS__, 'addControls'], 1); | |
| 27 | + add_action('elementor/element/section/section_advanced/after_section_end', [__CLASS__, 'addControls'], 1); | |
| 28 | + add_action('elementor/element/common/_section_style/after_section_end', [__CLASS__, 'addControls'], 1); | |
| 29 | + } | |
| 30 | + | |
| 31 | + public static function addControls($section): void | |
| 32 | + { | |
| 33 | + $section->start_controls_section( | |
| 34 | + 'kng_glass_bg_section', | |
| 35 | + [ | |
| 36 | + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Matte Glass Background', 'king-addons'), | |
| 37 | + 'tab' => Controls_Manager::TAB_ADVANCED | |
| 38 | + ] | |
| 39 | + ); | |
| 40 | + | |
| 41 | + $section->add_control( | |
| 42 | + 'kng_glass_bg_enable', | |
| 43 | + [ | |
| 44 | + 'label' => esc_html__('Enable Matte Glass Background', 'king-addons'), | |
| 45 | + 'type' => Controls_Manager::SWITCHER, | |
| 46 | + 'default' => '', | |
| 47 | + 'return_value' => 'yes', | |
| 48 | + 'label_on' => esc_html__('Yes', 'king-addons'), | |
| 49 | + 'label_off' => esc_html__('No', 'king-addons'), | |
| 50 | + 'prefix_class' => 'kng-glass-bg-', | |
| 51 | + ] | |
| 52 | + ); | |
| 53 | + | |
| 54 | + $section->add_control( | |
| 55 | + 'kng_glass_bg_blur_value', | |
| 56 | + [ | |
| 57 | + 'label' => esc_html__('Blur Value', 'king-addons'), | |
| 58 | + 'type' => Controls_Manager::NUMBER, | |
| 59 | + 'min' => 0, | |
| 60 | + 'max' => 100, | |
| 61 | + 'step' => 1, | |
| 62 | + 'default' => 20, | |
| 63 | + 'selectors' => [ | |
| 64 | + '{{WRAPPER}}.kng-glass-bg-yes' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);' | |
| 65 | + ], | |
| 66 | + 'condition' => [ | |
| 67 | + 'kng_glass_bg_enable' => 'yes' | |
| 68 | + ], | |
| 69 | + ] | |
| 70 | + ); | |
| 71 | + | |
| 72 | + $section->add_control( | |
| 73 | + 'kng_glass_bg_color', | |
| 74 | + [ | |
| 75 | + 'label' => esc_html__('Color', 'king-addons'), | |
| 76 | + 'type' => Controls_Manager::COLOR, | |
| 77 | + 'default' => 'rgba(0, 0, 0, 0)', | |
| 78 | + 'selectors' => [ | |
| 79 | + '{{WRAPPER}}.kng-glass-bg-yes' => 'background-color: {{VALUE}};', | |
| 80 | + ], | |
| 81 | + 'condition' => [ | |
| 82 | + 'kng_glass_bg_enable' => 'yes' | |
| 83 | + ], | |
| 84 | + ] | |
| 85 | + ); | |
| 86 | + | |
| 87 | + $section->end_controls_section(); | |
| 88 | + } | |
| 89 | +} | |