' . esc_html__( 'Contracts', 'ai-eshop-optimizer' ) . '';
echo '
' . esc_html__( 'Theme:', 'ai-eshop-optimizer' ) . ' ' . esc_html( implode( ', ', $theme_contracts ) ) . '
';
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$rooster = [ 'rooster-lms', 'rooster-lms-pro', 'ai-eshop-optimizer', 'ai-eshop-optimizer-pro', 'ai-eshop-optimizer-runtime', 'rooster-lti', 'woocommerce' ];
$rows = [];
foreach ( get_plugins() as $file => $plugin ) {
$dir = dirname( $file );
if ( ! in_array( $dir, $rooster, true ) || ! is_plugin_active( $file ) ) {
continue;
}
$header = get_file_data( WP_PLUGIN_DIR . '/' . $file, [ 'contracts' => 'Rooster Contracts' ] );
$rows[] = [
'_id' => $dir,
'plugin' => (string) $plugin['Name'],
'version' => (string) $plugin['Version'],
'contracts' => '' !== (string) $header['contracts'] ? (string) $header['contracts'] : [ 'html' => '' . esc_html__( 'none declared', 'ai-eshop-optimizer' ) . '' ],
];
}
\Rooster\Admin\Markup::out( \Rooster\Admin\Ui::table(
[
[ 'key' => 'plugin', 'label' => __( 'Active plugin', 'ai-eshop-optimizer' ) ],
[ 'key' => 'version', 'label' => __( 'Version', 'ai-eshop-optimizer' ), 'width' => 'xs' ],
[ 'key' => 'contracts', 'label' => __( 'Rooster Contracts', 'ai-eshop-optimizer' ), 'type' => 'code' ],
],
$rows,
[
'id' => 'rooster-status-contracts',
'caption' => __( 'The contracts of the active plugins', 'ai-eshop-optimizer' ),
'empty' => esc_html__( 'No Rooster plugin is active.', 'ai-eshop-optimizer' ),
'cards' => true,
]
) );
echo '' . esc_html__( 'Loading policy', 'ai-eshop-optimizer' ) . '
';
printf( '- %s: %s
', esc_html__( 'Device variants', 'ai-eshop-optimizer' ), rooster_setting( 'performance', 'device_variants', true ) ? esc_html__( 'on', 'ai-eshop-optimizer' ) : esc_html__( 'off', 'ai-eshop-optimizer' ) );
printf( '- %s: %s
', esc_html__( 'Deferred layer', 'ai-eshop-optimizer' ), rooster_setting( 'performance', 'defer', true ) ? esc_html__( 'on', 'ai-eshop-optimizer' ) : esc_html__( 'off', 'ai-eshop-optimizer' ) );
printf( '- %s: %s
', esc_html__( 'Speculative loading', 'ai-eshop-optimizer' ), esc_html( (string) rooster_setting( 'performance', 'speculation', 'moderate' ) ) );
printf( '- %s: %s
', esc_html__( 'Third parties', 'ai-eshop-optimizer' ), esc_html( (string) rooster_setting( 'performance', 'third_party', 'delay' ) ) );
printf( '- %s:
%s ', esc_html__( 'Modules loaded on this admin request', 'ai-eshop-optimizer' ), esc_html( implode( ', ', array_keys( array_filter( \Rooster\Core\Modules::loaded() ) ) ) ?: '-' ) );
echo '
';
echo '' . esc_html__( 'Footprint', 'ai-eshop-optimizer' ) . '
';
printf( '%s %s %s
', esc_html__( 'Open the front page with the footprint flag and view the page source:', 'ai-eshop-optimizer' ), esc_url( add_query_arg( 'rooster_footprint', '1', home_url( '/' ) ) ), esc_html( home_url( '/?rooster_footprint=1' ) ), esc_html__( 'The report is the last HTML comment (theme files, handles, modules, plugin file counts, notices). The build runs tools/footprint.mjs against it.', 'ai-eshop-optimizer' ) );
$last = get_option( 'rooster_perf_last' );
echo '' . esc_html__( 'Last measured scores', 'ai-eshop-optimizer' ) . '
';
if ( is_array( $last ) && ! empty( $last['results'] ) ) {
$rows = [];
foreach ( (array) $last['results'] as $i => $r ) {
$rows[] = [
'_id' => (string) $i,
'url' => (string) ( $r['url'] ?? '' ),
'device' => (string) ( $r['device'] ?? '' ),
'perf' => (int) ( $r['scores']['performance'] ?? 0 ),
'a11y' => (int) ( $r['scores']['accessibility'] ?? 0 ),
'bp' => (int) ( $r['scores']['best-practices'] ?? 0 ),
'seo' => (int) ( $r['scores']['seo'] ?? 0 ),
];
}
$score = static fn ( string $key, string $label ): array => [ 'key' => $key, 'label' => $label, 'type' => 'num', 'width' => 'xs', 'group' => __( 'Scores', 'ai-eshop-optimizer' ) ];
\Rooster\Admin\Markup::out( \Rooster\Admin\Ui::table(
[
[ 'key' => 'url', 'label' => __( 'URL', 'ai-eshop-optimizer' ) ],
[ 'key' => 'device', 'label' => __( 'Device', 'ai-eshop-optimizer' ), 'width' => 'xs' ],
$score( 'perf', __( 'Perf', 'ai-eshop-optimizer' ) ),
$score( 'a11y', __( 'A11y', 'ai-eshop-optimizer' ) ),
$score( 'bp', __( 'BP', 'ai-eshop-optimizer' ) ),
$score( 'seo', __( 'SEO', 'ai-eshop-optimizer' ) ),
],
$rows,
[
'id' => 'rooster-status-scores',
'caption' => __( 'The last measured scores', 'ai-eshop-optimizer' ),
'sticky_first' => true,
]
) );
printf( '%s %s
', esc_html__( 'Measured:', 'ai-eshop-optimizer' ), esc_html( (string) ( $last['generated'] ?? '' ) ) );
} else {
echo '' . esc_html__( 'No matrix imported yet (wp rooster perf import , from WP7).', 'ai-eshop-optimizer' ) . '
';
}
}
}