Advertisement
raselahmed7

ElementorWoo Class #5 | ContentBlock

Feb 26th, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.65 KB | None | 0 0
  1. <?php
  2.  
  3. class RRFCommerce_ContentBlock_Widget extends \Elementor\Widget_Base {
  4.  
  5.  
  6.     public function get_name() {
  7.         return 'rrfcommerce-content-block';
  8.     }
  9.  
  10.     public function get_title() {
  11.         return __( 'RRFCommerce ContentBlock', 'plugin-name' );
  12.     }
  13.  
  14.     public function get_icon() {
  15.         return 'fa fa-code';
  16.     }
  17.  
  18.     public function get_categories() {
  19.         return [ 'general' ];
  20.     }
  21.  
  22.     protected function _register_controls() {
  23.  
  24.         $this->start_controls_section(
  25.             'content_section',
  26.             [
  27.                 'label' => __( 'Content', 'plugin-name' ),
  28.                 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
  29.             ]
  30.         );
  31.  
  32.         $this->add_control(
  33.             'theme',
  34.             [
  35.                 'label' => __( 'Box theme', 'plugin-domain' ),
  36.                 'type' => \Elementor\Controls_Manager::SELECT,
  37.                 'default' => '1',
  38.                 'options' => [
  39.                     '1'  => __( 'Theme 1', 'plugin-domain' ),
  40.                     '2' => __( 'Theme 2', 'plugin-domain' ),
  41.                 ],
  42.             ]
  43.         );
  44.  
  45.        
  46.         $this->add_control(
  47.             'title',
  48.             [
  49.                 'label' => __( 'Title', 'plugin-domain' ),
  50.                 'type' => \Elementor\Controls_Manager::TEXT,
  51.                 'default' => 'Girl Lookbook 2015',
  52.             ]
  53.         );
  54.        
  55.         $this->add_control(
  56.             'content',
  57.             [
  58.                 'label' => __( 'Content', 'plugin-domain' ),
  59.                 'type' => \Elementor\Controls_Manager::WYSIWYG,
  60.                 'default' => 'Default content',
  61.             ]
  62.         );
  63.         $this->add_control(
  64.             'image',
  65.             [
  66.                 'label' => __( 'Image background', 'plugin-domain' ),
  67.                 'type' => \Elementor\Controls_Manager::MEDIA,
  68.             ]
  69.         );
  70.         $this->add_control(
  71.             'icon',
  72.             [
  73.                 'label' => __( 'Select icon', 'plugin-domain' ),
  74.                 'type' => \Elementor\Controls_Manager::ICON,
  75.                 'default' => 'fa fa-angle-double-right'
  76.             ]
  77.         );
  78.         $this->add_control(
  79.             'link',
  80.             [
  81.                 'label' => __( 'Link', 'plugin-domain' ),
  82.                 'type' => \Elementor\Controls_Manager::URL
  83.             ]
  84.         );
  85.        
  86.  
  87.         $this->end_controls_section();
  88.  
  89.     }
  90.  
  91.     protected function render() {
  92.  
  93.         $settings = $this->get_settings_for_display();
  94.        
  95.         if($settings['link']['is_external'] == true) {
  96.             $target= '_blank';
  97.         } else {
  98.             $target= '_self';
  99.         }
  100.  
  101.         echo '<div class="content-box content-box-theme-'.$settings['theme'].'">
  102.            <div class="content-box-bg" style="background-image:url('.wp_get_attachment_image_url($settings['image']['id'], 'large').')"></div>
  103.            <div class="content-box-content">
  104.                '.wpautop($settings['content']).'
  105.                <h6>'.$settings['title'].'</h6>
  106.                <a href="'.$settings['link']['url'].'" target="'.$target.'"><i class="'.$settings['icon'].'"></i></a>
  107.            </div>
  108.        </div>';
  109.        
  110.  
  111.     }
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement