# Condition Check
Elementor Pro AdvancedElementor runs a series of checks to ensure that conditions comply with a certain set of rules. The check()
method sets these checks.
# Check Method
The method that triggers this condition process is called check()
. In your condition class, use the method as follows:
class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public function check( $args ): bool {
return true;
}
}
2
3
4
5
6
7
If the condition check is valid, the template will be applied.
# Checking Conditions
Developers can add any type of condition checking. Let's see some examples.
# Front Page
In the example below, we'll check to see if it's a front page:
class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public function check( $args ): bool {
return is_front_page();
}
}
2
3
4
5
6
7
# 404 Page
In the following example we'll check to see if it's a 404 page:
class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public function check( $args ): bool {
return is_404();
}
}
2
3
4
5
6
7
# Embed Page
In this example we'll check to see if it's an embed page:
class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public function check( $args ): bool {
return is_embed();
}
}
2
3
4
5
6
7
# SSL Page
We can use server variables to check and see if the page was accessed with SSL:
class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public function check( $args ): bool {
return empty( $_SERVER['HTTPS'] );
}
}
2
3
4
5
6
7
# User Browser
We can apply different templates for different browsers by checking the user's browser (opens new window):
class Elementor_Test_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public function check( $args ): bool {
$browser = get_browser(null, true);
$is_firefox = ( $browser['browser'] === 'Firefox' );
return $is_firefox;
}
}
2
3
4
5
6
7
8
9