feat(start.php): add FS__SKIP_LATEST_SDK_LOADING opt-out for early Co… - #824
Closed
DanieleAlessandra wants to merge 2 commits into
Closed
feat(start.php): add FS__SKIP_LATEST_SDK_LOADING opt-out for early Co…#824DanieleAlessandra wants to merge 2 commits into
DanieleAlessandra wants to merge 2 commits into
Conversation
…mposer loads (Bedrock/Altis) When the SDK is autoloaded via Composer before WP finishes bootstrapping (e.g., Bedrock/Altis), the “latest SDK” selection logic can call WP functions that aren’t available yet (e.g. get_theme_root()), causing a fatal. This change introduces a guard that, when FS__SKIP_LATEST_SDK_LOADING is defined and true, skips that logic entirely and exposes a minimal fs_dynamic_init() no-op to avoid undefined-function errors. Details: • Guard placed right after the ABSPATH check in start.php. • If the flag is set, define a stub fs_dynamic_init() and return; early. • Keeps default behavior unchanged for all other environments. • Helps integrators who load the SDK from vendor/ before WP is ready. • Version bumped to 2.12.2.1. Notes: • The constant must be defined before the SDK is loaded (e.g., in wp-config.php or via Composer autoload.files preload in Bedrock). • Follow-up: document usage and caveats.
DanieleAlessandra
marked this pull request as ready for review
September 25, 2025 06:41
… and debug templates
- Added guarded initialization of `$fs` in multiple SDK templates (`form.php`, `retry-skip.php`, `optout.php`, `debug.php`, etc.)
- Replaced direct `freemius($VARS['id'])` calls with conditional checks for `function_exists('freemius')`
- Fallback to `Freemius::get_instance_by_id()` when the helper function is not yet defined
- Added early `return` when `$fs` could not be resolved to prevent fatal errors
# NOTE:
This workaround is **not a viable long-term solution**, as it requires patching numerous template files across the SDK.
It introduces code duplication and increases the risk of maintenance errors.
A centralized solution should be implemented instead (e.g., ensuring `freemius()` is always loaded before rendering templates).
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.
…mposer loads (Bedrock/Altis)
When the SDK is autoloaded via Composer before WP finishes bootstrapping (e.g., Bedrock/Altis), the “latest SDK” selection logic can call WP functions that aren’t available yet (e.g. get_theme_root()), causing a fatal. This change introduces a guard that, when FS__SKIP_LATEST_SDK_LOADING is defined and true, skips that logic entirely and exposes a minimal fs_dynamic_init() no-op to avoid undefined-function errors.
Details:
• Guard placed right after the ABSPATH check in start.php.
• If the flag is set, define a stub fs_dynamic_init() and return; early.
• Keeps default behavior unchanged for all other environments.
• Helps integrators who load the SDK from vendor/ before WP is ready.
• Version bumped to 2.12.2.1.
Notes:
• The constant must be defined before the SDK is loaded (e.g., in wp-config.php or via Composer autoload.files preload in Bedrock).
• Follow-up: document usage and caveats.