+ /**
+ * Get the URL of the WordPress Base Page.
+ *
+ * @return string|bool
+ * The Base Page URL, or false on failure.
+ */
+ public function getBasePageUrl() {
+ static $basepage_url = '';
+ if ($basepage_url === '') {
+
+ // Get the Base Page config setting.
+ $config = CRM_Core_Config::singleton();
+ $basepage_slug = $config->wpBasePage;
+
+ // Did we get a value?
+ if (!empty($basepage_slug)) {
+
+ // Query for our Base Page.
+ $pages = get_posts([
+ 'post_type' => 'page',
+ 'name' => strtolower($basepage_slug),
+ 'post_status' => 'publish',
+ 'posts_per_page' => 1,
+ ]);
+
+ // Find the Base Page object and set the URL.
+ if (!empty($pages) && is_array($pages)) {
+ $basepage = array_pop($pages);
+ if ($basepage instanceof WP_Post) {
+ $basepage_url = get_permalink($basepage->ID);
+ }
+ }
+
+ }
+
+ }
+
+ return $basepage_url;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getNotifyUrl(
+ $path = NULL,
+ $query = NULL,
+ $absolute = FALSE,
+ $fragment = NULL,
+ $frontend = FALSE,
+ $forceBackend = FALSE,
+ $htmlize = TRUE
+ ) {
+ $config = CRM_Core_Config::singleton();
+ $separator = '&';
+ $fragment = isset($fragment) ? ('#' . $fragment) : '';
+ $path = CRM_Utils_String::stripPathChars($path);
+ $queryParts = [];
+
+ // Get the Base Page URL.
+ $base = $this->getBasePageUrl();
+
+ // If not using Clean URLs.
+ if (!$config->cleanURL) {
+
+ // Build URL according to pre-existing logic.
+ if (!empty($path)) {
+ $queryParts[] = 'civiwp=CiviCRM';
+ $queryParts[] = 'q=' . rawurlencode($path);
+ }
+ if (!empty($query)) {
+ $queryParts[] = $query;
+ }
+
+ // Append our query parts, taking Permlink Structure into account.
+ if (get_option('permalink_structure') == '') {
+ $final = $base . $separator . implode($separator, $queryParts) . $fragment;
+ }
+ else {
+ $final = $base . '?' . implode($separator, $queryParts) . $fragment;
+ }
+
+ }
+ else {
+
+ // Build Clean URL.
+ if (!empty($path)) {
+ $base = trailingslashit($base) . str_replace('civicrm/', '', $path) . '/';
+ }
+ if (!empty($query)) {
+ $query = ltrim($query, '=?&');
+ $queryParts[] = $query;
+ }
+
+ if (!empty($queryParts)) {
+ $final = $base . '?' . implode($separator, $queryParts) . $fragment;
+ }
+ else {
+ $final = $base . $fragment;
+ }
+
+ }
+
+ return $final;
+ }
+