Skip to content

Commit

Permalink
Editor Controls: New Alert Control (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-elementor authored Jan 22, 2024
1 parent 2942209 commit 1bee99a
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/.vuepress/sidebars/editor-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module.exports = [
'control-button',
'control-divider',
'control-deprecated-notice',
'control-alert',
]
},
{
Expand Down
93 changes: 93 additions & 0 deletions src/editor-controls/control-alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Alert Control

<Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Basic" />

<img :src="$withBase('/assets/img/controls/control-alert.png')" alt="Alert Control" style="float: right;">

Elementor alert control displays a four types of alerts in the panel based on the severity of the message: info, success, warning and danger.

The control is defined in `Control_Alert` class which extends `Base_UI_Control` class.

When using this control, the `type` should be set to `\Elementor\Controls_Manager::ALERT` constant.

## Arguments

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>type</code></td>
<td><code>string</code></td>
<td>alert</td>
<td>The type of the control.</td>
</tr>
<tr>
<td><code>separator</code></td>
<td><code>string</code></td>
<td>default</td>
<td>Set the position of the control separator. Available values are <code>default</code>, <code>before</code> and <code>after</code>. <code>default</code> will hide the separator, unless the control type has specific separator settings. <code>before</code> / <code>after</code> will position the separator before/after the control.</td>
</tr>
<tr>
<td><code>alert_type</code></td>
<td><code>string</code></td>
<td>info</td>
<td>The type of the alert. Available values are <code>info</code>, <code>success</code>, <code>warning</code> and <code>danger</code>.</td>
</tr>
<tr>
<td><code>heading</code></td>
<td><code>string</code></td>
<td></td>
<td>The heading that appears above of the alert.</td>
</tr>
<tr>
<td><code>content</code></td>
<td><code>string</code></td>
<td></td>
<td>The content of the alert.</td>
</tr>
</tbody>
</table>

## Return Value

This control does not return any value.

## Usage

```php {14-22}
<?php
class Elementor_Test_Widget extends \Elementor\Widget_Base {

protected function register_controls() {

$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Content', 'textdomain' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);

$this->add_control(
'custom_panel_alert',
[
'type' => \Elementor\Controls_Manager::ALERT,
'alert_type' => 'warning',
'heading' => esc_html__( 'Custom Alert', 'textdomain' ),
'content' => esc_html__( 'Lorem ipsum dolor sit amet consectetur adipisicing elit.', 'textdomain' ) . ' <a href="">' . esc_html__( 'Learn more', 'textdomain' ) . '</a>',
]
);

$this->end_controls_section();

}

}
```

0 comments on commit 1bee99a

Please sign in to comment.