According to ChatGPT this would work (not tested!):
- Open the file and find the QM_Dispatcher class.
- Add a new condition in the “start” method to check if the user is in the Elementor editor.
- If this condition is true, use the “remove_filter” function to remove the database query monitoring filter.
- Here is an example of how the code could be modified:
class QM_Dispatcher {
public function start() {
if (is_admin() && (isset($_GET['action']) && $_GET['action'] == 'elementor')) {
return;
}
add_filter( 'query', array( $this, 'query' ) );
}
}
You can disable QM via conditional logic inside wp-config.php. This needs to happen before WordPress loads, so it won’t work if the code is inside a plugin or theme:
if ( isset( $_GET['action'] ) && $_GET['action'] === 'elementor' ) {
define( 'QM_DISABLED', true );
}
If you can’t edit your wp-config.php file then you can tell QM to cease its collection and output, which still results in a little overhead but not much:
add_action( 'init', function() {
if ( isset( $_GET['action'] ) && $_GET['action'] === 'elementor' ) {
do_action( 'qm/cease' );
}
} );
It looks like ChatGPT was taking the approach of editing the code inside QM itself. The $_GET['action'] logic is correct but everything else is quite wrong. ChatGPT needs to carry on doing some more research 😀
Thanks!
And I had no idea about flexibility in wp-config.php this opens new doors for me, thanks! What a smart way.