Skip to content

Commit

Permalink
Widgets: Add widget promotions (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-elementor authored Feb 25, 2024
1 parent 8546cfa commit 1982764
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 61 deletions.
26 changes: 13 additions & 13 deletions src/controls/complex-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,6 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
return 'eicon-code';
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Get widget categories.
*
Expand All @@ -313,6 +300,19 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
return [ 'test', 'emoji' ];
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Register test widget controls.
*
Expand Down
26 changes: 13 additions & 13 deletions src/controls/simple-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,6 @@ class Elementor_Currency_Widget extends \Elementor\Widget_Base {
return 'eicon-cart-medium';
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Get widget categories.
*
Expand All @@ -290,6 +277,19 @@ class Elementor_Currency_Widget extends \Elementor\Widget_Base {
return [ 'currency', 'currencies' ];
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Register currency widget controls.
*
Expand Down
48 changes: 34 additions & 14 deletions src/widgets/advanced-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,6 @@ class Elementor_List_Widget extends \Elementor\Widget_Base {
return 'eicon-bullet-list';
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Get widget categories.
*
Expand All @@ -154,6 +141,40 @@ class Elementor_List_Widget extends \Elementor\Widget_Base {
return [ 'list', 'lists', 'ordered', 'unordered' ];
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Get widget promotion data.
*
* Retrieve the widget promotion data.
*
* @since 1.0.0
* @access protected
* @return array Widget promotion data.
*/
protected function get_upsale_data() {
return [
'condition' => true,
'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
'image_alt' => esc_attr__( 'Upgrade', 'elementor-list-widget' ),
'title' => esc_html__( 'Promotion heading', 'elementor-list-widget' ),
'description' => esc_html__( 'Get the premium version of the widget with additional styling capabilities.', 'elementor-list-widget' ),
'upgrade_url' => esc_url( 'https://example.com/upgrade-to-pro/' ),
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor-list-widget' ),
];
}

/**
* Register list widget controls.
*
Expand Down Expand Up @@ -195,7 +216,6 @@ class Elementor_List_Widget extends \Elementor\Widget_Base {
[
'label' => esc_html__( 'Link', 'elementor-list-widget' ),
'type' => \Elementor\Controls_Manager::URL,
'placeholder' => esc_html__( 'https://your-link.com', 'elementor-list-widget' ),
'dynamic' => [
'active' => true,
],
Expand Down
26 changes: 13 additions & 13 deletions src/widgets/simple-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,6 @@ class Elementor_oEmbed_Widget extends \Elementor\Widget_Base {
return 'eicon-code';
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Get widget categories.
*
Expand All @@ -154,6 +141,19 @@ class Elementor_oEmbed_Widget extends \Elementor\Widget_Base {
return [ 'oembed', 'url', 'link' ];
}

/**
* 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() {
return 'https://developers.elementor.com/docs/widgets/';
}

/**
* Register oEmbed widget controls.
*
Expand Down
18 changes: 12 additions & 6 deletions src/widgets/widget-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
return 'eicon-code';
}

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

public function get_categories() {
return [ 'general' ];
}
Expand All @@ -35,6 +31,14 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
return [ 'keyword', 'keyword' ];
}

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

protected function get_upsale_data() {
return [];
}

}
```

Expand All @@ -44,8 +48,10 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {

* **Widget Icon** – The `get_icon()` method is an optional, but recommended, method. It lets you set the widget icon. You can use any [Elementor icons](https://elementor.github.io/elementor-icons/) or [FontAwesome icons](https://fontawesome.com/), to simply return the CSS class name.

* **Widget Help URL** – The `get_custom_help_url()` method is an optional method that sets a custom URL, where the user can get more information about the widget, below the controls.

* **Widget Categories** – The `get_categories()` method lets you set [the category of the widget](./widget-categories/).

* **Widget Keywords** – The `get_keywords()` method lets you set widget keywords and is used to filter the widget list.

* **Widget Help URL** – The `get_custom_help_url()` method is an optional method that sets a custom URL, where the user can get more information about the widget, below the controls.

* **Widget Promotion** – The `get_upsale_data()` method is an optional method that is used to display promotions at the bottom of the widget panel.
6 changes: 4 additions & 2 deletions src/widgets/widget-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {

public function get_icon() {}

public function get_custom_help_url() {}

public function get_categories() {}

public function get_keywords() {}

public function get_custom_help_url() {}

protected function get_upsale_data() {

public function get_script_depends() {}

public function get_style_depends() {}
Expand Down

0 comments on commit 1982764

Please sign in to comment.