Created
November 13, 2023 19:33
-
-
Save tomslominski/ce716bd9178a534e19fe7d33de7eb345 to your computer and use it in GitHub Desktop.
Custom Elementor condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'elementor/theme/register_conditions', function( \ElementorPro\Modules\ThemeBuilder\Classes\Conditions_Manager $manager ) { | |
require get_theme_file_path( 'gutenberg-page-condition.php' ); | |
$manager->get_condition( 'singular' )->register_sub_condition( new Gutenberg_Page() ); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( !defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly | |
} | |
class Gutenberg_Page extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base { | |
public static function get_type() { | |
return 'singular'; | |
} | |
public static function get_priority() { | |
return 20; | |
} | |
public function get_name() { | |
return 'gutenberg_page'; | |
} | |
public function get_label() { | |
return esc_html__( 'Gutenberg Page', 'domain' ); | |
} | |
public function check( $args ) { | |
if( !is_singular() ) { | |
return false; | |
} | |
return !Elementor\Plugin::instance()->documents->get( get_the_ID() )->is_built_with_elementor(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment