Skip to content

Commit 726e133

Browse files
committed
Add stats for active plugins
1 parent 75d435a commit 726e133

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

classes/rest/class-stats.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ public function get_stats( \WP_REST_Request $request ) {
175175

176176
$data['plugin_url'] = \esc_url( \get_admin_url( null, 'admin.php?page=progress-planner' ) );
177177

178+
$active_plugins = \get_option( 'active_plugins' );
179+
$data['plugins'] = [];
180+
foreach ( $active_plugins as $plugin ) {
181+
$plugin_data = \get_plugin_data( \WP_PLUGIN_DIR . '/' . $plugin );
182+
$data['plugins'][] = [
183+
'plugin' => $plugin,
184+
'name' => $plugin_data['Name'] ?? 'N/A', // @phpstan-ignore-line nullCoalesce.offset
185+
'version' => $plugin_data['Version'] ?? 'N/A', // @phpstan-ignore-line nullCoalesce.offset
186+
];
187+
}
188+
178189
return new \WP_REST_Response( $data );
179190
}
180191

0 commit comments

Comments
 (0)