0

When I activate my plugin, I need to call an API, to get some items, lets say fruits, flowers and animals. I need to create taxonomy terms out of these items. Then I need to loop over these items and make API calls to get some children items per item, like fruits - Apple, Banana, Guava etc., flowers - Rose, Lily, Jasmine etc. I need to create children terms out of these children items. Later some more API calls will be added to the code, to get data for each child item and create custom posts from them. Currently I am doing it on plugin activation. But it looks like the plugin activation is slowing down due to so much processing. Is there a better place or hook to do these activities? Can I use init to perform some API calls which can be suspended for a later time?

0

on the plugin activation hook, instead of doing everything right there just set a cron job that will do it.

  • A cron job is in discussion for updating the data in the future, since the data provider will have new data daily. How can I use a cron job and ensure that all my data is present when the site is accessed immediately after the plugin is activated? – Rutwick Gangurde Aug 31 '15 at 10:35
  • You can use a one time scheduled event with codex.wordpress.org/Function_Reference/wp_schedule_single_event firing it when the plugin activation hook is done setting the minimal most have settings. At the end of this one time event you can schedule a recurring event which only update whatever is needed. – Mark Kaplun Aug 31 '15 at 12:32
  • Please let me check it. – Rutwick Gangurde Aug 31 '15 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.