Skip to content

Commit 4157483

Browse files
Add "Widget Promotions" (#277)
1 parent 347757c commit 4157483

File tree

7 files changed

+117
-6
lines changed

7 files changed

+117
-6
lines changed
Loading

src/.vuepress/sidebars/widgets.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ module.exports = [
2323
children: [
2424
'widget-structure',
2525
'widget-data',
26-
'widget-categories',
26+
{
27+
collapsable: false,
28+
sidebarDepth: -1,
29+
children: [
30+
'widget-information',
31+
'widget-promotions',
32+
'widget-categories',
33+
]
34+
},
2735
'widget-dependencies',
2836
'widget-controls',
2937
'widget-rendering',

src/widgets/index.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Learn more about widget anatomy and how to create your own:
1919

2020
* [Widget Structure](./widget-structure/)
2121
* [Widget Data](./widget-data/)
22-
* [Widget Categories](./widget-categories/)
22+
* [Widget Information](./widget-information/)
23+
* [Widget Promotions](./widget-promotions/)
24+
* [Widget Categories](./widget-categories/)
2325
* [Widget Dependencies](./widget-dependencies/)
2426
* [Widget Controls](./widget-controls/)
2527
* [Widget Rendering](./widget-rendering/)

src/widgets/widget-data.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Intermediate" />
44

5-
Every widget requires basic information such as the widget ID, label and icon.
5+
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.
66

77
## Data Methods
88

@@ -32,7 +32,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
3232
}
3333

3434
public function get_custom_help_url() {
35-
return 'https://go.elementor.com/widget-name';
35+
return 'https://example.com/widget-name';
3636
}
3737

3838
protected function get_upsale_data() {
@@ -54,4 +54,4 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
5454

5555
* **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.
5656

57-
* **Widget Promotion** – The `get_upsale_data()` method is an optional method that is used to display promotions at the bottom of the widget panel.
57+
* **Widget Promotion** – The `get_upsale_data()` method is an optional method that is used to [display promotions](./widget-promotions/) at the bottom of the widget panel.

src/widgets/widget-information.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Widget Information
2+
3+
<Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Intermediate" />
4+
5+
Elementor widget need to have a unique ID used in the code, and an addition basic information used in the Elementor editor.
6+
7+
## Widget Name/ID
8+
9+
To set a unique ID for the widget, use the `get_name()` method. This string is used in code and in the database. The name should include only lowercase letters and it should not contain spaces (use `_` instead).
10+
11+
```php
12+
class Elementor_Test_Widget extends \Elementor\Widget_Base {
13+
14+
public function get_name() {
15+
return 'widget_name';
16+
}
17+
18+
}
19+
```
20+
21+
## Widget Title
22+
23+
Widget title is the label used in the Elementor editor. The end user will see this text when interacting with different panels. The title should use internalization functions to make the string translatable to other languages.
24+
25+
```php
26+
class Elementor_Test_Widget extends \Elementor\Widget_Base {
27+
28+
public function get_title() {
29+
return esc_html__( 'My Widget Name', 'textdomain' );
30+
}
31+
32+
}
33+
```
34+
35+
## Widget Icon
36+
37+
Each widget has not only a label but also an icon. This icons is displayed in different location in the Editor, like the elements panel and the navigator panel. It's not a required field, but very recommended.
38+
39+
Widgets can use any [Elementor icons](https://elementor.github.io/elementor-icons/) or [FontAwesome icons](https://fontawesome.com/), returning the icon CSS class. Custom icons can also be used.
40+
41+
```php
42+
class Elementor_Test_Widget extends \Elementor\Widget_Base {
43+
44+
public function get_icon() {
45+
return 'eicon-code';
46+
}
47+
48+
}
49+
```

src/widgets/widget-promotions.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Widget Promotions
2+
3+
<Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Intermediate" />
4+
5+
<img :src="$withBase('/assets/img/elementor-widget-promotion.png')" alt="Elementor Widget Promotion" style="float: right; width: 300px; margin-left: 20px; margin-bottom: 20px;">
6+
7+
Elementor widgets have two builtin location in the widget panel for promotions and upsells.
8+
9+
The first option is a simple "Need Help?" url which is an external link with general information about the widget.
10+
11+
The second option is a call-to-action area with offers to upgrade to premium widgets/products/services.
12+
13+
## Widget Help URL
14+
15+
Help links displayed at the bottom of the widget panel bellow all the sections. This is a builtin feature providing the user consistent user experience across all Elementor widgets.
16+
17+
Each widget have the option to set an external link containing general information about that specific widget and instruction how to use it.
18+
19+
```php
20+
class Elementor_Test_Widget extends \Elementor\Widget_Base {
21+
22+
public function get_custom_help_url() {
23+
return 'https://example.com/widget-name';
24+
}
25+
26+
}
27+
```
28+
29+
## Widget Promotion
30+
31+
Promotions are a way for freemium plugins to offer upsells to upgrade to premium widgets/products/services. Widget promotions displayed at the bottom of the widget panel.
32+
33+
```php
34+
class Elementor_Test_Widget extends \Elementor\Widget_Base {
35+
36+
protected function get_upsale_data() {
37+
return [
38+
'condition' => ! \Elementor\Utils::has_pro(),
39+
'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
40+
'image_alt' => esc_attr__( 'Upgrade', 'textdomain' ),
41+
'title' => esc_html__( 'Promotion heading', 'textdomain' ),
42+
'description' => esc_html__( 'Get the premium version of the widget and grow your website capabilities.', 'textdomain' ),
43+
'upgrade_url' => esc_url( 'https://example.com/upgrade-to-pro/' ),
44+
'upgrade_text' => esc_html__( 'Upgrade Now', 'textdomain' ),
45+
];
46+
}
47+
48+
}
49+
```
50+
51+
This is the place to emphasize that the promotion is set on a specific widget. It allows addon developers to create a custom CTA to promote a premium version of that widget.
52+
53+
There is an option to conditionally hide/display this promotion if some conditions are met. For example, Elementor uses widget promotions only when Elementor Pro is not active, therefore paying customers don't see widget promotions.

src/widgets/widget-structure.md

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ The `\Elementor\Widget_Base` class has many more methods, but the vast majority
5454
These methods can be divided into five groups:
5555

5656
* [Data](./widget-data/)
57-
* [Categories](./widget-categories/)
5857
* [Dependencies](./widget-dependencies/)
5958
* [Controls](./widget-controls/)
6059
* [Rendering](./widget-rendering/)

0 commit comments

Comments
 (0)