Advertisement
rejuancse

section1

Oct 1st, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.75 KB | None | 0 0
  1. <?php
  2. namespace Elementor;
  3.  
  4. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  5.  
  6. class Widget_Themeum_Section1 extends Widget_Base {
  7.     public function get_name() {
  8.         return 'thm-title-section';
  9.     }
  10.  
  11.     public function get_title() {
  12.         return __( 'Section One', 'backer' );
  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', 'backer' )
  28.             ]
  29.         );
  30.  
  31.         $this->add_control(
  32.             'upload_image',
  33.             [
  34.                 'label'         => __( 'Upload Image', 'backer' ),
  35.                 'type'          => Controls_Manager::MEDIA,
  36.                 'label_block'   => true,
  37.                 'default'       => [
  38.                         'url' => Utils::get_placeholder_image_src(),
  39.                     ],
  40.             ]
  41.         );
  42.  
  43.         $this->add_control(
  44.             'title_txt',
  45.             [
  46.                 'label'         => __( 'Title', 'backer' ),
  47.                 'type'          => Controls_Manager::TEXT,
  48.                 'label_block'   => true,
  49.                 'placeholder'   => __( 'Enter title', 'backer' ),
  50.                 'default'       => __( 'This is heading', 'backer' ),
  51.             ]
  52.         );
  53.         $this->add_control(
  54.             'subtitle_content',
  55.             [
  56.                 'label' => __( 'Sub Title Content', 'backer' ),
  57.                 'type' => Controls_Manager::TEXTAREA,
  58.                 'label_block' => true,
  59.                 'placeholder' => __( 'Enter Sub Title', 'backer' ),
  60.                 'default' => __( 'Write your sub title content of this section.', 'backer' ),
  61.             ]
  62.         );        
  63.         $this->add_control(
  64.             'video_link',
  65.             [
  66.                 'label' => __( 'Video Link', 'backer' ),
  67.                 'type' => Controls_Manager::TEXT,
  68.                 'label_block' => true,
  69.                 'default' => '',
  70.             ]
  71.         );
  72.         $this->add_control(
  73.             'video_intro',
  74.             [
  75.                 'label' => __( 'Video Intro Text', 'backer' ),
  76.                 'type' => Controls_Manager::TEXTAREA,
  77.                 'label_block' => true,
  78.                 'placeholder' => __( 'Enter Sub Title', 'backer' ),
  79.                 'default' => __( 'Write your sub title content of this section.', 'backer' ),
  80.             ]
  81.         );
  82.  
  83.  
  84.         $this->add_responsive_control(
  85.             'align',
  86.             [
  87.                 'label'     => __( 'Alignment', 'backer' ),
  88.                 'type'      => Controls_Manager::CHOOSE,
  89.                 'options'   => [
  90.                     'left'      => [
  91.                         'title' => __( 'Left', 'backer' ),
  92.                         'icon'  => 'fa fa-align-left',
  93.                     ],
  94.                     'center'    => [
  95.                         'title' => __( 'Center', 'backer' ),
  96.                         'icon'  => 'fa fa-align-center',
  97.                     ],
  98.                     'right'     => [
  99.                         'title' => __( 'Right', 'backer' ),
  100.                         'icon'  => 'fa fa-align-right',
  101.                     ],
  102.                     'justify'   => [
  103.                         'title' => __( 'Justified', 'backer' ),
  104.                         'icon'  => 'fa fa-align-justify',
  105.                     ],
  106.                 ],
  107.                 'default'   => '',
  108.                 'selectors' => [
  109.                     '{{WRAPPER}}' => 'text-align: {{VALUE}};',
  110.                 ],
  111.             ]
  112.         );
  113.  
  114.         $this->end_controls_section();
  115.  
  116.         $this->start_controls_section(
  117.             'section_title_style',
  118.             [
  119.                 'label'     => __( 'Title', 'backer' ),
  120.                 'tab'       => Controls_Manager::TAB_STYLE,
  121.             ]
  122.         );
  123.         $this->add_control(
  124.             'title_border',
  125.             [
  126.                 'label'         => __( 'Background Border', 'backer' ),
  127.                 'type'          => Controls_Manager::SWITCHER,
  128.                 'default'       => 'no',
  129.                 'label_on'      => __( 'Yes', 'backer' ),
  130.                 'label_off'     => __( 'No', 'backer' ),
  131.                 'selectors'     => [
  132.                     '{{WRAPPER}} h2.bordered:before' => 'width: 100%;',
  133.                 ],
  134.             ]
  135.         );
  136.         $this->add_control(
  137.             'title_bg_color',
  138.             [
  139.                 'label'     => __( 'Background Color', 'backer' ),
  140.                 'type'      => Controls_Manager::COLOR,
  141.                 'scheme'    => [
  142.                     'type'  => Scheme_Color::get_type(),
  143.                     'value' => Scheme_Color::COLOR_1,
  144.                 ],
  145.                 'selectors' => [
  146.                     '{{WRAPPER}} h2.bordered span' => 'background: {{VALUE}};',
  147.                 ],
  148.                 'condition' => [
  149.                     'title_border' => 'yes',
  150.                 ],
  151.             ]
  152.         );
  153.         $this->add_group_control(
  154.             Group_Control_Border::get_type(),
  155.             [
  156.                 'name' => 'image_border',
  157.                 'label' => __( 'Background Border', 'backer' ),
  158.                 'selector' => '{{WRAPPER}} h2.bordered:before',
  159.                 'condition' => [
  160.                     'title_border' => 'yes',
  161.                 ],
  162.             ]
  163.         );
  164.  
  165.         $this->add_control(
  166.             'title_color',
  167.             [
  168.                 'label'     => __( 'Text Color', 'backer' ),
  169.                 'type'      => Controls_Manager::COLOR,
  170.                 'scheme'    => [
  171.                     'type'  => Scheme_Color::get_type(),
  172.                     'value' => Scheme_Color::COLOR_1,
  173.                 ],
  174.                 'selectors' => [
  175.                     '{{WRAPPER}} .thm-heading-title' => 'color: {{VALUE}};',
  176.                 ],
  177.             ]
  178.         );
  179.  
  180.         $this->add_responsive_control(
  181.             'text_padding',
  182.             [
  183.                 'label'         => __( 'Title Padding', 'backer' ),
  184.                 'type'          => Controls_Manager::DIMENSIONS,
  185.                 'size_units'    => [ 'px', 'em', '%' ],
  186.                 'selectors'     => [
  187.                     '{{WRAPPER}} .thm-heading-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  188.                 ],
  189.                 'separator'     => 'before',
  190.             ]
  191.         );
  192.         $this->add_responsive_control(
  193.             'text_margin',
  194.             [
  195.                 'label'         => __( 'Title Margin', 'backer' ),
  196.                 'type'          => Controls_Manager::DIMENSIONS,
  197.                 'size_units'    => [ 'px', 'em', '%' ],
  198.                 'selectors'     => [
  199.                     '{{WRAPPER}} .thm-heading-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  200.                 ],
  201.                 'separator'     => 'before',
  202.             ]
  203.         );
  204.  
  205.         $this->add_group_control(
  206.             Group_Control_Typography::get_type(),
  207.             [
  208.                 'name'      => 'typography',
  209.                 'scheme'    => Scheme_Typography::TYPOGRAPHY_1,
  210.                 'selector'  => '{{WRAPPER}} .thm-heading-title',
  211.             ]
  212.         );
  213.  
  214.         $this->end_controls_section();
  215.         # Title Section end 1
  216.  
  217.  
  218.         # Sub Title Section 2
  219.         $this->start_controls_section(
  220.             'section_subtitle_style',
  221.             [
  222.                 'label'     => __( 'Sub Title', 'backer' ),
  223.                 'tab'       => Controls_Manager::TAB_STYLE,
  224.             ]
  225.         );
  226.  
  227.         $this->add_control(
  228.             'subtitle_color',
  229.             [
  230.                 'label'     => __( 'Subtitle Color', 'backer' ),
  231.                 'type'      => Controls_Manager::COLOR,
  232.                 'scheme'    => [
  233.                     'type'  => Scheme_Color::get_type(),
  234.                     'value' => Scheme_Color::COLOR_1,
  235.                 ],
  236.                 'selectors' => [
  237.                     '{{WRAPPER}} .sub-title-content' => 'color: {{VALUE}};',
  238.                 ],
  239.             ]
  240.         );
  241.  
  242.         $this->add_responsive_control(
  243.             'sub_text_padding',
  244.             [
  245.                 'label' => __( 'Sub Title Padding', 'backer' ),
  246.                 'type' => Controls_Manager::DIMENSIONS,
  247.                 'size_units' => [ 'px', 'em', '%' ],
  248.                 'selectors' => [
  249.                     '{{WRAPPER}} .sub-title-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  250.                 ],
  251.                 'separator' => 'before',
  252.             ]
  253.         );
  254.  
  255.         $this->add_group_control(
  256.             Group_Control_Typography::get_type(),
  257.             [
  258.                 'name'      => 'typography2',
  259.                 'scheme'    => Scheme_Typography::TYPOGRAPHY_2,
  260.                 'selector'  => '{{WRAPPER}} .sub-title-content',
  261.             ]
  262.         );
  263.         # Subtitle part 2 end
  264.     }
  265.  
  266.     protected function render( ) {
  267.         $settings = $this->get_settings();
  268.         $image = $settings['upload_image']; ?>
  269.  
  270.         <div class="right-thumb">  
  271.             <div class="single-item">
  272.                 <div class="thumb-area">
  273.  
  274.                     <?php if ( $image['url'] ) { ?>
  275.                     <img class="img-responsive" src="<?php esc_url($image['url']); ?>" alt="">    
  276.                     <?php } ?>
  277.                     <div class="about-content">
  278.                         <div class="content-inner">
  279.                             <span><?php echo $settings['title_txt']; ?></span>
  280.                             <h4><?php echo $settings['subtitle_content']; ?></h4>
  281.                         </div>
  282.                     </div>
  283.                     <div class="hover-info">
  284.                         <div class="content-inner">
  285.                             <h4><?php echo $settings['video_intro']; ?></h4>
  286.                             <div class="icon">
  287.                                 <a class="video-link" href="<?php echo $settings['video_link']; ?>"><i class="icofont icofont-play-alt-2"></i></a>
  288.                             </div>
  289.                         </div>
  290.                     </div>
  291.                 </div>
  292.             </div>
  293.         </div>
  294.  
  295.     <?php }
  296. }
  297.  
  298. Plugin::instance()->widgets_manager->register_widget_type( new Widget_Themeum_Section1() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement