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

Commit

Permalink
fixes #343 by reducing frequency of coupon load
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
Jon007 committed Aug 19, 2018
1 parent 51898f9 commit edf0993
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Hyyan/WPI/Coupon.php
Expand Up @@ -138,9 +138,13 @@ public function translateMessage($value, $coupon)
public function adminRegisterCouponStrings()
{
if (is_admin() && (!is_ajax())) {
$this->registerCouponStringsForTranslation();
global $pagenow;
if ( ($pagenow) && ( $pagenow == 'admin.php' ) && ($_GET[ 'page' ] == 'mlang_strings') ) {
$this->registerCouponStringsForTranslation();
}
}
}
}

/**
* Register coupon titles adn descriptions in Polylang's Strings translations table.
*/
Expand Down Expand Up @@ -198,8 +202,7 @@ private function getCoupons()
{
global $woocommerce;

$locale = (function_exists('pll_current_language')) ? pll_current_language('locale') : get_locale();
$tKey = 'coupons-' . $locale;
$tKey = 'coupons-ids';

$coupon_ids = get_transient($tKey);
if ($coupon_ids) {
Expand Down

0 comments on commit edf0993

Please sign in to comment.