Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Communications Dept

Cron Job to update filters

I’m using ACP on a custom post type to allow filter / sort on a few meta fields and run into a not-infrequent scenario where there are newer entries in post meta than show up in the filter for the admin column.

Manually I can resolve by going to the edit columns page, changing one (irrelevant) field setting, save, and change back the field setting and re-save. But as that is an admin only feature, it would be good if the plugin had a daily cron job to re-check the filters and update as happens on column save.

6 years, 3 months ago
Tobias
Developer

Admin Columns uses caching for the filtering dropdown menu. This improves the loading times significantly. The filter dropdown will be recreated every time the cache is flushed. The flushing of cache happends on different occasions:

– Creating, updating or deleting of posts
– Using inline edit
– Creating, editing or deleting a term
– Updating a user
– When admin column settins are updated or stored

A cron job woud not be necessairy I think, as most scenarios for flushing the cache are covered. Or do you have any additions to this list?

Cheers, Tobias

6 years, 3 months ago
Communications Dept

There are two use cases which appear to be missed from that, both when submissions are being driven by plugin rather than user.

In both cases, the only absolutely certain way I have been able to get ACP to show the fields in drop-downs is by your last point, “admin column settins are updated or stored”. If adding a daily cron job is not in scope / consideration, perhaps you can post an example of how another plugin / functions.php file could execute the flush with wp_schedule_event?

Thx!

6 years, 3 months ago
Tobias
Developer

You’re right about the metadata by plugins. The only solution to prevent that would be to hook into update_{type}_metadata, but that means AC has to be loaded on the frontend of a theme aswell, which we do not want.

The cache is being stored in a transient, which automatically expires in 7 days. I have changed this expiration interval to 1 day in v3.5.1. This means the cache will be flushed 24 hours after the last time the cache has been set. This should elimante the use for a cron job, but has almost the same results.

In the next release we’ll also be adding a hook cpac_filtering_clear_cache which you can use to flush the cache manually.

6 years, 2 months ago
Communications Dept

That’s a great balance / approach to solve the issue. Nice way to have both non-developer and plugin-integration experiences supported!

6 years, 2 months ago

You must be logged in to reply to this topic.