| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Modules\Display; |
| 4 |
|
| 5 |
use \Elementor\Controls_Manager; |
| 6 |
use \MasterAddons\Inc\Classes\Helper; |
| 7 |
|
| 8 |
/** |
| 9 |
* Author Name: Liton Arefin |
| 10 |
* Author URL: https://jeweltheme.com |
| 11 |
* Date: 6/5/2021 |
| 12 |
*/ |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} // Exit if accessed directly. |
| 17 |
|
| 18 |
if (!class_exists('MasterAddons\Modules\Display\Glassmorphism')) { |
| 19 |
class Glassmorphism |
| 20 |
{ |
| 21 |
|
| 22 |
/* |
| 23 |
* Instance of this class |
| 24 |
*/ |
| 25 |
private static $instance = null; |
| 26 |
|
| 27 |
public function __construct() |
| 28 |
{ |
| 29 |
// Add new controls to advanced tab globally |
| 30 |
// add_action("elementor/element/section/section_background/before_section_end", array($this, 'jltma_section_add_glassmorphism_controls'), 19, 3); |
| 31 |
// add_action("elementor/element/column/section_style/before_section_end", array($this, 'jltma_section_add_glassmorphism_controls'), 19, 3); |
| 32 |
// add_action("elementor/element/common/_section_background/before_section_end", array($this, 'jltma_section_add_glassmorphism_controls'), 19, 3); |
| 33 |
// add_action("elementor/element/container/section_background/before_section_end", array($this, 'jltma_section_add_glassmorphism_controls'), 19, 3); |
| 34 |
|
| 35 |
// // Add before_render hooks to apply class to container only |
| 36 |
// add_action('elementor/frontend/section/before_render', array($this, 'before_render_glass_effect'), 10); |
| 37 |
// add_action('elementor/frontend/column/before_render', array($this, 'before_render_glass_effect'), 10); |
| 38 |
// add_action('elementor/frontend/container/before_render', array($this, 'before_render_glass_effect'), 10); |
| 39 |
// add_action('elementor/frontend/widget/before_render', array($this, 'before_render_glass_effect'), 10); |
| 40 |
|
| 41 |
|
| 42 |
// Register controls |
| 43 |
add_action('elementor/element/after_section_end', [$this, 'jltma_section_add_glassmorphism_controls'], 11, 3); |
| 44 |
} |
| 45 |
|
| 46 |
private function add_controls($element, $args) |
| 47 |
{ |
| 48 |
// Create separate section for glassmorphism |
| 49 |
$element->start_controls_section( |
| 50 |
'jltma_glassmorphism_section', |
| 51 |
[ |
| 52 |
'tab' => Controls_Manager::TAB_ADVANCED, |
| 53 |
'label' => __('Glassmorphism', 'master-addons') . JLTMA_EXTENSION_BADGE |
| 54 |
] |
| 55 |
); |
| 56 |
|
| 57 |
// Glassmorphism controls - filtered through Pro_Modules.php |
| 58 |
$glassmorphism_controls = apply_filters('master_addons/modules/glassmorphism/controls', [ |
| 59 |
[ |
| 60 |
'type' => 'control', |
| 61 |
'control_id' => 'jltma_enable_glassmorphism_effect_pro', |
| 62 |
'args' => [ |
| 63 |
'label' => __('Enable Glassmorphism', 'master-addons'), |
| 64 |
'type' => Controls_Manager::SWITCHER, |
| 65 |
'default' => 'no', |
| 66 |
'return_value' => 'yes', |
| 67 |
'description' => Helper::upgrade_to_pro('Glassmorphism available on'), |
| 68 |
'label_on' => __('Enable', 'master-addons'), |
| 69 |
'label_off' => __('Disable', 'master-addons'), |
| 70 |
'prefix_class' => 'jltma-glass-effect-', |
| 71 |
], |
| 72 |
], |
| 73 |
]); |
| 74 |
|
| 75 |
foreach ($glassmorphism_controls as $control) { |
| 76 |
if ($control['type'] === 'control') { |
| 77 |
$element->add_control($control['control_id'], $control['args']); |
| 78 |
} elseif ($control['type'] === 'responsive_control') { |
| 79 |
$element->add_responsive_control($control['control_id'], $control['args']); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
$element->end_controls_section(); |
| 84 |
} |
| 85 |
|
| 86 |
public function jltma_section_add_glassmorphism_controls($element, $section_id, $args) |
| 87 |
{ |
| 88 |
// Only add glassmorphism section to specific elements after their sections |
| 89 |
if ( |
| 90 |
('widget' === $element->get_type() && '_section_style' === $section_id) || |
| 91 |
('section' === $element->get_name() && 'section_advanced' === $section_id) || |
| 92 |
('column' === $element->get_name() && 'section_advanced' === $section_id) || |
| 93 |
('container' === $element->get_name() && 'section_layout' === $section_id) |
| 94 |
) { |
| 95 |
$this->add_controls($element, $args); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
public static function get_instance() |
| 100 |
{ |
| 101 |
if (!self::$instance) { |
| 102 |
self::$instance = new self; |
| 103 |
} |
| 104 |
return self::$instance; |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
if (class_exists('MasterAddons\Modules\Display\Glassmorphism')) { |
| 110 |
Glassmorphism::get_instance(); |
| 111 |
} |
| 112 |
|