OwlCyberSecurity - MANAGER
Edit File: circle-button.php
<?php use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Group_Control_Typography; use Elementor\Utils; use Elementor\Group_Control_Border; if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class Chursy_Elementor_Circle_Button extends Widget_Base { public function get_name() { return 'chursy_elementor_circle_button'; } public function get_title() { return esc_html__( 'Circle Button', 'chursy' ); } public function get_icon() { return 'eicon-circle-o'; } public function get_categories() { return [ 'chursy' ]; } public function get_script_depends() { return [ '' ]; } // Add Your Controll In This Function protected function register_controls() { $this->start_controls_section( 'section_content', [ 'label' => esc_html__( 'Content', 'chursy' ), ] ); // Add Class control $this->add_control( 'sub_title', [ 'label' => esc_html__( 'Sub title', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, ] ); $this->add_control( 'text', [ 'label' => esc_html__( 'Text', 'chursy' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => esc_html__( 'Explore', 'chursy' ), ] ); $this->add_control( 'icon', [ 'label' => esc_html__( 'Class Icon', 'chursy' ), 'type' => \Elementor\Controls_Manager::ICONS, 'default' => [ 'value' => 'flaticon flaticon-diagonal-arrow', 'library' => 'all', ], ] ); $this->add_control( 'link', [ 'label' => esc_html__( 'Link', 'chursy' ), 'type' => \Elementor\Controls_Manager::URL, 'placeholder' => esc_html__( 'https://your-link.com', 'chursy' ), 'options' => [ 'url', 'is_external', 'nofollow' ], 'default' => [ 'url' => '', 'is_external' => false, 'nofollow' => false, ], ] ); $this->add_responsive_control( 'alignment', [ 'label' => esc_html__( 'Alignment', 'chursy' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__( 'Left', 'chursy' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__( 'Center', 'chursy' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__( 'Right', 'chursy' ), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'center', 'toggle' => true, 'selectors' => [ '{{WRAPPER}} .ova-circle-button' => 'text-align: {{VALUE}};', ], ] ); $this->add_responsive_control( 'text_alignment', [ 'label' => esc_html__( 'Text Alignment', 'chursy' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__( 'Left', 'chursy' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__( 'Center', 'chursy' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__( 'Right', 'chursy' ), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'center', 'toggle' => true, 'selectors' => [ '{{WRAPPER}} .ova-circle-button .button-content' => 'text-align: {{VALUE}};', ], ] ); $this->end_controls_section(); //SECTION TAB STYLE TITLE $this->start_controls_section( 'section_button_style', [ 'label' => esc_html__( 'Button', 'chursy' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'button_size', [ 'label' => esc_html__( 'Size', 'chursy' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'em', 'rem' ], 'range' => [ 'px' => [ 'min' => 80, 'max' => 600, 'step' => 1, ], '%' => [ 'min' => 10, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button' => 'width: {{SIZE}}{{UNIT}};min-width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'color_button', [ 'label' => esc_html__( 'Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button' => 'color : {{VALUE}};', ], ] ); $this->add_control( 'color_button_hover', [ 'label' => esc_html__( 'Color Hover', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button:hover' => 'color : {{VALUE}};' ], ] ); $this->add_control( 'background_color', [ 'label' => esc_html__( 'Background Color', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button' => 'background-color : {{VALUE}};', ], ] ); $this->add_control( 'background_color_hover', [ 'label' => esc_html__( 'Background Color Hover', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button:hover' => 'background-color : {{VALUE}};' ], ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'button_border', 'selector' => '{{WRAPPER}} .ova-circle-button .circle-button', ] ); $this->add_control( 'border_color_hover', [ 'label' => esc_html__( 'Border Color Hover', 'chursy' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button:hover' => 'border-color : {{VALUE}};' ], ] ); $this->add_responsive_control( 'circle_button_padding', [ 'label' => esc_html__( 'Padding', 'chursy' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'button_sub_title', [ 'label' => esc_html__( 'Sub Title', 'chursy' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'button_typography_sub_title', 'label' => esc_html__( 'Typography', 'chursy' ), 'selector' => '{{WRAPPER}} .ova-circle-button .circle-button .sub_title', ] ); $this->add_responsive_control( 'sub_title_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button .sub_title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'button_text', [ 'label' => esc_html__( 'Text', 'chursy' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'button_typography_text', 'label' => esc_html__( 'Typography', 'chursy' ), 'selector' => '{{WRAPPER}} .ova-circle-button .circle-button .text', ] ); $this->add_responsive_control( 'text_margin', [ 'label' => esc_html__( 'Margin', 'chursy' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button .text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'button_icon', [ 'label' => esc_html__( 'Icon', 'chursy' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_responsive_control( 'button_icon_size', [ 'label' => esc_html__( 'Size', 'chursy' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 1, 'max' => 300, 'step' => 1, ] ], 'selectors' => [ '{{WRAPPER}} .ova-circle-button .circle-button .icon i' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .ova-circle-button .circle-button .icon svg' => 'width: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); //END SECTION TAB STYLE TITLE } // Render Template Here protected function render() { $settings = $this->get_settings(); $sub_title = $settings['sub_title']; $text = $settings['text']; $icon = $settings['icon']; $link = $settings['link']['url']; $target = $settings['link']['is_external'] ? '_blank' : '_self'; $nofollow = (( $settings['link']['nofollow'] != '' ) && $settings['link']['nofollow'] ) ? 'rel=nofollow' : ''; ?> <div class="ova-circle-button"> <?php if ( !empty($link) ) { ?> <a href="<?php echo esc_attr($link); ?>" class="circle-button" target='<?php echo esc_attr($target); ?>' <?php echo esc_attr($nofollow); ?>> <?php } else { ?> <div class="circle-button"> <?php } ?> <div class="button-content"> <?php if ( !empty($sub_title) ) { ?> <span class="sub_title"><?php echo esc_html($sub_title); ?></span> <?php } ?> <?php if ( !empty($text) ) { ?> <span class="text"> <?php echo esc_html($text); ?> </span> <?php } ?> <?php if( $icon['value'] ){ ?> <div class="icon"> <?php \Elementor\Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?> </div> <?php } ?> </div> <?php if ( !empty($link) ) { ?> </a> <?php } else { ?> </div> <?php } ?> </div> <?php } } $widgets_manager->register( new Chursy_Elementor_Circle_Button() );