Skip to content

Commit

Permalink
Support polylang language prefixes with clean URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Apr 2, 2020
1 parent 7c1ee3f commit eef2749
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion civicrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,19 @@ public function rewrite_rules( $flush_rewrite_rules = false ) {
return;
}

// Let's add rewrite rule when viewing the basepage
// Let's add rewrite rule when viewing the basepage(s)
if ( function_exists( 'pll_languages_list' ) ) {
// Support polylang language prefixes - eg. ^(?:en/|pt/|)
$languages = pll_languages_list();
foreach ( $languages as $language ) {
$postID = pll_get_post( $basepage->ID, $language );
add_rewrite_rule(
"^{$language}/" . $config->wpBasePage . '/([^?]*)?',
'index.php?page_id=' . $postID . '&page=CiviCRM&q=civicrm%2F$matches[1]',
'top'
);
};
}
add_rewrite_rule(
'^' . $config->wpBasePage . '/([^?]*)?',
'index.php?page_id=' . $basepage->ID . '&page=CiviCRM&q=civicrm%2F$matches[1]',
Expand Down

0 comments on commit eef2749

Please sign in to comment.