• Resolved ofmarconi

    (@ofmarconi)


    Hi!

    I couldn’t search why Search from wp. org is broken.

    Is there any way to disable QueryMonitor completely or at least on the DOM within editors? In Elementor for example, it has up to 46,000 elements in the DOM ( LOL ) and I would like to monitor the query monitor in the backend and frontend, but not in the editor, is this possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ofmarconi

    (@ofmarconi)

    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' ) );
        }
    }
    
    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    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 😀

    Thread Starter ofmarconi

    (@ofmarconi)

    Thanks!

    And I had no idea about flexibility in wp-config.php this opens new doors for me, thanks! What a smart way.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Disable in Editors like Elementor’ is closed to new replies.