OwlCyberSecurity - MANAGER
Edit File: contact-info.php
<?php use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Group_Control_Typography; if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class Chursy_Elementor_Contact_Info extends Widget_Base { public function get_name() { return 'chursy_elementor_contact_info'; } public function get_title() { return esc_html__( 'Contact Info', 'chursy' ); } public function get_icon() { return 'eicon-email-field'; } public function get_categories() { return [ 'chursy' ]; } public function get_script_depends() { return [ '' ]; } protected function register_controls() { /** * Content Tab */ $this->start_controls_section( 'section_content', [ 'label' => esc_html__( 'Content', 'chursy' ), ] ); $this->add_control( 'icon', [ 'label' => esc_html__( 'Class Icon', 'chursy' ), 'type' => \Elementor\Controls_Manager::ICONS, 'default' => [ 'value' => 'ovaicon-facebook-logo', 'library' => 'all', ], ] ); $this->add_control( 'label', [ 'label' => esc_html__( 'Label', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__('Label', 'chursy'), ] ); $repeater = new \Elementor\Repeater(); $repeater->add_control( 'type', [ 'label' => esc_html__( 'Type', 'chursy' ), 'type' => Controls_Manager::SELECT, 'default' => 'email', 'options' => [ 'email' => esc_html__('Email', 'chursy'), 'phone' => esc_html__('Phone', 'chursy'), 'link' => esc_html__('Link', 'chursy'), 'text' => esc_html__('Text', 'chursy'), ] ] ); $repeater->add_control( 'email_label', [ 'label' => esc_html__( 'Email Label', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__( 'email@company.com', 'chursy' ), 'default' => esc_html__( 'email@company.com', 'chursy' ), 'condition' => [ 'type' => 'email', ] ] ); $repeater->add_control( 'email_address', [ 'label' => esc_html__( 'Email Adress', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__( 'email@company.com', 'chursy' ), 'default' => esc_html__( 'email@company.com', 'chursy' ), 'condition' => [ 'type' => 'email', ] ] ); $repeater->add_control( 'phone_label', [ 'label' => esc_html__( 'Phone Label', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__( '+012 (345) 678', 'chursy' ), 'default' => esc_html__( '+012 (345) 678', 'chursy' ), 'condition' => [ 'type' => 'phone', ] ] ); $repeater->add_control( 'phone_address', [ 'label' => esc_html__( 'Phone Adress', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__( '+012345678', 'chursy' ), 'default' => esc_html__( '+012345678', 'chursy' ), 'condition' => [ 'type' => 'phone', ] ] ); $repeater->add_control( 'link_label', [ 'label' => esc_html__( 'Link Label', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__( 'https://your-domain.com', 'chursy' ), 'default' => esc_html__( 'https://your-domain.com', 'chursy' ), 'condition' => [ 'type' => 'link', ] ] ); $repeater->add_control( 'link_address', [ 'label' => esc_html__( 'Link Adress', 'chursy' ), 'type' => \Elementor\Controls_Manager::URL, 'description' => esc_html__( 'https://your-domain.com', 'chursy' ), 'default' => esc_html__( 'https://your-domain.com', 'chursy' ), 'condition' => [ 'type' => 'link', ], 'show_external' => false, 'default' => [ 'url' => '#', 'is_external' => false, 'nofollow' => false, ], ] ); $repeater->add_control( 'text', [ 'label' => esc_html__( 'Text', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => esc_html__( 'Your text', 'chursy' ), 'default' => esc_html__( 'Your text', 'chursy' ), 'condition' => [ 'type' => 'text', ] ] ); $this->add_control( 'items_info', [ 'label' => esc_html__( 'Items Info', 'chursy' ), 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ 'type' => 'email', 'email_label' => esc_html__('email@company.com', 'chursy'), 'email_address' => esc_html__('email@company.com', 'chursy'), ], ], 'title_field' => '{{{ type }}}', ] ); $this->end_controls_section(); // End Content Tab /** * Icon Style Tab */ $this->start_controls_section( 'section_icon_style', [ 'label' => esc_html__( 'Icon', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'icon_fontsize', [ 'label' => esc_html__( 'Font Size', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 1, 'max' => 300, 'step' => 1, ] ], 'selectors' => [ '{{WRAPPER}} .ova-contact-info .icon i' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .ova-contact-info .icon svg' => 'width: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'icon_color', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-contact-info .icon' => 'color : {{VALUE}};', '{{WRAPPER}} .ova-contact-info .icon svg, {{WRAPPER}} .ova-contact-info .icon svg path' => 'fill : {{VALUE}};' ], ] ); $this->add_responsive_control( 'icon_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .ova-contact-info .icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // End Icon Style Tab /** * Label Style Tab */ $this->start_controls_section( 'section_label_style', [ 'label' => esc_html__( 'Label', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'label_typography', 'selector' => '{{WRAPPER}} .ova-contact-info .contact .label', ] ); $this->add_control( 'label_color', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-contact-info .contact .label' => 'color : {{VALUE}};', ], ] ); $this->add_responsive_control( 'label_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .ova-contact-info .contact .label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); /** * Info Style Tab */ $this->start_controls_section( 'section_info_style', [ 'label' => esc_html__( 'Info', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'info_typography', 'selector' => '{{WRAPPER}} .ova-contact-info .contact .info .item, {{WRAPPER}} .ova-contact-info .contact .info .item a', ] ); $this->add_control( 'info_color', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-contact-info .contact .info .item' => 'color : {{VALUE}};', '{{WRAPPER}} .ova-contact-info .contact .info .item a' => 'color : {{VALUE}};', ], ] ); $this->add_control( 'info_color_hover', [ 'label' => esc_html__( 'Link Color Hover', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-contact-info .contact .info .item a:hover' => 'color : {{VALUE}};', ], ] ); $this->add_responsive_control( 'info_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .ova-contact-info .contact .info .item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'info_alignment', [ 'label' => esc_html__( 'Alignment', 'chursy' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'flex-start' => [ 'title' => esc_html__( 'Flex start', 'chursy' ), 'icon' => 'eicon-v-align-top', ], 'center' => [ 'title' => esc_html__( 'Center', 'chursy' ), 'icon' => 'eicon-v-align-middle', ], 'flex-end' => [ 'title' => esc_html__( 'End', 'chursy' ), 'icon' => 'eicon-v-align-bottom', ], ], 'selectors' => [ '{{WRAPPER}} .ova-contact-info' => 'align-items: {{VALUE}};', ], ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings(); $icon = $settings['icon'] ? $settings['icon'] : ''; $label = $settings['label'] ? $settings['label'] : ''; $items_info = $settings['items_info']; ?> <div class="ova-contact-info"> <?php if( $icon['value'] ){ ?> <div class="icon"> <?php \Elementor\Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?> </div> <?php } ?> <div class="contact"> <?php if( $label ){ ?> <div class="label"> <?php echo esc_html( $label ); ?> </div> <?php } ?> <ul class="info"> <?php foreach( $items_info as $item ): $type = $item['type']; ?> <li class="item"> <?php switch ( $type ) { case 'email': $email_address = $item['email_address']; $email_label = $item['email_label']; if( $email_address && $email_label ){ ?> <a href="mailto:<?php echo esc_attr( $email_address ); ?> "> <?php echo esc_html( $email_label ); ?> </a> <?php } break; case 'phone': $phone_address = $item['phone_address']; $phone_label = $item['phone_label']; if( $phone_address && $phone_label ){ ?> <a href="tel:<?php echo esc_attr( $phone_address ) ?> "> <?php echo esc_html( $phone_label ); ?> </a> <?php } break; case 'link': $this->add_render_attribute( 'title' ); $link_address = $item['link_address']['url']; $link_label = $item['link_label']; $title = $item['link_label'] ? $item['link_label'] : ''; if ( ! empty( $item['link_address']['url'] ) ) { $this->add_link_attributes( 'url', $item['link_address'] ); echo sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'url' ), $title ); }else{ echo esc_html( $title ); } break; case 'text': $text = $item['text']; ?> <?php echo esc_html( $text ); ?> <?php break; default: break; } ?> </li> <?php endforeach; ?> </ul> </div> </div> <?php } // end render } $widgets_manager->register( new Chursy_Elementor_Contact_Info() );