Elementor 开发者文档

title: "Widget Data" post_status: publish comment_status: open taxonomy: category: - elementor-developers-docs post_tag: - Widgets - Src - Repos


Widget Data

Every widget requires basic information such as the widget ID, label and icon. In addition, a widget can have optional data providing extra information like an external link describing how to use the widget or promotion to promote premium version of the widget.

Data Methods

Widget data needs to be "returned" by certain methods. Those methods are simple:

class Elementor_Test_Widget extends \Elementor\Widget_Base {

    public function get_name(): string {
        return 'widget_name';
    }

    public function get_title(): string {
        return esc_html__( 'My Widget Name', 'textdomain' );
    }

    public function get_icon(): string {
        return 'eicon-code';
    }

    public function get_categories(): array {
        return [ 'general' ];
    }

    public function get_keywords(): array {
        return [ 'keyword', 'keyword' ];
    }

    public function get_custom_help_url(): string {
        return 'https://example.com/widget-name';
    }

    protected function get_upsale_data(): array {
        return [];
    }

}