Created
March 21, 2019 08:00
-
-
Save msaari/f2d461d3f18c6bd4ac7efe3b8f250c8f to your computer and use it in GitHub Desktop.
Multisite fixes for Relevanssi and WP 5.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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