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

fix(compat): resolve conflict with Polylang plugin #2784

Closed
Benunc opened this issue Feb 7, 2018 · 6 comments
Closed

fix(compat): resolve conflict with Polylang plugin #2784

Benunc opened this issue Feb 7, 2018 · 6 comments
Assignees
Milestone

Comments

@Benunc
Copy link
Member

Benunc commented Feb 7, 2018

Issue Overview

The Polylang plugin languages revert to English on switching between payment gateways.

Expected Behavior

If the language for a form is set at the form level, switching between payment gateways should not trigger a different language.

Current Behavior

polylang

Steps to Reproduce (for bugs)

On Local By Flywheel:

  1. Download this zip file, and drag/drop it onto local by flywheel. https://drive.google.com/file/d/1lxJLvFbfWyk0T3ikZnzzLAEhfBIJWksh/view?usp=sharing
  2. Log into the site with username ben and password 1
  3. Navigate to http://polylang.local/fr/donations/french/
  4. toggle between the donation forms.

Or the long way:

  1. Install Give and polylang. ( https://wordpress.org/plugins/polylang/ )
  2. Set up two languages, english and French in the polylang settings.
  3. create two forms, one in each language. Make the second one a translation of the first.
  4. Navigate to the French version.
  5. switch the payment gateway.

WordPress Environment

### WordPress Environment ###

Home URL: http://polylang.local
Site URL: http://polylang.local
WP Version: 4.9.4
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
Permalink Structure: /%postname%/
Show on Front: posts
Table Prefix Length: wp_
Table Prefix Length: 3
Table Prefix Status: Acceptable
Admin AJAX: Accessible
Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, refunded, failed, revoked, cancelled, abandoned, processing, preapproval

Server Environment

Hosting Provider: DBH: localhost, SRV: polylang.local
TLS Connection: Connection uses TLS 1.2
TLS Connection: Probably Okay
Server Info: Apache/2.4.10 (Debian)
PHP Version: 7.1.4
PHP Post Max Size: 1,000 MB
PHP Time Limit: 900
PHP Max Input Vars: 3000
PHP Max Upload Size: 1,000 MB
cURL Version: ❌ 7.38.0, OpenSSL/1.0.1t - We recommend a minimum cURL version of 7.40.
SUHOSIN Installed: –
MySQL Version: 5.6.34
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
gzip: ✔
GD Graphics Library: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Give Configuration

Give Version: 2.0.2
Give Cache: Enabled
Database Updates: All DB Updates Completed.
Give Cache: Enabled
Give Cache: ✔New Donation✔Donation Receipt✔New Offline Donation✔Offline Donation Instructions✔New User Registration✔User Registration Information✔Email access
Upgraded From: –
Test Mode: Enabled
Currency Code: USD
Currency Position: Before
Decimal Separator: .
Thousands Separator: ,
Success Page: http://polylang.local/donation-confirmation/
Failure Page: http://polylang.local/donation-failed/
Donation History Page: http://polylang.local/donation-history/
Give Forms Slug: /donations/
Enabled Payment Gateways: Test Donation, Offline Donation
Default Payment Gateway: Test Donation
PayPal IPN Verification: Enabled
PayPal IPN Notifications: N/A
Donor Email Access: Enabled

Session Configuration

Give Use Sessions: Enabled
Session: Disabled

Active Give Add-ons

Other Active Plugins

Polylang: by Frédéric Demarle – 2.3

Inactive Plugins

Theme

Name: Twenty Seventeen
Version: 1.4
Author URL: https://wordpress.org/
Child Theme: No – If you're modifying Give on a parent theme you didn't build personally, then we recommend using a child theme. See: How to Create a Child Theme

@Benunc
Copy link
Member Author

Benunc commented Feb 7, 2018

I did find that hard-coding a snippet like this "fixes" it:

function my_give_text_switcher( $translations, $text, $domain ) {
		if ( get_locale() === 'fr_FR' ) {
			if ( $domain == 'give' && $text == 'First Name' ) {
				$translations = __( 'Prénom', 'give' );
			}
		}
		return $translations;
	}

add_filter( 'gettext', 'my_give_text_switcher', 10, 3 );

But obviously having to hardcode all the French strings in the ajaxified fields is not a good solution.

@ravinderk
Copy link
Collaborator

ravinderk commented Feb 13, 2018

@DevinWalker Bumping up this issue because we need to do research on polylang plugin to fix the issue.

@ravinderk ravinderk modified the milestones: 2.0.3, 2.0.4 Feb 13, 2018
@DevinWalker DevinWalker modified the milestones: 2.0.4, 2.0.5 Feb 17, 2018
@kevinwhoffman kevinwhoffman changed the title fix: resolve conflict with polylang plugin fix(compat): resolve conflict with Polylang plugin Feb 21, 2018
@raftaar1191
Copy link
Contributor

Slack Call Summary

Participants: @raftaar1191, @ravinderk
Topic: What Can be Done to fixed this
Result: Had an call with @ravinderk to decision what we can do to fixed this issue, Other then chaining the priority of the hook.

@raftaar1191
Copy link
Contributor

raftaar1191 commented Feb 23, 2018

My finding for the above issues

Polylang used plugin_load hook to load his file and the priority of the hook is setup 1

add_action( 'plugins_loaded', array( $this, 'init' ), 1 );

Give load all it file class and text domain with the same hook but the priority is set is 0

add_action( 'plugins_loaded', array( $this, 'init' ), 0 );

So here you can see the Give load it text domain before the Polylang load so that was the reason it was not working.

then I had a test on how WooCommerce does it and then I come to know it load all it function class before the plugin_load hook but it load the text_domain in init hooks which fire after the plugins_loaded so there was no issues as the Text Domain is getting load after the Polylang functions are loaded so it can easily check and update for the post language

@DevinWalker
Copy link
Member

@ravinderk can we do the same as Woo and increase our compatibility?

DevinWalker pushed a commit that referenced this issue Feb 24, 2018
fix(compat): Change hook that load give text domain #2784
@DevinWalker
Copy link
Member

Got my answer on the PR.

DevinWalker added a commit that referenced this issue Feb 28, 2018
* release/2.1: (38 commits)
  fix(dashboard-widget): incorrect stat for this year #2847
  fix(cache): typo in text domain
  fix(cache): typo in function name
  fix(compat): resolve caching conflict with W3TC
  fix(form): #2838
  fix(compat): Change hook that load give text domain #2784
  style(code): improve formatting
  fix(form): sanitize default minimum amount
  fix(donation): Change Minimum Amount to 1.0 if empty  #2819
  fix(phpcs): Fix phpcs error #2819
  refactor(donation): Remove unwanted condition check #2819
  fix(donation): Fix amount format #2819
  fix(donation): Fix minimum donation amount check #2819
  refactor(import-settings): use core functions and sanitize $_POST
  feat(export): Make checkbox fields for export checked by default
  feat(export): Add feature to selectively export fields
  fix(media-uploads): upload file to correct folder
  fix(cache): prevent possible cache  conflict on multisite
  fix(db): use get_offset fn instead of repeatable logic
  style(db):improve code formatting
  ...
DevinWalker added a commit that referenced this issue Feb 28, 2018
* release/2.1: (39 commits)
  fix(dashboard-widget): incorrect stat for this year #2847
  fix(cache): typo in text domain
  fix(cache): typo in function name
  feat(admin-plugin): Add Give menu in plugin menu section #2278
  fix(compat): resolve caching conflict with W3TC
  fix(form): #2838
  fix(compat): Change hook that load give text domain #2784
  style(code): improve formatting
  fix(form): sanitize default minimum amount
  fix(donation): Change Minimum Amount to 1.0 if empty  #2819
  fix(phpcs): Fix phpcs error #2819
  refactor(donation): Remove unwanted condition check #2819
  fix(donation): Fix amount format #2819
  fix(donation): Fix minimum donation amount check #2819
  refactor(import-settings): use core functions and sanitize $_POST
  feat(export): Make checkbox fields for export checked by default
  feat(export): Add feature to selectively export fields
  fix(media-uploads): upload file to correct folder
  fix(cache): prevent possible cache  conflict on multisite
  fix(db): use get_offset fn instead of repeatable logic
  ...
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

No branches or pull requests

4 participants