Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Elementor;
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
- class Widget_Themeum_Title extends Widget_Base {
- public function get_name() {
- return 'thm-title';
- }
- public function get_title() {
- return __( 'Title', 'elementor' );
- }
- public function get_icon() {
- return 'eicon-apps wts-eae-pe';
- }
- public function get_categories() {
- return [ 'themeum-elementor' ];
- }
- protected function _register_controls() {
- $this->start_controls_section(
- 'section_title',
- [
- 'label' => __( 'Title Element', 'elementor' )
- ]
- );
- $this->add_control(
- 'title_txt',
- [
- 'label' => __( 'Title', 'elementor' ),
- 'type' => Controls_Manager::TEXT,
- 'label_block' => true,
- 'placeholder' => __( 'Enter title', 'elementor' ),
- 'default' => __( 'This is heading', 'elementor' ),
- ]
- );
- $this->add_control(
- 'subtitle_content',
- [
- 'label' => __( 'Sub Title Content', 'elementor' ),
- 'type' => Controls_Manager::TEXTAREA,
- 'label_block' => true,
- 'placeholder' => __( 'Enter Sub Title', 'elementor' ),
- 'default' => __( 'Write your sub title content of this section.', 'elementor' ),
- ]
- );
- $this->add_control(
- 'title_link',
- [
- 'label' => __( 'Link', 'elementor' ),
- 'type' => Controls_Manager::TEXT,
- 'label_block' => true,
- 'default' => '',
- ]
- );
- $this->add_responsive_control(
- 'align',
- [
- 'label' => __( 'Alignment', 'elementor' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'elementor' ),
- 'icon' => 'fa fa-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'elementor' ),
- 'icon' => 'fa fa-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'elementor' ),
- 'icon' => 'fa fa-align-right',
- ],
- 'justify' => [
- 'title' => __( 'Justified', 'elementor' ),
- 'icon' => 'fa fa-align-justify',
- ],
- ],
- 'default' => '',
- 'selectors' => [
- '{{WRAPPER}}' => 'text-align: {{VALUE}};',
- ],
- ]
- );
- $this->end_controls_section();
- $this->start_controls_section(
- 'section_title_style',
- [
- 'label' => __( 'Title', 'elementor' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'title_color',
- [
- 'label' => __( 'Text Color', 'elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .thm-heading-title' => 'color: {{VALUE}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
- 'selector' => '{{WRAPPER}} .thm-heading-title',
- ]
- );
- $this->end_controls_section();
- # Title Section end 1
- # Sub Title Section 2
- $this->start_controls_section(
- 'section_subtitle_style',
- [
- 'label' => __( 'Sub Title', 'elementor' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'subtitle_color',
- [
- 'label' => __( 'Subtitle Color', 'elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .sub-title-content' => 'color: {{VALUE}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography2',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_2,
- 'selector' => '{{WRAPPER}} .sub-title-content',
- ]
- );
- # Subtitle part 2 end
- }
- protected function render( ) {
- $settings = $this->get_settings();
- $lin = $settings['title_link']; ?>
- <div class="backer-title-content-wrapper">
- <?php if (! empty( $lin ) ) { ?>
- <h2 class="thm-heading-title"><a href="<?php echo $lin;?>"><?php echo $settings['title_txt']; ?></a></h2>
- <?php } else { ?>
- <h2 class="thm-heading-title"><?php echo $settings['title_txt']; ?></h2>
- <p class="sub-title-content"><?php echo $settings['subtitle_content']; ?></p>
- <?php } ?>
- </div>
- <?php }
- protected function _content_template() {
- ?>
- <#
- var title = settings.title_txt;
- if ( settings.title_link ) {
- title = '<a href="' + settings.title_link + '">' + title + '</a>';
- }
- var title_html = '<h2 class="thm-heading-title">' + title + '</h2>';
- print( title_html );
- #>
- <?php
- }
- }
- Plugin::instance()->widgets_manager->register_widget_type( new Widget_Themeum_Title() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement