Advertisement
rejuancse

video-link

Oct 1st, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.88 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.         $this->add_control(
  43.             'video_link',
  44.             [
  45.                 'label' => __( 'Video Link', 'backer' ),
  46.                 'type' => Controls_Manager::TEXT,
  47.                 'label_block' => true,
  48.                 'default' => '',
  49.             ]
  50.         );
  51.  
  52.         $this->add_responsive_control(
  53.             'align',
  54.             [
  55.                 'label'     => __( 'Alignment', 'backer' ),
  56.                 'type'      => Controls_Manager::CHOOSE,
  57.                 'options'   => [
  58.                     'left'      => [
  59.                         'title' => __( 'Left', 'backer' ),
  60.                         'icon'  => 'fa fa-align-left',
  61.                     ],
  62.                     'center'    => [
  63.                         'title' => __( 'Center', 'backer' ),
  64.                         'icon'  => 'fa fa-align-center',
  65.                     ],
  66.                     'right'     => [
  67.                         'title' => __( 'Right', 'backer' ),
  68.                         'icon'  => 'fa fa-align-right',
  69.                     ],
  70.                     'justify'   => [
  71.                         'title' => __( 'Justified', 'backer' ),
  72.                         'icon'  => 'fa fa-align-justify',
  73.                     ],
  74.                 ],
  75.                 'default'   => '',
  76.                 'selectors' => [
  77.                     '{{WRAPPER}}' => 'text-align: {{VALUE}};',
  78.                 ],
  79.             ]
  80.         );
  81.  
  82.         $this->end_controls_section();
  83.  
  84.         $this->start_controls_section(
  85.             'section_title_style',
  86.             [
  87.                 'label'     => __( 'Title', 'backer' ),
  88.                 'tab'       => Controls_Manager::TAB_STYLE,
  89.             ]
  90.         );
  91.         $this->add_control(
  92.             'title_border',
  93.             [
  94.                 'label'         => __( 'Background Border', 'backer' ),
  95.                 'type'          => Controls_Manager::SWITCHER,
  96.                 'default'       => 'no',
  97.                 'label_on'      => __( 'Yes', 'backer' ),
  98.                 'label_off'     => __( 'No', 'backer' ),
  99.                 'selectors'     => [
  100.                     '{{WRAPPER}} h2.bordered:before' => 'width: 100%;',
  101.                 ],
  102.             ]
  103.         );
  104.         $this->add_control(
  105.             'title_bg_color',
  106.             [
  107.                 'label'     => __( 'Background Color', 'backer' ),
  108.                 'type'      => Controls_Manager::COLOR,
  109.                 'scheme'    => [
  110.                     'type'  => Scheme_Color::get_type(),
  111.                     'value' => Scheme_Color::COLOR_1,
  112.                 ],
  113.                 'selectors' => [
  114.                     '{{WRAPPER}} h2.bordered span' => 'background: {{VALUE}};',
  115.                 ],
  116.                 'condition' => [
  117.                     'title_border' => 'yes',
  118.                 ],
  119.             ]
  120.         );
  121.         $this->add_group_control(
  122.             Group_Control_Border::get_type(),
  123.             [
  124.                 'name' => 'image_border',
  125.                 'label' => __( 'Background Border', 'backer' ),
  126.                 'selector' => '{{WRAPPER}} h2.bordered:before',
  127.                 'condition' => [
  128.                     'title_border' => 'yes',
  129.                 ],
  130.             ]
  131.         );
  132.  
  133.         $this->add_control(
  134.             'title_color',
  135.             [
  136.                 'label'     => __( 'Text Color', 'backer' ),
  137.                 'type'      => Controls_Manager::COLOR,
  138.                 'scheme'    => [
  139.                     'type'  => Scheme_Color::get_type(),
  140.                     'value' => Scheme_Color::COLOR_1,
  141.                 ],
  142.                 'selectors' => [
  143.                     '{{WRAPPER}} .thm-heading-title' => 'color: {{VALUE}};',
  144.                 ],
  145.             ]
  146.         );
  147.  
  148.         $this->add_responsive_control(
  149.             'text_padding',
  150.             [
  151.                 'label'         => __( 'Title Padding', 'backer' ),
  152.                 'type'          => Controls_Manager::DIMENSIONS,
  153.                 'size_units'    => [ 'px', 'em', '%' ],
  154.                 'selectors'     => [
  155.                     '{{WRAPPER}} .thm-heading-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  156.                 ],
  157.                 'separator'     => 'before',
  158.             ]
  159.         );
  160.         $this->add_responsive_control(
  161.             'text_margin',
  162.             [
  163.                 'label'         => __( 'Title Margin', 'backer' ),
  164.                 'type'          => Controls_Manager::DIMENSIONS,
  165.                 'size_units'    => [ 'px', 'em', '%' ],
  166.                 'selectors'     => [
  167.                     '{{WRAPPER}} .thm-heading-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  168.                 ],
  169.                 'separator'     => 'before',
  170.             ]
  171.         );
  172.  
  173.         $this->add_group_control(
  174.             Group_Control_Typography::get_type(),
  175.             [
  176.                 'name'      => 'typography',
  177.                 'scheme'    => Scheme_Typography::TYPOGRAPHY_1,
  178.                 'selector'  => '{{WRAPPER}} .thm-heading-title',
  179.             ]
  180.         );
  181.  
  182.         $this->end_controls_section();
  183.         # Title Section end 1
  184.  
  185.  
  186.         # Sub Title Section 2
  187.         $this->start_controls_section(
  188.             'section_subtitle_style',
  189.             [
  190.                 'label'     => __( 'Sub Title', 'backer' ),
  191.                 'tab'       => Controls_Manager::TAB_STYLE,
  192.             ]
  193.         );
  194.  
  195.         $this->add_control(
  196.             'subtitle_color',
  197.             [
  198.                 'label'     => __( 'Subtitle Color', 'backer' ),
  199.                 'type'      => Controls_Manager::COLOR,
  200.                 'scheme'    => [
  201.                     'type'  => Scheme_Color::get_type(),
  202.                     'value' => Scheme_Color::COLOR_1,
  203.                 ],
  204.                 'selectors' => [
  205.                     '{{WRAPPER}} .sub-title-content' => 'color: {{VALUE}};',
  206.                 ],
  207.             ]
  208.         );
  209.  
  210.         $this->add_responsive_control(
  211.             'sub_text_padding',
  212.             [
  213.                 'label' => __( 'Sub Title Padding', 'backer' ),
  214.                 'type' => Controls_Manager::DIMENSIONS,
  215.                 'size_units' => [ 'px', 'em', '%' ],
  216.                 'selectors' => [
  217.                     '{{WRAPPER}} .sub-title-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  218.                 ],
  219.                 'separator' => 'before',
  220.             ]
  221.         );
  222.  
  223.         $this->add_group_control(
  224.             Group_Control_Typography::get_type(),
  225.             [
  226.                 'name'      => 'typography2',
  227.                 'scheme'    => Scheme_Typography::TYPOGRAPHY_2,
  228.                 'selector'  => '{{WRAPPER}} .sub-title-content',
  229.             ]
  230.         );
  231.         # Subtitle part 2 end
  232.     }
  233.  
  234.     protected function render( ) {
  235.         $settings = $this->get_settings();
  236.         $image = $settings['upload_image']; ?>
  237.  
  238.  
  239.         <div class="video-thumb-area">
  240.             <?php if ( $image['url'] ) { ?>
  241.             <img class="img-responsive" src="<?php esc_url($image['url']); ?>" alt="video thumbmnail">    
  242.             <?php } ?>
  243.             <div class="video-play-btn">
  244.                 <a class="video-link" href="<?php echo $settings['video_link']; ?>"><i class="icofont icofont-ui-play"></i></a>
  245.             </div>
  246.         </div>
  247.  
  248.  
  249.     <?php }
  250. }
  251.  
  252. Plugin::instance()->widgets_manager->register_widget_type( new Widget_Themeum_Section1() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement