Skip to content
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

Explicitly set autoload value for options #9392

Closed
moorscode opened this issue Mar 30, 2018 · 2 comments
Closed

Explicitly set autoload value for options #9392

moorscode opened this issue Mar 30, 2018 · 2 comments

Comments

@moorscode
Copy link
Contributor

moorscode commented Mar 30, 2018

The update_options used the following classes need to be configured explicitly:

WPSEO_Option: autoload = true

WPSEO_GSC_Count: autoload = false
WPSEO_Onpage_Option: autoload = false
WPSEO_Taxonomy_Meta: autoload = false

See: https://codex.wordpress.org/Function_Reference/update_option

Whether to load the option when WordPress starts up. For existing options $autoload can only be updated using update_option() if $value is also changed. Accepts 'yes' or true to enable, 'no' or false to disable. For non-existent options, the default value is 'yes'.
Default: null

Configuring these autoload settings will reduce the memory usage on the front-end, as the GSC, Onpage and Taxonomy Meta are not needed on most page requests for the actual site user.

Implementing this is literally setting the 3rd argument of the function call.

Related call:

add_option( $option, $value, $deprecated, $autoload );

But this can only be used if the option does not exist yet, update_option will create the option if it does not exist yet or update it if the value is different from the current value.

@IreneStr
Copy link
Contributor

Please provide more context on how to implement and what the use case is.

@moorscode
Copy link
Contributor Author

A sniff is in the making to detect this automatically. Resolving the problems from that sniff can be done when it is released and bumped.

Yoast/yoastcs#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants