I am developing a WordPress plugin to analyze which page builder (e.g., Elementor, WPBakery, Divi) is actively being used to render the current page, not just which builder plugins are installed and active on the site which is similar to wappalyzer and builtwith.
My current approach is flawed because it only checks a pre-defined list of plugins against the active plugins list. This tells me if a builder is installed, but not if it was actually used to build this specific page.
private function analyze_builders()
{
$all_plugins = get_plugins();
$builders = [];
$builder_list = [
'elementor/elementor.php' => 'Elementor',
'wpbakery-visual-composer/wpbakery.php' => 'WPBakery',
'divi-builder/divi-builder.php' => 'Divi Builder',
// ... other builders
];
foreach ($builder_list as $slug => $label) {
if (isset($all_plugins[$slug])) {
$builders[] = [
'name' => __($label, 'pluginbuilder'),
'status' => is_plugin_active($slug) ? __('Active', 'pluginbuilder') : __('Inactive', 'pluginbuilder')
];
}
}
if (empty($builders)) {
return [
[
'name' => __('No builder used', 'pluginbuilder'),
'status' => ''
]
];
}
return $builders;
}
The Problem:
This method fails in two key scenarios:
-
If a site has multiple page builders active (e.g., both Elementor and WPBakery), it returns both, but doesn’t tell me which one built this page.
-
If a page builder is used that is not on my pre-defined list, it returns “No builder,” which is incorrect.
What I Need:
I need a way to dynamically detect the page builder from the page content itself. I’m looking for a reliable method to check the current post’s metadata or content for tell-tale signs of a specific page builder.
My Research & Ideas:
I’ve researched and believe the solution might involve checking for builder-specific patterns, such as:
-
Post Meta Data: Checking the
_wp_page_template
meta key or builder-specific keys like_elementor_edit_mode
or_wpb_shortcodes_custom_css
. -
Content Analysis: Scanning the post content for shortcodes (
[vc_row]
) or HTML comments (<!-- /wp:shortcode -->
) and CSS classes specific to a builder. -
Database Queries: Perhaps performing a specific database query on the
postmeta
table for the current post ID.
My Question:
What is the most robust and performant method to detect which page builder was used for the current WordPress page? I am particularly interested in hooks, filters, or database queries that are unique to major page builders like Elementor, WPBakery, and Divi.
Example of desired output:
For a page built with Elementor, the function should return 'Elementor'
.
For a classic page with no builder, it should return false
or 'None'
.