Hook mainwp_sitestable_item called too often? By design? (want to add custom data to Sitestable)

Hello,
I’m trying to use this example to add several additional custom columns to the sitetable:

I inserted debugging output like this:

 if (is_array($website_info) && isset($website_info['wpversion'])) {
	 customwp_logs($item['name']); // site name
     $item['wpversion'] = $website_info['wpversion'];

And I’m surprised that this is called 7 times when the site table is refreshed in the browser.

The data to display has to be fetched from an external API. So I would fetch it 7 times which would be overkill :slight_smile:

Is this by design or is there an easy way to prevent it?
If there is no workaround I’ll have to find a solution to “cache” the results somehow…

Thank you for any hints or pointers,
Bye
Sven

Hey @svenni

I’ve checked with the development team, and this is by design. It is being called 7 times because the sites table has 7 columns.

You can prevent it from being called that many times by using these hooks which will get the sites’ data as cached data:
mainwp_sitestable_prepared_items
mainwp_sitestable_website

Amazing! Thank you very much for the fast answer.

One question though: How “old” means “cached”?
Will it have the “fresh data from the last client sync”?
(that would be important :slight_smile:

Thank you!

Sorry, another related question:
I’ve found the documentation for the first hook mentioned:

(so I can give it a try)
but I was not able to find documentation for the second hook? Do I need to check this in the source code? :innocent:

Thanks!

The data is memory cached, so the next request will load the fetch the data again.

We’ve just made a documentation page for this hook. It’s available at:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.