Skip to content

Commit

Permalink
Create base page on every site on which CiviCRM is activated
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwach committed Nov 25, 2020
1 parent 712ddf2 commit e13fed3
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions includes/civicrm.basepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,37 @@ private function create_basepage($slug) {
// If multisite, switch to main site.
if (is_multisite() && !is_main_site()) {

// Store this site.
$original_site = get_current_blog_id();
/**
* Allow plugins to override the switch to the main site.
*
* This filter changes the default behaviour on WordPress Multisite so
* that the base page *is* created on every site on which CiviCRM is
* activated. This is a more sensible and inclusive default, since the
* absence of the base page on a sub-site often leads to confusion.
*
* To restore the previous functionality, return boolean TRUE.
*
* The previous functionality may be the desired behaviour when the
* WordPress Multisite instance in question is one where sub-sites aren't
* truly "separate" e.g. sites built on frameworks such as "Commons in
* a Box" or "MultilingualPress".
*
* @since 5.33
*
* @param bool False by default prevents the switch to the main site.
* @return bool Return true to enable the switch to the main site.
*/
$switch = apply_filters('civicrm_basepage_main_site_only', FALSE);

if ($switch !== FALSE) {

// Store this site.
$original_site = get_current_blog_id();

// Switch.
global $current_site;
switch_to_blog($current_site->blog_id);
// Switch to main site.
switch_to_blog(get_main_site_id());

}

}

Expand Down

0 comments on commit e13fed3

Please sign in to comment.