Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes _doing_it_wrong() messages being displayed on WordPress 6.7 due to translating too early #3616

Merged
merged 5 commits into from
Nov 22, 2024

Conversation

mattallan
Copy link
Contributor

@mattallan mattallan commented Nov 21, 2024

Fixes #3604

Related P2: peNR48-111-p2

Changes proposed in this Pull Request:

After updating to WordPress 6.7, stores using our Stripe extension and have WP_Debug enabled will start seeing the following _doing_it_wrong notices across WP Admin pages:

image

In WordPress 6.7, they changed the way translations are loaded which affects how and when translation strings should be triggered. With this change, any __() code called before the after_setup_theme is considered "too early" and will need to be updated to happen on a later hook.

Part of the challenge with Stripe is that the entire plugin is inited on the 'plugins_loaded' hook (which is before after_setup_theme):

add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );

Digging through all of the files and classes included/initiated WC_Stripe->init() I found the following issues within Stripe:

  • WC_Stripe_Privacy translated strings in the __construct(). Fixed in a4b1be2
  • WC_Stripe_Settings_Controller was being instantiated with passing get_main_stripe_gateway() as the second parameter. This function builds the main Stripe gateway class which translates a bunch of strings. 5b88b55
  • load_plugin_textdomain() was being called on plugins_loaded, this should happen on init 0361256

Testing instructions

To confirm the bug:

  1. Make sure define( 'WP_DEBUG', true ); is set in wp-config
  2. Update to the latest WordPress 6.7
  3. Go to your Edit User Profile page and update the language to Español
    image

There are two key areas of Stripe that these changes impact:

1. Privacy erasers/exporters

  1. Go to WP Admin > Tools > Export personal data
  2. Enter your email and manually download your personal data
  3. Download and open zip -> index.html file
  4. Under Customer Data heading, confirm "Stripe payment id" exists

2. Settings Controller

  1. Go to WooCommerce > Settings > Payments > Stripe
  2. Confirm no issues with loading the settings

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@mattallan mattallan requested review from a team and wjrosa and removed request for a team November 21, 2024 05:37
Copy link
Contributor

@wjrosa wjrosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is good and works as expected:

Under Customer Data heading, confirm "Stripe payment id" exists

Screenshot 2024-11-21 at 13 05 59

Confirm no issues with loading the settings

Screenshot 2024-11-21 at 13 07 14

@mattallan mattallan merged commit a4e0bf6 into develop Nov 22, 2024
33 of 35 checks passed
@mattallan mattallan deleted the fix/3604-wp-6.7-compatibility branch November 22, 2024 02:07
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.

WordPress 6.7 Compatibility - Translations triggered too early
2 participants