Merge pull request #20 from runcommand/namespace-class

Namespace the command class
This commit is contained in:
Daniel Bachhuber 2016-08-26 06:17:34 -07:00 committed by GitHub
commit 9893074687
2 changed files with 11 additions and 6 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
if ( class_exists( 'WP_CLI' ) ) { if ( class_exists( 'WP_CLI' ) ) {
require_once dirname( __FILE__ ) . '/inc/class-profile-command.php'; require_once dirname( __FILE__ ) . '/inc/class-command.php';
WP_CLI::add_command( 'profile', 'Profile_Command' ); WP_CLI::add_command( 'profile', 'runcommand\Profile\Command' );
} }

View file

@ -1,9 +1,14 @@
<?php <?php
namespace runcommand\Profile;
use WP_CLI;
use WP_CLI\Utils;
/** /**
* Profile the performance of a WordPress request. * Profile the performance of a WordPress request.
*/ */
class Profile_Command { class Command {
private $hook_start_time = 0; private $hook_start_time = 0;
private $hook_time = 0; private $hook_time = 0;
@ -93,10 +98,10 @@ class Profile_Command {
} }
} }
$this->focus_scope = WP_CLI\Utils\get_flag_value( $assoc_args, 'scope' ); $this->focus_scope = Utils\get_flag_value( $assoc_args, 'scope' );
$this->focus_hook = WP_CLI\Utils\get_flag_value( $assoc_args, 'hook' ); $this->focus_hook = Utils\get_flag_value( $assoc_args, 'hook' );
if ( ! isset( \WP_CLI::get_runner()->config['url'] ) ) { if ( ! isset( WP_CLI::get_runner()->config['url'] ) ) {
WP_CLI::add_wp_hook( 'muplugins_loaded', function(){ WP_CLI::add_wp_hook( 'muplugins_loaded', function(){
WP_CLI::set_url( home_url( '/' ) ); WP_CLI::set_url( home_url( '/' ) );
}); });