Created
June 17, 2016 08:06
-
-
Save andypotanin/04be35113a80b7b157547479e248bebd 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 | |
| // Only activate tests when on a 'develop' branch. | |
| if( isset( $_SERVER['HTTP_X_SELECTED_BRANCH'] ) && strpos( $_SERVER['HTTP_X_SELECTED_BRANCH'], 'develop' ) !== false ) { | |
| header( 'cache-control:no-cache, private' ); | |
| $_event_map = array( | |
| "init" => [ 5, 10, 20 ], | |
| "after_setup_theme" => [ 5, 10, 20 ], | |
| "plugins_loaded" => [ 5, 10, 20 ], | |
| "wp" => [ 5, 10, 20 ], | |
| "wp_loaded" => [ 5, 10, 20 ], | |
| "template_redirect" => [ 5, 10, 20 ], | |
| "get_header" => [ 5, 10, 20 ], | |
| ); | |
| foreach( $_event_map as $_action => $levels ) { | |
| //print_r($_action);die(); | |
| foreach( $levels as $level ) { | |
| add_action($_action, function() { | |
| if( !headers_sent() ) { | |
| $data = '[time:' . timer_stop() . '],[action:' . current_action() . ']'; | |
| if( $__level ) { | |
| $data .= '[level:' . $__level . ']'; | |
| } | |
| header( 'x-set-flag:' . $data, false ); | |
| } | |
| }, $level ); | |
| } | |
| } | |
| // time curl "http://localhost/" -H "x-selected-branch:develop-branch" -H "cache-control:no-cache" -H "pragma:no-cache" -H "x-forwarded-proto:https" -I | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment