Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qm/dispatch/... and qm/process hooks #177

Open
rask opened this issue Apr 7, 2016 · 2 comments
Open

qm/dispatch/... and qm/process hooks #177

rask opened this issue Apr 7, 2016 · 2 comments

Comments

@rask
Copy link

rask commented Apr 7, 2016

As qm/process is seemingly deprecated (contains a backcompat notice above the hook), I though some more documentation was needed on the qm/dispatch/<type> hooks. One use of the qm/process hook was to disable output on some pages (e.g. if the admin bar was not available). How do I use the qm/dispatch/... hooks to disable query monitor output?

I'll dig through the code but a short documentation on the hooks would be nice. :)

@johnbillion
Copy link
Owner

Yeah documentation for the hooks in QM is on my todo list. You can use the qm/dispatch/html filter to disable all HTML output on a given page:

add_filter( 'qm/dispatch/html', function( $dispatch ) {
    if ( $condition ) {
        return false;
    } else {
        return $dispatch;
    }
} );

Similarly, there are qm/dispatch/ajax, qm/dispatch/redirect, and qm/dispatch/rest filters to disable the header output in AJAX requests, redirects, and REST API requests respectively, if necessary.

@rask
Copy link
Author

rask commented Apr 8, 2016

qm/dispatch/html did the trick for me, I'll need to checkout how the AJAX etc. dispatcher are wired to find possible use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants