Skip to content

Commit 04a3790

Browse files
committed
Added a helper for checking if a page is built with the Elementor page builder
1 parent 0d018a5 commit 04a3790

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

includes/plugins.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Determine if Beaver Builder is enabled within the current loop.
1313
*
14-
* @since 0.1.0
14+
* @since 2.0.0
1515
* @access public
1616
* @return bool True if Beaver Builder is enabled.
1717
*/
@@ -25,10 +25,30 @@ function carelib_is_beaver_enabled() {
2525
return $enabled;
2626
}
2727

28+
/**
29+
* Determine if Elementor is enabled for a given post.
30+
*
31+
* @since 2.2.0
32+
* @access public
33+
* @param bool $post_id The ID of the post to check.
34+
* @return bool True if Elementor is enabled.
35+
*/
36+
function carelib_is_built_with_elementor( $post_id = false ) {
37+
if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
38+
return false;
39+
}
40+
41+
if ( ! $post_id ) {
42+
$post_id = get_the_ID();
43+
}
44+
45+
return (bool) get_post_meta( $post_id, '_elementor_edit_mode', true );
46+
}
47+
2848
/**
2949
* Determine if WooCommerce is installed and activated.
3050
*
31-
* @since 0.1.0
51+
* @since 2.0.0
3252
* @access public
3353
* @return bool True if WooCommerce is active.
3454
*/

0 commit comments

Comments
 (0)