New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: for options page - ability to autoload=false for options #1093
Comments
In // If no override, update the option
return update_option( $this->key, $this->options ); Either a filter there (the easiest path), that will allow to add a 3rd param to |
Added a filter, and parameter on options-page boxes toggles the filter. Please test: https://github.com/CMB2/CMB2/compare/options-autoload-feature |
@jtsternberg I've tested the PR. Switching from |
@slaFFik can you provide your code that you tested with? |
Also, you are right. It will not switch the autoload value in the DB after the first time it is inserted. If you want to test switching, you will need to actually delete the option from the database first. |
Default code from https://github.com/CMB2/CMB2-Snippet-Library/blob/master/options-and-settings-pages/options-pages-with-tabs-and-submenus.php snippet (100% the same) + add_filter( 'cmb2_should_autoload_test_main_options', '__return_true' ); //_false or
|
Using this update_option( 'test_test', time(), true ); // false actually udpates autoload |
Just remember, that So the bug in the commit is that you default to In short, you need to always pass the boolean no matter what, instead of a |
Ok, good feedback, thank you. Updated. Please test again? |
Looks good, tests for both filter and param for all scenarios passed fine when There will be a problem with Thank you for this feature! |
…emantics of the core parameters. Re: #1093
Expected Behavior:
When creating an options page using
\new_cmb2_box()
give ability to define theautoloader
, so devs could define that those options should NOT be autoloaded.As a developer, you know the drawbacks of
autoload=yes
.Actual Behavior:
currently it defaults to
yes
Steps to reproduce (I have confirmed I can reproduce this issue on the trunk branch):
Use the https://github.com/CMB2/CMB2-Snippet-Library/blob/master/options-and-settings-pages/options-pages-with-tabs-and-submenus.php snippet and save options.
The text was updated successfully, but these errors were encountered: