Fix/elayne Woocommerce Function Guards#93
Merged
Conversation
…al errors Wraps all WooCommerce-specific function calls in functions.php with function_exists() checks so the theme works safely on sites without WooCommerce installed. Bumps version to 4.6.2.
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.
This release adds defensive
function_exists()guards around all WooCommerce-specific function calls infunctions.phpto prevent fatal errors when the Elayne theme is activated on WordPress sites that do not have WooCommerce installed. Without these guards, calls to WooCommerce conditional functions such asis_shop(),is_product_category(), andwc_get_product()trigger PHP fatal errors on non-WooCommerce installations. The fix ensures graceful degradation by checking function availability before invocation, allowing the theme to operate safely in both WooCommerce and non-WooCommerce environments. The version is bumped to 4.6.2 across all version-tracked files.WooCommerce Function Guards:
function_exists()checks aroundis_shop(),is_product_category(), andis_product_tag()in the category filter drawer enqueue logic, preventing script registration failures on non-WooCommerce sitesis_product()andwc_get_product()calls in the product structured data function with existence checks, adding early returns when functions are unavailableWC()exists andWC()->structured_datais set before callinggenerate_product_data(), preventing null reference errorsVersion and Release Updates:
style.cssandreadme.txtstable tagCHANGELOG.md(Keep a Changelog format) andreadme.txt(WordPress format) documenting all guard additionsFiles Changed:
CHANGELOG.md(Modified)functions.php(Modified)readme.txt(Modified)style.css(Modified)