add elementor widget code example
Example: custom element widget in elementor
<?php
class Elementor_Test_Widget extends \Elementor\Widget_Base {
public function get_name() {}
public function get_title() {}
public function get_icon() {}
public function get_categories() {}
protected function _register_controls() {}
protected function render() {}
protected function _content_template() {}
}
// Widget Name – The get_name() method is a simple one, you just need to return a widget name that will be used in the code.
// Widget Title – The get_title() method, which again, is a very simple one, you need to return the widget title that will be displayed as the widget label.
// Widget Icon – The get_icon() method, is an optional but recommended method, it lets you set the widget icon. you can use any of the eicon or font-awesome icons, simply return the class name as a string.
// Widget Categories – The get_categories method, lets you set the category of the widget, return the category name as a string.
// Widget Controls – The _register_controls method lets you define which controls (setting fields) your widget will have.
// Render Frontend Output – The render() method, which is where you actually render the code and generate the final HTML on the frontend using PHP.
// Render Editor Output – The _content_template() method, is where you render the editor output to generate the live preview using a Backbone JavaScript template.