@@ -145,7 +145,7 @@ public function settings_page() {
145145
146146 foreach ( $ plugins as $ key => $ plugin ) {
147147 $ slug = $ this ->get_plugin_slug ( $ key );
148- $ cache = self :: get_report ( $ slug );
148+ $ cache = $ this -> get_report ( $ slug );
149149 if ( $ cache ) {
150150 // Use the cached report to create a table row.
151151 echo $ this ->render_table_row ( $ cache );
@@ -783,7 +783,7 @@ public function upgrade_delete_cache_items( $upgrader, $data ) {
783783 *
784784 * @return array|null Report data array, or null if the slug is empty or not found.
785785 */
786- public static function get_report ( $ slug ) {
786+ public function get_report ( $ slug ) {
787787 if ( empty ( $ slug ) ) {
788788 return null ;
789789 }
@@ -793,15 +793,14 @@ public static function get_report( $slug ) {
793793 require_once ABSPATH . 'wp-admin/includes/plugin-install.php ' ;
794794 }
795795
796- $ instance = new self ();
797- $ cache_key = $ instance ->create_cache_key ( $ slug );
796+ $ cache_key = $ this ->create_cache_key ( $ slug );
798797 $ cache = get_site_transient ( $ cache_key );
799798
800799 if ( ! empty ( $ cache ) ) {
801800 return $ cache ;
802801 }
803802
804- return $ instance ->assemble_plugin_report ( $ slug );
803+ return $ this ->assemble_plugin_report ( $ slug );
805804 }
806805
807806 }
@@ -814,9 +813,10 @@ public static function get_report( $slug ) {
814813 /**
815814 * Public API: get Plugin Report data for a plugin.
816815 *
817- * Convenience wrapper around RT_Plugin_Report::get_report(). Returns cached
818- * data when available, otherwise fetches fresh data from the wordpress.org API
819- * and caches it. Safe to call from any plugin — if Plugin Report is not active
816+ * Convenience wrapper around RT_Plugin_Report::get_report(). Uses a static
817+ * instance to avoid repeated object creation. Returns cached data when
818+ * available, otherwise fetches fresh data from the wordpress.org API and
819+ * caches it. Safe to call from any plugin — if Plugin Report is not active
820820 * or the slug is invalid, returns null.
821821 *
822822 * Example usage:
@@ -833,6 +833,10 @@ public static function get_report( $slug ) {
833833 * @return array|null Report data array, or null if not available.
834834 */
835835 function plugin_report_get_data ( $ slug ) {
836- return RT_Plugin_Report::get_report ( $ slug );
836+ static $ plugin_report = null ;
837+ if ( null === $ plugin_report ) {
838+ $ plugin_report = new RT_Plugin_Report ();
839+ }
840+ return $ plugin_report ->get_report ( $ slug );
837841 }
838842}
0 commit comments