Skip to content

Commit

Permalink
Merge pull request #176 from mjwconsult/cleanurls_polylang
Browse files Browse the repository at this point in the history
Support polylang language prefixes with clean URLs
  • Loading branch information
kcristiano authored Apr 2, 2020
2 parents 7c1ee3f + eef2749 commit 7c9df15
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 7c9df15

Please sign in to comment.