Plugin Dev: update_option from JS script?
-
What’s the best way to get/set an option from within an enqueued JS script?
My best guess to
setis to create a WP REST Route that sets/updates the option. I saw an SO answer from 2013 that said I could send a POST toadmin-ajax.phpto a handler I define, but I’m not sure if that’s out of date, or which is preferable.For getting an option, should I use
wp_localize_script/wp_add_inline_script? Is it worth setting up another REST endpoint to fetch the option?Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Plugin Dev: update_option from JS script?’ is closed to new replies.