Last active
October 24, 2016 11:40
-
-
Save foliovision/86835e70c0062481d708 to your computer and use it in GitHub Desktop.
Profile Builder - make the custom avatars global for WP Multisite
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 | |
if( is_multisite() && function_exists('switch_to_blog') ) { | |
add_filter( 'get_avatar', 'fv_pb_global_avatar_start', 20, 5 ); | |
add_filter( 'get_avatar', 'fv_pb_global_avatar_end', 22, 5 ); | |
function fv_pb_global_avatar_start( $avatar ) { | |
switch_to_blog(1); | |
return $avatar; | |
} | |
function fv_pb_global_avatar_end($avatar) { | |
restore_current_blog(); | |
$avatar = preg_replace( "~src='.*?/wp-content~", "src='/wp-content", $avatar ); | |
return $avatar; | |
} | |
} | |
add_action( 'current_screen', 'fv_wppb_upload_to_master_blog', 0 ); | |
function fv_wppb_upload_to_master_blog() { | |
if ( isset($_REQUEST['action']) && 'upload-attachment' == $_REQUEST['action'] && isset($_REQUEST['wppb_upload']) && 'true' == $_REQUEST['wppb_upload'] ) { | |
switch_to_blog(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment