Skip to content

fix(settings): guard apply_filters call for early initialization#26

Open
vdrnn wants to merge 2 commits intomainfrom
fix/settings-apply-filters-guard
Open

fix(settings): guard apply_filters call for early initialization#26
vdrnn wants to merge 2 commits intomainfrom
fix/settings-apply-filters-guard

Conversation

@vdrnn
Copy link
Contributor

@vdrnn vdrnn commented Dec 12, 2025

Summary

  • Guard apply_filters() call with function_exists() check in get_default_settings()
  • Allows the method to be called before WordPress loads (e.g., in Bedrock's config/application.php)
  • Enables Acorn/Bedrock projects to dynamically read MilliCache defaults without hardcoding values
  • Fully backward compatible - filter still works when WordPress is loaded

Test plan

  • Tested calling get_default_settings() from Bedrock application.php (before WordPress loads)
  • Verified filter hook still works in normal WordPress context
  • Confirmed all default values preserved exactly

Allow get_default_settings() to be called before WordPress loads by checking
if apply_filters() exists before using it. This enables Bedrock/Acorn projects
to dynamically read MilliCache defaults in config/application.php without
requiring hardcoded values.
Add defined() checks for DAY_IN_SECONDS and MONTH_IN_SECONDS to prevent
errors when get_default_settings() is called before WordPress loads its
constants (e.g., in Bedrock's application.php).

Fallback values: 86400 (1 day), 2592000 (30 days)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant