Skip to content

Instantly share code, notes, and snippets.

@msaari
Created March 21, 2019 08:00
Show Gist options
  • Select an option

  • Save msaari/f2d461d3f18c6bd4ac7efe3b8f250c8f to your computer and use it in GitHub Desktop.

Select an option

Save msaari/f2d461d3f18c6bd4ac7efe3b8f250c8f to your computer and use it in GitHub Desktop.
Multisite fixes for Relevanssi and WP 5.1
<?php
// In /lib/install.php, replace the relevanssi_new_blog() function with this:
function relevanssi_new_blog( $blog ) {
if ( is_int( $blog ) ) {
$blog_id = $blog;
} else {
$blog_id = $blog->id;
}
if ( is_plugin_active_for_network( 'relevanssi-premium/relevanssi.php' ) || is_plugin_active_for_network( 'relevanssi/relevanssi.php' ) ) {
switch_to_blog( $blog_id );
_relevanssi_install();
restore_current_blog();
}
}
/*
In relevanssi.php, remove the line:
add_action( 'wpmu_new_blog', 'relevanssi_new_blog', 10, 1 );
and add this:
*/
global $wp_version;
if ( version_compare( $wp_version, '5.1', '>=' ) ) {
add_action( 'wp_insert_site', 'relevanssi_new_blog', 10, 1 );
} else {
add_action( 'wpmu_new_blog', 'relevanssi_new_blog', 10, 1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment