collector->get_data(); if ( empty( $data->stylesheet ) ) { return; } $this->before_non_tabular_output(); echo '
'; echo '

' . esc_html__( 'Theme', 'query-monitor' ) . '

'; echo '

' . esc_html( $data->stylesheet ) . '

'; if ( self::has_clickable_links() ) { echo '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo self::output_filename( 'style.css', sprintf( '%s/style.css', $data->theme_dirs[ $data->stylesheet ] ), 0, true ); echo '

'; if ( $data->stylesheet_theme_json ) { echo '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo self::output_filename( 'theme.json', $data->stylesheet_theme_json, 0, true ); echo '

'; } } if ( $data->is_child_theme ) { echo '

' . esc_html__( 'Parent Theme', 'query-monitor' ) . '

'; echo '

' . esc_html( $data->template ) . '

'; if ( self::has_clickable_links() ) { echo '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo self::output_filename( 'style.css', sprintf( '%s/style.css', $data->theme_dirs[ $data->template ] ), 0, true ); echo '

'; if ( $data->template_theme_json ) { echo '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo self::output_filename( 'theme.json', $data->template_theme_json, 0, true ); echo '

'; } } } echo '
'; echo '
'; if ( ! empty( $data->block_template ) ) { echo '

' . esc_html__( 'Block Template', 'query-monitor' ) . '

'; if ( $data->block_template->wp_id ) { echo '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo self::build_link( QM_Util::get_site_editor_url( $data->block_template->id, 'wp_template' ), esc_html( $data->block_template->id ) ); echo '

'; } else { if ( self::has_clickable_links() ) { $file = sprintf( '%s/%s/%s.html', $data->theme_dirs[ $data->block_template->theme ], $data->theme_folders[ $data->block_template->type ], $data->block_template->slug ); } else { $file = ''; } echo '

' . self::output_filename( sprintf( '%s/%s.html', $data->theme_folders[ $data->block_template->type ], $data->block_template->slug ), $file, 0, true ) . '

'; // WPCS: XSS ok. } } else { echo '

' . esc_html__( 'Template File', 'query-monitor' ) . '

'; if ( ! empty( $data->template_path ) ) { if ( $data->is_child_theme ) { $display = $data->theme_template_file; } else { $display = $data->template_file; } if ( self::has_clickable_links() ) { $file = $data->template_path; } else { $file = ''; } echo '

' . self::output_filename( $display, $file, 0, true ) . '

'; // WPCS: XSS ok. } else { echo '

' . esc_html__( 'Unknown', 'query-monitor' ) . '

'; } } if ( ! empty( $data->template_hierarchy ) ) { echo '

' . esc_html__( 'Template Hierarchy', 'query-monitor' ) . '

'; echo '
  1. ' . implode( '
  2. ', array_map( 'esc_html', $data->template_hierarchy ) ) . '
'; } echo '
'; echo '
'; echo '

' . esc_html__( 'Template Parts', 'query-monitor' ) . '

'; if ( ! empty( $data->template_parts ) ) { if ( $data->is_child_theme ) { $parts = $data->theme_template_parts; } else { $parts = $data->template_parts; } echo ''; } else { echo '

' . esc_html__( 'None', 'query-monitor' ) . '

'; } if ( ! empty( $data->unsuccessful_template_parts ) ) { echo '

' . esc_html__( 'Not Loaded', 'query-monitor' ) . '

'; echo ''; } echo '
'; if ( ! empty( $data->timber_files ) ) { echo '
'; echo '

' . esc_html__( 'Twig Template Files', 'query-monitor' ) . '

'; echo ''; echo '
'; } if ( ! empty( $data->body_class ) ) { echo '
'; echo '

' . esc_html__( 'Body Classes', 'query-monitor' ) . '

'; echo ''; echo '
'; } $this->after_non_tabular_output(); } /** * @param array $menu * @return array */ public function admin_menu( array $menu ) { /** @var QM_Data_Theme $data */ $data = $this->collector->get_data(); if ( ! empty( $data->block_template ) ) { if ( $data->block_template->wp_id ) { $name = $data->block_template->id; } else { $name = sprintf( '%s/%s.html', $data->theme_folders[ $data->block_template->type ], $data->block_template->slug ); } } elseif ( isset( $data->template_file ) ) { $name = ( $data->is_child_theme ) ? $data->theme_template_file : $data->template_file; } else { $name = __( 'Unknown', 'query-monitor' ); } $menu[ $this->collector->id() ] = $this->menu( array( 'title' => esc_html( sprintf( /* translators: %s: Template file name */ __( 'Template: %s', 'query-monitor' ), $name ) ), ) ); return $menu; } /** * @param array $menu * @return array */ public function panel_menu( array $menu ) { if ( isset( $menu[ $this->collector->id() ] ) ) { $menu[ $this->collector->id() ]['title'] = __( 'Template', 'query-monitor' ); } return $menu; } } /** * @param array $output * @param QM_Collectors $collectors * @return array */ function register_qm_output_html_theme( array $output, QM_Collectors $collectors ) { if ( is_admin() ) { return $output; } $collector = QM_Collectors::get( 'response' ); if ( $collector ) { $output['response'] = new QM_Output_Html_Theme( $collector ); } return $output; } add_filter( 'qm/outputter/html', 'register_qm_output_html_theme', 70, 2 );