Advertisement
Guest User

backer-title

a guest
May 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.04 KB | None | 0 0
  1. <?php
  2. namespace Elementor;
  3.  
  4. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  5.  
  6. class Widget_Themeum_Title extends Widget_Base {
  7.     public function get_name() {
  8.         return 'thm-title';
  9.     }
  10.  
  11.     public function get_title() {
  12.         return __( 'Title', 'elementor' );
  13.     }
  14.  
  15.     public function get_icon() {
  16.         return 'eicon-apps wts-eae-pe';
  17.     }
  18.  
  19.     public function get_categories() {
  20.         return [ 'themeum-elementor' ];
  21.     }
  22.  
  23.     protected function _register_controls() {
  24.         $this->start_controls_section(
  25.             'section_title',
  26.             [
  27.                 'label' => __( 'Title Element', 'elementor' )
  28.             ]
  29.         );
  30.  
  31.         $this->add_control(
  32.             'title_txt',
  33.             [
  34.                 'label' => __( 'Title', 'elementor' ),
  35.                 'type' => Controls_Manager::TEXT,
  36.                 'label_block' => true,
  37.                 'placeholder' => __( 'Enter title', 'elementor' ),
  38.                 'default' => __( 'This is heading', 'elementor' ),
  39.             ]
  40.         );
  41.         $this->add_control(
  42.             'subtitle_content',
  43.             [
  44.                 'label' => __( 'Sub Title Content', 'elementor' ),
  45.                 'type' => Controls_Manager::TEXTAREA,
  46.                 'label_block' => true,
  47.                 'placeholder' => __( 'Enter Sub Title', 'elementor' ),
  48.                 'default' => __( 'Write your sub title content of this section.', 'elementor' ),
  49.             ]
  50.         );        
  51.         $this->add_control(
  52.             'title_link',
  53.             [
  54.                 'label' => __( 'Link', 'elementor' ),
  55.                 'type' => Controls_Manager::TEXT,
  56.                 'label_block' => true,
  57.                 'default' => '',
  58.             ]
  59.         );
  60.  
  61.         $this->add_responsive_control(
  62.             'align',
  63.             [
  64.                 'label'     => __( 'Alignment', 'elementor' ),
  65.                 'type'      => Controls_Manager::CHOOSE,
  66.                 'options'   => [
  67.                     'left'      => [
  68.                         'title' => __( 'Left', 'elementor' ),
  69.                         'icon'  => 'fa fa-align-left',
  70.                     ],
  71.                     'center'    => [
  72.                         'title' => __( 'Center', 'elementor' ),
  73.                         'icon'  => 'fa fa-align-center',
  74.                     ],
  75.                     'right'     => [
  76.                         'title' => __( 'Right', 'elementor' ),
  77.                         'icon'  => 'fa fa-align-right',
  78.                     ],
  79.                     'justify'   => [
  80.                         'title' => __( 'Justified', 'elementor' ),
  81.                         'icon'  => 'fa fa-align-justify',
  82.                     ],
  83.                 ],
  84.                 'default'   => '',
  85.                 'selectors' => [
  86.                     '{{WRAPPER}}' => 'text-align: {{VALUE}};',
  87.                 ],
  88.             ]
  89.         );
  90.  
  91.         $this->end_controls_section();
  92.  
  93.         $this->start_controls_section(
  94.             'section_title_style',
  95.             [
  96.                 'label'     => __( 'Title', 'elementor' ),
  97.                 'tab'       => Controls_Manager::TAB_STYLE,
  98.             ]
  99.         );
  100.  
  101.         $this->add_control(
  102.             'title_color',
  103.             [
  104.                 'label'     => __( 'Text Color', 'elementor' ),
  105.                 'type'      => Controls_Manager::COLOR,
  106.                 'scheme'    => [
  107.                     'type'  => Scheme_Color::get_type(),
  108.                     'value' => Scheme_Color::COLOR_1,
  109.                 ],
  110.                 'selectors' => [
  111.                     '{{WRAPPER}} .thm-heading-title' => 'color: {{VALUE}};',
  112.                 ],
  113.             ]
  114.         );
  115.  
  116.         $this->add_group_control(
  117.             Group_Control_Typography::get_type(),
  118.             [
  119.                 'name'      => 'typography',
  120.                 'scheme'    => Scheme_Typography::TYPOGRAPHY_1,
  121.                 'selector'  => '{{WRAPPER}} .thm-heading-title',
  122.             ]
  123.         );
  124.  
  125.         $this->end_controls_section();
  126.         # Title Section end 1
  127.  
  128.  
  129.         # Sub Title Section 2
  130.         $this->start_controls_section(
  131.             'section_subtitle_style',
  132.             [
  133.                 'label'     => __( 'Sub Title', 'elementor' ),
  134.                 'tab'       => Controls_Manager::TAB_STYLE,
  135.             ]
  136.         );
  137.  
  138.         $this->add_control(
  139.             'subtitle_color',
  140.             [
  141.                 'label'     => __( 'Subtitle Color', 'elementor' ),
  142.                 'type'      => Controls_Manager::COLOR,
  143.                 'scheme'    => [
  144.                     'type'  => Scheme_Color::get_type(),
  145.                     'value' => Scheme_Color::COLOR_1,
  146.                 ],
  147.                 'selectors' => [
  148.                     '{{WRAPPER}} .sub-title-content' => 'color: {{VALUE}};',
  149.                 ],
  150.             ]
  151.         );
  152.  
  153.         $this->add_group_control(
  154.             Group_Control_Typography::get_type(),
  155.             [
  156.                 'name'      => 'typography2',
  157.                 'scheme'    => Scheme_Typography::TYPOGRAPHY_2,
  158.                 'selector'  => '{{WRAPPER}} .sub-title-content',
  159.             ]
  160.         );
  161.         # Subtitle part 2 end
  162.     }
  163.  
  164.     protected function render( ) {
  165.         $settings = $this->get_settings();
  166.         $lin = $settings['title_link']; ?>
  167.  
  168.         <div class="backer-title-content-wrapper">
  169.  
  170.             <?php if (! empty(  $lin ) ) { ?>
  171.                 <h2 class="thm-heading-title"><a href="<?php echo $lin;?>"><?php echo $settings['title_txt']; ?></a></h2>
  172.             <?php } else { ?>
  173.                 <h2 class="thm-heading-title"><?php echo $settings['title_txt']; ?></h2>
  174.                 <p class="sub-title-content"><?php echo $settings['subtitle_content']; ?></p>
  175.             <?php } ?>
  176.  
  177.         </div>
  178.  
  179.         <?php }
  180.  
  181.     protected function _content_template() {
  182.         ?>
  183.         <#
  184.             var title = settings.title_txt;
  185.             if ( settings.title_link ) {
  186.                 title = '<a href="' + settings.title_link + '">' + title + '</a>';
  187.             }
  188.             var title_html = '<h2 class="thm-heading-title">' + title + '</h2>';
  189.             print( title_html );
  190.         #>
  191.         <?php
  192.     }
  193. }
  194.  
  195. Plugin::instance()->widgets_manager->register_widget_type( new Widget_Themeum_Title() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement