Custom_JS.php
5 years ago
Post_Duplicator.php
3 years ago
Promotion.php
3 years ago
Reading_Progress.php
3 years ago
Scroll_to_Top.php
3 years ago
Table_of_Content.php
2 years ago
Wrapper_Link.php
2 years ago
index.php
3 years ago
Wrapper_Link.php
73 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Essential_Addons_Elementor\Extensions; |
| 4 | |
| 5 | use Elementor\Controls_Manager; |
| 6 | |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | class Wrapper_Link { |
| 13 | |
| 14 | /** |
| 15 | * Initialize hooks |
| 16 | */ |
| 17 | public function __construct() { |
| 18 | add_action( 'elementor/element/common/_section_style/after_section_end', [ $this, 'register_controls' ] ); |
| 19 | add_action( 'elementor/element/column/section_advanced/after_section_end', [ $this, 'register_controls' ] ); |
| 20 | add_action( 'elementor/element/section/section_advanced/after_section_end', [ $this, 'register_controls' ] ); |
| 21 | add_action( 'elementor/element/container/section_layout/after_section_end', [ $this, 'register_controls' ] ); |
| 22 | add_action( 'elementor/frontend/before_render', [ $this, 'before_render' ], 1 ); |
| 23 | } |
| 24 | |
| 25 | public function register_controls( $element ) { |
| 26 | $element->start_controls_section( |
| 27 | 'eael_wrapper_link_section', |
| 28 | [ |
| 29 | 'label' => __( '<i class="eaicon-logo"></i> Wrapper Link', 'essential-addons-for-elementor-lite' ), |
| 30 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 31 | ] |
| 32 | ); |
| 33 | |
| 34 | $element->add_control( |
| 35 | 'eael_wrapper_link_switch', |
| 36 | [ |
| 37 | 'label' => __( 'Enable Wrapper Link', 'essential-addons-for-elementor-lite' ), |
| 38 | 'type' => Controls_Manager::SWITCHER |
| 39 | ] |
| 40 | ); |
| 41 | |
| 42 | $element->add_control( |
| 43 | 'eael_wrapper_link', |
| 44 | [ |
| 45 | 'label' => __( 'Link', 'essential-addons-for-elementor-lite' ), |
| 46 | 'type' => Controls_Manager::URL, |
| 47 | 'dynamic' => [ |
| 48 | 'active' => true, |
| 49 | ], |
| 50 | 'condition' => [ |
| 51 | 'eael_wrapper_link_switch!' => '' |
| 52 | ] |
| 53 | ] |
| 54 | ); |
| 55 | |
| 56 | $element->end_controls_section(); |
| 57 | } |
| 58 | |
| 59 | public function before_render( $element ) { |
| 60 | $wrapper_link_settings = $element->get_settings_for_display( 'eael_wrapper_link' ); |
| 61 | |
| 62 | if ( ! empty( $element->get_settings_for_display( 'eael_wrapper_link_switch' ) ) && ! empty( $wrapper_link_settings['url'] ) ) { |
| 63 | unset( $wrapper_link_settings['custom_attributes'] ); |
| 64 | |
| 65 | $element->add_render_attribute( '_wrapper', |
| 66 | 'data-eael-wrapper-link', |
| 67 | wp_json_encode( $wrapper_link_settings ) |
| 68 | ); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | } |
| 73 |