背景组控件

Elementor 背景组控件显示用于定义背景的输入字段，包括背景颜色、背景图像、背景渐变或背景视频。
该控件在继承 
Group_Control_Base 类的 
Group_Control_Background 类中定义。
使用此组控件时，
type 应设置为 
Group_Control_Background::get_type() 方法。
参数
	
		
			
名称
			
类型
			
默认值
			
描述
		
	
	
		
			
type
			
string
			
background
			
控件的类型。
		
		
			
separator
			
string
			
default
			
设置控件分隔符的位置。可用值为 
default、
before 和 
after。
default 将隐藏分隔符，除非控件类型有特定的分隔符设置。
before / 
after 会将分隔符定位在控件之前/之后。
		
		
			
types
			
array
			
			
要使用的特定背景类型。可用类型包括 
classic、
gradient、
video 和 
slideshow。默认为空数组，包含所有类型。
		
		
			
include
			
array
			
			
从组控件中包含特定的控件。示例：
['image']
		
		
			
exclude
			
array
			
			
从组控件中排除某些控件。示例：
['image']
		
		
			
fields_options
			
array
			
			
一个多维数组，包含覆盖控件设置的数据。
		
	
Return Value
(
array) An array containing the background values.
Usage
<?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_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'background',
				'types' => [ 'classic', 'gradient', 'video' ],
				'selector' => '{{WRAPPER}} .your-class',
			]
		);
		$this->end_controls_section();
	}
	protected function render(): void {
		$settings = $this->get_settings_for_display();
		?>
		<div class="your-class">
			...
		</div>
		<?php
	}
	protected function content_template(): void {
		?>
		<div class="your-class">
			...
		</div>
		<?php
	}
}
注意事项
视频和幻灯片类型仅支持在分区/容器级别使用，不支持在小部件级别使用。