Skip to content

fix: compatibility with WordPress 7.0 and PHP 8.4+#76

Draft
joshuapregua wants to merge 1 commit intodevelopfrom
joshua/fix-wp7.0
Draft

fix: compatibility with WordPress 7.0 and PHP 8.4+#76
joshuapregua wants to merge 1 commit intodevelopfrom
joshua/fix-wp7.0

Conversation

@joshuapregua
Copy link
Copy Markdown
Contributor

Summary

Fixes four deprecations that cause fatal errors or silent failures on WordPress 7.0 and PHP 8.4. No logic, hooks, or user-facing behaviour is changed — deprecation fixes only.


Changes

1. Remove deprecated load_plugin_textdomain() path arguments

File: genesis-connect-woocommerce.php

- load_plugin_textdomain( 'gencwooc', false, GCW_DIR . '/languages' );
+ load_plugin_textdomain( 'gencwooc' );

The $deprecated and $plugin_rel_path arguments were deprecated in WP 6.7 and removed in WP 7.0. WordPress now auto-discovers plugin translations from wp-content/languages/plugins/.

2. Remove pass-by-reference on $woocommerce object (fatal on PHP 8.4)

- remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
+ remove_filter( 'template_include', array( $woocommerce, 'template_loader' ) );

Using & on an object is meaningless since PHP 5 (objects are passed by handle). It was deprecated in PHP 8.0 and is fatal in PHP 8.4. Without this fix, WooCommerce's template_loader is never removed from template_include, causing double-rendered shop pages on the frontend (/shop/, /product/*, /product-category/*).

3. Replace is_plugin_active() with class/function existence checks

- if ( ! function_exists( 'is_plugin_active' ) ) {
-     require_once ABSPATH . '/wp-admin/includes/plugin.php';
- }
- if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
+ if ( ! class_exists( 'WooCommerce' ) ) {

- if ( is_plugin_active( 'genesis-simple-sidebars/plugin.php' ) ) {
+ if ( function_exists( 'ss_do_sidebar' ) ) {

- if ( is_plugin_active( 'genesis-simple-menus/simple-menu.php' ) ) {
+ if ( class_exists( 'Genesis_Simple_Menus' ) ) {

4. Replace removed woocommerce_get_template_part() with wc_get_template_part()

- woocommerce_get_template_part( 'loop', 'shop' );  // ×2 in legacy compat functions
+ wc_get_template_part( 'loop', 'shop' );

woocommerce_get_template_part() was removed in WooCommerce 2.1 (current minimum is 3.3). Also fixes gencwooc_get_template_part() which accessed $woocommerce->template_url — a property also removed in WC 2.1 — making it silently non-functional. Now delegates directly to wc_get_template_part().

Testing

Environment needed: WordPress 7.0, PHP 8.4, WooCommerce ≥ 3.3, any Genesis child theme.

Enable debug logging in wp-config.php

Test Expected result
Visit /shop/ Products render inside Genesis layout — no double wrapper, no fatal
Visit /product/any-product/ Single product renders inside Genesis layout
Visit /product-category/any-category/ Archive renders inside Genesis layout
Deactivate WooCommerce, visit admin "WooCommerce required" notice shown — no fatal
Deactivate Genesis Simple Sidebars No error, integration silently skipped
Check wp-content/debug.log Zero deprecation notices related to this plugin

- Remove deprecated load_plugin_textdomain() path args (WP 6.7 deprecated, WP 7.0 removed)
- Remove pass-by-reference on $woocommerce object (fatal on PHP 8.4+)
- Replace is_plugin_active() calls with class_exists()/function_exists() (premature timing on after_setup_theme)
- Replace removed woocommerce_get_template_part() with wc_get_template_part()
- Fix gencwooc_get_template_part() which relied on removed $woocommerce->template_url property (WC 2.1+)
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