*/ public function get_output() { $output = array(); /** @var QM_Data_HTTP $data */ $data = $this->collector->get_data(); if ( empty( $data->http ) ) { return $output; } $requests = array(); foreach ( $data->http as $http ) { $stack = array(); foreach ( $http['filtered_trace'] as $item ) { $stack[] = $item['display']; } $requests[] = array( 'url' => $http['url'], 'method' => $http['args']['method'], 'response' => ( $http['response'] instanceof WP_Error ) ? $http['response']->get_error_message() : $http['response']['response'], 'time' => round( $http['ltime'], 4 ), 'stack' => $stack, ); } $output['total'] = count( $requests ); $output['time'] = round( $data->ltime, 4 ); $output['requests'] = $requests; return $output; } } /** * @param array $output * @param QM_Collectors $collectors * @return array */ function register_qm_output_raw_http( array $output, QM_Collectors $collectors ) { $collector = QM_Collectors::get( 'http' ); if ( $collector ) { $output['http'] = new QM_Output_Raw_HTTP( $collector ); } return $output; } add_filter( 'qm/outputter/raw', 'register_qm_output_raw_http', 30, 2 );