Condition Structure


目录

Each condition needs to have a few basic settings, such as a unique name and label. In addition, a condition should be assigned to a group. A condition could have sub-conditions. The final, and most important, is the check method that checks whether the condition complies with a set of predefined rules.

Theme Condition Class

First, we need to create a class that extends the \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base class:

class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
}

Theme Condition Structure

As mentioned above, conditions extend the \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base class and inherit its methods. A simple condition skeleton will look as follows:

class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {

	public static function get_type(): string {}

	public function get_priority(): int {}

	public function get_name(): string {}

	public function get_label(): string {}

	public function get_all_label(): string {}

	public function register_sub_conditions(): void {}

	public function check( $args ): bool {}

}

Let’s break it down:

Please note that the Condition_Base class has many more methods developers can use, but the methods mentioned above will cover the vast majority of your needs.


版本号 #2
由 壳壳虫 创建于 2026-03-26 17:08:44 UTC
由 壳壳虫 更新于 2026-03-26 17:08:44 UTC