I'm developing a custom plugin, which requires input of authentication data for a remote API, and this data needs to be saved. I want to encrypt it before saving to db.
I've added a settings page, containing:
<form method="post" action="options.php">
<!-- form fields here... -->
</form>
Rather than having each option saved as a different entry in {wp_table_prefix}_options
table, I want them saved as an object in only one row, so the name
attributes are of this type:
<input name="plugin-slug[option-key]" ...>
The question is fairly simple: what is the proper way to encrypt the data before saving it in db? I'd like to hash the entire object and I'm going to decrypt it back after get_option('plugin-slug')
.
Is there a default method to filter the sent request to options.php
, before saving it in db? I haven't been able to find anything on the topic or an example that already does it. It's hard to believe nobody needed something similar before.
I also tried finding a filter or action called inside into options.php but, as you can see, it has a fairly convoluted logic and some backwards compatibility code... I was hoping there's a more straight-forward way of doing it than pinning toothpicks into options.php
.