From 37c421741524bba6839757957c13eb9703bc6d35 Mon Sep 17 00:00:00 2001 From: Arjun Singh Saluja Date: Sat, 27 Sep 2025 23:29:41 +0530 Subject: [PATCH] Enhancement: Show plugin cards when external requests fail (#2189) --- .../plugin-management/plugin-management.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 plugins/performance-lab/modules/plugin-management/plugin-management.php diff --git a/plugins/performance-lab/modules/plugin-management/plugin-management.php b/plugins/performance-lab/modules/plugin-management/plugin-management.php new file mode 100644 index 0000000000..3650bb5af0 --- /dev/null +++ b/plugins/performance-lab/modules/plugin-management/plugin-management.php @@ -0,0 +1,71 @@ +No plugins found.

'; + return; + } + + echo '
'; + foreach ( $all_plugins as $plugin_path => $plugin_data ) { + echo '
'; + echo '

' . esc_html( $plugin_data['Name'] ) . '

'; + if ( ! empty( $plugin_data['Version'] ) ) { + echo '

Version: ' . esc_html( $plugin_data['Version'] ) . '

'; + } + if ( ! empty( $plugin_data['Description'] ) ) { + echo '

' . esc_html( $plugin_data['Description'] ) . '

'; + } + echo '
'; + } + echo '
'; + + return; + } + + // ✅ If external request is successful, render normal data + $body = wp_remote_retrieve_body( $response ); + $data = json_decode( $body, true ); + + if ( ! empty( $data['plugins'] ) ) { + echo '
'; + foreach ( $data['plugins'] as $plugin ) { + echo '
'; + echo '

' . esc_html( $plugin['name'] ?? 'Unknown Plugin' ) . '

'; + if ( ! empty( $plugin['version'] ) ) { + echo '

Version: ' . esc_html( $plugin['version'] ) . '

'; + } + if ( ! empty( $plugin['short_description'] ) ) { + echo '

' . esc_html( $plugin['short_description'] ) . '

'; + } + echo '
'; + } + echo '
'; + } else { + echo '

No plugin data found.

'; + } +} +add_action( 'admin_notices', 'performance_lab_render_plugin_cards' );