Skip to content

Commit

Permalink
=4.2.6.0= ~ fix course query filter with polylang
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhbdphyscode committed Jan 30, 2024
1 parent e302683 commit 7a49d92
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions inc/ExternalPlugin/Polylang/class-lp-polylang.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ public function filter_query_user_courses( LP_User_Items_Filter $filter ): LP_Us
return $filter;
}

if ( $pll_current_lang == pll_default_language() ) {
return $filter;
}

$lp_db = LP_Database::getInstance();

$filter->join[] = "INNER JOIN $lp_db->tb_term_relationships AS r_term ON ui.item_id = r_term.object_id";
$filter->join[] = "INNER JOIN $lp_db->tb_terms AS term ON r_term.term_taxonomy_id = term.term_id";
$filter->where[] = $lp_db->wpdb->prepare( 'AND term.slug = %s', $pll_current_lang );
$filter->join[] = "INNER JOIN $lp_db->tb_term_relationships AS r_term_pll ON ui.item_id = r_term_pll.object_id";
$filter->join[] = "INNER JOIN $lp_db->tb_terms AS pll_terms ON r_term_pll.term_taxonomy_id = pll_terms.term_id";
$filter->where[] = $lp_db->wpdb->prepare( 'AND pll_terms.slug = %s', $pll_current_lang );

return $filter;
}
Expand Down

0 comments on commit 7a49d92

Please sign in to comment.