Created
November 19, 2016 20:54
-
-
Save joehoyle/8060b28a62f19f78dc9f06499d7ce1bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $wp_filter; | |
if ( ! $wp_filter ) { | |
$wp_filter = array( | |
'parse_request' => array(), | |
'rest_post_dispatch' => array(), | |
); | |
} | |
// set the newrelic values to the matched query | |
$wp_filter['parse_request'][0] = array( | |
'newrelic' => array( | |
'function' => function( WP $wp ) { | |
if ( extension_loaded( 'newrelic' ) ) { | |
newrelic_name_transaction( $wp->matched_rule ); | |
} | |
}, | |
'accepted_args' => 1, | |
), | |
); | |
$wp_filter['rest_post_dispatch'][0] = array( | |
'newrelic' => array( | |
'function' => function( $result ) { | |
if ( extension_loaded( 'newrelic' ) ) { | |
newrelic_name_transaction( '/wp-json' . $result->get_matched_route() ); | |
} | |
return $result; | |
}, | |
'accepted_args' => 1, | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment