collector->get_data(); if ( empty( $data->types ) || empty( $data->times ) ) { return; } $total_time = 0; $this->before_tabular_output(); echo ''; echo ''; echo '' . esc_html__( 'Component', 'query-monitor' ) . ''; foreach ( $data->types as $type_name => $type_count ) { echo ''; echo $this->build_sorter( $type_name ); // WPCS: XSS ok; echo ''; } echo ''; echo $this->build_sorter( __( 'Time', 'query-monitor' ) ); // WPCS: XSS ok; echo ''; echo ''; echo ''; echo ''; foreach ( $data->times as $row ) { $total_time += $row['ltime']; echo ''; echo ''; echo self::build_filter_trigger( 'db_queries', 'component', $row['component'], esc_html( $row['component'] ) ); // WPCS: XSS ok; foreach ( $data->types as $type_name => $type_count ) { if ( isset( $row['types'][ $type_name ] ) ) { echo '' . esc_html( number_format_i18n( $row['types'][ $type_name ] ) ) . ''; } else { echo ' '; } } echo '' . esc_html( number_format_i18n( $row['ltime'], 4 ) ) . ''; echo ''; } echo ''; echo ''; $total_stime = number_format_i18n( $total_time, 4 ); echo ''; echo ' '; foreach ( $data->types as $type_name => $type_count ) { echo '' . esc_html( number_format_i18n( $type_count ) ) . ''; } echo '' . esc_html( $total_stime ) . ''; echo ''; echo ''; $this->after_tabular_output(); } /** * @param array $menu * @return array */ public function panel_menu( array $menu ) { /** @var QM_Data_DB_Components $data */ $data = $this->collector->get_data(); if ( empty( $data->types ) || empty( $data->times ) ) { return $menu; } /** @var QM_Collector_DB_Queries|null $dbq */ $dbq = QM_Collectors::get( 'db_queries' ); if ( $dbq ) { /** @var QM_Data_DB_Queries $dbq_data */ $dbq_data = $dbq->get_data(); if ( ! empty( $dbq_data->component_times ) ) { $menu['qm-db_queries']['children'][] = $this->menu( array( 'title' => esc_html__( 'Queries by Component', 'query-monitor' ), ) ); } } return $menu; } } /** * @param array $output * @param QM_Collectors $collectors * @return array */ function register_qm_output_html_db_components( array $output, QM_Collectors $collectors ) { $collector = QM_Collectors::get( 'db_components' ); if ( $collector ) { $output['db_components'] = new QM_Output_Html_DB_Components( $collector ); } return $output; } add_filter( 'qm/outputter/html', 'register_qm_output_html_db_components', 40, 2 );