Snippets: Make All Multi-site Sites use the Main Site Customizer Settings & Custom CSS

// Set current site to use main site Customizer Settings
function myprefix_apply_main_site_settings() {

	if ( ! is_multisite() ) {
		return; // not a multisite
	}

	// get global theme mods
	global $wpex_theme_mods;

	// switch to main site
	switch_to_blog( get_network()->site_id );

	// Get main site theme mods
	$main_mods = get_theme_mods();

	// Switch back to current site
	restore_current_blog();

	// Set current theme mods to equal the mods of the main site.
	$wpex_theme_mods = $main_mods;
	
}
add_action( 'after_setup_theme', 'myprefix_apply_main_site_settings', 0 ); // priority of 0 is important here

// Filter Custom CSS to also grab any custom CSS from the main site
function myprefix_apply_main_site_custom_css_to_all_sites( $css ) {

	if (  ! is_multisite() ) {
		return $css; // not a multisite
	}

	// switch to main site
	switch_to_blog( get_network()->site_id );
 	
 	// Get main site custom css
    $post     = wp_get_custom_css_post( get_stylesheet() );
	$main_css = $post ? $post->post_content : '';

	// Switch back to current site
	restore_current_blog();

	// Return current site CSS + Main site CSS
	return $css . $main_css;

}
add_filter( 'wp_get_custom_css', 'myprefix_apply_main_site_custom_css_to_all_sites' );

// Hide Customizer settings.
add_filter( 'pre_option_wpex_customizer_panels', '__return_empty_array', 9999 );

// Disable customizer manager panel
add_action( 'after_setup_theme', function() {
	global $wpex_theme_mods;
	$wpex_theme_mods['customizer_panel_enable'] = false;
	add_filter( 'wpex_theme_addons', function( $addons ) {
		unset( $addons['customizer_panel'] );
		unset( $addons['customizer_manager'] );
		return $addons;
	} );
}, 0 );
All PHP snippets should be added via a child theme's functions.php file.