Skip to content

Instantly share code, notes, and snippets.

@imranhoshain
Created September 17, 2018 09:49
Show Gist options
  • Save imranhoshain/b67cd3b67cdfc236a13b48c09233ce98 to your computer and use it in GitHub Desktop.
Save imranhoshain/b67cd3b67cdfc236a13b48c09233ce98 to your computer and use it in GitHub Desktop.
<?php
namespace Marvel\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* @since 1.1.0
*/
class Marvel_About_Box extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.1.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'marvel-about-box';
}
/**
* Retrieve the widget title.
*
* @since 1.1.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Marvel About Section', 'marvel-toolkit' );
}
/**
* Retrieve the widget icon.
*
* @since 1.1.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-icon-box';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @since 1.1.0
*
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return [ 'marvel' ];
}
/**
* Register the widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.1.0
*
* @access protected
*/
protected function _register_controls() {
// Content Controls
$this->start_controls_section(
'marvel_about_box',
[
'label' => esc_html_x( 'About Box','Admin Panel','marvel-toolkit' )
]
);
$this->add_control(
'ab_condition',
[
'label' => __( 'Select Option', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'default' => __( 'Default', 'elementor' ),
'image' => __( 'Image Box', 'elementor' ),
],
]
);
$this->add_control(
'ab_icon',
[
'label' => __( 'Select Icon', 'elementor' ),
'type' => Controls_Manager::ICON,
'label_block' => true,
'default' => [
'default' => 'fa fa-star',
],
'condition' => [
'ab_condition' => 'default',
],
]
);
$this->add_control(
'ab_image',
[
'label' => __( 'Choose Image', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'ab_condition' => 'image',
],
]
);
$this->end_controls_section();
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.1.0
*
* @access protected
*/
protected function render( ) {
$settings = $this->get_settings();
echo marvel_about_box_shortcode ($settings);
}
/**
* Render the widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 1.1.0
*
* @access protected
*/
protected function content_template() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment