Custom_JS.php
1 year ago
Hover_Effect.php
1 year ago
Post_Duplicator.php
1 year ago
Promotion.php
1 year ago
Reading_Progress.php
3 years ago
Scroll_to_Top.php
1 year ago
Table_of_Content.php
1 year ago
Wrapper_Link.php
1 year ago
index.php
3 years ago
Wrapper_Link.php
113 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' ], 100 ); |
| 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->add_control( |
| 57 | 'eael_wrapper_link_disable_traditional', |
| 58 | [ |
| 59 | 'label' => __( 'Disable Traditional Link', 'essential-addons-for-elementor-lite' ), |
| 60 | 'type' => Controls_Manager::SWITCHER, |
| 61 | 'label_on' => esc_html__( 'Yes', 'essential-addons-for-elementor-lite' ), |
| 62 | 'label_off' => esc_html__( 'Off', 'essential-addons-for-elementor-lite' ), |
| 63 | 'return_value' => 'yes', |
| 64 | 'condition' => [ |
| 65 | 'eael_wrapper_link_switch!' => '' |
| 66 | ] |
| 67 | ] |
| 68 | ); |
| 69 | |
| 70 | $element->add_control( |
| 71 | 'ael_wrapper_link_warning_text', |
| 72 | [ |
| 73 | 'type' => Controls_Manager::RAW_HTML, |
| 74 | 'raw' => __('By Disabling <strong>Traditional Link</strong> some features (ex: dynamic tags, custom atrributes etc.) may not work.', 'essential-addons-for-elementor-lite'), |
| 75 | 'content_classes' => 'eael-warning', |
| 76 | 'condition' => [ |
| 77 | 'eael_wrapper_link_switch!' => '', |
| 78 | 'eael_wrapper_link_disable_traditional' => 'yes' |
| 79 | ] |
| 80 | ] |
| 81 | ); |
| 82 | |
| 83 | $element->end_controls_section(); |
| 84 | } |
| 85 | |
| 86 | public function before_render( $element ) { |
| 87 | $wrapper_link_settings = $element->get_settings_for_display( 'eael_wrapper_link' ); |
| 88 | |
| 89 | if ( "yes" === $element->get_settings_for_display( 'eael_wrapper_link_switch' ) && ! empty( $wrapper_link_settings['url'] ) ) { |
| 90 | $disable_traditional = $element->get_settings_for_display( 'eael_wrapper_link_disable_traditional' ); |
| 91 | if( 'yes' === $disable_traditional ){ |
| 92 | $element->add_render_attribute( '_wrapper', |
| 93 | 'data-eael-wrapper-link', |
| 94 | wp_json_encode( [ |
| 95 | 'url' => esc_url( $wrapper_link_settings['url'] ), |
| 96 | 'is_external' => esc_attr( $wrapper_link_settings['is_external'] ), |
| 97 | 'nofollow' => esc_attr( $wrapper_link_settings['nofollow'] ) |
| 98 | ] ) |
| 99 | ); |
| 100 | |
| 101 | $element->add_render_attribute( '_wrapper', 'class', 'eael-non-traditional-link' ); |
| 102 | } else { |
| 103 | $link_id = 'eael-wrapper-link-' . $element->get_id(); |
| 104 | $element->add_render_attribute( 'eael_wrapper_link', 'class', $link_id . ' --eael-wrapper-link-tag' ); |
| 105 | $element->add_link_attributes( 'eael_wrapper_link', $wrapper_link_settings ); |
| 106 | echo "<a "; $element->print_render_attribute_string( 'eael_wrapper_link' ); echo "></a>"; |
| 107 | |
| 108 | $element->add_render_attribute( '_wrapper', 'data-eael-wrapper-link', $link_id ); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 |