michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
340 stars 71 forks source link

Suppress submission of data to wp-options table. #110

Closed pcraig3 closed 10 years ago

pcraig3 commented 10 years ago

Even when inserting form values into a custom database, the wp_options table is still updated. It would be ideal if there were an easy way to cancel submitting a form's values to wp_options table.

michaeluno commented 10 years ago

Will adding a method like disableSavingOptions() be sufficient? (If there is a better method name, let me know.)

Or you may like to just pass an empty string '' to the first parameter of the constructor so that the framework considers that the user does not want to save any option to the options table. But this might be confusing as currently the default value is null and if null is passed, the instantiated class name is used as the option key.

Let me know if you have a better idea.

pcraig3 commented 10 years ago

Initially, I was thinking that there could be a way to specify into which table to insert/update/delete values, but on reflection I don't think that makes too much sense. The WordPress Settings API doesn't use raw database queries, so I very much doubt there's really a place to specify a different table name and/or query to run instead of the default.

Your initial option is probably the simplest. Running a custom query once the form values have been validated makes sense to me, so adding a method to disable the autosave option at the top level would suit me just fine.

michaeluno commented 10 years ago

Updated the development version 3.1.0b. Download: https://github.com/michaeluno/admin-page-framework/archive/3.1.0b.zip

I added the both methods. You may call the disableSavingOptions() method in the setUp() method or just pass an empty string '' to the constructor's first parameter. Let me know if one of them is not necessary.

Initially, I was thinking that there could be a way to specify into which table to insert/update/delete values,

Ah, there is no means with the framework to do that. Sorry.

michaeluno commented 10 years ago

On second thought, I feel the method is redundant and passing an empty string to the constructor is just sufficient.

michaeluno commented 10 years ago

This can be tested with the file which can be downloaded in the link (3.1.0b) posted previously.

Also posted an example script on Gist. https://gist.github.com/michaeluno/fcfac27825aa8a35b90f