perf: explicit option autoload flags (closes #22)#43
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates OutPost’s option creation/upgrade flow to set explicit autoload behavior so only front-end–needed options are loaded in alloptions, reducing unnecessary option loading overhead.
Changes:
- Adds explicit autoload groupings and applies them on activation and during
maybe_upgrade(). - Switches default option seeding from
update_option()toadd_option(..., $autoload)to set autoload at creation time. - Bumps the internal schema/version option to
1.2.0and extends upgrade logic to include option autoload tuning.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+32
| /** Options that are read on the front end and should autoload. */ | ||
| const AUTOLOAD_YES = [ | ||
| 'outpost_branding_text', | ||
| 'outpost_branding_url', | ||
| 'outpost_cache_duration', | ||
| 'outpost_brand_account', | ||
| ]; | ||
|
|
||
| /** Options only read in admin/cron and should NOT autoload. */ | ||
| const AUTOLOAD_NO = [ | ||
| 'outpost_digest_send_hour', | ||
| 'outpost_digest_send_minute', | ||
| 'outpost_from_name', | ||
| 'outpost_from_email', | ||
| 'outpost_posts_per_digest', | ||
| 'outpost_digest_batch_size', | ||
| 'outpost_double_optin', | ||
| 'outpost_manage_page_id', | ||
| 'outpost_db_version', | ||
| 'outpost_show_setup_wizard', | ||
| ]; |
Front-end-read options autoload; admin/cron-only options do not. Fresh installs seed via add_option() with the right autoload; existing installs migrate once via wp_set_options_autoload() in maybe_upgrade() (db version bumped to 1.2.0). Co-Authored-By: Claude Opus 4.8 <[email protected]>
609cdee to
6008313
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4. Closes #22.
What
All plugin options were created without an explicit autoload value, so they all loaded on every request. Now:
yes: branding text/url, cache duration, brand account.no: send hour/minute, from name/email, posts-per-digest, batch size, double opt-in, manage page id, db version, setup-wizard flag.Fresh installs seed via
add_option(..., $autoload); existing installs migrate once viawp_set_options_autoload()inmaybe_upgrade()(db version bumped to1.2.0). No behavior change for admins.Verify
On an existing install, after a page load: the admin-only option keys are no longer in
wp_load_alloptions()(or check theautoloadcolumn). Front-end feed/branding still render with no extra queries.Closes #22
🤖 Generated with Claude Code