跳转到主要内容

警告控制

Elementor 警告控制根据消息的严重程度,在面板中显示四种类型的警告:信息、成功、警告和危险。

该控件在继承 Base_UI_Control 类的 Control_Alert 类中定义。

使用此控件时,type 应设置为 \Elementor\Controls_Manager::ALERT 常量。

参数

名称 类型 默认值 描述
type string alert 控件的类型。
separator string default 设置控件分隔符的位置。可用值为 default、before 和 after。default 将隐藏分隔符,除非控件类型有特定的分隔符设置。before / after 会将分隔符定位在控件之前/之后。
alert_type string info 警告的类型。可用值为 info、success、warning 和 danger。
heading string 显示在警告上方的标题。
content string 警告的内容。

返回值

此控件不返回任何值。

用法

<?php
class Elementor_Test_Widget extends \Elementor\Widget_Base {

	protected function register_controls(): void {

		$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();

	}

}