I have a small and growing collection of code fragments for things that should only be executed once. For example, a one-time pass that adds information to every taxonomy term.

As of now, I have been keeping them in theme/function files, commenting them in or out when needed to run.

Instead, I'd like to move to a situation where I, the admin, could just execute them by a button press.

What should I explore in order to build a plugin which gives me an admin page with a few buttons on, corresponding to my code fragments? How should I think about making buttons that make the code run?

I have use of ACF.

  • 1
    A way to start looking into could be an Ajax request to a function you have defined on php. Or an api fetch to a rest route. – Alvaro Dec 2 '18 at 23:12
  • Learn how to add an admin page, then add your buttons to it. Start here developer.wordpress.org/reference/functions/add_menu_page – shanebp Dec 3 '18 at 23:21
  • Then learn how to submit a form on a button click in wp-admin - lots of examples on web. – shanebp Dec 3 '18 at 23:21

Your Answer

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

Browse other questions tagged or ask your own question.