diff --git a/js/crm.payment.js b/js/crm.payment.js index 2b07ab6b992dc252d25f0885beb4eb14cc05db56..e104b2fe887be2b44905c6e157c65a0c0ca3df32 100644 --- a/js/crm.payment.js +++ b/js/crm.payment.js @@ -285,10 +285,11 @@ // /civicrm/payment/form? occurs when a payproc is selected on page // /civicrm/contact/view/participant occurs when payproc is first loaded on event credit card payment // On wordpress these are urlencoded - return (url.match("civicrm(\/|%2F)payment(\/|%2F)form") !== null) || - (url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") !== null) || - (url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)membership") !== null) || - (url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)contribution") !== null); + var basePage = CRM.config.isFrontend ? CRM.vars.payment.basePage : 'civicrm'; + return (url.match(basePage + "(\/|%2F)payment(\/|%2F)form") !== null) || + (url.match(basePage + "(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") !== null) || + (url.match(basePage + "(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)membership") !== null) || + (url.match(basePage + "(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)contribution") !== null); }, /** diff --git a/mjwshared.php b/mjwshared.php index 6fc911163fbbcad64eebd14bdbf99c54b12de35e..7f0458afc1837d4bbd5c4f8b213c01ad18c6baa1 100644 --- a/mjwshared.php +++ b/mjwshared.php @@ -261,8 +261,19 @@ function mjwshared_civicrm_buildForm($formName, &$form) { return; } + // On Wordpress frontend we may have a different basePage (eg. mysite.com/mycrm/contribute/transact) + // CRM.payment.isAJAXPaymentForm requires the basePage to compare URLs. + $basePage = 'civicrm'; + if (CRM_Core_Config::singleton()->userFramework === 'WordPress') { + $wpBasePage = \Civi::settings()->get('wpBasePage'); + if (!empty($wpBasePage)) { + $basePage = $wpBasePage; + } + } + $jsVars = [ 'jsDebug' => (boolean) \Civi::settings()->get('mjwshared_jsdebug'), + 'basePage' => $basePage, ]; \Civi::resources()->addVars('payment', $jsVars);