mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:39:02 +08:00
Merge pull request #103 from runcommand/50-profile-mu-plugins
Start profiling right away when profiling `muplugins_loaded:before`
This commit is contained in:
commit
35e0c8f9eb
2 changed files with 23 additions and 2 deletions
|
@ -120,3 +120,20 @@ Feature: Profile a specific hook
|
|||
"""
|
||||
Warning: Called 1
|
||||
"""
|
||||
|
||||
Scenario: Profile the mu_plugins:before hook
|
||||
Given a WP install
|
||||
And a wp-content/mu-plugins/awesome-file.php file:
|
||||
"""
|
||||
<?php
|
||||
function awesome_func() {
|
||||
// does nothing
|
||||
}
|
||||
awesome_func();
|
||||
"""
|
||||
|
||||
When I run `wp profile hook muplugins_loaded:before --fields=callback`
|
||||
Then STDOUT should contain:
|
||||
"""
|
||||
wp-content/mu-plugins/awesome-file.php
|
||||
"""
|
||||
|
|
|
@ -98,8 +98,12 @@ class Profiler {
|
|||
}
|
||||
$end_hook = substr( $this->focus, 0, -7 );
|
||||
$key = array_search( $end_hook, $stage_hooks );
|
||||
$start_hook = $stage_hooks[ $key - 1 ];
|
||||
WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 );
|
||||
if ( isset( $stage_hooks[ $key - 1 ] ) ) {
|
||||
$start_hook = $stage_hooks[ $key - 1 ];
|
||||
WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 );
|
||||
} else {
|
||||
WP_CLI::add_hook( 'after_wp_config_load', array( $this, 'wp_tick_profile_begin' ) );
|
||||
}
|
||||
WP_CLI::add_wp_hook( $end_hook, array( $this, 'wp_tick_profile_end' ), -9999 );
|
||||
} else {
|
||||
WP_CLI::add_wp_hook( 'all', array( $this, 'wp_hook_begin' ) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue