Merge pull request #58 from runcommand/48-stage-template

Register some basic hooks for the template stage
This commit is contained in:
Daniel Bachhuber 2016-08-30 07:00:21 -07:00 committed by GitHub
commit dd0f772a6b
2 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,21 @@
Feature: Profile the template render stage
Scenario: Profiler loads a table with the correct hooks
Given a WP install
When I run `wp profile --stage=template --fields=hook`
Then STDOUT should be a table containing rows:
| hook |
| |
| template_redirect |
| |
| template_include |
| |
| wp_head |
| |
| loop_start |
| |
| loop_end |
| |
| wp_footer |
| total |

View file

@ -295,7 +295,16 @@ class Command {
}
// Load the theme template.
if ( ! $this->focus_stage && ! $this->focus_hook ) {
if ( 'template' === $this->focus_stage ) {
$this->set_stage_hooks( array(
'template_redirect',
'template_include',
'wp_head',
'loop_start',
'loop_end',
'wp_footer',
) );
} else if ( ! $this->focus_stage && ! $this->focus_hook ) {
$logger = new Logger( 'stage', 'template' );
$logger->start();
}