Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Commit edf0993

Browse files
committed
fixes #343 by reducing frequency of coupon load
- coupon id cache doesn’t need to be read on every admin screen, only the polylang strings table screen - coupon ids don’t need to be cached per language
1 parent 51898f9 commit edf0993

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Hyyan/WPI/Coupon.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,13 @@ public function translateMessage($value, $coupon)
138138
public function adminRegisterCouponStrings()
139139
{
140140
if (is_admin() && (!is_ajax())) {
141-
$this->registerCouponStringsForTranslation();
141+
global $pagenow;
142+
if ( ($pagenow) && ( $pagenow == 'admin.php' ) && ($_GET[ 'page' ] == 'mlang_strings') ) {
143+
$this->registerCouponStringsForTranslation();
144+
}
142145
}
143-
}
146+
}
147+
144148
/**
145149
* Register coupon titles adn descriptions in Polylang's Strings translations table.
146150
*/
@@ -198,8 +202,7 @@ private function getCoupons()
198202
{
199203
global $woocommerce;
200204

201-
$locale = (function_exists('pll_current_language')) ? pll_current_language('locale') : get_locale();
202-
$tKey = 'coupons-' . $locale;
205+
$tKey = 'coupons-ids';
203206

204207
$coupon_ids = get_transient($tKey);
205208
if ($coupon_ids) {

0 commit comments

Comments
 (0)