Skip to content

Instantly share code, notes, and snippets.

@aaroneaton
Created September 13, 2011 14:32
Show Gist options
  • Save aaroneaton/1213938 to your computer and use it in GitHub Desktop.
Save aaroneaton/1213938 to your computer and use it in GitHub Desktop.
WP:Share WP media libraries across multisite network
<?php
// Add filter that inserts our new tab
function nsm_menu($tabs) {
$newtab = array('shared_media' => __('Network Shared Media', 'networksharedmedia'));
return array_merge($tabs, $newtab);
}
add_filter('media_upload_tabs', 'nsm_menu');
// Load media_nsm_process() into the existing iframe
function nsm_menu_handle() {
return wp_iframe('media_nsm_process');
}
add_action('media_upload_shared_media', 'nsm_menu_handle');
/*
* media_nsm_process() contains the code for what you want to display. This function MUST start with the word 'media' in order
* for the proper CSS to load.
*
* First, we switch to the blog containing all of the media. This is called up by the blog # found in the database.
*
* Then we call media_upload_library() which contains all of the code needed to show the library, select media sizes, and
* insert into the post.
*/
function media_nsm_process() {
switch_to_blog(3);
media_upload_library();
}
?>
@mkormendy
Copy link

I realize this is 6 years old .. but I wanted to let anyone know that this doesn't work anymore for WP 4.0+ if they came across this GIST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment