public function run() {
		WP_CLI::add_wp_hook(
			'muplugins_loaded',
			function() {
				if ( $url = WP_CLI::get_runner()->config['url'] ) {
					WP_CLI::set_url( trailingslashit( $url ) );
				} else {
					WP_CLI::set_url( home_url( '/' ) );
				}
			}
		);
		WP_CLI::add_hook(
			'after_wp_config_load',
			function() {
				if ( defined( 'SAVEQUERIES' ) && ! SAVEQUERIES ) {
					WP_CLI::error( "'SAVEQUERIES' is defined as false, and must be true. Please check your wp-config.php" );
				}
				if ( ! defined( 'SAVEQUERIES' ) ) {
					define( 'SAVEQUERIES', true );
				}
			}
		);
		if ( 'hook' === $this->type
			&& ':before' === substr( $this->focus, -7, 7 ) ) {
			$stage_hooks = array();
			foreach ( $this->stage_hooks as $hooks ) {
				$stage_hooks = array_merge( $stage_hooks, $hooks );
			}
			$end_hook = substr( $this->focus, 0, -7 );
			$key      = array_search( $end_hook, $stage_hooks );
			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 );
		} elseif ( 'hook' === $this->type
			&& ':after' === substr( $this->focus, -6, 6 ) ) {
			$start_hook = substr( $this->focus, 0, -6 );
			WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 );
		} else {
			WP_CLI::add_wp_hook( 'all', array( $this, 'wp_hook_begin' ) );
		}
		WP_CLI::add_wp_hook( 'pre_http_request', array( $this, 'wp_request_begin' ) );
		WP_CLI::add_wp_hook( 'http_api_debug', array( $this, 'wp_request_end' ) );
		$this->load_wordpress_with_template();
	}
public function run() {
		WP_CLI::add_wp_hook(
			'muplugins_loaded',
			function() {
				if ( $url = WP_CLI::get_runner()->config['url'] ) {
					WP_CLI::set_url( trailingslashit( $url ) );
				} else {
					WP_CLI::set_url( home_url( '/' ) );
				}
			}
		);
		WP_CLI::add_hook(
			'after_wp_config_load',
			function() {
				if ( defined( 'SAVEQUERIES' ) && ! SAVEQUERIES ) {
					WP_CLI::error( "'SAVEQUERIES' is defined as false, and must be true. Please check your wp-config.php" );
				}
				if ( ! defined( 'SAVEQUERIES' ) ) {
					define( 'SAVEQUERIES', true );
				}
			}
		);
		if ( 'hook' === $this->type
			&& ':before' === substr( $this->focus, -7, 7 ) ) {
			$stage_hooks = array();
			foreach ( $this->stage_hooks as $hooks ) {
				$stage_hooks = array_merge( $stage_hooks, $hooks );
			}
			$end_hook = substr( $this->focus, 0, -7 );
			$key      = array_search( $end_hook, $stage_hooks );
			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 );
		} elseif ( 'hook' === $this->type
			&& ':after' === substr( $this->focus, -6, 6 ) ) {
			$start_hook = substr( $this->focus, 0, -6 );
			WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 );
		} else {
			WP_CLI::add_wp_hook( 'all', array( $this, 'wp_hook_begin' ) );
		}
		WP_CLI::add_wp_hook( 'pre_http_request', array( $this, 'wp_request_begin' ) );
		WP_CLI::add_wp_hook( 'http_api_debug', array( $this, 'wp_request_end' ) );
		$this->load_wordpress_with_template();
	}
public function run ( ) { WP_CLI :: add_wp_hook ( 'muplugins_loaded' , function ( ) { if ( $ url = WP_CLI :: get_runner ( ) -> config [ 'url' ] ) { WP_CLI :: set_url ( trailingslashit ( $ url ) ) ; } else { WP_CLI :: set_url ( home_url ( '/' ) ) ; } } ) ; WP_CLI :: add_hook ( 'after_wp_config_load' , function ( ) { if ( defined ( 'SAVEQUERIES' ) && ! SAVEQUERIES ) { WP_CLI :: error ( "'SAVEQUERIES' is defined as false, and must be true. Please check your wp-config.php" ) ; } if ( ! defined ( 'SAVEQUERIES' ) ) { define ( 'SAVEQUERIES' , true ) ; } } ) ; if ( 'hook' === $ this -> type && ':before' === substr ( $ this -> focus , - 7 , 7 ) ) { $ stage_hooks = array ( ) ; foreach ( $ this -> stage_hooks as $ hooks ) { $ stage_hooks = array_merge ( $ stage_hooks , $ hooks ) ; } $ end_hook = substr ( $ this -> focus , 0 , - 7 ) ; $ key = array_search ( $ end_hook , $ stage_hooks ) ; 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 ) ; } elseif ( 'hook' === $ this -> type && ':after' === substr ( $ this -> focus , - 6 , 6 ) ) { $ start_hook = substr ( $ this -> focus , 0 , - 6 ) ; WP_CLI :: add_wp_hook ( $ start_hook , array ( $ this , 'wp_tick_profile_begin' ) , 9999 ) ; } else { WP_CLI :: add_wp_hook ( 'all' , array ( $ this , 'wp_hook_begin' ) ) ; } WP_CLI :: add_wp_hook ( 'pre_http_request' , array ( $ this , 'wp_request_begin' ) ) ; WP_CLI :: add_wp_hook ( 'http_api_debug' , array ( $ this , 'wp_request_end' ) ) ; $ this -> load_wordpress_with_template ( ) ; }
Run the profiler against WordPress
Run the profiler against WordPress