Skip to content

Fix/elayne Woocommerce Function Guards#93

Merged
jasperf merged 1 commit into
mainfrom
fix/elayne-woocommerce-function-guards
Jun 19, 2026
Merged

Fix/elayne Woocommerce Function Guards#93
jasperf merged 1 commit into
mainfrom
fix/elayne-woocommerce-function-guards

Conversation

@jasperf

@jasperf jasperf commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

This release adds defensive function_exists() guards around all WooCommerce-specific function calls in functions.php to 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 as is_shop(), is_product_category(), and wc_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:

  • Added function_exists() checks around is_shop(), is_product_category(), and is_product_tag() in the category filter drawer enqueue logic, preventing script registration failures on non-WooCommerce sites
  • Wrapped is_product() and wc_get_product() calls in the product structured data function with existence checks, adding early returns when functions are unavailable
  • Added validation that WC() exists and WC()->structured_data is set before calling generate_product_data(), preventing null reference errors

Version and Release Updates:

  • Bumped version from 4.6.1 to 4.6.2 in style.css and readme.txt stable tag
  • Added changelog entry in both CHANGELOG.md (Keep a Changelog format) and readme.txt (WordPress format) documenting all guard additions

Files Changed:

…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.
@jasperf jasperf merged commit d703482 into main Jun 19, 2026
3 checks passed
@jasperf jasperf deleted the fix/elayne-woocommerce-function-guards branch June 19, 2026 23:45
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