0
X
Add Snippet To Project
New Project
Add To Existing Project
/**
* Plugin Name: Topic Flip FAQs
* Description: A custom Elementor widget generated by <a href='https://wpturbo.dev/generators/elementor-widget/'>WPTurbo's Elementor Widget Generator</a>.
* Plugin URI: https://wpturbo.dev/
* Version: 1.0.0
* Author: WPTurbo Elementor Widget Generator
* Author URI: https://wpturbo.dev/generators/elementor-widget/
* Text Domain: tf
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Register oEmbed Widget.
*
* Include widget file and register widget class.
*
* @since 1.0.0
* @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
* @return void
*/
function wpturbo_register_custom_elementor_plugin( \Elementor\Widgets_Manager $widgets_manager ) : void {
$widgets_manager->register( new Custom_Elementor_Widget() );
}
add_action( 'elementor/widgets/register', 'wpturbo_register_custom_elementor_plugin' );
class Custom_Elementor_Widget extends \Elementor\Widget_Base {
/**
* Get widget name.
*
* Retrieve oEmbed widget name.
*
* @since 1.0.0
* @access public
* @return string Widget name.
*/
public function get_name(): string {
return 'tf-faqwidget';
}
/**
* Get widget title.
*
* Retrieve oEmbed widget title.
*
* @since 1.0.0
* @access public
* @return string Widget title.
*/
public function get_title(): string {
return __( 'Topic Flip FAQs', 'tf' );
}
/**
* Get widget icon.
*
* Retrieve oEmbed widget icon.
*
* @since 1.0.0
* @access public
* @return string Widget icon.
*/
public function get_icon(): string {
return 'fa fa-question';
}
/**
* Get custom help URL.
*
* Retrieve a URL where the user can get more information about the widget.
*
* @since 1.0.0
* @access public
* @return string Widget help URL.
*/
public function get_custom_help_url(): string {
// Replace this with your elementor widget's documentation URL.
return 'https://wpturbo.dev/generators/elementor-widget/';
}
/**
* Get widget categories.
*
* Retrieve the list of categories the oEmbed widget belongs to.
*
* @since 1.0.0
* @access public
* @return array Widget categories.
*/
public function get_categories(): array {
return array('Topic Flip');
}
/**
* Register oEmbed widget controls.
*
* Add input fields to allow the user to customize the widget settings.
*
* @since 1.0.0
* @access protected
*/
protected function register_controls() : void {
$this->start_controls_section( 'content_section', array(
'label' => __( 'Edit FAQs', 'tf' ),
'tab' => ElementorControls_Manager::TAB_CONTENT,
));
$this->add_control( 'wpturbo-my-field', array(
'label' => __( 'My Field', 'tf' ),
'type' => \Elementor\Controls_Manager::TEXT,
'input_type' => 'text',
'placeholder' => __( 'My Field', 'tf' ),
));
$this->end_controls_section();
}
/**
* Render oEmbed widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
* @access protected
*/
protected function render() : void {
$settings = $this->get_settings_for_display();
echo '<div class="oembed-elementor-widget">';
echo $settings['wpturbo-my-field'];
echo '</div>';
}
}