*/ private static function page_choices() { $posts = get_posts( array( 'post_type' => array( 'page', 'post' ), 'post_status' => 'publish', 'numberposts' => 15, 'orderby' => 'date', 'order' => 'DESC', ) ); $choices = array(); foreach ( $posts as $post ) { $title = '' !== trim( (string) $post->post_title ) ? $post->post_title : __( '(no title)', '360-orbit-speed-optimizer' ); $choices[] = array( 'url' => (string) get_permalink( $post ), 'title' => wp_html_excerpt( $title, 60, '…' ), ); } return $choices; } /* ---------------------------------------------------------------- */ /* Ergebnis (Frontend) */ /* ---------------------------------------------------------------- */ /** * Analyse einer gespeicherten Messung. * * @param string $slot "home" oder "page". * @param array $measurement * @return array Ergebnis von Advisor::analyze(). */ public static function analyze( $slot, array $measurement ) { $environment = Wp360_Speed_Optimizer_Doctor_Environment::collect(); if ( 'home' !== $slot ) { // Eine einzelne Seite bekommt nur die Teile der Umgebung, die zu ihr gehoeren // (Faehigkeit der .htaccess, Seiten-Cache-Plugin); Autoload, PHP usw. gelten // der ganzen Website und stehen beim Ergebnis der Startseite. $environment = array_intersect_key( $environment, array_flip( array( 'can_write_htaccess', 'page_cache_plugin', 'heartbeat_throttled', 'plugins_active', 'css_js_revalidate' ) ) ); } return Wp360_Speed_Optimizer_Doctor_Advisor::for_tier( self::tier() )->analyze( $measurement, $environment ); } /** * Alle gespeicherten Ergebnisse als HTML. * * @return string */ public static function results_html() { $results = Wp360_Speed_Optimizer_Doctor_Runner::results(); if ( array() === $results ) { return '

' . esc_html__( 'No check yet. Click "Start check" to see how your site is doing.', '360-orbit-speed-optimizer' ) . '

'; } $html = ''; foreach ( array( 'home', 'page' ) as $slot ) { if ( isset( $results[ $slot ]['measurement'] ) && is_array( $results[ $slot ]['measurement'] ) ) { $html .= self::slot_html( $slot, $results[ $slot ] ); } } return $html; } /** * @param array{time:int,measurement:array} $result */ private static function slot_html( $slot, array $result ) { $m = Wp360_Speed_Optimizer_Doctor_Measurement::normalize( $result['measurement'] ); $analysis = self::analyze( $slot, $m ); $dismiss = Wp360_Speed_Optimizer_Doctor_Dismissals::filter( $analysis['findings'], get_option( self::DISMISS_OPTION, array() ), time() ); ob_start(); ?>

' . esc_html( '' !== $m['url'] ? $m['url'] : '/' ) . '', esc_html( Wp360_Speed_Optimizer_Doctor_Page::format_time( (int) $result['time'] ) ) ); ?>

  • ms
  • 0 ? esc_html( number_format_i18n( $m['ttfb_ms'] ) ) . ' ms' : '–'; ?>
$status ) { ?>

    $ms ) { ?>

>,hidden:list>} $split * @param array $analysis * @param bool $with_top Die "drei wichtigsten Schritte" zeigen? */ private static function findings_html( array $split, array $analysis, $with_top ) { $visible = $split['visible']; $hidden = $split['hidden']; ob_start(); if ( array() === $visible && array() === $hidden ) { echo '

' . esc_html__( 'Nothing to improve was found in this check. Nice work!', '360-orbit-speed-optimizer' ) . '

'; } $top = array_values( array_filter( Wp360_Speed_Optimizer_Doctor_Advisor::top( $visible ) ) ); if ( $with_top && array() !== $top ) { echo '

' . esc_html__( 'The most important steps', '360-orbit-speed-optimizer' ) . '

    '; foreach ( $top as $finding ) { $text = Wp360_Speed_Optimizer_Doctor_Texts::for_finding( $finding ); echo '
  1. ' . esc_html( $text['title'] ) . '
  2. '; } echo '
'; } if ( array() !== $visible ) { $areas = array_unique( array_column( $visible, 'area' ) ); echo '

' . esc_html__( 'All recommendations', '360-orbit-speed-optimizer' ) . '

'; if ( count( $areas ) > 1 ) { echo '

'; echo ' '; foreach ( $areas as $area ) { echo ' '; } echo '

'; } foreach ( $visible as $finding ) { echo self::card_html( $finding ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } if ( array() !== $hidden ) { echo '
' . esc_html( sprintf( /* translators: %d: number of hidden recommendations */ _n( '%d hidden recommendation', '%d hidden recommendations', count( $hidden ), '360-orbit-speed-optimizer' ), count( $hidden ) ) ) . ''; foreach ( $hidden as $finding ) { $text = Wp360_Speed_Optimizer_Doctor_Texts::for_finding( $finding ); echo '

' . esc_html( $text['title'] ) . ' – ' . esc_html( 'done' === $finding['dismissed'] ? __( 'marked as done', '360-orbit-speed-optimizer' ) : __( 'postponed', '360-orbit-speed-optimizer' ) ) . '

'; } echo '
'; } return (string) ob_get_clean(); } /** * Eine Karte mit dem festen Aufbau: Ueberschrift, Zahl, Warum, Schritte, * Aufwand, Risiko, Wirkung und die moeglichen Schaltflaechen. * * @param array $finding */ private static function card_html( array $finding ) { $text = Wp360_Speed_Optimizer_Doctor_Texts::for_finding( $finding ); $fix = isset( $finding['fix'] ) ? $finding['fix'] : null; $can_fix = null !== $fix && Wp360_Speed_Optimizer_Doctor_Fixes::is_known( $fix ); $cleaner = ! empty( $finding['data']['cleaner_active'] ); $blocked = null === $fix && in_array( $finding['id'], array( 'compression', 'browser_cache' ), true ); ob_start(); ?>

· ·

$m * @param array $analysis */ private static function result_text( array $m, array $analysis ) { $lines = array( sprintf( /* translators: 1: site address, 2: overall rating */ __( 'Performance Doctor – %1$s: %2$s', '360-orbit-speed-optimizer' ), home_url( '/' ), Wp360_Speed_Optimizer_Doctor_Texts::overall_label( $analysis['overall'] ) ), sprintf( /* translators: 1: server time in ms, 2: first byte in ms, 3: number of queries */ __( 'Server time %1$s ms, first byte %2$s ms, %3$s database queries', '360-orbit-speed-optimizer' ), number_format_i18n( $m['server_ms'] ), number_format_i18n( $m['ttfb_ms'] ), number_format_i18n( $m['queries']['count'] ) ), '', ); foreach ( $analysis['findings'] as $finding ) { $text = Wp360_Speed_Optimizer_Doctor_Texts::for_finding( $finding ); $lines[] = '- ' . $text['title'] . ': ' . $text['figures']; } return implode( "\n", $lines ); } /* ---------------------------------------------------------------- */ /* Backend / manuelle Messung */ /* ---------------------------------------------------------------- */ /** * Schalter, Zustand und Anleitung der manuellen Messung. */ public static function capture_box_html() { $until = Wp360_Speed_Optimizer_Doctor_Browser_Capture::active_until(); $entries = Wp360_Speed_Optimizer_Doctor_Browser_Capture::entries(); ob_start(); if ( $until > 0 ) { ?>

true ); $analysis = Wp360_Speed_Optimizer_Doctor_Advisor::for_tier( self::tier() )->analyze( $m, $environment ); $split = Wp360_Speed_Optimizer_Doctor_Dismissals::filter( $analysis['findings'], get_option( self::DISMISS_OPTION, array() ), time() ); $top = null; foreach ( $m['sources'] as $source ) { // Das eigene Plugin (auch die Pro-Variante) ist der Messaufwand, nie der Befund. if ( 'plugin' === $source['type'] && 0 !== strpos( $source['name'], '360-orbit-speed-optimizer' ) ) { $top = $source; break; } } ob_start(); ?>

  • ms

' . esc_html( $summary['slowest']['url'] ) . '', esc_html( number_format_i18n( $summary['slowest']['server_ms'] ) ) ); ?>

' . esc_html( $top['label'] ) . '', esc_html( number_format_i18n( $top['ms'] ) ), esc_html( number_format_i18n( $top['share'] * 100 ) ) ); ?>