Commit c2cc8c08 authored by haystack's avatar haystack

Respect the CIVICRM_CLEANURL constant

parent c5bc2eeb
......@@ -607,33 +607,56 @@ class CiviCRM_For_WordPress {
*/
public function register_hooks_common() {
// Register user hooks
// Register user hooks.
$this->users->register_hooks();
// If CiviCRM is installed, we can use clean URLs.
if ( CIVICRM_INSTALLED ) {
// Register hooks for clean URLs.
$this->register_hooks_clean_urls();
}
// Have we flushed rewrite rules?
if ( get_option( 'civicrm_rules_flushed' ) !== 'true' ) {
// Apply custom rewrite rules, then flush rules afterwards
$this->rewrite_rules( true );
/**
* Register hooks to handle Clean URLs.
*
* @since 5.12
*/
public function register_hooks_clean_urls() {
// Set a one-time-only option to flag that this has been done
add_option( 'civicrm_rules_flushed', 'true' );
// Bail if CiviCRM is not installed.
if (!CIVICRM_INSTALLED) {
return;
}
} else {
// Bail if we can't initialize CiviCRM.
if (!$this->initialize()) {
return;
}
// Apply custom rewrite rules normally
$this->rewrite_rules();
// Bail if CiviCRM is not using clean URLs.
if (!defined('CIVICRM_CLEANURL') || CIVICRM_CLEANURL !== 1) {
return;
}
}
// Have we flushed rewrite rules?
if ( get_option( 'civicrm_rules_flushed' ) !== 'true' ) {
// Add our query vars
add_filter( 'query_vars', array( $this, 'query_vars' ) );
// Apply custom rewrite rules, then flush rules afterwards.
$this->rewrite_rules( true );
// Set a one-time-only option to flag that this has been done.
add_option( 'civicrm_rules_flushed', 'true' );
} else {
// Apply custom rewrite rules normally.
$this->rewrite_rules();
}
// Add our query vars.
add_filter( 'query_vars', array( $this, 'query_vars' ) );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment